/* Inter, served from this folder (SIL Open Font License, see fonts/Inter-LICENSE.txt). No CDN. */
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/css/fonts/inter-latin-ext-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}
@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/css/fonts/inter-latin-wght-normal.woff2') format('woff2-variations');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

/* Design tokens: the shared "Clean SaaS" set (same names and values as time-report and the codly.se admin),
   then codly's old names as aliases, then codly's own tokens. Light only (UX-SPEC). A page CSS never writes
   a colour literal: a new colour is a named token here. */
:root {
  color-scheme: light;

  /* Accent */
  --primary-color: #067a5b;
  --primary-hover: #056249;

  /* Surfaces */
  --bg-canvas: #f6f8fa;
  --bg-primary: #ffffff;
  --bg-secondary: #fcfcfd;
  --bg-tertiary: #f2f4f7;
  --bg-hover: #f2f4f7;
  /* "This is the current page" in the nav. Paired with --primary-color text. */
  --bg-active: rgba(6, 122, 91, 0.08);

  /* Text. On a tinted fill (--bg-tertiary, --accent-bg) use --text-secondary: --text-muted is under 4.5:1 there. */
  --text-primary: #101828;
  --text-secondary: #475467;
  --text-muted: #667085;
  /* Text on a coloured surface (primary button, toast). */
  --text-inverse: #ffffff;
  --text-error: #d92d20;        /* error text on white (4.8:1) */
  /* Error text on --bg-error: --text-error is 4.4:1 there, this is 6.5:1. */
  --text-error-strong: #b42318;
  --bg-error: #fef3f2;          /* the fill of an error strip */
  --border-error: #f2b8b3;      /* the border of an error strip, the danger button */
  --text-success: #067a5b;      /* success text */

  /* Borders. --border-control is 3.26:1 against white (WCAG 1.4.11 asks 3:1). */
  --border-primary: #e4e7ec;
  --border-secondary: #d0d5dd;
  --border-control: #858fa1;

  /* Focus: a solid colour, 5.4:1 against white. */
  --focus-ring: #067a5b;

  /* Shadows */
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-float: 0 8px 24px rgba(16, 24, 40, 0.18);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 999px;

  /* Font */
  --font-sans: 'Inter Variable', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;

  /* One height for buttons, inputs and selects. 38 px: codly is desktop first with dense grids. */
  --control-height: 38px;

  /* Spacing scale (8 px base) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 40px;
  --space-8: 48px;

  /* Type scale (dense desktop app) */
  --text-h1: 1.5rem;
  --text-h2: 1.125rem;
  --text-h3: 1rem;
  --text-body: 0.875rem;
  --text-small: 0.8125rem;
  --text-label: 0.75rem;

  /* Z-index scale (the values the app had before) */
  --z-sticky: 20;
  --z-overlay: 30;
  --z-floating: 50;
  --z-toast: 60;
  --z-modal: 100;

  /* Shell geometry: the height of the sticky top bar (the Löner header sticks under it) */
  --topbar-h: 56px;

  /* codly's old names: aliases of the shared ones, so the page CSS keeps working */
  --bg: var(--bg-canvas);
  --panel: var(--bg-primary);
  --ink: var(--text-primary);
  --muted: var(--text-muted);
  --line: var(--border-primary);
  --line-strong: var(--border-secondary);
  --head: var(--bg-tertiary);
  --accent: var(--primary-color);
  --accent-dark: var(--primary-hover);
  --danger: var(--text-error);
  --danger-bg: var(--bg-error);
  --focus: var(--focus-ring);
  --shadow: var(--shadow-card);

  /* codly's own tokens */
  --accent-bg: #eaf3ee;
  --amber: #7a5200;
  --amber-bg: #fdf3d9;
  --amber-line: #f0d38a;
  /* Printing: black on white, whatever the screen tokens are (Att skanna, UX-SPEC §7). */
  --print-ink: #000000;
  --print-paper: #ffffff;
  /* The pale veil over a page behind a floating panel (the file viewer, the invoice mapper). */
  --scrim: rgba(255, 255, 255, 0.85);
  /* The dark veil behind a modal. */
  --overlay-bg: rgba(16, 24, 40, 0.5);

  /* Tints for the tables and the badges */
  --bg-flash: #dff3e6;          /* a row or cell that was just saved */
  --bg-accent-soft: #eef6f1;    /* an editable cell under the mouse */
  --bg-cost: #eaf2ed;           /* the cost row of Löner */
  --bg-cost-current: #dcefe3;   /* the same, in the current month */
  --hatch-a: #f0f1f3;          /* a cell that does not apply (hatched) */
  --hatch-b: #f7f8f9;          /* the second stripe of the hatch */
  --bg-success-soft: #dff3e6;   /* badge: confirmed */
  --border-success-soft: #b9e3c8; /* badge: confirmed, its border */
  --info-text: #1f4fb0;         /* badge: paying (blue, so it is neither draft nor paid) */
  --info-bg: #e8eefb;           /* badge: paying, its fill */
  --info-line: #b9cdf0;         /* badge: paying, its border */
  /* On a dark surface (the toast) */
  --on-dark-line: rgba(255, 255, 255, 0.4);
  --on-dark-hover: rgba(255, 255, 255, 0.12);
  /* Future months on paper: a solid grey fill that prints the same everywhere */
  --print-future-bg: #d9dbe0;
  --print-future-ink: #55595f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-sans);
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-size: var(--text-body);
}

button, input, select, textarea { font-family: inherit; }

header.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--topbar-h);
  padding: 0 var(--space-5);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-primary);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}
header.topbar .brand {
  font-weight: 700;
  font-size: var(--text-h3);
}
header.topbar nav { display: flex; gap: var(--space-1); flex-wrap: wrap; }
header.topbar nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-weight: 500;
}
header.topbar nav a:hover { background: var(--bg-hover); color: var(--text-primary); }
/* The open page: pale accent fill and accent text, never a dark pill. */
header.topbar nav a.active,
header.topbar nav a[aria-current="page"] {
  background: var(--bg-active);
  color: var(--primary-color);
  font-weight: 600;
}

