:root {
  --navy: #0E1A2B;
  --navy-2: #1C3150;
  --orange: #FF7A1A;
  --orange-soft: rgba(255, 122, 26, .13);
  --bg: #F2F4F7;
  --card: #FFFFFF;
  --text: #111827;
  --muted: #6B7280;
  --line: #E5E7EB;
  --field: #F7F8FA;
  --green: #16A34A;
  --red: #DC2626;
  --yellow: #EAB308;
  --shadow: 0 2px 10px rgba(14, 26, 43, .07);
  --radius: 16px;
  --tabs-h: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E1A2B;
    --card: #1A273B;
    --text: #F3F4F6;
    --muted: #9AA5B5;
    --line: #2A3A52;
    --field: #22314A;
    --green: #34D399;
    --red: #F87171;
    --shadow: 0 2px 10px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--orange); }
.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.green { color: var(--green); }
.red { color: var(--red); }
.orange { color: var(--orange); }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Opstart */
.boot { position: fixed; inset: 0; background: var(--navy); display: grid; place-items: center; z-index: 50; }
.boot-logo { color: #fff; font-size: 34px; font-weight: 800; letter-spacing: -.5px; animation: pulse 1.4s ease-in-out infinite; }
.boot-logo span { color: var(--orange); }
@keyframes pulse { 50% { opacity: .55; } }

/* Login */
.login { min-height: 100vh; min-height: 100dvh; background: var(--navy); display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--card); border-radius: 22px; padding: 28px 22px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-logo img { width: 52px; height: 52px; border-radius: 13px; }
.login-logo .name { font-size: 26px; font-weight: 800; letter-spacing: -.5px; }
.login-logo .name b { color: var(--orange); }
.login-logo .tag { color: var(--muted); font-size: 14px; }
.login h2 { margin: 6px 0 14px; font-size: 20px; }
.login .links { display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 14px; flex-wrap: wrap; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--orange); font-weight: 600; }

/* Skal */
.shell { min-height: 100vh; min-height: 100dvh; }
.side { display: none; }
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 10; background: var(--navy); color: #fff; padding-top: env(safe-area-inset-top); }
.top-in { display: flex; align-items: center; gap: 8px; min-height: 56px; padding: 0 12px 0 16px; max-width: 980px; margin: 0 auto; }
.top h1 { font-size: 19px; margin: 0; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.2px; }
.top-actions { display: flex; gap: 4px; align-items: center; }
.icon-btn { background: none; border: 0; color: var(--orange); width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; padding: 0; }
.icon-btn:hover { background: rgba(255,255,255,.08); }
.icon-btn svg.i { width: 22px; height: 22px; }
.top .text-btn { background: none; border: 0; color: var(--orange); font-weight: 600; padding: 8px 10px; border-radius: 10px; display: inline-flex; gap: 6px; align-items: center; }
.top .text-btn:hover { background: rgba(255,255,255,.08); }
.view { max-width: 980px; margin: 0 auto; padding: 16px 16px calc(var(--tabs-h) + 28px + env(safe-area-inset-bottom)); }

