/* PayDay — Låneoversigt. Dark-first, accent-driven, light-theme aware. */
:root {
  color-scheme: dark;
  --bg: #101014;
  --surface: #1a1a20;
  --surface-2: #16161b;
  --surface-3: #191920;
  --field: #151519;
  --border: #26262e;
  --border-2: #2b2b33;
  --border-3: #232329;
  --text: #f4f4f5;
  --text-2: #c8c8cf;
  --muted: #9a9aa4;
  --muted-2: #71717a;
  --muted-3: #6a6a74;
  --accent: #8b7cf6;
  --accent-2: #6c5ce7;
  --accent-soft: rgba(139, 124, 246, .12);
  --accent-grad: linear-gradient(145deg, var(--accent), var(--accent-2));
  --danger: #f0708a;
  --good: #34d399;
  --warn: #efe4a1;
  --hero: linear-gradient(160deg, #211f30, #1a1a20);
  --hero-border: #2c2a3a;
  --shadow: 0 20px 40px -12px rgba(0, 0, 0, .6);
  --radius: 20px;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f7;
  --surface: #ffffff;
  --surface-2: #ffffff;
  --surface-3: #f1f1f5;
  --field: #f5f5f8;
  --border: #e6e6ec;
  --border-2: #e0e0e8;
  --border-3: #eeeef2;
  --text: #17171c;
  --text-2: #3a3a44;
  --muted: #6a6a74;
  --muted-2: #8a8a94;
  --muted-3: #9a9aa4;
  --accent-soft: rgba(139, 124, 246, .14);
  --hero: linear-gradient(160deg, #ece9fb, #ffffff);
  --hero-border: #ddd8f5;
  --shadow: 0 20px 40px -12px rgba(80, 70, 130, .18);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* Safety net: the page itself never scrolls sideways (clip, unlike hidden,
   doesn't turn body into a scroll container or break position: sticky). */
html, body { overflow-x: clip; }
/* iOS must not inflate text on rotate (that reads as a zoom). */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
}
a { color: color-mix(in srgb, var(--accent) 78%, white); text-decoration: none; }
a:hover { color: color-mix(in srgb, var(--accent) 60%, white); }
input, button, textarea, select { font-family: inherit; }
input::placeholder, textarea::placeholder { color: var(--muted-3); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }

/* ---- App shell ---- */
.shell { padding-left: 248px; min-height: 100vh; }
.sidebar {
  position: fixed; top: 0; left: 0; bottom: 0; width: 248px;
  background: var(--surface-2); border-right: 1px solid var(--border-3);
  padding: 26px 18px; display: flex; flex-direction: column; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px 4px; }
/* Logo from assets/branding: white wordmark on dark, black on light */
.brand-logo { display: inline-flex; line-height: 0; }
.brand-logo img { height: auto; max-width: 100%; }
.brand-logo .on-light, :root[data-theme="light"] .brand-logo .on-dark { display: none; }
:root[data-theme="light"] .brand-logo .on-light { display: block; }
.nav { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 13px;
  background: none; color: var(--muted); font-weight: 600; font-size: 14.5px; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.nav a.active { background: color-mix(in srgb, var(--accent) 16%, var(--surface-3)); color: var(--text);
  font-weight: 700; box-shadow: inset 3px 0 0 -1px var(--accent); }
.nav .ico { font-size: 17px; width: 20px; text-align: center; }

.bottomnav { display: none; position: fixed; bottom: 0; left: 0; right: 0; height: 71px;
  background: var(--surface-2); border-top: 1px solid var(--border-3); z-index: 30;
  align-items: center; justify-content: space-around; padding: 0 8px 5px; }
.bottomnav a, .bottomnav button { display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--muted-3);
  font-size: 10px; flex: 1; text-align: center; background: none; border: none; padding: 0; cursor: pointer; }
.bottomnav a.active, .bottomnav button.active { color: var(--accent); }
.bottomnav .ico { display: flex; line-height: 0; }
.nav .ico { display: inline-flex; align-items: center; justify-content: center; }
.bottomnav .fab { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px;
  margin-top: -14px; border-radius: 17px; background: var(--accent-grad); color: #fff; font-size: 26px;
  font-weight: 800; box-shadow: 0 10px 22px -8px color-mix(in srgb, var(--accent) 80%, transparent); }

/* ---- Sidebar extras: add button + profile menu ---- */
.side-add { margin-top: 24px; gap: 8px; }
.side-user { margin-top: auto; }
.usermenu { position: relative; }
.userchip { display: flex; align-items: center; gap: 10px; background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 13px; padding: 6px 10px 6px 6px; cursor: pointer; }
.userchip .who { line-height: 1.2; flex: 1; min-width: 0; }
.userchip .chev { color: var(--muted-2); display: flex; }
.menu.menu-up { top: auto; bottom: calc(100% + 8px); left: 0; right: 0; width: auto; }
.menu svg { color: var(--muted); flex-shrink: 0; }
.menu .danger svg { color: inherit; }

/* ---- Mobile menu sheet ---- */
.overlay.sheet-overlay { align-items: flex-end; padding: 0; }
.sheet { width: 100%; height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow-y: auto;
  background: var(--surface);
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(18px + env(safe-area-inset-bottom, 0px));
  animation: sheet-in .22s ease-out; }
@keyframes sheet-in { from { transform: translateY(100%); } to { transform: none; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 0 4px 16px; }
.sheet-user { display: flex; align-items: center; gap: 12px; padding: 4px 4px 16px; border-bottom: 1px solid var(--border-3); margin-bottom: 8px; }
.sheet-list a, .sheet-list button, .sheet-logout { display: flex; align-items: center; gap: 13px; width: 100%; padding: 14px 6px;
  background: none; border: none; color: var(--text); font-size: 15px; font-weight: 600; text-align: left; cursor: pointer; border-radius: 12px; }
.sheet-list a > svg:first-child, .sheet-list button > svg:first-child { color: var(--muted); }
.sheet-list a > span, .sheet-list button > span { flex: 1; }
.sheet-list small { display: block; font-size: 12px; color: var(--muted-2); font-weight: 500; margin-top: 1px; }
.sheet-list a > svg:last-child, .sheet-list button > svg:last-child { color: var(--muted-3); }
.sheet-list a.active, .sheet-list a.active > svg:first-child { color: var(--accent); }
/* Bottom row of the mobile menu: "Log ud" left, "Skift platform" at the far right */
.sheet-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: auto; padding-top: 6px; border-top: 1px solid var(--border-3); }
.sheet-logout { color: var(--danger); width: auto; padding-top: 16px; }
.sheet-switch { display: flex; align-items: center; gap: 8px; padding: 9px 13px; margin-top: 6px; border-radius: 12px; cursor: pointer; white-space: nowrap;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--accent); background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); }
.menu .menu-switch { margin-top: 6px; border-top: 1px solid var(--border-2); border-radius: 0 0 10px 10px; padding-top: 12px; }
.userchip .who .n { font-size: 13px; font-weight: 700; }
.userchip .who .t { font-size: 11px; color: var(--muted-2); }
.menu { position: absolute; top: calc(100% + 8px); right: 0; width: 236px; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 15px; padding: 7px; box-shadow: var(--shadow); z-index: 50; }
.menu button, .menu a { display: flex; align-items: center; gap: 11px; width: 100%; padding: 11px 12px; border: none;
  background: none; color: var(--text); font-size: 14px; font-weight: 600; text-align: left; border-radius: 10px; cursor: pointer; }
.menu button:hover, .menu a:hover { background: color-mix(in srgb, var(--accent) 12%, transparent); }
.menu .sep { height: 1px; background: var(--border-2); margin: 6px 4px; }
.menu .danger { color: var(--danger); }

/* ---- Layout main ---- */
main { padding: 26px 30px 48px; max-width: none; width: 100%; }
.page-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; margin-bottom: 22px; }
.h1 { font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.h1-lg { font-size: 30px; }
.sub { color: var(--muted-2); font-size: 13.5px; margin-top: 2px; }

/* ---- Avatar ---- */
.av { border-radius: 12px; color: #141414; display: flex; align-items: center; justify-content: center;
  font-weight: 800; overflow: hidden; flex-shrink: 0; background-size: cover; background-position: center; }
.av img { width: 100%; height: 100%; object-fit: cover; }

/* ---- Cards & grids ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px 24px; }
.card.tight { padding: 20px 22px; }
.card.hero { background: var(--hero); border-color: var(--hero-border); }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.mb16 { margin-bottom: 16px; }
.mb24 { margin-bottom: 24px; }

.kpi-label { font-size: 13px; font-weight: 600; color: var(--muted); }
.card.hero .kpi-label { color: color-mix(in srgb, var(--accent) 55%, white); }
:root[data-theme="light"] .card.hero .kpi-label { color: var(--accent-2); }
.kpi-value { font-size: 34px; font-weight: 800; letter-spacing: -.02em; margin-top: 12px; }
.kpi-value .unit { font-size: 18px; color: var(--muted); font-weight: 600; }
.kpi-foot { color: var(--muted-2); font-size: 12.5px; margin-top: 8px; }
.kpi-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 22px; }
.kpi-pct { flex: none; font-size: 11.5px; font-weight: 700; padding: 3px 8px; border-radius: 20px; white-space: nowrap;
  color: var(--muted); background: var(--surface-3); }
.kpi-pct.up { color: var(--good); background: color-mix(in srgb, var(--good) 14%, transparent); }
.kpi-pct.down { color: var(--danger); background: color-mix(in srgb, var(--danger) 14%, transparent); }
.kpi-rows { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; }
.kpi-rows > div { display: flex; justify-content: space-between; gap: 10px; }
.kpi-rows span { color: var(--muted); }
.kpi-rows b { font-weight: 700; color: var(--text-2); white-space: nowrap; }
.kpi-rows b.miss { color: var(--danger); }
.kpi-pct[data-cmp] { cursor: help; }
.kpi-pct[data-cmp]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cmp-tip { position: fixed; z-index: 200; min-width: 220px; max-width: calc(100vw - 16px); padding: 10px 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow); font-size: 12.5px;
  opacity: 0; pointer-events: none; transform: translateY(-3px); transition: opacity .12s, transform .12s; }
.cmp-tip.on { opacity: 1; transform: none; }
.cmp-tip .r { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
.cmp-tip .r + .r { margin-top: 4px; }
.cmp-tip .r b { color: var(--text-2); font-weight: 700; white-space: nowrap; }
.cmp-tip .r.now span { color: var(--text); font-weight: 600; }
.cmp-tip .r.now b { color: var(--text); }
.cmp-tip .basis { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--border); color: var(--muted-2); font-size: 11.5px; }
.card.hero .kpi-rows { border-top-color: var(--hero-border); }
.card-title { font-weight: 700; font-size: 16px; }

/* ---- Buttons ---- */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 12px;
  border: 1px solid var(--border-2); background: var(--surface-3); color: var(--text-2); font-weight: 600;
  font-size: 14px; cursor: pointer; transition: filter .15s, border-color .15s; }
