/* HamsterIT – dark, quiet, dense. Monochrome chrome; colour only for state (error, success, focus). */

:root {
  --bg: #0f0f10;
  --sidebar: #0f0f10;
  --panel: #161618;
  --panel-raised: #1c1c1f;
  --hover: #1f1f22;
  --active: #26262a;
  --line: #26262a;
  --line-strong: #34343a;
  --text: #ededef;
  --text-2: #a1a1aa;
  --text-3: #71717a;
  --primary-bg: #ededef;
  --primary-text: #0f0f10;
  --focus: #5b8def;
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.1);
  --green: #4ade80;
  --green-bg: rgba(74, 222, 128, 0.1);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --text-xs: 0.75rem;     /* 12 */
  --text-s: 0.8125rem;    /* 13 */
  --text-m: 0.875rem;     /* 14 */
  --text-l: 1.25rem;      /* 20 */
  --radius: 8px;
  --radius-s: 6px;
  --sidebar-w: 15rem;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 400 var(--text-m)/1.5 var(--font);
  -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
h1 { font-size: var(--text-l); }
h2 { font-size: var(--text-m); }
p { margin: 0 0 0.75rem; }
a { color: var(--text); text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 0.2em; }
a:hover { text-decoration-color: var(--text-2); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
svg.icon { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--panel); color: var(--text); padding: 0.5rem 0.75rem; z-index: 10; }
.skip:focus { left: 0.5rem; }
.js .js-hide { display: none; }
.muted { color: var(--text-2); }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* ---------- Buttons ---------- */
.button, .button-secondary, .button-quiet, .button-danger-quiet {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: inherit; font-size: var(--text-s); font-weight: 500; cursor: pointer; text-decoration: none;
  border-radius: var(--radius-s); height: 2rem; padding: 0 0.75rem; white-space: nowrap;
}
.button { background: var(--primary-bg); color: var(--primary-text); border: 1px solid var(--primary-bg); }
.button:hover { background: #fff; color: var(--primary-text); }
.button-secondary { background: var(--panel-raised); color: var(--text); border: 1px solid var(--line-strong); }
.button-secondary:hover { background: var(--active); }
.button-quiet, .button-danger-quiet { background: none; border: 1px solid transparent; color: var(--text-2); padding: 0 0.5rem; }
.button-quiet:hover { color: var(--text); background: var(--hover); }
.button-danger-quiet { color: var(--red); }
.button-danger-quiet:hover { background: var(--red-bg); }
.button-block { width: 100%; height: 2.375rem; font-size: var(--text-m); }

/* ---------- Forms ---------- */
.form { display: grid; gap: 1rem; }
.form-narrow { max-width: 24rem; }
.form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 1rem; }
.form legend { font-size: var(--text-xs); font-weight: 500; color: var(--text-3); margin-bottom: 0.25rem; padding: 0; }
.form fieldset + fieldset:not(.act-row) { margin-top: 0.5rem; }
.form > .button { justify-self: start; }
.field { display: grid; gap: 0.375rem; }
.field label { font-size: var(--text-s); font-weight: 500; color: var(--text); }
.hint { margin: 0; font-size: var(--text-xs); color: var(--text-3); }
input[type="text"], input[type="email"], input[type="password"], select {
  font: inherit; font-size: var(--text-m); color: var(--text); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--radius-s);
  height: 2.25rem; padding: 0 0.75rem; width: 100%;
}
select { padding-right: 2rem; }
input::placeholder { color: var(--text-3); }
input:hover, select:hover { border-color: #45454c; }
input:focus-visible, select:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.25); }
.has-error input, .has-error select { border-color: var(--red); }
.error-text { margin: 0; font-size: var(--text-xs); color: var(--red); }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.form-inline { display: grid; grid-template-columns: minmax(12rem, 1fr) 11rem auto; gap: 0.75rem; align-items: end; }
.form-inline .button { height: 2.25rem; }

.alert { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248, 113, 113, 0.25); border-radius: var(--radius-s); padding: 0.5rem 0.75rem; font-size: var(--text-s); }
.alert-inset { margin: 0 1rem 1rem; }
.flash { background: var(--green-bg); color: var(--green); border: 1px solid rgba(74, 222, 128, 0.25); border-radius: var(--radius-s); padding: 0.5rem 0.75rem; font-size: var(--text-s); }

