/* ==========================================================================
   Lommeboken designsystem v1
   Rolige, varme nøytraler · furugrønn hovedfarge · rav for poeng
   Alle farger er roller (tokens). Mørk modus er egne, valgte trinn – ikke invertering.
   ========================================================================== */

:root {
  color-scheme: light;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  /* Flater – Lommeboken 2.0: lys salviegrønn bakgrunn, vaniljehvite kort */
  --bg: #e2eee5;
  --bg-2: #d6e8dc;
  --surface: #fffcf2;
  --surface-2: #f7f2e2;
  --surface-3: #ede6d1;
  --border: #e9e1c9;
  --border-strong: #cfc6aa;

  /* Tekst */
  --text: #17261e;
  --text-2: #46554c;
  --muted: #687669;
  --on-brand: #ffffff;

  /* Økonomifarger (alltid med tekst/etikett, aldri farge alene) */
  --income: #1d7a43;
  --expense: #c23a2f;
  --left: #1f5fbf;
  --income-soft: #e2f2e7;
  --expense-soft: #fbe6e3;
  --left-soft: #e3ecfa;

  /* Merkevare: furu */
  --brand: #1c6b55;
  --brand-hover: #155845;
  --brand-soft: #e3f1ea;
  --brand-soft-2: #cfe7db;
  --brand-ink: #0f4a3a;

  /* Poeng: rav */
  --points: #9a5b00;
  --points-strong: #c98500;
  --points-soft: #fdf1d8;

  /* Status (reservert – alltid med ikon + tekst) */
  --good: #0ca30c;
  --good-text: #126b23;
  --good-soft: #e3f4e3;
  --warning: #fab219;
  --warning-text: #7a5200;
  --warning-soft: #fff4d6;
  --serious: #ec835a;
  --serious-text: #9a3b14;
  --serious-soft: #fde9e0;
  --critical: #d03b3b;
  --critical-text: #a42525;
  --critical-soft: #fbe5e5;
  --info-soft: #e7eefb;
  --info-text: #1f4f99;

  /* Diagram (validert kategorisk palett, rekkefølge fast) */
  --chart-surface: #ffffff;
  --series-1: #2a78d6; /* inntekter / hovedserie */
  --series-2: #eb6834; /* utgifter */
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #6250d6;
  --series-8: #e34948;
  --grid: #e8e9e3;
  --axis: #c3c2b7;

  /* Form */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 18px;
  --r-xl: 24px;
  --shadow-1: 0 1px 2px rgba(20, 32, 26, .06), 0 1px 1px rgba(20, 32, 26, .04);
  --shadow-2: 0 4px 16px rgba(20, 32, 26, .08), 0 1px 3px rgba(20, 32, 26, .06);
  --shadow-3: 0 18px 48px rgba(20, 32, 26, .18);
  --focus: 0 0 0 3px color-mix(in srgb, var(--brand) 35%, transparent);

  /* Avstand (4 px-skala) */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  --nav-h: 64px;
  --sidebar-w: 248px;
  --content-max: 1120px;
  --tap: 44px;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

:root[data-theme="dark"] { color-scheme: dark; }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) { color-scheme: dark; } }

/* Mørke trinn – deklarert to ganger: OS-innstilling og manuelt valg */
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    --bg: #0e1311; --surface: #161c19; --surface-2: #1c2420; --surface-3: #242d29; --border: #29332e; --border-strong: #3a4640;
    --text: #edf2ee; --text-2: #b7c3bc; --muted: #8d9993; --bg-2: #121a16; --income: #5fd08a; --expense: #f08378; --left: #84b4f7; --income-soft: #173022; --expense-soft: #3b1a1a; --left-soft: #18243a;
    --brand: #47b08f; --brand-hover: #5cc3a2; --brand-soft: #173329; --brand-soft-2: #1e4236; --brand-ink: #9fe0c8; --on-brand: #06231a;
    --points: #f0b648; --points-strong: #f0b648; --points-soft: #33280f;
    --good-text: #4cc764; --good-soft: #173022; --warning-text: #f5c451; --warning-soft: #33290f; --serious-text: #f29b78; --serious-soft: #3a2017; --critical-text: #f07f7f; --critical-soft: #3b1a1a;
    --info-soft: #18243a; --info-text: #9dbcf0;
    --chart-surface: #161c19; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --grid: #262e2a; --axis: #3a4640;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 6px 20px rgba(0,0,0,.35); --shadow-3: 0 18px 48px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1311; --surface: #161c19; --surface-2: #1c2420; --surface-3: #242d29; --border: #29332e; --border-strong: #3a4640;
  --text: #edf2ee; --text-2: #b7c3bc; --muted: #8d9993; --bg-2: #121a16; --income: #5fd08a; --expense: #f08378; --left: #84b4f7; --income-soft: #173022; --expense-soft: #3b1a1a; --left-soft: #18243a;
  --brand: #47b08f; --brand-hover: #5cc3a2; --brand-soft: #173329; --brand-soft-2: #1e4236; --brand-ink: #9fe0c8; --on-brand: #06231a;
  --points: #f0b648; --points-strong: #f0b648; --points-soft: #33280f;
  --good-text: #4cc764; --good-soft: #173022; --warning-text: #f5c451; --warning-soft: #33290f; --serious-text: #f29b78; --serious-soft: #3a2017; --critical-text: #f07f7f; --critical-soft: #3b1a1a;
  --info-soft: #18243a; --info-text: #9dbcf0;
  --chart-surface: #161c19; --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500; --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --grid: #262e2a; --axis: #3a4640;
  --shadow-1: 0 1px 2px rgba(0,0,0,.4); --shadow-2: 0 6px 20px rgba(0,0,0,.35); --shadow-3: 0 18px 48px rgba(0,0,0,.6);
}

