* { box-sizing: border-box; }
/* hidden-attributten skal vinde over eksplicitte display-regler (fx #login-view flex,
   #shell grid) — ellers skjuler .hidden=true ikke elementet */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  min-height: 100dvh;
}
h1, h2, h3 { margin: 0; }

/* ---------- Login ---------- */
#login-view {
  display: flex; align-items: center; justify-content: center;
  min-height: 100dvh; padding: 24px;
}
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 32px 28px;
  width: 100%; max-width: 360px;
  display: flex; flex-direction: column; gap: 16px;
}
.login-title { font-family: var(--font-display); font-weight: 600; font-size: 28px; text-align: center; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.login-card input {
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 12px 14px; font-size: 16px; font-family: inherit;
}
.login-card input:focus { outline: none; border-color: var(--accent); }

/* ---------- Knapper ---------- */
.btn {
  border: none; border-radius: var(--radius-sm); padding: 12px 18px;
  font-size: 15px; font-weight: 600; font-family: inherit; cursor: pointer;
}
.btn--primary { background: var(--accent); color: var(--bg); }
.btn--primary:hover { background: var(--accent-hover); }
.btn--ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }

/* ---------- Shell / navigation ---------- */
#shell { min-height: 100dvh; }
#page { padding: 20px 16px calc(var(--nav-height) + 24px); max-width: 640px; margin: 0 auto; }
.page-title { font-family: var(--font-display); font-weight: 600; font-size: 26px; margin-bottom: 16px; }

#sidebar { display: none; }
#bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; height: var(--nav-height);
  display: flex; justify-content: space-around; align-items: stretch;
  background: var(--surface-2); border-top: 1px solid var(--border-soft);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; font-size: 10px; color: var(--text-faint); text-decoration: none;
}
.nav-item .nav-icon { font-size: 20px; line-height: 1; font-style: normal; }
.nav-item--active { color: var(--accent-hover); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-height) + 16px);
  transform: translateX(-50%) translateY(8px);
  background: var(--surface); border: 1px solid var(--red); color: var(--text);
  border-radius: var(--radius-sm); padding: 12px 18px; font-size: 14px;
  opacity: 0; transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--success { border-color: var(--green); }

/* ---------- Desktop (≥1024px): sidebar i stedet for bund-nav ---------- */
@media (min-width: 1024px) {
  #shell { display: grid; grid-template-columns: 220px 1fr; }
  #bottom-nav { display: none; }
  #sidebar {
    display: flex; flex-direction: column; gap: 8px;
    border-right: 1px solid var(--border-soft); padding: 24px 16px;
    position: sticky; top: 0; height: 100dvh;
  }
  .sidebar-brand { font-family: var(--font-display); font-size: 20px; font-weight: 600; margin-bottom: 16px; }
  #sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
  #sidebar-nav .nav-item {
    flex-direction: row; justify-content: flex-start; gap: 10px;
    font-size: 14px; padding: 10px 12px; border-radius: var(--radius-sm);
  }
  #sidebar-nav .nav-item--active { background: var(--accent-soft); }
  #page { padding-bottom: 24px; }
}