.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px 6px; color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 600; min-height: var(--tabs-h); justify-content: center; }
.tabs a.on { color: var(--orange); }
.tabs svg.i { width: 24px; height: 24px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 236px 1fr; background: linear-gradient(to right, var(--navy) 236px, var(--bg) 236px); }
  .side { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; background: var(--navy); color: #fff; padding: 18px 12px; }
  .side-logo { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; font-size: 22px; font-weight: 800; letter-spacing: -.4px; padding: 4px 8px 20px; }
  .side-logo img { width: 36px; height: 36px; border-radius: 9px; }
  .side-logo b { color: var(--orange); }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a { display: flex; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 12px; color: #C9D2DF; text-decoration: none; font-weight: 600; }
  .side-nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
  .side-nav a.on { background: rgba(255,122,26,.16); color: var(--orange); }
  .side-foot { margin-top: auto; font-size: 12px; color: #9AA5B5; padding: 8px; line-height: 1.4; }
  .tabs { display: none; }
  .view { padding-bottom: 48px; }
  .top-in { padding-left: 24px; padding-right: 20px; }
  .view { padding-left: 24px; padding-right: 24px; }
}

/* Kort og fliser */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
@media (min-width: 700px) { .tiles.four { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px; min-width: 0; }
.tile .ic { color: var(--orange); }
.tile .ic svg.i { width: 18px; height: 18px; }
.tile .v { font-size: 22px; font-weight: 700; margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.3px; }
.tile .l { font-size: 12.5px; color: var(--muted); }
.section-title { font-size: 14px; font-weight: 600; color: var(--muted); margin: 18px 4px 8px; }
.section-title:first-child { margin-top: 4px; }

/* Søg og værktøjslinje */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; align-items: center; }
.search { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--card); border-radius: 12px; padding: 0 12px; box-shadow: var(--shadow); min-width: 0; }
.search svg.i { color: var(--muted); width: 18px; height: 18px; }
.search input { flex: 1; border: 0; background: none; outline: none; padding: 11px 0; min-width: 0; }
select.pill { appearance: none; -webkit-appearance: none; border: 0; background: var(--card); box-shadow: var(--shadow); border-radius: 12px; padding: 11px 32px 11px 12px; font-weight: 600; font-size: 14px; color: var(--text); background-image: linear-gradient(45deg, transparent 50%, var(--orange) 50%), linear-gradient(135deg, var(--orange) 50%, transparent 50%); background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%; background-size: 5px 5px; background-repeat: no-repeat; max-width: 46vw; }

/* Bilrækker */
.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 12px; align-items: stretch; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px 14px 12px 12px; text-decoration: none; color: inherit; transition: transform .08s ease; }
.row:hover { transform: translateY(-1px); }
.row:active { transform: scale(.995); }
.stripe { width: 4px; border-radius: 2px; background: var(--line); flex: none; }
.stripe.warn { background: var(--yellow); }
.stripe.crit { background: var(--red); }
.stripe.sold { background: var(--green); }
.row .mid { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 3px; }
.row .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; gap: 6px; align-items: center; }
.row .t svg.i { width: 15px; height: 15px; color: var(--muted); }
.row .d { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .end { text-align: right; display: flex; flex-direction: column; align-items: flex-end; justify-content: center; gap: 2px; flex: none; }
.row .p { font-weight: 700; }
.row .s { font-size: 12px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--orange-soft); color: var(--orange); white-space: nowrap; }
.badge.red { background: rgba(220,38,38,.12); color: var(--red); }
.badge svg.i { width: 12px; height: 12px; }
.days { font-size: 12px; font-weight: 700; color: var(--muted); display: inline-flex; gap: 3px; align-items: center; }
.days svg.i { width: 12px; height: 12px; }
.days.warn { color: #B58900; }
.days.crit { color: var(--red); }
@media (prefers-color-scheme: dark) { .days.warn { color: var(--yellow); } }
.out-note { color: var(--orange); font-weight: 600; font-size: 14px; display: flex; gap: 6px; align-items: center; margin: 0 4px 10px; }

.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty svg.i { width: 44px; height: 44px; color: var(--orange); margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 0 0 4px; font-size: 18px; }
.empty p { margin: 0 0 16px; }

/* Knapper */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; background: var(--orange); color: #fff; text-decoration: none; }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .45; cursor: not-allowed; filter: none; }
.btn.block { width: 100%; }
.btn.ghost { background: var(--orange-soft); color: var(--orange); }
.btn.plain { background: var(--field); color: var(--text); }
.btn.danger { background: rgba(220,38,38,.1); color: var(--red); }
.btn.small { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.btn svg.i { width: 18px; height: 18px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* Formularer (iOS-agtige grupper) */
.group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 14px; overflow: hidden; }
.group-h { font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin: 18px 6px 6px; display: flex; align-items: center; gap: 6px; }
.group-h.orange { color: var(--orange); }
.group-f { font-size: 13px; color: var(--muted); margin: -8px 6px 14px; }
.f { display: flex; align-items: center; gap: 12px; padding: 0 14px; min-height: 48px; border-top: 1px solid var(--line); }
.group > .f:first-child, .group > :first-child { border-top: 0; }
.f > label, .f > .lbl { flex: none; min-width: 112px; color: var(--text); font-size: 15px; }
.f input, .f select, .f textarea { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 12px 0; text-align: right; font-size: 16px; }
.f select { appearance: none; -webkit-appearance: none; color: var(--orange); font-weight: 600; text-align-last: right; cursor: pointer; }
.f input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
.f input[type=date], .f input[type=datetime-local] { color: var(--orange); font-weight: 600; min-height: 44px; }
.f .val { flex: 1; text-align: right; }
.f.stack { flex-direction: column; align-items: stretch; gap: 4px; padding: 10px 14px; }
.f.stack > label { min-width: 0; font-size: 13px; color: var(--muted); }
.f.stack input, .f.stack textarea { text-align: left; padding: 6px 0; }
.f textarea { text-align: left; resize: vertical; min-height: 70px; line-height: 1.4; }
a.f { text-decoration: none; }
.f.btnrow { justify-content: flex-start; color: var(--orange); font-weight: 600; background: none; border-left: 0; border-right: 0; border-bottom: 0; width: 100%; text-align: left; }
.f.btnrow:hover { background: var(--field); }
.f.btnrow.red { color: var(--red); }
.f.btnrow .right { margin-left: auto; color: var(--muted); font-weight: 500; font-size: 14px; }
.f.big .val { font-size: 20px; font-weight: 700; }
.stepper { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.stepper button { width: 36px; height: 32px; border-radius: 9px; border: 0; background: var(--field); color: var(--orange); font-size: 18px; font-weight: 700; }
.stepper span { min-width: 92px; text-align: center; }
.seg { display: flex; background: var(--field); border-radius: 10px; padding: 3px; margin: 10px 14px; }
.seg button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 8px; font-weight: 600; font-size: 14px; }
.seg button.on { background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); color: var(--orange); }
.input-full { width: 100%; border: 1px solid var(--line); background: var(--field); border-radius: 12px; padding: 12px 14px; outline: none; font-size: 16px; }
.input-full:focus { border-color: var(--orange); }
.stack-form { display: flex; flex-direction: column; gap: 10px; }
.err { color: var(--red); font-size: 14px; margin: 4px 0 0; }
.ok { color: var(--green); font-size: 14px; }
.note { font-size: 14px; color: var(--muted); padding: 10px 14px; border-top: 1px solid var(--line); }
.plate-line { display: flex; gap: 8px; align-items: center; }

/* Bilens side */
.hero { padding: 16px; margin-bottom: 14px; }
.hero h2 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.3px; }
.hero .meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.calc-card { padding: 16px; }
.calc-card .big { font-size: 22px; font-weight: 700; }
.calc-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.calc-split .v { font-size: 20px; font-weight: 700; }
.exp { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-top: 1px solid var(--line); }
.exp:first-child { border-top: 0; }
.catpick { position: relative; width: 40px; height: 34px; flex: none; border-radius: 9px; background: var(--orange-soft); display: grid; place-items: center; cursor: pointer; font-size: 17px; }
.catpick select { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.exp select.old { width: 40px; height: 34px; border-radius: 9px; border: 0; background: var(--orange-soft); color: var(--orange); appearance: none; -webkit-appearance: none; text-align: center; font-weight: 700; cursor: pointer; padding: 0; }
.exp .cat { font-size: 12px; color: var(--muted); }
.exp input.t { flex: 1; min-width: 0; border: 0; background: none; outline: none; padding: 6px 0; }
.exp input.a { width: 110px; border: 0; background: none; outline: none; padding: 6px 0; text-align: right; font-weight: 600; }
.exp .del { color: var(--muted); }
.exp .del:hover { color: var(--red); background: rgba(220,38,38,.08); }
.testdrive { border: 2px solid var(--orange); }
.testdrive.late { border-color: var(--red); }

@media (min-width: 900px) {
  .detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; align-items: start; }
}

