:root {
  --navy-950: #082238;
  --navy-900: #123d63;
  --navy-800: #1c527e;
  --blue-500: #2f80c5;
  --blue-100: #dcecf8;
  --blue-50: #eff7fc;
  --ink: #172434;
  --muted: #607084;
  --line: #d9e2ec;
  --surface: #ffffff;
  --canvas: #f3f7fa;
  --input: #fff3c9;
  --input-border: #e5c756;
  --success: #13745b;
  --shadow: 0 16px 42px rgba(24, 55, 82, 0.09);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 88% -10%, rgba(76, 157, 216, 0.18), transparent 32rem),
    var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  height: 58px;
  padding: 0 max(24px, calc((100vw - 1480px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--navy-950);
  color: white;
}

.brand { display: flex; align-items: center; gap: 11px; font-weight: 750; letter-spacing: -0.01em; }
.brand-mark {
  width: 31px; height: 31px; display: grid; place-items: center;
  border-radius: 9px; background: #5db1e8; color: var(--navy-950); font-size: 12px; font-weight: 900;
}
.save-state { color: #b8c9d8; font-size: 12px; }

.page-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 42px 0 64px; }

.hero { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; margin-bottom: 28px; }
.eyebrow, .section-number { margin: 0 0 7px; color: var(--blue-500); font-size: 11px; font-weight: 850; letter-spacing: 0.14em; }
h1 { max-width: 720px; margin: 0; color: var(--navy-950); font-size: clamp(34px, 5vw, 58px); line-height: 0.98; letter-spacing: -0.05em; }
.hero-copy { max-width: 720px; margin: 16px 0 0; color: var(--muted); font-size: 16px; line-height: 1.6; }
.hero-actions, .forecast-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.button {
  min-height: 43px; border: 1px solid transparent; border-radius: 10px; padding: 0 17px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 750;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--navy-900); color: white; box-shadow: 0 9px 22px rgba(18, 61, 99, 0.18); }
