/* ─────────────────────────────────────────────────────────
   REGNSKAP — Modernist Ledger
   Felles stilark for alle sidene
   ───────────────────────────────────────────────────────── */

:root {
  --bg: #f3efe6;
  --surface: #faf7f0;
  --surface-2: #ede8db;
  --ink: #1c1a17;
  --ink-2: #5a554f;
  --ink-3: #8d877d;
  --line: #d8d2c4;
  --line-2: #e9e3d4;
  --accent: #8b2538;
  --accent-2: #b34055;
  --positive: #34552a;
  --negative: #8b2538;
  --gold: #b89150;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;

  --r-sm: 4px;
  --r: 6px;
  --r-lg: 10px;

  --shadow-1: 0 1px 2px rgba(28, 26, 23, 0.04);
  --shadow-2: 0 8px 24px rgba(28, 26, 23, 0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at top left, rgba(139, 37, 56, 0.025), transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(52, 85, 42, 0.02), transparent 55%);
}

a { color: var(--ink); text-decoration: none; }

input, button, select, textarea { font: inherit; color: inherit; }

.container {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

/* ─────────── Topbar ─────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 36px;
  gap: 24px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 4px rgba(139, 37, 56, 0.08);
}

.brand-name {
  font-family: var(--serif);
  font-size: 26px;
  font-style: italic;
  font-weight: 400;
  letter-spacing: -0.015em;
  line-height: 1;
}

.brand-sub {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  padding-left: 14px;
  border-left: 1px solid var(--line);
}

nav.tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--r);
}

nav.tabs a {
  padding: 7px 14px;
  font-size: 13.5px;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  transition: all 0.18s;
  font-weight: 450;
}

nav.tabs a:hover { color: var(--ink); }

nav.tabs a.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-1), 0 0 0 1px var(--line);
}

/* ─────────── Section header ─────────── */
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 24px;
  flex-wrap: wrap;
}

.section-head h1 {
  font-family: var(--serif);
  font-size: 44px;
  font-weight: 400;
  letter-spacing: -0.025em;
  line-height: 1.05;
}

.section-head h1 em {
  font-style: italic;
  color: var(--accent);
}

.section-head .meta {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--ink-3);
}

/* ─────────── Period selector ─────────── */
.period-selector {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  overflow: hidden;
}

.period-selector button {
  padding: 8px 14px;
  background: transparent;
  border: none;
  font-size: 13px;
  color: var(--ink-2);
  cursor: pointer;
  transition: all 0.18s;
  border-right: 1px solid var(--line);
  font-family: var(--sans);
}

.period-selector button:last-child { border-right: none; }

.period-selector button:hover { background: var(--surface-2); color: var(--ink); }

.period-selector button.active {
  background: var(--ink);
  color: var(--bg);
}

/* ─────────── KPI cards ─────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: 36px;
}

.kpi {
  background: var(--surface);
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
}

.kpi-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

.kpi-value {
  font-family: var(--serif);
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.kpi-value.positive { color: var(--positive); }
.kpi-value.negative { color: var(--negative); }

.kpi-sub {
  font-size: 11.5px;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: 0.04em;
}

/* ─────────── Card ─────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line-2);
  gap: 12px;
}

.card-head.no-border {
  border-bottom: none;
  padding-bottom: 0;
  margin-bottom: 16px;
}

.card-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.01em;
}

.card-subtitle {
  font-family: var(--mono);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--ink-3);
  margin-top: 4px;
}

/* ─────────── Two-column layout ─────────── */
.grid-2 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.grid-2.equal { grid-template-columns: 1fr 1fr; }

/* ─────────── Tables ─────────── */
.txn-table {
  width: 100%;
  border-collapse: collapse;
}

.txn-table th {
  text-align: left;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  padding: 0 12px 12px;
  border-bottom: 1px solid var(--line);
}

.txn-table th.right, .txn-table td.right { text-align: right; }

.txn-table td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line-2);
  font-size: 14px;
  vertical-align: middle;
}

.txn-table tbody tr:last-child td { border-bottom: none; }

