/* Operator dashboard, management dialogs and health panels. */
:root {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: #173a47;
    font-synthesis: none;
}
* {
    box-sizing: border-box;
}
body {
    margin: 0;
}
main {
    max-width: 1240px;
    margin: auto;
    padding: 32px;
}
header,
nav,
.section-title,
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}
header {
    padding-bottom: 26px;
    border-bottom: 1px solid #d6e1dd;
}
.brand {
    font-size: 38px;
    font-weight: 750;
    text-decoration: none;
    letter-spacing: -2px;
}
.brand span {
    font-size: 10px;
    letter-spacing: 2px;
    margin-left: 15px;
}
a {
    color: inherit;
}
nav {
    font-size: 14px;
}
.intro {
    padding: 36px 0 16px;
}
.eyebrow {
    font-size: 11px;
    letter-spacing: 2px;
    color: #527669;
    font-weight: 650;
}
h1 {
    font:
        44px Georgia,
        serif;
    margin: 12px 0;
}
h2 {
    font-size: 21px;
    margin: 10px 0;
}
h3 {
    font-size: 15px;
}
.intro > p:last-child,
.muted,
footer {
    color: #667e7b;
    font-size: 14px;
    line-height: 1.6;
}
.metrics {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin: 20px 0 24px;
}
.metrics article {
    background: #e6efea;
    border-radius: 14px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}
.metrics span {
    font-size: 13px;
}
.metrics strong {
    font-size: 36px;
    font-weight: 550;
}
.panel {
    background: white;
    border: 1px solid #dce5df;
    border-radius: 16px;
    padding: 26px;
    margin-bottom: 24px;
}
.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}
svg {
    width: 100%;
    height: auto;
    display: block;
}
rect {
    fill: #48887d;
}
svg text {
    fill: #667e7b;
    font-size: 11px;
}
.table-wrap {
    overflow-x: auto;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    text-align: left;
}
th {
    color: #667e7b;
    font-weight: 550;
    font-size: 12px;
}
th,
td {
    padding: 15px 12px;
    border-bottom: 1px solid #e8eeea;
}
td:first-child,
th:first-child {
    padding-left: 0;
}
td small {
    display: block;
    color: #667e7b;
    margin-top: 5px;
}
td button {
    margin: 3px;
}
button {
    font: inherit;
    font-size: 14px;
    padding: 11px 16px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: #205749;
    color: white;
    cursor: pointer;
}
button:hover:not(:disabled) {
    background: #327461;
}
button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.secondary {
    background: white;
    border-color: #cbd9d2;
    color: #205749;
}
.secondary:hover:not(:disabled) {
    background: #edf4ef;
}
label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 16px 0;
}
input {
    display: block;
    width: 100%;
    padding: 12px;
    margin-top: 8px;
    border: 1px solid #cbd9d2;
    border-radius: 8px;
    font: inherit;
    font-weight: 400;
    background: white;
    color: #173a47;
}
input[type='color'] {
    height: 44px;
    padding: 4px;
}
input:disabled {
    background: #edf1ef;
}
#search {
    max-width: 380px;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
summary:focus-visible {
    outline: 3px solid #60aeb7;
    outline-offset: 3px;
}
dialog {
    max-width: 580px;
    width: calc(100% - 32px);
    max-height: 90vh;
    overflow: auto;
    border: 0;
    border-radius: 16px;
    padding: 26px;
    color: #173a47;
}
dialog::backdrop {
    background: #14372e88;
}
.form-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}
fieldset {
    border: 1px solid #dce5df;
    border-radius: 8px;
    margin: 20px 0;
}
.pagination {
    justify-content: flex-end;
    padding-top: 20px;
}
summary {
    cursor: pointer;
    font-size: 13px;
}
#login {
    max-width: 480px;
}
#status {
    min-height: 20px;
}
#status.error,
#form-status {
    color: #a43e32;
}
footer {
    padding: 15px 0;
}
[hidden] {
    display: none !important;
}
@media (max-width: 700px) {
    main {
        padding: 20px;
    }
    .metrics {
        grid-template-columns: 1fr 1fr;
    }
    .metrics article {
        padding: 18px;
    }
    .charts {
        grid-template-columns: 1fr;
    }
    h1 {
        font-size: 34px;
    }
    .panel {
        padding: 18px;
    }
    .section-title {
        flex-wrap: wrap;
    }
    nav {
        gap: 10px;
    }
    .brand span {
        display: none;
    }
}