/* ---------- Sign-in ---------- */
.auth .auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 3rem 1rem; }
.auth-col { width: 100%; max-width: 22rem; }
.auth-mark { display: flex; justify-content: center; margin-bottom: 1.5rem; }
.auth-col h1 { text-align: center; margin-bottom: 0.375rem; }
.auth-col .lead { text-align: center; color: var(--text-2); font-size: var(--text-s); margin-bottom: 1.5rem; }
.auth-col .form { margin-top: 1.5rem; }
.auth-col .flash, .auth-col .alert { margin-top: 1rem; }
.auth-links { display: grid; gap: 0.5rem; justify-items: center; margin-top: 1.5rem; font-size: var(--text-s); color: var(--text-2); }
.auth-links a { color: var(--text-2); }
.auth-links a:hover { color: var(--text); }
.logo { display: inline-grid; place-items: center; width: 2.25rem; height: 2.25rem; border-radius: 9px; background: var(--primary-bg); color: var(--primary-text); font-weight: 700; font-size: 0.95rem; letter-spacing: -0.04em; }
.logo-s { width: 1.5rem; height: 1.5rem; border-radius: 6px; font-size: 0.7rem; }

/* ---------- Application shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }
.sidebar { background: var(--sidebar); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 0.75rem; position: sticky; top: 0; height: 100vh; }

.switcher { position: relative; margin-bottom: 1rem; }
.switcher > summary, .company-static {
  list-style: none; display: flex; align-items: center; gap: 0.625rem; padding: 0.375rem 0.5rem;
  border-radius: var(--radius-s); cursor: pointer;
}
.company-static { cursor: default; }
.switcher > summary::-webkit-details-marker { display: none; }
.switcher > summary:hover, .switcher[open] > summary { background: var(--hover); }
.company-avatar { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 6px; background: var(--active); border: 1px solid var(--line-strong); font-size: 0.7rem; font-weight: 600; flex: none; }
.company-text { display: grid; min-width: 0; flex: 1; }
.company-name { font-size: var(--text-s); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-role { font-size: var(--text-xs); color: var(--text-3); }
.switcher .chev { color: var(--text-3); }
.switcher-menu { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 5; background: var(--panel-raised); border: 1px solid var(--line-strong); border-radius: var(--radius); padding: 0.25rem; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5); }
.switcher-menu p { margin: 0; padding: 0.375rem 0.5rem 0.25rem; font-size: var(--text-xs); color: var(--text-3); }
.switcher-menu button { all: unset; box-sizing: border-box; display: flex; align-items: center; gap: 0.625rem; width: 100%; padding: 0.375rem 0.5rem; border-radius: var(--radius-s); font-size: var(--text-s); cursor: pointer; }
.switcher-menu button:hover, .switcher-menu button:focus-visible { background: var(--hover); }
.switcher-menu button[aria-current="true"] { color: var(--text); }
.switcher-menu .check { margin-left: auto; color: var(--text-2); }

.nav { display: grid; gap: 1px; }
.nav a { display: flex; align-items: center; gap: 0.625rem; padding: 0.375rem 0.5rem; border-radius: var(--radius-s); color: var(--text-2); text-decoration: none; font-size: var(--text-s); font-weight: 500; }
.nav a:hover { background: var(--hover); color: var(--text); }
.nav a[aria-current="page"] { background: var(--active); color: var(--text); }
.nav-group { margin: 1.25rem 0 0.25rem; padding: 0 0.5rem; font-size: var(--text-xs); color: var(--text-3); }

.me { margin-top: auto; border-top: 1px solid var(--line); padding-top: 0.75rem; display: flex; align-items: center; gap: 0.25rem; }
.me-link { display: flex; align-items: center; gap: 0.625rem; min-width: 0; flex: 1; padding: 0.375rem 0.5rem; border-radius: var(--radius-s); text-decoration: none; color: var(--text); }
.me-link:hover, .me-link[aria-current="page"] { background: var(--hover); }
.me-avatar { display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--active); font-size: 0.7rem; font-weight: 600; flex: none; }
.me-text { display: grid; min-width: 0; }
.me-name, .me-email { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-name { font-size: var(--text-s); font-weight: 500; }
.me-email { font-size: var(--text-xs); color: var(--text-3); }
.me form { margin: 0; }
.icon-button { all: unset; display: inline-grid; place-items: center; width: 2rem; height: 2rem; border-radius: var(--radius-s); color: var(--text-3); cursor: pointer; }
.icon-button:hover { background: var(--hover); color: var(--text); }
.icon-button:focus-visible { outline: 2px solid var(--focus); }

.main { padding: 2.5rem clamp(1rem, 4vw, 3rem) 4rem; width: 100%; max-width: 64rem; margin: 0 auto; }
.main > .flash { margin-bottom: 1.5rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 2rem; }
.page-head p { margin: 0.25rem 0 0; color: var(--text-2); font-size: var(--text-s); }

.section { margin-bottom: 2rem; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; }
.section-head p { margin: 0.2rem 0 0; color: var(--text-2); font-size: var(--text-s); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.panel-flush { padding: 0; overflow: hidden; }
.panel-footer { border-top: 1px solid var(--line); padding: 0.75rem 1rem; display: flex; justify-content: space-between; align-items: center; gap: 1rem; color: var(--text-2); font-size: var(--text-s); }
.panel > :last-child { margin-bottom: 0; }

.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr)); gap: 1rem; }
.overview .panel { display: flex; flex-direction: column; gap: 0.25rem; }
.overview h2 { color: var(--text-2); font-weight: 500; font-size: var(--text-s); }
.overview .value { font-size: var(--text-m); font-weight: 500; }
.overview .panel-actions { margin-top: auto; padding-top: 1rem; }

.details { display: grid; grid-template-columns: 10rem 1fr; gap: 0; margin: 0; }
.details dt, .details dd { padding: 0.75rem 1rem; border-top: 1px solid var(--line); margin: 0; font-size: var(--text-s); }
.details dt:first-of-type, .details dt:first-of-type + dd { border-top: 0; }
.details dt { color: var(--text-2); }
.details dd { overflow-wrap: anywhere; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: var(--text-s); }
.table th, .table td { text-align: left; padding: 0.625rem 1rem; border-top: 1px solid var(--line); vertical-align: middle; }
.table thead th { white-space: nowrap; border-top: 0; font-size: var(--text-xs); font-weight: 500; color: var(--text-3); padding-top: 0.75rem; padding-bottom: 0.5rem; }
.table tbody tr:hover { background: rgba(255, 255, 255, 0.015); }
.table td:first-child { min-width: 13rem; }
.table .actions { text-align: right; white-space: nowrap; width: 1%; }
.cell-strong { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; color: var(--text); }
.cell-sub { display: block; font-size: var(--text-xs); color: var(--text-3); overflow-wrap: anywhere; }
.tag { white-space: nowrap; display: inline-flex; align-items: center; height: 1.25rem; padding: 0 0.4rem; font-size: 0.6875rem; font-weight: 500; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--text-2); }
.row-form { display: flex; gap: 0.5rem; align-items: center; margin: 0; }
.row-form select { width: auto; height: 1.875rem; font-size: var(--text-s); background: transparent; border-color: transparent; padding-left: 0.5rem; }
.row-form select:hover { border-color: var(--line-strong); background: var(--panel-raised); }
.empty { padding: 2rem 1rem; text-align: center; color: var(--text-3); font-size: var(--text-s); }

/* ---------- Registers and sales documents ---------- */
input[type="date"], textarea { font: inherit; font-size: var(--text-m); color: var(--text); background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--radius-s); width: 100%; }
input[type="date"] { height: 2.25rem; padding: 0 0.75rem; color-scheme: dark; }
textarea { padding: 0.5rem 0.75rem; resize: vertical; min-height: 4.5rem; line-height: 1.5; }
textarea:focus-visible, input[type="date"]:focus-visible { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(91, 141, 239, 0.25); }
.has-error textarea, [aria-invalid="true"] { border-color: var(--red) !important; }
.label-like { font-size: var(--text-s); font-weight: 500; }
.check { display: inline-flex; align-items: center; gap: 0.5rem; font-size: var(--text-s); color: var(--text-2); cursor: pointer; }
.check input { width: 1rem; height: 1rem; margin: 0; accent-color: var(--primary-bg); }
.right { text-align: right !important; }
.prewrap { white-space: pre-wrap; }
.back { display: inline-flex; align-items: center; gap: 0.25rem; margin-bottom: 0.5rem; font-size: var(--text-s); color: var(--text-2); text-decoration: none; }
.back:hover { color: var(--text); }
.page-head h1 { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.page-head p { display: flex; align-items: center; gap: 0.5rem; }

.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar form { margin: 0; }
.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }
.tabs a { padding: 0.3rem 0.625rem; border-radius: var(--radius-s); font-size: var(--text-s); font-weight: 500; color: var(--text-2); text-decoration: none; }
.tabs a:hover { color: var(--text); background: var(--hover); }
.tabs a[aria-current="page"] { color: var(--text); background: var(--active); }
.search { position: relative; display: block; width: 16rem; max-width: 100%; color: var(--text-3); }
.search .icon { position: absolute; left: 0.625rem; top: 50%; transform: translateY(-50%); }
.search input { padding-left: 2rem; height: 2rem; font-size: var(--text-s); }

