:root {
    color-scheme: light;
    --ink: #102238;
    --muted: #64748b;
    --line: #dce5ec;
    --surface: #ffffff;
    --surface-soft: #f4f8fa;
    --navy: #0b243b;
    --teal: #008c8b;
    --teal-dark: #006e70;
    --green: #138a5b;
    --red: #b4233f;
    --blue: #2563eb;
    --shadow: 0 24px 70px rgba(16, 34, 56, .12);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    color: var(--ink);
    background:
        radial-gradient(circle at 7% 8%, rgba(0, 140, 139, .13), transparent 28rem),
        radial-gradient(circle at 94% 18%, rgba(11, 36, 59, .10), transparent 34rem),
        #eef4f6;
}

button, input, select, textarea, a { font: inherit; }

button, a { -webkit-tap-highlight-color: transparent; }

.shell {
    width: min(1080px, calc(100% - 32px));
    margin: 0 auto;
    padding: 48px 0 72px;
}

.hero {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 22px;
    align-items: center;
    margin-bottom: 28px;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 64px;
    height: 64px;
    border-radius: 20px;
    color: white;
    background: linear-gradient(145deg, var(--teal), var(--navy));
    box-shadow: 0 14px 30px rgba(0, 110, 112, .24);
    font-weight: 800;
    letter-spacing: -.04em;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 7px; font-size: clamp(1.8rem, 4vw, 2.75rem); line-height: 1.05; letter-spacing: -.035em; }
h2 { margin-bottom: 7px; font-size: 1.25rem; letter-spacing: -.02em; }
.subtitle { max-width: 700px; margin-bottom: 0; color: var(--muted); line-height: 1.6; }
.eyebrow { margin-bottom: 7px; color: var(--teal-dark); font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }

.connection {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, .72);
    font-size: .82rem;
    font-weight: 700;
    white-space: nowrap;
}

.connection-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 0 4px rgba(180, 35, 63, .10); }
.connection.is-ready .connection-dot { background: var(--green); box-shadow: 0 0 0 4px rgba(19, 138, 91, .10); }

.account-panel { display: grid; justify-items: end; gap: 10px; }
.account-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 12px; font-size: .82rem; }
.account-actions form { margin: 0; }
.text-link, .text-button { padding: 0; border: 0; color: var(--teal-dark); background: transparent; cursor: pointer; font-weight: 750; text-decoration: none; }
.text-link:hover, .text-button:hover { text-decoration: underline; }

.workspace-card, .progress-card, .results-card {
    border: 1px solid rgba(220, 229, 236, .92);
    border-radius: 24px;
    background: rgba(255, 255, 255, .95);
    box-shadow: var(--shadow);
}

.workspace-card { overflow: hidden; }
.progress-card, .results-card { margin-top: 22px; padding: 28px; }

.mode-tabs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 6px; background: var(--surface-soft); border-bottom: 1px solid var(--line); }
.mode-tab { padding: 14px 18px; border: 0; border-radius: 14px; color: var(--muted); background: transparent; cursor: pointer; font-weight: 750; }
.mode-tab:hover { color: var(--ink); }
.mode-tab.is-active { color: var(--navy); background: white; box-shadow: 0 5px 18px rgba(16, 34, 56, .09); }