body[data-session-state='checking']
    :is(#login-form, #login, #logout, #business-content, #workspace, #dashboard),
body[data-session-state='error']
    :is(#login-form, #login, #logout, #business-content, #workspace, #dashboard) {
    display: none !important;
}
#session-loading {
    padding: 1rem 0;
    color: #647c88;
}

.bulk-actions,
.dialog-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin: 1rem 0;
}
.bulk-actions span {
    font-size: 13px;
    color: #667e7b;
}
.danger {
    background: #a3312c;
    color: #fff;
}
.danger:hover:not(:disabled) {
    background: #812420;
}
.selection-checkbox,
input[type='checkbox'] {
    width: 20px;
    height: 20px;
    display: inline-block;
    margin: 0;
    cursor: pointer;
}
.delete-warning {
    padding: 12px;
    border-left: 4px solid #a3312c;
    background: #fff1ef;
    line-height: 1.6;
}
.deletion-targets {
    max-height: 220px;
    overflow: auto;
    padding-left: 22px;
    overflow-wrap: anywhere;
}
.deletion-targets li {
    margin: 0.5rem 0;
}
.dialog-actions {
    justify-content: flex-end;
}
#program-list {
    list-style: none;
    padding: 0;
}
#program-list li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    padding: 16px;
    margin: 12px 0;
    border: 1px solid #dce5df;
    border-radius: 12px;
}
#program-list strong {
    flex-basis: 100%;
}
#multi-program-switch {
    appearance: none;
    width: 44px;
    height: 26px;
    border: 0;
    border-radius: 20px;
    background: #8b9994;
    position: relative;
    vertical-align: middle;
    margin-right: 8px;
    padding: 0;
    transition: background 0.15s;
}
#multi-program-switch::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: white;
    transition: transform 0.15s;
}
#multi-program-switch:checked {
    background: #205749;
}
#multi-program-switch:checked::after {
    transform: translateX(18px);
}
#multi-program-switch:disabled {
    opacity: 0.5;
}

.health-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}
.health-grid article {
    padding: 18px;
    border: 1px solid #dce5df;
    border-radius: 12px;
}
.health-grid p {
    font-size: 13px;
    line-height: 1.5;
}
.health-state {
    display: inline-block;
    padding: 4px 9px;
    border-radius: 20px;
    background: #fff0d5;
    color: #714c00;
    font-size: 12px;
    text-transform: capitalize;
}
.health-state[data-state='ok'],
.health-state[data-state='running'] {
    background: #e0f0e5;
    color: #205749;
}
.health-state[data-state='failed'],
.health-state[data-state='error'] {
    background: #ffe3df;
    color: #a3312c;
}
.health-warning {
    color: #8a4600;
}
.health-good {
    color: #205749;
}

#business-billing-dialog {
    overflow-wrap: anywhere;
}
#business-billing-dialog p {
    line-height: 1.5;
}
#billing-setup-fields {
    min-width: 0;
    padding: 16px;
    margin: 20px 0;
}
#billing-setup-fields select {
    display: block;
    width: 100%;
    min-width: 0;
    margin-top: 8px;
}
#billing-setup-fields input {
    min-width: 0;
    max-width: 100%;
}
#business-billing-dialog button {
    max-width: 100%;
    white-space: normal;
}
#billing-link-result {
    margin: 18px 0;
}
#billing-link-url {
    min-width: 0;
    font-size: 13px;
}
