/* What every Malling tool page shares: the design tokens, the layout, and
   the components more than one page uses. Each page's own sheet comes
   after, and uses the tokens rather than numbers of its own.

   The look is Stemma's (Saldobalanse/apps/ui/stemma.css), as Bilagsflyt
   has it (bilagsflyt.css and bilagsflyt_tema.css), both read 23.11.2026:
   a cream page, cream cards a shade lighter, warm hairlines in place of
   burgundy lines, burgundy-tinted shadows, the slim burgundy band at the
   top with Malling's red line under it, Stemma's status colours, and
   Malling's own typeface. Light only, as Stemma and Alfredo are. The
   class names and token names are the ones the pages have always used,
   so each page takes the look from here. */

/* Malling's typeface, Fold Grotesque Pro, Light and Medium only (the
   profile has no bold), served from static/fonts. Until the files load
   the text shows in Arial (font-display: swap). */
/* stylelint-disable declaration-property-value-allowed-list */
@font-face {
  font-family: "Fold Grotesque";
  font-style: normal;
  font-weight: 300 400;
  font-display: swap;
  src: url("fonts/FoldGrotesque-Light-Pro.woff2") format("woff2");
}

@font-face {
  font-family: "Fold Grotesque";
  font-style: normal;
  font-weight: 500 700;
  font-display: swap;
  src: url("fonts/FoldGrotesque-Medium-Pro.woff2") format("woff2");
}
/* stylelint-enable declaration-property-value-allowed-list */

:root {
  color-scheme: light;

  /* Malling's colours and Stemma's: the only literal colours anywhere
     (stylelint requires tokens everywhere else). */
  /* stylelint-disable color-no-hex, function-disallowed-list */
  --burgund: #3C0025;
  /* Burgundy a shade darker: a primary button under the pointer. */
  --burgund-dyp: #2A0019;
  --rod: #FF7474;
  --lys: #FFC4C4;
  --lilla: #EFE6FF;
  --gronn: #ECFFA5;
  --hvit: #FFFFFF;
  /* The palette's other tints. */
  --oransje: #FFD396;
  --rosa: #FFCEF0;
  --gul: #FFFCAC;
  /* The text that reads on each tint (5.7:1 or more). */
  --lilla-tekst: #3D2C66;
  --gronn-tekst: #3F5410;
  --gul-tekst: #6B4E13;
  /* Stemma's surfaces: the cream page, cards a shade lighter, sand for
     what is calm, a stripe under the pointer, a burgundy tint for what is
     chosen. */
  --flate: #FDFAF6;
  --kort: #FFFCF8;
  --sand: #F2ECE2;
  --stripe: #FBF7F1;
  --tint: #F1E7EC;
  /* Muted text: 5.3:1 on cream and 4.7:1 on sand (never #9A8478, 3.4:1). */
  --demp: #7A6458;
  /* Warm hairlines. */
  --strek: #DDD5C9;
  --strek-svak: #EFE6DB;
  /* Status: ok, needs a look, failed; strong for text, icons and bars,
     -flate for fills. */
  --ok: #2E7D32;
  --ok-flate: #E7F2E7;
  --obs: #C98A00;
  --obs-flate: #FDF2D9;
  --avvik: #B3261E;
  --avvik-flate: #FBE4E4;
  --avvik-strek: #F1B6B6;
  /* A checkbox's tick and dash, in cream (Lucide's shapes, as Bilagsflyt's). */
  --i-hake: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFCF8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6L9 17l-5-5'/%3E%3C/svg%3E");
  --i-strek: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFCF8' stroke-width='3' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
  /* stylelint-enable color-no-hex, function-disallowed-list */

  /* The backdrop behind a dialog, and the soft burgundy shadows: a
     card's, and a lifted panel's (a dialog, a menu). */
  --overlay: color-mix(in srgb, var(--burgund) 34%, transparent);
  --skygge: 0 1px 2px color-mix(in srgb, var(--burgund) 3.5%, transparent),
    0 10px 30px -14px color-mix(in srgb, var(--burgund) 16%, transparent);
  --skygge-lg: 0 2px 6px color-mix(in srgb, var(--burgund) 4.5%, transparent),
    0 28px 56px -22px color-mix(in srgb, var(--burgund) 22%, transparent);
  --shadow: var(--skygge-lg);
  /* A field in focus: a soft ring around its burgundy edge. */
  --ring: 0 0 0 3px color-mix(in srgb, var(--burgund) 14%, transparent);
  /* Cream on the band, and its fainter shades. */
  --krem-svak: color-mix(in srgb, var(--flate) 72%, transparent);
  --krem-strek: color-mix(in srgb, var(--flate) 35%, transparent);

  /* Motion: an exponential ease out that reads soft from ~220ms, and a
     short straight one for a press. */
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-trykk: cubic-bezier(0.3, 0.7, 0.4, 1);
  --tid: 0.22s;
  --tid-trykk: 0.11s;

  --font-sans: "Fold Grotesque", fold-grotesque, Arial, Helvetica, sans-serif;
  --font-mono: ui-monospace, Consolas, monospace;
  --weight-light: 300;
  --weight-medium: 500;
  --leading: 1.5;

  --text-2xs: 12px;
  --text-xs: 13px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 20px;
  --text-2xl: 22px;
  /* Icon glyphs, e.g. a dialog's ×. */
  --text-icon: 28px;

  /* Spacing, in steps of 4px: --space-N is N × 4px. */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* Stemma's corners: a card 14, a row in a list 10, a control 8, a tag
     6, a small mark 4, and a pill. */
  --radius-sm: 4px;
  --radius-merke: 6px;
  --radius: 8px;
  --radius-felt: 10px;
  --radius-lg: 14px;
  --radius-pill: 999px;
  --border: 1px solid var(--strek);

  /* Control heights: a form's (36), a toolbar's (32), a small one (28). */
  --kontroll-h: 36px;
  --kontroll-h-s: 32px;
  --kontroll-h-xs: 28px;

  /* The band's height with its red line: sticky table headers stop right
     below it. */
  --header-height: 50px;
  /* One content width for every page (Tailwind's max-w-7xl). */
  --content-width: 1280px;
  --gutter: var(--space-4);
}

