:root {
  --paper: #F4F6FB; --surface: #FFFFFF; --surface-2: #F7F9FD; --surface-3: #EEF2FA;
  --ink: #0F1E3D; --ink-soft: #3A4A66; --muted: #66758F; --faint: #93A0B8;
  --line: #DCE3EF; --line-strong: #C4CEDE;
  --accent: #0B7C90; --accent-strong: #095E6E; --accent-wash: #E2F1F4; --accent-line: #B4DCE3; --on-accent: #ffffff;
  --good: #12805C; --good-wash: #E2F3EC; --warn: #B26A00; --warn-wash: #FaEEDA;
  --bad: #C22B2B; --bad-wash: #FBE6E6; --info: #2F5FD0; --info-wash: #E8EFFC;
  --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-pill: 999px;
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --bar-h: 58px;
  --shadow-sm: 0 1px 2px rgba(15,30,61,.06), 0 1px 3px rgba(15,30,61,.04);
  --shadow-md: 0 4px 14px rgba(15,30,61,.08);
  --shadow-lg: 0 18px 48px rgba(15,30,61,.16);
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Code", Menlo, monospace;

  /* old names still read by pages not yet ported to the new tokens */
  --font-sans: var(--sans);
  --font-mono: var(--mono);
  --accent-ink: var(--accent-strong);
  --teal: var(--accent);
  --maxw: 1120px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0F0F11; --surface: #16171A; --surface-2: #1B1C20; --surface-3: #232429;
    --ink: #ECEDEF; --ink-soft: #B2B4BB; --muted: #83868E; --faint: #5B5E66;
    --line: #282A30; --line-strong: #383B43;
    --accent: #37BBCE; --accent-strong: #6FD6E3; --accent-wash: rgba(55,187,206,.13); --accent-line: rgba(55,187,206,.34); --on-accent: #082A30;
    --good: #3FBE86; --good-wash: rgba(63,190,134,.13); --warn: #E0A44A; --warn-wash: rgba(224,164,74,.14);
    --bad: #F0605F; --bad-wash: rgba(240,96,95,.14); --info: #4C82F7; --info-wash: rgba(76,130,247,.13);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 18px rgba(0,0,0,.5); --shadow-lg: 0 22px 54px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --paper: #0F0F11; --surface: #16171A; --surface-2: #1B1C20; --surface-3: #232429;
  --ink: #ECEDEF; --ink-soft: #B2B4BB; --muted: #83868E; --faint: #5B5E66;
  --line: #282A30; --line-strong: #383B43;
  --accent: #37BBCE; --accent-strong: #6FD6E3; --accent-wash: rgba(55,187,206,.13); --accent-line: rgba(55,187,206,.34); --on-accent: #082A30;
  --good: #3FBE86; --good-wash: rgba(63,190,134,.13); --warn: #E0A44A; --warn-wash: rgba(224,164,74,.14);
  --bad: #F0605F; --bad-wash: rgba(240,96,95,.14); --info: #4C82F7; --info-wash: rgba(76,130,247,.13);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.4); --shadow-md: 0 6px 18px rgba(0,0,0,.5); --shadow-lg: 0 22px 54px rgba(0,0,0,.6);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 26px;
  letter-spacing: -0.02em;
}
h2 {
  font-size: 17px;
}
h3 {
  font-size: 14px;
}
p {
  margin: 0 0 var(--sp-3);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}
::selection {
  background: var(--accent-wash);
}

.eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
}

.muted {
  color: var(--muted);
}
.soft {
  color: var(--ink-soft);
}

.mono {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
}
.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-5);
  min-width: 0;
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.brand:hover {
  text-decoration: none;
}
.brand__mark {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: 7px;
  object-fit: contain;
  display: block;
}
.brand small {
  color: var(--muted);
  font-weight: 500;
}

.nav {
  display: flex;
  gap: 2px;
  margin-left: var(--sp-3);
}
.nav a {
  padding: 7px 12px;
  border-radius: var(--r-pill);
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}
.nav a:hover {
  background: var(--surface-3);
  color: var(--ink);
  text-decoration: none;
}
.nav a.is-active {
  background: var(--accent-wash);
  color: var(--accent-strong);
}