.badge { display: inline-flex; align-items: center; gap: 0.35rem; height: 1.375rem; padding: 0 0.5rem; border-radius: 999px; font-size: var(--text-xs); font-weight: 500; white-space: nowrap; background: var(--active); color: var(--text-2); }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--green-bg); color: var(--green); }
.badge-blue { background: rgba(91, 141, 239, 0.14); color: #8fb0f5; }
.badge-red { background: var(--red-bg); color: var(--red); }
.badge-muted { background: transparent; border: 1px solid var(--line-strong); color: var(--text-3); }

.table-link tbody tr, .table tbody tr:has(.row-link) { cursor: pointer; }
.row-link { text-decoration: none; }
.row-link:hover { text-decoration: underline; }
.table td.num.right, .table th.right { text-align: right; }
.table td:first-child:has(.row-link) { min-width: 8rem; }
.row-error td { border-top: 0; padding-top: 0; }

.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.form-footer, .actions-row, .action-bar { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.actions-row form, .action-bar form, .inline-form { margin: 0; }
.action-bar { justify-content: space-between; margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); }
.notice { background: rgba(91, 141, 239, 0.08); border: 1px solid rgba(91, 141, 239, 0.25); color: var(--text); border-radius: var(--radius-s); padding: 0.5rem 0.75rem; font-size: var(--text-s); }
.links-row { display: flex; gap: 1rem; font-size: var(--text-s); color: var(--text-2); margin: 1rem 0 2rem; }
.links-row:empty { display: none; }
.overview-4 { grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); }
.overview .value.num { font-size: 1.0625rem; }
.overview .muted { margin: 0; font-size: var(--text-xs); }