* {
  box-sizing: border-box;
}

/* 14px Light on cream: a working tool's size, with room to breathe. */
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-light);
  line-height: var(--leading);
  color: var(--burgund);
  background: var(--flate);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizelegibility;
}

::selection {
  color: var(--burgund);
  background: var(--lilla);
}

main {
  max-width: var(--content-width);
  margin: var(--space-10) auto var(--space-12);
  padding: 0 var(--gutter);
}

section + section {
  margin-top: var(--space-12);
}

a {
  color: var(--burgund);
  text-decoration-color: color-mix(in srgb, var(--burgund) 35%, transparent);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--tid) var(--ease);
}

a:hover {
  text-decoration-color: currentcolor;
}

/* Keyboard focus, everywhere: a 2px burgundy ring just outside. */
:focus-visible {
  outline: 2px solid var(--burgund);
  outline-offset: 2px;
}

/* --- The band ------------------------------------------------------------------ */

/* Bilagsflyt's top bar (Stemma's band at half the height), on every page:
   slim burgundy, Malling's logo and the page's name in cream, the red
   line under it and a soft shadow below that; who is signed in at the
   end. It stays in view as the page scrolls. */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: 48px;
  padding: 0 var(--space-5);
  color: var(--flate);
  background: var(--burgund);
  border-bottom: 2px solid var(--rod);
  box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--burgund) 55%, transparent);
}

header h1 {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--flate);
  white-space: nowrap;
}

/* Malling's logo, linking back to the index at /. */
.merke-logo {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  border-radius: var(--radius-sm);
}

.merke-logo img {
  display: block;
  width: auto;
  height: 20px;
}

.merke-app {
  overflow: hidden;
  text-overflow: ellipsis;
}

header :focus-visible {
  outline-color: var(--flate);
  outline-offset: 3px;
}

/* The band's right side: who is signed in, and a button to sign out
   (or in, on the public index). */
.user-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

/* Alfred.Admin's Xledger credits, one chip per Xledger and key, kept
   live by xledger_credits.js. */
.xledger-credits {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  justify-content: flex-end;
}

.credit-chip {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 var(--space-3);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  border: 1px solid var(--krem-strek);
  border-radius: var(--radius-pill);
}

/* Under a tenth of the hour's credits left. */
.credit-chip.low {
  color: var(--burgund);
  background: var(--rod);
  border-color: transparent;
}

