@font-face {
  font-family: Manrope;
  src: url('./assets/Manrope.ttf') format('truetype');
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  font: 16px/1.5 Manrope, system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  --radius: 22px;
  --ease: cubic-bezier(.2, .75, .3, 1);
}

* { box-sizing: border-box; }
html { scroll-padding-top: 88px; }
body, h1, h2, p { margin: 0; }
body { min-width: 0; }
h1 { font-size: clamp(36px, 6vw, 66px); line-height: 1.08; letter-spacing: -.052em; font-weight: 800; }
h2 { font-size: 21px; line-height: 1.2; letter-spacing: -.045em; font-weight: 800; }
p { color: var(--muted); }
a { color: var(--wine); }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid #a14922; outline-offset: 3px; }

main, .top { width: min(100%, 1160px); margin-inline: auto; padding-inline: 24px; }
.skip-link { position: fixed; z-index: 3; left: 12px; top: 12px; padding: 8px 12px; background: white; transform: translateY(-160%); }
.skip-link:focus { transform: none; }

.site-header {
  position: sticky;
  z-index: 2;
  top: 0;
  border-bottom: 1px solid var(--line);
  background: #f8f8faf5;
}
.top { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 30px; min-height: 72px; }

.brand span { color: var(--wine-dark); font-size: .75em; letter-spacing: -.025em; white-space: nowrap; }
.section-nav { display: flex; align-items: center; gap: clamp(8px, 2vw, 24px); }
.section-nav a { color: var(--muted); font-size: 14px; font-weight: 750; padding: 10px 0; text-decoration: none; }
.section-nav a:hover { color: var(--wine); }
.year { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 14px; font-weight: 700; white-space: nowrap; }

.intro, .section-head, .record, .actions { display: flex; align-items: center; gap: 14px; }
.intro, .section-head, .record { justify-content: space-between; }
.intro { margin-block: 42px 24px; align-items: end; }
.actions { flex-wrap: wrap; }
section[id] { scroll-margin-top: 12px; }

