:root {
  /* ricagroup.se's palette. Their tokens are authored in OKLCH on hue 75;
     these are the same colours converted to hex, plus two derived steps
     (--line-strong, --grid) stepped in that same hue family. */
  --bg: #F3EDE6;            /* primary-beige — the page plane */
  --surface: #FEFBF8;       /* white — cards */
  --surface-2: #F7F5F1;     /* off-white — inputs and insets */
  --ink: #0D0B08;           /* black */
  --ink-muted: #3E3A35;     /* gray */
  --ink-faint: #75716B;     /* light-gray */
  --accent: #0D0B08;        /* Rica leads with the warm black, not a colour */
  --accent-strong: #24211C; /* hover-black */
  --accent-soft: #E9E4DD;   /* secondary-beige */
  --on-accent: #FEFBF8;
  --topbar-bg: #0D0B08;
  --topbar-fg: #FEFBF8;
  --line: #DBD7D2;          /* border */
  --line-strong: #C7C3BE;
  --positive: #2F7A52;
  --positive-soft: #E1F0E7;
  --warning: #8A5A0F;
  --warning-soft: #F3E4C8;
  --danger: #A93A3A;
  --danger-soft: #F5E1E1;
  --shadow: 0 1px 2px rgba(13, 11, 8, 0.05), 0 8px 24px rgba(13, 11, 8, 0.06);
  --radius: 8px;
  --radius-sm: 5px;
  /* Matches ricagroup.se: one family for headings and body alike. */
  --font-display: 'Poppins', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  --font-body: 'Poppins', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;

  /* Chart series. Fixed slot order is the colourblind-safety mechanism, not
     decoration: reordering or generating a 9th hue breaks the separation checks. */
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --series-other: #75716B;
  --grid: #E4E1DC;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100E;            /* the plane the black bar sits on */
    --surface: #1D1A17;       /* cards */
    --surface-2: #262420;     /* inputs and insets */
    --ink: #F1EEEA; --ink-muted: #AEAAA5; --ink-faint: #847F7A;
    /* Light mode leads with a black button; dark mode inverts that rather than
       introducing a colour the light theme never uses. */
    --accent: #F1EEEA; --accent-strong: #DBD7D2; --accent-soft: #312D28;
    --on-accent: #0D0B08;
    --line: #33302C; --line-strong: #4B4742;
    --topbar-bg: #0D0B08; --topbar-fg: #FEFBF8;
    --positive: #5FBB8B; --positive-soft: #1C3327;
    --warning: #E0B25C; --warning-soft: #3A2E15;
    --danger: #E68686; --danger-soft: #3A2222;
    --shadow: 0 1px 2px rgba(0,0,0,0.34), 0 8px 24px rgba(0,0,0,0.40);
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --series-other: #847F7A;
    --grid: #2B2825;
  }
}
:root[data-theme="dark"] {
  --bg: #12100E;            /* the plane the black bar sits on */
  --surface: #1D1A17;       /* cards */
  --surface-2: #262420;     /* inputs and insets */
  --ink: #F1EEEA; --ink-muted: #AEAAA5; --ink-faint: #847F7A;
  /* Light mode leads with a black button; dark mode inverts that rather than
     introducing a colour the light theme never uses. */
  --accent: #F1EEEA; --accent-strong: #DBD7D2; --accent-soft: #312D28;
  --on-accent: #0D0B08;
  --line: #33302C; --line-strong: #4B4742;
  --topbar-bg: #0D0B08; --topbar-fg: #FEFBF8;
  --positive: #5FBB8B; --positive-soft: #1C3327;
  --warning: #E0B25C; --warning-soft: #3A2E15;
  --danger: #E68686; --danger-soft: #3A2222;
  --shadow: 0 1px 2px rgba(0,0,0,0.34), 0 8px 24px rgba(0,0,0,0.40);
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --series-other: #847F7A;
  --grid: #2B2825;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body);
  font-size: 15px; line-height: 1.6; font-weight: 400;
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
/* Rica's heading treatment: bold, tight leading, slightly negative tracking. */
h1, h2, h3 {
  font-family: var(--font-display); font-weight: 700;
  line-height: 1.15; letter-spacing: -0.02em; margin: 0;
}
table { font-variant-numeric: tabular-nums; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
.hidden { display: none !important; }

.app { max-width: 1100px; margin: 0 auto; padding: 0 20px 64px; }

/* Topbar */
.topbar {
  background: var(--topbar-bg); color: var(--topbar-fg);
  margin: 0 -20px 0; padding: 12px 20px;
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 20px; align-items: center;
}
.brand { display: flex; align-items: center; gap: 12px; justify-self: start; }
.brand-text h1 { font-size: 19px; color: var(--topbar-fg); }
.brand-text .tagline { display: none; }

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

/* Primary navigation, in the bar itself. */
.mainnav { display: flex; gap: 4px; align-items: center; justify-self: center; }
.mainnav .tab-btn {
  background: none; border: none; cursor: pointer; padding: 9px 14px; border-radius: var(--radius-sm);
  font-size: 14px; font-weight: 500; color: rgba(254,251,248,0.74); white-space: nowrap;
}
.mainnav .tab-btn:hover { color: var(--topbar-fg); background: rgba(254,251,248,0.08); }
.mainnav .tab-btn.is-active { color: var(--topbar-fg); background: rgba(254,251,248,0.16); font-weight: 600; }

/* Account menu */
.session-box { position: relative; justify-self: end; }
.avatar-btn { background: none; border: none; padding: 0; cursor: pointer; display: block; border-radius: 999px; }
.avatar {
  width: 36px; height: 36px; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; letter-spacing: 0.02em;
  border: 1px solid rgba(254,251,248,0.35);
}
.avatar-btn:hover .avatar, .avatar-btn[aria-expanded="true"] .avatar { border-color: var(--topbar-fg); }

.profile-menu {
  position: absolute; top: calc(100% + 10px); right: 0; z-index: 60;
  min-width: 220px; padding: 6px;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.profile-head { padding: 10px 12px 12px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.profile-head .who-am-i { font-size: 14px; font-weight: 700; color: var(--ink); }
.role-pill {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}
.menu-sep { height: 1px; background: var(--line); margin: 6px 0; }
.theme-block { padding: 4px 12px 8px; }
.theme-label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--ink-faint); margin-bottom: 7px;
}
.theme-switch {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 2px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px;
}
.theme-btn {
  background: none; border: none; cursor: pointer; border-radius: 4px;
  padding: 6px 4px; font-size: 12.5px; color: var(--ink-muted); white-space: nowrap;
}
.theme-btn:hover { color: var(--ink); }
.theme-btn.is-active { background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.menu-item {
  display: block; width: 100%; text-align: left;
  background: none; border: none; cursor: pointer;
  padding: 10px 12px; border-radius: var(--radius-sm);
  font-size: 14px; color: var(--ink);
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.is-active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.menu-item.is-danger { color: var(--danger); }
.menu-item.is-danger:hover { background: var(--danger-soft); }
.version-row { padding: 6px 12px 4px; display: flex; flex-direction: column; gap: 4px; }
#app-version { font-size: 11.5px; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.version-warn { font-size: 11.5px; font-weight: 600; color: var(--warning); }

/* Login screen */
.login-wrap { max-width: 380px; margin: 64px auto; }
.login-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 32px;
}
.login-card h2 { font-size: 20px; margin-bottom: 6px; }
.login-card p.hint { color: var(--ink-muted); font-size: 13px; margin: 0 0 20px; }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }

.panel { display: none; padding-top: 26px; }
.panel.is-active { display: block; }

/* Cards / forms */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card + .card { margin-top: 18px; }
.card h2 { font-size: 17px; margin-bottom: 4px; }
.card .hint { color: var(--ink-muted); font-size: 13px; margin: 4px 0 18px; }

.field-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--ink-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.field input, .field select, .field textarea {
  background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 9px 10px; color: var(--ink); width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.field textarea { resize: vertical; min-height: 42px; font-family: inherit; }
.field.wide { grid-column: 1 / -1; }
.actions-row { display: flex; align-items: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

.btn-primary {
  background: var(--accent); color: var(--on-accent); border: none;
  padding: 10px 20px; border-radius: var(--radius-sm); font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-ghost {
  background: none; border: 1px solid var(--line-strong); color: var(--ink);
  padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px; cursor: pointer;
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-small { padding: 5px 10px; font-size: 12.5px; border-radius: var(--radius-sm); cursor: pointer; border: 1px solid var(--line-strong); background: var(--surface); }
.btn-save { border-color: var(--positive); color: var(--positive); }
.btn-cancel { border-color: var(--line-strong); color: var(--ink-muted); }
.btn-delete {
  background: none; border: 1px solid var(--line-strong); color: var(--ink-faint);
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
}
.btn-delete:hover { border-color: var(--danger); color: var(--danger); }
.btn-delete.is-confirming { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); font-weight: 600; }

.toolbar { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .field { min-width: 150px; }
.summary-chip { background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 13px; color: var(--ink-muted); font-weight: 500; }
.summary-chip strong { color: var(--ink); font-weight: 700; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
thead th {
  text-align: left; font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-muted); background: var(--surface-2); padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
td.num, th.num { text-align: right; }
td.note-cell { color: var(--ink-muted); font-size: 13px; max-width: 220px; }
.empty-row td { text-align: center; color: var(--ink-faint); padding: 28px 14px; font-style: italic; }
.rate-badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  background: var(--warning-soft); color: var(--warning); padding: 2px 7px; border-radius: 999px; margin-left: 6px;
}
.rate-edit-form { display: inline-flex; gap: 6px; align-items: center; margin-left: 8px; }
.rate-edit-form input { width: 84px; padding: 5px 7px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink); }
.total-row td { font-weight: 700; background: var(--surface-2); border-top: 2px solid var(--line-strong); }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--accent-strong); color: var(--on-accent);
  padding: 12px 20px; border-radius: var(--radius-sm); box-shadow: var(--shadow);
  font-size: 13.5px; font-weight: 500; z-index: 40; max-width: 90vw;
}
.toast.is-error { background: var(--danger); }

/* ---------------------------------------------------------------------------
   Charts
   --------------------------------------------------------------------------- */
.charts { display: grid; gap: 18px; margin-bottom: 18px; }
.chart-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px; margin: 0; position: relative;
}
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 2px; }
.chart-card h3 { font-family: var(--font-display); font-size: 15px; font-weight: 600; margin: 0; }
.chart-sub { color: var(--ink-muted); font-size: 12.5px; margin: 0 0 14px; }
.chart-toggle {
  background: none; border: 1px solid var(--line-strong); color: var(--ink-muted);
  padding: 5px 10px; border-radius: var(--radius-sm); font-size: 12px; cursor: pointer; white-space: nowrap;
}
.chart-toggle:hover { border-color: var(--accent); color: var(--accent); }
.chart-plot { position: relative; }
.chart-plot svg { display: block; overflow: visible; }
.chart-empty { color: var(--ink-faint); font-style: italic; font-size: 13px; padding: 24px 0; text-align: center; }

/* Recessive chrome: solid hairlines, never dashed. */
.grid-line { stroke: var(--grid); stroke-width: 1; }
.axis-line { stroke: var(--line-strong); stroke-width: 1; }
.axis-text { fill: var(--ink-faint); font-size: 11px; font-variant-numeric: tabular-nums; }
.series-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.series-label { font-size: 11.5px; font-weight: 600; }
/* A 2px surface ring keeps overlapping marks readable without a drawn border. */
.series-dot { stroke: var(--surface); stroke-width: 2; }
.pie-slice { stroke: var(--surface); stroke-width: 2; }
.pie-slice.is-dim { opacity: 0.35; }
.crosshair { stroke: var(--line-strong); stroke-width: 1; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-muted); }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; flex: 0 0 auto; }
.legend-item strong { color: var(--ink); font-weight: 600; }