.table-form td { padding: 0.375rem 0.375rem; }
.table-form td:first-child { padding-left: 1rem; min-width: 11rem; }
.table-form td:last-child { padding-right: 1rem; }
.table-form input, .table-form select { height: 2rem; font-size: var(--text-s); padding: 0 0.5rem; }
.table-form select { padding-right: 1.5rem; }
.table-lines td:nth-child(2) { min-width: 14rem; }
.w-qty, .w-disc { width: 5.5rem; }
.w-unit { width: 4.5rem; }
.w-price { width: 8rem; }
.w-vat { width: 8.5rem; }
.totals { display: grid; grid-template-columns: auto auto; gap: 0.25rem 2rem; margin: 0; min-width: 14rem; }
.totals dt { color: var(--text-2); }
.totals dd { margin: 0; text-align: right; color: var(--text); }
.totals .total { font-weight: 600; color: var(--text); font-size: var(--text-m); padding-top: 0.25rem; }
.contact-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)) auto; gap: 0.75rem; align-items: end; padding: 1rem; border-top: 1px solid var(--line); }
.contact-form .button-secondary { height: 2.25rem; }
.pager { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; margin-top: 1rem; font-size: var(--text-s); }
.pager .muted { margin-right: auto; }

/* ---------- Custom fields ---------- */
.req { color: var(--text-3); font-weight: 400; }
.check-group { border: 0; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.375rem 1rem; }
.check-group legend { padding: 0; margin-bottom: 0.375rem; width: 100%; }
.check-list { display: grid; gap: 0.875rem; }
.check-list .check, .access-grid .check { align-items: flex-start; color: var(--text); }
.check-list .check input, .access-grid .check input { margin-top: 0.15rem; }
.check-hint { display: block; color: var(--text-3); font-size: var(--text-xs); margin-top: 0.125rem; }
.access-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.access-grid fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 0.5rem; align-content: start; }
.access-grid legend { padding: 0; margin-bottom: 0.25rem; }
.static { margin: 0; height: 2.25rem; display: flex; align-items: center; color: var(--text-2); font-size: var(--text-m); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: var(--text-s); }
.flags { display: flex; flex-wrap: wrap; gap: 0.25rem; }
.empty-lead p { margin: 0 0 0.375rem; }
.empty-lead .muted { color: var(--text-3); }
.w-code { width: 14rem; }
.row-ext td { border-top: 0; padding-top: 0; padding-bottom: 0.625rem; }
.ext-inline { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; align-items: center; padding: 0.125rem 0 0.125rem 0.75rem; border-left: 2px solid var(--line-strong); margin-left: 0.125rem; }
.ext-inline .field { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.5rem; }
.ext-inline .field > label, .ext-inline .field > .label-like, .ext-inline .check-group legend { font-size: var(--text-xs); font-weight: 500; color: var(--text-2); white-space: nowrap; }
.ext-inline select, .ext-inline input[type="text"], .ext-inline input[type="date"], .ext-inline input[type="email"], .ext-inline input[type="url"] { width: 12rem; height: 1.875rem; font-size: var(--text-s); padding: 0 0.5rem; }
.ext-inline textarea { width: 20rem; min-height: 2.5rem; font-size: var(--text-s); }
.ext-inline .check-group { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; }
.ext-inline .check-group legend { float: left; margin: 0 0.25rem 0 0; padding: 0; width: auto; }
.ext-inline .check { font-size: var(--text-s); }
.ext-inline .error-text { flex-basis: 100%; }
details.tech { margin-top: 1rem; }
details.tech summary { cursor: pointer; color: var(--text-2); font-size: var(--text-s); }
details.tech pre { margin: 0.75rem 0 0; padding: 0.75rem 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-s); font-size: var(--text-xs); overflow-x: auto; color: var(--text-2); }
[hidden] { display: none !important; }
.overview + .section { margin-top: 2rem; }

