/* Nordic Night. Dark palette from Main/Confirm, light from Mac. Layout: phone below 900px, sidebar + grid at 900px and up. */
:root {
  --bg: #F2F3F5; --side: #ECEDF0; --card: #FFFFFF; --tile: #FFFFFF; --line: #E3E5EA; --row: #EEF0F3;
  --ink: #0E1116; --sub: #4A5160; --muted: #5F6675; --track: #E3E5EA; --grid: #EEF0F3; --axis: #D5D8DE;
  --blue: #2F4FD8; --green: #0B8A5E; --red: #B42318; --amber: #E89A2C; --purple: #6D4ED6; --grey: #8A919C;
  --forecast-a: #F6C88A; --forecast-b: #FCE7CB;
  --pill-bg: #0E1116; --pill-ink: #FFFFFF; --ghost-line: #D5D8DE;
  --warn-bg: #FDECEA; --warn-line: transparent; --warn-ink: #8F1C13; --warn-icon-bg: #FBD5D0; --warn-icon: #B42318;
  --red-bg: #FDECEA; --red-ink: #B42318;
  --ok-bg: #E8F6EF; --ok-line: #BFE8D5; --ok-ink: #0B6B48; --ok-icon: #0B8A5E;
  --sheet: #FFFFFF; --scrim: rgba(14, 17, 22, .35);
  --serif: "Space Grotesk", system-ui, sans-serif; --sans: Inter, system-ui, -apple-system, sans-serif;
  --radius-card: 22px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B0D10; --side: #0B0D10; --card: #14171C; --tile: #1B1F26; --line: rgba(255, 255, 255, .07); --row: rgba(255, 255, 255, .06);
    --ink: #F3F4F6; --sub: #A3AAB6; --muted: #7D8590; --track: #232831; --grid: rgba(255, 255, 255, .06); --axis: #3A404A;
    --blue: #7B93FF; --green: #4FD8A4; --red: #FF8A7A; --amber: #FFB547; --purple: #B79CFF; --grey: #8A919C;
    --forecast-a: rgba(255, 181, 71, .55); --forecast-b: rgba(255, 181, 71, .16);
    --pill-bg: #F3F4F6; --pill-ink: #0B0D10; --ghost-line: rgba(255, 255, 255, .1);
    --warn-bg: #2A1714; --warn-line: rgba(255, 138, 122, .25); --warn-ink: #FFD3CC; --warn-icon-bg: rgba(255, 138, 122, .16); --warn-icon: #FF8A7A;
    --red-bg: rgba(255, 138, 122, .14); --red-ink: #FF8A7A;
    --ok-bg: #0F1A16; --ok-line: rgba(79, 216, 164, .25); --ok-ink: #A8EBD0; --ok-icon: #4FD8A4;
    --sheet: #14171C; --scrim: rgba(0, 0, 0, .6);
  }
}
:root[data-theme="dark"] {
  --bg: #0B0D10; --side: #0B0D10; --card: #14171C; --tile: #1B1F26; --line: rgba(255, 255, 255, .07); --row: rgba(255, 255, 255, .06);
  --ink: #F3F4F6; --sub: #A3AAB6; --muted: #7D8590; --track: #232831; --grid: rgba(255, 255, 255, .06); --axis: #3A404A;
  --blue: #7B93FF; --green: #4FD8A4; --red: #FF8A7A; --amber: #FFB547; --purple: #B79CFF; --grey: #8A919C;
  --forecast-a: rgba(255, 181, 71, .55); --forecast-b: rgba(255, 181, 71, .16);
  --pill-bg: #F3F4F6; --pill-ink: #0B0D10; --ghost-line: rgba(255, 255, 255, .1);
  --warn-bg: #2A1714; --warn-line: rgba(255, 138, 122, .25); --warn-ink: #FFD3CC; --warn-icon-bg: rgba(255, 138, 122, .16); --warn-icon: #FF8A7A;
  --red-bg: rgba(255, 138, 122, .14); --red-ink: #FF8A7A;
  --ok-bg: #0F1A16; --ok-line: rgba(79, 216, 164, .25); --ok-ink: #A8EBD0; --ok-icon: #4FD8A4;
  --sheet: #14171C; --scrim: rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--sans); font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
p, h1, h2 { margin: 0; }
button { font: inherit; }
[hidden] { display: none !important; }
.num, .nm, .big, .h1, .rate .v, .tile .v, .row-f input, .pay-amt { font-family: var(--serif); }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.side { display: none; }
.main { padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px calc(env(safe-area-inset-bottom, 0px) + 32px); }
.main-inner { display: flex; flex-direction: column; gap: 12px; }

/* header */
.top { display: grid; grid-template-columns: 44px 1fr 44px; align-items: center; padding: 0 0 6px; }
.top > div:nth-child(2) { text-align: center; min-width: 0; }
.top-r { grid-column: 1 / -1; justify-self: center; margin-top: 10px; }
.top-r:empty { display: none; }
.count { font-size: 13px; color: var(--sub); letter-spacing: .02em; }
.h1 { margin-top: 2px; font-size: 34px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.yarrows { display: flex; gap: 6px; }
.yarrow {
  width: 44px; height: 44px; border-radius: 22px; border: 1px solid var(--ghost-line);
  background: var(--card); color: var(--ink); display: grid; place-items: center; cursor: pointer;
}
.yarrow:disabled { color: var(--muted); cursor: default; }
.pill-head { display: none; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px; }
.lbl { font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 4px; display: inline-block; flex: none; }
.dot.sm { width: 8px; height: 8px; }

/* hero: ring on phone, bar on wide */
.hero { display: flex; flex-direction: column; align-items: center; padding: 22px 20px 20px; border-radius: 28px; }
.gauge { position: relative; width: 260px; height: 236px; }
.gauge svg { display: block; }
.gauge-c { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding-top: 6px; }
.gauge-c .g-num { margin-top: 2px; font-size: 54px; font-weight: 500; letter-spacing: -.035em; line-height: 1.05; }
.gauge-c .g-sub { margin-top: 6px; font-size: 13px; color: var(--sub); }
.rates { display: grid; grid-template-columns: 1fr 1fr; width: 100%; max-width: 300px; margin: 6px auto 0; }
.rates.single { grid-template-columns: 1fr; max-width: 150px; }
.rate { min-width: 0; display: flex; flex-direction: column; align-items: center; text-align: center; padding: 4px 8px; }
.rate + .rate { border-left: 0.5px solid var(--line); }
.rate .k { font-size: 12px; color: var(--sub); white-space: nowrap; }
.rate .v { margin: 4px 0 0; font-size: 28px; font-weight: 500; line-height: 1.1; letter-spacing: -.01em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rate-next .v { color: var(--red); }
.rate-up { display: inline-block; vertical-align: 0; margin-left: 4px; }
.rate .rate-sub { margin-top: 2px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.heroL .rates { display: none; }
.heroL { display: none; }
.barWrap { width: 100%; }
.bar-track { position: relative; height: 28px; border-radius: 14px; background: var(--track); overflow: hidden; }
.bar-used { position: absolute; left: 0; top: 0; bottom: 0; background: var(--amber); }
.bar-fore { position: absolute; top: 0; bottom: 0; background: repeating-linear-gradient(-45deg, var(--forecast-a) 0 6px, var(--forecast-b) 6px 12px); }
.bar-limit { position: absolute; top: -10px; height: 48px; width: 2px; background: var(--red); }
.bar-legend { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 12px; margin-top: 16px; font-size: 13px; color: var(--sub); }
.bar-legend span { display: flex; align-items: center; gap: 6px; }
.bar-legend .lim { color: var(--red); font-weight: 600; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

/* warning */
.warn {
  position: relative; display: flex; gap: 12px; align-items: flex-start; width: 100%; margin-top: 12px;
  background: var(--warn-bg); border: 1px solid var(--warn-line); border-radius: 22px; padding: 14px 16px;
}
.warn > div:not(.warn-ico) { padding-right: 36px; }
.warn-x {
  position: absolute; top: 0; right: 0; width: 44px; height: 44px; border: 0; background: none;
  color: var(--warn-ink); font-size: 22px; line-height: 1; cursor: pointer; border-radius: 22px;
}
.notice-restore {
  display: block; min-height: 44px; margin: 4px auto 0; padding: 0 12px; border: 0; background: none;
  color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer;
}
.warn-ico { flex: none; width: 32px; height: 32px; border-radius: 10px; background: var(--warn-icon-bg); color: var(--warn-icon); display: grid; place-items: center; }
.warn-t { font-weight: 600; color: var(--warn-ink); }
.warn-b { margin-top: 2px; font-size: 14px; color: var(--warn-ink); opacity: .9; }
.warn-b b { font-weight: 600; }
.warn-btn { margin-top: 8px; background: none; border: 0; padding: 0; color: var(--warn-ink); font-weight: 600; font-size: 13px; text-decoration: underline; cursor: pointer; }
.warn-btn:disabled { text-decoration: none; cursor: default; }

/* tiles */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 16px; }
.tile .k { font-size: 13px; color: var(--sub); display: flex; align-items: center; gap: 6px; }
.tile .v { margin-top: 6px; font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.tile .v small { font-size: 16px; color: var(--sub); }
.tile.tap { cursor: pointer; }

/* charts & breakdown */
.split { display: flex; flex-direction: column; gap: 10px; }
.chart-card, .where-card { padding: 18px 16px 14px; border-radius: var(--radius-card); }
.card-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card-h h2 { font-size: 15px; font-weight: 600; }
.card-h .sm { font-size: 12px; color: var(--sub); }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; margin: 8px 0 6px; font-size: 12px; color: var(--sub); }
.chart-legend span { display: flex; align-items: center; gap: 6px; }
.lg-line { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-note { margin-top: 4px; font-size: 12px; color: var(--muted); }
.hint {
  display: block; width: 100%; margin: 8px 0 0; padding: 9px 12px; border-radius: 12px;
  background: var(--warn-bg); color: var(--ink); border: 0; font-size: 13px; text-align: left; cursor: pointer;
}
.where-amt { font-family: var(--serif); font-size: 15px; font-weight: 500; }
.stack { display: flex; gap: 3px; height: 14px; margin-top: 14px; }
.stack > div { height: 100%; }
.legend2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; margin-top: 14px; font-size: 13px; }
.legend2 > div { display: flex; justify-content: space-between; gap: 8px; }
.legend2 .l { display: flex; align-items: center; gap: 8px; color: var(--sub); }
.legend2 .eur { display: none; }
.where-big { display: none; }
.where-list { display: none; }

/* payslip lists */
.slips { padding: 8px 16px; border-radius: var(--radius-card); }
.slips h2 { font-size: 15px; font-weight: 600; margin: 10px 0 4px; }
.row {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%;
  min-height: 52px; padding: 8px 0; background: none; border: 0; border-bottom: 1px solid var(--row);
  color: var(--ink); text-align: left;
}
.row:last-child { border-bottom: 0; }
.row .n { font-weight: 500; }
.row .s { font-size: 12px; color: var(--muted); }
.row .pay-amt { font-weight: 500; }
button.row { cursor: pointer; }
.row.on .n { color: var(--blue); }
.row.sub .n { color: var(--sub); font-weight: 400; }
.row.sub .s { font-size: 13px; color: var(--muted); }
.row.todo .n { font-weight: 600; }
.row.todo .s { color: var(--amber); font-weight: 600; font-size: 13px; }
.detail { border-top: 1px solid var(--row); margin: 4px 0 8px; padding-top: 8px; }
.detail .line { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; padding: 3px 0; }
.del {
  width: 100%; margin-top: 10px; height: 40px; border-radius: 20px; background: none;
  border: 1px solid var(--red); color: var(--red); font-size: 14px; cursor: pointer;
}
.empty { text-align: center; color: var(--sub); padding: 32px 14px; }

/* add buttons */
.add {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px;
  border: 0; border-radius: 28px; background: var(--pill-bg); color: var(--pill-ink); font-weight: 600; font-size: 16px; cursor: pointer;
}
.add svg { width: 20px; height: 20px; }
.add-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; padding: 24px 16px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, transparent, var(--bg) 40%);
}
.add-side { display: none; }

/* toast */
.toast {
  position: fixed; left: 16px; right: 16px; top: calc(12px + env(safe-area-inset-top, 0px)); max-width: 480px; margin: 0 auto; z-index: 10;
  background: var(--pill-bg); color: var(--pill-ink); border-radius: 12px; padding: 10px 14px; font-size: 14px;
  opacity: 0; transform: translateY(-12px);
}

/* confirm / prompt sheet */
dialog.sheet {
  border: 0; padding: 0; margin: auto auto 0; width: 100%; max-width: 100%; background: transparent; color: var(--ink);
  font: inherit; font-variant-numeric: tabular-nums;
}
dialog.sheet::backdrop { background: var(--scrim); }
dialog.sheet form {
  background: var(--sheet); border-top: 1px solid var(--line); border-radius: 32px 32px 0 0;
  padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px;
}
.grab { flex: none; position: relative; width: 40px; height: 5px; border-radius: 3px; background: var(--grey); opacity: .5; align-self: center; }
.grab::after { content: ""; position: absolute; inset: -16px -60px; } /* bigger grab area */
.sh-head { display: flex; gap: 12px; align-items: center; }
.sh-ico { flex: none; width: 44px; height: 44px; border-radius: 14px; background: var(--tile); color: var(--blue); display: grid; place-items: center; }
.sh-head h2 { font-family: var(--serif); font-size: 22px; font-weight: 600; letter-spacing: -.01em; }
.sh-head p { font-size: 13px; color: var(--sub); }
.status { display: flex; gap: 10px; align-items: center; font-size: 13px; border-radius: 16px; padding: 10px 14px; border: 1px solid transparent; }
.status.ok { background: var(--ok-bg); border-color: var(--ok-line); color: var(--ok-ink); }
.status.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn-ink); }
.status.ok svg { color: var(--ok-icon); }
.status.warn svg { color: var(--amber); }
.status[hidden] { display: none; }
.grp { background: var(--tile); border-radius: 20px; padding: 4px 16px; }
.row-f { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 52px; border-bottom: 1px solid var(--row); }
.row-f:last-child { border-bottom: 0; }
.row-f label { color: var(--sub); display: flex; align-items: center; gap: 8px; }
.row-f input {
  width: 140px; text-align: right; background: transparent; border: 0; padding: 0; color: var(--ink);
  font-family: var(--serif); font-size: 17px; font-weight: 500; outline: none;
}
.row-f.net { min-height: 60px; }
.row-f.net label { color: var(--ink); font-weight: 600; }
.row-f.net input { width: 150px; font-size: 22px; font-weight: 600; color: var(--green); }
.row-f input[readonly] { color: var(--sub); }
.tgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tf { background: var(--tile); border-radius: 16px; padding: 10px 14px; }
.tf label { display: block; font-size: 12px; color: var(--sub); }
.tf input {
  width: 100%; background: transparent; border: 0; padding: 0; color: var(--ink); outline: none;
  font-family: var(--serif); font-size: 17px; font-weight: 500;
}
.need { color: var(--warn-ink); font-size: 13px; min-height: 0; }
.need:empty { display: none; }
.acts { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.ghost { height: 48px; border: 0; border-radius: 24px; background: transparent; color: var(--sub); font-weight: 500; font-size: 15px; cursor: pointer; }
.add:disabled { opacity: .4; }

/* ---------- wide: sidebar + grid (>= 900px) ---------- */
@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); }
  .side {
    display: flex; flex-direction: column; gap: 28px; padding: 28px 20px; background: var(--side);
    border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; overflow-y: auto;
  }
  .add-side { display: flex; height: 44px; font-size: 15px; border-radius: 22px; }
  .add-bar { display: none; }
  .add-phone { display: none; }

  .main { padding: 36px clamp(20px, 4vw, 56px) 48px; }
  .main-inner { max-width: 1080px; margin: 0 auto; gap: 20px; }
  .top { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; padding: 0; }
  .top > div:nth-child(2) { text-align: left; }
  .top-r { grid-column: auto; margin-top: 0; }
  .count { font-size: 14px; color: var(--muted); }
  .h1 { font-size: 40px; }
  .yarrows { display: none; }
  .pill-head {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
    background: var(--red-bg); color: var(--red-ink); font-size: 13px; font-weight: 600;
  }

  .hero { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 28px 40px; padding: 28px; border-radius: 24px; }
  .gauge { display: none; }
  .hero > .rates { display: none; }
  .heroL .rates { display: grid; margin-top: 18px; max-width: 460px; }
  .heroL { display: block; flex: 1 1 260px; }
  .heroL .lbl { font-size: 14px; }
  .heroL .big { margin-top: 4px; font-size: 72px; font-weight: 500; letter-spacing: -.04em; line-height: 1; }
  .heroL .rate-line { margin-top: 12px; font-size: 14px; color: var(--sub); }
  .heroL .rate-line b { color: var(--ink); font-weight: 600; }
  .heroL .rate-line .r { color: var(--red); font-weight: 600; }
  .barWrap { flex: 2 1 420px; min-width: 0; }
  .bar-track { height: 28px; }
  .bar-limit { top: -10px; height: 48px; }
  .warn { margin-top: 18px; }
  .warn-b { font-size: 14px; }

  .tiles { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
  .tile .v { font-size: 32px; }
  .split { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: stretch; }
  .chart-card, .where-card { padding: 24px; border-radius: 24px; }
  .card-h h2 { font-size: 16px; }
  .where-card { display: flex; flex-direction: column; }
  .where-big { display: block; margin-top: 6px; font: 500 36px/1.1 var(--serif); letter-spacing: -.02em; }
  .where-card .stack { height: 16px; margin-top: 20px; }
  .where-card .legend2 { display: none; }
  .where-list { display: flex; flex-direction: column; margin-top: 16px; font-size: 14px; }
  .where-list > div { display: flex; justify-content: space-between; align-items: center; min-height: 40px; border-bottom: 1px solid var(--row); }
  .where-list > div:last-child { border-bottom: 0; }
  .where-list .l { display: flex; align-items: center; gap: 8px; color: var(--sub); }
  .where-list b { font-weight: 600; }
  .where-list .p { color: var(--muted); margin-left: 6px; }
  .slips-main { display: none; }
  .slips-side { display: block; padding: 0; background: none; border: 0; }
  .slips-side .card-h { margin-bottom: 6px; }
  .toast { left: auto; right: 24px; top: 24px; margin: 0; }
}