.user-name {
  max-width: 180px;
  overflow: hidden;
  font-size: var(--text-xs);
  color: var(--krem-svak);
  text-overflow: ellipsis;
  white-space: nowrap;
}

a.header-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  height: var(--kontroll-h-xs);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--flate);
  text-decoration: none;
  border: 1px solid var(--krem-strek);
  border-radius: var(--radius-pill);
  transition: background-color var(--tid) var(--ease), color var(--tid) var(--ease);
}

a.header-button:hover,
a.header-button:focus {
  color: var(--burgund);
  background: var(--flate);
}

@media (max-width: 640px) {
  header {
    padding: 0 var(--space-4);
  }

  header .user-name {
    display: none;
  }
}

/* --- Headings and text ------------------------------------------------------------ */

h2 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--weight-medium);
  letter-spacing: -0.01em;
}

h3 {
  margin: 0 0 var(--space-1);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
}

h4 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

/* A section's heading and lead, with its buttons beside them (under them
   on a phone). */
.intro {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0 var(--space-6);
}

/* The heading and lead take the room; in a narrow column the buttons
   wrap under them instead of running over the next one. */
.intro > :first-child {
  flex: 1 1 360px;
}

.intro .actions {
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
}

@media (max-width: 600px) {
  .intro {
    flex-direction: column;
    gap: 0;
  }

  /* Stacked, a flex-basis is a height: let the text take what it needs. */
  .intro > :first-child {
    flex-basis: auto;
  }

  .intro > button {
    margin-bottom: var(--space-4);
  }
}

/* The paragraph under a page's or section's heading. */
p.lead {
  max-width: 68ch;
  margin: 0 0 var(--space-5);
  font-size: var(--text-base);
  line-height: var(--leading);
  color: var(--demp);
}

code,
pre {
  font-family: var(--font-mono);
}

code {
  font-size: var(--text-xs);
  overflow-wrap: anywhere;
}

summary {
  cursor: pointer;
}

.muted {
  color: var(--demp);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Two sections side by side, where both fit (a page's own sheet can set
   other columns); one under the other on smaller screens. A
   `.screen-section` among them stays in view as the page scrolls, no
   taller than the screen, its table scrolling inside. `.split.wide` is
   for sections with wide tables: they wait for 1600px (below). */
@media (min-width: 1320px) {
  main.split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-10);
    align-items: start;
    max-width: 1880px;
  }

  main.split section + section {
    margin-top: 0;
  }

  main.split .screen-section {
    position: sticky;
    top: calc(var(--header-height) + var(--space-6));
    display: flex;
    flex-direction: column;
    /* Below the top bar and main's top margin, with the same gap left
       under it. */
    max-height: calc(
      100dvh - var(--header-height) - var(--space-12) - var(--space-6)
    );
  }

  main.split .screen-section .table-wrap {
    flex: 0 1 auto;
    min-height: 0;
    max-height: none;
  }
}

@media (min-width: 1320px) and (max-width: 1599px) {
  main.split.wide {
    display: block;
    max-width: var(--content-width);
  }

  main.split.wide section + section {
    margin-top: var(--space-12);
  }

  main.split.wide .screen-section {
    position: static;
    display: block;
    max-height: none;
  }

  main.split.wide .screen-section .table-wrap {
    max-height: calc(100dvh - var(--header-height) - var(--space-8));
  }
}

/* --- Buttons (Stemma's .knapp) -------------------------------------------------------- */

/* Every button starts plain, and gets its look from a class (or its
   page's rule). */
button {
  padding: 0;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
}

/* Burgundy with cream words (primary), or a light outline (secondary,
   Stemma's ghost). 36px tall; pressed, a button gives a little at once.
   A link that does what a button would (e.g. "Logg inn med Malling")
   wears the same classes. */
button.primary,
button.secondary,
a.button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--kontroll-h);
  padding: 0 var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: background-color var(--tid) var(--ease), border-color var(--tid) var(--ease),
    color var(--tid) var(--ease), box-shadow var(--tid) var(--ease),
    opacity var(--tid) var(--ease), transform var(--tid-trykk) var(--ease-trykk);
}

button.primary,
a.button.primary {
  color: var(--flate);
  background: var(--burgund);
  border-color: var(--burgund);
}

