:root {
  --ink: #102a32;
  --muted: #5f7077;
  --brand: #0b2e38;
  --accent: #00bcd4;
  --accent-dark: #007d8d;
  --surface: #ffffff;
  --background: #f3f7f8;
  --line: #d9e3e6;
  --success: #137a4b;
  --warning: #9a5d00;
  --danger: #b42318;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(11, 46, 56, 0.08);
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; background: var(--background); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 1000; background: white; color: var(--brand); padding: .75rem 1rem; border-radius: .5rem; }
.skip-link:focus { top: 1rem; }

.app-header { min-height: 72px; display: flex; align-items: center; gap: 2rem; padding: .75rem clamp(1rem, 4vw, 4rem); background: var(--brand); color: white; position: sticky; top: 0; z-index: 20; box-shadow: 0 5px 20px rgba(0,0,0,.14); }
.brand { display: flex; align-items: center; gap: .75rem; color: white; text-decoration: none; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.brand img { border-radius: 10px; }
.main-nav { display: flex; margin-left: auto; gap: .5rem; }
.nav-button, .menu-button { border: 1px solid rgba(255,255,255,.25); background: transparent; color: #dce8ea; border-radius: 9px; padding: .65rem 1rem; font-weight: 700; }
.nav-button:hover, .nav-button:focus-visible, .nav-button.is-active { background: rgba(0,188,212,.14); border-color: var(--accent); color: white; }
.menu-button { display: none; margin-left: auto; }

main { width: min(1440px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); }
.view:not(.is-active) { display: none; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1.5rem; }
.page-heading h1 { margin: .1rem 0 0; font-size: clamp(1.7rem, 4vw, 2.5rem); line-height: 1.1; }
.eyebrow { margin: 0; color: var(--accent-dark); font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; }

.calculator-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(300px, .85fr); gap: 1.5rem; align-items: start; }
.settings-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.settings-layout > *, .settings-layout .panel { min-width: 0; }
.settings-layout form { overflow: hidden; }
.bands-tabs { display: flex; gap: .45rem; overflow-x: auto; padding: .2rem 0 .85rem; margin-bottom: .4rem; }
.bands-tabs::-webkit-scrollbar { height: 7px; }.bands-tabs::-webkit-scrollbar-thumb { background: #8ba1a8; border-radius: 8px; }
.settings-layout .section-header .button-row { flex-wrap: nowrap; justify-content: flex-end; }
.settings-layout .section-header .button { white-space: nowrap; }
.band-tab { flex: 0 0 auto; border: 1px solid var(--line); background: #edf2f4; color: var(--ink); padding: .58rem .72rem; border-radius: 8px; font-weight: 750; }
.band-tab.is-active { background: var(--brand); color: white; border-color: var(--brand); }
.settings-matrix { position: sticky; top: 96px; }
.matrix-table { min-width: 760px; }
.matrix-table td { font-size: .74rem; white-space: nowrap; }
.matrix-table td:nth-last-child(3) { color: var(--accent-dark); font-weight: 850; }.matrix-table td:nth-last-child(2) { color: #9a5d00; font-weight: 850; }.matrix-table td:last-child { color: var(--danger); font-weight: 850; }
.validation-title { margin-top: 1.5rem !important; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.volume-table { min-width: 480px; }.volume-table input { min-width: 86px; text-align: center; }
.selected-band-editor { display: grid; gap: .85rem; padding: 1rem 0; }.selected-band-editor h2 { margin: 0; font-size: .95rem; }.workload { padding: 1rem; border-left: 4px solid var(--accent); background: #eef3f5; border-radius: 8px; }
.panel, .result-card, .kpi { background: var(--surface); border: 1px solid rgba(11,46,56,.07); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel { padding: clamp(1rem, 2.5vw, 1.6rem); }
.stack { display: grid; gap: 1.25rem; }
fieldset { min-width: 0; margin: 0; padding: 0 0 1.2rem; border: 0; border-bottom: 1px solid var(--line); }
fieldset:last-child { border-bottom: 0; padding-bottom: 0; }
legend, .panel h2 { margin: 0 0 1rem; padding: 0; font-size: 1.05rem; font-weight: 850; }
.subheading { margin: 1.25rem 0 .75rem; font-size: .95rem; }
.form-grid { display: grid; gap: .9rem 1rem; }
.form-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid-5 { grid-template-columns: repeat(5, minmax(130px, 1fr)); }
label { display: grid; gap: .35rem; color: #40545b; font-size: .82rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #cbd8dc; border-radius: 9px; padding: .6rem .72rem; background: white; color: var(--ink); }
input:focus-visible, select:focus-visible, button:focus-visible { outline: 3px solid rgba(0,188,212,.32); outline-offset: 2px; border-color: var(--accent-dark); }
input[aria-invalid="true"] { border-color: var(--danger); }
.check-row { display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; }
.check-row input, .service-item input[type="checkbox"] { width: 1.15rem; min-height: 1.15rem; accent-color: var(--accent-dark); }
.service-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .65rem; }
.service-item { display: flex; gap: .6rem; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: .75rem; font-size: .86rem; }
.service-item span:last-child { margin-left: auto; font-weight: 800; }
.service-item input[type="number"] { width: 86px; min-height: 34px; padding: .35rem; margin-left: auto; }

.results-column { display: grid; gap: 1rem; position: sticky; top: 96px; }
.result-card { padding: clamp(1.25rem, 3vw, 2rem); color: white; background: linear-gradient(145deg, #0b2e38, #124b59); }
.band-chip, .status-chip { display: inline-flex; align-items: center; width: fit-content; border-radius: 999px; padding: .35rem .7rem; font-size: .75rem; font-weight: 900; }
.band-chip { background: rgba(0,188,212,.17); border: 1px solid var(--accent); color: #8ff4ff; }
.status-chip { background: white; border: 1px solid var(--line); color: var(--muted); }
.status-success { color: var(--success); border-color: #88ceb0; background: #effbf5; }
.status-error { color: var(--danger); border-color: #f0a39c; background: #fff4f2; }
.result-label { margin: 1.4rem 0 .2rem; color: #c8d9dd; font-weight: 700; }
.money-large { display: block; font-size: clamp(2.1rem, 5vw, 3.4rem); line-height: 1; color: #5deaff; }
.margin-note { min-height: 1.5rem; color: #d6e8eb; font-size: .85rem; }
.result-list { margin: 1.4rem 0; }
.result-list div { display: flex; justify-content: space-between; gap: 1rem; padding: .65rem 0; border-bottom: 1px solid rgba(255,255,255,.13); }
.result-list dt { color: #d6e8eb; }
.result-list dd { margin: 0; font-weight: 850; }
.result-list .result-total { border: 0; font-size: 1.08rem; }
.button-row { display: flex; flex-wrap: wrap; gap: .7rem; }
.button { min-height: 42px; border-radius: 9px; padding: .65rem 1rem; border: 1px solid transparent; font-weight: 850; }
.button-primary { background: var(--accent); color: #06262e; }
.button-primary:hover { background: #38d2e4; }
.button-secondary { background: white; border-color: var(--line); color: var(--brand); }
.button-danger { background: var(--danger); color: white; }
.metrics-card h2 { font-size: 1rem; }
.metrics-card h2 span { float: right; font-size: .72rem; color: var(--muted); font-weight: 500; }
.volume-details { margin: .75rem 0; padding: .7rem .85rem; border: 1px solid rgba(0,188,212,.55); border-radius: 8px; background: rgba(0,188,212,.08); color: #dceff2; font-size: .7rem; }
.volume-details p { margin: 0; padding: .38rem 0; border-bottom: 1px dotted rgba(255,255,255,.35); font-weight: 650; }
.volume-details p:last-child { border-bottom: 0; }
.metrics-grid { grid-template-columns: 1fr; }
.metrics-grid div { display: flex; justify-content: space-between; align-items: center; padding: .45rem 0; border-bottom: 1px dotted var(--line); background: transparent; border-radius: 0; }
.metrics-grid div:last-child { border-bottom: 0; }
.metrics-grid dd { color: var(--accent-dark); }
.metrics-grid div:last-child dd { background: #d8f2df; color: var(--success); padding: .2rem .45rem; border-radius: 4px; }
.metrics-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .8rem; margin: 0; }
.metrics-grid div { padding: .8rem; background: #f5f9fa; border-radius: 9px; }
.metrics-grid dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.metrics-grid dd { margin: .25rem 0 0; font-weight: 900; }

.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.kpi { padding: 1.2rem; border-left: 4px solid var(--accent); }
.kpi span { color: var(--muted); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.kpi strong { display: block; margin-top: .35rem; font-size: 1.5rem; }
.kpi-highlight strong { color: var(--accent); }
.info-icon { display: inline-grid; place-items: center; width: 1rem; height: 1rem; padding: 0; border: 0; border-radius: 50%; background: #b8c2c6; color: white; font-size: .7rem; font-weight: 900; vertical-align: middle; position: relative; }
.info-icon::after { content: attr(data-tooltip); display: none; position: absolute; z-index: 30; top: 1.35rem; left: 50%; transform: translateX(-50%); width: 180px; padding: .55rem; border-radius: 7px; background: var(--brand); color: white; font-size: .72rem; line-height: 1.35; text-transform: none; letter-spacing: normal; }
.info-icon:hover::after, .info-icon:focus-visible::after { display: block; }
.section-header { display: flex; justify-content: space-between; align-items: end; gap: 1rem; margin-bottom: 1rem; }
.section-header h2, .section-header p { margin: 0; }
.section-header p { color: var(--muted); font-size: .82rem; }
.search-label { min-width: min(300px, 100%); }
.table-panel { min-width: 0; }
.table-scroll { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; min-width: 780px; }
.data-table th { padding: .75rem; background: var(--brand); color: white; text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }
.data-table td { padding: .75rem; border-bottom: 1px solid var(--line); font-size: .84rem; vertical-align: middle; }
.data-table tbody tr:hover { background: #f6fafb; }
.data-table.compact { min-width: 1180px; }
.data-table.compact input { min-width: 92px; }
.data-table .action-cell { display: flex; gap: .4rem; }
.small-button { border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--brand); padding: .4rem .55rem; font-weight: 750; }
.status-select { min-width: 110px; }

dialog { width: min(520px, calc(100% - 2rem)); padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(5,24,29,.7); }
.dialog-content { display: grid; gap: 1rem; padding: 1.4rem; }
.dialog-header { display: flex; justify-content: space-between; align-items: center; }
.dialog-header h2 { margin: 0; }
.icon-button { border: 0; background: transparent; font-size: 1.6rem; color: var(--muted); }
.dialog-actions { justify-content: flex-end; margin-top: .5rem; }
.toast { position: fixed; right: 1rem; bottom: 1rem; z-index: 50; max-width: min(420px, calc(100% - 2rem)); padding: .9rem 1rem; background: var(--brand); color: white; border-radius: 10px; box-shadow: var(--shadow); }
.empty-state { text-align: center; color: var(--muted); padding: 2rem !important; }
.muted-copy { margin: 0; color: var(--muted); }
.align-end { display: flex; align-items: end; }

@media (max-width: 1050px) {
  .calculator-layout { grid-template-columns: 1fr; }
  .results-column { position: static; }
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .form-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .settings-layout { grid-template-columns: 1fr; }.settings-matrix { position: static; }
}

@media (max-width: 720px) {
  .app-header { flex-wrap: wrap; gap: .5rem; }
  .brand span { font-size: .92rem; letter-spacing: 0; }
  .menu-button { display: block; }
  .main-nav { display: none; width: 100%; flex-direction: column; }
  .main-nav.is-open { display: flex; }
  .nav-button { width: 100%; text-align: left; }
  main { padding: 1rem; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .form-grid-2, .form-grid-3, .form-grid-5, .service-list, .kpi-grid { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .section-header { align-items: stretch; flex-direction: column; }
  .search-label { min-width: 0; }
}

@media print {
  .app-header, .page-heading, .calculator-layout > form, .button-row, .toast { display: none !important; }
  body, main { background: white; padding: 0; }
  .calculator-layout { display: block; }
  .results-column { display: block; }
  .result-card { color: var(--ink); background: white; box-shadow: none; border: 2px solid var(--brand); }
  .result-card * { color: var(--ink) !important; }
  .metrics-card { box-shadow: none; margin-top: 1rem; }
}