/* Moms */
.period { display: flex; align-items: center; justify-content: center; gap: 14px; background: var(--card); border-radius: 999px; box-shadow: var(--shadow); padding: 6px 10px; width: max-content; margin: 0 auto 6px; }
.period .icon-btn { width: 36px; height: 36px; }
.period strong { min-width: 130px; text-align: center; font-size: 17px; }
.vat-hero { background: linear-gradient(135deg, var(--navy), var(--navy-2)); color: #fff; border-radius: var(--radius); padding: 22px 16px; text-align: center; margin: 12px 0 16px; }
.vat-hero .l { color: rgba(255,255,255,.75); font-size: 14px; }
.vat-hero .v { color: var(--orange); font-size: 40px; font-weight: 800; letter-spacing: -.5px; line-height: 1.15; margin: 4px 0; }
.center-note { text-align: center; color: var(--muted); font-size: 13px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 10, 20, .5); z-index: 40; display: flex; align-items: flex-end; justify-content: center; animation: fade .15s ease; }
.modal { background: var(--bg); width: 100%; max-width: 620px; max-height: 92vh; max-height: 92dvh; border-radius: 20px 20px 0 0; display: flex; flex-direction: column; animation: up .2s ease; overflow: hidden; }
@media (min-width: 700px) { .modal-bg { align-items: center; padding: 24px; } .modal { border-radius: 20px; max-height: 88vh; } }
.modal-head { background: var(--navy); color: #fff; display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 16px; min-height: 54px; }
.modal-head h2 { flex: 1; font-size: 17px; margin: 0; text-align: center; }
.modal-head button { background: none; border: 0; color: var(--orange); font-weight: 600; padding: 8px 10px; border-radius: 10px; min-width: 72px; }
.modal-head button.strong { font-weight: 800; }
.modal-head button:disabled { opacity: .4; cursor: not-allowed; }
.modal-body { overflow: auto; padding: 14px 14px calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 14px; scrollbar-width: none; }
.chip { border: 0; border-radius: 999px; padding: 8px 12px; font-weight: 600; font-size: 14px; background: var(--orange-soft); color: var(--orange); white-space: nowrap; }
.chip.on { background: var(--orange); color: #fff; }

.sig { width: 100%; height: 150px; background: #fff; border-radius: 12px; border: 1px dashed var(--line); touch-action: none; display: block; }

/* Indstillinger */
.acct { display: flex; gap: 14px; align-items: center; padding: 16px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--orange); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 22px; flex: none; }
.sicon { width: 29px; height: 29px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: none; }
.sicon svg.i { width: 16px; height: 16px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tabs-h) + 18px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--navy); color: #fff; padding: 11px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s ease; z-index: 60; box-shadow: 0 8px 30px rgba(0,0,0,.3); max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
@media (min-width: 900px) { .toast { bottom: 28px; } }
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; vertical-align: 1px; }
.sync-dot.busy { background: var(--orange); animation: pulse 1s infinite; }
.sync-dot.bad { background: var(--red); }
.spin { width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: rot .7s linear infinite; display: inline-block; flex: none; }
@keyframes rot { to { transform: rotate(360deg); } }