/* ===== Grunnlag ===== */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text); background: var(--bg); background-image: linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%); background-attachment: fixed; min-height: 100vh;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 26px; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
p { margin: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: none; box-shadow: var(--focus); }
.sr-only { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.text-2 { color: var(--text-2); }
.small { font-size: 13px; }
.xs { font-size: 12px; }
.strong { font-weight: 650; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.pos { color: var(--good-text); }
.neg { color: var(--text); }
.points-text { color: var(--points); font-weight: 650; }
svg.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
svg.icon.sm { width: 16px; height: 16px; }
svg.icon.lg { width: 24px; height: 24px; }

/* ===== Oppstart ===== */
.boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 12px; color: var(--muted); }
.boot-mark { width: 44px; height: 44px; border-radius: 14px; background: var(--brand); animation: pulse 1.2s var(--ease) infinite alternate; }
@keyframes pulse { from { opacity: .5; transform: scale(.94); } to { opacity: 1; transform: scale(1); } }

/* ===== Skall og navigasjon ===== */
.shell { min-height: 100vh; }
.main { padding: calc(env(safe-area-inset-top) + 8px) var(--s4) calc(var(--nav-h) + env(safe-area-inset-bottom) + 88px); max-width: var(--content-max); margin: 0 auto; }
.topbar { display: flex; align-items: center; gap: var(--s3); min-height: 56px; margin-bottom: var(--s2); }
.topbar .title { flex: 1; min-width: 0; }
.topbar h1 { font-size: 24px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .subtitle { color: var(--muted); font-size: 13px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--text-2); font-size: 14px; margin-bottom: 2px; }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -0.01em; color: var(--text); }
.brand-mark { width: 32px; height: 32px; border-radius: 10px; background: var(--brand); display: grid; place-items: center; color: var(--on-brand); flex: none; }
.brand-mark svg { width: 20px; height: 20px; }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(5, 1fr);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
.bottom-nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11.5px; font-weight: 550; text-decoration: none; min-height: var(--tap); }
.bottom-nav a[aria-current="page"] { color: var(--brand); }
.bottom-nav a[aria-current="page"] .nav-ico { background: var(--brand-soft); }
.nav-ico { display: grid; place-items: center; width: 52px; height: 28px; border-radius: 14px; transition: background .2s; }

.fab {
  position: fixed; right: var(--s4); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); z-index: 31;
  height: 56px; padding: 0 20px 0 16px; border-radius: 18px; border: 0; background: var(--brand); color: var(--on-brand);
  display: inline-flex; align-items: center; gap: 8px; font-weight: 650; box-shadow: var(--shadow-2); cursor: pointer;
}
.fab:hover { background: var(--brand-hover); }
.fab svg { width: 22px; height: 22px; stroke-width: 2.2; }

.sidebar { display: none; }

@media (min-width: 960px) {
  .bottom-nav, .fab, .mobile-only { display: none !important; }
  .shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; }
  .sidebar {
    display: flex; flex-direction: column; gap: var(--s1); position: sticky; top: 0; height: 100vh; overflow-y: auto;
    padding: var(--s5) var(--s3); border-right: 1px solid var(--border); background: var(--surface);
  }
  .sidebar .brand { padding: 4px 10px 16px; }
  .sidebar .new-btn { margin: 0 4px 12px; }
  .side-group { margin-top: var(--s3); }
  .side-label { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 6px 12px; }
  .side-link { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 550; text-decoration: none; }
  .side-link:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
  .side-link[aria-current="page"] { background: var(--brand-soft); color: var(--brand-ink); }
  .side-link .badge { margin-left: auto; }
  .side-foot { margin-top: auto; padding-top: var(--s4); border-top: 1px solid var(--border); }
  .main { padding: var(--s6) var(--s8) var(--s12); }
  .desktop-hide { display: none !important; }
}
@media (max-width: 959px) { .desktop-only { display: none !important; } }

