:root {
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: #20332f;
  background: #f5f8f6;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --navy: #203b34;
  --teal: #287b65;
  --muted: #71817b;
  --line: #e3ebe6;
  --surface: #fff;
}

* { box-sizing: border-box; }

body { margin: 0; min-width: 320px; }

.topbar {
  height: 72px;
  padding: 0 max(5vw, calc((100vw - 1160px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--navy);
}

.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--navy); text-decoration: none; font-size: 16px; font-weight: 650; }
.brand strong { color: var(--teal); font-weight: 700; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid #dcebe4; border-radius: 11px; background: #eff7f2; color: var(--teal); }
.brand-mark svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.account-actions { display: flex; align-items: center; gap: 16px; }
.account-name { color: #536760; font-size: 13px; }
.credit-pill, .small-pill { padding: 7px 11px; border: 1px solid #dcebe4; border-radius: 20px; background: #f1f8f4; color: #287b65; font-size: 12px; font-weight: 700; white-space: nowrap; }

.layout { width: min(1160px, calc(100% - 36px)); margin: 42px auto 42px; min-height: calc(100vh - 190px); }
.auth-panel { max-width: 480px; margin: 24px auto 0; padding: 36px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 11px; letter-spacing: .12em; font-weight: 800; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; color: var(--navy); font-size: clamp(27px, 4vw, 36px); letter-spacing: -.04em; }
h2 { margin-bottom: 0; color: var(--navy); font-size: 18px; letter-spacing: -.02em; }
.muted { color: var(--muted); line-height: 1.55; }
.small { font-size: 12px; }
.card { border: 1px solid var(--line); border-radius: 15px; background: var(--surface); box-shadow: 0 8px 28px #1c392d08; padding: 26px; }
.form-stack { display: grid; gap: 17px; margin-top: 28px; }
label { display: grid; gap: 7px; color: #34495a; font-size: 13px; font-weight: 650; }
input[type="email"], input[type="password"], input[type="text"] { width: 100%; height: 44px; border: 1px solid #dce6e0; border-radius: 9px; padding: 0 12px; font: inherit; font-weight: 400; color: #20332f; background: white; transition: border-color .16s, box-shadow .16s; }
input[type="tel"], input[type="date"], input[type="month"], input[type="number"], select, textarea { width: 100%; min-height: 43px; border: 1px solid #dce6e0; border-radius: 9px; padding: 9px 11px; font: inherit; font-size: 13px; color: #20332f; background: white; transition: border-color .16s, box-shadow .16s; }
textarea { resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: #65a88e; box-shadow: 0 0 0 3px #3b98701c; }
label small { color: var(--muted); font-weight: 400; }
.button { min-height: 42px; border: 0; border-radius: 8px; padding: 0 16px; cursor: pointer; font: inherit; font-size: 13px; font-weight: 700; transition: transform .15s, background .15s; }
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: wait; opacity: .65; transform: none; }
.button-primary { color: #fff; background: var(--teal); box-shadow: 0 4px 12px #287b651b; }
.button-primary:hover { background: #116f62; }
.button-quiet { border: 1px solid var(--line); color: #425a51; background: #fff; }
.button-quiet-light { border: 1px solid var(--line); color: #52675f; background: #f7faf8; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.report-actions .button { display: inline-flex; align-items: center; text-decoration: none; }
.auth-switch { margin: 23px 0 0; color: var(--muted); font-size: 13px; text-align: center; }
.text-button { border: 0; padding: 0; color: var(--teal); background: none; cursor: pointer; font: inherit; font-weight: 700; }
.free-credit-note { margin: 20px 0 0; border-top: 1px solid var(--line); padding-top: 16px; color: var(--muted); text-align: center; font-size: 12px; }

.notice { margin-bottom: 18px; padding: 13px 16px; border: 1px solid #cde8df; border-radius: 9px; background: #ebf7f3; color: #145c50; font-size: 14px; }
.notice.error { border-color: #f1d2cd; background: #fff1ef; color: #913d32; }
.analysis-vat-note { margin: 14px 0; padding: 11px 14px; border: 1px solid #f0d9a8; border-radius: 8px; background: #fff8e8; color: #73551b; font-size: 12px; line-height: 1.5; }
.welcome { display: flex; justify-content: space-between; align-items: end; margin-bottom: 25px; }
.welcome h1 { margin-bottom: 7px; }
.welcome .muted { margin-bottom: 0; }
.main-menu { display: flex; gap: 4px; overflow-x: auto; margin: 0 0 20px; padding: 5px; border: 1px solid var(--line); border-radius: 12px; background: #fff; scrollbar-width: thin; }
.menu-item { display: inline-flex; min-height: 40px; flex: 0 0 auto; align-items: center; gap: 8px; border: 1px solid transparent; border-radius: 8px; padding: 0 12px; color: #65766f; background: transparent; cursor: pointer; font: inherit; font-size: 12px; font-weight: 600; transition: color .16s, background .16s, border-color .16s; }
.menu-item svg { width: 17px; height: 17px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; opacity: .82; }
.menu-item:hover { border-color: #e6eee9; color: var(--navy); background: #f8fbf9; }
.menu-item.active { border-color: #d7e9df; color: #287b65; background: #edf7f1; }
.menu-page { min-height: 250px; }
.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.45fr) minmax(280px, .8fr); gap: 18px; align-items: stretch; }
.dashboard-grid .upload-card { grid-column: 1 / -1; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-bottom: 21px; }
.upload-card, .credits-card { min-height: 322px; }
.upload-form { display: grid; gap: 14px; }
.drop-zone { position: relative; min-height: 138px; align-items: center; justify-content: center; border: 1px dashed #b9cec2; border-radius: 11px; background: #fafcfb; cursor: pointer; text-align: center; font-weight: 400; transition: border-color .16s, background .16s; }
.drop-zone:hover { border-color: var(--teal); background: #f4fbf9; }
.drop-zone input { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; opacity: 0; }
.upload-icon { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid #d9eae1; border-radius: 12px; background: #eff7f2; color: var(--teal); }
.upload-icon svg { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.55; stroke-linecap: round; stroke-linejoin: round; }
.rule-note { display: grid; gap: 5px; color: #566b79; font-size: 12px; line-height: 1.5; }
.rule-note strong { color: #273d4e; }
.balance-large { color: var(--teal); font-size: 30px; font-weight: 800; }
.package-list { display: grid; gap: 10px; }
.package-option { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 9px; }
.package-info { display: grid; gap: 4px; font-size: 13px; }
.package-info span { color: var(--muted); font-size: 12px; }
.package-option .button { min-height: 36px; padding: 0 12px; }
.credits-card > .muted { margin: 14px 0 0; }
.history-card, .jobs-card, .results-card { margin-top: 18px; }
.dashboard-grid .history-card { margin-top: 0; }
.clients-card { margin-bottom: 18px; }
.client-form { display: grid; gap: 17px; padding: 20px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; }
.client-form h3, .message-history h3 { margin: 0; color: var(--navy); font-size: 15px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.wide-field { grid-column: 1 / -1; }
.optional-fields { padding-top: 14px; border-top: 1px solid var(--line); }
.optional-fields summary { color: var(--teal); cursor: pointer; font-size: 13px; font-weight: 700; }
.optional-fields > p { margin: 10px 0; }
.optional-fields .form-grid { margin-top: 12px; }
.consent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
fieldset { display: grid; gap: 9px; border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
legend { padding: 0 5px; color: #34495a; font-size: 12px; font-weight: 700; }
.checkbox-line { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; line-height: 1.45; }
.checkbox-line input { margin: 2px 0 0; accent-color: var(--teal); }
.form-actions { display: flex; gap: 9px; }
.client-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; margin-top: 17px; }
.client-card { display: grid; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 15px; }
.client-card-header { display: flex; justify-content: space-between; align-items: start; gap: 9px; }
.client-card-title { color: var(--navy); font-size: 14px; font-weight: 750; }
.client-card-meta, .client-card-status { color: var(--muted); font-size: 12px; line-height: 1.45; }
.client-card-status { display: flex; flex-wrap: wrap; gap: 6px; }
.status-chip { padding: 4px 7px; border-radius: 20px; background: #edf3f5; color: #526b78; font-size: 10px; }
.status-chip.good { background: #e4f3ef; color: #146d60; }
.client-card-actions { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 3px; }
.client-card-actions .button { min-height: 34px; padding: 0 10px; font-size: 12px; }
.client-detail-card { margin-top: 18px; }
.detail-heading { display: flex; justify-content: space-between; align-items: start; gap: 18px; }
.detail-heading h2 { margin-bottom: 5px; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; margin-top: 20px; }
.detail-subcard { border: 1px solid var(--line); border-radius: 9px; padding: 16px; }
.detail-subcard h3 { margin: 0 0 13px; color: var(--navy); font-size: 14px; }
.detail-subcard .form-stack { margin-top: 0; gap: 11px; }
.contract-row, .ledger-row { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.contract-row:last-child, .ledger-row:last-child { border-bottom: 0; }
.account-balance { margin: 0 0 12px; color: var(--teal); font-size: 20px; font-weight: 800; }
.communication-recipients { display: flex; justify-content: flex-start; gap: 8px; color: var(--muted); font-size: 12px; }
.recipient-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; color: #34495a; font-size: 13px; }
.recipient-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px 12px; max-height: 210px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 10px; }
.recipient-option { display: flex; align-items: flex-start; gap: 7px; font-size: 12px; font-weight: 400; }
.recipient-option input { margin: 2px 0 0; accent-color: var(--teal); }
.recipient-option span { overflow-wrap: anywhere; }
.message-history { margin-top: 25px; padding-top: 18px; border-top: 1px solid var(--line); }
.message-history h3 { margin-bottom: 10px; }
.profile-card { max-width: 900px; margin: 0 auto; }
.profile-form { margin-top: 22px; }
.profile-section { display: grid; gap: 14px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #fbfcfd; }
.profile-section h3 { margin: 0; color: var(--navy); font-size: 15px; }
.profile-section .form-grid { gap: 14px; }
.admin-card { margin-bottom: 18px; }
.admin-card .section-heading { margin-bottom: 12px; }
.admin-action-button { min-height: 32px; padding: 0 9px; font-size: 11px; white-space: nowrap; }
.admin-credit-form { display: grid; grid-template-columns: 90px minmax(120px, 1fr) auto; gap: 5px; margin-top: 7px; }
.admin-credit-form input { min-width: 0; width: 100%; min-height: 32px; padding: 5px 7px; font-size: 11px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { padding: 11px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 650; }
.positive { color: #13806d; font-weight: 700; }
.negative { color: #a24a40; font-weight: 700; }
.empty-state { margin: 0; padding: 15px 0; color: var(--muted); font-size: 13px; }
.job-list { display: grid; gap: 9px; }
.job-row { display: grid; grid-template-columns: minmax(145px, 1fr) minmax(180px, 2fr) minmax(100px, .7fr) minmax(80px, .55fr) auto; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.job-row:last-child { border-bottom: 0; }
.job-period { color: var(--navy); font-weight: 800; }
.job-filename { overflow: hidden; color: #516673; text-overflow: ellipsis; white-space: nowrap; }
.job-coverage { color: var(--teal); font-weight: 750; }
.link-button { border: 0; color: var(--teal); background: none; cursor: pointer; font: inherit; font-weight: 700; text-decoration: underline; }
.result-summary { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0; }
.summary-chip { padding: 10px 13px; border-radius: 8px; background: #f2f6f7; color: #4f6572; font-size: 12px; }
.summary-chip strong { color: var(--navy); }
.analysis-report-wrap { overflow-x: auto; }
.analysis-report-table { width: 100%; min-width: 820px; border-collapse: collapse; }
.analysis-report-table th, .analysis-report-table td { padding: 10px 9px; }
.analysis-subtotal-row { background: #edf5f3; color: var(--navy); font-weight: 750; }
.analysis-spacer-row td { height: 12px; padding: 0; border: 0; }
.analysis-grand-total-row { background: var(--navy); color: #fff; font-weight: 800; }
.analysis-grand-total-row td { color: #fff; }
.supplier-block { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.supplier-title { display: flex; justify-content: space-between; gap: 12px; color: var(--navy); font-size: 14px; font-weight: 750; }
.supplier-reason { margin: 6px 0 10px; color: var(--muted); font-size: 12px; }
.checkout { width: min(720px, calc(100% - 28px)); margin: 46px auto; padding: 25px; border: 1px solid var(--line); border-radius: 14px; background: #fff; }
.payment-dialog { width: min(560px, calc(100% - 24px)); max-width: 560px; max-height: calc(100% - 30px); border: 0; border-radius: 14px; padding: 0; box-shadow: 0 18px 70px #10253855; }
.payment-dialog::backdrop { background: #152d42a8; }
.payment-form { display: grid; gap: 17px; border: 0; box-shadow: none; }
.footer { max-width: 1160px; margin: 0 auto 20px; padding: 0 18px; color: #82919b; font-size: 11px; text-align: center; }
[hidden] { display: none !important; }

@media (max-width: 820px) {
  .layout { margin-top: 30px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .upload-card, .credits-card { min-height: auto; }
  .job-row { grid-template-columns: 1fr 1.4fr .8fr auto; }
  .job-row .job-supplier-count { display: none; }
  .client-list { grid-template-columns: 1fr; }
  .admin-credit-form { grid-template-columns: 80px minmax(110px, 1fr); }
  .admin-credit-form .button { grid-column: 1 / -1; }
}

@media (max-width: 560px) {
  .topbar { height: 65px; padding: 0 16px; }
  .account-actions { gap: 8px; }
  .account-name { display: none; }
  .layout { width: calc(100% - 24px); margin-top: 23px; }
  .main-menu { gap: 3px; padding: 4px; }
  .menu-item { min-height: 38px; padding: 0 11px; font-size: 12px; }
  .card { padding: 19px; }
  .auth-panel { padding: 25px 21px; }
  .job-row { grid-template-columns: 1fr auto; gap: 6px 10px; }
  .job-filename, .job-coverage, .job-supplier-count { grid-column: 1; }
  .job-row .button { grid-column: 2; grid-row: 1 / span 3; }
  .form-grid, .consent-grid, .detail-grid, .recipient-list { grid-template-columns: 1fr; }
  .wide-field { grid-column: auto; }
}