/* The compact menu: below 1100 px the entries fold behind one "Meny" button (nav.js adds it; MomsShell.jsx
   draws the same for the moms screens). At 1024 px the 11 entries already wrapped to two rows. */
header.topbar .nav-toggle { display: none; } /* scoped: the general .btn rule comes later and would show it */
.nav-toggle-icon,
.nav-toggle-icon::before,
.nav-toggle-icon::after {
  display: block;
  width: 16px;
  height: 2px;
  background: currentColor;
  border-radius: 1px;
}
.nav-toggle-icon { position: relative; }
.nav-toggle-icon::before,
.nav-toggle-icon::after { content: ""; position: absolute; left: 0; }
.nav-toggle-icon::before { top: -5px; }
.nav-toggle-icon::after { top: 5px; }
@media screen and (max-width: 1099px) {
  header.topbar { flex-wrap: wrap; gap: var(--space-2) var(--space-3); }
  header.topbar .brand { margin-right: auto; }
  header.topbar .year-selector { margin-left: 0; }
  header.topbar .nav-toggle { display: inline-flex; gap: var(--space-2); order: 2; }
  header.topbar .year-selector,
  header.topbar .session-status { order: 1; margin-left: 0; }
  /* The open list scrolls inside itself, so a short screen (a phone held sideways) reaches the last entry
     under the sticky bar. */
  header.topbar nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; gap: 2px; padding-bottom: var(--space-2); max-height: calc(100dvh - var(--topbar-h)); overflow-y: auto; }
  /* Open while the button says so: aria-expanded is the one state, for nav.js and for MomsShell.jsx. */
  header.topbar:has(.nav-toggle[aria-expanded="true"]) nav { display: flex; }
  header.topbar nav a { display: flex; align-items: center; min-height: 44px; }
  /* "Logga ut" (shown only when the login is in use) is the last entry of the open menu, not a fourth
     thing in the one-row bar. */
  header.topbar .logout-btn { order: 4; display: none; }
  header.topbar:has(.nav-toggle[aria-expanded="true"]) .logout-btn { display: inline-flex; margin-bottom: var(--space-2); }
}

main { padding: var(--space-5); max-width: 1180px; margin: 0 auto; }

h1 { font-size: var(--text-h1); font-weight: 700; margin: 0 0 var(--space-1); }
h2 { font-size: var(--text-h2); font-weight: 600; }
.sub { color: var(--text-muted); margin: 0 0 var(--space-4); }
.sub a { color: var(--accent-dark); font-weight: 600; text-decoration: none; }
.sub a:hover { text-decoration: underline; }

.card {
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-card);
}

.placeholder {
  color: var(--muted);
  font-style: italic;
}

table {
  border-collapse: collapse;
  width: 100%;
}
/* Quiet tables: no filled header bar, hairlines between the rows, no vertical lines, no zebra. */
th, td {
  border: none;
  border-bottom: 1px solid var(--border-primary);
  padding: var(--space-2) var(--space-3);
  text-align: right;
}
th:first-child, td:first-child { text-align: left; }
thead th {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: var(--text-label);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tabular-nums,
td.num {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ── focus & baseline a11y ─────────────────────────────────────────── */
/* One rule for every link, button, input, select, textarea, summary and [tabindex]. */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}
@media (forced-colors: active) {
  :focus-visible { outline: 2px solid CanvasText; outline-offset: 2px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ── toolbar ────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  flex-wrap: wrap;
}

.toolbar-right { display: flex; align-items: center; gap: var(--space-4); }

/* ── buttons ────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font: inherit;
  font-weight: 600;
  font-size: var(--text-body);
  border-radius: var(--radius-md);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-secondary);
  background: var(--bg-primary);
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  min-height: var(--control-height);
}
.btn:hover { background: var(--bg-hover); }
.btn-primary {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: var(--text-inverse);
}
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
/* Destructive: ghost danger (white, red text, red hairline). */
.btn-danger {
  background: var(--bg-primary);
  border-color: var(--border-error);
  color: var(--text-error);
}
.btn-danger:hover { background: var(--bg-error); color: var(--text-error-strong); }
.btn-link {
  background: none;
  border: none;
  color: var(--primary-hover);
  font-weight: 600;
  cursor: pointer;
  padding: 2px var(--space-1);
  min-height: 24px;
  min-width: 24px;
}
.btn-link:hover { text-decoration: underline; }
.btn-small { padding: 0 var(--space-3); font-size: var(--text-label); min-height: 30px; }

/* ── toggle (Visa avslutade) ───────────────────────────────────────── */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-small);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle input { width: 24px; height: 24px; }

/* ── badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  font-size: var(--text-label);
  font-weight: 700;
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge-ended { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ── table row states ──────────────────────────────────────────────── */
tr.ended td { color: var(--text-muted); background: var(--bg-secondary); }
tr.flash { animation: flash-row 1.2s ease-out; }
@keyframes flash-row {
  0% { background: var(--bg-flash); }
  100% { background: transparent; }
}

/* ── empty state / skeleton ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .btn { margin-top: 12px; }

.skeleton-row td {
  padding: 10px;
}
.skeleton-bar {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 37%, var(--bg-tertiary) 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
}
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ── form panel ─────────────────────────────────────────────────────── */
.form-panel {
  margin-top: 14px;
}
.form-panel h2 {
  font-size: var(--text-h3);
  margin: 0 0 14px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
  max-width: 320px;
}
.field label {
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--muted);
}
.field input:not([type="checkbox"]):not([type="radio"]),
.field select,
.field textarea {
  font: inherit;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
}
.field textarea { padding: var(--space-2) var(--space-3); }
.field .hint { font-size: 11px; color: var(--muted); }
.field-row { display: flex; gap: 16px; flex-wrap: wrap; }

.radio-group { display: flex; gap: 16px; flex-wrap: wrap; }
/* A radio is as large as a checkbox (24 px, WCAG 2.2 target size), and both are drawn in the accent. */
.radio-group input[type="radio"] { width: 24px; height: 24px; margin: 0; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary-color); }
.radio-group label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-small);
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}