.chart-tip {
  position: absolute; pointer-events: none; z-index: 30;
  background: var(--accent-strong); color: var(--on-accent);
  border-radius: var(--radius-sm); padding: 8px 10px; font-size: 12px; line-height: 1.5;
  box-shadow: var(--shadow); white-space: nowrap; opacity: 0; transition: opacity 0.12s;
}
.chart-tip.is-visible { opacity: 1; }
.chart-tip .tip-head { font-weight: 700; margin-bottom: 4px; }
.chart-tip .tip-row { display: flex; align-items: center; gap: 7px; }
.chart-tip .tip-row .legend-swatch { width: 8px; height: 8px; }
.chart-tip .tip-val { margin-left: auto; padding-left: 12px; font-variant-numeric: tabular-nums; }

/* The table-view twin every chart carries. */
.chart-table table { min-width: 0; }
.chart-table td, .chart-table th { font-size: 12.5px; padding: 7px 10px; }

/* Users admin */
.pill-role, .pill-state {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 3px 8px; border-radius: 999px;
}
.pill-role.is-admin { background: var(--accent-soft); color: var(--accent); }
.pill-role.is-employee { background: var(--surface-2); color: var(--ink-muted); }
.pill-state.is-active { background: var(--positive-soft); color: var(--positive); }
.pill-state.is-inactive { background: var(--warning-soft); color: var(--warning); }
.user-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.perm-list { display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.perm-check { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-muted); cursor: pointer; }
.perm-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.perm-check.is-locked { cursor: default; color: var(--ink-faint); }
.perm-check.is-locked input { cursor: default; }
.perm-always { font-size: 12px; color: var(--ink-faint); font-style: italic; }