/* ---------- Small screens ---------- */
@media (max-width: 52rem) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .nav { min-width: 0; }
  .table-form td:first-child { min-width: 8rem; }
  .sidebar { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .switcher { margin-bottom: 0.5rem; }
  .nav { grid-auto-flow: column; justify-content: start; overflow-x: auto; gap: 0.25rem; }
  .nav-group { display: none; }
  .me { margin-top: 0.5rem; }
  .form-inline, .grid-form, .grid-3, .contact-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .access-grid { grid-template-columns: 1fr; }
  .search { width: 100%; }
  .main { padding-top: 1.5rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* ---- rules (fas 8) ---------------------------------------------------------------------------- */
/* The builder reads as a sentence: När → Om → Gör. The step numbers mark that order. */
.step { display: inline-flex; align-items: center; justify-content: center; width: 1.375rem; height: 1.375rem; margin-right: 0.5rem; border-radius: 50%; border: 1px solid var(--line-strong); font-size: var(--text-xs); font-weight: 600; color: var(--text-2); vertical-align: 0.1em; }
.match-row { display: flex; gap: 1.25rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); font-size: var(--text-s); }
.radio { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; }
.w-op { width: 10rem; }
.table-form tr.has-error td { background: var(--red-bg); }
.panel-hint { margin: 0; padding: 0.625rem 1rem; border-top: 1px solid var(--line); }
.form .act-row { display: grid; grid-template-columns: minmax(10rem, 14rem) repeat(auto-fit, minmax(10rem, 1fr)); gap: 0.75rem; margin: 0; padding: 0.875rem 1rem; border: 0; border-bottom: 1px solid var(--line); }
.form .act-row.has-error { background: var(--red-bg); }
.act-row .act-text { grid-column: span 2; }
.act-row > .error-text { grid-column: 1 / -1; margin: 0; }
.code-input { width: 100%; min-height: 18rem; font-size: var(--text-xs); line-height: 1.55; tab-size: 2; }
.rule-read { display: grid; grid-template-columns: 4rem 1fr; gap: 0.5rem 1rem; margin: 0; }
.rule-read dt { color: var(--text-3); font-size: var(--text-s); padding-top: 0.05rem; }
.rule-read dd { margin: 0; }
.rule-read ul { margin: 0.25rem 0 0; padding-left: 1.1rem; }
.notice-warn { background: rgba(250, 204, 21, 0.07); border-color: rgba(250, 204, 21, 0.25); }
.notice + .notice, .alert + .notice, .notice + .alert { margin-top: 0.5rem; }
.dry-result { font-size: var(--text-l); font-weight: 600; margin: 0 0 0.75rem; font-variant-numeric: tabular-nums; }
.dry-example { padding: 0.75rem 0; border-top: 1px solid var(--line); }
.dry-example p { margin: 0 0 0.25rem; }
.dry-example ul { margin: 0.25rem 0 0; padding-left: 1.1rem; color: var(--text-2); font-size: var(--text-s); }

/* Approvals on a record: the one place a rule asks a person for something. */
.approval { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; padding: 0.875rem 1rem; border-radius: var(--radius); border: 1px solid rgba(250, 204, 21, 0.3); background: rgba(250, 204, 21, 0.06); }
.approval-rejected { border-color: rgba(248, 113, 113, 0.3); background: var(--red-bg); }
.approval-text p { margin: 0; }
.approval-text p + p { margin-top: 0.15rem; }
.approval-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.approval-form input[type="text"] { width: 14rem; }
.inline-actions { display: inline-flex; gap: 0.375rem; margin: 0; }
.rule-meta { display: flex; align-items: center; gap: 0.375rem; flex-wrap: wrap; margin: -0.5rem 0 1rem; font-size: var(--text-s); }
.tag-rule { border-style: dashed; }
.why-link { color: var(--text-3); margin-left: auto; }
.why-link:hover { color: var(--text); }

/* Notifications, the "Varför?" history. */
.nav .count { margin-left: auto; min-width: 1.25rem; height: 1.25rem; padding: 0 0.35rem; border-radius: 999px; background: var(--primary-bg); color: var(--primary-text); font-size: 0.6875rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.feed li:last-child { border-bottom: 0; }
.feed p { margin: 0; }
.feed p + p { margin-top: 0.15rem; }
.feed .dot { flex: none; width: 0.5rem; height: 0.5rem; margin-top: 0.45rem; border-radius: 50%; background: var(--focus); }
.feed-dots li:not(.unread) { padding-left: 2.25rem; }

@media (max-width: 640px) {
  .form .act-row { grid-template-columns: 1fr; }
  .act-row .act-text { grid-column: auto; }
  .rule-form .table-form thead { display: none; }
  .rule-form .table-form tr { display: grid; grid-template-columns: minmax(0, 1fr) 5.5rem; gap: 0.375rem; padding: 0.625rem 1rem; border-bottom: 1px solid var(--line); }
  .rule-form .table-form td, .rule-form .table-form td:first-child, .rule-form .table-form td:last-child { padding: 0; min-width: 0; border: 0; }
  .rule-form .table-form td:last-child { grid-column: 1 / -1; }
  .rule-form .table-form select, .rule-form .table-form input { width: 100%; }
  .rule-read { grid-template-columns: 1fr; gap: 0.15rem; }
  .rule-read dd { margin-bottom: 0.5rem; }
  .approval-form input[type="text"] { width: 100%; }
}

/* ---- reports (fas 9) -------------------------------------------------------------------------- */
.report-list { list-style: none; margin: 0; padding: 0; }
.report-list li { display: flex; align-items: center; gap: 0.75rem; border-bottom: 1px solid var(--line); padding-right: 1rem; }
.report-list li:last-child { border-bottom: 0; }
.report-link { flex: 1; display: grid; gap: 0.1rem; padding: 0.75rem 1rem; color: inherit; text-decoration: none; min-width: 0; }
.report-link:hover { background: var(--hover); }
.report-name { font-weight: 600; }
.report-desc { color: var(--text-2); font-size: var(--text-s); }
.report-meta { color: var(--text-3); font-size: var(--text-xs); }
.crumbs { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 1rem; font-size: var(--text-s); color: var(--text-3); }
.crumbs a { color: var(--text-2); }
.totals-strip { display: flex; flex-wrap: wrap; gap: 0.75rem 2rem; margin: 0 0 1rem; }
.totals-strip dt { color: var(--text-3); font-size: var(--text-xs); }
.totals-strip dd { margin: 0; font-size: var(--text-l); font-weight: 600; }
.report-table td.num, .report-table th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* The chart: one bar per group, labels and values as text so it reads without the bars. */
.chart { margin: 0 0 1rem; }
.chart figcaption { font-size: var(--text-s); color: var(--text-2); margin-bottom: 0.75rem; }
.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.375rem; }
.bars li { display: grid; grid-template-columns: minmax(6rem, 12rem) 1fr minmax(6rem, auto); gap: 0.75rem; align-items: center; font-size: var(--text-s); }
.bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.bar-track { display: block; width: 100%; height: 0.875rem; background: var(--panel-raised); border-radius: 3px; }
.bar { fill: var(--text-2); }
.bar-neg { fill: var(--red); opacity: 0.7; }
.bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.pick-list { list-style: none; margin: 0; padding: 0.75rem 1rem; display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: 0.5rem; }
.pick-list li.has-error select { border-color: var(--red); }
.view-tabs { margin-bottom: 0.75rem; }
.tab-view { display: inline-flex; align-items: center; gap: 0.35rem; }
.tab-view .icon { width: 0.875rem; height: 0.875rem; }

@media (max-width: 640px) {
  .bars li { grid-template-columns: 1fr auto; }
  .bar-track { grid-column: 1 / -1; grid-row: 2; }
}
.display-col { display: grid; gap: 1rem; align-content: start; }
.view-form fieldset.check-list { margin-top: 1rem; }

/* ---- proposals (fas 10) ----------------------------------------------------------------------- */
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.compare-title { margin: 0 0 0.5rem; font-size: var(--text-s); color: var(--text-3); font-weight: 500; }
.sum-list { margin: 0; padding-left: 1.1rem; display: grid; gap: 0.25rem; }
.rationale { margin: 0; border-left: 3px solid rgba(250, 204, 21, 0.5); color: var(--text-2); white-space: normal; }
.diff td { vertical-align: top; word-break: break-word; }
.diff-added .diff-new { color: var(--green); }
.diff-removed td:first-child, .diff-removed .diff-old { color: var(--red); }
.diff-changed .diff-old { color: var(--text-3); text-decoration: line-through; }
.decision-form .field { max-width: 36rem; }
@media (max-width: 52rem) { .compare { grid-template-columns: 1fr; } }
.decision-form .form-footer { margin-top: 0.75rem; }

/* ---- access tokens (fas 11) ------------------------------------------------------------------- */
.token-created { display: grid; gap: 0.5rem; border-color: rgba(74, 222, 128, 0.35); }
.token-created p { margin: 0; color: var(--text-2); font-size: var(--text-s); }
.token-created .label-like { margin-top: 0.5rem; }
.token-secret { width: 100%; padding: 0.5rem 0.75rem; border: 1px solid var(--line-strong); border-radius: var(--radius-s); background: var(--bg); color: var(--text); }
.token-secret:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.token-setup dd { overflow-wrap: anywhere; }
.form .access-grid { margin-top: 1.25rem; }
.form .access-grid fieldset + fieldset { margin-top: 0; }
.token-footer { justify-content: space-between; margin-top: 1.25rem; }
.token-scopes { min-width: 16rem; }
.access-grid .check input { flex: none; }

/* ---- AI chat (fas 12) ------------------------------------------------------------------------- */
/* The bar sits at the bottom of the work area, centred on the content column; the panel opens above it. */
.has-chat .main { padding-bottom: 7rem; }
.chat-dock { position: fixed; z-index: 30; bottom: 0; left: var(--sidebar-w); right: 0; padding: 0 clamp(1rem, 4vw, 3rem) 1rem; pointer-events: none; }
.chat-dock > * { pointer-events: auto; max-width: 46rem; margin-left: auto; margin-right: auto; }
.chat-bar { display: flex; align-items: flex-end; gap: 0.5rem; padding: 0.375rem 0.375rem 0.375rem 0.75rem; background: var(--panel-raised);
  border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45); }