.field-error {
  color: var(--danger);
  font-size: var(--text-label);
  margin-top: -8px;
  margin-bottom: 14px;
}

/* Live parse echo (Slice 6 gate, Maja P0-1): "= X kr brutto" under Belopp
   as you type — resolves both the parse ambiguity (confirms the typed
   string was actually understood) and the netto/brutto ambiguity at once. */
.field-hint {
  color: var(--muted);
  font-size: var(--text-label);
  margin-top: -8px;
  margin-bottom: 14px;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.form-actions .spacer { flex: 1; }
.saved-ghost {
  font-size: var(--text-label);
  color: var(--accent-dark);
  font-weight: 600;
}

/* ── preview block ("Så här blir det i Löner") ─────────────────────── */
.preview {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin: 4px 0 18px;
  max-width: 460px;
}
.preview h3 {
  font-size: var(--text-label);
  margin: 0 0 8px;
  color: var(--text-secondary);
  font-weight: 700;
}
.preview-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  row-gap: 4px;
  column-gap: 12px;
  font-size: var(--text-small);
}
.preview-grid dt { color: var(--text-secondary); }
.preview-grid dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  text-align: right;
  cursor: default;
}
.preview-grid dd.emphasis { font-weight: 700; }
.preview.amber {
  background: var(--amber-bg);
  border-color: var(--amber-line);
}
.preview-note {
  font-size: var(--text-label);
  color: var(--amber);
  margin: 8px 0 0;
}

/* ── inline error strip (card-level) ──────────────────────────────── */
.alert {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-small);
  margin-bottom: var(--space-3);
}
.alert.danger {
  background: var(--bg-error);
  border: 1px solid var(--border-error);
  color: var(--text-error-strong);
}
.alert.amber {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  color: var(--amber);
}
.alert .btn { margin-left: 10px; }

.confirm-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-label);
  color: var(--danger);
}

[hidden] { display: none !important; }

.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;
}

/* ── year selector (topbar, right-aligned) ─────────────────────────── */
.year-selector {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}
.year-selector select {
  font: inherit;
  font-weight: 600;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* ── Löner: person cards + year grid ───────────────────────────────── */
.person-card, .summary-card { padding-left: 8px; padding-right: 8px; }
.person-card { margin-bottom: 18px; }
.person-card-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.person-card-head h2 { font-size: var(--text-h3); margin: 0; }
.person-card-head .meta { color: var(--muted); font-size: var(--text-label); }

/* No overflow-x:auto here by default: any non-visible overflow on this
   wrapper would make IT (not the viewport) the containing block for the
   sticky thead below, pinning the header partway down the table instead of
   under the topbar. table.loner-grid is sized to fit ≥1024px without
   horizontal scroll (this app's supported range); the narrow-viewport
   fallback below trades sticky-header for horizontal scroll instead. */
.table-scroll { overflow-x: visible; }

table.loner-grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  table-layout: fixed;
  font-size: 11.5px;
}
table.loner-grid th,
table.loner-grid td {
  border: 1px solid var(--line);
  padding: 5px 2px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* The header is not a filled bar. The month names stay in normal case (jan, feb ...): upper case over
   a 12-column grid at this width reads worse than it looks. */
table.loner-grid thead th {
  background: var(--bg-primary);
  color: var(--text-muted);
  font-size: 11px;
  text-transform: none;
  letter-spacing: 0;
  position: sticky;
  top: var(--topbar-h);
  z-index: 4;
  border-bottom: 1px solid var(--border-secondary);
}
table.loner-grid tbody th {
  text-align: left;
  background: var(--head);
  font-weight: 600;
  white-space: normal;
  overflow-wrap: break-word;
  line-height: 1.2;
}
table.loner-grid th:first-child,
table.loner-grid td:first-child {
  position: sticky;
  left: 0;
  z-index: 3;
  background: var(--bg-tertiary);
  text-align: left;
  width: 150px;
}
table.loner-grid thead th:first-child { z-index: 6; background: var(--bg-primary); }
table.loner-grid td.col-ytd,
table.loner-grid th.col-ytd {
  border-left: 1px dashed var(--border-secondary);
  background: var(--bg-secondary);
  width: 64px;
  font-size: 10.5px;
}
/* The "I år" column (a secondary forecast figure): 64 px holds a 7-digit sum on one line at 10.5 px. */
table.loner-grid td.col-ytd {
  /* 64 px holds a 7-digit sum on one line ("1 257 015"); a number broken over two lines was hard to read
     (Maja, routines walk 2026-11-22). Under 900 px the grid scrolls inside its card anyway. */
  white-space: nowrap;
  line-height: 1.15;
}
table.loner-grid td.col-total,
table.loner-grid th.col-total {
  border-left: 2px solid var(--line-strong);
  font-weight: 700;
  width: 88px;
  font-size: 11px;
}
table.loner-grid td.month-current,
table.loner-grid th.month-current {
  background: var(--accent-bg);
}
/* Muted text is under 4.5:1 on the tint. */
table.loner-grid th.month-current { color: var(--text-secondary); }
/* P2-10: months after "today" (current real year/month only) read as
   forecast, not actual — dimmed rather than a full legend entry, since it
   applies to every future column uniformly. */
table.loner-grid td.month-future,
table.loner-grid th.month-future,
table.loner-grid td.month-future * {
  /* Muted text, not opacity: half opacity fell to 2.3:1 (WCAG AA asks 4.5:1). */
  color: var(--text-muted);
}
table.loner-grid tr.row-cost td {
  background: var(--bg-cost);
  font-weight: 700;
  color: var(--ink); /* P3: full-ink, not the muted computed-cell default */
}
table.loner-grid tr.row-cost td.month-current { background: var(--bg-cost-current); }
/* Slice 7 gate (Maja B3): the "Ej beräknad skatt" row on the Årsrapport's
   company table — amber, matching .excluded-footnote's colour, so the row
   visually flags itself as the caveat it is rather than reading as just
   another totals line. */
table.loner-grid tr.row-excluded-tax th,
table.loner-grid tr.row-excluded-tax td {
  color: var(--amber);
  font-style: italic;
}

td.cell-computed {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  cursor: default;
}
td.cell-editable {
  cursor: pointer;
  position: relative;
}
td.cell-editable:hover { background: var(--bg-accent-soft); }
td.cell-inactive {
  cursor: default;
  color: var(--text-secondary);
  background: repeating-linear-gradient(
    135deg, var(--hatch-a), var(--hatch-a) 6px, var(--hatch-b) 6px, var(--hatch-b) 12px
  );
}
td.cell-readonly-hourly {
  cursor: default;
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  line-height: 1.25;
}
.hourly-hours-sublabel {
  font-size: 10px;
  color: var(--text-secondary);
}

/* P2-8: an amber left border + bold value, not a 6px dot — a dot read as
   "saved" (too close to the Sparat ghost) and green was already spoken for
   by the current-month tint. Border survives print (only background colors
   need "print backgrounds" enabled; borders always print). */
/* `table.loner-grid td` (the base cell-border rule) is (0,0,1,2) — more
   specific than a bare `td.cell-overridden` (0,0,1,1) would be, so the
   selector needs the `table.loner-grid` ancestor class repeated here to
   actually win the border-left override. */
table.loner-grid td.cell-overridden {
  border-left: 3px solid var(--amber);
  font-weight: 700;
}

/* P3: cells that were just saved/reset flash briefly, alongside the
   "Sparat" ghost. */
td.cell-flash { animation: flash-row 1.2s ease-out; }

.loner-legend {
  display: flex;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  font-size: var(--text-label);
  color: var(--muted);
  margin-top: 10px;
}
.legend-item { display: inline-flex; align-items: center; gap: 8px; }
.swatch-overridden {
  display: inline-block;
  width: 16px;
  height: 12px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--amber);
  background: var(--panel);
}
.loner-legend .hatch-sample {
  display: inline-block;
  width: 16px;
  height: 12px;
  border: 1px solid var(--line);
  background: repeating-linear-gradient(
    135deg, var(--hatch-a), var(--hatch-a) 4px, var(--hatch-b) 4px, var(--hatch-b) 8px
  );
}