.topbar__spacer {
  flex: 1;
}
.livechip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--muted);
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  white-space: nowrap;
}
.livedot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 0 var(--good);
  animation: pulse 2.4s infinite;
}
@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 60%, transparent);
  }
  70% {
    box-shadow: 0 0 0 6px transparent;
  }
  100% {
    box-shadow: 0 0 0 0 transparent;
  }
}
.kbd {
  font-family: var(--mono);
  font-size: 11px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  color: var(--muted);
  background: var(--surface);
}
.iconbtn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--r-md);
  color: var(--ink-soft);
}
.iconbtn:hover {
  border-color: var(--line-strong);
  color: var(--ink);
}
.userpill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface);
  font-size: 13px;
  white-space: nowrap;
}
.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ffffff));
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
}

/* Layout */
.wrap {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-5);
  flex: 1 0 auto;
  min-width: 0;
}
.pagehead {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
}
.pagehead .sub {
  color: var(--muted);
  margin-top: 4px;
}
.page-head {
  margin-bottom: var(--sp-5);
}
.page-head p {
  color: var(--muted);
  margin: var(--sp-2) 0 0;
  max-width: 60ch;
}

.footer {
  border-top: 1px solid var(--line);
  color: var(--faint);
  font-size: 0.82rem;
  min-width: 0;
}
.footer__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.card__body {
  padding: var(--sp-5);
}
.card__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}

.grid {
  display: grid;
  gap: var(--sp-4);
}
@media (min-width: 720px) {
  .grid--2 {
    grid-template-columns: 1fr 1fr;
  }
  .grid--3 {
    grid-template-columns: repeat(3, 1fr);
  }
  .grid--4 {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* Home: stat tiles + tool cards */
.tile {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
}
.tile .k {
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.tile .v {
  font-family: var(--mono);
  font-size: 30px;
  font-weight: 600;
  margin-top: 8px;
  letter-spacing: -0.02em;
}
.navcard {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  transition: 0.16s;
}
.navcard:hover {
  border-color: var(--accent-line);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  text-decoration: none;
}
.navcard h3 {
  margin-bottom: 4px;
}
.navcard p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}
.navcard .arm {
  margin-top: 14px;
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: var(--r-md);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s;
}
.btn:hover {
  border-color: var(--muted);
  text-decoration: none;
}
.btn--primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn--primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.btn--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--ink-soft);
}
.btn--ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
}
.btn--sm {
  padding: 6px 10px;
  font-size: 13px;
}
.btn--lg {
  padding: 0.85rem 1.4rem;
  font-size: 1rem;
}
.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forms */
.field {
  display: block;
  margin-bottom: var(--sp-4);
}
.field__label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin-bottom: var(--sp-2);
}
.field__hint {
  color: var(--muted);
  font-size: 0.82rem;
  margin-top: var(--sp-2);
}
.input,
.select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
}
.input:focus,
.select:focus {
  outline: 2px solid var(--accent-wash);
  border-color: var(--accent);
}
.formgrid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-4);
}
@media (max-width: 640px) {
  .formgrid {
    grid-template-columns: 1fr;
  }
}

