:root {
  --bg: #0f172a;
  --bg-soft: #1e293b;
  --card: #ffffff;
  --ink: #0f172a;
  --ink-soft: #475569;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --green: #16a34a;
  --green-dark: #15803d;
  --amber: #d97706;
  --red: #dc2626;
  --radius: 16px;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: #f1f5f9;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.4;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  background: var(--bg);
  color: #fff;
  position: sticky; top: 0; z-index: 10;
}
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; flex: 1; }
.topbar .back {
  background: rgba(255,255,255,0.12); border: 0; color: #fff;
  width: 38px; height: 38px; border-radius: 10px; font-size: 20px;
}
.topbar .logout {
  background: rgba(255,255,255,0.12); border: 0; color: #fff;
  padding: 8px 12px; border-radius: 10px; font-size: 14px;
}

/* ── Login ── */
.login-wrap {
  flex: 1; display: flex; flex-direction: column; justify-content: center;
  padding: 28px 24px; background: linear-gradient(160deg, #1e293b, #0f172a);
  color: #fff; min-height: 100vh;
}
.logo-badge {
  width: 64px; height: 64px; border-radius: 18px; background: var(--brand);
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  margin: 0 auto 18px;
}
.login-wrap h2 { text-align: center; margin: 0 0 4px; font-size: 24px; }
.login-wrap .sub { text-align: center; color: #94a3b8; margin: 0 0 28px; font-size: 14px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: #cbd5e1; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid #334155;
  background: #0b1220; color: #fff; font-size: 16px;
}
.field input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

.btn {
  width: 100%; padding: 15px; border-radius: 12px; border: 0;
  font-size: 16px; font-weight: 700; color: #fff; background: var(--brand);
}
.btn:active { background: var(--brand-dark); }
.btn.green { background: var(--green); }
.btn.green:active { background: var(--green-dark); }
.btn.ghost { background: rgba(255,255,255,0.1); }
.btn[disabled] { opacity: 0.6; }

.msg { font-size: 14px; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; display: none; }
.msg.show { display: block; }
.msg.err { background: #7f1d1d; color: #fecaca; }
.msg.ok { background: #14532d; color: #bbf7d0; }

.link-btn {
  background: none; border: 0; color: #93c5fd; font-size: 14px;
  margin-top: 12px; text-decoration: underline;
}

/* ── Home ── */
.home-grid { padding: 24px 18px; display: grid; gap: 18px; }
.home-card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 28px 22px; text-align: center; border: 1px solid var(--line);
}
.home-card .ic { font-size: 44px; display: block; margin-bottom: 10px; }
.home-card .t { font-size: 20px; font-weight: 800; margin-bottom: 4px; }
.home-card .d { font-size: 14px; color: var(--ink-soft); }
.home-user { padding: 18px 18px 0; font-size: 14px; color: var(--ink-soft); }

/* ── Content ── */
.content { flex: 1; padding: 14px 14px 30px; overflow-y: auto; }

/* Kalender dagsstrimmel */
.daystrip { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 12px; }
.day {
  flex: 0 0 auto; min-width: 60px; text-align: center; padding: 10px 8px;
  border-radius: 12px; background: #fff; border: 1px solid var(--line);
}
.day.has { border-color: var(--brand); }
.day.sel { background: var(--brand); color: #fff; border-color: var(--brand); }
.day .dow { font-size: 11px; text-transform: uppercase; opacity: 0.8; }
.day .num { font-size: 18px; font-weight: 800; }
.day .cnt {
  font-size: 11px; margin-top: 3px; background: var(--amber); color: #fff;
  border-radius: 8px; padding: 1px 6px; display: inline-block;
}
.day.sel .cnt { background: rgba(255,255,255,0.3); }

.monthbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.monthbar button { background: #fff; border: 1px solid var(--line); border-radius: 10px; width: 40px; height: 40px; font-size: 18px; }
.monthbar .label { font-weight: 700; font-size: 16px; }

/* Aftale-kort */
.appt {
  background: #fff; border: 1px solid var(--line); border-radius: 14px;
  margin-bottom: 10px; overflow: hidden;
}
.appt-head {
  padding: 14px 14px; display: flex; align-items: center; gap: 10px;
}
.appt-head .dot { width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; background: var(--brand); }
.appt-head .nm { flex: 1; font-weight: 700; }
.appt-head .nm small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 13px; }
.appt-head .arrow { color: var(--ink-soft); transition: transform .15s; }
.appt.open .appt-head .arrow { transform: rotate(90deg); }
.appt-body { display: none; padding: 0 14px 14px; border-top: 1px solid var(--line); }
.appt.open .appt-body { display: block; }

.kv { display: flex; gap: 8px; font-size: 14px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.kv .k { color: var(--ink-soft); min-width: 78px; }
.kv .v { flex: 1; }
.kv a { color: var(--brand); text-decoration: none; }
.tag {
  display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 8px;
  background: #eff6ff; color: var(--brand); margin: 2px 4px 2px 0;
}
.tag.quote { background: #fef3c7; color: var(--amber); }
.tag.order { background: #dcfce7; color: var(--green); }
.tag.callback { background: #fee2e2; color: var(--red); }

.row-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.row-actions .btn { padding: 12px; font-size: 14px; border: 1px solid transparent; }
.row-actions .btn.full { grid-column: 1 / -1; }
/* Ghost-knapper på hvide kort: synlig ramme, lys baggrund og mørk tekst
   (før: hvid tekst på næsten-hvid baggrund → lignede svævende ikoner) */
.row-actions .btn.ghost {
  background: #f8fafc;
  color: var(--ink);
  border: 1px solid var(--line);
}
.row-actions .btn.ghost:active { background: #eef2ff; border-color: var(--brand); }

/* ── Kontakt-knapper (Telefon / Mobil / Email) i kundedropdowns ── */
.contact-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin: 10px 0 4px; }
.contact-btn {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: #f8fafc; font-size: 14px; font-weight: 600; color: var(--ink);
  text-align: left; font-family: inherit;
}
.contact-btn:active { background: #eef2ff; border-color: var(--brand); }
.contact-btn .ci {
  width: 36px; height: 36px; border-radius: 10px; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.contact-btn.tel .ci { background: #dcfce7; border: 1px solid var(--green); }
.contact-btn.mob .ci { background: #dbeafe; border: 1px solid var(--brand); }
.contact-btn.mail .ci { background: #fef3c7; border: 1px solid var(--amber); }
.contact-btn .cv { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.contact-btn .cv small { display: block; font-weight: 400; color: var(--ink-soft); font-size: 12px; }

.empty { text-align: center; color: var(--ink-soft); padding: 40px 20px; }
.spinner { text-align: center; padding: 40px; color: var(--ink-soft); }

/* ── Modal ── */
.modal {
  position: fixed; inset: 0; background: rgba(15,23,42,0.55);
  display: none; align-items: flex-end; justify-content: center; z-index: 1300;
  padding-bottom: env(safe-area-inset-bottom);
}
.modal.show { display: flex; }
.sheet {
  background: #fff; width: 100%; max-width: 560px; border-radius: 20px 20px 0 0;
  padding: 20px 18px 26px; max-height: 88vh; overflow-y: auto;
}
.sheet h3 { margin: 2px 0 14px; font-size: 19px; }
.sheet .who { color: var(--ink-soft); font-size: 14px; margin-bottom: 14px; }
.opt-btn {
  width: 100%; text-align: left; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: #f8fafc; margin-bottom: 10px;
  font-size: 15px; font-weight: 600;
}
.opt-btn small { display: block; font-weight: 400; color: var(--ink-soft); margin-top: 2px; }
.opt-btn:active { background: #eef2ff; border-color: var(--brand); }
.sheet textarea, .sheet input[type=date] {
  width: 100%; padding: 12px; border-radius: 10px; border: 1px solid var(--line);
  font-size: 15px; font-family: inherit; margin-bottom: 12px;
}
.sheet .close { background: none; border: 0; color: var(--ink-soft); font-size: 15px; width: 100%; padding: 10px; }

/* ── Rute ── */
.route-toolbar { display: flex; gap: 8px; margin-bottom: 12px; }
.route-toolbar .btn { padding: 12px; font-size: 14px; }
.pick {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 12px;
}
.pick.checked { border-color: var(--green); background: #f0fdf4; }
.pick .chk {
  width: 26px; height: 26px; border-radius: 8px; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; font-size: 16px;
}
.pick.checked .chk { background: var(--green); border-color: var(--green); color: #fff; }
.pick .info { flex: 1; }
.pick .info .nm { font-weight: 700; }
.pick .info .ad { font-size: 13px; color: var(--ink-soft); }
.pick .seq {
  background: var(--brand); color: #fff; width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 14px;
}

.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; z-index: 99; opacity: 0; transition: opacity .2s; pointer-events: none;
  max-width: 90%;
}
.toast.show { opacity: 1; }

/* ── Filterchips ── */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; }
.chip {
  flex: 0 0 auto; padding: 7px 13px; border-radius: 20px; font-size: 13px; font-weight: 600;
  border: 1.5px solid var(--line); background: #fff; color: var(--ink-soft); white-space: nowrap;
}
.chip.active { border-color: var(--brand); background: #eff6ff; color: var(--brand); }

/* ── Søgefelt ── */
.search-input {
  width: 100%; padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line);
  font-size: 16px; margin-bottom: 14px; background: #fff;
}
.search-input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }

/* ── Tabel-rækker (kunder/ordrer/faktura) ── */
.trow {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 10px;
}
.trow .main { flex: 1; min-width: 0; }
.trow .main .nm { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .main .sub { font-size: 13px; color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trow .pill {
  font-size: 11px; padding: 3px 9px; border-radius: 10px; font-weight: 700; flex: 0 0 auto;
  background: #eff6ff; color: var(--brand);
}

/* ── Checkbox i kalender/rute ── */
.appt-head .cbox {
  width: 24px; height: 24px; border-radius: 7px; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto;
  font-size: 15px; color: #fff; background: #fff;
}
.appt-head .cbox.on { background: var(--green); border-color: var(--green); }

/* ── Dashboard / faktura rubrikker ── */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 16px 14px;
}
.stat-card .val { font-size: 22px; font-weight: 800; }
.stat-card .lbl { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

/* ── Ekstra knapfarver ── */
.btn.amber { background: var(--amber); }
.btn.amber:active { background: #b45309; }
.btn.red { background: var(--red); }
.btn.red:active { background: #b91c1c; }

/* ── Footer "Udviklet af Ardilogi" ── */
.app-footer {
  text-align: center; padding: 18px 12px 22px; font-size: 12px; color: var(--ink-soft);
}
.app-footer a { color: var(--brand); text-decoration: none; }

/* ── Bulk-handlingslinje ── */
.bulk-bar {
  display: flex; gap: 8px; align-items: center; margin-bottom: 12px; flex-wrap: wrap;
}
.bulk-bar .selall {
  display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600;
  background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 9px 13px;
}
.bulk-bar .selall .box {
  width: 22px; height: 22px; border-radius: 6px; border: 2px solid var(--line);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 14px;
}
.bulk-bar .selall.on .box { background: var(--brand); border-color: var(--brand); }
.bulk-bar .count { font-size: 13px; color: var(--ink-soft); }
.bulk-bar .act-btn {
  margin-left: auto; background: var(--brand); color: #fff; border: 0; border-radius: 12px;
  padding: 10px 16px; font-size: 14px; font-weight: 700;
}
.bulk-bar .act-btn[disabled] { opacity: .5; }

/* ── Login sprog-flag ── */
.lang-row { display: flex; justify-content: center; gap: 10px; margin-bottom: 18px; }
.lang-btn {
  display: flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 20px;
  border: 1.5px solid #334155; background: #0b1220; color: #cbd5e1; font-size: 14px; font-weight: 600;
}
.lang-btn.active { border-color: var(--brand); background: #1e293b; color: #fff; }
.lang-btn .flag { font-size: 17px; }

/* Datovælger i kalender-top */
.cal-jump { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.cal-jump input[type=date] {
  flex: 1; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line); font-size: 15px; background: #fff;
}

.cal-quick { display: flex; gap: 8px; margin-bottom: 10px; }
.cal-quick .chip { cursor: pointer; }

/* ── Værktøjer ── */
.tool-intro { font-size: 14px; color: var(--ink-soft); margin: 0 0 14px; line-height: 1.5; }
.map-frame {
  width: 100%; height: 340px; border-radius: 14px; overflow: hidden;
  border: 1px solid var(--line); background: #e5e7eb; margin-bottom: 12px;
}
.map-frame iframe, .map-frame > div { width: 100%; height: 100%; border: 0; }

/* Adresse-forslag (DAWA autocomplete) */
.addr-suggest {
  position: absolute; top: 56px; left: 0; right: 0; z-index: 20;
  background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden;
  box-shadow: var(--shadow); display: none;
}
.addr-suggest.show { display: block; }
.addr-suggest .opt { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--line); }
.addr-suggest .opt:last-child { border-bottom: 0; }
.addr-suggest .opt:active { background: #eff6ff; }

/* BBR resultat */
.bbr-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 10px; }
.bbr-card h4 { margin: 0 0 8px; font-size: 15px; }

/* Stort skråfoto-vindue: fylder højden, men aldrig ud over skærmen i siderne */
.map-frame-tall {
  height: calc(100vh - 230px);
  min-height: 420px;
  max-width: 100%;
}

/* ── Måneds-gitter (kalender visning 2) ── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.cal-grid .dow { text-align: center; font-size: 11px; font-weight: 700; color: var(--ink-soft); padding: 4px 0; }
.cal-cell {
  aspect-ratio: 1/1; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: 4px 2px; font-size: 13px; cursor: pointer; position: relative; overflow: hidden;
}
.cal-cell.empty { background: transparent; border: 0; cursor: default; }
.cal-cell.today { border-color: var(--brand); border-width: 2px; }
.cal-cell .dnum { font-weight: 600; }
.cal-cell .cnt {
  margin-top: 2px; font-size: 10px; font-weight: 700; color: #fff; background: var(--brand);
  border-radius: 10px; min-width: 18px; text-align: center; padding: 1px 5px;
}
.cal-cell .dots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; margin-top: 2px; }
.cal-cell .pdot { width: 5px; height: 5px; border-radius: 50%; }

/* ── Popup (dagens kunder i måneds-visning) ── */
.cal-popup-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1200;
  display: flex; align-items: flex-end; justify-content: center;
}
.cal-popup-sheet {
  background: var(--card, #ffffff); color: var(--ink); width: 100%; max-width: 640px; max-height: 85vh;
  border-radius: 18px 18px 0 0; padding: 16px; overflow-y: auto;
}
.cal-popup-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-popup-head h3 { margin: 0; font-size: 17px; }
.cal-popup-head button { background: none; border: 0; font-size: 20px; color: var(--ink-soft); cursor: pointer; }

/* ── Opdel faktura modal ── */
.split-modes { display: flex; gap: 8px; margin: 10px 0; }
.split-modes .opt-btn { flex: 1; margin: 0; }
.opt-btn.sel { background: rgba(234,179,8,0.15); border-color: #eab308; color: #92400e; font-weight: 700; }
.sp-lbl { display: block; font-size: 12px; color: var(--ink-soft); margin: 8px 0 4px; }
.sp-inp { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px; box-sizing: border-box; }
.sp-hint { font-size: 11px; color: var(--ink-soft); margin: 4px 0 0; }
.sp-msg { background: rgba(239,68,68,0.1); color: #b91c1c; border: 1px solid rgba(239,68,68,0.3); border-radius: 8px; padding: 8px 10px; font-size: 12px; margin: 8px 0; }

/* ── Tilbud-detaljer i popup ── */
.q-items { margin: 12px 0; }
.q-item { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.q-total { margin-top: 10px; text-align: right; font-size: 14px; }

/* ── Tilbud-detaljer: indhold + totaler ── */
.q-content { font-size: 14px; line-height: 1.6; color: var(--ink); margin: 12px 0; padding: 12px; background: rgba(0,0,0,0.03); border-radius: 10px; }
.q-content * { max-width: 100%; }
.q-ref { font-family: monospace; font-size: 11px; color: #888; }
.q-totals { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.q-trow { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; padding: 3px 0; color: var(--ink-soft); }
.q-trow-total { font-weight: 700; font-size: 15px; color: var(--ink); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }

/* ── Rute startadresse ── */
.rt-start-wrap { margin-bottom: 12px; }
.rt-start-lbl { display: block; font-size: 13px; color: var(--ink-soft); margin-bottom: 4px; font-weight: 600; }
.rt-start-err { color: #dc2626; font-size: 12px; margin: 6px 0 0; }

/* ── Startadresse autocomplete ── */
.rt-start-dropdown {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
  background: var(--card, #fff); border: 1px solid var(--line); border-radius: 10px;
  margin-top: 4px; overflow: hidden; box-shadow: 0 8px 24px rgba(0,0,0,0.18);
}
.rt-start-opt { padding: 10px 14px; font-size: 13px; color: var(--ink); cursor: pointer; border-bottom: 1px solid var(--line); }
.rt-start-opt:last-child { border-bottom: 0; }
.rt-start-opt:hover { background: rgba(0,0,0,0.05); }


/* Global spinner keyframe */
@keyframes navi-spin { to { transform: rotate(360deg); } }