/* ── cell popover editor ─────────────────────────────────────────── */
.cell-popover {
  position: fixed;
  z-index: var(--z-floating);
  background: var(--bg-primary);
  border: 1px solid var(--border-secondary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  padding: var(--space-3);
  width: 220px;
  font-size: var(--text-small);
}
.cell-popover label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 4px;
}
.cell-popover input[type="number"] {
  width: 100%;
  font: inherit;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  margin-bottom: var(--space-2);
}
.cell-popover .popover-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cell-popover .popover-error {
  color: var(--danger);
  font-size: 11px;
  margin: 6px 0 0;
}
.cell-popover .popover-info {
  color: var(--muted);
  font-size: 11px;
  margin: 6px 0 0;
}
.cell-popover .popover-saved {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 600;
  margin-left: 4px;
}

/* Below the supported desktop-first range: trade the sticky thead for
   horizontal scroll so nothing clips (the two are mutually exclusive per
   the CSS containing-block rule noted above `.table-scroll`). Scoped to
   `screen` only — printing at a fixed @page size (see below) must never
   fall into this fallback and lose the fixed column widths the print
   layout is sized around. */
@media screen and (max-width: 899px) {
  .table-scroll { overflow-x: auto; }
  table.loner-grid { table-layout: auto; min-width: 900px; }
  table.loner-grid thead th { position: static; }
  table.loner-grid th:first-child,
  table.loner-grid td:first-child { position: static; }
}

/* ── skeleton grid (real shape) ──────────────────────────────────── */
.skeleton-card .skeleton-bar { height: 12px; margin: 3px 0; }

/* ── summary card ───────────────────────────────────────────────── */
.summary-card h2 { font-size: var(--text-h3); margin: 0 0 10px; }
.summary-footnote {
  font-size: 11.5px;
  color: var(--muted);
  margin: 10px 0 0;
}
.excluded-footnote {
  color: var(--amber);
  font-weight: 600;
}

/* ── hourly Brutto: one link in the card header, not one per cell ─── */
.hourly-source-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--accent-dark);
  text-decoration: none;
}
.hourly-source-link:hover { text-decoration: underline; }

/* ── print-only chrome (hidden on screen, shown under @media print) ─ */
.print-header, .print-footnote {
  display: none;
  font-size: 11px;
  color: var(--muted);
  margin: 0 0 8px;
}
/* Screen vs. print label swap for the Totalt/"Prognos helår" header cell
   (see js/loner.js buildTotalHeader) — both spans always exist, CSS alone
   decides which renders, so nothing has to change at the moment of
   printing. */
.label-print { display: none; }

/* ── Timmar: add bar ────────────────────────────────────────────── */
.add-bar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.add-bar .field { margin-bottom: 0; max-width: none; }
/* 140px, not 110px (Slice 6 gate, Maja P2): 110px clipped its own rendered
   value in a date input ("2026-08-2…"). */
.add-bar .field-narrow { width: 140px; }
.add-bar .field-grow { flex: 1; min-width: 160px; }
/* Notering doesn't need to eat every remaining pixel (Slice 6 gate, Maja
   P2: "oversized, rebalance") — capped so it stays proportionate next to
   Datum/Belopp/Kanal instead of stretching the whole bar. */
.add-bar .field-note { max-width: 280px; }
.add-bar .field-submit { flex: 0 0 auto; }
.add-bar input[type="text"],
.add-bar input[type="date"],
.add-bar input[type="number"],
.add-bar select {
  font: inherit;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
  width: 100%;
}
.add-bar[hidden] { display: none; }