/* Which clients an employee may report on */
.scope-panel {
  margin-top: 10px; padding: 12px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: var(--surface-2);
  display: flex; flex-direction: column; gap: 10px; text-align: left; max-width: 340px;
}
.scope-modes { display: flex; flex-direction: column; gap: 6px; }
.scope-modes label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.scope-modes input { margin: 0; accent-color: var(--accent); }
.scope-filter {
  width: 100%; padding: 7px 9px; font-size: 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
}
.scope-boxes {
  max-height: 190px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); padding: 8px;
}
.scope-boxes label { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.scope-boxes input { margin: 0; accent-color: var(--accent); flex: 0 0 auto; }
.scope-count { font-size: 12px; color: var(--ink-muted); }
.scope-actions { display: flex; gap: 6px; }

.import-report {
  margin-top: 14px; padding: 12px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2);
  font-size: 13.5px; color: var(--ink-muted);
  display: flex; flex-direction: column; gap: 8px;
}
.import-report strong { color: var(--ink); }
.import-report ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.import-report .import-problem { color: var(--warning); }

/* Filter drawer toggle: only ever visible on small screens. */
.filter-toggle { display: none; }

/* ---------------------------------------------------------------------------
   Mobile. Below 760px the data tables stop being tables and become stacked
   cards, so nothing depends on horizontal scrolling to be readable.
   --------------------------------------------------------------------------- */