/* Slide-over drawer (add-creditor and similar focused forms) */
.slideover-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: none;
  background: color-mix(in srgb, var(--ink) 32%, transparent);
  backdrop-filter: blur(2px);
}
.slideover-overlay.show {
  display: block;
  animation: cmdk-fade 0.12s ease;
}
.slideover {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 151;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.slideover.show {
  transform: none;
}
.slideover__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--line);
}
.slideover__body {
  flex: 1;
  overflow: auto;
  padding: var(--sp-5);
}
@media (max-width: 480px) {
  .slideover {
    max-width: 100%;
  }
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.table th {
  text-align: left;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  font-weight: 600;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
}
.table td {
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
.table tbody tr:last-child td {
  border-bottom: none;
}
.table tbody tr {
  transition: background 0.12s ease;
}
.table tbody tr:hover {
  background: var(--surface-2);
}
.table td.num,
.table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
/* new cockpit-style table shell (pages migrate to this over time) */
.tablecard {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.tscroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.data th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: left;
  padding: 11px 14px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data th.num,
table.data td.num {
  text-align: right;
}
table.data td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  color: var(--ink-soft);
}
table.data tbody tr:hover {
  background: var(--surface-2);
}
table.data tbody tr:last-child td {
  border-bottom: none;
}
table.data .ref {
  font-family: var(--mono);
  color: var(--ink);
  font-weight: 500;
}
table.data .cust {
  color: var(--ink);
}
.cbx {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}
tr.sel {
  background: var(--accent-wash) !important;
}
.od-hi {
  color: var(--bad);
  font-weight: 600;
}
.due {
  font-family: var(--mono);
  font-size: 12.5px;
}

/* Invoice cockpit: a fixed-height shell below the top bar. The main column
   is a flex chain so the bulk bar always pins to the bottom of the visible
   area and the table shrinks to whatever room is left. Full-bleed — the
   .wrap around it drops its reading max-width and padding so the cockpit
   fills the actual available width (a 100vw breakout would overshoot by
   the scrollbar's width). */
.wrap:has(> .cockpit) {
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
.cockpit {
  padding: 0 var(--sp-5);
  display: grid;
  grid-template-columns: 264px 1fr;
  gap: var(--sp-5);
  height: calc(100vh - var(--bar-h));
  overflow: hidden;
}
.filters {
  height: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  padding: var(--sp-5) var(--sp-4);
}
.filters h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: var(--sp-3);
}
.fgroup {
  margin-bottom: var(--sp-4);
}
.fgroup label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.frow {
  display: flex;
  gap: 8px;
}
.filters .clear {
  display: block;
  width: 100%;
  margin-top: var(--sp-2);
  text-align: center;
}

.cockmain {
  min-width: 0;
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) 0;
}
.cockhead {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.cockhead .count {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}
.cockhead .count b {
  color: var(--ink);
  font-family: var(--mono);
}
/* the bulk-action form wraps the tablecard, so it has to carry the flex
   budget down to it or the table never shrinks to fit */
.cockmain form {
  flex: 1;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.cockmain .tablecard {
  flex: 1;
  min-height: 0;
}
.cockmain .pager {
  flex: none;
  margin-top: var(--sp-4);
}

.bulkbar {
  flex: none;
  z-index: 20;
  display: none;
  align-items: center;
  gap: var(--sp-4);
  padding: 12px var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}
.bulkbar.show {
  display: flex;
  animation: bulkbar-slideup 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}
@keyframes bulkbar-slideup {
  from { transform: translateY(100%); }
  to { transform: none; }
}
.bulkbar .selcount {
  font-weight: 600;
}
.bulkbar .selcount b {
  font-family: var(--mono);
  color: var(--accent-strong);
}
.bulkbar .spacer {
  flex: 1;
}

@media (max-width: 900px) {
  .cockpit {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }
  .filters {
    height: auto;
    overflow: visible;
  }
  .cockmain {
    height: auto;
    overflow: visible;
  }
  .cockmain .tablecard {
    flex: none;
  }
}

/* Live progress panel (bulk actions, background jobs) */
.live {
  flex: none;
  margin-bottom: var(--sp-4);
  border: 1px solid var(--accent-line);
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: var(--sp-4) var(--sp-5);
  box-shadow: var(--shadow-md);
  display: none;
}
.live.show {
  display: block;
  animation: live-drop 0.25s ease;
}
@keyframes live-drop {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.live__top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.live__top .tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  background: var(--accent-wash);
  padding: 3px 8px;
  border-radius: var(--r-sm);
}
.live__top .title {
  font-weight: 600;
}
.live__top .pct {
  margin-left: auto;
  font-family: var(--mono);
  color: var(--muted);
}
.meter {
  position: relative;
  height: 12px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
  display: flex;
}
.meter i {
  height: 100%;
  display: block;
  transition: width 0.3s ease;
}
.meter i.seg-good { background: var(--good); }
.meter i.seg-muted { background: var(--faint); }
.meter i.seg-bad { background: var(--bad); }
.meter i.seg-info { background: var(--info); }
.meter i.seg-sweep {
  position: absolute;
  top: 0;
  left: -30%;
  width: 30%;
  background: var(--accent);
  animation: live-sweep 1.3s ease-in-out infinite;
}
@keyframes live-sweep {
  0% { left: -30%; }
  100% { left: 100%; }
}
.live__legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.live__legend b {
  font-family: var(--mono);
  color: var(--ink);
}
.live__legend .dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 5px;
  vertical-align: middle;
}
.live__feed {
  margin-top: 12px;
  max-height: 112px;
  overflow: auto;
  border-top: 1px dashed var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.live__feed .ev {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-soft);
  display: flex;
  gap: 8px;
  align-items: center;
}
.live__feed .ev .s {
  width: 62px;
  flex: none;
  font-weight: 600;
}

.action-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-4);
}
.filter-bar .input {
  width: auto;
  flex: 1 1 160px;
}