/* ── Timmar: grouped table ──────────────────────────────────────── */
table.timmar-table { width: 100%; border-collapse: collapse; }
table.timmar-table th,
table.timmar-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
table.timmar-table thead th { text-align: right; }
table.timmar-table thead th:first-child { text-align: left; }
table.timmar-table tr.month-group-row th {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  text-transform: none;
  letter-spacing: 0;
  text-align: left;
  font-weight: 700;
  font-size: var(--text-small);
  padding-top: 12px;
}
table.timmar-table tr.month-subtotal-row td {
  background: var(--bg-secondary);
  font-weight: 700;
  border-top: 1px solid var(--border-secondary);
}
table.timmar-table td.col-delete { text-align: right; width: 70px; white-space: nowrap; }
table.timmar-table td.num,
table.timmar-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* P2: "Ta bort" is a destructive action — .btn-link's default green
   (var(--accent-dark), shared with genuinely positive links like "Brutto
   kommer från Timmar →") reads as an endorsement of clicking it. Muted at
   rest, danger-red only on hover/focus (not a permanent red — this isn't a
   warning state, it's an ordinary available action). Declared after
   .btn-link so it wins the color override at equal specificity. */
.btn-delete {
  color: var(--muted);
  white-space: nowrap;
}
.btn-delete:hover,
.btn-delete:focus-visible {
  color: var(--danger);
  text-decoration: underline;
}

.badge-window-warning {
  background: var(--amber-bg);
  color: var(--amber);
  border: 1px solid var(--amber-line);
}

/* Add-bar's field-error (Timmar validation) sits in a flex-column .field,
   not the Personer form's block layout the base .field-error rule was
   written for — its negative top-margin trick doesn't apply here. */
.add-bar .field-error,
.add-bar .field-hint {
  margin: 4px 0 0;
}

.year-total-footer {
  font-weight: 600;
  font-size: var(--text-small);
  margin: 14px 0 0;
}
.year-total-footer a { color: var(--accent-dark); font-weight: 700; text-decoration: none; padding-block: 5px; /* hit area >=24px; inline, so line layout is unchanged */ }
.year-total-footer a:hover { text-decoration: underline; }

/* ── toast (undo, 8s — never a confirm()) ──────────────────────── */
#toast-region {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-toast);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-float);
  font-size: var(--text-small);
}
.toast .btn {
  background: transparent;
  border: 1px solid var(--on-dark-line);
  color: var(--text-inverse);
}
.toast .btn:hover { background: var(--on-dark-hover); }
/* An error toast (moms-scan.js adds .toast-error): the strong error red, so it does not read as a
   saved file. White on it is 6.5:1. */
.toast.toast-error { background: var(--text-error-strong); }

/* ── Granskare (Slice 5) ────────────────────────────────────────────── */

.session-status {
  margin-left: auto;
  font-size: var(--text-small);
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}
.session-status .btn-link { padding: 0; }
.session-status .dot {
  width: 8px; height: 8px; border-radius: 50%;
  display: inline-block;
}
.session-status .dot.online { background: var(--accent); }
.session-status .dot.offline { background: var(--border-secondary); }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.section-head h2 { font-size: var(--text-h3); margin: 0; }
#section-unpaid { margin-bottom: 18px; }

.rule-text {
  font-size: var(--text-small);
  color: var(--text-secondary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin: 0 0 var(--space-3);
}

/* stepper: two marks, kept apart. The page that is open (.is-page) is the bold green pill. The progress of
   the quarter is shown by the number: a done step keeps its check mark (green text and circle), the step the
   quarter has reached (.active) has a green number circle. */
.stepper {
  display: flex;
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
  flex-wrap: wrap;
}
.stepper .step {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-small);
  color: var(--text-secondary);
  padding: 6px 10px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
}
.stepper .step-num {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  color: var(--text-inverse);
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stepper .step.active { color: var(--text-primary); }
/* A step that is a link (the moms screens): the link carries the padding, so that the whole pill is the
   target (at least 24 px high). */
.stepper .step.step-link { padding: 0; }
.stepper .step > a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: var(--radius-full);
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
}
.stepper .step.step-link:hover { filter: brightness(0.96); }
.stepper .step.is-page { background: var(--accent-bg); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 2px var(--accent-dark); }
.stepper .step.active .step-num { background: var(--accent); }
.stepper .step.done { color: var(--accent-dark); }
.stepper .step.done .step-num { background: var(--accent-dark); }
.stepper .step.is-page.done { color: var(--ink); }

/* warning badges (25 000 kr/year cumulative brutto) */
.badge-warning-amber { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-line); }
.badge-warning-red { background: var(--bg-error); color: var(--text-error-strong); border: 1px solid var(--border-error); }

/* run status badges */
.badge-status-draft { background: var(--amber-bg); color: var(--amber); border: 1px solid var(--amber-line); }
.badge-status-confirmed { background: var(--bg-success-soft); color: var(--primary-hover); border: 1px solid var(--border-success-soft); }
/* 'paying' (Slice 5 gate-3): a distinct in-progress look — never amber
   (draft) or green (paid), so it can't be mistaken for either at a glance. */
.badge-status-paying { background: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-line); }

/* a badge that's also a clickable control (the overlap warning, which opens
   the sibling run) — resets the <button> chrome a .badge span never had. */
.badge-button {
  font: inherit;
  cursor: pointer;
  margin-left: 4px;
}
.badge-button:hover { filter: brightness(0.95); }

table.reviewer-table { width: 100%; border-collapse: collapse; }
table.reviewer-table th, table.reviewer-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
table.reviewer-table thead th { text-align: right; }
table.reviewer-table thead th:first-child { text-align: left; }
table.reviewer-table td.num, table.reviewer-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* The total row of any table: bold, a stronger line above, a light fill. Use tr.row-total on a new table;
   Löner (tr.row-cost) and Timmar (tr.month-subtotal-row) keep their own, which carry more meaning. */
table tr.row-total td,
table tr.row-total th { font-weight: 700; border-top: 2px solid var(--border-secondary); background: var(--bg-tertiary); }
table.reviewer-table tr.reviewer-row { cursor: pointer; }
table.reviewer-table tr.reviewer-row:hover { background: var(--bg-hover); }
table.reviewer-table tr.entries-row td { background: var(--bg-secondary); padding: 0; }
table.reviewer-table .entries-detail { padding: 8px 16px 12px; }
table.reviewer-table .entries-detail table { width: 100%; font-size: var(--text-label); }
table.reviewer-table .entries-detail th, table.reviewer-table .entries-detail td { padding: 4px 8px; border: none; }