button.primary:hover:not(:disabled),
a.button.primary:hover {
  background: var(--burgund-dyp);
  border-color: var(--burgund-dyp);
  box-shadow: var(--skygge);
}

button.secondary,
a.button.secondary {
  color: var(--burgund);
  background: var(--kort);
  border-color: var(--strek);
}

button.secondary:hover:not(:disabled),
a.button.secondary:hover {
  background: var(--sand);
  border-color: color-mix(in srgb, var(--demp) 45%, var(--strek));
}

button.primary:active:not(:disabled),
button.secondary:active:not(:disabled),
a.button:active {
  transform: scale(0.985);
}

button:disabled {
  opacity: 0.55;
  box-shadow: none;
  cursor: not-allowed;
}

button[aria-busy="true"] {
  cursor: progress;
}

button.primary .spinner {
  border-color: var(--flate);
  border-right-color: transparent;
}

/* A button that reads as a link. */
button.link {
  font-size: var(--text-sm);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentcolor 40%, transparent);
  text-underline-offset: 3px;
  border-radius: var(--radius-sm);
  transition: text-decoration-color var(--tid) var(--ease);
}

button.link:hover {
  text-decoration-color: currentcolor;
}

/* --- Forms ----------------------------------------------------------------- */

.field {
  margin-bottom: var(--space-4);
}

/* A label over its field: Medium, a size under the text. */
label {
  display: block;
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}

.hint {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  line-height: var(--leading);
  color: var(--demp);
}

/* A warm hairline, 36px tall; burgundy with a soft ring in focus. Inputs,
   selects and buttons are one height, so they line up in a row. */
input:not([type=checkbox], [type=radio]),
select,
textarea {
  width: 100%;
  min-height: var(--kontroll-h);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-light);
  color: var(--burgund);
  background-color: var(--hvit);
  border: 1px solid var(--strek);
  border-radius: var(--radius);
  transition: border-color var(--tid) var(--ease), box-shadow var(--tid) var(--ease),
    background-color var(--tid) var(--ease);
}

textarea {
  padding: var(--space-2) var(--space-3);
  line-height: var(--leading);
  resize: vertical;
}

/* A file field: a dashed drop area on cream, its button a light outline
   like a secondary button, not the browser's grey one. */
input[type=file] {
  min-height: auto;
  padding: var(--space-3);
  color: var(--demp);
  background: var(--kort);
  border: 1px dashed var(--strek);
  border-radius: var(--radius-felt);
  cursor: pointer;
}

input[type=file]::file-selector-button {
  min-height: var(--kontroll-h-s);
  margin-right: var(--space-3);
  padding: 0 var(--space-4);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--burgund);
  background: var(--hvit);
  border: 1px solid var(--strek);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--tid) var(--ease), border-color var(--tid) var(--ease);
}

input[type=file]:hover {
  background: var(--stripe);
}

input[type=file]:hover::file-selector-button {
  background: var(--sand);
  border-color: color-mix(in srgb, var(--demp) 45%, var(--strek));
}

/* A date's calendar icon in the muted colour. */
input::-webkit-calendar-picker-indicator {
  opacity: 0.6;
  cursor: pointer;
}

input::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}

input:not([type=checkbox], [type=radio]):hover,
select:hover,
textarea:hover {
  border-color: color-mix(in srgb, var(--demp) 45%, var(--strek));
}

input:not([type=checkbox], [type=radio]):focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--burgund);
  box-shadow: var(--ring);
}

input::placeholder,
textarea::placeholder {
  color: var(--demp);
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--demp);
  background-color: var(--stripe);
  cursor: not-allowed;
}

/* A select draws its own chevron (Lucide's), as Bilagsflyt's does. */
select {
  padding-right: var(--space-8);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233C0025' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right var(--space-3) center;
  background-size: 16px;
  appearance: none;
  cursor: pointer;
}

select[multiple] {
  padding-right: var(--space-3);
  background-image: none;
}

/* Checkboxes and radio buttons drawn in the house's way, as Bilagsflyt
   draws them: 16px, a warm edge, burgundy with a cream tick when on. */