.pager {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-4);
}
.pager__spacer {
  flex: 1;
}

/* Badges & chips */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge--good {
  color: var(--good);
  background: var(--good-wash);
}
.badge--info {
  color: var(--info);
  background: var(--info-wash);
}
.badge--warn {
  color: var(--warn);
  background: var(--warn-wash);
}
.badge--bad {
  color: var(--bad);
  background: var(--bad-wash);
}
.badge--neutral {
  color: var(--muted);
  background: var(--surface-2);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--ink-soft);
  border: 1px solid var(--line);
}
.chip b {
  font-family: var(--mono);
  color: var(--ink);
}
.chip__count {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.chip__label {
  color: var(--muted);
}
.chip.is-empty {
  color: var(--faint);
}
.chip.is-empty .chip__count {
  color: var(--faint);
}
/* Score gauge (customer detail) */
.sep {
  border: none;
  border-top: 1px solid var(--line);
  margin: var(--sp-5) 0;
}
.gauge-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-6);
  flex-wrap: wrap;
}
.metarow {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  margin-top: var(--sp-3);
}
.metarow .m .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.metarow .m .v {
  font-family: var(--mono);
  font-size: 15px;
  margin-top: 2px;
}
.meta-row {
  display: flex;
  gap: var(--sp-5);
  flex-wrap: wrap;
  padding-top: var(--sp-4);
  border-top: 1px solid var(--line);
}
.meta {
  min-width: 0;
}
.meta__label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 2px;
}
.meta__value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--ink);
  word-break: break-all;
}

/* Factor breakdown (score gauge, income/wealth groups) */
.factor {
  margin-bottom: 12px;
}
.factor .fl {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  margin-bottom: 5px;
}
.factor .bar {
  height: 8px;
  border-radius: var(--r-pill);
  background: var(--surface-3);
  overflow: hidden;
}
.factor .bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 55%, #ffffff));
  border-radius: var(--r-pill);
}

.empty {
  padding: var(--sp-6);
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
}

/* Toasts */
.toaststack {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 340px;
  max-width: calc(100vw - 40px);
}
.toast {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 12px 14px;
  transform: translateX(120%);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
}
.toast.in {
  transform: none;
  opacity: 1;
}
.toast--success {
  border-left-color: var(--good);
}
.toast--error {
  border-left-color: var(--bad);
}
.toast--info {
  border-left-color: var(--info);
}
.toast .ic {
  width: 20px;
  height: 20px;
  flex: none;
  margin-top: 1px;
}
.toast--success .ic {
  color: var(--good);
}
.toast--error .ic {
  color: var(--bad);
}
.toast--info .ic {
  color: var(--info);
}
.toast .msg {
  font-size: 13.5px;
}
.toast .msg b {
  font-weight: 600;
}
.toast .x {
  margin-left: auto;
  border: none;
  background: none;
  color: var(--faint);
  font-size: 16px;
  line-height: 1;
}
.login__alerts {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
  text-align: left;
}
.login__alerts .toast {
  transform: none;
  opacity: 1;
}