table.runs-table { width: 100%; border-collapse: collapse; }
table.runs-table th, table.runs-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.runs-table thead th { text-align: left; }
table.runs-table td.num, table.runs-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.runs-table tr.run-row { cursor: pointer; }
table.runs-table tr.run-row:hover { background: var(--bg-hover); }

table.payout-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
table.payout-table th, table.payout-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); }
table.payout-table thead th { text-align: left; }
table.payout-table td.num, table.payout-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

.detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.detail-summary .stat { background: var(--bg-tertiary); border-radius: var(--radius-md); padding: var(--space-3); }
.detail-summary .stat dt { font-size: var(--text-label); color: var(--text-secondary); margin: 0 0 2px; }
.detail-summary .stat dd { font-size: var(--text-h3); font-weight: 700; margin: 0; font-variant-numeric: tabular-nums; }

.mark-paid-panel {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}
.mark-paid-panel .confirm-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: var(--text-small);
  margin-bottom: 10px;
}
.mark-paid-panel .confirm-checkbox input { margin-top: 3px; width: 16px; height: 16px; }

.reconciliation-panel {
  background: var(--amber-bg);
  border: 1px solid var(--amber-line);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  margin-top: var(--space-3);
  font-size: var(--text-small);
}
.reconciliation-panel h3 { font-size: var(--text-small); margin: 0 0 8px; color: var(--amber); }
.reconciliation-panel .id-list { font-family: ui-monospace, monospace; font-size: 11.5px; color: var(--muted); }
.reconciliation-panel a { color: var(--amber); font-weight: 700; }

/* ── modal (login / confirm dialogs — never a native alert/confirm) ──── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-5);
}
.modal {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-float);
  padding: var(--space-5);
  width: 100%;
  max-width: 420px;
}
.modal h2 { font-size: var(--text-h2); margin: 0 0 var(--space-1); }
.modal p.modal-sub { color: var(--muted); font-size: var(--text-small); margin: 0 0 16px; }
.modal .field { max-width: none; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal .modal-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: -8px;
  margin-bottom: 14px;
}

/* ── print: run-detail underlag only (list view / stepper / modals never
   print — they're hidden via .toolbar-print-hide and the containers
   themselves) ─────────────────────────────────────────────────────────── */
@media print {
  #list-view, #modal-region, .toolbar-print-hide, header.topbar { display: none !important; }
  #detail-view[hidden] { display: none !important; }
  #detail-view { display: block !important; }
  .stepper { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; }
  /* P2: the amber/green workflow badge (Underlag skapat / Utbetald) is a
     screen affordance — on paper it's replaced by the plain factual
     "Utbetalningsdatum: ..." line in .doc-meta, always rendered. */
  .badge-status-draft, .badge-status-confirmed, .badge-status-paying { display: none !important; }
}

/* ── row-disclosure: the interactive control lives in the first cell, not
   the whole <tr> (P2 — screen-reader table flattening) ────────────────── */
.row-disclosure {
  background: none;
  border: none;
  padding: 2px 4px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  text-align: left;
}
.row-disclosure:hover { text-decoration: underline; }
.disclosure-chevron { color: var(--muted); width: 10px; display: inline-block; }

/* ── Granskare: document metadata (org.nr / period / utbetalningsdatum /
   redovisningsperiod) — what makes the printed underlag filable ───────── */
.doc-meta {
  font-size: var(--text-small);
  color: var(--muted);
  margin: 4px 0 14px;
}
.doc-meta p { margin: 2px 0; }

/* ── Granskare: "Ackumulerat i år" column + opening-balance caveat ─────── */
.ytd-col { color: var(--muted); }
.caveat-star {
  color: var(--amber);
  font-weight: 700;
  padding: 0 2px;
  min-width: 0;
  min-height: 0;
}

/* ── Granskare: a table dimmed behind a page-level banner (P1-10: these
   hours already live in a draft underlag) — still readable, clearly
   secondary to the banner's call to action. ────────────────────────────── */
table.table-dimmed { opacity: 0.55; }

/* ── Granskare: "Nästa steg" panel (P1-15) ──────────────────────────────── */
.next-steps-panel {
  border-top: 1px solid var(--line);
  margin-top: 18px;
  padding-top: 14px;
}
.next-steps-panel h3 { font-size: var(--text-small); margin: 0 0 8px; }
.next-steps-panel ol { margin: 0; padding-left: 20px; font-size: var(--text-small); }
.next-steps-panel li { margin-bottom: 4px; }

/* ── Granskare: printable per-entry appendix table (P1-9) ──────────────── */
table.appendix-table { width: 100%; border-collapse: collapse; margin: 4px 0 14px; font-size: var(--text-label); }
table.appendix-table th, table.appendix-table td { padding: 4px 8px; border-bottom: 1px solid var(--line); }
table.appendix-table thead th { text-align: left; }
table.appendix-table td.num, table.appendix-table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── nav dot: an unpaid löneunderlag pending, mirrored on the Granskare nav
   item on every page (js/nav.js) ───────────────────────────────────────── */
header.topbar nav a { position: relative; }
.nav-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--danger);
  margin-left: 6px;
  vertical-align: middle;
}

