/* ------------------------------------------------------------------ tokens */
:root {
  --accent: #2a50bb;            /* overridden from Admin -> Utseende */
  --accent-ink: #ffffff;
  --accent-soft: color-mix(in srgb, var(--accent) 10%, white);
  --accent-line: color-mix(in srgb, var(--accent) 35%, white);
  --accent-strong: color-mix(in srgb, var(--accent) 80%, black);

  --bg: #ffffff;
  --side: #fafafa;
  --panel: #ffffff;
  --subtle: #f7f7f6;
  --ink: #171717;
  --ink-2: #404040;
  --muted: #737373;
  --line: #ebebea;
  --line-strong: #dcdcda;

  --ok: #15803d;   --ok-soft: #ecfdf3;
  --bad: #c2410c;  --bad-soft: #fff4ed;
  --warn: #a16207; --warn-soft: #fefce8;
  --info: #1d4ed8; --info-soft: #eff6ff;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 1px 3px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
  --side-w: 256px;
  --rail-w: 64px;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "cv11", "ss01";
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); }
body { font-size: 14px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 600; }
h2 { font-size: 16px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mono { font-family: "JetBrains Mono", ui-monospace, Menlo, monospace; font-size: 12.5px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.mobile-only { display: none !important; }

/* ------------------------------------------------------------------ icons */
.ic { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ic svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* ------------------------------------------------------------------ shell */
.shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar { width: var(--side-w); flex: none; background: var(--side); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; transition: width .18s ease; overflow: hidden; }
.sb-brand { display: flex; align-items: center; gap: 10px; min-height: 76px; padding: 14px 16px; text-decoration: none;
  border-bottom: 1px solid var(--line); }
.sb-brand .brand-logo { display: block; max-height: 48px; max-width: 100%; object-fit: contain; object-position: left center; }
.sb-brand .brand-name { font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; flex: none;
  background: var(--accent); color: var(--accent-ink); font-size: 17px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.sb-group { font-size: 12px; font-weight: 500; color: var(--muted); padding: 14px 10px 6px; white-space: nowrap; }
.sb-group:first-child { padding-top: 4px; }
.sb-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); text-decoration: none; font: inherit; font-size: 14px; background: none; border: none; cursor: pointer;
  white-space: nowrap; text-align: left; }
.sb-item:hover { background: #f0f0ef; color: var(--ink); }
.sb-item.active { color: var(--accent-strong); background: var(--accent-soft); font-weight: 500; }
.sb-item.active .ic { color: var(--accent); }
.sb-item .count { margin-left: auto; background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 600;
  border-radius: 99px; padding: 1px 7px; }
.sb-foot { border-top: 1px solid var(--line); padding: 10px; }
.sb-user { display: flex; align-items: center; gap: 10px; padding: 6px 10px 10px; min-width: 0; }
.sb-user .who { min-width: 0; }
.sb-user .who div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sb-backdrop { display: none; }

.shell.collapsed .sidebar { width: var(--rail-w); }
.shell.collapsed .sb-label, .shell.collapsed .sb-group, .shell.collapsed .brand-name,
.shell.collapsed .sb-user .who, .shell.collapsed .sb-item .count { display: none; }
.shell.collapsed .sb-brand { justify-content: center; padding: 16px 8px; }
/* collapsed rail: show only the left, square part of the logo (the symbol) */
.shell.collapsed .sb-brand .brand-logo { width: 40px; height: 40px; max-width: none; max-height: none; object-fit: cover; object-position: left center; }
.shell.collapsed .sb-item { justify-content: center; padding: 9px; }
.shell.collapsed .sb-user { justify-content: center; padding: 6px 0 10px; }
.shell.collapsed .sb-group + .sb-item, .shell.collapsed .sb-nav hr { margin-top: 10px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 60px; flex: none; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--bg); }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); min-width: 0; }
.crumbs a { text-decoration: none; } .crumbs a:hover { color: var(--ink); }
.crumbs .ic { width: 14px; height: 14px; color: #a3a3a3; }
.crumbs .here { color: var(--ink); font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.credit-pill { display: inline-flex; align-items: center; gap: 6px; text-decoration: none; border: 1px solid var(--line-strong);
  border-radius: 99px; padding: 5px 12px; font-weight: 500; font-size: 13px; background: #fff; }
.credit-pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: #f0f0ef; border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2); flex: none; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: var(--radius-sm); width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }

#view { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.page { flex: 1; overflow: auto; padding: 32px 40px 56px; }
.page-inner { max-width: 1080px; margin: 0 auto; }
.page-inner.wide { max-width: 1320px; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 28px; }
.page-head .titles { flex: 1; min-width: 0; }
.page-head p { color: var(--muted); margin-top: 4px; }

/* settings rows (title left, card right) */
.set-row { display: grid; grid-template-columns: minmax(200px, 300px) minmax(0, 1fr); gap: 32px; padding: 28px 0; border-top: 1px solid var(--line); }
.set-row:first-of-type { border-top: none; padding-top: 4px; }
.set-head h3 { font-size: 15px; }
.set-head p { color: var(--muted); margin-top: 4px; font-size: 13.5px; }
.set-body > * + * { margin-top: 14px; }

/* ------------------------------------------------------------------ cards & tables */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat span { color: var(--muted); font-size: 13px; }
.stat b { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }

.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list tr:last-child td { border-bottom: none; }
table.list th { font-size: 13px; color: var(--ink-2); font-weight: 500; background: #fff; position: sticky; top: 0; z-index: 1; }
table.list tbody tr:hover td { background: #fafaf9; }
table.list td.mono { color: var(--ink-2); }
table.kv td:first-child { color: var(--muted); width: 160px; }
.num { text-align: right !important; font-variant-numeric: tabular-nums; }
.clickable { cursor: pointer; }

.badge { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: #a3a3a3; }
.badge.requested, .badge.creating { border-color: #fde68a; color: var(--warn); } .badge.requested::before, .badge.creating::before { background: #eab308; }
.badge.queued, .badge.running { border-color: #bfdbfe; color: var(--info); } .badge.queued::before, .badge.running::before { background: #3b82f6; animation: pulse 1.4s infinite; }
.badge.review { border-color: var(--accent-line); color: var(--accent-strong); } .badge.review::before { background: var(--accent); }
.badge.exported, .badge.done { border-color: #bbf7d0; color: var(--ok); } .badge.exported::before, .badge.done::before { background: #22c55e; }
.badge.failed, .badge.rejected, .badge.cancelled { border-color: #fed7aa; color: var(--bad); } .badge.failed::before, .badge.rejected::before { background: #f97316; }
@keyframes pulse { 50% { opacity: .35; } }

.progress { height: 6px; background: #efefee; border-radius: 99px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); transition: width .4s; border-radius: 99px; }

/* ------------------------------------------------------------------ forms */
label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-2); margin-bottom: 6px; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=month], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); font: inherit; font-size: 14px;
  background: #fff; color: var(--ink); transition: border-color .12s, box-shadow .12s; }
textarea { min-height: 120px; font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-group { display: flex; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; background: #fff; }
.input-group span { padding: 9px 12px; background: var(--subtle); color: var(--muted); border-right: 1px solid var(--line-strong); white-space: nowrap; }
.input-group input { border: none; border-radius: 0; }
.input-group:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent); }
.input-group:focus-within input { box-shadow: none; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--ink); font-weight: 400; margin: 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.field { margin-bottom: 14px; }
input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: #fff; cursor: pointer; }

.btn { border: 1px solid var(--line-strong); background: #fff; color: var(--ink); padding: 8px 14px; border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; font-weight: 500; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; justify-content: center;
  text-decoration: none; box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s; white-space: nowrap; }
.btn:hover { background: #fafaf9; border-color: #cfcfcc; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); border-color: #fdba74; }
.btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn.ghost:hover { background: #f4f4f3; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }
.btn .ic { width: 16px; height: 16px; }

.hint { background: var(--accent-soft); color: var(--accent-strong); border: 1px solid var(--accent-line); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
.note { background: var(--bad-soft); color: #9a3412; border: 1px solid #fed7aa; padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; }
.error-box { background: var(--bad-soft); color: #9a3412; border: 1px solid #fed7aa; padding: 10px 14px; border-radius: var(--radius-sm); }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); border: 1px dashed var(--line-strong); border-radius: var(--radius); }

/* ------------------------------------------------------------------ login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--side); }
.login-card { width: 100%; max-width: 400px; padding: 32px; box-shadow: var(--shadow); }
.login-logo { display: flex; justify-content: center; margin-bottom: 20px; }
.login-logo .brand-logo { max-height: 84px; max-width: 100%; object-fit: contain; }
.login-logo .brand-mark { width: 48px; height: 48px; font-size: 24px; border-radius: 12px; }
.login-title { text-align: center; margin-bottom: 24px; }
.login-title h1 { font-size: 20px; }
.login-title p { color: var(--muted); margin-top: 4px; }

/* ------------------------------------------------------------------ map page */
.map-layout { flex: 1; display: grid; grid-template-columns: 360px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--line); overflow: auto; padding: 24px; background: #fff; }
.side h2 { font-size: 17px; }
.map { position: relative; min-height: 300px; }
.map-host { position: absolute; inset: 0; }
.map-search { position: absolute; top: 12px; left: 56px; z-index: 500; display: flex; gap: 6px; width: min(380px, calc(100% - 70px)); }
.map-search input { box-shadow: var(--shadow); border-color: transparent; }
.map-search .btn { box-shadow: var(--shadow); }
.estimate { background: var(--subtle); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px; }
.estimate table { width: 100%; border-collapse: collapse; }
.estimate td { padding: 3px 0; }
.estimate td:last-child { text-align: right; font-weight: 500; font-variant-numeric: tabular-nums; }
.estimate tr.total td { border-top: 1px solid var(--line); padding-top: 8px; font-weight: 600; }

/* ------------------------------------------------------------------ review */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: none; background: none; padding: 9px 12px; font: inherit; font-weight: 500; color: var(--muted);
  cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs .count { font-weight: 500; color: var(--muted); margin-left: 6px; background: #f0f0ef; border-radius: 99px; padding: 0 7px; font-size: 12px; }
.review-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) 440px; min-height: 0; }
.review-main { overflow: auto; padding: 28px 32px; }
.review-map { position: relative; border-left: 1px solid var(--line); }
.review-toolbar { position: sticky; top: -28px; z-index: 5; background: var(--bg); padding: 10px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(176px, 1fr)); gap: 12px; }
.card { background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative; transition: border-color .12s, box-shadow .12s; }
.card:hover { box-shadow: var(--shadow); }
.card.yes { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card.no { opacity: .7; }
.card.focus { box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.card .thumb { aspect-ratio: 1; background: #ececeb center/cover; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.card .meta { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px; font-size: 12.5px; gap: 6px; }
.card .verdict { position: absolute; top: 8px; left: 8px; background: rgba(23, 23, 23, .72); color: #fff; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500; backdrop-filter: blur(4px); }
.card .pick { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(255,255,255,.92); border: 1.5px solid var(--line-strong); font-weight: 700; font-size: 13px; }
.card.yes .pick { background: var(--accent); border-color: var(--accent); color: #fff; }
.export-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 18px; box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ toasts & modal */
.toasts { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 3000; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 400px; font-size: 13.5px; }
.toast.error { background: #9a3412; }
.toast.ok { background: var(--accent-strong); }
.modal { position: fixed; inset: 0; background: rgba(23, 23, 23, .35); display: grid; place-items: center; z-index: 2000; padding: 16px; backdrop-filter: blur(2px); }
.modal-card { background: #fff; border-radius: 14px; padding: 24px; width: min(640px, 100%); max-height: 90vh; overflow: auto; position: relative; box-shadow: var(--shadow); }
.modal-card h2 { margin-bottom: 16px; font-size: 18px; }
.modal-close { position: absolute; top: 12px; right: 14px; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.copy-box { display: flex; gap: 6px; }
.copy-box input { font-family: "JetBrains Mono", monospace; font-size: 12px; }
.logo-preview { display: grid; place-items: center; min-height: 140px; background:
  repeating-conic-gradient(#f4f4f3 0 25%, #fff 0 50%) 0 0 / 16px 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 16px; }
.logo-preview img { max-height: 100px; max-width: 100%; }
details summary { cursor: pointer; font-weight: 500; }

.leaflet-container { font: inherit; }
.pin-mode .leaflet-container { cursor: crosshair; }

/* ------------------------------------------------------------------ responsive */
@media (max-width: 1100px) {
  .set-row { grid-template-columns: 1fr; gap: 14px; }
}
@media (max-width: 900px) {
  .mobile-only { display: grid !important; }
  .sidebar { position: fixed; z-index: 1500; inset: 0 auto 0 0; transform: translateX(-100%); transition: transform .2s ease; width: var(--side-w) !important; }
  .shell.menu-open .sidebar { transform: none; }
  .shell.menu-open .sb-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.3); z-index: 1400; }
  .sb-collapse { display: none !important; }
  .topbar { padding: 0 14px; }
  .credit-pill { padding: 4px 10px; }
  .page { padding: 20px 16px 40px; }
  .map-layout { grid-template-columns: 1fr; grid-template-rows: auto 60vh; overflow: auto; }
  .side { border-right: none; border-bottom: 1px solid var(--line); }
  .review-layout { grid-template-columns: 1fr; grid-template-rows: 38vh minmax(0, 1fr); }
  .review-map { border-left: none; order: -1; border-bottom: 1px solid var(--line); }
  .review-main { padding: 16px; }
  .page-head { flex-direction: column; }
}
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.model-card { padding: 18px; }
table.list th { white-space: nowrap; }

/* map legend: villas scanned by anyone vs. the user's own areas */
.legend { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.legend .swatch { display: inline-block; width: 14px; height: 10px; border-radius: 2px; vertical-align: middle; }
.legend .swatch.scanned { background: rgba(107, 114, 128, .6); border: 1px solid #4b5563; }
.legend .swatch.mine { background: rgba(196, 54, 44, .1); border: 1px solid #c4362c; margin-left: 8px; }

/* scans list: the user's "handled" tick greys the row out */
table.list th.tick, table.list td.tick { width: 72px; text-align: center; }
table.list td.tick input { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
table.list tr.handled td { color: #b4b4b2; background: #f7f7f6; }
table.list tr.handled td b, table.list tr.handled .badge { color: #b4b4b2; border-color: var(--line); font-weight: 500; }
table.list tr.handled .badge::before { background: #d4d4d4; animation: none; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 99px; margin-left: 6px;
  background: var(--ok-soft); color: var(--ok); border: 1px solid #bbf7d0; vertical-align: 1px; }
tr.handled .tag { background: #f4f4f3; color: #a3a3a3; border-color: var(--line); }

.card .why { padding: 0 10px 9px; font-size: 11.5px; color: var(--muted); line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Utan nummer: two upload targets side by side */
.np-uploads { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.drop { display: block; text-align: center; padding: 22px 18px; border-style: dashed; cursor: pointer; transition: background .15s, border-color .15s; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft, #f4f6fb); }
.drop.done b { color: var(--ok); }
.drop .small { margin-top: 6px; }
.np-take label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