.wide-only { display: none; }
.top-r { display: flex; align-items: center; gap: 8px; }
.bar-block { display: none; }
.where-amt { font-family: var(--serif); }
@media (min-width: 900px) {
  .wide-only { display: inline; }
  .bar-block { display: block; }
  .where-amt { display: none; }
}

/* ---------- delta chips, compare detail ---------- */
.row-r { display: flex; align-items: center; gap: 8px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; font-variant-numeric: tabular-nums; }
.chip.up { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.chip.down { color: var(--red); background: color-mix(in srgb, var(--red) 14%, transparent); }
.line.strong { font-weight: 600; }
.up { color: var(--green); }
.down { color: var(--red); }
.detail .lbl { margin: 6px 0 4px; }
.detail-h { margin-top: 12px !important; }

/* ---------- header pill ---------- */
.pill-head { border: 0; cursor: pointer; font: inherit; transition: opacity 240ms ease-out, visibility 0s; }
.pill-head.is-off { opacity: 0; visibility: hidden; transition: opacity 240ms ease-in, visibility 0s linear 240ms; pointer-events: none; }

/* ---------- tax card fixer ---------- */
.fixer { gap: 14px !important; }
.fx { background: var(--tile); border-radius: 18px; padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; }
.fx .lbl { margin-bottom: 2px; }
.fx-big { font-family: var(--serif); font-size: 20px; font-weight: 500; letter-spacing: -.01em; }
.fx-sub { font-size: 13px; color: var(--sub); }
.copy {
  align-self: flex-start; margin-top: 6px; height: 34px; padding: 0 14px; border-radius: 17px;
  border: 1px solid var(--ghost-line); background: var(--card); color: var(--ink); font-size: 13px; cursor: pointer;
}
.fx-note {
  border: 0; text-align: left; cursor: pointer; padding: 10px 12px; border-radius: 12px;
  background: var(--warn-bg); color: var(--ink); font-size: 13px;
}
.fx-est { font-size: 12px; color: var(--muted); }

/* ---------- year totals card (on the dashboard) ---------- */
.linkish { background: none; border: 0; padding: 0; color: var(--blue); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.btn-print {
  height: 40px; padding: 0 18px; border-radius: 20px; border: 1px solid var(--ghost-line); background: var(--card);
  color: var(--ink); font: inherit; font-size: 14px; cursor: pointer;
}
.ytotals { display: flex; flex-direction: column; }
.yt-row { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-top: 1px solid var(--row); font-size: 14px; font-variant-numeric: tabular-nums; }
.yt-row small { font-size: 12px; color: var(--muted); margin-left: 4px; }
.yt-note { font-size: 13px; color: var(--sub); margin-top: 8px; }
.ytotals .btn-print { margin-top: 12px; align-self: flex-start; }
.yt-print-head { display: none; }

/* Print: only the Year totals card, on one clean sheet (everything else is hidden, not just the controls). */
@media print {
  @page { margin: 14mm; }
  html, body { background: #fff !important; }
  body * { visibility: hidden !important; }
  .ytotals, .ytotals * { visibility: visible !important; }
  .ytotals {
    position: absolute; left: 0; top: 0; width: 100%; margin: 0 !important; padding: 0 !important;
    background: #fff !important; border: 0 !important; box-shadow: none !important; color: #000 !important;
  }
  .ytotals .no-print, .ytotals .linkish, .ytotals .yt-note { display: none !important; }
  .ytotals .yt-row { color: #000 !important; border-top-color: #ccc !important; }
  .ytotals .card-h .sm { color: #444 !important; }
  .yt-print-head { display: block !important; font: 600 18px var(--serif); margin: 0 0 10px; color: #000 !important; }
}

/* ---------- confirm sheet on wide: centred dialog ---------- */
@media (min-width: 900px) {
  dialog.sheet { margin: auto; max-width: 480px; }
  dialog.sheet form { border-radius: 28px; border: 1px solid var(--line); padding: 20px 24px 24px; max-height: calc(100vh - 48px); overflow-y: auto; }
  .grab { display: none; }
}

/* ================= motion ================= */
/* Entrance animations only under .enter (set by app.js on load and on year changes). `backwards` fill keeps
   the final state natural, so :active scale and later renders are not affected. */
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } }
@keyframes row-in { from { opacity: 0; transform: translateX(-8px); } }
@keyframes fill-arc { from { stroke-dasharray: 0 691.15; } }
@keyframes grow-w { from { width: 0; } }
@keyframes grow-x { from { transform: scaleX(0); } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.15); } 100% { transform: scale(1); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes bd-in { from { opacity: 0; } }
@keyframes bd-out { to { opacity: 0; } }
@keyframes sheet-pop { from { opacity: 0; transform: scale(.96); } }
@keyframes sheet-pop-out { to { opacity: 0; transform: scale(.96); } }

.enter .main-inner { animation: fade-in 260ms ease-out backwards; }
.enter .stagger { animation: fade-up 260ms cubic-bezier(.2, .7, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 40ms); }
.enter .arc { animation: fill-arc 900ms cubic-bezier(.2, .7, .2, 1) backwards; }
.enter .bar-used, .enter .bar-fore { animation: grow-w 900ms cubic-bezier(.2, .7, .2, 1) backwards; }
.enter .bar-limit { animation: fade-in 400ms ease-out 900ms backwards; }
.enter .draw { stroke-dasharray: 1; animation: draw 800ms ease-out 150ms backwards; }
.enter .fade { animation: fade-in 500ms ease-out 500ms backwards; }
.enter line.fade { animation-delay: 0ms; }
.enter .area { animation: fade-in 500ms ease-out 700ms backwards; }
.enter .pop { transform-box: fill-box; transform-origin: center; animation: pop 360ms cubic-bezier(.3, 1.4, .6, 1) 900ms backwards; }
.enter .pop.late { animation-delay: 1100ms; }
.enter .stack > div { transform-origin: left center; animation: grow-x 600ms cubic-bezier(.2, .8, .2, 1) backwards; }
.enter .stack > div:nth-child(1) { animation-delay: 200ms; }
.enter .stack > div:nth-child(2) { animation-delay: 260ms; }
.enter .stack > div:nth-child(3) { animation-delay: 320ms; }
.enter .stack > div:nth-child(4) { animation-delay: 380ms; }
.enter .slips .row { animation: row-in 260ms ease-out backwards; animation-delay: calc(var(--i, 0) * 30ms + 120ms); }
.enter .slips .chip { display: inline-block; animation: pop 320ms cubic-bezier(.3, 1.4, .6, 1) backwards; animation-delay: calc(var(--i, 0) * 30ms + 250ms); }

/* Press feedback */
button, .row, .tile.tap { transition: transform 120ms ease-out; }
button:not(.warn-x):active, .row:active, .tile.tap:active { transform: scale(.97); }

/* Toast: slides in from the top, out again */
/* Toast: transform and opacity only. Enter 260 ms ease-out, leave 200 ms ease-in (see notify in app.js). */
.toast.show { opacity: 1; transform: none; transition: transform 260ms cubic-bezier(.2, .8, .2, 1), opacity 260ms ease-out; }
.toast.leave { opacity: 0; transform: translateY(-12px); transition: transform 200ms ease-in, opacity 200ms ease-in; }
.toast.anim { will-change: transform, opacity; }

/* Tax card notice: the card collapses in place (grid rows 1fr to 0fr), fading and sliding up. Restore reverses it. */
.notice-slot { display: grid; grid-template-rows: 1fr; transition: grid-template-rows 320ms ease-in-out; }
.notice-slot.collapsed { grid-template-rows: 0fr; }
.notice-inner { min-height: 0; overflow: hidden; }
.notice-slot .warn { transition: opacity 320ms ease-in-out, transform 320ms ease-in-out; }
.notice-slot.collapsed .warn { opacity: 0; transform: translateY(-6px); }
.notice-slot.collapsed .notice-inner { visibility: hidden; transition: visibility 0s linear 320ms; }
.restore-slot { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 320ms ease-in-out; }
.restore-slot.open { grid-template-rows: 1fr; }
.restore-inner { min-height: 0; overflow: hidden; }
.restore-inner .notice-restore { opacity: 0; visibility: hidden; transition: opacity 200ms ease-out, visibility 0s linear 200ms; }
.restore-slot.open .restore-inner .notice-restore { opacity: 1; visibility: visible; transition: opacity 260ms ease-out 320ms, visibility 0s; }

/* Sheets: slide up with a decelerating curve, backdrop fades; closing slides down (see closeSheet in motion.js) */
dialog.sheet::backdrop { opacity: var(--bd, 1); transition: opacity 120ms linear; }
dialog.sheet[open]::backdrop { animation: bd-in 300ms ease-out backwards; }
dialog.sheet.closing::backdrop { animation: bd-out 260ms ease-in forwards; }
dialog.sheet[open] form { animation: sheet-in 380ms cubic-bezier(.16, 1, .3, 1) backwards; }
dialog.sheet.closing form { animation: sheet-out 260ms cubic-bezier(.4, 0, 1, 1) forwards; }
dialog.sheet form { overscroll-behavior: contain; max-height: 90vh; overflow-y: auto; touch-action: pan-y; }
.grab, .sh-head { touch-action: none; }
@media (min-width: 900px) {
  dialog.sheet form { max-height: calc(100vh - 48px); }
  dialog.sheet[open] form { animation: sheet-pop 260ms ease-out backwards; }
  dialog.sheet.closing form { animation: sheet-pop-out 200ms ease-in forwards; }
}

/* Reduced motion: every animation and transition is off, the final state shows at once */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
.sh-head h2:focus { outline: none; } /* the title takes focus when a sheet opens, see openSheet */

/* Navigation markup shared by the Mac sidebar and the phone drawer (rules are scoped to .side or .nav) */
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand .mark { width: 32px; height: 32px; border-radius: 10px; background: var(--pill-bg); color: var(--pill-ink); display: grid; place-items: center; font: 600 16px var(--serif); }
.brand span { font: 600 18px var(--serif); letter-spacing: -.01em; }
.side-sec { display: flex; flex-direction: column; gap: 2px; }
.side-sec > p { margin: 0 8px 6px; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .06em; text-transform: uppercase; }
.side .yr, .nav .yr {
  display: flex; justify-content: space-between; align-items: center; min-height: 44px; padding: 0 12px;
  border-radius: 10px; background: none; border: 0; color: var(--sub); cursor: pointer; text-align: left; font: inherit;
}
.side .yr.on, .nav .yr.on { background: var(--card); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(14, 17, 22, .06); }
.side .yr .c, .nav .yr .c { font: 500 12px var(--sans); color: var(--muted); }
.side .row, .nav .row { min-height: 44px; padding: 0 12px; border-bottom: 0; border-radius: 10px; }
.side .row:hover, .nav .row:hover { background: var(--card); }
.side .row .pay-amt, .nav .row .pay-amt { font-family: var(--serif); font-size: 14px; color: var(--sub); }
.side-foot { margin-top: auto; }
.add-side svg, .add-drawer svg { width: 18px; height: 18px; }
.side .slips-side h2 { display: none; }
.side .detail, .nav .detail { margin: 6px 0 0; }
.side .detail .line, .nav .detail .line { font-size: 12px; }

/* Phone: hamburger and drawer */
.menu-btn {
  flex: none; width: 44px; height: 44px; border: 1px solid var(--ghost-line); background: var(--card); color: var(--ink);
  border-radius: 22px; display: grid; place-items: center; cursor: pointer; align-self: center;
}
.add-drawer { display: flex; height: 48px; font-size: 15px; border-radius: 24px; }
dialog.drawer {
  position: fixed; inset: 0 auto 0 0; margin: 0; height: 100%; max-height: 100%; width: min(84vw, 320px); max-width: none;
  border: 0; padding: 0; background: transparent; color: var(--ink); font: inherit;
}
dialog.drawer::backdrop { background: var(--scrim); opacity: var(--bd, 1); transition: opacity 260ms ease-in; }
dialog.drawer[open]::backdrop { animation: bd-in 300ms ease-out backwards; }
dialog.drawer.closing::backdrop { animation: bd-out 260ms ease-in forwards; }
.drawer-panel {
  height: 100%; display: flex; flex-direction: column; gap: 20px; padding: calc(env(safe-area-inset-top, 0px) + 16px) 16px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--side); border-radius: 0 24px 24px 0; border-right: 1px solid var(--line);
  overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
}
dialog.drawer[open] .drawer-panel { animation: drawer-in 380ms cubic-bezier(.16, 1, .3, 1) backwards; }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; touch-action: none; }
.drawer-title { font-family: var(--serif); font-size: 20px; font-weight: 600; outline: none; }
.drawer-close {
  width: 44px; height: 44px; border: 0; border-radius: 22px; background: none; color: var(--ink); font-size: 24px; cursor: pointer;
}
.drawer-body { display: flex; flex-direction: column; gap: 24px; flex: 1; }
@keyframes drawer-in { from { transform: translateX(-100%); } }
@keyframes drawer-out { to { transform: translateX(-100%); } }
@media (min-width: 900px) {
  .menu-btn, dialog.drawer { display: none !important; }
}

/* Muted one-line tip under the add button */
.tip { margin: 8px 4px 0; font-size: 12px; line-height: 1.4; color: var(--muted); text-align: center; }

/* The payslip detail, in the main view */
.slip-detail .card-h { margin-bottom: 4px; }
.slip-detail .line { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.slip-detail .line.strong { font-weight: 600; border-bottom: 1px solid var(--row); padding-bottom: 8px; margin-bottom: 4px; }
.slip-detail .detail-h { margin: 12px 0 4px; }
.slip-detail .del { margin-top: 14px; }

/* Payslip detail: the wrapper animates its height (grid rows 0fr to 1fr), the content fades with it */
.detail-wrap { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 260ms ease-in; }
.detail-wrap.open { grid-template-rows: 1fr; transition-timing-function: ease-out; }
.detail-inner { min-height: 0; overflow: hidden; opacity: 0; transition: opacity 200ms ease-in; }
.detail-wrap.open .detail-inner { opacity: 1; transition-timing-function: ease-out; }
.detail-inner .slip-detail { margin-top: 10px; }

/* Ring: earned this year in the centre; the tax card left sits under the ring */
.gauge-c .g-num { font-size: 38px; white-space: nowrap; }
.gauge-c .g-sub { max-width: 170px; text-align: center; line-height: 1.35; }
.ring-left { margin-top: 2px; font-size: 15px; color: var(--ink); text-align: center; }
.ring-left b { font-family: var(--serif); font-weight: 500; font-size: 17px; }
@media (min-width: 900px) { .ring-left { display: none; } }


/* Fixer: the Vero link is a full-width primary button */
.fx-link { flex: none; height: 52px; text-decoration: none; font-size: 16px; }
/* the sheet form scrolls when tall: its children keep their natural height (buttons must not squash) */
dialog.sheet form > * { flex-shrink: 0; }

/* The status bar area: a solid strip, so scrolled content never shows through it */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; z-index: 20; pointer-events: none;
  height: env(safe-area-inset-top, 0px); background: var(--bg);
}
@media print { body::before { display: none; } }

/* Calm prompt card: the months before the first payslip (after-tax totals need their tax and net) */
.prompt-card { display: flex; align-items: center; gap: 12px; margin-top: 12px; padding: 14px 16px; border-radius: 18px; background: var(--tile); border: 1px solid var(--line); }
.prompt-card.pc-compact { margin-top: 10px; }
.pc-text { flex: 1; min-width: 0; }
.pc-t { font-size: 14px; font-weight: 600; }
.pc-b { margin-top: 2px; font-size: 13px; color: var(--sub); }
.pc-btn { flex: none; height: 40px; padding: 0 14px; border: 0; border-radius: 20px; background: var(--pill-bg); color: var(--pill-ink); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; }

/* Year totals: what the added payslips add up to */
.yt-scope { margin: -4px 0 6px; font-size: 12px; color: var(--muted); }

/* The breakdown: the file it was read from and the pay date, one line */
.src { margin: 2px 0 10px; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.src span { color: var(--sub); }

/* Months with no payslip: neutral. A hollow circle marks it; the whole row adds that month. */
.row.missing { width: 100%; }
.row.missing .rlead { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row.missing .mk { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--muted); }
.row.missing .s { color: var(--muted); font-size: 12px; }
.row.missing:hover, .row.missing:focus-visible { background: var(--row); outline: none; }

/* Review sheet: several new payslips */
.review .rv-list { display: flex; flex-direction: column; gap: 8px; }
.rv-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 16px; background: var(--tile); border: 1px solid var(--line); }
.rv-row.check { background: var(--warn-bg); border-color: var(--warn-line); }
.rv-main { flex: 1; min-width: 0; }
.rv-m { font-size: 14px; font-weight: 600; }
.rv-f { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rv-end { flex: none; text-align: right; }
.rv-n { font-family: var(--serif); font-size: 16px; font-variant-numeric: tabular-nums; }
.rv-s { font-size: 12px; color: var(--muted); }
.rv-row.check .rv-s { color: var(--warn-ink); }
.rv-edit { flex: none; height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--ghost-line); background: var(--card); color: var(--ink); font: inherit; font-size: 14px; cursor: pointer; }
.review .add:disabled { opacity: .4; }