@media (max-width: 1040px) {
  .topbar {
    padding: 0 var(--sp-3);
    gap: var(--sp-2);
  }
  .livechip,
  .userpill {
    display: none;
  }
  .nav {
    margin-left: var(--sp-2);
    overflow-x: auto;
  }
}
@media (max-width: 620px) {
  .wrap {
    padding: var(--sp-5) var(--sp-4) var(--sp-6);
  }
}

/* Lifecycle timeline (invoice detail) */
.tl {
  position: relative;
  padding-left: 26px;
}
.tl::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 4px;
  bottom: 4px;
  width: 2px;
  background: var(--line);
}
.tl .n {
  position: relative;
  padding-bottom: var(--sp-4);
}
.tl .n:last-child {
  padding-bottom: 0;
}
.tl .n::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--accent);
}
.tl .n.done::before {
  background: var(--accent);
}
.tl .n .t {
  font-size: 12px;
  color: var(--muted);
  font-family: var(--mono);
  margin-bottom: var(--sp-1);
}
.tl .n .h {
  font-weight: 600;
  margin: 1px 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

/* Command menu */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh var(--sp-4) var(--sp-4);
  background: color-mix(in srgb, var(--ink) 32%, transparent);
  backdrop-filter: blur(3px);
}
.cmdk-overlay.show {
  display: flex;
  animation: cmdk-fade 0.12s ease;
}
@keyframes cmdk-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.cmdk {
  width: 100%;
  max-width: 620px;
  max-height: 66vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: cmdk-pop 0.14s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes cmdk-pop {
  from { transform: translateY(-8px) scale(0.99); opacity: 0.4; }
  to { transform: none; opacity: 1; }
}
.cmdk__in {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.cmdk__in > svg {
  color: var(--muted);
  flex: none;
}
.cmdk__in input {
  flex: 1;
  min-width: 0;
  border: none;
  background: none;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
.cmdk__in .scope {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent-strong);
  background: var(--accent-wash);
  padding: 2px 7px;
  border-radius: var(--r-sm);
  flex: none;
}
.cmdk__list {
  overflow: auto;
  padding: 6px;
}
.cmdk__glabel {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--faint);
  padding: 10px 12px 6px;
}
.cmdk__item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
}
.cmdk__item .ic {
  width: 20px;
  flex: none;
  color: var(--muted);
  display: grid;
  place-items: center;
}
.cmdk__item .tt {
  flex: 1;
  min-width: 0;
}
.cmdk__item .tt .t {
  font-size: 14px;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk__item .tt .s {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmdk__item .meta {
  font-size: 11px;
  color: var(--faint);
  font-family: var(--mono);
  flex: none;
}
.cmdk__item.sel {
  background: var(--accent-wash);
}
.cmdk__item.sel .ic {
  color: var(--accent-strong);
}
.cmdk__empty {
  padding: 26px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}
.cmdk__foot {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 9px 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  flex-wrap: wrap;
}
.cmdk__foot .k {
  font-family: var(--mono);
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  padding: 0 5px;
  margin-right: 5px;
}
.cmdk__foot .sp {
  flex: 1;
}
@media (max-width: 560px) {
  .cmdk__foot .sp,
  .cmdk__foot #cmdkHint {
    display: none;
  }
}

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

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 0%, rgba(36, 86, 214, 0.12), transparent 70%),
    var(--paper);
  padding: var(--sp-4);
}
.login__card {
  width: 100%;
  max-width: 380px;
  padding: var(--sp-5);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login__logo { border-radius: 10px; }
.login__title { margin: var(--sp-3) 0 0; font-size: 1.25rem; }
.login__sub { margin: var(--sp-1) 0 var(--sp-4); color: var(--ink-soft); }
.login__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  width: 100%;
  padding: 0.85rem 1rem;
  margin-top: var(--sp-2);
  border-radius: var(--r-md);
  border: 1px solid var(--line);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  color: var(--ink);
  background: var(--surface);
}
.login__btn--vipps { background: #ff5b24; border-color: #ff5b24; color: #fff; }
.login__btn--vipps:hover { filter: brightness(0.96); text-decoration: none; }
.login__btn--bankid { opacity: 0.55; cursor: not-allowed; }
