/* Svenska Pooltak CRM – tema "Nattblå": mörkt marinblått, sidomeny med ikoner, sökfält överst, kort i ett bredare rutnät.
   Laddas efter crm.css och ersätter dess färger. Typsnittet (Inter) ligger i app/static/fonts, så inget hämtas från internet. */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url("../fonts/Inter-Regular.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url("../fonts/Inter-Medium.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 600; font-display: swap; src: url("../fonts/Inter-SemiBold.woff") format("woff"); }
@font-face { font-family: "Inter"; font-weight: 700; font-display: swap; src: url("../fonts/Inter-Bold.woff") format("woff"); }

:root {
  --bg:#08101a;
  --surface:#0c1725;
  --ink:#e6edf7;
  --muted:#8b9bb2;
  --line:#1a2a3f;
  --brand:#6facec;
  --accent:#6facec;
  --accent-soft:#162d4a;
  --ok:#79d3a2;
  --ok-soft:#1c4634;
  --warn:#e9bd72;
  --warn-soft:#4a3818;
  --bad:#f19a9a;
  --bad-soft:#4a1f29;
  --info:#8fc1f4;
  --info-soft:#17304f;
  --neutral-soft:#1b2b40;
  --radius:12px;
  --shadow:0 0 0 1px rgba(111,172,236,.04);
  --gap:20px;
  --font-body:"Inter", system-ui, "Segoe UI", sans-serif;
  --font-head:var(--font-body);
  --head-weight:600;
  --sidebar-w:244px; --gutter:max(40px, calc((100% - 1600px) / 2));
  --surface-2:#101e30;
  --head:#ffffff; --on-accent:#ffffff;
  --sidebar-bg:#0d1824; --nav-ink:#a9b7cc; --nav-hover:rgba(111,172,236,.08); --active-bg:#1b2d43;
  --faint:#5f718b; --hint:#6d7f98; --th-ink:#7f90a8; --muted-2:#9fb0c8; --ink-soft:#cbd6e6; --num-out:#4b5d75;
  --search-bg:#101d2d; --input-bg:#0a1521; --input-border:#223650;
  --btn-bg:#122033; --btn-border:#243751; --btn-hover:#1a2d46; --btn-primary:#3b82d6; --btn-primary-hover:#4a90e2;
  --file-btn-border:#2a4260; --file-btn-hover:#243b57;
  --line-soft:#14243a; --bar-bg:#162840; --calc-box:#0f2036; --total-line:#3a5273; --kpi-icon-bg:#12233a; --bad-border:#5b2a35;
  --cal-head-bg:#0f1d2e; --cal-weekend:#0a1420; --cal-out:#080f18;
  --chip-measurement-ink:#cfe3fa; --chip-installation-ink:#cdeedd; --chip-other-ink:#dbe3ee;
  --k-measurement:#6facec; --k-measurement-bg:#17304f; --k-installation:#79d3a2; --k-installation-bg:#1c4634; --k-other:#b6c2d4; --k-other-bg:#27374d;
}

/* Ljust tema – väljs med knappen längst ner i menyn och sparas per webbläsare (data-theme på <html>). */
html[data-theme="light"] {
  --bg:#f1f4f9; --surface:#ffffff; --surface-2:#f6f8fc; --ink:#1c2735; --muted:#5d6b80; --line:#dbe2ec;
  --brand:#1f6fc2; --accent:#1f6fc2; --accent-soft:#e3eefb;
  --ok:#1d7a4c; --ok-soft:#dcf1e6; --warn:#8f5400; --warn-soft:#fbefd6; --bad:#b3363f; --bad-soft:#fbe3e5;
  --info:#1f6fc2; --info-soft:#e3eefb; --neutral-soft:#e9eef5;
  --shadow:0 1px 2px rgba(20,40,70,.06);
  --head:#0f1a2a; --on-accent:#ffffff;
  --sidebar-bg:#ffffff; --nav-ink:#4a5a70; --nav-hover:rgba(31,111,194,.07); --active-bg:#e3eefb;
  --faint:#8795a8; --hint:#7a889b; --th-ink:#5d6b80; --muted-2:#4f5e73; --ink-soft:#2b3a4e; --num-out:#9aa7b8;
  --search-bg:#ffffff; --input-bg:#ffffff; --input-border:#cbd5e1;
  --btn-bg:#ffffff; --btn-border:#cbd5e1; --btn-hover:#eef3f9; --btn-primary:#1f6fc2; --btn-primary-hover:#195ea6;
  --file-btn-border:#cbd5e1; --file-btn-hover:#e3eaf3;
  --line-soft:#edf1f6; --bar-bg:#e3e9f1; --calc-box:#f1f6fc; --total-line:#a9bdd6; --kpi-icon-bg:#e8f0fa; --bad-border:#efb3b9;
  --cal-head-bg:#f3f6fb; --cal-weekend:#f8fafd; --cal-out:#f1f4f9;
  --chip-measurement-ink:#17497f; --chip-installation-ink:#14583a; --chip-other-ink:#3b4a5e;
  --k-measurement:#1f6fc2; --k-measurement-bg:#dbe9fa; --k-installation:#1d7a4c; --k-installation-bg:#d9f0e3; --k-other:#5d6b80; --k-other-bg:#e6ebf2;
}