/* ── print ──────────────────────────────────────────────────────── */
@media print {
  @page { size: A4 landscape; margin: 12mm; }

  header.topbar, .toolbar-print-hide, .sub, .year-selector {
    display: none !important;
  }
  /* Belt-and-suspenders (Slice 7 gate, Nitin): hiding the ancestor already
     keeps these off the printed page, but a computed-style check run
     directly against <nav> or #btn-print (rather than the header it lives
     in) still reads the element's OWN display/visibility, which a
     display:none ancestor does not rewrite. Hide the descendants directly
     too so such a check — and any future print engine that renders
     ancestor/descendant independently — agrees with what actually prints. */
  header.topbar nav, header.topbar nav a, .toolbar-print-hide * {
    display: none !important;
    visibility: hidden !important;
  }
  /* The override legend only earns its place on paper when the printed
     grid actually has an overridden cell to explain (P1-4); `has-overrides`
     is toggled by js/loner.js's renderLegend(). */
  .loner-legend { display: none !important; }
  .loner-legend.has-overrides { display: flex !important; }

  main { max-width: none; padding: 0; }
  .person-card { break-inside: avoid; box-shadow: none; }
  .card { box-shadow: none; }
  table.loner-grid thead th { position: static; }
  table.loner-grid th:first-child,
  table.loner-grid td:first-child { position: static; }

  .print-header, .print-footnote { display: block; }
  .label-screen { display: none; }
  .label-print { display: inline; }

  /* Future months: opacity renders inconsistently across print engines
     (some browsers print backgrounds faded, others don't unless "print
     backgrounds" is on) — a solid grey fill + darker text is legible either
     way. js/loner.js's updatePrintChrome() prints the matching legend line
     ("Grå = prognos, ej utfall.") only when there are future months to
     explain. */
  table.loner-grid td.month-future,
  table.loner-grid th.month-future {
    opacity: 1;
    background: var(--print-future-bg) !important;
    color: var(--print-future-ink);
  }

  /* A focus ring is a screen affordance ("you can interact here") that has
     no meaning on paper, and can land on whichever cell happened to be
     focused at print time. */
  *:focus { outline: none !important; }
}

/* ── Utdelning (Slice 6) ─────────────────────────────────────────────── */

.hero-card {
  margin-bottom: 14px;
}
.hero-main {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.hero-label {
  font-size: var(--text-small);
  color: var(--muted);
  font-weight: 600;
}
.hero-value {
  font-size: 34px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
/* The big hero figure is NET (what actually lands in the account); the
   brutto equivalent — the basis the plan/utrymme itself is denominated in —
   sits right beside it, smaller, so the figure's basis is never ambiguous. */
.hero-value-sub {
  font-size: var(--text-h3);
  font-weight: 600;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* Over-plan: the hero itself turns red — an unmissable state change, not
   just a badge tucked into the stats row (UX-SPEC §5). */
.hero-card.over-plan .hero-value,
.hero-card.over-plan .hero-label,
.hero-card.over-plan .hero-value-sub {
  color: var(--text-error-strong);
}
.hero-card.over-plan { border-color: var(--border-error); background: var(--bg-error); }

.hero-stats {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  margin-top: 12px;
  font-size: var(--text-small);
}
.hero-stats .stat dt {
  color: var(--muted);
  font-size: 11.5px;
  margin: 0 0 2px;
}
.hero-stats .stat dd {
  margin: 0;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-size: var(--text-h3);
}

.hero-progress { margin-top: 14px; }
.progress-track {
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--bg-tertiary);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--primary-color);
  border-radius: var(--radius-full);
  transition: width 0.2s ease, background-color 0.2s ease;
}
/* Approaching the limit (Slice 6 gate, Maja P2): green stayed green at 99%
   consumed, which reads as "plenty left" right up until it's gone. Amber
   past ~90% gives an actual heads-up before the hero itself turns red. */
.progress-fill.near-limit { background: var(--amber); }
.progress-fill.over-plan { background: var(--danger); }

.plan-card { margin-bottom: 16px; }
.plan-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.plan-label { font-size: var(--text-small); color: var(--muted); font-weight: 600; }
.plan-value {
  font-size: var(--text-h3);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.plan-edit-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.plan-edit-row .field { margin-bottom: 0; }
.field-legend {
  font-size: var(--text-label);
  font-weight: 600;
  color: var(--muted);
  display: block;
  margin-bottom: 4px;
}

/* ── segmented control (Konto/Kort) ─────────────────────────────────── */
/* The name of a segmented group, in front of it, when a toolbar has two groups that would read as one
   (Bankrader: Konto and Visa). */
.segmented-label { font-size: var(--text-small); font-weight: 600; color: var(--text-secondary); }
.segmented-field { display: inline-flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.segmented {
  display: inline-flex;
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.segmented-option {
  font: inherit;
  font-size: var(--text-small);
  font-weight: 600;
  min-height: calc(var(--control-height) - 2px);
  padding: 0 var(--space-3);
  border: none;
  background: var(--bg-primary);
  color: var(--text-secondary);
  cursor: pointer;
}
.segmented-option + .segmented-option { border-left: 1px solid var(--border-control); }
.segmented-option:hover { background: var(--bg-hover); }
.segmented-option.active {
  background: var(--primary-color);
  color: var(--text-inverse);
}

/* ── ledger table ────────────────────────────────────────────────────── */
table.ledger-table { width: 100%; border-collapse: collapse; }
table.ledger-table th, table.ledger-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line);
}
table.ledger-table thead th { text-align: right; }
table.ledger-table thead th:first-child { text-align: left; }
table.ledger-table td.num, table.ledger-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.ledger-table td.col-delete { text-align: right; width: 70px; white-space: nowrap; }
table.ledger-table tr.over-plan-row td.col-kvar { color: var(--danger); font-weight: 700; }

/* "Kvar efter uttag" mirrors the hero (Slice 6 gate, Maja P1-3): net on top
   (the same basis the hero's big number uses, so the two are self-verifying
   by eye), brutto as a small sub-line underneath — not a bare brutto figure
   any more. */
.cell-primary { font-weight: 700; }
.cell-sub { display: block; font-size: 11px; font-weight: 400; color: var(--muted); }
table.ledger-table tr.over-plan-row td.col-kvar .cell-sub { color: inherit; opacity: 0.85; }

/* Future-dated withdrawals (Slice 6 gate, Maja P1-6): still counted in
   Tagit ut (never silently excluded — a planned withdrawal is real money
   Pierre intends to take), but visually distinguished so "already taken"
   and "planned" aren't confused at a glance. */
/* Muted text, not opacity: opacity takes text under 4.5:1 contrast. The badge "Planerat" says why. */
table.ledger-table tr.planned-row td { color: var(--text-muted); }
.badge-planned {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--line);
  font-style: italic;
}

.badge-channel {
  background: var(--bg-tertiary);
  color: var(--ink);
  border: 1px solid var(--line);
}

/* ── Löner: dividend summary strip (Slice-6 hook, UX-SPEC §2) ─────────── */
.dividend-strip {
  font-size: var(--text-small);
  font-weight: 600;
  color: var(--text-primary);
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  margin: 0 0 var(--space-3);
}
.dividend-strip a { color: var(--accent-dark); font-weight: 700; text-decoration: none; margin-left: 2px; padding-block: 5px; /* hit area >=24px; inline, so line layout is unchanged */ }
.dividend-strip a:hover { text-decoration: underline; }

/* ── Översikt (Slice 7) — five single-question cards ────────────────── */
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}
.overview-card { display: flex; flex-direction: column; min-height: 150px; }
.overview-card h2 { font-size: var(--text-body); margin: 0 0 10px; color: var(--muted); }
.overview-card-body { flex: 1; }
.overview-hero-value {
  font-size: 26px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  margin: 0;
}
.overview-hero-danger { color: var(--danger); }
.overview-sub { color: var(--muted); font-size: var(--text-small); margin: 6px 0 0; }
.overview-sub-total { font-weight: 600; color: var(--ink); }
.overview-card-link {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 12px;
  color: var(--accent-dark);
  font-weight: 700;
  font-size: var(--text-small);
  text-decoration: none;
}
.overview-card-link:hover { text-decoration: underline; }