.mode-panel { min-height: 245px; padding: 36px; }
.panel-copy { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.panel-copy p { max-width: 720px; margin: 0; color: var(--muted); line-height: 1.65; }
.step-number { color: var(--teal); font-size: .78rem; font-weight: 850; letter-spacing: .12em; }
.feature-list { display: flex; flex-wrap: wrap; gap: 10px; padding: 0; margin: 30px 0 0 36px; list-style: none; }
.feature-list li { padding: 8px 12px; border: 1px solid #d9eceb; border-radius: 999px; color: var(--teal-dark); background: #f2fbfa; font-size: .83rem; font-weight: 650; }
.appointment-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin: 28px 0 0 36px; }
.assignment-option { display: flex; align-items: flex-start; gap: 12px; margin: 22px 0 0 36px; padding: 14px 16px; border: 1px solid #d9eceb; border-radius: 13px; background: #f5fbfb; cursor: pointer; }
.assignment-option input { width: 19px; height: 19px; margin: 2px 0 0; accent-color: var(--teal); flex: 0 0 auto; }
.assignment-option span { display: grid; gap: 4px; }
.assignment-option strong { color: var(--teal-dark); font-size: .92rem; }
.assignment-option small { color: var(--muted); font-size: .8rem; line-height: 1.45; }

label { display: block; margin-bottom: 10px; font-weight: 750; }
input[type="text"], input[type="password"], input[type="email"], input[type="url"], input[type="number"], input[type="date"], input[type="search"], input[type="file"], select {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 13px;
    color: var(--ink);
    background: #fbfdfe;
    outline: none;
}
input[type="file"] { min-height: auto; }
input:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(0, 140, 139, .10); }
textarea { width: 100%; min-height: 180px; resize: vertical; padding: 16px; border: 1px solid var(--line); border-radius: 15px; color: var(--ink); background: #fbfdfe; line-height: 1.55; outline: none; }
textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(0, 140, 139, .10); }
.field-note { margin: 9px 0 0; color: var(--muted); font-size: .82rem; }

.actions { display: flex; justify-content: flex-end; padding: 0 36px 32px; }
.primary-button, .secondary-button, .ghost-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    min-height: 48px;
    padding: 0 20px;
    border-radius: 13px;
    border: 0;
    text-decoration: none;
    cursor: pointer;
    font-weight: 780;
}
.primary-button { color: white; background: linear-gradient(135deg, var(--teal), var(--teal-dark)); box-shadow: 0 12px 24px rgba(0, 110, 112, .22); }
.primary-button:hover { filter: brightness(.96); transform: translateY(-1px); }
.primary-button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.secondary-button { border: 1px solid var(--line); color: var(--teal-dark); background: white; }
.ghost-button { color: var(--muted); background: var(--surface-soft); }