.btn:hover { border-color: var(--muted-3); }
.btn-accent { border: none; background: var(--accent-grad); color: #fff; font-weight: 700;
  box-shadow: 0 8px 20px -8px color-mix(in srgb, var(--accent) 70%, transparent); }
.btn-accent:hover { filter: brightness(1.06); }
.btn-good { border: none; background: var(--good); color: #08150f; font-weight: 700; }
.btn-danger { border: 1px solid color-mix(in srgb, var(--danger) 40%, transparent);
  background: color-mix(in srgb, var(--danger) 8%, transparent); color: var(--danger); font-weight: 600; }
.btn-sm { padding: 9px 14px; font-size: 13px; border-radius: 11px; }
.btn-lg { padding: 13px 26px; font-size: 15px; border-radius: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.iconbtn { width: 40px; height: 40px; border-radius: 12px; background: var(--surface-3);
  border: 1px solid var(--border); color: var(--text-2); font-size: 17px; cursor: pointer; }

/* ---- Forms ---- */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 7px; font-weight: 600; }
.req { color: var(--accent); }
.input, .textarea {
  width: 100%; background: var(--field); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 12px 14px; color: var(--text); font-size: 14px; outline: none; transition: border-color .15s;
}
.input:focus, .textarea:focus { border-color: var(--accent); }
.textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.input-affix { display: flex; align-items: center; background: var(--field); border: 1px solid var(--border-2);
  border-radius: 12px; padding: 0 14px; }
.input-affix input { flex: 1; width: 0; background: none; border: none; padding: 12px 0; color: var(--text); font-size: 14px; outline: none; min-width: 0; }
.input-affix .affix { color: var(--muted); font-size: 14px; }
.addr-wrap .input-affix { gap: 10px; } /* search icon not glued to the text */
.card > .addr-wrap.field:last-child { margin-bottom: 0; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 6px; }
/* Shared /login: a message sent along by the platforms (?m=…) */
.login-notice { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 16px; padding: 10px 12px; border-radius: 12px; font-size: 13px; line-height: 1.4;
  color: var(--text-2); background: var(--surface-3); border: 1px solid var(--border-2); }
.login-notice svg { flex: none; margin-top: 1px; }
.login-notice.success svg { color: var(--good); }
.login-notice.info svg { color: var(--accent); }
.login-notice.error { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }

/* iOS-style wheel date picker */
.dwp { width: 100%; }
.dwp-field {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--field); border: 1px solid var(--border-2); border-radius: 12px;
  padding: 12px 14px; color: var(--text); font-size: 14px; cursor: pointer; text-align: left;
}
.dwp-field:hover { border-color: var(--muted-3); }
.dwp-display.is-empty { color: var(--muted-3); }
.dwp-caret { color: var(--muted-2); font-size: 12px; }