@media (max-width: 760px) {
  body { font-size: 16px; }

  .app {
    padding: 0 14px calc(48px + env(safe-area-inset-bottom));
  }

  /* Brand and account share the top row; the nav wraps to its own line below. */
  .topbar {
    margin: 0 -14px;
    padding: 10px 14px;
    padding-top: calc(10px + env(safe-area-inset-top));
    gap: 10px;
    grid-template-columns: 1fr auto;
  }
  .brand { gap: 10px; }
  .brand-text h1 { font-size: 17px; }
  .mainnav {
    grid-column: 1 / -1; justify-self: stretch; justify-content: flex-start;
    margin: 0 -14px; padding: 2px 14px 0;
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none; -ms-overflow-style: none; -webkit-overflow-scrolling: touch;
  }
  .mainnav::-webkit-scrollbar { display: none; }
  .mainnav .tab-btn { padding: 10px 12px; }
  /* Anchored to the screen edge so it never runs off on a narrow phone. */
  .profile-menu { right: -4px; min-width: 240px; }
  .menu-item { padding: 13px 12px; }

  .panel { padding-top: 18px; }
  .card { padding: 16px; border-radius: var(--radius); }

  /* One field per row, and 16px inputs so iOS does not zoom on focus. */
  .field-grid { grid-template-columns: 1fr; gap: 12px; }
  .field input, .field select, .field textarea { font-size: 16px; padding: 12px 12px; }
  .field textarea { min-height: 72px; }

  /* Full-width primary actions are far easier to hit with a thumb. */
  .actions-row { gap: 10px; }
  .btn-primary { width: 100%; padding: 14px 20px; font-size: 15px; }
  .actions-row .hint { width: 100%; margin: 0; }

  /* Filters collapse behind a toggle instead of filling the screen. */
  .filter-toggle {
    display: block; width: 100%; text-align: left;
    background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink);
    padding: 12px 14px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
    cursor: pointer; margin-bottom: 12px;
  }
  .filter-toggle::after { content: " ▾"; color: var(--ink-muted); }
  .filter-toggle[aria-expanded="true"]::after { content: " ▴"; }
  /* The toolbar itself stays put; only the filter fields collapse, so the
     row/hour total above the table never disappears with them. */
  .toolbar { display: flex; flex-direction: column; align-items: stretch; gap: 12px; }
  .toolbar .field { display: none; min-width: 0; width: 100%; }
  .toolbar.is-open .field { display: flex; }
  /* Invoicing has no toggle button, so its fields are always shown. */
  #panel-fakturering .toolbar .field { display: flex; }
  .toolbar .summary-chip { order: -1; }
  .toolbar .btn-ghost { width: 100%; padding: 12px; font-size: 14px; }
  .summary-chip { align-self: flex-start; }

  /* The report summary should stay visible even with filters collapsed. */
  #rapporter-summary { display: block; width: 100%; text-align: center; margin-bottom: 12px; }

  /* Tables become cards. */
  .table-wrap { overflow-x: visible; border: none; background: none; border-radius: 0; }
  table { min-width: 0; display: block; }
  thead { display: none; }
  tbody, tbody tr, tbody td { display: block; }
  tbody tr {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 4px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  }
  tbody tr:hover { background: var(--surface); }
  tbody td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 15px; text-align: right;
  }
  tbody tr td:last-child { border-bottom: none; }
  tbody td::before {
    content: attr(data-label);
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em;
    color: var(--ink-muted); text-align: left; flex: 0 0 auto;
  }
  tbody td:not([data-label]) { justify-content: flex-end; }
  tbody td:not([data-label])::before { content: none; }
  td.num { text-align: right; }
  td.note-cell { max-width: none; }
  /* An empty note adds nothing on a small screen. */
  tbody td.note-cell:empty { display: none; }
  .empty-row td { display: block; text-align: center; }
  .empty-row td::before { content: none; }

  .btn-delete { padding: 9px 14px; font-size: 13px; }
  .rate-edit-form { display: flex; flex-wrap: wrap; margin-left: 0; width: 100%; justify-content: flex-end; }
  .rate-edit-form input { width: 100px; padding: 9px; font-size: 16px; }
  .btn-small { padding: 9px 12px; font-size: 13px; }
  .btn-ghost.btn-edit-rate { padding: 8px 12px; }

  .hide-mobile { display: none; }
  .chart-card { padding: 14px; }
  .chart-head { flex-wrap: wrap; }
  .chart-legend { gap: 6px 12px; }
  .user-actions { justify-content: flex-end; }
  .user-actions .btn-small { padding: 9px 12px; }
  .total-row td { background: var(--surface-2); }
  tbody tr.total-row { border-color: var(--line-strong); border-width: 2px; }

  .login-wrap { margin: 32px auto; padding: 0 14px; }
  .login-card { padding: 24px 20px; }

  .toast {
    left: 14px; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom));
    transform: none; max-width: none; text-align: center;
  }
}