.button-primary:hover { background: var(--navy-800); }
.button-secondary { background: white; color: var(--navy-900); border-color: #b8c8d6; }
.button-ghost { background: transparent; color: var(--muted); border-color: var(--line); }

.summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.metric-card {
  min-height: 110px; padding: 19px 21px; display: flex; flex-direction: column; justify-content: space-between;
  background: var(--surface); border: 1px solid rgba(204, 217, 229, 0.85); border-radius: 14px; box-shadow: 0 8px 28px rgba(31, 60, 84, 0.05);
}
.metric-accent { background: linear-gradient(135deg, var(--navy-900), var(--navy-800)); border-color: transparent; }
.metric-label { color: var(--muted); font-size: 12px; font-weight: 700; }
.metric-value { color: var(--navy-950); font-size: 29px; line-height: 1; letter-spacing: -0.04em; }
.metric-text { font-size: 22px; }
.metric-accent .metric-label { color: #c8ddec; }
.metric-accent .metric-value { color: white; }

.workspace { display: grid; grid-template-columns: minmax(300px, 0.8fr) minmax(560px, 1.5fr); gap: 18px; align-items: start; }
.panel, .forecast-section { background: var(--surface); border: 1px solid rgba(204, 217, 229, 0.9); border-radius: 16px; box-shadow: var(--shadow); }
.panel { padding: 23px; }
.panel-heading, .forecast-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
h2 { margin: 0; color: var(--navy-950); font-size: 22px; letter-spacing: -0.025em; }
.input-legend { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.input-legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--input); border: 1px solid var(--input-border); }

.settings-grid { display: grid; gap: 13px; margin-top: 21px; }
.field { display: grid; gap: 6px; }
.field > span { color: #425268; font-size: 12px; font-weight: 750; }
.field input, .field select, .auditor-row input {
  width: 100%; min-height: 42px; border: 1px solid var(--input-border); border-radius: 9px;
  background: var(--input); color: var(--navy-950); padding: 0 11px; outline: none;
}
.field input:focus, .field select:focus, .auditor-row input:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(47, 128, 197, 0.14); }
.parameter-row { margin-top: 16px; padding: 14px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-radius: 12px; background: var(--blue-50); border: 1px solid var(--blue-100); }
.parameter-help { grid-column: 1 / -1; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.compact-field { position: relative; }
.compact-field small { position: absolute; right: 11px; bottom: 13px; color: var(--muted); font-size: 10px; }

.panel-note { margin: 12px 0 17px; color: var(--muted); font-size: 12px; }
.text-button { border: 0; background: transparent; color: var(--blue-500); font-weight: 750; padding: 5px; }
.auditor-list-header, .auditor-row { display: grid; grid-template-columns: 58px minmax(180px, 1fr) 96px 118px; gap: 8px; align-items: center; }
.auditor-list-header { padding: 0 3px 7px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.auditor-list { display: grid; gap: 7px; }
.auditor-row { padding: 7px; border-radius: 10px; background: #f8fafc; border: 1px solid #e6edf3; }
.mt-badge { height: 34px; display: grid; place-items: center; border-radius: 8px; background: var(--blue-100); color: var(--navy-900); font-size: 11px; font-weight: 850; }
.auditor-row input { min-height: 36px; padding: 0 9px; font-size: 12px; }
.auditor-row input[type="number"] { text-align: right; }

.forecast-section { margin-top: 18px; padding: 23px; }
.forecast-heading { align-items: flex-end; margin-bottom: 17px; }
.forecast-heading p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.table-frame { overflow: auto; max-height: 68vh; border: 1px solid #cedbe5; border-radius: 12px; background: white; }
.forecast-table { border-collapse: separate; border-spacing: 0; min-width: 100%; width: max-content; font-size: 11px; }
.forecast-table th, .forecast-table td { min-width: 52px; height: 37px; padding: 0 9px; text-align: right; border-right: 1px solid #e2e9ef; border-bottom: 1px solid #e2e9ef; white-space: nowrap; }
.forecast-table thead th { position: sticky; top: 0; z-index: 3; background: var(--navy-900); color: white; font-weight: 800; text-align: center; }
.forecast-table .name-column { min-width: 210px; max-width: 260px; text-align: left; position: sticky; left: 0; z-index: 2; }
.forecast-table thead .name-column { z-index: 5; }
.forecast-table .start-column { min-width: 76px; position: sticky; left: 210px; z-index: 2; text-align: center; }
.forecast-table thead .start-column { z-index: 5; }
.forecast-table tbody .name-column, .forecast-table tbody .start-column { background: white; }
.forecast-table tbody tr:nth-child(even) td:not(.name-column):not(.start-column) { background: #f7fafc; }
.forecast-table .pre-start { color: #c4ced7; background: #f2f5f7 !important; }
.forecast-table .total-column { font-weight: 850; color: var(--navy-900); background: var(--blue-50) !important; }
.forecast-table .total-row td { position: sticky; bottom: 0; z-index: 3; background: var(--blue-100) !important; color: var(--navy-900); font-weight: 850; border-bottom: 0; }
.forecast-table .total-row .name-column { z-index: 4; }
.forecast-table .total-row .start-column { z-index: 4; }

.toast { position: fixed; right: 22px; bottom: 22px; padding: 12px 16px; border-radius: 10px; background: var(--navy-950); color: white; font-size: 12px; box-shadow: var(--shadow); opacity: 0; transform: translateY(12px); pointer-events: none; transition: 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 620px) {
  .topbar { padding: 0 16px; }
  .save-state { display: none; }
  .page-shell { width: min(100% - 22px, 1480px); padding-top: 26px; }
  h1 { font-size: 40px; }
  .hero-actions, .hero-actions .button { width: 100%; }
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .metric-card { min-height: 95px; padding: 16px; }
  .metric-value { font-size: 24px; }
  .panel, .forecast-section { padding: 16px; border-radius: 13px; }
  .auditor-list-header { display: none; }
  .auditor-row { grid-template-columns: 52px minmax(140px, 1fr) 82px; }
  .auditor-row .quantity-input { grid-column: 2 / -1; }
  .forecast-heading { align-items: flex-start; flex-direction: column; }
  .forecast-actions, .forecast-actions .button { width: 100%; }
}

@page { size: landscape; margin: 0.35in; }
@media print {
  body { background: white; }
  .no-print, .summary-grid, .workspace, .forecast-actions { display: none !important; }
  .page-shell { width: 100%; padding: 0; }
  .forecast-section { margin: 0; padding: 0; border: 0; box-shadow: none; }
  .forecast-heading { margin-bottom: 10px; }
  .table-frame { max-height: none; overflow: visible; border-radius: 0; }
  .forecast-table { width: 100%; font-size: 8px; }
  .forecast-table th, .forecast-table td { min-width: auto; height: 24px; padding: 0 3px; }
  .forecast-table .name-column, .forecast-table .start-column, .forecast-table thead th, .forecast-table .total-row td { position: static; }
}
