:root {
  color-scheme: dark;
  --bg: #111214;
  --bg-top: #17181b;
  --panel: #18191d;
  --panel-2: #202228;
  --field: #111318;
  --border: #343840;
  --text: #f0f3f5;
  --muted: #a4adb7;
  --accent: #5cc8a7;
  --accent-2: #f1c06a;
  --success: #48d597;
  --danger: #ff7a7a;
  --warning: #f7c873;
  --shadow: 0 10px 26px rgba(0, 0, 0, 0.24);
  --radius: 8px;
}
body[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fa;
  --bg-top: #eef2f6;
  --panel: #ffffff;
  --panel-2: #eef2f6;
  --field: #ffffff;
  --border: #cfd8e3;
  --text: #18212b;
  --muted: #617080;
  --accent: #147c66;
  --accent-2: #9d6510;
  --success: #0f8c5a;
  --danger: #ba3434;
  --warning: #9c6714;
  --shadow: 0 10px 26px rgba(30, 41, 59, 0.12);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg) 340px); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { min-height: 100vh; padding: clamp(12px, 1.6vw, 24px); }
body.is-locked { display: grid; place-items: center; }
button, input, select { font: inherit; }
input, select { width: 100%; border: 1px solid var(--border); background: var(--field); color: var(--text); border-radius: 8px; padding: 10px 11px; outline: none; }
input:focus, select:focus { border-color: rgba(92, 200, 167, 0.75); box-shadow: 0 0 0 3px rgba(92, 200, 167, 0.14); }
.access-gate { width: 100%; min-height: calc(100vh - clamp(24px, 3.2vw, 48px)); display: grid; place-items: center; }
body:not(.is-locked) .access-gate { display: none; }
body.is-locked .app-shell { display: none; }
.access-panel { width: min(100%, 420px); border: 1px solid var(--border); border-radius: var(--radius); background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.02)); padding: 24px; box-shadow: var(--shadow); }
.access-panel h1 { margin: 6px 0 8px; font-size: 2rem; }
.access-field { margin-top: 18px; }
.access-submit { width: 100%; margin-top: 14px; }
.access-error { min-height: 1.3em; margin: 12px 0 0; color: var(--danger); font-size: 0.92rem; }
.app-shell { width: min(100%, 1760px); margin: 0 auto; }
main, .panel, .grid, .grid > *, .card, .field-grid, .summary-grid, .kpi-grid, .table-wrap { min-width: 0; }
.hero { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: center; margin-bottom: 12px; }
.hero h1 { margin: 4px 0 4px; font-size: clamp(1.7rem, 2.4vw, 2.6rem); letter-spacing: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.14em; color: var(--accent-2); font-size: 0.74rem; margin: 0; }
.subtle, .help { color: var(--muted); }
.subtle { margin: 0; }
.help { margin: 0; line-height: 1.45; }
.hero-actions { display: flex; align-items: center; justify-content: end; gap: 10px; flex-wrap: wrap; }
.hero-badge, .pill { border: 1px solid var(--border); background: rgba(255,255,255,0.04); border-radius: 8px; padding: 7px 10px; font-size: 0.84rem; white-space: nowrap; }
.theme-switch { display: inline-flex; align-items: center; gap: 9px; border: 1px solid var(--border); border-radius: 999px; padding: 5px 7px 5px 10px; background: rgba(255,255,255,0.04); cursor: pointer; user-select: none; }
.theme-switch-text { color: var(--muted); font-size: 0.84rem; min-width: 34px; text-align: right; }
.theme-switch input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; pointer-events: none; }
.theme-switch-track { width: 42px; height: 24px; border-radius: 999px; border: 1px solid var(--border); background: var(--field); padding: 2px; transition: background 0.18s ease, border-color 0.18s ease; }
.theme-switch-thumb { display: block; width: 18px; height: 18px; border-radius: 999px; background: var(--muted); transform: translateX(0); transition: transform 0.18s ease, background 0.18s ease; }
.theme-switch input:checked + .theme-switch-track { border-color: rgba(92,200,167,0.75); background: rgba(92,200,167,0.16); }
.theme-switch input:checked + .theme-switch-track .theme-switch-thumb { transform: translateX(18px); background: var(--accent); }
.theme-switch:focus-within { box-shadow: 0 0 0 3px rgba(92, 200, 167, 0.14); border-color: rgba(92, 200, 167, 0.75); }
.pill.accent { color: var(--accent-2); }
.pill.neutral { color: var(--muted); }
.panel.hidden { display: none; }
.panel:not(.hidden) { display: grid; gap: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.overview-grid { grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.9fr); align-items: stretch; }
.result-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card { background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.018)); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.card.spaced, .spaced { margin-top: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 14px; }
.card-head.wrap { align-items: start; flex-wrap: wrap; }
.card h2 { margin: 0; font-size: 1.08rem; letter-spacing: 0; }
.field-grid { display: grid; gap: 14px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.setup-fields { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
label { display: grid; gap: 7px; }
label span { color: var(--muted); font-size: 0.92rem; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.summary-grid > div { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: rgba(255,255,255,0.02); }
.summary-label { color: var(--muted); font-size: 0.88rem; margin-bottom: 6px; }
.summary-value { font-size: 1rem; font-weight: 700; margin-bottom: 4px; }
.summary-small { color: var(--muted); font-size: 0.85rem; }
.btn { border: 1px solid var(--border); background: rgba(255,255,255,0.04); color: var(--text); border-radius: 8px; padding: 10px 14px; cursor: pointer; }
.btn:hover { border-color: rgba(255,255,255,0.22); }
.btn.primary { background: linear-gradient(135deg, rgba(92,200,167,0.30), rgba(92,200,167,0.16)); border-color: rgba(92,200,167,0.75); }
.btn.ghost { padding: 8px 12px; }
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); max-width: 100%; }
.input-table-wrap { max-height: min(46vh, 520px); }
.renewal-table-wrap { max-height: min(66vh, 720px); }
.result-table-wrap { max-height: min(48vh, 560px); }
table { width: 100%; border-collapse: collapse; min-width: 0; }
th, td { border-bottom: 1px solid var(--border); padding: 10px; text-align: left; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--panel-2); }
.table-wrap thead th { position: sticky; top: 0; z-index: 1; }
tr:last-child td { border-bottom: none; }
.compact { font-size: 0.92rem; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 0.86rem; border-radius: 999px; padding: 5px 10px; border: 1px solid var(--border); }
.status.early { color: var(--warning); }
.status.late { color: var(--danger); }
.status.ontime { color: var(--success); }
.result-box { display: grid; gap: 10px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.kpi { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: rgba(255,255,255,0.02); min-width: 0; }
.kpi .label { color: var(--muted); font-size: 0.86rem; margin-bottom: 6px; }
.kpi .value { font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
.note { color: var(--muted); font-size: 0.9rem; line-height: 1.5; }
.breakdown { width: 100%; border-collapse: collapse; min-width: 760px; margin-top: 0; }
.breakdown th, .breakdown td { padding: 8px 10px; font-size: 0.92rem; }
.small-table { width: 100%; border-collapse: collapse; min-width: 0; margin-top: 0; }
.acv-input-table { min-width: 420px; }
.renewal-table { min-width: 1480px; }
.small-table th, .small-table td { padding: 8px 10px; font-size: 0.9rem; }
.footer-note { margin-top: 10px; color: var(--muted); font-size: 0.86rem; }
.summary-actions { margin-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.summary-actions .footer-note { margin: 0; }
.math-explanation { display: none; margin-top: 24px; padding: 18px; background: var(--field); border-radius: var(--radius); border: 1px solid var(--border); }
.math-explanation.is-visible { display: block; }
.math-explanation h2 { color: var(--text); border-bottom: 1px solid var(--border); padding-bottom: 10px; margin: 0 0 18px; }
.math-explanation h3 { color: var(--accent); margin: 18px 0 8px; }
.math-explanation h3.total { color: var(--success); }
.math-explanation p { color: var(--text); line-height: 1.6; margin: 0; }
.report-title { display: flex; justify-content: space-between; gap: 18px; align-items: start; margin-bottom: 16px; }
.report-title h2 { border: 0; margin: 0; padding: 0; }
.report-title-side { display: grid; justify-items: end; gap: 8px; }
.report-kicker { color: var(--accent-2); font-size: 0.76rem; letter-spacing: 0.12em; margin: 0 0 4px; text-transform: uppercase; }
.report-generated { color: var(--muted); font-size: 0.86rem; white-space: nowrap; }
.report-print-button { white-space: nowrap; }
.report-answer { border: 1px solid rgba(92,200,167,0.45); border-radius: var(--radius); background: rgba(92,200,167,0.08); padding: 14px; margin-bottom: 14px; }
.answer-label { color: var(--muted); font-size: 0.82rem; margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.08em; }
.answer-value { font-size: 1.65rem; font-weight: 800; margin-bottom: 6px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; margin: 14px 0; }
.report-cardlet { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px; background: rgba(255,255,255,0.025); }
.report-cardlet span { display: block; color: var(--muted); font-size: 0.82rem; margin-bottom: 4px; }
.report-cardlet strong { display: block; font-size: 1rem; overflow-wrap: anywhere; }
.report-table { width: 100%; border-collapse: collapse; table-layout: fixed; margin: 10px 0 16px; }
.report-table th, .report-table td { border: 1px solid var(--border); padding: 8px; vertical-align: top; white-space: normal; overflow-wrap: anywhere; }
.report-table th { color: var(--text); background: rgba(255,255,255,0.06); }
.formula-table th { width: 34%; }
@media (max-width: 1180px) {
  .overview-grid, .result-grid, .grid.two, .field-grid.two { grid-template-columns: 1fr; }
  .hero { align-items: start; }
}
@media (max-width: 760px) {
  body { padding: 10px; }
  .hero { grid-template-columns: 1fr; }
  .hero-actions { justify-content: start; }
  .hero-badge { width: fit-content; }
  .setup-fields, .summary-grid, .kpi-grid { grid-template-columns: 1fr; }
  .card { padding: 14px; }
  .card-head { align-items: start; flex-direction: column; }
  .summary-actions .btn { width: 100%; }
}

@media print {
  @page { size: A4 landscape; margin: 9mm; }
  * { box-shadow: none !important; text-shadow: none !important; }
  html, body { width: auto !important; min-height: auto !important; background: #fff !important; color: #111 !important; overflow: visible !important; }
  body { padding: 0 !important; }
  body.is-printing .access-gate,
  body.is-printing .hero,
  body.is-printing .report-print-button,
  body.is-printing #new-flow-panel > :not(.report-card),
  body.is-printing .report-card > .card-head,
  body.is-printing #totalSummary > .kpi-grid,
  body.is-printing .summary-actions {
    display: none !important;
  }
  body.is-printing .app-shell,
  body.is-printing main,
  body.is-printing #new-flow-panel,
  body.is-printing .report-card,
  body.is-printing #totalSummary,
  body.is-printing .math-explanation {
    display: block !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    overflow: visible !important;
  }
  body.is-printing .report-card,
  body.is-printing .math-explanation {
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    color: #111 !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  body.is-printing .math-explanation h2,
  body.is-printing .math-explanation h3,
  body.is-printing .math-explanation p,
  body.is-printing .report-cardlet span,
  body.is-printing .report-cardlet strong,
  body.is-printing .report-generated,
  body.is-printing .report-kicker {
    color: #111 !important;
  }
  body.is-printing .math-explanation h2 {
    font-size: 18pt;
    margin: 0;
    padding: 0;
    border: 0;
  }
  body.is-printing .math-explanation h3 {
    font-size: 11pt;
    margin: 10pt 0 4pt;
    break-after: avoid;
    page-break-after: avoid;
  }
  body.is-printing .math-explanation p {
    font-size: 9pt;
    line-height: 1.35;
    margin: 0 0 6pt;
  }
  body.is-printing .report-title,
  body.is-printing .report-answer,
  body.is-printing .report-grid,
  body.is-printing .report-cardlet,
  body.is-printing .report-table {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.is-printing .report-title { margin-bottom: 8pt; }
  body.is-printing .report-answer {
    background: #eef8f4 !important;
    border: 1px solid #9fcfbe !important;
    padding: 8pt;
    margin-bottom: 8pt;
  }
  body.is-printing .answer-label {
    color: #315448 !important;
    font-size: 7pt;
  }
  body.is-printing .answer-value {
    font-size: 17pt;
    margin-bottom: 3pt;
  }
  body.is-printing .report-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 5pt;
    margin: 7pt 0;
  }
  body.is-printing .report-cardlet {
    background: #fff !important;
    border: 1px solid #d0d7de !important;
    padding: 5pt;
  }
  body.is-printing .report-cardlet span { font-size: 7pt; }
  body.is-printing .report-cardlet strong { font-size: 9pt; }
  body.is-printing .report-table,
  body.is-printing .report-table thead,
  body.is-printing .report-table tbody,
  body.is-printing .report-table tr,
  body.is-printing .report-table th,
  body.is-printing .report-table td {
    overflow: visible !important;
    white-space: normal !important;
  }
  body.is-printing .report-table {
    width: 100% !important;
    min-width: 0 !important;
    table-layout: fixed !important;
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
    margin: 5pt 0 9pt;
    break-inside: auto;
    page-break-inside: auto;
  }
  body.is-printing .report-table thead { display: table-header-group; }
  body.is-printing .report-table tfoot { display: table-footer-group; }
  body.is-printing .report-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  body.is-printing .report-table th,
  body.is-printing .report-table td {
    border: 1px solid #d0d7de !important;
    color: #111 !important;
    padding: 3pt 4pt;
    font-size: 7.2pt;
    line-height: 1.2;
    overflow-wrap: anywhere;
    vertical-align: top;
  }
  body.is-printing .detail-table th,
  body.is-printing .detail-table td {
    font-size: 6.4pt;
    padding: 2.5pt 3pt;
  }
  body.is-printing .report-table th {
    background: #f1f4f7 !important;
    font-weight: 700;
  }
  body.is-printing .formula-table th { width: 28%; }
  body.is-printing .renewal-report-table th,
  body.is-printing .renewal-report-table td {
    font-size: 6.6pt;
    padding: 2.5pt 3pt;
  }
}

/* Hide Hostinger/000webhost watermark */
div[style*="z-index: 9999999"] { display: none !important; }
.disclaimer { display: none !important; }