input[type=checkbox],
input[type=radio] {
  display: inline-grid;
  flex-shrink: 0;
  place-content: center;
  width: 16px;
  height: 16px;
  margin: 0;
  vertical-align: middle;
  background: var(--hvit) center / 12px no-repeat;
  border: 1.5px solid color-mix(in srgb, var(--demp) 70%, var(--hvit));
  border-radius: var(--radius-sm);
  appearance: none;
  cursor: pointer;
  transition: background-color var(--tid-trykk) var(--ease-trykk),
    border-color var(--tid) var(--ease), box-shadow var(--tid) var(--ease);
}

input[type=radio] {
  border-radius: 50%;
}

input[type=checkbox]:hover:not(:disabled),
input[type=radio]:hover:not(:disabled) {
  border-color: var(--burgund);
}

input[type=checkbox]:checked {
  background-color: var(--burgund);
  background-image: var(--i-hake);
  border-color: var(--burgund);
}

input[type=checkbox]:indeterminate {
  background-color: var(--burgund);
  background-image: var(--i-strek);
  border-color: var(--burgund);
}

input[type=radio]:checked {
  background: var(--burgund);
  border-color: var(--burgund);
  box-shadow: inset 0 0 0 3px var(--hvit);
}

input[type=checkbox]:disabled,
input[type=radio]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* A checkbox and its label, side by side. */
.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-light);
  cursor: pointer;
}

.check input {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Fields side by side, wrapping onto new lines where they don't fit. */
.row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
}

.row .field {
  flex: 1;
  min-width: 200px;
}

/* Filters over a table or list, bottom-aligned with their button. */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  margin-bottom: var(--space-4);
}

.toolbar .field {
  margin: 0;
  min-width: 160px;
}

.toolbar .field.grow {
  flex: 1;
}

.toolbar .field.compact {
  min-width: 90px;
}

.toolbar .check {
  margin-bottom: var(--space-2);
}

.actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* --- Content ---------------------------------------------------------------- */

/* A result or status box: a cream card with a warm edge and the soft
   shadow (Stemma's .kort); done in green, failed in red, each with a bar
   in its colour at the left (Bilagsflyt's notice). */
.card {
  margin-top: var(--space-6);
  padding: var(--space-5) var(--space-6);
  line-height: var(--leading);
  background: var(--kort);
  border: 1px solid var(--strek-svak);
  border-radius: var(--radius-lg);
  box-shadow: var(--skygge);
}

.card.done {
  color: color-mix(in srgb, var(--ok) 70%, var(--burgund));
  background: var(--ok-flate);
  border-color: transparent;
  box-shadow: inset 3px 0 0 var(--ok);
}

.card.error {
  color: var(--avvik);
  background: var(--avvik-flate);
  border-color: var(--avvik-strek);
  box-shadow: inset 3px 0 0 var(--avvik);
}

/* Something went wrong loading the page's data. */
.alert {
  padding: var(--space-3) var(--space-4);
  line-height: var(--leading);
  color: var(--avvik);
  background: var(--avvik-flate);
  border: 1px solid var(--avvik-strek);
  border-radius: var(--radius);
}

/* Label/value pairs. */
dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: var(--space-1) var(--space-4);
  margin: 0;
  font-size: var(--text-sm);
}

dt {
  font-weight: var(--weight-medium);
}

dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

/* A status in a pill, as Bilagsflyt's .bf-chip (Stemma's .pill): lilla by
   default; one class per status picks its colour. */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  min-height: 22px;
  padding: 0 var(--space-2);
  font-size: var(--text-2xs);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--lilla-tekst);
  background: var(--lilla);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
}

.tag.done,
.tag.succeeded,
.tag.xledger {
  color: color-mix(in srgb, var(--ok) 88%, var(--burgund));
  background: var(--ok-flate);
}

.tag.error,
.tag.failed,
.tag.reject {
  color: var(--avvik);
  background: var(--avvik-flate);
}

/* Not done yet, or nothing to show: outlined, so it shows on any card. */
.tag.queued,
.tag.running,
.tag.idle,
.tag.cancelled,
.tag.off,
.tag.leave {
  color: var(--burgund);
  background: var(--kort);
  border-color: var(--strek);
}

.tag.cancelled,
.tag.off {
  color: var(--demp);
  border-style: dashed;
}

.count {
  margin: 0 0 var(--space-3);
  font-size: var(--text-sm);
  color: var(--demp);
}

.pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
  font-size: var(--text-sm);
}