.dwp-backdrop {
  position: fixed; inset: 0; background: rgba(8, 8, 11, .55); backdrop-filter: blur(3px);
  z-index: 80; display: flex; align-items: flex-end; justify-content: center;
}
.dwp-sheet {
  width: 100%; max-width: 520px; background: var(--surface);
  border-radius: 20px 20px 0 0; border: 1px solid var(--border-2); border-bottom: none;
  padding: 6px 12px calc(14px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -20px 40px -12px rgba(0, 0, 0, .5); animation: dwpUp .22s ease;
}
@keyframes dwpUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.dwp-sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 6px; border-bottom: 1px solid var(--border-3);
}
.dwp-sheet-title { font-size: 15px; font-weight: 700; color: var(--text-2); }
.dwp-sheet-title .val { color: var(--accent); margin-left: 10px; font-weight: 800; }
.dwp-done { background: none; border: none; color: var(--accent); font-weight: 800; font-size: 16px; cursor: pointer; padding: 6px 8px; }
.dwp-wheels { position: relative; display: flex; padding: 8px 0 4px; }
.dwp-col {
  flex: 1; height: 220px; overflow-y: scroll; scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch; touch-action: pan-y; text-align: center; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 26%, #000 74%, transparent);
          mask-image: linear-gradient(180deg, transparent, #000 26%, #000 74%, transparent);
}
.dwp-col::-webkit-scrollbar { display: none; }
.dwp-col[data-col="month"] { flex: 1.6; }
.dwp-col[data-col="day"] { flex: .8; }
.dwp-item {
  height: 40px; line-height: 40px; scroll-snap-align: center; font-size: 21px; color: var(--muted-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px;
}
.dwp-item.sel { color: var(--text); font-weight: 700; }
.dwp-pad { height: 90px; }
.dwp-highlight {
  position: absolute; left: 6px; right: 6px; top: 50%; transform: translateY(-50%);
  height: 40px; border-top: 1px solid var(--border-2); border-bottom: 1px solid var(--border-2);
  background: color-mix(in srgb, var(--accent) 6%, transparent); pointer-events: none; border-radius: 8px;
}

/* ---- Chips / badges ---- */
.chip { font-size: 12px; font-weight: 600; padding: 5px 11px; border-radius: 20px; width: fit-content; }
.pill-toggle { display: flex; gap: 4px; background: var(--surface-3); border: 1px solid var(--border); border-radius: 11px; padding: 3px; }
.pill-toggle button { padding: 8px 14px; border: none; border-radius: 8px; background: none; color: var(--muted);
  font-weight: 600; font-size: 13px; cursor: pointer; }
.pill-toggle button.on { background: color-mix(in srgb, var(--accent) 90%, black); color: #fff; font-weight: 700; }

/* ---- Lists / rows ---- */
.row { display: flex; align-items: center; gap: 13px; padding: 11px 0; border-bottom: 1px solid var(--border-3); }
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-size: 14px; font-weight: 700; }
.row .meta { font-size: 12px; color: var(--muted-2); }
.hoverrow { cursor: pointer; border-radius: 10px; transition: background .12s; }
.hoverrow:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

.lender-card { cursor: pointer; transition: border-color .15s; display: block; color: inherit; }
.lender-card:hover { border-color: var(--muted-3); }
.ministat { flex: 1; background: var(--field); border-radius: 12px; padding: 10px 12px; }
.ministat .l { font-size: 11px; color: var(--muted-2); }
.ministat .v { font-size: 15px; font-weight: 700; margin-top: 2px; }

/* ---- Table (loans) ---- */
.table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table .thead, .table .trow { display: grid; grid-template-columns: 1.6fr 1fr 1fr 1fr .9fr; align-items: center; padding: 14px 22px; }
.table .thead { border-bottom: 1px solid var(--border-3); font-size: 12px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }
.table .trow { border-bottom: 1px solid var(--border-3); cursor: pointer; }
.table .trow:last-child { border-bottom: none; }
.table .trow:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }

/* Dashboard KPI row: grid on desktop, snap carousel on mobile (see media query) */
.kpi-snap { margin-bottom: 16px; }
.kpi-dots { display: none; }

/* Dashboard: per-lender lånt / tilbage / næste betaling */
.debts-head, .debts-row { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1.3fr; align-items: center; gap: 12px; }
.debts-head { padding: 6px 6px 10px; border-bottom: 1px solid var(--border-3); font-size: 12px; color: var(--muted-2); text-transform: uppercase; letter-spacing: .05em; }
.debts-head span:not(:first-child) { text-align: right; }
.debts-row { padding: 12px 6px; border-bottom: 1px solid var(--border-3); text-decoration: none; color: inherit; border-radius: 10px; }
.debts-row:last-child { border-bottom: none; }
.debts-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.debts-row .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.debts-row .title { font-size: 14px; font-weight: 700; }
.debts-row .meta { font-size: 12px; color: var(--muted-2); }
.debts-row .cell { display: flex; flex-direction: column; align-items: flex-end; text-align: right; }
.debts-row .only-mob { display: none; }

/* Responsive helpers: show only on desktop / only on mobile (≤900px) */
.only-mob { display: none !important; }

/* Opret lån, step 4: payment mode cards */
.mode-opts { display: flex; gap: 10px; margin-bottom: 20px; flex-wrap: wrap; }
.plan-opt { flex: 1 1 180px; display: flex; align-items: flex-start; gap: 12px; text-align: left; padding: 14px 16px; border-radius: 14px; cursor: pointer; color: var(--text);
  font: inherit; border: 1px solid var(--border-2); background: var(--field); transition: border-color .12s, background .12s; }
.plan-opt[hidden] { display: none; }
.mode-opts.stacked { flex-direction: column; margin-bottom: 0; }
/* Mails: switches in settings, per-låntager choices on the edit page */
.mail-switches { display: flex; flex-direction: column; gap: 8px; }
.mail-prefs { display: flex; flex-direction: column; }
.mail-pref { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; padding: 12px 0; }
.mail-pref + .mail-pref { border-top: 1px solid var(--border); }
.mail-pref-text { flex: 1 1 220px; min-width: 0; }
.mail-pref-text b { display: block; font-size: 14px; }
.mail-pref-text small { display: block; font-size: 12.5px; color: var(--muted-2); margin-top: 2px; }
.mail-noemail { display: flex; align-items: flex-start; gap: 8px; margin-bottom: 10px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px;
  color: #f5b544; background: rgba(245, 181, 68, .1); border: 1px solid rgba(245, 181, 68, .28); }
.mail-noemail svg { flex: none; margin-top: 1px; }
.seg3 { display: flex; gap: 3px; padding: 3px; border-radius: 11px; background: var(--surface-3); border: 1px solid var(--border); }
.seg3 label { cursor: pointer; }
.seg3 input { position: absolute; opacity: 0; pointer-events: none; }
.seg3 span { display: block; padding: 7px 11px; border-radius: 8px; font-size: 12.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg3 span small { font-weight: 500; opacity: .8; }
.seg3 input:checked + span { background: color-mix(in srgb, var(--accent) 90%, black); color: #fff; }
.seg3 input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Låntager edit page: autosave status */
.save-status { display: flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 9px 12px; border-radius: 12px;
  font-size: 13px; font-weight: 600; color: var(--muted); background: var(--surface-3); border: 1px solid var(--border); transition: color .15s, background .15s; }
.save-status svg { flex: none; }
.save-status.saved { color: var(--good); background: color-mix(in srgb, var(--good) 10%, transparent); border-color: color-mix(in srgb, var(--good) 25%, transparent); }
.save-status.error { color: var(--danger); background: color-mix(in srgb, var(--danger) 10%, transparent); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.save-spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: save-spin .7s linear infinite; }
@keyframes save-spin { to { transform: rotate(360deg); } }
.mode-opts.stacked .plan-opt { flex: none; }
.plan-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.plan-opt .t { font-size: 15px; font-weight: 700; }
.plan-opt .d { font-size: 12.5px; color: var(--muted-2); margin-top: 3px; line-height: 1.4; }
.plan-opt .tx { display: block; min-width: 0; }
.plan-opt .ic { flex: none; width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  color: var(--muted); background: var(--surface-3); border: 1px solid var(--border); transition: color .12s, background .12s; }
.plan-opt.on .ic { color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); border-color: transparent; }

/* Lån list rows (desktop uses the .table grid; mobile layout in media query) */
.loan-row .who { display: flex; align-items: center; gap: 12px; min-width: 0; }
.loan-row .name { font-size: 14px; font-weight: 700; }
.loan-row .meta { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.loan-row .right { text-align: right; }
.loan-row .amt { font-size: 15px; font-weight: 800; white-space: nowrap; }
.loan-row .st { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; margin-top: 3px; white-space: nowrap; }
.loan-row .st .dot { width: 7px; height: 7px; }
.debts-row .nw { white-space: nowrap; }
.debts-row .cell .val { font-size: 14.5px; font-weight: 700; }
.debts-row .cell .sub2 { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }

/* ---- Charts ---- */
.donut { border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.donut .hole { border-radius: 50%; background: var(--surface); display: flex; flex-direction: column; align-items: center; justify-content: center; }
.legend { display: flex; flex-direction: column; gap: 14px; }
.legend .li { display: flex; align-items: center; gap: 10px; }
.dot { width: 9px; height: 9px; border-radius: 50%; }
.bars { display: flex; align-items: flex-end; gap: 12px; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.bars .pair { width: 100%; display: flex; gap: 3px; align-items: flex-end; justify-content: center; }
.bars .bar { border-radius: 5px 5px 0 0; }
.bars .lab { font-size: 11px; color: var(--muted-2); }
.progressbar { height: 9px; background: var(--field); border-radius: 20px; overflow: hidden; }
.progressbar > span { display: block; height: 100%; border-radius: 20px; }

/* ---- Wizard step indicator ---- */
.steps { display: flex; align-items: center; gap: 0; margin-bottom: 30px; }
.steps .seg { display: flex; align-items: center; flex: 1; }
.steps .node { display: flex; flex-direction: column; align-items: center; gap: 7px; }
.steps .dot-num { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; background: var(--field); color: var(--muted); border: 1px solid var(--border-2); }
.steps .node.active .dot-num { background: var(--accent-grad); color: #fff; border-color: transparent; }
.steps .node.done .dot-num { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); border-color: var(--accent); }
.steps .lab { font-size: 11.5px; color: var(--muted-2); white-space: nowrap; }
.steps .node.active .lab { color: var(--text); }
.steps .line { flex: 1; height: 2px; background: var(--border-2); margin: 0 6px 22px; }
.steps .line.done { background: var(--accent); }
.wizard-body { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; min-height: 300px; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 22px; }
.step-title { font-size: 19px; font-weight: 800; margin-bottom: 4px; }
.step-sub { color: var(--muted-2); font-size: 13.5px; margin-bottom: 20px; }

/* ---- Modals ---- */
.overlay { position: fixed; inset: 0; background: rgba(8, 8, 11, .66); backdrop-filter: blur(4px); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { width: 460px; max-width: 100%; background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); max-height: 92vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 19px; font-weight: 800; }
.closex { width: 32px; height: 32px; border-radius: 10px; background: var(--surface-3); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 14px; }
[hidden] { display: none !important; }

/* ---- Address autocomplete ---- */
.addr-wrap { position: relative; }
.addr-list { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--surface);
  border: 1px solid var(--border-2); border-radius: 13px; padding: 6px; box-shadow: var(--shadow); z-index: 40;
  max-height: 260px; overflow-y: auto; }
.addr-list button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: none;
  background: none; color: var(--text-2); font-size: 13.5px; text-align: left; border-radius: 9px; cursor: pointer; }
.addr-list button:hover, .addr-list button.active { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.addr-pin { color: var(--accent); display: flex; flex: none; }
.addr-txt { min-width: 0; }
.addr-txt b { display: block; color: var(--text); font-weight: 700; }
.addr-txt small { display: block; color: var(--muted-2); font-size: 12.5px; margin-top: 1px; }
.addr-note { padding: 10px 12px; font-size: 13px; color: var(--muted); }
.addr-note.err { color: var(--danger); }
.addr-data .kv .v { text-align: right; overflow-wrap: anywhere; }

/* ---- Toast ---- */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 90;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: 14px; padding: 13px 20px;
  box-shadow: var(--shadow); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 10px;
  animation: toastin .25s ease; }
.toast.error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.toast .tico { font-size: 16px; }
.toast.success .tico { color: var(--good); }
.toast.error .tico { color: var(--danger); }
.toast.info .tico { color: var(--accent); }
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 12px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---- Empty states ---- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted-2); }
.empty .big { font-size: 40px; margin-bottom: 12px; }
.empty .t { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }

/* ---- Auth ---- */
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px; }
.auth-card { width: 420px; max-width: 100%; }
.auth-brand { display: flex; align-items: center; gap: 11px; justify-content: center; margin-bottom: 26px; }
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 8px 0; border-bottom: 1px solid var(--border-3); }
.kv:last-child { border-bottom: none; }
.kv .k { font-size: 13px; color: var(--muted); flex-shrink: 0; }
.kv .v { font-size: 13px; font-weight: 600; text-align: right; min-width: 0; overflow-wrap: anywhere; }
/* "fra → til" values never break inside; on very narrow screens the whole
   value drops below its label instead. */