/* ---------- Konti ---------- */
.dim-text { color: var(--text-dim); font-size: 13px; }
.wealth { margin-bottom: 20px; position: relative; }
.wealth-total { font-family: var(--font-display); font-size: 40px; font-weight: 600; }
.acct-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; cursor: pointer;
}
.acct-main { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.acct-name { font-weight: 600; font-size: 15px; }
.acct-desc { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.acct-sync { color: var(--text-faint); font-size: 12px; margin-top: 2px; }
.acct-sync--error { color: var(--red); }
.wealth #sync-btn { position: absolute; top: 0; right: 0; }
.acct-balance { font-weight: 700; font-size: 15px; white-space: nowrap; }
.acct-balance.pos { color: var(--green); }
.acct-balance.neg { color: var(--red); }
.acct-spark { width: 100%; height: 60px; margin-top: 12px; }
.acct-graph-labels { display: flex; justify-content: space-between; color: var(--text-faint); font-size: 11px; }

/* ---------- Månedsnav + posteringer ---------- */
.month-nav { display: flex; align-items: center; justify-content: center; gap: 16px; margin-bottom: 14px; }
.month-btn {
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  border-radius: var(--radius-sm); width: 36px; height: 36px; font-size: 18px; cursor: pointer;
}
.month-label { font-weight: 600; min-width: 140px; text-align: center; }
.tx-search {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 11px 14px;
  font-size: 15px; font-family: inherit; margin-bottom: 10px;
}
.tx-search:focus { outline: none; border-color: var(--accent); }
.pills { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.pill {
  background: var(--surface); border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 999px; padding: 7px 14px; font-size: 13px; cursor: pointer; font-family: inherit;
}
.pill--active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-hover); }
.tx-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 4px; border-bottom: 1px solid var(--border-soft);
}
.tx-icon {
  width: 34px; height: 34px; border-radius: var(--radius-sm); flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border); font-size: 16px;
}
.tx-main { flex: 1; min-width: 0; }
.tx-desc { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.tx-amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.tx-amount.neg { color: var(--text); }
.tx-amount.pos { color: var(--green); }

/* ---------- Overblik hero ---------- */
.hero { margin: 6px 0 20px; }
.hero-net { font-family: var(--font-display); font-size: 44px; font-weight: 600; color: var(--green); }
.hero-net.neg { color: var(--red); }
.hero-inout { font-size: 13px; color: var(--text-dim); margin-top: 4px; }
.hero-inout b { color: var(--text); font-weight: 700; }
.hero-inout b.pos { color: var(--green); }

/* ---------- Mere + CSV-import ---------- */
.mere-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mere-list li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.mere-link { display: block; padding: 14px 16px; color: var(--text); text-decoration: none; font-weight: 500; }
.back-link { color: var(--text-dim); text-decoration: none; font-size: 13px; display: inline-block; margin-bottom: 8px; }
.csv-form { display: flex; flex-direction: column; gap: 14px; max-width: 420px; }
.csv-form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.csv-form select, .csv-form input[type=file] {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 10px 12px; font: inherit;
}
.csv-result { margin-top: 16px; padding: 12px 16px; background: var(--surface);
  border: 1px solid var(--green); border-radius: var(--radius-sm); font-size: 14px; }

/* ---------- Regler + Faste udgifter ---------- */
.rule-row { display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); margin-bottom: 6px; }
.rule-main { flex: 1; min-width: 0; }
.rule-name { font-size: 14px; font-weight: 500; }
.rule-meta { font-size: 12px; color: var(--text-faint); margin-top: 2px; }
.fe-interval { display: flex; gap: 10px; }
.fe-interval .txm-field { flex: 1; }
#fe-list { margin-top: 12px; }
.txm-field select { background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 10px 12px; font: inherit; }

/* ---------- Overblik: budget-linje + statusgrupperet kategoriliste ---------- */
.budget-line { margin: 4px 0 18px; }
.budget-line-text { font-size: 13px; color: var(--text-dim); margin-bottom: 6px; }
.budget-line-text b { color: var(--text); font-weight: 700; }
.budget-line-bar { height: 4px; background: var(--surface); border-radius: 2px; overflow: hidden; }
.budget-line-bar #bl-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.budget-line-bar #bl-fill.over { background: var(--red); }

.cat-group { margin-bottom: 18px; }
.cat-group-title { font-size: 12px; color: var(--text-dim); margin-bottom: 8px; letter-spacing: .02em; }
.cat-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); margin-bottom: 6px;
  color: var(--text); text-decoration: none;
}
.cat-icon { font-size: 18px; width: 26px; text-align: center; flex-shrink: 0; }
.cat-main { flex: 1; min-width: 0; }
.cat-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-bar { height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 5px; overflow: hidden; }
.cat-bar-fill { height: 100%; border-radius: 2px; }
.cat-bar--over { background: var(--red); }
.cat-bar--near { background: var(--yellow); }
.cat-bar--ok { background: var(--green); }
.cat-bar--nobudget { background: var(--text-faint); }
.cat-nums { font-size: 13px; font-weight: 700; white-space: nowrap; }
.cat-of { color: var(--text-dim); font-weight: 400; }
.rollover-badge { font-size: 11px; font-weight: 400; margin-left: 4px; }
.rollover-badge.pos { color: var(--green); }
.rollover-badge.neg { color: var(--red); }
.budget-chart { width: 100%; height: 140px; margin-bottom: 4px; }
.chart-bar { fill: var(--accent); opacity: .85; }
.chart-label { fill: var(--text-faint); font-size: 9px; text-anchor: middle; }
.chart-avg { stroke: var(--yellow); stroke-width: 1; stroke-dasharray: 4 3; }
.chart-caption { margin-bottom: 18px; }
.budget-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); margin-bottom: 6px;
}
.budget-row-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.budget-row-input { display: flex; align-items: center; gap: 6px; }
.budget-input {
  width: 84px; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 8px 10px;
  font: inherit; text-align: right;
}
.budget-input:focus { outline: none; border-color: var(--accent); }
.budget-sub { display: flex; justify-content: space-between; gap: 8px; font-size: 12px;
  padding: 4px 12px 4px 38px; color: var(--text-dim); }