.txn-table tbody tr {
  transition: background 0.15s;
}

.txn-table tbody tr:hover {
  background: var(--surface-2);
}

.amt {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.amt.income { color: var(--positive); }
.amt.expense { color: var(--negative); }

.cat-tag {
  display: inline-block;
  padding: 3px 10px;
  background: var(--surface-2);
  border-radius: 999px;
  font-size: 12px;
  color: var(--ink-2);
  border: 1px solid var(--line-2);
  white-space: nowrap;
}

.txn-date {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}

.row-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.icon-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: var(--r-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--ink-2);
  transition: all 0.15s;
  padding: 0;
}

.icon-btn:hover {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}

.icon-btn.danger:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ─────────── Forms ─────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field.full { grid-column: 1 / -1; }

.field label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
}

.field input, .field select, .field textarea {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 14.5px;
  color: var(--ink);
  transition: all 0.15s;
  font-family: var(--sans);
}

.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--ink);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(28, 26, 23, 0.06);
}

.field input[type="number"], .field input[type="date"] {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}

.field-help {
  font-size: 12px;
  color: var(--ink-3);
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* ─────────── Buttons ─────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--bg);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: var(--r);
  cursor: pointer;
  transition: all 0.18s;
  text-decoration: none;
  font-family: var(--sans);
  white-space: nowrap;
}

.btn:hover {
  background: #2c2925;
  transform: translateY(-1px);
  box-shadow: var(--shadow-2);
}

.btn:active { transform: translateY(0); }

.btn.ghost {
  background: transparent;
  color: var(--ink);
}

.btn.ghost:hover { background: var(--surface-2); transform: none; box-shadow: none; }

.btn.outline {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn.outline:hover { background: var(--surface-2); border-color: var(--ink-2); }

.btn.danger {
  background: var(--accent);
  border-color: var(--accent);
}

.btn.danger:hover { background: #6e1d2c; border-color: #6e1d2c; }

.btn.small {
  padding: 5px 11px;
  font-size: 12.5px;
}

.btn-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─────────── Type toggle (inntekt/utgift) ─────────── */
.type-toggle {
  display: flex;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
  width: 100%;
}

.type-toggle label {
  flex: 1;
  background: var(--surface);
  padding: 11px 18px;
  cursor: pointer;
  font-size: 13.5px;
  text-align: center;
  transition: all 0.18s;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.type-toggle input { display: none; }

.type-toggle input:checked + label.income {
  background: var(--positive);
  color: var(--surface);
}

.type-toggle input:checked + label.expense {
  background: var(--accent);
  color: var(--surface);
}

/* ─────────── Empty state ─────────── */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--ink-3);
}

.empty-icon {
  font-family: var(--serif);
  font-size: 56px;
  font-style: italic;
  opacity: 0.4;
  margin-bottom: 8px;
  line-height: 1;
}

.empty p { font-size: 14px; max-width: 320px; margin: 0 auto; }

.empty .btn { margin-top: 16px; }

/* ─────────── Charts ─────────── */
.chart-container {
  width: 100%;
  position: relative;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.bar-rect {
  transition: opacity 0.2s;
  cursor: default;
}

.bar-rect:hover { opacity: 0.8; }

/* ─────────── Modal ─────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 23, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.modal-backdrop.open {
  display: flex;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--surface);
  border-radius: var(--r-lg);
  border: 1px solid var(--line);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(28, 26, 23, 0.25);
  animation: modalIn 0.25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-head {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-head h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  font-style: italic;
}

.modal-body { padding: 22px 24px; }

.modal-foot {
  padding: 16px 24px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--ink-3);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--surface-2); color: var(--ink); }

/* ─────────── Toast ─────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 18px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r);
  font-size: 13.5px;
  z-index: 200;
  animation: toastIn 0.3s ease;
  box-shadow: var(--shadow-2);
  max-width: 320px;
}

.toast.success { border-left: 3px solid var(--positive); }
.toast.error { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─────────── Footer ─────────── */
.footer {
  margin-top: 56px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.footer .dot { color: var(--accent); margin: 0 6px; }

/* ─────────── Filter row ─────────── */
.filter-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 16px;
}

/* ─────────── Quick add ─────────── */
.quick-add {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: 22px;
  margin-bottom: 24px;
}

/* ─────────── Settings groups ─────────── */
.settings-group {
  margin-bottom: 32px;
}

.settings-group h3 {
  font-family: var(--serif);
  font-size: 22px;
  font-style: italic;
  font-weight: 400;
  margin-bottom: 14px;
}

.cat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--r);
  font-size: 14px;
}

