/* Insyn — always light, in the console's colours (app/public/index.html :root): paper, white
   panels, grey lines, ink text, red #DF1016 as the brand. No dark mode: Niklas never uses it.
   Charts use the same palette: the brand in focus in red, everyone else in grey, ordered parts on a
   grey-to-ink ramp, amber only for the "tunt underlag" warning. Checked with the dataviz palette
   validator: red vs grey ΔE 27 (normal) / 18 (deutan); the ink ramp passes the ordinal checks. */
:root {
  color-scheme: light;
  --red: #DF1016;
  --red-ink: #B80D12;
  --page: #F6F6F4;
  --card: #FDFDFB;
  --panel2: #EDEDE9;
  --ink: #141414;
  --ink-2: #4A4A4A;
  --muted: #6B6B6B;
  --line: #E4E4E1;
  --hover: rgba(20, 20, 20, .05);
  --grid: #E4E4E1;
  --axis: #BDBDB8;
  --own: #DF1016;
  --other: #A8A7A2;
  --whisker: #4A4A4A;
  --warn: #B26B00;
  --ramp-1: #A8A7A2; --ramp-2: #85847F; --ramp-3: #6B6B6B; --ramp-4: #4A4A4A; --ramp-5: #141414;
  --shadow: 0 1px 2px rgba(20, 20, 20, .05), 0 4px 16px rgba(20, 20, 20, .04);
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font: 400 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: "Inter Tight", Inter, system-ui, sans-serif; letter-spacing: -.01em; margin: 0; }
a { color: inherit; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 0 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); font-weight: 600; font-size: 14px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--hover); }
.btn-red { background: var(--red); border-color: var(--red); color: #fff; }
.btn-red:hover { background: var(--red-ink); border-color: var(--red-ink); }
.btn-quiet { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }
.linkbtn { border: 0; background: none; padding: 0; color: var(--ink-2); font-weight: 600; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- header ---------- */
.top { background: var(--card); border-bottom: 1px solid var(--line); border-top: 4px solid var(--red); }
.top-in { display: flex; align-items: center; justify-content: space-between; min-height: 60px; gap: 12px; }
.lockup { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: "Inter Tight", Inter, sans-serif; font-weight: 800; font-size: 18px; }
.lockup svg { width: 22px; height: 24px; display: block; }
.lockup .product { font-weight: 700; color: var(--red); }
.who { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--ink-2); min-width: 0; }
.who .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.pill-red { border-color: var(--red); color: var(--red); }

/* ---------- login / welcome ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; border-top: 4px solid var(--red); }
.auth-card { width: 100%; max-width: 400px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-card .lockup { margin-bottom: 28px; }
.auth-card h1 { font-size: 28px; font-weight: 800; }
.auth-card .lead { color: var(--ink-2); margin: 8px 0 22px; }
.field { display: grid; gap: 6px; margin-bottom: 14px; }
.field label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field input, .field select, .inline input, .inline select { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.auth-card .btn-red { width: 100%; justify-content: center; min-height: 44px; margin-top: 6px; }
.err { color: var(--red); font-size: 14px; margin: 10px 0 0; min-height: 1em; }
.note { color: var(--muted); font-size: 13px; margin: 14px 0 0; }

/* ---------- board list ---------- */
.page { padding: 28px 16px 64px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { font-size: 30px; font-weight: 800; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.boards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.boards a { display: block; text-decoration: none; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.boards a:hover { border-color: var(--ink-2); }
.boards h2 { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.boards .meta { color: var(--muted); font-size: 13px; }
.boards .pill { margin-top: 12px; }
.empty-state { color: var(--ink-2); background: var(--card); border: 1px dashed var(--line); border-radius: var(--radius); padding: 28px; }

/* ---------- board ---------- */
.board-head { display: grid; gap: 6px; margin-bottom: 14px; }
.back { font-size: 14px; color: var(--ink-2); text-decoration: none; }
.back:hover { text-decoration: underline; }
.title-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: space-between; }
.title-row h1 { font-size: 28px; font-weight: 800; }
.title-row .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.board-meta { color: var(--muted); font-size: 13px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 0 12px; border-top: 1px solid var(--line); margin-top: 6px; }
.filters .lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 2px; background: var(--card); }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--card); }
.banner { background: var(--card); border: 1px solid var(--red); color: var(--ink); border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.saving { font-size: 12px; color: var(--muted); }

.grid-stack { margin: 0 -6px; }
.grid-stack > .grid-stack-item > .grid-stack-item-content { overflow: hidden; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); display: flex; flex-direction: column; }
.card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 4px 8px; padding: 12px 12px 4px 14px; }
.card-head > div:first-child { flex: 1 1 170px; min-width: 0; }
.can-edit .card-head { cursor: grab; }
.card-head h3 { font-size: 15px; font-weight: 700; line-height: 1.3; }
.card-head .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.card-tools { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.tool { border: 0; background: transparent; border-radius: 6px; padding: 4px 7px; font-size: 12px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.tool:hover, .tool[aria-pressed="true"], .tool[aria-expanded="true"] { background: var(--hover); color: var(--ink); }
.tool-select { border: 1px solid var(--line); border-radius: 6px; padding: 2px 4px; font-size: 12px; background: var(--card); }
.card-body { position: relative; flex: 1; min-height: 0; padding: 4px 14px 0; }
.card-body.loading > :not(.card-info) { opacity: .45; transition: opacity .2s; }
.card-chart { position: absolute; inset: 4px 14px 0; display: flex; flex-direction: column; }
.card-info { position: absolute; inset: 0 8px 0; background: var(--card); padding: 6px 6px 10px; overflow: auto; font-size: 13px; color: var(--ink-2); z-index: 2; }
.card-info strong { display: block; color: var(--ink); margin-bottom: 6px; }
.card-foot { display: flex; align-items: center; gap: 8px; padding: 8px 14px 11px; font-size: 12px; color: var(--muted); border-top: 1px solid var(--line); margin-top: 6px; min-height: 36px; }
.card-foot .basis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-error { color: var(--ink-2); font-size: 13px; padding: 12px 0; }
.grade { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.grade::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }
.grade-tunt::before { background: var(--warn); }
.grade-dold::before { background: transparent; border: 1.5px solid var(--muted); width: 7px; height: 7px; }

/* ---------- charts ---------- */
.ins-svg { display: block; overflow: visible; }
.ins-grid { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.ins-base { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.ins-tick { font-size: 11px; fill: var(--muted); font-variant-numeric: tabular-nums; }
.ins-cat { font-size: 11px; fill: var(--ink-2); }
.ins-cat-own { fill: var(--ink); font-weight: 700; }
.ins-val { font-size: 11px; fill: var(--ink); font-weight: 600; }
.ins-val-none { fill: var(--muted); font-weight: 400; }
.ins-own { fill: var(--own); }
.ins-other { fill: var(--other); }
.ins-none { stroke: var(--muted); stroke-width: 2; }
.ins-whisker { stroke: var(--whisker); stroke-width: 1.25; }
.ins-hit { outline: none; cursor: default; }
.ins-hit:hover, .ins-hit:focus { fill: var(--hover); }
.ins-seg { stroke: var(--card); stroke-width: 2; outline: none; }
.ins-seg:hover, .ins-seg:focus { opacity: .82; }
.ins-ramp-1 { fill: var(--ramp-1); background: var(--ramp-1); }
.ins-ramp-2 { fill: var(--ramp-2); background: var(--ramp-2); }
.ins-ramp-3 { fill: var(--ramp-3); background: var(--ramp-3); }
.ins-ramp-4 { fill: var(--ramp-4); background: var(--ramp-4); }
.ins-ramp-5 { fill: var(--ramp-5); background: var(--ramp-5); }
.ins-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12px; color: var(--ink-2); padding-bottom: 6px; }
.ins-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.ins-swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0; }
.ins-swatch-own { background: var(--own); }
.ins-swatch-other { background: var(--other); }
.ins-donut { display: flex; flex-direction: column; align-items: center; gap: 10px; height: 100%; }
.ins-donut.ins-donut-side { flex-direction: row; justify-content: center; gap: 16px; }
.ins-donut-name { font-size: 13px; font-weight: 700; fill: var(--ink); }
.ins-donut-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 10px auto auto; gap: 6px 8px; align-items: center; font-size: 13px; white-space: nowrap; }
.ins-donut-list li { display: contents; }
.ins-donut-list strong { text-align: right; }
.ins-donut-label { color: var(--ink-2); }
.ins-donut-list strong { font-variant-numeric: tabular-nums; }
.ins-kpi { display: flex; flex-direction: column; justify-content: center; height: 100%; gap: 4px; }
.ins-kpi-label { font-size: 13px; color: var(--ink-2); }
.ins-kpi-value { font-size: 52px; line-height: 1.05; font-weight: 700; letter-spacing: -.02em; }
.ins-kpi-compare { font-size: 13px; color: var(--muted); }
.ins-table-wrap { overflow: auto; height: 100%; }
.ins-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ins-table th { text-align: left; font-weight: 600; color: var(--ink-2); padding: 6px 8px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--card); }
.ins-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.ins-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ins-table tr.own td { font-weight: 700; }
.ins-empty { color: var(--muted); font-size: 13px; }
.ins-tip { position: fixed; z-index: 1000; pointer-events: none; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 24px rgba(20, 20, 20, .1); padding: 8px 10px; font-size: 12px; max-width: 280px; }
.ins-tip-title { font-weight: 600; color: var(--ink-2); margin-bottom: 4px; }
.ins-tip-row { display: flex; align-items: center; gap: 8px; }
.ins-tip-row strong { font-size: 14px; }
.ins-tip-label { color: var(--ink-2); }
.ins-tip-note { color: var(--muted); margin-top: 2px; }
.ins-key { width: 12px; height: 2px; border-radius: 1px; flex-shrink: 0; }
.ins-key-own { background: var(--own); }
.ins-key-other { background: var(--other); }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--card); color: var(--ink); width: min(560px, calc(100vw - 32px)); box-shadow: 0 12px 40px rgba(20, 20, 20, .12); }
dialog.wide { width: min(980px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(246, 246, 244, .8); backdrop-filter: blur(2px); }
.dlg { padding: 22px 22px 18px; display: grid; gap: 14px; max-height: calc(100vh - 64px); overflow: auto; }
.dlg h2 { font-size: 21px; font-weight: 800; }
.dlg h3 { font-size: 14px; font-weight: 700; color: var(--ink-2); font-family: Inter, sans-serif; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.inline input[type="email"], .inline input[type="text"] { flex: 2 1 180px; width: auto; }
.inline select { flex: 1 1 130px; width: auto; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.people li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.people .who-col { flex: 1 1 200px; min-width: 0; }
.people .who-col div { overflow: hidden; text-overflow: ellipsis; }
.people .email { font-size: 13px; color: var(--muted); }
.people select { min-height: 34px; padding: 4px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.invite-box { background: var(--page); border: 1px solid var(--line); border-radius: 10px; padding: 12px; display: grid; gap: 8px; font-size: 14px; }
.invite-box input { width: 100%; min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font-size: 13px; }
.hint { font-size: 13px; color: var(--muted); margin: 0; }
.mail-box { border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; background: var(--page); }
.mail-box .field { margin: 0; }
.mail-to { font-size: 14px; color: var(--ink-2); }
.field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); font: inherit; font-size: 14px; line-height: 1.5; resize: vertical; }
.ok { color: var(--ink); font-size: 14px; font-weight: 600; margin: 0; min-height: 1em; }
.add-grid { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 16px; }
.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; align-content: start; }
.qlist label { display: block; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; cursor: pointer; }
.qlist input { position: absolute; opacity: 0; pointer-events: none; }
.qlist input:checked + label { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.qlist input:focus-visible + label { outline: 2px solid var(--red); outline-offset: 2px; }
.qlist strong { display: block; font-size: 14px; }
.qlist span { font-size: 12px; color: var(--muted); }
.qconf { display: grid; gap: 12px; align-content: start; min-width: 0; }
.preview { border: 1px solid var(--line); border-radius: var(--radius); height: 300px; position: relative; padding: 10px 12px; }
.preview .card-chart { inset: 10px 12px; }
.def { font-size: 13px; color: var(--ink-2); margin: 0; }
.versions { list-style: none; margin: 0; padding: 0; }
.versions li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }

@media (max-width: 760px) {
  .add-grid { grid-template-columns: 1fr; }
  .title-row h1, .page-head h1 { font-size: 24px; }
  .who .name { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