.budget-sub-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal-sheet {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0; width: 100%; max-width: 560px;
  max-height: 85vh; overflow-y: auto; padding: 16px;
}
@media (min-width: 1024px) {
  .modal-backdrop { align-items: center; }
  .modal-sheet { border-radius: var(--radius); }
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.modal-title { font-weight: 600; font-size: 17px; }
.modal-close { background: none; border: none; color: var(--text-dim); font-size: 18px; cursor: pointer; padding: 4px 8px; }
.txm-desc { font-weight: 600; font-size: 15px; }
.txm-meta { color: var(--text-dim); font-size: 13px; margin: 2px 0 10px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin: 12px 0; }
.cat-pick {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.cat-pick:hover { border-color: var(--accent); }
.cat-pick--active { border-color: var(--accent); background: var(--accent-soft); }
.cat-pick-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cover-pick {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit; font-size: 13px; cursor: pointer; text-align: left;
}
.cover-pick:hover { border-color: var(--accent); }
.txm-remember { display: flex; gap: 8px; align-items: center; font-size: 14px; margin: 10px 0; }
#txm-rule-fields label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
#txm-rule-fields input[type=text], #txm-rule-fields input:not([type]) {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 10px 12px; font: inherit;
}
.txm-amount-cb { flex-direction: row !important; align-items: center; }
.tx-badge { font-size: 11px; margin-left: 5px; }
.tx-toolbar { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft); border: 1px solid var(--accent); border-radius: var(--radius-sm);
  padding: 8px 12px; margin-bottom: 10px; font-size: 13px; }
.tx-check { accent-color: var(--accent); width: 18px; height: 18px; flex-shrink: 0; }
.tx-account {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 9px 10px; font: inherit; font-size: 13px;
}
.txm-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; }
.txm-cover-intro { margin-bottom: 8px; }
.txm-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); margin: 10px 0; }
.txm-field input {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 10px 12px; font: inherit;
}
.txm-similar-row { display: flex; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); }
.txm-similar-desc { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Kuverter ---------- */
.env-toolbar { display: flex; gap: 8px; margin-bottom: 14px; }
.env-card { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; }
.env-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.env-name { font-size: 15px; font-weight: 600; }
.env-amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.env-meta { font-size: 12px; margin-top: 6px; }
.env-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

/* ---------- Dækning ---------- */
.cov-group { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 8px; cursor: pointer; }
.cov-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.cov-title { font-size: 14px; font-weight: 600; }
.cov-total { font-weight: 700; white-space: nowrap; }
.cov-meta { font-size: 12px; margin-top: 2px; }
.cov-items { margin-top: 8px; }

/* ---------- Pengedates ---------- */
.pd-summary { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 14px; }
.pd-summary-nums { font-size: 13px; color: var(--text-dim); margin-bottom: 8px; }
.pd-summary-nums b { color: var(--text); }
.pd-card { background: var(--surface); border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm); padding: 12px 14px; margin: 8px 0; }
.pd-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pd-date { font-weight: 600; font-size: 15px; }
.pd-badge { font-size: 11px; color: var(--yellow); margin-left: 6px; }
.pd-badge--done { color: var(--green); }
.pd-agenda { margin: 10px 0; }
.pd-agenda-item { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.pd-agenda-item .pd-done { text-decoration: line-through; color: var(--text-faint); }
.pd-agenda-item span { flex: 1; }
.pd-agenda-del { background: none; border: none; color: var(--text-faint); cursor: pointer; }
.pd-agenda-add { display: flex; gap: 6px; margin-top: 6px; }
.pd-agenda-input { flex: 1; background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); padding: 8px 10px; font: inherit; font-size: 13px; }
.pd-notes { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
  color: var(--text); padding: 8px 10px; font: inherit; resize: vertical; }
.pd-images { margin-top: 10px; }
.pd-thumbs { display: flex; gap: 8px; margin-bottom: 8px; }
.pd-thumb { position: relative; }
.pd-thumb img { width: 96px; height: 96px; object-fit: cover; border-radius: var(--radius-sm);
  border: 1px solid var(--border); }
.pd-img-del { position: absolute; top: -6px; right: -6px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 50%; color: var(--text-dim);
  width: 22px; height: 22px; cursor: pointer; font-size: 11px; }