.cat-item .cat-name { display: flex; align-items: center; gap: 10px; }

.cat-type-badge {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 999px;
}

.cat-type-badge.income {
  background: rgba(52, 85, 42, 0.12);
  color: var(--positive);
}

.cat-type-badge.expense {
  background: rgba(139, 37, 56, 0.1);
  color: var(--accent);
}

/* ─────────── Stats list ─────────── */
.stats-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.stat-row-head {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
}

.stat-row-bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 2px;
  overflow: hidden;
}

.stat-row-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-row-pct {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
}

/* ─────────── Responsive ─────────── */
@media (max-width: 980px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2.equal { grid-template-columns: 1fr; }
  .section-head h1 { font-size: 36px; }
  .filter-row { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 640px) {
  .container { padding: 20px 16px 60px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: flex-start; }
  nav.tabs { width: 100%; overflow-x: auto; }
  .section-head h1 { font-size: 30px; }
  .kpi-value { font-size: 28px; }
  .form-grid { grid-template-columns: 1fr; }
  .filter-row { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}

/* ─────────── Animations ─────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.kpi { animation: fadeUp 0.5s ease backwards; }
.kpi:nth-child(1) { animation-delay: 0.05s; }
.kpi:nth-child(2) { animation-delay: 0.12s; }
.kpi:nth-child(3) { animation-delay: 0.19s; }
.kpi:nth-child(4) { animation-delay: 0.26s; }

.card { animation: fadeUp 0.5s ease 0.32s backwards; }

.txn-table tbody tr { animation: fadeUp 0.4s ease backwards; }

/* ─────────── Bilag & badges ─────────── */
.bilag {
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.konto-tag {
  display: inline-block;
  padding: 2px 8px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--surface-2);
  color: var(--ink-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--line-2);
}

/* ─────────── Medlem-status ─────────── */
.medlem-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 999px;
}

.medlem-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.medlem-status.betalt {
  background: rgba(52, 85, 42, 0.1);
  color: var(--positive);
}
.medlem-status.betalt::before { background: var(--positive); }

.medlem-status.ubetalt {
  background: rgba(139, 37, 56, 0.08);
  color: var(--accent);
}
.medlem-status.ubetalt::before { background: var(--accent); }

.medlem-status.inaktiv {
  background: var(--surface-2);
  color: var(--ink-3);
}
.medlem-status.inaktiv::before { background: var(--ink-3); }

/* ─────────── Resultatregnskap ─────────── */
.resultat-tabell {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 14px;
}

.resultat-tabell .gruppe-head td {
  font-family: var(--serif);
  font-style: italic;
  font-size: 17px;
  padding: 22px 0 8px;
  border-bottom: 1px solid var(--ink);
  color: var(--ink);
}

.resultat-tabell .linje td {
  padding: 7px 0;
  border-bottom: 1px solid var(--line-2);
}

.resultat-tabell .linje td:first-child {
  padding-left: 16px;
  font-family: var(--sans);
}

.resultat-tabell .sum-rad td {
  padding: 12px 0 14px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.resultat-tabell .sum-rad td:first-child {
  font-family: var(--sans);
  font-style: italic;
}

.resultat-tabell .total-rad td {
  padding: 18px 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 22px;
  border-top: 2px solid var(--ink);
  border-bottom: 4px double var(--ink);
}

.resultat-tabell .belop {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.resultat-tabell .belop.positive { color: var(--positive); }
.resultat-tabell .belop.negative { color: var(--accent); }

/* ─────────── Tre-kolonners grid ─────────── */
.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 980px) {
  .grid-3 { grid-template-columns: 1fr; }
}

/* Print-friendly */
@media print {
  body { background: white; }
  nav.tabs, .btn, .period-selector, .filter-row, .quick-add, .row-actions, .icon-btn { display: none !important; }
  .card { break-inside: avoid; box-shadow: none; }
}

/* ═══════════════════════════════════════════════════════════
   LOGIN-side & BRUKER-meny (sky-versjon)
   ═══════════════════════════════════════════════════════════ */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-lg);
  padding: 48px 40px;
  box-shadow: 0 1px 0 rgba(28,26,23,0.04);
}