.chat-bar:focus-within { border-color: var(--focus); }
.chat-bar-icon { display: inline-flex; height: 2rem; align-items: center; color: var(--text-3); }
.chat-bar textarea { flex: 1; min-height: 2rem; max-height: 10rem; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; font-size: var(--text-m); line-height: 1.4; padding: 0.3rem 0; }
.chat-bar textarea::placeholder { color: var(--text-3); }
.chat-send { display: inline-grid; place-items: center; width: 2rem; height: 2rem; flex: none; border: 0; border-radius: 8px; cursor: pointer;
  background: var(--primary-bg); color: var(--primary-text); }
.chat-send:hover { background: #fff; }
.chat-send:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.chat-bar textarea:focus, .chat-bar textarea:focus-visible { outline: none; box-shadow: none; }
.is-busy .chat-send { opacity: 0.4; cursor: progress; }

.chat-panel { display: flex; flex-direction: column; max-height: min(70vh, 40rem); margin-bottom: 0.5rem; background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55); overflow: hidden; }
.chat-panel[hidden] { display: none; }
.chat-panel-head { display: flex; align-items: center; gap: 0.25rem; padding: 0.5rem 0.5rem 0.5rem 1rem; border-bottom: 1px solid var(--line); }
.chat-panel-title { display: inline-flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: var(--text-s); margin-right: auto; }
.chat-panel-head form { margin: 0; }
.chat-thread { overflow-y: auto; padding: 1rem; display: grid; gap: 0.875rem; align-content: start; overscroll-behavior: contain; }