.kv-range { flex-wrap: wrap; row-gap: 2px; }
.kv-range .v { white-space: nowrap; overflow-wrap: normal; margin-left: auto; }
.range-arrow { display: inline-flex; vertical-align: -2px; color: var(--muted-2); margin: 0 2px; }

/* Settings rail */
.settings { display: grid; grid-template-columns: 220px 1fr; gap: 20px; align-items: start; }
.settings-rail { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 92px; }
.settings-rail a { display: flex; align-items: center; gap: 10px; padding: 11px 13px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer; }
.settings-rail a:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text); }
.settings-rail a.active { background: color-mix(in srgb, var(--accent) 16%, var(--surface-3)); color: var(--text); font-weight: 700; }
.swatch { display: flex; flex-direction: column; align-items: center; gap: 8px; background: none; border: none; cursor: pointer; }
.swatch .sw { width: 46px; height: 46px; border-radius: 14px; }
.swatch .nm { font-size: 12px; color: var(--muted); }

/* Settings on mobile, iOS-style: sections → sub-pages → page (desktop keeps the rail) */
.settings-mhead, .settings-mlist { display: none; }
.set-group { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-bottom: 18px; }
.set-row { display: flex; align-items: center; gap: 13px; padding: 12px 14px; color: var(--text); font-size: 15px; font-weight: 600; text-decoration: none; position: relative; }
.set-row + .set-row::before { content: ''; position: absolute; top: 0; left: 59px; right: 0; height: 1px; background: var(--border); }
.set-row:active { background: var(--surface-3); }
.set-ico { flex: none; width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; }
.set-label { flex: 1; min-width: 0; }
.set-row:not(.set-profile) .set-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.set-label b { display: block; font-size: 17px; font-weight: 800; }
.set-label small { display: block; font-size: 13px; font-weight: 500; color: var(--muted-2); margin-top: 2px; overflow-wrap: anywhere; }
.set-val { color: var(--muted-2); font-weight: 500; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 45%; }
.set-row > svg:last-child { flex: none; color: var(--muted-3); }
.set-profile { padding: 14px; }
.set-profile + .set-row::before { left: 14px; }
.set-row.danger .set-label { color: var(--danger); }
.settings-back { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 600; color: var(--accent); margin-bottom: 8px; }
@media (max-width: 900px) {
  .settings-page:not(.is-root) .settings-head { display: none; }
  .settings-mhead { display: block; margin-bottom: 18px; }
  .settings-mlist { display: block; }
  .settings-rail { display: none !important; }
  .settings.is-root, .settings.is-subs { display: none; }
  .settings-body > .m-off { display: none; }
  /* Låntager edit, iOS-style: list of sections, then one section per page */
  .lender-edit.is-root #lenderEdit { display: none; }
  .lender-edit:not(.is-root) .page-head { display: none; }
  .lender-edit .m-off, .lender-edit .edit-actions { display: none !important; }
  /* the page heading names the section; a second card on the page (keep-title) keeps its own */
  .lender-edit:not(.is-root) .card:not(.keep-title) > .form-sec-head .form-sec-ico, .lender-edit:not(.is-root) .card:not(.keep-title) > .form-sec-head .card-title { display: none; }
  /* the page heading already names the page */
  .settings-body.one-card > .card > .card-title:first-child { display: none; }
}
/* ---- Edit forms: sections with an icon header + sticky profile side ---- */
.form-sec-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.form-sec-ico { width: 36px; height: 36px; border-radius: 11px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  color: var(--accent); background: var(--accent-soft); }
.form-grid3 { gap: 14px; }
.edit-profile { display: flex; flex-direction: column; align-items: center; text-align: center; }
.edit-profile-name { font-size: 18px; font-weight: 800; margin-top: 12px; overflow-wrap: anywhere; }
.edit-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-3); }
.danger-card { border-color: color-mix(in srgb, var(--danger) 25%, var(--border)); background: color-mix(in srgb, var(--danger) 4%, var(--surface)); }
@media (min-width: 901px) and (max-width: 1250px) {
  .form-grid3 { grid-template-columns: 1fr 1fr; }
}