.login-card .brand-mark {
  width: 22px;
  height: 22px;
  margin-bottom: 18px;
}

.login-card h1 {
  font-family: var(--serif);
  font-style: italic;
  font-size: 32px;
  font-weight: 400;
  letter-spacing: -0.01em;
  margin-bottom: 6px;
}

.login-card p.lead {
  color: var(--ink-2);
  font-size: 14px;
  margin-bottom: 28px;
  line-height: 1.5;
}

.login-card .field {
  margin-bottom: 16px;
}

.login-card .btn {
  width: 100%;
  justify-content: center;
}

.login-message {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  line-height: 1.55;
}

.login-message.info {
  background: rgba(28,26,23,0.04);
  border: 1px solid var(--line-2);
  color: var(--ink-2);
}

.login-message.success {
  background: rgba(52, 85, 42, 0.08);
  border: 1px solid rgba(52, 85, 42, 0.25);
  color: var(--positive);
}

.login-message.error {
  background: rgba(139, 37, 56, 0.06);
  border: 1px solid rgba(139, 37, 56, 0.25);
  color: var(--accent);
}

.login-foot {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--line-2);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-3);
  text-align: center;
}

/* Brukermeny i topbar */
.user-menu {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-3);
}

.user-menu .user-email {
  text-transform: lowercase;
}

.user-menu .logout-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s;
  cursor: pointer;
}

.user-menu .logout-link:hover {
  border-bottom-color: var(--accent);
}

/* Loading-tilstand */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 200px;
  font-family: var(--serif);
  font-style: italic;
  color: var(--ink-3);
  font-size: 16px;
}

.loading-state::before {
  content: '·';
  font-size: 40px;
  margin-right: 12px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   MOBIL — bedre tabeller og topbar på smale skjermer
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 720px) {
  /* Topbar stables vertikalt */
  .topbar {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
    padding: 16px;
  }

  .brand {
    justify-content: center;
  }

  nav.tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    justify-content: flex-start;
    padding: 4px 0;
  }

  nav.tabs a {
    flex-shrink: 0;
    font-size: 12px;
    padding: 6px 10px;
  }

  .user-menu {
    justify-content: center;
    flex-wrap: wrap;
  }

  /* Section-head stables */
  .section-head {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .section-head h1 {
    font-size: 26px;
    text-align: center;
  }

  .period-selector {
    justify-content: center;
  }

  /* KPI-grid: 2 kolonner på tablet, 1 på telefon */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Filter-row stables */
  .filter-row {
    grid-template-columns: 1fr !important;
  }

  /* Tabeller: scroll horisontalt */
  .txn-table {
    font-size: 12.5px;
  }
  .txn-table th, .txn-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }
  .card > div:has(> table) {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Modal: full skjerm på mobil */
  .modal {
    width: calc(100vw - 24px);
    max-width: none;
    margin: 12px;
    max-height: calc(100vh - 24px);
  }
  .modal-body {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
  }
  .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Quick-add */
  .quick-add .form-grid {
    grid-template-columns: 1fr !important;
  }

  /* Login-card paddes mindre */
  .login-card {
    padding: 32px 24px;
  }
}

@media (max-width: 480px) {
  .kpi-grid {
    grid-template-columns: 1fr !important;
  }

  .container {
    padding: 12px;
  }

  .card {
    padding: 18px 16px;
  }

  .section-head h1 {
    font-size: 22px;
  }
}