html { -webkit-text-size-adjust:100%; }
body { font-family:var(--font-body); font-size:15px; line-height:1.55; color:var(--ink); background:var(--bg); font-feature-settings:"tnum" 1, "cv11" 1; -webkit-font-smoothing:antialiased; }
a { color:var(--brand); text-underline-offset:3px; text-decoration-thickness:1px; }
a:hover { text-decoration-thickness:2px; }
:focus-visible { outline:2px solid var(--info); outline-offset:2px; border-radius:3px; }

/* ---- Skal och navigering ---- */
.shell { min-height:100vh; }
.top { height:auto; border:0; padding:0; justify-content:flex-start; align-items:stretch; }
.brand { text-decoration:none; font-weight:500; display:flex; align-items:center; gap:10px; white-space:nowrap; }
.brand b { font-weight:700; }
.brand-mark { width:12px; height:12px; flex:none; background:var(--accent); border-radius:3px; }
.top nav { display:flex; }
.nav-group { display:flex; }
.top nav a { margin:0; text-decoration:none; white-space:nowrap; }
main { max-width:none; margin:0; padding:0; }
.stage > main { width:100%; max-width:1040px; }
.foot { text-align:left; color:var(--muted); font-size:12px; padding:48px 0 8px; }

/* ---- Typografi ---- */
h1 { font-family:var(--font-head); font-weight:var(--head-weight); font-size:32px; line-height:1.15; letter-spacing:-.022em; color:var(--ink); margin:0 0 6px; }
h2 { font-family:var(--font-head); font-weight:var(--head-weight); font-size:18px; letter-spacing:-.012em; text-transform:none; color:var(--ink); margin:0 0 14px; }
h3 { font-size:14px; font-weight:600; margin:18px 0 8px; }
p.lead { color:var(--muted); margin:0 0 28px; max-width:72ch; }
tr.lead { margin:0; max-width:none; }
.hint { color:var(--muted); font-size:13px; margin:14px 0 0; max-width:70ch; }
.muted { color:var(--muted); }
.page-head { margin-bottom:var(--gap); align-items:flex-end; }
.page-head.tight { margin-bottom:12px; align-items:baseline; }
.page-head.tight h2 { margin:0; }

/* ---- Ytor ---- */
.card { background:var(--surface); border:1px solid var(--line); border-top:1px solid var(--line); border-radius:var(--radius); box-shadow:var(--shadow); padding:24px 28px; margin-bottom:var(--gap); }

/* ---- Tabeller ---- */
table.plain th { font-size:12.5px; font-weight:500; color:var(--muted); text-transform:none; letter-spacing:0; padding:0 12px 10px 0; border-bottom:1px solid var(--line); }
table.plain th.right { padding-right:0; }
table.plain td { padding:14px 12px 14px 0; border-bottom:1px solid var(--line); vertical-align:top; }
table.plain td.right { padding-right:0; padding-left:20px; }
table.plain th.right { padding-left:20px; }
table.plain td.nowrap { white-space:nowrap; }
table.plain tbody tr:last-child td { border-bottom:0; }
table.plain td a { font-weight:500; }
table.plain td .small { color:var(--muted); font-weight:400; }
table.plain td b { font-weight:600; }
table.plain .bar { display:block; height:4px; margin-top:7px; background:var(--neutral-soft); border-radius:2px; max-width:180px; }
table.plain .bar i { display:block; height:100%; background:var(--brand); border-radius:2px; opacity:.85; }
table.plain tr.lost .bar i, table.plain tr.delivered .bar i { opacity:.4; }
table.acts tr.overdue td, table.acts tr.today td, table.plain tr.offer-expired td { background:none; }
table.acts td { vertical-align:middle; }

/* ---- Knappar och statusmärken ---- */
.btn { font:inherit; font-weight:500; padding:8px 16px; border:1px solid var(--line); border-radius:var(--radius); background:var(--surface); color:var(--ink); text-decoration:none; line-height:1.3; transition:background .12s, border-color .12s; }
.btn:hover { background:var(--neutral-soft); text-decoration:none; }
.btn.primary { background:var(--brand); border-color:var(--brand); color:var(--on-accent); }
.btn.primary:hover { background:var(--brand); filter:brightness(1.18); }
.btn.small { padding:5px 12px; font-size:13.5px; }
.btn.quiet { border-color:transparent; background:none; color:var(--muted); padding:5px 8px; font-size:13.5px; }
.btn.quiet:hover { background:var(--neutral-soft); color:var(--ink); }
.link-btn { color:var(--muted); text-decoration:none; margin-left:2px; padding:5px 8px; font-size:13.5px; border-radius:var(--radius); }
.link-btn:hover { color:var(--bad); background:var(--bad-soft); text-decoration:none; }
.actions { gap:8px; }
.pill { display:inline-block; font-size:12.5px; font-weight:500; letter-spacing:0; padding:2px 10px; border-radius:99px; background:var(--neutral-soft); color:var(--ink); white-space:nowrap; }
.pill.ok-pill { background:var(--ok-soft); color:var(--ok); } .pill.muted-pill { background:var(--neutral-soft); color:var(--muted); }
.pill.due-overdue { background:var(--bad-soft); color:var(--bad); } .pill.due-today { background:var(--warn-soft); color:var(--warn); } .pill.due-soon { background:var(--info-soft); color:var(--info); }