/* ===== Layout-hjelpere ===== */
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.stack-lg { display: flex; flex-direction: column; gap: var(--s6); }
.row { display: flex; align-items: center; gap: var(--s3); }
.row-sm { display: flex; align-items: center; gap: var(--s2); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.grid { display: grid; gap: var(--s4); }
.grid-2 { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
.grid-stats { display: grid; gap: var(--s3); grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 720px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 1100px) { .dash-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: var(--s5); align-items: start; } }
.span-2 { grid-column: 1 / -1; }

/* ===== Kort ===== */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: var(--s5); box-shadow: var(--shadow-1); min-width: 0; }
.card.flat { box-shadow: none; }
.card.tight { padding: var(--s4); }
.card.pad-0 { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); }
.card-head h2 { font-size: 16px; }
.card-head .link { font-size: 14px; font-weight: 550; display: inline-flex; align-items: center; gap: 2px; }
.card.brand { background: linear-gradient(155deg, var(--brand) 0%, color-mix(in srgb, var(--brand) 70%, #0b3328) 100%); color: var(--on-brand); border: 0; }
.card.brand .muted, .card.brand .label { color: color-mix(in srgb, var(--on-brand) 78%, transparent); }
.card.points-card { background: var(--points-soft); border-color: color-mix(in srgb, var(--points-strong) 30%, var(--border)); }
.section-title { font-size: 13px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin: var(--s2) 0 calc(var(--s2) * -1); }

/* ===== Nøkkeltall ===== */
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 550; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat .hint { font-size: 12.5px; color: var(--muted); }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: var(--s4); }
.hero-value { font-size: 36px; font-weight: 750; letter-spacing: -0.03em; line-height: 1.1; }
@media (min-width: 720px) { .hero-value { font-size: 42px; } }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; font-weight: 600; }
.delta.up { color: var(--good-text); }
.delta.down { color: var(--critical-text); }

/* ===== Knapper ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: var(--tap); padding: 0 18px;
  border-radius: 12px; border: 1px solid transparent; font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none !important;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover:not([disabled]) { background: var(--brand-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover:not([disabled]) { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover:not([disabled]) { background: var(--surface-2); color: var(--text); }
.btn-soft { background: var(--brand-soft); color: var(--brand-ink); }
.btn-soft:hover:not([disabled]) { background: var(--brand-soft-2); }
.btn-danger { background: var(--critical); color: #fff; }
.btn-danger:hover:not([disabled]) { background: #b52f2f; }
.btn-danger-ghost { background: transparent; color: var(--critical-text); }
.btn-danger-ghost:hover { background: var(--critical-soft); }
.btn-points { background: var(--points-strong); color: #1b1200; }
.btn-points:hover:not([disabled]) { filter: brightness(1.05); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: var(--tap); height: var(--tap); border-radius: 12px; border: 0; background: transparent; color: var(--text-2); cursor: pointer; flex: none; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.sm { width: 36px; height: 36px; }
.btn-row { display: flex; gap: var(--s2); flex-wrap: wrap; }
.btn-row.end { justify-content: flex-end; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Skjema ===== */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field .label { font-size: 14px; font-weight: 600; color: var(--text); }
.field .help { font-size: 13px; color: var(--muted); }
.field .error { font-size: 13px; color: var(--critical-text); font-weight: 550; display: flex; gap: 4px; align-items: center; }
.input, .select, .textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 11px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-size: 16px; transition: border-color .15s, box-shadow .15s;
}
.input::placeholder, .textarea::placeholder { color: color-mix(in srgb, var(--muted) 80%, transparent); }
.input:hover, .select:hover { border-color: color-mix(in srgb, var(--brand) 40%, var(--border-strong)); }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand); box-shadow: var(--focus); outline: none; }
.input[aria-invalid="true"] { border-color: var(--critical); }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236d7a73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.textarea { min-height: 88px; resize: vertical; }
.input-money { position: relative; }
.input-money .input { padding-right: 42px; font-variant-numeric: tabular-nums; }
.input-money .unit { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 15px; pointer-events: none; }
.input-xl { font-size: 32px !important; font-weight: 700; min-height: 64px; letter-spacing: -0.02em; text-align: center; border-radius: 16px; }
.input-money.xl .unit { font-size: 20px; right: 18px; }
.form-grid { display: grid; gap: var(--s4); grid-template-columns: 1fr; }
@media (min-width: 600px) { .form-grid.two { grid-template-columns: 1fr 1fr; } }
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; min-height: var(--tap); padding: 8px 0; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.search { position: relative; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search .input { padding-left: 40px; }

/* Bryter */
.switch { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: 12px 0; cursor: pointer; min-height: var(--tap); }
.switch + .switch { border-top: 1px solid var(--border); }
.switch input { appearance: none; width: 46px; height: 28px; border-radius: 14px; background: var(--border-strong); position: relative; flex: none; cursor: pointer; transition: background .2s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(18px); }
.switch input:focus-visible { box-shadow: var(--focus); }

/* Segmentert kontroll */
.segmented { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; max-width: 100%; overflow-x: auto; }
.segmented button { border: 0; background: transparent; padding: 0 14px; min-height: 36px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--text-2); cursor: pointer; white-space: nowrap; }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.segmented.block { display: flex; width: 100%; }
.segmented.block button { flex: 1; }

/* Chips/filtre */
.chips { display: flex; gap: var(--s2); overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text-2); font-weight: 550; font-size: 14px; cursor: pointer; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--text); border-color: var(--text); color: var(--bg); }