.progress {
  height: var(--space-2);
  overflow: hidden;
  background: var(--sand);
  border-radius: var(--radius-pill);
}

.card .progress {
  background: var(--strek-svak);
}

.progress div {
  width: 0;
  height: 100%;
  background: var(--burgund);
  border-radius: var(--radius-pill);
  transition: width 0.5s var(--ease);
}

.spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: var(--space-2);
  vertical-align: -1px;
  border: 2px solid var(--burgund);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* --- Tables ----------------------------------------------------------------- */

/* Every table sits in a .table-wrap: a white card with a warm edge and
   the soft shadow (Stemma's table in its frame). It scrolls sideways when
   the table is wider than the page, and down once it's taller than the
   screen below the band, with the column headings stuck to its top. */
.table-wrap {
  max-height: calc(100dvh - var(--header-height) - var(--space-8));
  overflow: auto;
  background: var(--hvit);
  border: 1px solid var(--strek);
  border-radius: var(--radius-lg);
  box-shadow: var(--skygge);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

th,
td {
  padding: var(--space-2) var(--space-3);
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--strek-svak);
}

/* Stemma's heading: on sand in the muted colour, not capitals. A shadow,
   not a border: a collapsed border scrolls away from a sticky cell. */
th {
  position: sticky;
  top: 0;
  z-index: 1;
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  white-space: nowrap;
  vertical-align: middle;
  color: var(--demp);
  background: var(--sand);
  border-bottom: 0;
  box-shadow: inset 0 -1px 0 var(--strek);
}

tbody tr:last-child > td {
  border-bottom: 0;
}

tbody tr:hover > td {
  background: var(--stripe);
}

td.nowrap {
  white-space: nowrap;
}

/* A table body whose rows open something (a row's details, an edit form). */
.clickable-rows tr {
  cursor: pointer;
}

.clickable-rows tr:hover td {
  background: var(--tint);
}

/* --- Dialogs ---------------------------------------------------------------- */

/* A card over a dimmed page: 14px corners, the large soft shadow. */
dialog {
  width: min(640px, calc(100vw - var(--space-8)));
  max-height: calc(100dvh - var(--space-8) * 2);
  padding: 0;
  line-height: var(--leading);
  color: var(--burgund);
  background: var(--kort);
  border: 1px solid var(--strek);
  border-radius: var(--radius-lg);
  box-shadow: var(--skygge-lg);
}

dialog::backdrop {
  background: var(--overlay);
}

dialog[open] {
  animation: dialog-in 0.32s var(--ease);
}

@keyframes dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
}

/* The padding is here, not on the dialog: a click on the dialog itself
   is then a click on the backdrop. */
.dialog-body {
  padding: var(--space-6);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--strek-svak);
}

.dialog-head h3 {
  margin: 0;
  font-size: var(--text-xl);
}

/* A square button with just its glyph: the dialog's ×. */
button.close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--kontroll-h-s);
  height: var(--kontroll-h-s);
  font-size: var(--text-icon);
  line-height: 1;
  color: var(--demp);
  border-radius: var(--radius);
  transition: background-color var(--tid) var(--ease), color var(--tid) var(--ease);
}

button.close:hover {
  color: var(--burgund);
  background: var(--sand);
}

dialog h4 {
  margin: var(--space-5) 0 var(--space-2);
}

/* A form dialog's buttons: at its end, with a `.start` one (e.g. delete)
   pushed to the other side. */
.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--strek-svak);
}

.dialog-actions .start {
  margin-right: auto;
}

/* A thing's changes, in its edit dialog (a company, an account): newest
   first, each with who and what changed. */
.history {
  margin-top: var(--space-5);
  padding-top: var(--space-3);
  font-size: var(--text-sm);
  border-top: 1px solid var(--strek-svak);
}

.history summary {
  font-weight: var(--weight-medium);
}

.history .count {
  margin: var(--space-2) 0;
}

.history-entries {
  max-height: 240px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.history-entries li {
  padding: var(--space-2) 0;
  border-top: 1px solid var(--strek-svak);
}

.history-entries .who {
  font-weight: var(--weight-medium);
}

.history-entries dl {
  margin-top: var(--space-1);
}

@media (prefers-reduced-motion: reduce) {
  *,
  ::before,
  ::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

[hidden] {
  display: none !important;
}