.overview-people-list { margin: 0; }
.overview-people-list dt { font-size: var(--text-small); color: var(--ink); float: left; clear: left; margin: 3px 0; }
.overview-people-list dd {
  font-size: var(--text-small);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  float: right;
  margin: 3px 0;
}
.overview-people-list::after { content: ""; display: block; clear: both; }

/* Inline bar-per-month sparkline — plain DOM divs, no chart library. */
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 40px;
  margin-top: 10px;
}
.sparkline-col { flex: 1; height: 100%; display: flex; align-items: flex-end; }
.sparkline-bar {
  width: 100%;
  background: var(--accent);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
}
.sparkline-bar-unknown {
  background: repeating-linear-gradient(45deg, var(--line), var(--line) 3px, transparent 3px, transparent 6px);
}
/* Slice 7 gate (Maja B1): a forecast month (not yet actual) reads as
   forecast in the sparkline too — same 0.5 opacity convention as Löner's
   own table.loner-grid td.month-future. */
.sparkline-bar-forecast { opacity: 0.5; }

.att-gora-list { list-style: none; margin: 0; padding: 0; }
.att-gora-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: var(--text-small);
  padding: 5px 0;
  border-bottom: 1px solid var(--line);
}
.att-gora-row:last-child { border-bottom: none; }
.att-gora-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  background: var(--muted);
}
.att-gora-row:has(.att-gora-row-link) .att-gora-dot { margin-top: 8px; } /* centre on the 24px link */
.att-gora-amber .att-gora-dot { background: var(--amber); }
.att-gora-red .att-gora-dot { background: var(--danger); }
.att-gora-amber { color: var(--amber); }
.att-gora-red { color: var(--danger); }
/* Slice 7 gate finding 1: each row's own text IS the link to the page that
   resolves it — inherit the row's amber/red colour (so it reads exactly
   like the plain text it replaces) and only signal "interactive" on
   hover/focus, via underline + the shared a:focus-visible ring. */
.att-gora-row-link { display: inline-flex; align-items: center; min-height: 24px; color: inherit; text-decoration: none; }
.att-gora-row-link:hover { text-decoration: underline; }

/* Slice 8 — the other-employer rows (Brutto/Skatt/Netto landsting, Skatt
   totalt). Recessed on purpose: they are another employer's figures, shown
   so the Codly numbers visibly add up, not Codly's own money. */
.row-landsting th,
.row-landsting td {
  color: var(--text-secondary);
  background: var(--bg-secondary);
  font-style: italic;
}

/* ── Moms: parts of the design system added for the moms screens (UX-SPEC §0) ─────────────── */

/* Drop target: the one way to give a file to the app. "Släpp filer här" + a "Välj fil" button.
   .is-over while a file is dragged above it. */
.drop-target {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  text-align: center;
  color: var(--muted);
  background: var(--panel);
  border: 2px dashed var(--border-secondary);
  border-radius: var(--radius-lg);
}
.drop-target.is-over {
  border-color: var(--accent);
  background: var(--accent-bg);
  color: var(--ink);
}

/* Period selector: year + quarter, next to the year selector pattern of the topbar. */
.period-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.period-selector label { color: var(--muted); font-weight: 600; }
.period-selector select {
  font: inherit;
  font-weight: 600;
  min-height: var(--control-height);
  padding: 0 var(--space-3);
  border: 1px solid var(--border-control);
  border-radius: var(--radius-md);
  background: var(--bg-primary);
  color: var(--text-primary);
}

/* A wider modal: a list or a document inside the dialog (the base .modal is 420 px). */
.modal.modal-wide { max-width: 720px; }

/* Mobile (375 px): a table that turns into blocks. The cell with class "what" comes first and is
   bold; every other cell shows its column name from data-label before the value. */
.table-stack td.what { font-weight: 600; }
@media screen and (max-width: 600px) {
  .table-stack,
  .table-stack tbody,
  .table-stack tr,
  .table-stack td { display: block; width: 100%; }
  .table-stack thead { display: none; }
  .table-stack tr {
    display: flex;
    flex-direction: column;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
  }
  .table-stack td {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    border: none;
    padding: 3px 0;
    text-align: left;
  }
  .table-stack td::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-weight: 600;
  }
  .table-stack td.num { text-align: right; }
  .table-stack td.what {
    order: -1;
    justify-content: flex-start;
    font-weight: 700;
    padding-bottom: 6px;
  }
  .table-stack td[data-label=""]::before,
  .table-stack td:not([data-label])::before { content: none; }
  header.topbar { padding: 0 var(--space-3); }
  /* Granskare's login line is too long for the bar's one row on a phone: it gets the row under it. */
  header.topbar .session-status { order: 4; flex-basis: 100%; padding-bottom: var(--space-2); }
  main { padding: var(--space-3); }
  .card { padding: var(--space-4); }
  .person-card, .summary-card { padding-left: 8px; padding-right: 8px; } /* the Löner grid needs the width */
}