/* ===== Lister ===== */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: var(--s3); padding: 12px 0; min-height: 56px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none !important; }
.list-item:last-child { border-bottom: 0; }
button.list-item, a.list-item { background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; text-align: left; cursor: pointer; font: inherit; }
button.list-item:hover, a.list-item:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.card.pad-0 .list-item { padding-left: var(--s4); padding-right: var(--s4); }
.list-item .main-text { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .sub-text { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .amount { font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.avatar-ico { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.avatar-ico.brand { background: var(--brand-soft); color: var(--brand-ink); }
.avatar-ico.points { background: var(--points-soft); color: var(--points); }
.avatar-ico.income { background: color-mix(in srgb, var(--series-1) 14%, var(--surface)); color: var(--series-1); }
.avatar-ico.expense { background: color-mix(in srgb, var(--series-2) 14%, var(--surface)); color: var(--series-2); }
.avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--brand-soft); color: var(--brand-ink); flex: none; }
.day-head { font-size: 13px; font-weight: 650; color: var(--muted); padding: 14px 0 4px; display: flex; justify-content: space-between; }
.card.pad-0 .day-head { padding-left: var(--s4); padding-right: var(--s4); background: var(--surface-2); padding-top: 8px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== Merkelapper ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 650; background: var(--surface-2); color: var(--text-2); white-space: nowrap; line-height: 1.6; }
.badge.brand { background: var(--brand-soft); color: var(--brand-ink); }
.badge.good { background: var(--good-soft); color: var(--good-text); }
.badge.warning { background: var(--warning-soft); color: var(--warning-text); }
.badge.serious { background: var(--serious-soft); color: var(--serious-text); }
.badge.critical { background: var(--critical-soft); color: var(--critical-text); }
.badge.points { background: var(--points-soft); color: var(--points); }
.badge.info { background: var(--info-soft); color: var(--info-text); }
.badge.demo { background: repeating-linear-gradient(135deg, var(--warning-soft) 0 6px, color-mix(in srgb, var(--warning-soft) 60%, var(--surface)) 6px 12px); color: var(--warning-text); border: 1px dashed color-mix(in srgb, var(--warning) 70%, transparent); }
.points-chip { display: inline-flex; align-items: center; gap: 6px; padding: 0 12px; min-height: 36px; border-radius: 18px; background: var(--points-soft); color: var(--points); font-weight: 700; text-decoration: none !important; font-variant-numeric: tabular-nums; }
.coin { width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ffe08a, var(--points-strong) 60%, #9a5b00); display: inline-grid; place-items: center; flex: none; box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.35); }
.coin::after { content: ""; width: 7px; height: 7px; border-radius: 2px; transform: rotate(45deg); background: rgba(255,255,255,.55); }
.coin.lg { width: 28px; height: 28px; }
.coin.lg::after { width: 10px; height: 10px; }

/* ===== Fremdrift ===== */
.progress { height: 10px; border-radius: 6px; background: var(--surface-3); overflow: hidden; position: relative; }
.progress.sm { height: 6px; }
.progress.lg { height: 14px; border-radius: 8px; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .6s var(--ease); max-width: 100%; }
.progress.warning > span { background: var(--warning); }
.progress.over > span { background: var(--critical); }
.progress.points > span { background: var(--points-strong); }
.progress .marker { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text-2); opacity: .5; }
.budget-line { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.budget-line:last-child { border-bottom: 0; }
.budget-line .top { display: flex; justify-content: space-between; gap: var(--s3); align-items: baseline; }
.budget-line .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.budget-line .meta { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: var(--s2); }
.ring { position: relative; display: grid; place-items: center; flex: none; }
.ring svg { transform: rotate(-90deg); }
.ring .ring-label { position: absolute; font-weight: 700; font-size: 15px; }

/* ===== Varsler / meldinger ===== */
.alert { display: flex; gap: var(--s3); align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--surface-2); border: 1px solid var(--border); }
.alert .alert-ico { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: none; background: var(--surface); }
.alert.info { background: var(--info-soft); border-color: transparent; }
.alert.info .alert-ico { color: var(--info-text); }
.alert.warning { background: var(--warning-soft); border-color: transparent; }
.alert.warning .alert-ico { color: var(--warning-text); }
.alert.serious { background: var(--serious-soft); border-color: transparent; }
.alert.serious .alert-ico { color: var(--serious-text); }
.alert.critical { background: var(--critical-soft); border-color: transparent; }
.alert.critical .alert-ico { color: var(--critical-text); }
.alert.good { background: var(--good-soft); border-color: transparent; }
.alert.good .alert-ico { color: var(--good-text); }
.alert .alert-title { font-weight: 650; font-size: 14.5px; }
.alert .alert-text { font-size: 13.5px; color: var(--text-2); }
.notice-demo { display: flex; gap: 10px; align-items: center; padding: 10px 14px; border-radius: var(--r); border: 1px dashed color-mix(in srgb, var(--warning) 70%, transparent); background: var(--warning-soft); color: var(--warning-text); font-size: 13.5px; font-weight: 550; }

/* ===== Tom tilstand ===== */
.empty { text-align: center; padding: var(--s8) var(--s4); display: flex; flex-direction: column; align-items: center; gap: var(--s3); }
.empty .empty-ico { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); }
.empty .empty-ico svg { width: 28px; height: 28px; }
.empty h3 { font-size: 17px; }
.empty p { color: var(--muted); max-width: 380px; }

/* ===== Skjelett ===== */
.skeleton { background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 8px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ===== Dialog / ark ===== */
dialog.modal { border: 0; padding: 0; background: transparent; max-width: none; max-height: none; width: 100%; height: 100%; margin: 0; color: var(--text); }
dialog.modal::backdrop { background: rgba(8, 14, 11, .48); backdrop-filter: blur(2px); }
.modal-wrap { min-height: 100%; display: flex; align-items: flex-end; justify-content: center; }
.modal-panel {
  width: 100%; max-height: 92vh; overflow-y: auto; background: var(--surface); border-radius: 22px 22px 0 0; box-shadow: var(--shadow-3);
  padding: var(--s2) var(--s5) calc(var(--s5) + env(safe-area-inset-bottom)); animation: sheet-in .25s var(--ease);
}
.modal-grip { width: 40px; height: 5px; border-radius: 3px; background: var(--border-strong); margin: 4px auto 10px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s4); position: sticky; top: calc(var(--s2) * -1); background: var(--surface); padding-top: 4px; z-index: 1; }
.modal-head h2 { font-size: 19px; }
.modal-foot { display: flex; gap: var(--s2); justify-content: flex-end; margin-top: var(--s5); flex-wrap: wrap; }
.modal-foot .btn { flex: 1 1 auto; }
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (min-width: 720px) {
  .modal-wrap { align-items: center; padding: var(--s6); }
  .modal-panel { max-width: 560px; border-radius: 22px; padding: var(--s6); animation-name: modal-in; }
  .modal-panel.wide { max-width: 760px; }
  .modal-grip { display: none; }
  .modal-foot .btn { flex: 0 0 auto; }
}
@keyframes modal-in { from { transform: scale(.97); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Toast ===== */
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 84px); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(460px, calc(100% - 24px)); pointer-events: none; }
@media (min-width: 960px) { .toasts { bottom: 24px; left: auto; right: 24px; transform: none; } }
.toast { pointer-events: auto; display: flex; gap: 10px; align-items: center; padding: 12px 14px; border-radius: 14px; background: var(--text); color: var(--bg); box-shadow: var(--shadow-3); font-weight: 550; font-size: 14.5px; animation: toast-in .25s var(--ease); }
.toast.error { background: var(--critical); color: #fff; }
.toast.points { background: var(--points-strong); color: #1b1200; }
.toast .grow { min-width: 0; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ===== Tabeller ===== */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num, .table td.right, .table th.right { text-align: right; font-variant-numeric: tabular-nums; }

/* ===== Månedsvelger ===== */
.month-picker { display: inline-flex; align-items: center; gap: 2px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 2px; }
.month-picker .label { min-width: 132px; text-align: center; font-weight: 650; font-size: 14.5px; text-transform: capitalize; }

/* ===== Diagram ===== */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .hit { fill: transparent; cursor: crosshair; }
.chart .hover-band { fill: var(--text); opacity: .05; }
.chart-tooltip { position: absolute; pointer-events: none; z-index: 5; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-2); border-radius: 10px; padding: 8px 10px; font-size: 13px; min-width: 150px; transform: translate(-50%, calc(-100% - 10px)); white-space: nowrap; }
.chart-tooltip .tt-title { font-weight: 650; margin-bottom: 4px; text-transform: capitalize; }
.chart-tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.legend { display: flex; gap: var(--s4); flex-wrap: wrap; font-size: 13px; color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.swatch.line { height: 3px; width: 14px; border-radius: 2px; }
.hbar { display: grid; gap: 4px; padding: 8px 0; }
.hbar .top { display: flex; justify-content: space-between; gap: var(--s3); font-size: 14px; }
.hbar .track { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.hbar .fill { height: 100%; border-radius: 4px; background: var(--series-2); }
.hbar button { all: unset; cursor: pointer; display: grid; gap: 4px; }
.table-toggle { font-size: 13px; }

/* ===== Innlogging ===== */
.auth-page { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.auth-aside { display: none; }
.auth-main { display: flex; flex-direction: column; justify-content: center; padding: var(--s8) var(--s5); max-width: 440px; width: 100%; margin: 0 auto; gap: var(--s6); }
@media (min-width: 960px) {
  .auth-page { grid-template-columns: 1.1fr 1fr; }
  .auth-aside { display: flex; flex-direction: column; justify-content: space-between; padding: var(--s12); background: linear-gradient(160deg, #1c6b55 0%, #0f3f33 100%); color: #eaf6f0; position: relative; overflow: hidden; }
  .auth-aside h2 { font-size: 34px; line-height: 1.15; letter-spacing: -0.03em; max-width: 440px; }
  .auth-aside .feature { display: flex; gap: 12px; align-items: flex-start; max-width: 420px; }
  .auth-aside .feature .avatar-ico { background: rgba(255,255,255,.12); color: #fff; }
  .auth-aside .deco { position: absolute; right: -120px; bottom: -120px; width: 420px; height: 420px; border-radius: 50%; border: 60px solid rgba(255,255,255,.05); }
}
.demo-accounts { display: grid; gap: 6px; }
.demo-accounts button { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; border: 1px dashed var(--border-strong); background: var(--surface); cursor: pointer; text-align: left; font-size: 14px; }
.demo-accounts button:hover { border-color: var(--brand); background: var(--brand-soft); }

/* ===== Fordeler ===== */
.offer-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.offer-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; color: inherit; text-decoration: none !important; transition: box-shadow .2s, transform .2s; position: relative; }
.offer-card:hover { box-shadow: var(--shadow-2); transform: translateY(-2px); }
.offer-art { height: 112px; display: grid; place-items: center; position: relative; }
.offer-art svg { width: 44px; height: 44px; stroke-width: 1.5; }
.offer-body { padding: var(--s4); display: flex; flex-direction: column; gap: 6px; flex: 1; }
.offer-body .partner { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.offer-body .title { font-weight: 650; font-size: 15.5px; line-height: 1.3; }
.offer-foot { display: flex; justify-content: space-between; align-items: center; margin-top: auto; padding-top: 8px; }
.offer-fav { position: absolute; top: 8px; right: 8px; background: color-mix(in srgb, var(--surface) 85%, transparent); }
.offer-fav[aria-pressed="true"] { color: var(--critical); }
.offer-fav[aria-pressed="true"] svg { fill: currentColor; }
.art-0 { background: linear-gradient(135deg, #e3f1ea, #cfe7db); color: #1c6b55; }
.art-1 { background: linear-gradient(135deg, #fdf1d8, #f9e0ad); color: #9a5b00; }
.art-2 { background: linear-gradient(135deg, #e7eefb, #cfdcf6); color: #1f4f99; }
.art-3 { background: linear-gradient(135deg, #fbe7ef, #f5cddd); color: #8c2a52; }
.art-4 { background: linear-gradient(135deg, #ece9fb, #d9d3f6); color: #4a3aa7; }
.art-5 { background: linear-gradient(135deg, #fde9e0, #f8cfbd); color: #9a3b14; }
.art-6 { background: linear-gradient(135deg, #e0f3f1, #c3e8e3); color: #0f6b60; }
:root[data-theme="dark"] [class^="art-"], :root[data-theme="dark"] [class*=" art-"] { filter: brightness(.55) saturate(1.2); }
@media (prefers-color-scheme: dark) { :root:where(:not([data-theme="light"])) [class*="art-"] { filter: brightness(.55) saturate(1.2); } }
.demo-ribbon { position: absolute; top: 10px; left: 10px; }
.code-box { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 22px; font-weight: 700; letter-spacing: .08em; padding: 14px; border-radius: 12px; border: 2px dashed var(--border-strong); text-align: center; background: var(--surface-2); }

/* ===== Poeng ===== */
.task { display: flex; align-items: center; gap: var(--s3); padding: 10px 0; border-bottom: 1px solid var(--border); }
.task:last-child { border-bottom: 0; }
.task-check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--border-strong); display: grid; place-items: center; flex: none; color: transparent; }
.task.done .task-check { background: var(--good); border-color: var(--good); color: #fff; }
.task.done .task-name { color: var(--muted); }
.achievement { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; padding: var(--s4) var(--s2); border-radius: var(--r); border: 1px solid var(--border); background: var(--surface); }
.achievement .medal { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); }
.achievement.got .medal { background: radial-gradient(circle at 35% 30%, #ffe8a6, var(--points-strong)); color: #4a2d00; }
.achievement:not(.got) { opacity: .65; }
.achievement .name { font-weight: 650; font-size: 13.5px; }
.achievement .desc { font-size: 12px; color: var(--muted); }
.ach-grid { display: grid; gap: var(--s3); grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }

/* ===== Meny (mobil) ===== */
.menu-list .list-item { min-height: 60px; }

/* ===== Diverse ===== */
.divider { height: 1px; background: var(--border); margin: var(--s4) 0; border: 0; }
details.disclosure > summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 6px; color: var(--brand); font-weight: 600; font-size: 14px; min-height: 36px; }
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure[open] > summary svg { transform: rotate(180deg); }
.kbd { font-family: ui-monospace, Consolas, monospace; font-size: 12px; padding: 1px 6px; border-radius: 6px; border: 1px solid var(--border-strong); }
.page-enter { animation: page-in .25s var(--ease); }
@keyframes page-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.help-text { font-size: 14px; color: var(--text-2); line-height: 1.6; }
.help-text p + p { margin-top: 8px; }
.prose h2 { margin-top: var(--s6); margin-bottom: var(--s2); }
.prose p, .prose li { color: var(--text-2); line-height: 1.65; }
.prose ul { padding-left: 20px; }
.estimate { font-size: 12.5px; color: var(--muted); display: inline-flex; gap: 4px; align-items: center; }
.sticky-actions { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); border: 1px solid var(--border); border-radius: var(--r); padding: 10px; box-shadow: var(--shadow-2); }
@media (min-width: 960px) { .sticky-actions { bottom: 16px; } }
.tx-amount-in { color: var(--good-text); }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
@media (forced-colors: active) { .progress > span { background: Highlight; } .btn { border: 1px solid ButtonText; } }

/* ==========================================================================
   Lommeboken 2.0 – komponenter
   ========================================================================== */
.card { border-radius: 20px; box-shadow: 0 1px 2px rgba(40, 60, 40, .05), 0 6px 18px rgba(40, 70, 50, .06); border-color: var(--border); }
.sidebar { background: color-mix(in srgb, var(--surface) 70%, transparent); backdrop-filter: blur(10px); }
.bottom-nav { background: color-mix(in srgb, var(--surface) 94%, transparent); }
.money { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.money.income { color: var(--income); }
.money.expense { color: var(--expense); }
.money.left { color: var(--left); }
.money.neg-left { color: var(--expense); }

/* Overskrift i kort med liten knapp øverst til høyre */
.box-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s3); min-height: 36px; }
.box-head h2 { font-size: 16px; font-weight: 700; }
.box-head .sub { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.box-head .tools { display: flex; gap: 2px; }
.tool-btn { width: 36px; height: 36px; border-radius: 12px; border: 0; background: transparent; color: var(--text-2); display: grid; place-items: center; cursor: pointer; }
.tool-btn:hover { background: var(--surface-2); color: var(--text); }
.tool-btn svg { width: 19px; height: 19px; }

/* Tre nøkkeltall */
.trio { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.trio .k { background: var(--surface-2); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.trio .k .l { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trio .k .v { font-size: 17px; margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
.trio .k.income { background: var(--income-soft); } .trio .k.expense { background: var(--expense-soft); } .trio .k.left { background: var(--left-soft); }
@media (min-width: 720px) { .trio .k .v { font-size: 22px; } .trio .k { padding: 14px 16px; } }
.context-line { font-size: 12.5px; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* Neste lønn */
.payday { display: flex; align-items: center; gap: 16px; }
.payday .days { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; color: var(--income); line-height: 1; font-variant-numeric: tabular-nums; }
.payday .unit { font-size: 15px; font-weight: 700; color: var(--income); }

/* Postlister */
.rows { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 10px; padding: 11px 2px; border-bottom: 1px solid var(--border); min-height: 52px; width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; font: inherit; color: inherit; }
button.row-item { cursor: pointer; }
button.row-item:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.row-item:last-child { border-bottom: 0; }
.row-item .t { flex: 1; min-width: 0; }
.row-item .n { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item .d { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-item.sub { padding-left: 18px; min-height: 40px; }
.row-item.sub .n { font-weight: 500; font-size: 14px; color: var(--text-2); }
.sum-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 4px 0 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.sum-line .money { font-size: 22px; }
.left-total { text-align: center; padding: 6px 0 14px; }
.left-total .money { font-size: 34px; letter-spacing: -0.02em; }
.group-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 12px 0 2px; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 650; background: var(--surface-3); color: var(--text-2); }
.pill.saving { background: var(--left-soft); color: var(--left); }
.pill.main { background: var(--income-soft); color: var(--income); }
.pill.changed { background: var(--warning-soft); color: var(--warning-text); }

/* Kollapsbar boks */
.collapse-head { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-align: left; }
.collapse-head svg.chev { transition: transform .2s; }
.collapse-head[aria-expanded="false"] svg.chev { transform: rotate(-90deg); }

/* Budsjettvelger og månedsvelger */
.plan-bar { display: flex; align-items: center; gap: 8px; }
.plan-bar .select { font-weight: 700; font-size: 16px; min-height: 44px; border-radius: 14px; background-color: var(--surface); }
.mp { position: relative; display: inline-block; }
.mp-btn { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 14px; border: 1px solid var(--border-strong); background: var(--surface); font-weight: 700; font-size: 15px; cursor: pointer; color: var(--text); text-transform: capitalize; }
.mp-pop { position: absolute; z-index: 40; top: calc(100% + 6px); left: 0; width: 290px; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow-3); padding: 12px; }
.mp-year { display: flex; align-items: center; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
.mp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mp-grid button { min-height: 42px; border-radius: 12px; border: 1px solid transparent; background: var(--surface-2); font-weight: 600; cursor: pointer; color: var(--text); text-transform: capitalize; }
.mp-grid button[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.mp-grid button.now { border-color: var(--brand); }

/* Meny */
.menu-group { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; overflow: hidden; box-shadow: 0 1px 2px rgba(40,60,40,.05); }
.menu-group a, .menu-group button.mi { display: flex; align-items: center; gap: 14px; padding: 14px 16px; min-height: 58px; border-bottom: 1px solid var(--border); color: inherit; text-decoration: none; background: none; border-left: 0; border-right: 0; border-top: 0; width: 100%; font: inherit; text-align: left; cursor: pointer; }
.menu-group a:last-child, .menu-group button.mi:last-child { border-bottom: 0; }
.menu-group .mi-ico { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-ink); flex: none; }
.menu-group .mi-t { flex: 1; min-width: 0; }
.menu-group .mi-t b { display: block; font-weight: 650; }
.menu-group .mi-t span { display: block; font-size: 13px; color: var(--muted); }
.logout-btn { width: 100%; min-height: 52px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--expense); font-weight: 700; font-size: 16px; display: flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; }

/* Veiviser */
.wizard { max-width: 560px; margin: 0 auto; }
.steps { display: flex; gap: 6px; justify-content: center; margin: 4px 0 14px; }
.steps i { width: 28px; height: 6px; border-radius: 3px; background: var(--surface-3); }
.steps i.on { background: var(--brand); }
.cat-edit { border: 1px solid var(--border); border-radius: 16px; padding: 12px; background: var(--surface); display: grid; gap: 8px; }
.cat-edit .top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-edit .top > input.grow { flex: 1 1 100%; font-weight: 600; }
@media (min-width: 600px) { .cat-edit .top > input.grow { flex: 1 1 auto; } }
.cat-edit .top .input-money { flex: 1 1 140px; }
.cat-edit .top .input { min-height: 42px; }
.chip-add { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; border: 1px dashed var(--border-strong); background: transparent; font-size: 13px; cursor: pointer; color: var(--text-2); }
.chip-add[aria-pressed="true"] { background: var(--brand-soft); border-style: solid; border-color: var(--brand); color: var(--brand-ink); }
.alloc { position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 8px); z-index: 5; }
@media (min-width: 960px) { .alloc { bottom: 16px; } }
.code-big { font-family: ui-monospace, "SF Mono", Consolas, monospace; font-size: 26px; font-weight: 800; letter-spacing: .06em; text-align: center; padding: 16px; border-radius: 16px; background: var(--surface-2); border: 2px dashed var(--border-strong); }

@media print {
  .sidebar, .bottom-nav, .fab, .no-print, .toasts { display: none !important; }
  .shell { display: block; } .main { padding: 0; max-width: none; }
  .card { box-shadow: none; break-inside: avoid; }
  body { background: #fff; }
}

/* ===== Lommeboken 2.0 beta: dagens bonus, personvernboks ===== */
.bonus-box { display: flex; flex-direction: column; gap: 12px; }
.bonus-main { display: flex; align-items: center; gap: 14px; }
.bonus-ico { width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-soft, #dcefe3); color: var(--brand, #1b6b55); flex: none; }
.bonus-pts { font-size: 28px; font-weight: 750; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.bonus-pts .small { font-weight: 500; color: var(--text-2); }
.bonus-done { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 10px 14px; border-radius: 12px; background: var(--income-soft, #e3f2e8); color: var(--income); font-weight: 600; font-size: 15px; }
.bonus-box .btn { min-height: 48px; font-size: 16px; }
.privacy-box { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: var(--left-soft, #e7effb); border: 1px solid color-mix(in srgb, var(--left) 22%, transparent); color: var(--text); }
.privacy-box h3 { margin: 0 0 4px; font-size: 16px; }
.privacy-box p { margin: 0 0 6px; font-size: 14px; line-height: 1.5; color: var(--text-2); }
.privacy-box p:last-child { margin-bottom: 0; }
.privacy-box a { color: var(--left); font-weight: 600; }
.privacy-ico { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--surface); color: var(--left); flex: none; }
.left-card .left-total { padding: 4px 0 2px; }
.left-card .left-total .money { font-size: 30px; font-weight: 750; }
.text-warning { color: var(--warning, #9a6b00); }

/* ===== Lommeboken 3.0 ===== */
/* Sveipbar fanelinje: Oversikt og Meny fast, resten ruller sideveis. Siden selv får aldri horisontal rulling. */
.bottom-nav.swipe { display: flex; padding-left: env(safe-area-inset-left); padding-right: env(safe-area-inset-right); }
.bottom-nav.swipe > a { flex: 0 0 72px; }
.bottom-nav.swipe a { font-size: 11px; min-width: 0; }
.bottom-nav.swipe .nav-l { max-width: 70px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-scroll { flex: 1 1 auto; min-width: 0; display: flex; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scrollbar-width: none; -webkit-overflow-scrolling: touch; position: relative;
  -webkit-mask-image: linear-gradient(90deg, var(--ml, #000) 0, #000 18px, #000 calc(100% - 18px), var(--mr, #000) 100%); mask-image: linear-gradient(90deg, var(--ml, #000) 0, #000 18px, #000 calc(100% - 18px), var(--mr, #000) 100%); }
.nav-scroll::-webkit-scrollbar { display: none; }
.nav-scroll.more-l { --ml: transparent; } .nav-scroll.more-r { --mr: transparent; }
.nav-scroll > a { flex: 1 0 68px; scroll-snap-align: center; }
html, body { overflow-x: hidden; }
/* Sorterbare lister */
.sortable { display: flex; flex-direction: column; }
.sort-row { display: flex; align-items: center; gap: 2px; transition: transform .15s ease; background: var(--surface); border-radius: 12px; }
.sort-row.dragging { transition: none; box-shadow: var(--shadow-lg, 0 8px 24px rgba(0,0,0,.15)); opacity: .96; }
.sort-body { flex: 1 1 auto; min-width: 0; }
.drag-handle { flex: none; width: 32px; height: 44px; display: grid; place-items: center; border: 0; background: none; color: var(--muted); cursor: grab; touch-action: none; border-radius: 8px; }
.drag-handle:active { cursor: grabbing; color: var(--brand); }
.drag-handle:focus-visible { outline: 2px solid var(--brand); }
.sort-btns { display: none; flex: none; }
.sortable:focus-within .sort-btns, .sort-row:hover .sort-btns { display: flex; }
@media (pointer: coarse) { .sort-btns { display: none !important; } }
.mini-btn { width: 30px; height: 30px; border: 0; background: none; color: var(--muted); border-radius: 8px; display: grid; place-items: center; cursor: pointer; }
.mini-btn:disabled { opacity: .3; }
.tab-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px 10px 4px; min-height: 60px; }
.switch-inline { position: relative; display: inline-flex; width: 50px; height: 30px; flex: none; }
.switch-inline input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.switch-inline .track { width: 100%; height: 100%; border-radius: 15px; background: var(--border-strong, #c9c3ad); transition: background .2s; position: relative; }
.switch-inline .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch-inline input:checked + .track { background: var(--brand); }
.switch-inline input:checked + .track::after { transform: translateX(20px); }
.switch-inline input:focus-visible + .track { outline: 2px solid var(--brand); outline-offset: 2px; }
/* Handleliste */
.add-bar { display: flex; gap: 8px; align-items: center; }
.add-bar-sticky { position: sticky; bottom: calc(var(--nav-h, 64px) + env(safe-area-inset-bottom) + 8px); z-index: 10; box-shadow: 0 6px 24px rgba(0,0,0,.10); }
@media (min-width: 900px) { .add-bar-sticky { bottom: 12px; } }
.shop-tools { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.shop-tools .select { min-height: 40px; max-width: 220px; }
.shop-row { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 14px 6px 4px; border-bottom: 1px solid var(--border); }
.sort-row:last-child .shop-row { border-bottom: 0; }
.shop-check { position: relative; width: 44px; height: 44px; display: grid; place-items: center; flex: none; cursor: pointer; }
.shop-check input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.shop-check .box { width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--border-strong, #b9b39c); display: grid; place-items: center; color: transparent; transition: all .15s; background: var(--surface); }
.shop-check input:checked + .box { background: var(--income); border-color: var(--income); color: #fff; }
.shop-check input:focus-visible + .box { outline: 2px solid var(--brand); outline-offset: 2px; }
.shop-main { flex: 1 1 auto; min-width: 0; text-align: left; border: 0; background: none; padding: 6px 0; font: inherit; color: inherit; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.shop-main:disabled { cursor: default; }
.shop-main .n { font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.shop-main .q { font-weight: 500; color: var(--text-2); font-size: 14px; }
.shop-main .d { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.shop-row .p { flex: none; font-variant-numeric: tabular-nums; font-size: 14px; color: var(--text-2); }
.shop-row.done .n { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chip { flex: none; min-height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid var(--border); background: var(--surface); font: inherit; font-size: 14px; cursor: pointer; color: var(--text); }
.chip[aria-pressed="true"] { background: var(--brand); color: var(--on-brand, #fff); border-color: var(--brand); }
.undo-bar { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h, 64px) + env(safe-area-inset-bottom) + 84px); z-index: 40; display: flex; gap: 12px; align-items: center; background: var(--text); color: var(--surface); padding: 8px 8px 8px 16px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 24px); }
.link-btn { border: 0; background: none; color: var(--brand); font: inherit; cursor: pointer; padding: 4px 0; align-self: flex-start; display: inline-flex; gap: 4px; align-items: center; }
/* Tilbudsaviser */
.list-item.flyer { gap: 12px; }
.store-mark { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 14px; flex: none; letter-spacing: .02em; }
.flyer-link { color: inherit; text-decoration: none; min-width: 0; }
.icon.fav-on { fill: #f2b705; stroke: #c99400; }
/* Ønskelister */
.wish { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px 12px 4px; border-bottom: 1px solid var(--border); }
.sort-row:last-child .wish { border-bottom: 0; }
.wish-img { width: 64px; height: 64px; border-radius: 12px; object-fit: cover; flex: none; background: var(--bg-2, #eef3ec); }
.wish-img.ph { display: grid; place-items: center; color: var(--muted); }
.wish .n { font-weight: 650; font-size: 16px; overflow-wrap: anywhere; }
.wish .d { font-size: 14px; color: var(--text-2); margin-top: 2px; overflow-wrap: anywhere; }
.wish .m { display: flex; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-top: 4px; }
.wish-act { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex: none; }