/* ---- Formulär ---- */
input, textarea, select { border:1px solid var(--input-border); border-radius:var(--radius); padding:9px 11px; background:var(--input-bg); color:var(--ink); }
input:focus, textarea:focus, select:focus { outline:2px solid var(--info); outline-offset:0; border-color:var(--info); }
label { font-weight:500; font-size:14px; margin-bottom:5px; }
.form-grid { gap:18px 24px; }
dl.kv { grid-template-columns:150px 1fr; gap:10px 16px; }
dl.kv dt { color:var(--muted); font-size:14px; }
.flash { border-radius:var(--radius); border:0; border-left:4px solid var(--info); background:var(--info-soft); padding:12px 16px; margin-bottom:24px; }
.flash.ok { border-left-color:var(--ok); background:var(--ok-soft); } .flash.warn { border-left-color:var(--warn); background:var(--warn-soft); }
.calc-form fieldset, .included-box { border-radius:var(--radius); border-color:var(--line); }

/* ---- Nyckeltal ---- */
.kpis { display:grid; grid-template-columns:repeat(6, 1fr); gap:0; margin:0 0 var(--gap); }
.kpi { background:none; border:0; border-left:1px solid var(--line); border-radius:0; padding:2px 0 2px 20px; }
.kpi:first-child { border-left:0; padding-left:0; }
.kpi b { font-family:var(--font-head); font-weight:var(--head-weight); font-size:28px; line-height:1.1; letter-spacing:-.02em; color:var(--ink); display:block; white-space:nowrap; }
.kpi span { display:block; margin-top:6px; color:var(--muted); font-size:13px; line-height:1.35; max-width:16ch; }
.kpi.bad b { color:var(--bad); }

/* ---- Översikt och kund: grundlayout (enkel kolumn) ---- */
.dash { display:block; }
.dash .card h2 { font-size:18px; }
.cust { display:block; }
.cust-side .card:last-child, .cust-main .card:last-child { margin-bottom:0; }

@media (max-width:900px) {
  .kpis { grid-template-columns:repeat(3, 1fr); row-gap:24px; }
  .kpi:nth-child(4) { border-left:0; padding-left:0; }
}
@media (max-width:640px) {
  .kpis { grid-template-columns:repeat(2, 1fr); }
  .kpi:nth-child(odd) { border-left:0; padding-left:0; } .kpi:nth-child(even) { padding-left:16px; }
  .card { padding:18px; }
  table.plain { display:block; overflow-x:auto; }
}
@media (prefers-reduced-motion:reduce) { * { transition:none !important; } }

tr.lead td { color:inherit; }
table.plain td.right + td, table.plain th.right + th { padding-left:24px; }

.btn { white-space:nowrap; }

/* Delar som bara används av vissa teman */
.topbar, .side-foot { display:none; }
.top nav .ico { display:none; }