/* ---- Profile photo (settings) ---- */
.photo-row { display: flex; align-items: center; gap: 18px; }
.photo-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.settings-rail a svg { flex-shrink: 0; }

/* ---- Låntager-portal (platform/laantager) ---- */
.portal-top { position: sticky; top: 0; z-index: 30; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); }
.portal-top-in { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 30px; }
.portal-top .brand { padding: 0; }
.portal-nav { display: flex; align-items: center; gap: 8px; }
.portal-badge { width: fit-content; margin: -14px auto 18px; padding: 4px 11px; border-radius: 20px; font-size: 12px; font-weight: 700;
  color: var(--accent); background: var(--accent-soft); letter-spacing: .02em; }
@media (max-width: 900px) {
  .portal-top-in { padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; }
  .portal-nav .btn { padding: 9px 11px; }
  .grid3.portal-kpis { grid-template-columns: 1fr 1fr !important; }
  .grid3.portal-kpis > .hero { grid-column: 1 / -1; }
  .grid3.portal-kpis > .card:not(.hero) .kpi-value { font-size: 21px !important; white-space: nowrap; }
  .portal-split > .side { order: -1; } /* "Næste betaling" first on phones */
}

/* ---- Switch (checkbox styled as a toggle) ---- */
.switch-row { display: flex; align-items: flex-start; gap: 13px; cursor: pointer; padding: 14px 16px; border-radius: 14px;
  border: 1px solid var(--border-2); background: var(--field); }