.progress-heading, .results-heading { display: flex; justify-content: space-between; gap: 18px; align-items: center; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
#progress-count { color: var(--teal-dark); font-weight: 800; }
.progress-track { height: 10px; margin: 18px 0 14px; overflow: hidden; border-radius: 999px; background: #e8eff2; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), #32b9a7); transition: width .28s ease; }
#progress-message { color: var(--muted); }
.activity-log { display: grid; gap: 8px; max-height: 190px; overflow: auto; padding: 0; margin: 22px 0 0; list-style: none; }
.activity-log li { padding: 10px 12px; border-left: 3px solid #cfe2e4; color: #52647a; background: #f8fbfc; font-size: .84rem; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin: 22px 0; }
.summary-item { padding: 18px; border-radius: 16px; background: var(--surface-soft); }
.summary-item strong { display: block; margin-bottom: 5px; font-size: 1.55rem; }
.summary-item span { color: var(--muted); font-size: .82rem; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 16px; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); text-align: left; font-size: .86rem; }
th { color: #52647a; background: #f5f8fa; font-size: .73rem; letter-spacing: .06em; text-transform: uppercase; }
tbody tr:last-child td { border-bottom: 0; }
.warnings { margin-top: 16px; padding: 15px; border: 1px solid #f1d6a8; border-radius: 14px; color: #825517; background: #fff9ed; font-size: .86rem; line-height: 1.55; }

.alert { display: grid; gap: 6px; margin-bottom: 20px; padding: 16px 18px; border-radius: 16px; font-size: .9rem; }
.alert-error { border: 1px solid #f3c5ce; color: #8d243a; background: #fff4f6; }
.alert-success { border: 1px solid #bfe5d5; color: #126746; background: #f0fbf6; }
.alert-info { border: 1px solid #cfe2e4; color: #315d66; background: #f2f9fa; }

.feedback-popup {
    position: fixed;
    z-index: 1000;
    top: 22px;
    left: 50%;
    width: min(520px, calc(100% - 28px));
    transform: translateX(-50%);
}
.feedback-popup-card {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 13px;
    align-items: start;
    padding: 17px 18px;
    border: 1px solid transparent;
    border-radius: 17px;
    box-shadow: 0 20px 55px rgba(16, 34, 56, .22);
}
.feedback-popup.is-success .feedback-popup-card { border-color: #9dd9ba; color: #0d613f; background: #edfbf4; }
.feedback-popup.is-error .feedback-popup-card { border-color: #efb7c2; color: #8d243a; background: #fff2f5; }
.feedback-popup-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    color: white;
    background: var(--red);
    font-weight: 900;
}
.feedback-popup.is-success .feedback-popup-icon { background: var(--green); }
.feedback-popup-copy { min-width: 0; padding-top: 2px; }
.feedback-popup-copy strong { display: block; font-size: .98rem; }
.feedback-popup-copy p { margin: 5px 0 0; color: inherit; font-size: .86rem; line-height: 1.48; overflow-wrap: anywhere; }
.feedback-popup-close {
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 9px;
    color: currentColor;
    background: transparent;
    cursor: pointer;
    font-size: 1.35rem;
    line-height: 1;
}
.feedback-popup-close:hover { background: rgba(16, 34, 56, .07); }

.auth-page { display: grid; place-items: center; padding: 24px; }
.auth-shell { width: min(460px, 100%); }
.auth-card {
    padding: 36px;
    border: 1px solid rgba(220, 229, 236, .92);
    border-radius: 24px;
    background: rgba(255, 255, 255, .97);
    box-shadow: var(--shadow);
}
.auth-card .brand-mark { margin-bottom: 24px; }
.auth-card h1 { margin-bottom: 10px; }
.auth-card .subtitle { margin-bottom: 26px; }
.stack-form { display: grid; gap: 18px; }
.field { min-width: 0; }
.field label { margin-bottom: 7px; font-size: .88rem; }
.full-button { width: 100%; }

.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 24px; }
.page-header-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.settings-card {
    padding: 26px;
    border: 1px solid rgba(220, 229, 236, .92);
    border-radius: 22px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 16px 45px rgba(16, 34, 56, .09);
}
.settings-card.is-wide { grid-column: 1 / -1; }
.settings-card h2 { margin-bottom: 5px; }
.settings-card > .subtitle { margin-bottom: 22px; font-size: .9rem; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.form-grid .is-wide { grid-column: 1 / -1; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.file-status { margin: 7px 0 0; color: var(--muted); font-size: .78rem; }
.data-table-actions { white-space: nowrap; }
.badge { display: inline-flex; padding: 5px 9px; border-radius: 999px; color: var(--teal-dark); background: #eaf8f6; font-size: .72rem; font-weight: 800; }

.module-shell { width: min(1180px, calc(100% - 32px)); }
.module-header { align-items: center; }
.module-title { display: flex; align-items: center; gap: 18px; }
.module-title h1 { margin-bottom: 7px; }
.module-tabs {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin: 0 0 20px;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(255, 255, 255, .72);
}
.module-tabs a {
    padding: 11px 15px;
    border-radius: 11px;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 760;
    text-decoration: none;
    white-space: nowrap;
}
.module-tabs a:hover { color: var(--ink); background: var(--surface-soft); }
.module-tabs a.is-active { color: var(--navy); background: white; box-shadow: 0 5px 18px rgba(16, 34, 56, .09); }
.module-dashboard { box-shadow: var(--shadow); }
.module-card-heading { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; }
.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 7px 12px;
    border-radius: 999px;
    font-size: .77rem;
    font-weight: 800;
    white-space: nowrap;
}
.status-idle { color: #536174; background: #edf2f5; }
.status-running { color: #946016; background: #fff6df; }
.status-ok { color: var(--green); background: #eaf8f1; }
.status-fail { color: var(--red); background: #fff0f3; }
.module-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin: 24px 0 0;
}
.module-stats div { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface-soft); }
.module-stats dt { margin-bottom: 6px; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.module-stats dd { margin: 0; overflow-wrap: anywhere; font-size: .91rem; font-weight: 760; }
.module-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.warning-button { color: #855510; border-color: #efd8a9; background: #fffaf0; }
.module-message { margin: 18px 0 0; }
.live-panel { overflow: hidden; margin-top: 20px; border: 1px solid var(--line); border-radius: 17px; }
.live-panel-heading { display: flex; justify-content: space-between; gap: 18px; padding: 15px 17px; border-bottom: 1px solid var(--line); background: var(--surface-soft); }
.live-panel-heading > div { display: grid; gap: 4px; }
.live-panel-heading span, .live-panel-heading small { color: var(--muted); font-size: .8rem; }
.module-events { max-height: 330px; margin: 0; padding: 0; gap: 0; }
.module-events li { display: grid; grid-template-columns: 78px 210px minmax(0, 1fr); gap: 12px; border-left: 0; border-bottom: 1px solid #edf2f5; border-radius: 0; background: white; }
.module-events li:last-child { border-bottom: 0; }
.module-events time { color: var(--muted); }
.module-events span { color: var(--muted); overflow-wrap: anywhere; }
.module-table { margin-top: 20px; }
.module-table td { vertical-align: top; }
.status-text { font-weight: 800; }
.status-text.is-success { color: var(--green); }
.status-text.is-error { color: var(--red); }
.recipient-list { display: grid; gap: 10px; margin-top: 18px; }
.recipient-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-soft); overflow-wrap: anywhere; }
.recipient-row form { margin: 0; }
.danger-link { color: var(--red); }
.field-label { display: block; margin-bottom: 10px; font-weight: 750; }
.day-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.day-picker label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 9px 10px; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-soft); font-size: .83rem; font-weight: 650; }
.day-picker input { accent-color: var(--teal); }
.sticky-actions { align-items: center; margin-top: 0; }

.billing-shell { width: min(1760px, calc(100% - 24px)); }
.billing-control-card { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(430px, 1.25fr); gap: 28px; padding: 28px; }
.billing-control-copy p:last-child { margin-bottom: 0; color: var(--muted); line-height: 1.6; }
.billing-scan-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; gap: 14px; align-items: end; }
.billing-scan-form label { margin-bottom: 7px; font-size: .82rem; }
.billing-scan-form .primary-button { white-space: nowrap; }
.billing-progress { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid var(--line); }
.billing-progress p { margin-bottom: 0; color: var(--muted); }
.billing-results-heading { align-items: end; flex-wrap: wrap; }
.billing-filters { display: grid; grid-template-columns: minmax(190px, 1.3fr) minmax(130px, .8fr) repeat(2, minmax(135px, .8fr)) auto; gap: 10px; align-items: end; width: min(940px, 100%); margin-left: auto; }
.billing-filter { margin: 0; color: var(--muted); font-size: .75rem; }
.billing-filter span { display: block; margin-bottom: 7px; }
.billing-filter input, .billing-filter select { min-height: 42px; padding: 8px 10px; border-radius: 11px; font-size: .78rem; }
.billing-filter-clear { min-height: 42px; padding: 0 13px; border: 1px solid var(--line); white-space: nowrap; }
.billing-summary { grid-template-columns: repeat(3, minmax(140px, 220px)); }
.billing-table { min-width: 0; table-layout: fixed; }
.billing-table th, .billing-table td { padding: 10px 8px; overflow-wrap: anywhere; }
.billing-table th { font-size: .66rem; }
.billing-table td { vertical-align: top; font-size: .78rem; line-height: 1.4; }
.billing-table th:nth-child(1) { width: 20%; }
.billing-table th:nth-child(2) { width: 12%; }
.billing-table th:nth-child(3) { width: 8%; }
.billing-table th:nth-child(4) { width: 9%; }
.billing-table th:nth-child(5) { width: 24%; }
.billing-table th:nth-child(6) { width: 17%; }
.billing-table th:nth-child(7) { width: 10%; }
.billing-table td:nth-child(7) { vertical-align: middle; }
.billing-table tbody tr > td { transition: background-color .18s ease; }
.billing-table tbody tr.billing-row-pending > td { background: rgba(180, 35, 63, .12); }
.billing-table tbody tr.billing-row-invoiced > td { background: rgba(37, 99, 235, .12); }
.billing-primary-value { display: block; }
.billing-project-note { display: block; margin-top: 5px; color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.billing-project-link { display: block; margin-top: 5px; color: var(--muted); font-size: .72rem; overflow-wrap: anywhere; }
.billing-project-link:hover { color: var(--accent); }
.billing-number { white-space: nowrap; font-variant-numeric: tabular-nums; }
.billing-tc-form { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; align-items: center; min-width: 0; }
.billing-tc-form input { min-width: 0; min-height: 36px; padding: 8px 9px; border-radius: 10px; font-size: .74rem; font-variant-numeric: tabular-nums; }
.billing-save-button { min-height: 36px; padding: 0 8px; border-radius: 10px; font-size: .72rem; }
.billing-save-button:disabled { cursor: wait; opacity: .55; }
.billing-invoice-toggle { display: inline-flex; align-items: center; gap: 5px; min-height: 36px; padding: 5px 7px; border: 1px solid rgba(180, 35, 63, .35); border-radius: 10px; color: var(--red); background: rgba(180, 35, 63, .08); cursor: pointer; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.billing-invoice-check { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 6px; color: white; background: var(--red); font-size: .82rem; line-height: 1; }
.billing-invoice-toggle.is-invoiced { border-color: rgba(37, 99, 235, .35); color: var(--blue); background: rgba(37, 99, 235, .09); }
.billing-invoice-toggle.is-invoiced .billing-invoice-check { background: var(--blue); }
.billing-invoice-toggle:hover { filter: brightness(.96); }
.billing-invoice-toggle:focus-visible { outline: 3px solid rgba(37, 99, 235, .22); outline-offset: 2px; }
.billing-invoice-toggle:disabled { cursor: wait; opacity: .55; }
.billing-empty { margin: 24px 0 4px; color: var(--muted); text-align: center; }

.is-hidden { display: none !important; }
body.is-busy .mode-tabs, body.is-busy #job-form { pointer-events: none; opacity: .64; }

@media (max-width: 760px) {
    .feedback-popup { top: 12px; }
    .shell { width: min(100% - 20px, 1080px); padding-top: 24px; }
    .hero { grid-template-columns: auto 1fr; }
    .account-panel { grid-column: 1 / -1; justify-items: start; }
    .account-actions { justify-content: flex-start; }
    .mode-panel { padding: 26px 20px; }
    .actions { padding: 0 20px 22px; }
    .primary-button { width: 100%; }
    .feature-list { margin-left: 0; }
    .appointment-fields { grid-template-columns: 1fr; margin-left: 0; }
    .assignment-option { margin-left: 0; }
    .progress-card, .results-card { padding: 21px 16px; border-radius: 20px; }
    .results-heading { align-items: flex-start; flex-direction: column; }
    .result-actions { width: 100%; justify-content: flex-start; }
    .summary-grid { grid-template-columns: 1fr; }
    .auth-card { padding: 28px 22px; }
    .page-header { flex-direction: column; }
    .settings-grid, .form-grid { grid-template-columns: 1fr; }
    .settings-card.is-wide, .form-grid .is-wide { grid-column: auto; }
    .module-title { align-items: flex-start; }
    .module-card-heading, .live-panel-heading { flex-direction: column; }
    .module-stats { grid-template-columns: 1fr 1fr; }
    .module-events li { grid-template-columns: 1fr; gap: 4px; }
    .module-actions > * { flex: 1 1 180px; }
    .billing-shell { width: min(100% - 20px, 1320px); }
    .billing-control-card { grid-template-columns: 1fr; padding: 22px 18px; }
    .billing-scan-form { grid-template-columns: 1fr; }
    .billing-results-heading { align-items: stretch; }
    .billing-filters { grid-template-columns: 1fr 1fr; width: 100%; margin-left: 0; }
    .billing-search { grid-column: 1 / -1; }
    .billing-filter-clear { width: 100%; }
    .billing-summary { grid-template-columns: 1fr; }
    .billing-table { min-width: 1000px; }
}

@media (max-width: 480px) {
    .module-stats, .day-picker { grid-template-columns: 1fr; }
    .module-title .brand-mark { width: 52px; height: 52px; border-radius: 16px; flex: 0 0 auto; }
    .billing-filters { grid-template-columns: 1fr; }
    .billing-search { grid-column: auto; }
}