.chat-msg { max-width: 88%; font-size: var(--text-m); line-height: 1.55; }
.chat-msg p, .chat-msg ul, .chat-msg ol { margin: 0 0 0.5rem; }
.chat-msg > :last-child { margin-bottom: 0; }
.chat-msg ul, .chat-msg ol { padding-left: 1.25rem; }
.chat-msg a { color: #8fb0f5; }
.chat-msg code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.85em; background: var(--active); padding: 0.05rem 0.3rem; border-radius: 4px; }
.chat-user { justify-self: end; background: var(--active); padding: 0.5rem 0.75rem; border-radius: 12px 12px 4px 12px; }
.chat-ai { justify-self: start; }
.chat-thinking { margin: 0; color: var(--text-3); font-size: var(--text-s); }
.chat-notice { margin: 0; color: var(--text-3); font-size: var(--text-s); }
.chat-error { margin: 0; }

.chat-card { justify-self: stretch; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--panel-raised); padding: 0.75rem 0.875rem; display: grid; gap: 0.625rem; }
.chat-card-head { display: flex; align-items: flex-start; gap: 0.5rem; margin: 0; font-size: var(--text-s); color: var(--text-2); }
.chat-card-head .icon { margin-top: 0.15rem; color: #8fb0f5; }
.chat-card-head strong { color: var(--text); font-weight: 600; }
.chat-card-rows { display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: 0.25rem 1rem; margin: 0; font-size: var(--text-s); }
.chat-card-rows dt { color: var(--text-3); }
.chat-card-rows dd { margin: 0; overflow-wrap: anywhere; }
.chat-card-actions { display: flex; gap: 0.5rem; margin: 0; }
.chat-card-status { display: flex; align-items: center; gap: 0.375rem; margin: 0; font-size: var(--text-s); color: var(--text-2); }
.chat-card-status.is-done { color: var(--green); }
.chat-card-status.is-done a { color: inherit; }
.chat-card-status.is-failed { color: var(--red); }
.chat-card-errors { margin: 0; padding-left: 1.25rem; font-size: var(--text-s); color: var(--red); }
.chat-card-done, .chat-card-rejected, .chat-card-expired { background: transparent; }
.chat-card-rejected .chat-card-rows, .chat-card-expired .chat-card-rows { opacity: 0.6; }

.chat-empty { color: var(--text-2); font-size: var(--text-s); }
.chat-empty p { margin: 0 0 0.375rem; }
.chat-empty-title { color: var(--text); font-weight: 600; font-size: var(--text-m); }
.chat-examples { margin: 0.5rem 0 0; padding-left: 1.1rem; display: grid; gap: 0.25rem; color: var(--text-3); }

/* The full page (/ai, also the version without JavaScript). */
.chat-page { display: grid; gap: 1rem; max-width: 46rem; }
.chat-page .chat-thread { padding: 0; overflow: visible; }
.chat-bar-page { box-shadow: none; }

.ai-usage { display: grid; gap: 0.625rem; }
.ai-usage-figure { margin: 0; font-size: 1.0625rem; }
.ai-usage-figure .muted { font-size: var(--text-s); }
.ai-meter { width: 100%; height: 6px; display: block; }
.ai-meter-track { fill: var(--active); }
.ai-meter-fill { fill: var(--primary-bg); }
.ai-meter-fill.is-full { fill: var(--red); }
.ai-usage .hint { margin: 0; }

@media (max-width: 52rem) {
  .chat-dock { left: 0; width: 100%; padding: 0 0.75rem 0.75rem; }
  .chat-panel { max-height: 75vh; }
  .chat-msg { max-width: 100%; }
}

/* ---- menu settings (D76) ---------------------------------------------------------------------- */
.menu-list { list-style: none; margin: 0; padding: 0; }
.menu-list li { display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem 0.5rem 1rem; border-top: 1px solid var(--line); }
.menu-list li:first-child { border-top: 0; }
.menu-list li.is-hidden .menu-list-text, .menu-list li.is-hidden .menu-list-icon { opacity: 0.5; }
.menu-list-icon { display: inline-flex; color: var(--text-2); }
.menu-list-text { display: grid; min-width: 0; margin-right: auto; }
.menu-list-text .cell-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.menu-list-actions { display: flex; align-items: center; gap: 0.125rem; flex: none; }
.menu-list-actions form { margin: 0; }
.icon-spacer { display: inline-block; width: 2rem; }
.menu-add { display: grid; grid-template-columns: repeat(auto-fit, minmax(17rem, 1fr)); gap: 1rem; align-items: start; }
.menu-add .form { gap: 0.875rem; }
.menu-add .button-secondary { justify-self: start; }
.menu-add-title { display: flex; align-items: center; gap: 0.5rem; margin: 0; font-size: var(--text-m); font-weight: 600; }
.menu-roles { display: flex; flex-wrap: wrap; gap: 0.375rem 1rem; border: 0; margin: 0; padding: 0; }
.menu-roles legend { width: 100%; padding: 0; margin-bottom: 0.25rem; }
.menu-roles .hint { width: 100%; margin: 0; }
.menu-pin { margin: 0; }
.nav-external { display: inline-flex; margin-left: auto; color: var(--text-3); }
.nav-external .icon { width: 12px; height: 12px; }
.menu-list-actions form:last-child button { min-width: 4.5rem; justify-content: flex-end; }

/* ---------- Ansvarig och område (D77) ---------- */
.tabs a.tab-toggle { display: inline-flex; align-items: center; gap: 0.35rem; margin-left: 0.375rem; box-shadow: inset 0 0 0 1px var(--line); }
.tabs a.tab-toggle[aria-pressed="true"] { color: var(--text); background: var(--active); box-shadow: inset 0 0 0 1px var(--line-strong); }
.tab-toggle .icon { width: 0.875rem; height: 0.875rem; }
.assign-panel { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; padding: 0.875rem 1rem; }
.assign-who { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.assign-icon { display: inline-flex; align-items: center; justify-content: center; width: 2rem; height: 2rem; border-radius: 50%; background: var(--panel-raised); color: var(--text-2); flex: none; }
.assign-who h2 { font-size: var(--text-xs); font-weight: 500; color: var(--text-2); letter-spacing: 0; }
.assign-names { margin: 0; font-weight: 500; }
.assign-names.muted { font-weight: 400; }
details.assign-edit > summary { list-style: none; cursor: pointer; }
details.assign-edit > summary::-webkit-details-marker { display: none; }
.assign-panel > details.assign-edit { display: grid; justify-items: end; gap: 0.75rem; }
.assign-panel > details.assign-edit[open] { flex-basis: 100%; justify-items: stretch; }
.assign-panel > details.assign-edit[open] > summary { justify-self: end; }
.assign-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem; margin: 0; }
.assign-form .field { min-width: 12rem; }
.line-who { min-width: 9rem; }
.line-who details.assign-edit > summary span { text-decoration: underline dotted var(--line-strong); text-underline-offset: 0.25em; }
.line-who details.assign-edit > summary:hover span { text-decoration-color: var(--text-2); }
.line-who details.assign-edit[open] .assign-form { margin-top: 0.625rem; padding: 0.75rem; background: var(--panel-raised); border-radius: var(--radius-s); flex-direction: column; align-items: stretch; }