.switch-row input { position: absolute; opacity: 0; pointer-events: none; }
.switch { flex-shrink: 0; position: relative; width: 42px; height: 24px; border-radius: 12px; background: var(--border-2); transition: background .2s; margin-top: 1px; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch-text { display: flex; flex-direction: column; gap: 3px; }
.switch-text b { font-size: 14px; }
.switch-text small { font-size: 12.5px; color: var(--muted-2); line-height: 1.45; }
.invite-link { display: flex; gap: 8px; }
.portal-mismatch { margin: 10px 0 4px; padding: 10px 12px; border-radius: 12px; font-size: 12.5px; line-height: 1.45; color: #f5b544;
  background: rgba(245, 181, 68, .1); border: 1px solid rgba(245, 181, 68, .28); }
.portal-mismatch svg { vertical-align: -3px; }
.invite-link .input { font-size: 12.5px; padding-top: 9px; padding-bottom: 9px; min-width: 0; }
.btn-copy { flex: none; width: 40px; padding: 0; justify-content: center; }
.btn-copy.copied { background: #34d399; border-color: #34d399; color: #0b1f17; }

/* ---- Full-width desktop layouts ----
   .page-split: main column + sticky side panel (summary, preview, actions).
   .card-grid / .settings-body: cards side by side, as many as fit. */
.page-split { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.page-split > .side { position: sticky; top: 24px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-grid, .settings-body { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr)); gap: 16px; align-items: start; }
.card-grid > .card, .settings-body > .card { margin-bottom: 0; }
.card-grid > .span-all { grid-column: 1 / -1; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr)); gap: 10px; }
.pick-grid > .btn { grid-column: 1 / -1; }
.preview-head { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.preview-head .n { font-size: 17px; font-weight: 800; overflow-wrap: anywhere; }
.preview-head .s { font-size: 12.5px; color: var(--muted-2); }

/* ---- Feedback / tickets ---- */
.nav-badge { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; }
.sheet-list .nav-badge { margin-left: 0; flex: 0 0 auto; }
.bottomnav .ico { position: relative; }
.nav-dot { position: absolute; top: -2px; right: -4px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface); }
.pill-toggle a { padding: 8px 14px; border-radius: 8px; color: var(--muted); font-weight: 600; font-size: 13px; white-space: nowrap; }
.pill-toggle a.on { background: color-mix(in srgb, var(--accent) 90%, black); color: #fff; font-weight: 700; }
.pill-toggle a .n { opacity: .7; font-weight: 600; margin-left: 2px; }
.tk-ico { width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center;
  color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 14%, transparent); }