/* ---- Nattblå ---- */
html { color-scheme:dark; }
html[data-theme="light"] { color-scheme:light; }
body { background:var(--bg); color:var(--ink); }
a { color:var(--accent); }
.shell { display:grid; grid-template-columns:var(--sidebar-w) minmax(0, 1fr); }
.top { position:sticky; top:0; height:100vh; background:var(--sidebar-bg); border-right:1px solid var(--line); padding:26px 14px 20px; display:flex; flex-direction:column; gap:30px; overflow:auto; }
.brand { color:var(--head); padding:0 12px; font-size:15px; }
.brand b { color:var(--accent); }
.brand-mark { width:22px; height:22px; border-radius:6px; background:linear-gradient(135deg, #f5c518 0 50%, #6facec 50% 100%); }
.top nav { flex-direction:column; gap:22px; flex:1; }
.nav-group { flex-direction:column; gap:3px; }
.nav-group + .nav-group { padding-top:22px; border-top:1px solid var(--line); }
.top nav a { display:flex; align-items:center; gap:13px; color:var(--nav-ink); padding:11px 12px; border-radius:10px; font-weight:500; font-size:14.5px; }
.top nav a:hover { background:var(--nav-hover); color:var(--head); }
.top nav a.on { background:var(--active-bg); color:var(--head); }
.top nav .ico { display:block; width:20px; height:20px; flex:none; fill:none; stroke:currentColor; stroke-width:1.7; stroke-linecap:round; stroke-linejoin:round; }
.top nav a.on .ico { stroke:var(--accent); }
.side-foot { display:flex; flex-direction:column; gap:14px; padding:0 4px; color:var(--faint); font-size:12px; line-height:1.5; }
.side-foot .ver { padding:0 8px; }
.theme-toggle { display:grid; grid-template-columns:1fr 1fr; gap:3px; padding:3px; background:var(--input-bg); border:1px solid var(--line); border-radius:10px; }
.theme-toggle button { display:flex; align-items:center; justify-content:center; gap:7px; font:inherit; font-size:13px; font-weight:500; color:var(--nav-ink); background:none; border:0; border-radius:7px; padding:7px 6px; cursor:pointer; }
.theme-toggle button:hover { color:var(--head); }
.theme-toggle button[aria-pressed="true"] { background:var(--active-bg); color:var(--head); }
.theme-toggle svg { width:15px; height:15px; fill:none; stroke:currentColor; stroke-width:1.9; stroke-linecap:round; stroke-linejoin:round; flex:none; }
.stage { padding:0 40px 32px; max-width:1680px; }
.topbar { display:flex; align-items:center; justify-content:space-between; gap:24px; height:76px; border-bottom:1px solid var(--line); margin:0 -40px 34px; padding:0 40px; }
.topbar form { position:relative; flex:0 1 520px; }
.topbar .ico { position:absolute; left:14px; top:50%; transform:translateY(-50%); width:18px; height:18px; fill:none; stroke:var(--muted); stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.topbar input { width:100%; background:var(--search-bg); border:1px solid transparent; border-radius:12px; padding:12px 14px 12px 44px; }
.topbar input:focus { border-color:var(--accent); }
.today { color:var(--muted); font-size:14px; }
.foot { display:none; }
h1 { font-size:30px; font-weight:600; letter-spacing:-.02em; color:var(--head); }
h2 { font-size:17px; font-weight:600; color:var(--head); }
p.lead { color:var(--muted); }
.page-head { margin-bottom:26px; }

.card { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); box-shadow:none; padding:22px 24px; margin-bottom:var(--gap); }
.card h2 { margin-bottom:12px; }
.hint { color:var(--hint); }

.btn { background:var(--btn-bg); border:1px solid var(--btn-border); color:var(--ink); border-radius:10px; }
.btn:hover { background:var(--btn-hover); }
.btn.primary { background:var(--btn-primary); border-color:var(--btn-primary); color:var(--on-accent); border-radius:10px; }
.btn.primary:hover { background:var(--btn-primary-hover); filter:none; }
.btn.small, .btn.quiet { border-radius:8px; }
.btn.quiet { background:none; border-color:transparent; color:var(--muted); }
.btn.quiet:hover { background:var(--neutral-soft); color:var(--head); }
.link-btn:hover { background:var(--bad-soft); color:var(--bad); }
.pill { border-radius:8px; }
.pill.due-soon { background:var(--info-soft); color:var(--info); }

table.plain th { color:var(--th-ink); border-bottom-color:var(--line); font-weight:500; }
table.plain td { border-bottom-color:var(--line-soft); }
table.plain td a { color:var(--info); }
table.plain td b { color:var(--head); }
table.plain .bar { background:var(--bar-bg); }
table.plain .bar i { background:var(--accent); opacity:1; }
table.plain tr.lost .bar i, table.plain tr.delivered .bar i { opacity:.45; }
table.plain tr.offer-expired td { background:none; }
tr.lead td { color:inherit; }

input, textarea, select { background:var(--input-bg); border:1px solid var(--input-border); color:var(--ink); border-radius:10px; }
input::placeholder, textarea::placeholder { color:var(--faint); }
input:focus, textarea:focus, select:focus { outline:2px solid rgba(111,172,236,.45); border-color:var(--accent); }
select option { background:var(--surface); color:var(--ink); }
input:disabled { opacity:.5; }
label { color:var(--ink-soft); }
dl.kv dt { color:var(--muted); } dl.kv dd { color:var(--ink); }
.flash { background:var(--info-soft); color:var(--ink); }
.flash.ok { background:var(--ok-soft); } .flash.warn { background:var(--warn-soft); }
.err, .req { color:var(--bad); }
.calc-form fieldset, .included-box { border-color:var(--line); }
.calc-form legend, .included-box legend { color:var(--head); }
.calc-form label.opt.opt-box { background:var(--input-bg); border-color:var(--input-border); }
.calc-form label.opt.opt-box:has(input:checked) { background:var(--accent-soft); border-color:var(--accent); }
.calc-box { background:var(--calc-box); border-left-color:var(--accent); color:var(--ink); }
.calc-lines tfoot tr.total td, table.doc-lines tfoot tr.total td { border-top-color:var(--total-line); }
.doc-chips a { background:var(--btn-bg); border-color:var(--btn-border); color:var(--ink); } .doc-chips a:hover { background:var(--btn-hover); }
.next-step { border-top-color:var(--accent); }
.check-grid label.inline, label.inline { color:var(--ink); }
.included-box h3, h3 { color:var(--muted-2); }
details.steps summary { color:var(--accent); cursor:pointer; }
.mono { color:var(--muted-2); }
.muted-pill { background:var(--neutral-soft); color:var(--muted-2); }

/* Nyckeltal som kort med ikon */
.kpis { display:grid; grid-template-columns:repeat(3, minmax(0, 1fr)); gap:var(--gap); margin:0 0 var(--gap); padding:0; background:none; border:0; box-shadow:none; }
.kpi { display:grid; grid-template-columns:48px minmax(0, 1fr); grid-template-rows:auto auto; column-gap:16px; align-items:center; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; }
.kpi:first-child { padding-left:20px; }
.kpi::before { content:""; grid-row:1 / span 2; width:48px; height:48px; border-radius:50%; background:var(--kpi-icon-bg) center / 22px no-repeat; }
.kpi span { grid-column:2; grid-row:1; margin:0; max-width:none; color:var(--muted); font-size:13px; line-height:1.3; align-self:end; }
.kpi b { grid-column:2; grid-row:2; font-size:26px; font-weight:600; color:var(--head); margin-top:2px; align-self:start; }
.kpi span.sub { grid-row:3; margin-top:4px; align-self:start; font-size:13px; }
.kpi span.sub b { display:inline; font-size:13px; font-weight:600; color:var(--head); margin:0; }
.kpi.bad { border-color:var(--bad-border); } .kpi.bad b { color:var(--bad); }
.kpi:nth-child(1)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f19a9a' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 8v4M12 16h.01M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0z'/%3E%3C/svg%3E"); }
.kpi:nth-child(2)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e9bd72' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 4H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zM16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); }
.kpi:nth-child(3)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236facec' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M16 13H8M16 17H8M10 9H8'/%3E%3C/svg%3E"); }
.kpi:nth-child(4)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236facec' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/%3E%3C/svg%3E"); }
.kpi:nth-child(5)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2379d3a2' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5'/%3E%3C/svg%3E"); }
html[data-theme="light"] .kpi:nth-child(1)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b3363f' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 8v4M12 16h.01M22 12a10 10 0 1 1-20 0 10 10 0 0 1 20 0z'/%3E%3C/svg%3E"); }
html[data-theme="light"] .kpi:nth-child(2)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238f5400' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M19 4H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2zM16 2v4M8 2v4M3 10h18'/%3E%3C/svg%3E"); }
html[data-theme="light"] .kpi:nth-child(3)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f6fc2' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8zM14 2v6h6M16 13H8M16 17H8M10 9H8'/%3E%3C/svg%3E"); }
html[data-theme="light"] .kpi:nth-child(4)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231f6fc2' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 1v22M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6'/%3E%3C/svg%3E"); }
html[data-theme="light"] .kpi:nth-child(5)::before { background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231d7a4c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 2L2 7l10 5 10-5-10-5zM2 17l10 5 10-5M2 12l10 5 10-5'/%3E%3C/svg%3E"); }

/* Översikt: tolvkolumnsrutnät */
.dash { display:grid; grid-template-columns:repeat(12, minmax(0, 1fr)); gap:var(--gap); align-items:stretch; }
.dash .card { margin:0; }
.d-todo { grid-column:1 / span 8; grid-row:1; }
.d-cal { grid-column:9 / span 4; grid-row:1; }
.d-orders { grid-column:1 / -1; grid-row:2; overflow-x:auto; }

/* Kundsida: smal kolumn till vänster, resten till höger */
.cust { display:grid; grid-template-columns:340px minmax(0, 1fr); gap:var(--gap); align-items:start; }
.cust-side { position:sticky; top:20px; }
.cust-side .card, .cust-main .card { margin-bottom:var(--gap); }
.cust-main .card:last-child, .cust-side .card:last-child { margin-bottom:0; }
.cust-side dl.kv { grid-template-columns:1fr; gap:2px 0; }
.cust-side dl.kv dt { margin-top:12px; font-size:13px; } .cust-side dl.kv dd { word-break:break-word; }
.cust-side table.plain thead { display:none; }
.cust-side table.plain tr { display:block; padding:12px 0; border-bottom:1px solid var(--line); } .cust-side table.plain tr:last-child { border:0; }
.cust-side table.plain td { display:block; padding:0 0 2px; border:0; }

@media (max-width:1320px) {
  .dash { display:block; } .dash .card { margin-bottom:var(--gap); }
  .cust { display:block; } .cust-side { position:static; }
}
@media (max-width:900px) {
  .shell { display:block; }
  .top { position:static; height:auto; flex-direction:row; flex-wrap:wrap; align-items:center; padding:12px 16px; gap:8px 16px; }
  .top nav { flex-direction:row; flex-wrap:wrap; gap:0 4px; flex:none; } .nav-group { flex-direction:row; flex-wrap:wrap; } .nav-group + .nav-group { padding:0; border:0; }
  .top nav a { padding:8px 10px; } .side-foot { flex-direction:row; align-items:center; margin-left:auto; padding:0; } .side-foot .ver { display:none; } .theme-toggle button span { display:none; } .theme-toggle button { padding:7px 9px; }
  .stage { padding:0 16px 24px; } .topbar { margin:0 -16px 24px; padding:0 16px; height:64px; } .today { display:none; }
  .kpis { grid-template-columns:1fr 1fr; }
}
.stage > main { max-width:none; width:100%; }
.d-orders .pill { white-space:normal; display:inline-block; text-align:right; line-height:1.3; max-width:100%; }
table.orders td, table.orders th { padding-right:16px; }
table.orders td:last-child, table.orders th:last-child { padding-right:0; }
.d-orders .page-head.tight { align-items:baseline; }

/* Detaljer */
input[type=checkbox], input[type=radio] { accent-color:var(--btn-primary); }
input[type=file] { padding:6px; }
input[type=file]::file-selector-button { background:var(--active-bg); color:var(--ink); border:1px solid var(--file-btn-border); border-radius:8px; padding:6px 14px; margin-right:12px; font:inherit; cursor:pointer; }
input[type=file]::file-selector-button:hover { background:var(--file-btn-hover); }
table.acts { table-layout:fixed; }
table.acts .c-due { width:150px; } table.acts .c-target { width:24%; } table.acts .c-act { width:240px; }

@media (max-width:900px) {
  table.acts { table-layout:auto; }
  table.plain { display:block; overflow-x:auto; }
  table.plain td, table.plain th { white-space:nowrap; }
  table.plain td:nth-child(2) { white-space:normal; min-width:200px; }
  .kpi b { font-size:20px; white-space:normal; }
  .page-head { flex-wrap:wrap; gap:12px; }
}

/* Kundsidan: alla åtgärder på en rad under rubriken */
.page-head + .cust-bar { margin-top:-6px; }
.cust-bar { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:12px; margin:0 0 var(--gap); padding:12px 14px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); }
.cust-bar .bar-new, .cust-bar .bar-manage { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.cust-bar form { margin:0; }

/* Kalender */
.cal-nav { display:flex; align-items:center; gap:12px; margin:0 0 14px; }
.cal-nav h2 { margin:0 8px; min-width:11ch; text-align:center; font-size:20px; }
.cal { border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; background:var(--surface); }
.cal-row { display:grid; grid-template-columns:44px repeat(7, minmax(0, 1fr)); }
.cal-row + .cal-row { border-top:1px solid var(--line); }
.cal-head { background:var(--cal-head-bg); color:var(--muted); font-size:13px; font-weight:500; }
.cal-head span { padding:9px 10px; }
.wk { color:var(--faint); font-size:12px; padding:9px 0 0 12px; }
.cal-head .wk { padding:9px 0 9px 12px; }
.cal-day { min-height:112px; padding:6px 6px 8px; border-left:1px solid var(--line); display:flex; flex-direction:column; gap:4px; min-width:0; }
.cal-day.we { background:var(--cal-weekend); }
.cal-day.out { background:var(--cal-out); }
.cal-day.out .num { color:var(--num-out); }
.cal-day .num { align-self:flex-start; min-width:26px; height:26px; line-height:26px; text-align:center; border-radius:13px; color:var(--ink-soft); text-decoration:none; font-size:13.5px; font-weight:500; }
.cal-day .num:hover { background:var(--active-bg); color:var(--head); }
.cal-day.today .num { background:var(--btn-primary); color:var(--on-accent); }
.chip { display:block; padding:3px 8px; border-radius:7px; font-size:12.5px; line-height:1.35; text-decoration:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; border-left:3px solid transparent; }
.chip b { font-weight:600; }
.chip.k-measurement { background:var(--k-measurement-bg); color:var(--chip-measurement-ink); border-left-color:var(--k-measurement); }
.chip.k-installation { background:var(--k-installation-bg); color:var(--chip-installation-ink); border-left-color:var(--k-installation); }
.chip.k-other { background:var(--k-other-bg); color:var(--chip-other-ink); border-left-color:var(--k-other); }
.chip:hover { filter:brightness(1.2); text-decoration:none; }
.chip.done { opacity:.55; text-decoration:line-through; }
.cal-day .more { font-size:12px; color:var(--muted); padding:0 8px; }
.cal-legend { margin:12px 0 var(--gap); display:flex; flex-wrap:wrap; gap:8px 12px; align-items:center; }
.chip-kind { display:inline-block; font-size:12px; font-weight:500; padding:1px 9px; border-radius:99px; border:1px solid transparent; }
.chip-kind.k-measurement { background:var(--k-measurement-bg); color:var(--k-measurement); }
.chip-kind.k-installation { background:var(--k-installation-bg); color:var(--k-installation); }
.chip-kind.k-other { background:var(--k-other-bg); color:var(--k-other); }
table.appts .c-when { width:150px; } table.appts .c-act { width:250px; }
table.appts tr.cancelled td { opacity:.6; } table.appts tr.done td b { color:var(--muted); }
.field select { width:100%; }

/* Minikalender på översikten */
.mini-nav { display:flex; align-items:center; gap:10px; margin:0 0 10px; }
.mini-nav a:first-child, .mini-nav a:nth-child(3) { width:28px; height:28px; line-height:26px; text-align:center; border-radius:8px; border:1px solid var(--btn-border); background:var(--btn-bg); text-decoration:none; color:var(--ink); }
.mini-nav a:hover { background:var(--btn-hover); }
.mini-nav b { flex:1; text-align:center; font-weight:600; color:var(--head); }
.mini-row { display:grid; grid-template-columns:26px repeat(7, 1fr); align-items:center; text-align:center; }
.mini-head { color:var(--muted); font-size:12px; margin-bottom:2px; }
.mini .wk { padding:0; font-size:11px; text-align:left; }
.md { display:block; margin:2px auto; width:32px; height:32px; line-height:32px; border-radius:16px; font-size:13.5px; color:var(--ink-soft); text-decoration:none; position:relative; }
.md.out { color:var(--num-out); }
.md.today { box-shadow:inset 0 0 0 1.5px var(--btn-primary); }
.md.has { background:var(--k-measurement-bg); color:var(--head); font-weight:600; }
.md.has:hover { filter:brightness(1.25); }
.d-cal h3 { margin:16px 0 8px; }
ul.upcoming { list-style:none; margin:0; padding:0; }
ul.upcoming li { padding:9px 0; border-top:1px solid var(--line); display:flex; flex-wrap:wrap; align-items:baseline; gap:2px 10px; }
ul.upcoming li:first-child { border-top:0; }
ul.upcoming .when { color:var(--head); min-width:92px; }
ul.upcoming .when b { font-weight:600; }

@media (max-width:1320px) { .d-cal { grid-column:auto; grid-row:auto; } }
@media (max-width:900px) {
  .cal-row { grid-template-columns:30px repeat(7, minmax(0, 1fr)); }
  .cal-day { min-height:72px; padding:4px 3px; } .chip { font-size:11px; padding:2px 4px; } .chip b { display:none; }
  .cal-head span { padding:8px 2px; font-size:12px; } .wk { padding-left:6px; }
}
table.appts .c-when { width:210px; } table.appts .c-when .small { white-space:nowrap; }
.deliver-form { margin:0; }

/* Nyckeltal + försäljningsdiagram: tre kolumner, diagrammet sträcker sig över två rader till höger om de två nedre nyckeltalen */
.kpis > .kpi:nth-child(4) { grid-column:1; grid-row:2; }
.kpis > .kpi:nth-child(5) { grid-column:1; grid-row:3; }
.kpi-chart { grid-column:2 / span 2; grid-row:2 / span 2; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:16px 20px 12px; min-width:0; }
.kc-head { display:flex; flex-wrap:wrap; align-items:baseline; justify-content:space-between; gap:6px 18px; margin:0 0 6px; }
.kc-head h2 { margin:0; font-size:16px; }
.legend { display:flex; flex-wrap:wrap; gap:4px 16px; list-style:none; margin:0; padding:0; font-size:13px; color:var(--ink-soft); }
.legend .sw { display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:6px; }
.sw.this, .bar.this { fill:var(--btn-primary); background:var(--btn-primary); }
.sw.prev, .bar.prev { fill:var(--muted-2); background:var(--muted-2); opacity:.6; }
.sales-chart { display:block; width:100%; height:auto; }
.sales-chart .grid { stroke:var(--line-soft); stroke-width:1; }
.sales-chart .tick { fill:var(--muted); font-size:11px; font-family:var(--font-body); }
.sales-chart .cnt { font-size:11px; font-family:var(--font-body); font-weight:600; }
.sales-chart .cnt-this { fill:var(--btn-primary-hover); }
.sales-chart .cnt-prev { fill:var(--muted-2); font-weight:400; }
.sales-chart .cnt-sep { fill:var(--faint); font-weight:400; }
.sales-chart .hit { fill:transparent; }
.sales-chart .hit:hover { fill:var(--nav-hover); }
.kc-note { margin:2px 0 0; font-size:12px; color:var(--muted); }
.kc-note .cnt-this { color:var(--btn-primary-hover); font-weight:600; }
.kc-table { margin-top:6px; font-size:13px; }
.kc-table summary { cursor:pointer; color:var(--muted); }
.kc-table table { margin-top:8px; }
@media (max-width:1100px) {
  .kpis > .kpi:nth-child(4), .kpis > .kpi:nth-child(5) { grid-column:auto; grid-row:auto; }
  .kpi-chart { grid-column:1 / -1; grid-row:auto; }
}

a.kpi { color:inherit; text-decoration:none; }
a.kpi:hover { border-color:var(--accent); }
.tabs { display:flex; gap:8px; margin:0 0 var(--gap); }
.close-form { display:flex; flex-direction:column; gap:6px; align-items:stretch; width:150px; margin:0 0 0 auto; }
.close-form input[name="reason"] { width:100%; box-sizing:border-box; padding:6px 9px; font-size:13px; }
.close-form .btn { width:100%; justify-content:center; white-space:nowrap; }
.offers-open td { vertical-align:middle; }
.offers-open .sub { font-size:12.5px; color:var(--muted); margin-top:2px; }
.offers-open td:nth-child(2) { min-width:140px; }

.field > .label { display:block; font-weight:600; margin-bottom:4px; }
.seg { display:inline-flex; gap:6px; padding:4px; border:1px solid var(--line); border-radius:10px; background:var(--surface-2); }
.seg label { color:var(--ink); display:flex; align-items:center; gap:7px; padding:7px 14px; border-radius:7px; cursor:pointer; font-weight:500; margin:0; }
.seg label:has(input:checked) { background:var(--accent-soft); color:var(--ink); box-shadow:inset 0 0 0 1px var(--accent); }
.seg input { width:auto; margin:0; accent-color:var(--accent); }
[hidden] { display:none !important; }
.contact-box { border:1px solid var(--line); border-radius:10px; padding:12px 16px 16px; margin:4px 0; }
.contact-box legend { padding:0 8px; font-weight:600; }

/* Innehållet centreras på breda skärmar: kantmarginalen är minst 40 px och växer när fönstret är bredare än 1600 px. Sökraden och dess linje går över hela bredden. */
.stage { max-width:none; padding:0 0 32px; }
.stage > .topbar { margin:0 0 34px; padding:0 var(--gutter); }
.stage > main { padding:0 var(--gutter); }
@media (max-width:900px) {
  .stage { --gutter:16px; padding:0 0 24px; }
  .stage > .topbar { margin:0 0 24px; }
}

/* Försäljningsstatistik: fyra nyckeltal i rad */
.stat-tiles { display:grid; grid-template-columns:repeat(4, minmax(0, 1fr)); gap:var(--gap); margin:0 0 var(--gap); }
.stat-tile { background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:18px 20px; display:grid; gap:4px; }
.stat-tile span { color:var(--muted); font-size:13px; line-height:1.3; }
.stat-tile b { font-size:26px; font-weight:600; color:var(--head); line-height:1.15; white-space:nowrap; }
.stat-tile small { color:var(--muted); font-size:13px; }
.stat-table tfoot td { border-top:2px solid var(--total-line); }
@media (max-width:1100px) { .stat-tiles { grid-template-columns:repeat(2, minmax(0, 1fr)); } }
@media (max-width:560px) { .stat-tiles { grid-template-columns:1fr; } }
.stat-table th.right { text-align:right; }
.table-scroll { overflow-x:auto; }

/* Inställningar: startsida med knappar per avsnitt, och delsidor med sidomeny */
.set-heading { margin:28px 0 12px; font-size:13px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--muted); }
.set-tiles { display:grid; grid-template-columns:repeat(auto-fill, minmax(380px, 1fr)); gap:var(--gap); }
.set-tile { display:grid; grid-template-columns:44px minmax(0, 1fr) auto; align-items:center; gap:14px; padding:16px 18px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); color:inherit; text-decoration:none; }
.set-tile:hover { background:var(--surface-2); border-color:var(--btn-border); }
.set-ico { display:grid; place-items:center; width:44px; height:44px; border-radius:50%; background:var(--kpi-icon-bg); color:var(--accent); }
.set-ico .ico, .set-h-ico { width:22px; height:22px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.set-txt { display:grid; gap:3px; min-width:0; }
.set-txt b { font-weight:600; color:var(--head); font-size:15px; }
.set-txt small { color:var(--muted); font-size:13px; line-height:1.4; }
.set-go { color:var(--faint); font-size:24px; line-height:1; }
.set-tile:hover .set-go { color:var(--accent); }
.set-layout { display:grid; grid-template-columns:260px minmax(0, 1fr); gap:var(--gap); align-items:start; margin-top:8px; }
.set-nav { display:flex; flex-direction:column; gap:2px; background:var(--surface); border:1px solid var(--line); border-radius:var(--radius); padding:12px; position:sticky; top:16px; }
.set-nav a { display:flex; align-items:center; gap:10px; padding:9px 10px; border-radius:8px; color:var(--nav-ink); text-decoration:none; font-size:14px; line-height:1.3; }
.set-nav a:hover { background:var(--nav-hover); }
.set-nav a.on { background:var(--active-bg); color:var(--head); }
.set-nav .ico { width:18px; height:18px; flex:none; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.set-nav a.on .ico { color:var(--accent); }
.set-nav .set-back { color:var(--muted); font-size:13px; padding:4px 10px 10px; }
.set-group { margin:12px 10px 4px; font-size:11px; font-weight:600; letter-spacing:.06em; text-transform:uppercase; color:var(--faint); }
.set-h-ico { vertical-align:-4px; margin-right:10px; color:var(--accent); }
.set-actions { display:flex; justify-content:flex-end; gap:10px; }
@media (max-width:900px) { .set-layout { grid-template-columns:1fr; } .set-nav { position:static; } }
.opt-table input[name^="opt_label"] { min-width:15em; }
.opt-table select { min-width:11em; }

/* Inloggning, konto och användaradministration */
.auth-body { min-height:100vh; display:grid; place-items:center; background:var(--bg); }
.auth-wrap { width:min(440px, 100% - 32px); padding:32px 0; }
.auth-brand { display:flex; align-items:center; gap:10px; margin:0 0 18px 4px; color:var(--head); font-weight:600; font-size:17px; }
.auth-brand b { color:var(--accent); font-weight:600; }
.auth-card { padding:28px 30px; }
.auth-card h1 { margin:0 0 14px; font-size:24px; }
.auth-card .field { margin-bottom:14px; }
.auth-card .actions { margin-top:18px; }
.auth-card .btn.primary { width:100%; justify-content:center; }
.who { display:flex; align-items:center; justify-content:space-between; gap:10px; padding:10px 0 0; border-top:1px solid var(--line); }
.who-name { display:grid; min-width:0; color:var(--ink-soft); text-decoration:none; font-size:13px; line-height:1.3; }
.who-name small { color:var(--faint); font-size:12px; }
.who .btn { padding:5px 10px; font-size:12px; }
.center { text-align:center; }
.lv { display:inline-block; min-width:54px; padding:2px 8px; border-radius:999px; font-size:12px; background:var(--neutral-soft); color:var(--muted-2); }
.lv.lv1 { background:var(--info-soft); color:var(--info); }
.lv.lv2 { background:var(--ok-soft); color:var(--ok); }
.perm-table { margin-top:18px; }
.perm-table td, .perm-table th { vertical-align:middle; }
.perm-table input[type=radio] { width:18px; height:18px; }
.role-table { min-width:900px; }
.role-table th:first-child, .role-table td:first-child { min-width:240px; }
.role-table th.center { min-width:84px; font-size:12px; line-height:1.25; }
.user-table td:first-child { white-space:nowrap; }
.temp-pw { display:inline-block; padding:10px 16px; border:1px dashed var(--btn-border); border-radius:8px; background:var(--input-bg); color:var(--head); font-size:20px; letter-spacing:.06em; user-select:all; }