.metrics {
  display: grid;
  grid-template-columns: 1fr 1.06fr;
  min-height: 198px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  margin-bottom: 16px;
}
.metric { min-width: 0; padding: 14px 0; }
.metric p { color: var(--muted); font-size: 14px; }
.metric strong { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; font-size: clamp(16px, 2.45vw, 23px); letter-spacing: -.04em; }
.metric.accent { display: flex; min-height: 198px; flex-direction: column; justify-content: center; gap: 2px; padding: 24px 30px; background: #f3e8f0; }
.metric.accent p { color: var(--wine); font-weight: 700; }
.metric.accent strong { font-size: clamp(32px, 7vw, 68px); line-height: 1.15; letter-spacing: -.05em; }
.metric-breakdown { display: grid; align-content: center; padding: 10px 24px; }
.metric-breakdown .metric { display: grid; grid-template-columns: minmax(0, 1fr) minmax(80px, auto); align-items: center; gap: 10px; }
.metric-breakdown .metric + .metric { border-top: 1px solid var(--line); }
.metric-breakdown strong { text-align: right; }

.grid, .fields { display: grid; gap: 16px; }
.grid { grid-template-columns: 1fr 1.2fr; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; margin-bottom: 16px; min-width: 0; }
.panel p { margin-top: 6px; }
.panel:target { border-color: #b08696; }

#threshold { margin-top: 16px; }
.threshold-status { font-weight: 750; font-size: 14px; }
.positive { color: #245c4b; }
.alert { color: #8f3317; font-weight: 750; }
.gauge { overflow: hidden; background: #efe6df; border-radius: 12px; height: 10px; margin-top: 14px; }
.gauge-fill { display: block; height: 100%; background: var(--wine); border-radius: inherit; transform-origin: left center; }
.gauge[data-status="next"] .gauge-fill, .gauge[data-status="immediate"] .gauge-fill { background: var(--rust); }
.threshold-caption { font-size: 13px; }
.threshold-figures { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 18px; }
.threshold-figures p { font-size: 13px; }
.threshold-figures strong { font-size: clamp(17px, 2.5vw, 25px); letter-spacing: -.05em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

.bars { position: relative; isolation: isolate; display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; height: 142px; margin-top: 14px; }
.bar { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 5px; cursor: pointer; min-width: 0; text-align: center; }
.bar-label { color: var(--muted); font-size: 10px; font-weight: 700; padding-block: 2px; border-radius: 5px; }
.bars::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  z-index: -1;
  width: calc((100% - 44px) / 12);
  border-radius: 6px;
  background: #f5ebe6;
  transform: translateX(calc(var(--month, 0) * (100% + 4px)));
}
.bar.selected .bar-label { color: var(--wine-dark); }
.bar-fill { display: flex; align-items: flex-end; align-self: end; margin-inline: auto; width: 68%; min-height: 2px; border-radius: 6px 6px 2px 2px; overflow: hidden; background: var(--wine); transform-origin: center bottom; }
.bar-fill.empty { background: #e4d8d2; }
.bar-reserve { display: block; width: 100%; background: var(--rust); }
.chart-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.chart-foot select { font-size: 13px; text-transform: capitalize; }
.chart-foot .chart-readout { margin: 0; color: var(--ink); font-weight: 750; font-size: 13px; overflow-wrap: anywhere; }
.chart-key { font-size: 12px; }

button, input, select, textarea {
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #b9a9a5;
  border-radius: 10px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
}
button { min-height: 44px; cursor: pointer; font-weight: 750; }
button:hover:not(:disabled) { background: #f6ece5; }
button:disabled { opacity: .55; cursor: default; }
.primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.primary:hover:not(:disabled) { background: var(--wine-dark); border-color: var(--wine-dark); }
.primary span { margin-right: 3px; }
.record { padding-block: 12px; border-bottom: 1px solid var(--line); }
.record:last-child { border-bottom: 0; padding-bottom: 0; }
.record > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.record small { display: block; color: var(--muted); }
.record .actions button { font-size: 13px; }
.empty-state { border-top: 1px solid var(--line); padding-top: 14px; }
.panel .empty-state { margin-top: 14px; }

.fields { grid-template-columns: repeat(3, minmax(0, 1fr)); margin-block: 16px; }
.fields label, dialog label { display: grid; gap: 5px; font-weight: 700; }
.field-note { grid-column: span 2; align-self: end; font-size: 14px; }
.ateco-field, .document { grid-column: 1 / -1; }
.ateco-field > input, .document textarea { display: block; width: 100%; margin-top: 5px; }
#ateco-results { display: grid; gap: 4px; margin-top: 6px; }
#ateco-results button { text-align: left; font-size: 14px; }
.document { padding: 12px; background: #f3f2f5; border-radius: 10px; }
summary { color: var(--wine); cursor: pointer; font-weight: 750; }
.document textarea { resize: vertical; }
.document label { margin-block: 8px; }
#document-result, #profile-status { font-size: 14px; }
#verify-vat { display: inline-block; margin-top: 4px; }
.help { margin-bottom: 12px; }
.backup .actions { margin-top: 12px; }
footer { padding: 4px 0 24px; color: var(--muted); font-size: 13px; }
#notice { background: #f4e8e3; color: var(--wine); padding: 10px 12px; border-radius: 10px; margin-bottom: 14px; }

dialog {
  width: min(460px, calc(100% - 24px));
  max-height: calc(100% - 24px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  color: inherit;
}
dialog::backdrop { background: #2f192399; }
dialog form { display: grid; gap: 13px; }
#done { display: flex; align-items: center; }

@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color 140ms var(--ease), border-color 140ms var(--ease), transform 140ms var(--ease); }
  button:active:not(:disabled) { transform: scale(.98); }
  .bars::before { transition: transform 200ms var(--ease); }
  .vault-card { animation: enter 240ms var(--ease) both; }
  #notice:not([hidden]) { animation: enter 160ms var(--ease) both; }
  dialog[open]::backdrop { animation: dim-in 170ms ease-out both; }
  @keyframes dim-in { from { opacity: 0; } to { opacity: 1; } }
  .metrics { animation: enter 270ms var(--ease) both; }
  .gauge-fill, .bar-fill:not(.empty) { animation: grow 380ms var(--ease) both; }
  .gauge-fill { animation-name: grow-inline; }
  dialog[open] { animation: enter 210ms var(--ease) both; }
  @keyframes enter {
    from { opacity: 0; transform: translateY(7px); }
    to { opacity: 1; transform: translateY(0); }
  }
  @keyframes grow { from { transform: scaleY(0); } }
  @keyframes grow-inline { from { transform: scaleX(0); } }
}

@media (max-width: 860px) {
  html { scroll-padding-top: 116px; }
  .top { grid-template-columns: 1fr auto; gap: 2px 12px; min-height: auto; padding-block: 10px 4px; }
  .section-nav { grid-column: 1 / -1; grid-row: 2; justify-content: space-between; }
  .grid { grid-template-columns: 1fr; gap: 0; }
  .fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .field-note { grid-column: auto; }
}
@media (max-width: 510px) {
  main, .top { padding-inline: 14px; }
  .intro, .section-head, .record { flex-direction: column; align-items: flex-start; }
  .intro { margin-block: 26px 18px; gap: 12px; }
  .metrics { grid-template-columns: 1fr; }
  .metric.accent { min-height: 124px; padding: 20px; }
  .metric-breakdown { padding: 4px 16px; }
  .metric p { font-size: 13px; }
  .panel { padding: 16px; }
  .fields { grid-template-columns: 1fr; }
  .year { font-size: 12px; }
  .section-nav a { font-size: 13px; }
}

.account-controls { display: flex; align-items: center; gap: 8px; }
#lock-vault { font-size: 13px; padding-inline: 10px; }
.vault-gate { width: min(100%, 476px); padding: clamp(24px, 8vh, 78px) 18px 24px; }
.vault-intro .brand { display: inline-flex; align-items: center; }

.vault-intro { margin-bottom: 24px; }
.vault-intro p { margin-top: 2px; font-size: 14px; }
.vault-card { padding: clamp(20px, 5vw, 32px); background: white; border: 1px solid var(--line); border-radius: var(--radius); }
.vault-card h1 { font-size: clamp(29px, 8vw, 42px); letter-spacing: -.055em; }
#gate-copy { margin-block: 12px 20px; }
.vault-form { display: grid; gap: 12px; }
.vault-form label { display: grid; gap: 5px; font-weight: 700; }
.vault-form input { width: 100%; }
.vault-actions { display: flex; flex-wrap: wrap; margin-top: 8px; }
.text-button { padding-inline: 0; color: var(--wine-dark); background: transparent; border-color: transparent; }
.text-button:hover:not(:disabled) { background: transparent; text-decoration: underline; }
.form-feedback { color: #8f3317; font-size: 14px; }
.form-feedback:empty { display: none; }
.vault-footnote { margin-top: 16px; font-size: 13px; }
@media (max-width: 360px) {
  .account-controls { gap: 5px; }
  .account-controls .year { gap: 4px; }
  .account-controls select { padding-inline: 6px; }
  .top { column-gap: 6px; }
  .top .brand { font-size: 16px; gap: 5px; }
  .top .brand img { width: 27px; height: 27px; border-radius: 7px; }
  #lock-vault { padding-inline: 6px; }
}
#gate-error:not(:empty) { margin-bottom: 12px; }
#password-note { font-size: 13px; margin-top: -6px; }
.report-actions { margin-top: 16px; }
.reserve-summary { color: var(--muted); font-size: 13px; padding-block: 4px; }

.tax-balance { margin-top: 16px; padding: 12px; background: #f3f2f5; border-radius: 10px; }
.tax-balance:empty { display: none; }
.tax-balance p { margin: 0; font-size: 13px; }
#f24-planner { margin-top: 16px; }
#f24-rows .record { align-items: start; }
.f24-sources { font-size: 13px; }
.tax-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(96px, .7fr); gap: 8px; }
.cloud-form { max-width: 420px; margin-top: 16px; }
.support { max-width: 740px; padding-block: 36px; }
.support h1 { margin-block: 24px; }
.support p + p { margin-top: 12px; }

.metric-breakdown .metric-hint {
  padding-block: 10px 6px;
  color: var(--muted);
  font-size: 13px;
}
.metric-hint a { color: inherit; text-underline-offset: 3px; }

.site-header { background: #f8f8faee; }
@supports (backdrop-filter: blur(12px)) {
  .site-header { background: #f8f8fad9; backdrop-filter: blur(12px); }
}
.section-nav { gap: clamp(2px, 1vw, 14px); }
.section-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px clamp(7px, 1vw, 14px);
  border-radius: 9px;
}
.section-nav a:hover, .section-nav a[aria-current="location"] {
  background: #f0e2e5;
  color: var(--wine);
}
.metric.accent strong { color: var(--wine); }
.external-action {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding-inline: 8px;
  text-underline-offset: 4px;
  font-weight: 700;
}
.secondary-action { color: var(--wine); border-color: #bc9caa; }
dialog { background: var(--surface); }
dialog .actions { justify-content: flex-end; }
.vault-card { box-shadow: 0 16px 38px #37142410; }
@media (max-width: 860px) {
  .section-nav { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .section-nav a { padding-inline: 2px; }
}
@media (max-width: 510px) {
  .intro .primary { width: 100%; }
}

/* Workspace navigation adapts independently of the data panels. */
.app-layout {
  width: min(100%, 1440px);
  margin-inline: auto;
  display: grid;
  grid-template-columns: 176px minmax(0, 1fr);
  gap: clamp(20px, 3vw, 48px);
  padding-inline: clamp(20px, 3vw, 48px);
}
.app-layout main { width: 100%; padding-inline: 0; min-width: 0; }
#workspace .top {
  width: min(100%, 1440px);
  padding-inline: clamp(20px, 3vw, 48px);
  grid-template-columns: 1fr auto;
}
.app-layout .section-nav {
  position: sticky;
  top: 96px;
  align-self: start;
  display: grid;
  grid-template-columns: 1fr;
  gap: 4px;
  margin-top: 42px;
}
.app-layout .section-nav a { justify-content: start; gap: 10px; padding: 12px; }
.section-nav svg { flex: none; }
@media (min-width: 641px) and (max-width: 1050px) {
  .app-layout { grid-template-columns: 94px minmax(0, 1fr); gap: 16px; }
  .app-layout .section-nav a { flex-direction: column; justify-content: center; padding: 10px 4px; gap: 4px; }
}
@media (max-width: 860px) {
  html { scroll-padding-top: 78px; }
  #workspace .top { min-height: 62px; padding-block: 6px; }
  .app-layout .section-nav { grid-column: auto; grid-row: auto; top: 80px; }
}
@media (max-width: 640px) {
  html { scroll-padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .app-layout { display: block; padding: 0 max(14px, env(safe-area-inset-right)) calc(80px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
  #workspace .top { padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right)); }
  .app-layout .section-nav {
    position: fixed;
    z-index: 2;
    inset: auto 0 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    margin: 0;
    padding: 5px max(6px, env(safe-area-inset-right)) calc(5px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: var(--surface);
  }
  .app-layout .section-nav a { flex-direction: column; justify-content: center; gap: 2px; padding: 5px 2px; font-size: .78rem; }
  dialog { max-height: calc(100dvh - 20px); overflow-y: auto; overscroll-behavior: contain; }
}
.workspace-mode { display:flex; align-items:center; justify-content:space-between; gap:10px; margin:24px 0 0; }
.workspace-mode label { display:flex; align-items:center; flex-wrap:wrap; gap:8px; font-weight:700; }
.company-totals { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,170px),1fr)); gap:12px; margin-top:18px; }
.company-totals div { background:var(--paper); padding:14px; border-radius:12px; overflow-wrap:anywhere; }
.company-totals strong { font-size:1.35rem; color:var(--wine); }
#agent-notice { margin-top: 0; }
.agent-line { display: flex; justify-content: space-between; gap: 12px; padding-block: 10px; border-bottom: 1px solid var(--line); }
.agent-line span { color: var(--muted); }
.agent-line strong { font-variant-numeric: tabular-nums; white-space: nowrap; }
.agent-line.agent-total { border-bottom: 0; }
.agent-line.agent-total span { color: var(--ink); font-weight: 750; }
.agent-line.agent-total strong { color: var(--wine); font-size: 1.25rem; }
#agent-income details { margin-top: 12px; }
#agent-income details .agent-line { font-size: 13px; }
.agent-pair { display: flex; align-items: flex-end; justify-content: center; gap: 2px; min-height: 0; height: 100%; }
.agent-pair span { width: 38%; min-height: 2px; border-radius: 4px 4px 1px 1px; }
.agent-in { background: var(--wine); }
.agent-out { background: var(--rust); }
.agent-legend { display: flex; flex-wrap: wrap; gap: 14px; }
.agent-legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; margin-right: 6px; border-radius: 50%; }
.agent-key-in::before { background: var(--wine); }
.agent-key-out::before { background: var(--rust); }
.agent-check { display: flex !important; align-items: center; gap: 8px; align-self: end; }
.agent-check input { width: auto; }
.record.agent-next strong:first-child { color: var(--wine); }
.agent-sources { font-size: 12px; }