.tk-types { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.tk-type { display: flex; flex-direction: column; gap: 6px; color: inherit; transition: border-color .15s, transform .15s; }
.tk-type:hover { border-color: var(--c, var(--muted-3)); transform: translateY(-1px); }
.tk-type .tk-ico { margin-bottom: 8px; }
.tk-type .t { font-weight: 800; font-size: 15.5px; }
.tk-type .d { font-size: 13px; color: var(--muted-2); }
.tk-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.tk-search { flex: 1 1 220px; display: flex; align-items: center; gap: 8px; background: var(--field); border: 1px solid var(--border-2);
  border-radius: 12px; padding: 0 12px; color: var(--muted-2); }
.tk-search:focus-within { border-color: var(--accent); }
.tk-search input { flex: 1; width: 0; min-width: 0; background: none; border: none; outline: none; color: var(--text); font-size: 14px; padding: 10px 0; }
.tk-filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.tk-filter { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  color: var(--muted); border: 1px solid var(--border-2); }
.tk-filter svg { color: var(--c, currentColor); }
.tk-filter:hover { color: var(--text); }
.tk-filter.on { color: var(--text); border-color: var(--c, var(--accent)); background: color-mix(in srgb, var(--c, var(--accent)) 12%, transparent); }
.tk-list { padding: 6px 10px; }
.tk-row { display: flex; align-items: center; gap: 13px; padding: 12px 10px; border-bottom: 1px solid var(--border-3); color: inherit; border-radius: 12px; }
.tk-row:last-child { border-bottom: none; }
.tk-row:hover { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.tk-row .grow { flex: 1; min-width: 0; }
.tk-row .title { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-row.unread .title { font-weight: 800; }
.tk-row .meta { font-size: 12px; color: var(--muted-2); margin-top: 3px; }
.tk-unread { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 7px; vertical-align: 1px; }
.tk-chips { display: flex; gap: 6px; flex-shrink: 0; }
.tk-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tk-opt { display: flex; align-items: center; gap: 10px; padding: 11px 12px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border-2); background: var(--field); transition: border-color .12s, background .12s; }
.tk-opt input { position: absolute; opacity: 0; pointer-events: none; }
.tk-opt .tk-ico { width: 32px; height: 32px; border-radius: 9px; }
.tk-opt .t { font-weight: 700; font-size: 14px; }
.tk-opt:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, transparent); }
.tk-opt:has(input:focus-visible) { outline: 2px solid var(--c); outline-offset: 2px; }
.tk-attach { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.tk-thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.tk-thumbs:empty { display: none; }
.tk-thumbs img { width: 76px; height: 76px; object-fit: cover; border-radius: 10px; border: 1px solid var(--border-2); display: block; }
.tk-thread .tk-thumbs { margin-top: 10px; }
.tk-body-input { min-height: 280px; }
.tk-context { font-size: 12.5px; color: var(--muted); background: var(--field); border: 1px solid var(--border-3); border-radius: 12px; padding: 10px 12px; }
.tk-h1 { font-size: 24px; overflow-wrap: anywhere; }
.tk-headchips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.tk-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 24px; }
.tk-side-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tk-thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.tk-msg { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; }
.tk-msg.staff { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.tk-msg.internal { border-style: dashed; border-color: color-mix(in srgb, #f5b544 50%, var(--border)); background: color-mix(in srgb, #f5b544 5%, var(--surface)); }
.tk-msg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.tk-msg-head > span:last-child { margin-left: auto; font-weight: 500; color: var(--muted-2); font-size: 12px; }
.tk-staff { font-size: 10.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--accent);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 6px; }
.tk-internal { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; color: #f5b544; }
.tk-body { font-size: 14px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere; color: var(--text-2); }
.tk-event { text-align: center; font-size: 12px; color: var(--muted-2); padding: 2px 0; }
.tk-event b { color: var(--muted); font-weight: 700; }
.tk-event svg { vertical-align: -1px; }
.tk-reply { padding: 18px; }
.tk-reply-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tk-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; font-weight: 600; }
.tk-status-pick { width: auto; padding-top: 8px; padding-bottom: 8px; font-size: 13px; }
@media (max-width: 900px) {
  .tk-types, .tk-pick { grid-template-columns: 1fr; }
  .tk-layout { grid-template-columns: 1fr; }
  .page-split { grid-template-columns: 1fr; }
  .page-split > .side { position: static; }
  .tk-body-input { min-height: 140px; }
  .tk-side { position: static; }
  .tk-row { padding: 12px 4px; }
  .tk-row .tk-ico { width: 34px; height: 34px; }
  .tk-chips .chip { padding: 4px 9px; font-size: 11.5px; }
  .tk-bar .pill-toggle { width: 100%; }
  .tk-bar .pill-toggle a { flex: 1; text-align: center; }
}

/* ---- Responsive ---- */
@media (max-width: 1150px) and (min-width: 901px) {
  .grid4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { display: none; }
  .bottomnav { display: flex; }
  .shell { padding-left: 0; padding-bottom: 81px; }
  main { padding: calc(20px + env(safe-area-inset-top, 0px)) 16px 40px; }
  .grid4, .grid3, .grid2, .mainrow, .settings { grid-template-columns: minmax(0, 1fr) !important; }
  .settings-rail { flex-direction: row; overflow-x: auto; padding-bottom: 4px; position: static; }
  .settings-rail a { white-space: nowrap; }
  .table .thead { display: none; }
  .table .trow { grid-template-columns: 1fr auto; row-gap: 4px; }
  .grid3.kpi-snap { display: flex; position: relative; gap: 12px; overflow-x: auto; scroll-snap-type: x mandatory;
    margin: 0 -16px 10px; padding: 0 16px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .kpi-snap::-webkit-scrollbar { display: none; }
  .kpi-snap > .card { flex: 0 0 82%; scroll-snap-align: center; padding: 18px 20px; }
  .kpi-snap .kpi-value { font-size: 28px; margin-top: 8px; }
  .kpi-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 16px; }
  .kpi-dots span { width: 6px; height: 6px; border-radius: 3px; background: var(--border-2); transition: width .2s, background .2s; }
  .kpi-dots span.on { width: 18px; background: var(--accent); }
  .debts-head { display: none; }
  /* Mobile: two columns — who + "lånt · tilbage" | next payment */
  .debts-row { grid-template-columns: 1fr auto; column-gap: 10px; padding: 12px 4px; }
  .debts-row .only-desk { display: none; }
  .debts-row .only-mob { display: block; }
  .debts-row .val .only-mob { display: inline; }
  .debts-row .who .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .debts-row .cell .val { font-size: 15px; white-space: nowrap; }
  .h1-lg { font-size: 24px; }
  .only-desk { display: none !important; }
  .only-mob { display: revert !important; }
  /* Toasts sit above the bottom nav instead of on top of it */
  .toast { bottom: calc(83px + env(safe-area-inset-bottom, 0px)); max-width: calc(100% - 32px); }
  /* No scrollbars on mobile: they eat width and offset the layout */
  html, body, * { scrollbar-width: none; }
  ::-webkit-scrollbar { display: none; width: 0; height: 0; }
  /* Long names in plain list rows get an ellipsis instead of wrapping */
  .row .grow .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  /* Never let content push the page sideways on small phones */
  .bottomnav a, .bottomnav button { min-width: 0; }
  .bottomnav a span, .bottomnav button span { white-space: nowrap; }
  .bottomnav .fab { flex: 0 0 52px; }
  .overlay > .modal { min-width: 0; }
  .range-toggle { width: 100%; overflow-x: auto; scrollbar-width: none; }
  .range-toggle::-webkit-scrollbar { display: none; }
  .range-toggle .btn { flex: 1 0 auto; justify-content: center; padding-left: 10px; padding-right: 10px; white-space: nowrap; }
  /* Lån list: two columns — who + "af X · forfald" | remaining + status */
  .table .trow.loan-row { grid-template-columns: 1fr auto; column-gap: 12px; padding: 13px 16px; }
  .loan-row .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
.mainrow { display: grid; gap: 16px; }
/* Grid/flex children may shrink below their content's width; long unbroken
   strings (emails, links) then wrap instead of stretching the whole column. */
.grid2 > *, .grid3 > *, .grid4 > *, .mainrow > *, .stack > * { min-width: 0; }
.card { overflow-wrap: break-word; }

/* ---- Motion: app-like page transitions + quick entrance animations ---- */
/* Cross-document View Transitions (Chrome/Edge 126+, Safari 18.2+); other
   browsers simply navigate as before. Nav chrome stays put, the page slides. */
@view-transition { navigation: auto; }
.sidebar { view-transition-name: sidebar; }
.bottomnav { view-transition-name: bottomnav; }
main { view-transition-name: page; }
::view-transition-group(root) { animation-duration: .16s; }
::view-transition-group(sidebar), ::view-transition-group(bottomnav),
::view-transition-old(sidebar), ::view-transition-new(sidebar),
::view-transition-old(bottomnav), ::view-transition-new(bottomnav) { animation: none; }
::view-transition-group(page) { animation: none; }
::view-transition-old(page) { animation: page-out .12s ease-in both; }
::view-transition-new(page) { animation: page-in .2s cubic-bezier(.2, .8, .2, 1) both; }
html:active-view-transition-type(back)::view-transition-old(page) { animation-name: page-out-back; }
html:active-view-transition-type(back)::view-transition-new(page) { animation-name: page-in-back; }
@keyframes page-out      { to   { opacity: 0; transform: translateX(-14px); } }
@keyframes page-in       { from { opacity: 0; transform: translateX(22px); } }
@keyframes page-out-back { to   { opacity: 0; transform: translateX(14px); } }
@keyframes page-in-back  { from { opacity: 0; transform: translateX(-22px); } }

/* Content entrance: top-level blocks and list rows rise in, lightly staggered */
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
main > * { animation: rise .26s cubic-bezier(.2, .8, .2, 1) backwards; }
main > :nth-child(2) { animation-delay: .03s; }
main > :nth-child(3) { animation-delay: .06s; }
main > :nth-child(4) { animation-delay: .09s; }
main > :nth-child(n+5) { animation-delay: .12s; }
.debts-row, .lender-card, .table .trow, .kpi-snap > .card { animation: rise .26s cubic-bezier(.2, .8, .2, 1) backwards; }
.debts-row:nth-child(2), .lender-card:nth-child(2), .table .trow:nth-child(2), .kpi-snap > .card:nth-child(2) { animation-delay: .04s; }
.debts-row:nth-child(3), .lender-card:nth-child(3), .table .trow:nth-child(3), .kpi-snap > .card:nth-child(3) { animation-delay: .07s; }
.debts-row:nth-child(4), .lender-card:nth-child(4), .table .trow:nth-child(4) { animation-delay: .1s; }
.debts-row:nth-child(n+5), .lender-card:nth-child(n+5), .table .trow:nth-child(n+5) { animation-delay: .12s; }

/* Modals fade in, their panel pops slightly */
@keyframes fade-in { from { opacity: 0; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.overlay:not([hidden]) { animation: fade-in .16s ease-out; }
.overlay:not([hidden]) > .modal { animation: pop-in .2s cubic-bezier(.2, .8, .2, 1); }
.menu:not([hidden]) { animation: pop-in .14s ease-out; }

/* Tactile press feedback */
.btn, .bottomnav a, .bottomnav button, .debts-row, .lender-card, .hoverrow, .sheet-list a, .sheet-list button {
  -webkit-tap-highlight-color: transparent; }
.btn:active, .debts-row:active, .lender-card:active, .hoverrow:active, .sheet-list a:active, .sheet-list button:active {
  transform: scale(.98); transition: transform .08s; }
.bottomnav a:active .ico, .bottomnav button:active .ico, .bottomnav .fab:active { transform: scale(.88); transition: transform .08s; }

@media (prefers-reduced-motion: reduce) {
  @view-transition { navigation: none; }
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation: none !important; transition: none !important; }
}

/* ---- In-app navigation (fetch + swap, see app.js router) ---- */
/* Leave: the page slides away the moment you tap. */
.shell.nav-leaving main { opacity: 0; transform: translateX(-16px); pointer-events: none;
  transition: opacity .12s ease-in, transform .12s ease-in; }
.shell.nav-leaving.nav-back main { transform: translateX(16px); }
/* Enter: the new page slides in (fill: backwards so nothing lingers afterwards). */
.shell.nav-enter main { animation: page-in .22s cubic-bezier(.2, .8, .2, 1) backwards; }
.shell.nav-enter-back main { animation: page-in-back .22s cubic-bezier(.2, .8, .2, 1) backwards; }

/* Loader: small accent spinner, centred in the content area */
.nav-loader { position: fixed; top: 50%; left: calc(50% + 124px); z-index: 25; width: 30px; height: 30px;
  margin: -15px 0 0 -15px; opacity: 0; transform: scale(.7); pointer-events: none;
  transition: opacity .12s, transform .12s; }
.nav-loader.on { opacity: 1; transform: none; }
.nav-loader span { display: block; width: 100%; height: 100%; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--accent) 22%, transparent); border-top-color: var(--accent);
  animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 900px) { .nav-loader { left: 50%; } }
@media (prefers-reduced-motion: reduce) { .nav-loader span { animation: spin 1.2s linear infinite !important; } }

/* No zoom (app feel): no double-tap zoom, and on touch screens inputs are
   16px so iOS doesn't auto-zoom when a field gets focus. Pinch is blocked
   by the viewport meta + nozoom.js. touch-action must be on every element:
   it does not reach into scroll containers (.sheet, modals), so on html
   alone the loan wizard still double-tap-zoomed. More specific rules (the
   date wheel's pan-y) still win. */
*, *::before, *::after { touch-action: manipulation; }
@media (pointer: coarse) {
  .input, .textarea, .input-affix input, select, textarea, input:not([type=checkbox]):not([type=radio]) { font-size: 16px; }
}

/* Styled confirm dialog (app.js confirmDialog) — sits above other modals */
.confirm-overlay { z-index: 80; }
.confirm-modal { width: 380px; text-align: center; padding-top: 26px; }
.confirm-ico { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 800; background: var(--accent-soft); color: var(--accent); }
.confirm-ico svg { width: 22px; height: 22px; }
.confirm-ico.danger { background: color-mix(in srgb, var(--danger) 14%, transparent); color: var(--danger); }
.confirm-msg { margin: 8px 0 22px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 10px; }
.confirm-actions .btn { flex: 1; justify-content: center; }
.btn-danger-solid { border: none; background: var(--danger); color: #1a0a0e; font-weight: 700; }
.btn-danger-solid:hover { filter: brightness(1.06); }

/* Install-app steps (iOS) */
.install-steps { display: flex; flex-direction: column; gap: 12px; margin: 6px 0 20px; }
.install-steps div { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--text-2); }
.install-steps b { width: 28px; height: 28px; flex: none; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; }

/* Language switcher (lang_switcher()) */
.lang-switch { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.lang-switch button { display: inline-flex; align-items: center; gap: 8px; font: inherit; font-size: 13px; font-weight: 600; padding: 8px 13px; border-radius: 10px; cursor: pointer;
  background: var(--field); border: 1px solid var(--border-2); color: var(--muted); }
.lang-switch button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--text); }
.lang-switch.compact { justify-content: center; margin-top: 22px; }
.lang-switch.compact button { background: none; border-color: transparent; padding: 6px 9px; font-size: 12.5px; }
.lang-switch.compact button.on { border-color: var(--border-2); }
.flag { flex: none; border-radius: 3px; box-shadow: 0 0 0 1px rgba(0, 0, 0, .18); }
.lang-switch button:not(.on) .flag { opacity: .85; }
/* Login pages: only the active language shows its name; the others are flags */
.lang-switch.compact button:not(.on) span { display: none; }
.lang-switch.compact button:not(.on) { padding: 6px; }


/* ---- Admin: see PayDay as another user ---- */
.imp-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; padding: 10px 14px; border-radius: 13px; background: rgba(239, 196, 92, .12); border: 1px solid rgba(239, 196, 92, .35); color: #efc45c; font-size: 13px; font-weight: 700; }
.imp-bar > span { display: inline-flex; align-items: center; gap: 8px; min-width: 0; overflow-wrap: anywhere; }
.imp-bar button { background: #efc45c; color: #1a1406; border: 0; border-radius: 9px; padding: 7px 12px; font: inherit; font-size: 12.5px; cursor: pointer; white-space: nowrap; }
.adm-search { position: relative; margin-bottom: 14px; }
.adm-search .ico { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); display: flex; pointer-events: none; }
.adm-search .input { padding-left: 38px; }
.adm-users .title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; overflow-wrap: anywhere; }
.adm-users .meta { overflow-wrap: anywhere; }
.adm-users .btn-sm { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.adm-chip { color: #efe4a1; background: rgba(239, 228, 161, .14); font-size: 11px; }
@media (max-width: 520px) { .adm-users .btn-sm span { display: none; } }
