/* =============================================================================
   Mitab — hand-rolled design system (Phase 3, shadcn-inspired visual refresh).
   One stylesheet. No framework, no preprocessor, no remote @import, no webfont.
   Ported 1:1 from docs/design/phase3-visual-refresh-mockup.html onto the REAL
   view class names (this is a restyle — markup churn is minimal).

   Token model mirrors shadcn/ui: a semantic light token block in :root and a
   full [data-theme="dark"] override block. The theme is set on <html> by the
   render-blocking wwwroot/js/theme-init.js (no-flash) and flipped by the top-bar
   toggle in wwwroot/js/mitab-ui.js (persisted in localStorage).

   Section order: tokens → reset/base → app shell → page head → tables → forms
   → buttons → badges → alerts → cards/dl → map → right rail + calendar → responsive.
   ============================================================================= */

/* ------------------------------------------------------------------ tokens -- */
:root {
  /* Tell the browser to paint native control internals (date/time picker glyphs,
     the popup calendar, spin buttons, scrollbars) for a LIGHT scheme. Flipped to
     dark below so those glyphs stay visible on the dark background (QA 2026-07-23). */
  color-scheme: light;

  /* Neutrals — Tokyo Night "Day", tiered for elevation: a recessed lavender-grey ground,
     near-white raised cards, and a subtle band tint that sits ABOVE the ground (never a
     dark stripe). Keeps the soft navy-on-lavender feel without the flat, dull greys. */
  --background:          #e1e2e7;   /* recessed page ground */
  --foreground:          #343b58;
  --card:                #f7f8fc;   /* raised surfaces — bright, faint blue */
  --card-foreground:     #343b58;
  --muted:               #e7e9f2;   /* subtle band/hover tint — above the ground, below card */
  --muted-foreground:    #565f89;
  --accent:              #e9ebf3;   /* hover/ghost surface (shadcn "accent") */
  --accent-foreground:   #343b58;
  --border:              #d5d8e4;   /* softened so 1px outlines don't read as heavy/boxy */
  --input:               #c9cddd;
  --ring:                #2e7de9;

  /* Brand accent — Tokyo Night Day blue. */
  --primary:             #2e7de9;
  --primary-hover:       #1c68d4;
  --primary-foreground:  #f7f8fc;
  --primary-weak:        #d6e2fb;

  /* Secondary (filled neutral button). */
  --secondary:           #d7d9e3;
  --secondary-foreground:#343b58;

  /* Semantic — Tokyo Night Day accents (separate from the primary hue). */
  --success:      #587539; --success-fg:#3d5220; --success-bg:#dde9c9; --success-bd:#bcd09b;
  --warn:         #8c6c3e; --warn-fg:   #6b4e1f; --warn-bg:   #f0e6cd; --warn-bd:   #dcc48a;
  --destructive:  #f52a65; --destr-fg:  #b21e49; --destr-bg:  #f6d6df; --destr-bd:  #eaa9bc;

  --star:         #b15c00;   /* "startar denna dag" marker (Tokyo Night Day orange, reads as flag) */

  /* Typography — system stack, no web fonts. */
  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, "Apple Color Emoji", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --fs-xs: .75rem;  --fs-sm: .8125rem; --fs-base: .875rem; --fs-md: 1rem;
  --fs-lg: 1.25rem; --fs-xl: 1.5rem;

  /* Radius / shadow / sizing. */
  --radius: .5rem;
  --shadow-xs: 0 1px 2px 0 rgba(52,59,88,.08);
  --shadow-sm: 0 1px 2px 0 rgba(52,59,88,.11), 0 1px 3px 0 rgba(52,59,88,.09);
  --shadow-md: 0 4px 14px -4px rgba(52,59,88,.18), 0 2px 6px -3px rgba(52,59,88,.12);
  --control-h: 2.25rem;
  --maxw: 74rem;
  --header-h: 3.5rem;

  /* Focus ring (2px page-coloured gap + 2px accent). */
  --focus-ring: 0 0 0 2px var(--background), 0 0 0 4px var(--ring);
}

[data-theme="dark"] {
  /* Paint native control internals for a DARK scheme so the date/time picker
     glyphs (::-webkit-calendar-picker-indicator) and the native popup calendar
     are visible on the dark background, not dark-on-dark (QA 2026-07-23). */
  color-scheme: dark;

  /* Tokyo Night "Night": deep desaturated navy grounds and soft lavender text, so the
     dark theme is easy on the eyes rather than white-on-black. */
  --background:          #1a1b26;
  --foreground:          #c0caf5;
  --card:                #1f2335;
  --card-foreground:     #c0caf5;
  --muted:               #24283b;
  --muted-foreground:    #7f88b3;
  --accent:              #24283b;
  --accent-foreground:   #c0caf5;
  --border:              #2a2e42;
  --input:               #2c3048;
  --ring:                #7aa2f7;

  --primary:             #7aa2f7;
  --primary-hover:       #8fb4ff;
  --primary-foreground:  #16161e;
  --primary-weak:        #23324e;

  --secondary:           #292e42;
  --secondary-foreground:#c0caf5;

  --success:#9ece6a; --success-fg:#b9e08b; --success-bg:#1f2a1a; --success-bd:#35502a;
  --warn:   #e0af68; --warn-fg:   #ecc07f; --warn-bg:   #2a2417; --warn-bd:   #4a3f22;
  --destructive:#f7768e; --destr-fg:#f79bad; --destr-bg:#2b2130; --destr-bd:#4d3340;

  --star:#ff9e64;
  --shadow-xs: 0 1px 2px 0 rgba(0,0,0,.4);
  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,.5);
  --shadow-md: 0 6px 18px -4px rgba(0,0,0,.6);
}

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

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

body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font: var(--fs-base)/1.55 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
  color: var(--foreground);
  margin: 0 0 var(--fs-base);
  line-height: 1.2; letter-spacing: -.01em; text-wrap: balance;
}
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-md); }

p { margin: 0 0 var(--fs-base); }

a { color: var(--primary); text-decoration: none; }
a:hover, a:focus-visible { text-decoration: underline; }

img, svg, canvas { max-width: 100%; }
svg { display: block; }
button { font: inherit; }

/* Single visible focus style for every interactive element. Never removed without replacement. */
:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
  border-radius: calc(var(--radius) - 2px);
}

/* Screen-reader-only utility (skip link, star hint, etc.). */
.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 link becomes visible on focus. */
.skip-link {
  position: absolute; left: .75rem; top: -3rem;
  background: var(--card); color: var(--primary);
  padding: .5rem .75rem; border-radius: var(--radius);
  box-shadow: var(--shadow-sm); z-index: 100;
  transition: top .12s ease;
}
.skip-link:focus { top: .75rem; }

.is-hidden { display: none !important; }
.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-muted, .muted { color: var(--muted-foreground); }

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

/* --------------------------------------------------------------- app shell -- */
.app-header {
  position: sticky; top: 0; z-index: 50;
  /* Tint from the raised card surface (not the recessed ground) so the bar reads
     bright like the cards below it, keeping a hint of frosted translucency. */
  background: color-mix(in srgb, var(--card) 88%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.nav {
  max-width: var(--maxw);
  margin: 0 auto;
  min-height: var(--header-h);
  padding: 0 1.25rem;
  display: flex; align-items: center; gap: 1.25rem;
}

.nav-brand {
  display: inline-flex; align-items: center; gap: .5rem;
  font-weight: 650; letter-spacing: -.02em; font-size: var(--fs-md);
  color: var(--foreground); text-decoration: none;
}
.nav-brand:hover, .nav-brand:focus-visible { text-decoration: none; }
.nav-brand__logo {
  height: 1.375rem; width: auto; display: block; flex: none;
  /* raster wordmark with transparent bg — sits on both the light and dark header */
}

.nav-links {
  display: flex; align-items: center; gap: .125rem;
  list-style: none; margin: 0; padding: 0;
}
.nav-link {
  display: inline-flex; align-items: center; height: 2rem;
  padding: 0 .625rem; border-radius: calc(var(--radius) - 2px);
  color: var(--muted-foreground); text-decoration: none;
  font-weight: 500; font-size: var(--fs-base);
}
.nav-link:hover, .nav-link:focus-visible {
  background: var(--accent); color: var(--foreground); text-decoration: none;
}
.nav-link[aria-current="page"] { color: var(--foreground); font-weight: 550; }

.nav-auth { margin-left: auto; display: flex; align-items: center; gap: .625rem; }
.nav-user { color: var(--muted-foreground); font-size: var(--fs-sm); }

/* Icon button (theme toggle, mobile nav disclosure). */
.icon-btn, .nav-toggle {
  height: var(--control-h); width: var(--control-h);
  display: grid; place-items: center; cursor: pointer;
  background: transparent; color: var(--muted-foreground);
  border: 1px solid var(--border); border-radius: calc(var(--radius) - 2px);
}
.icon-btn:hover, .nav-toggle:hover { background: var(--accent); color: var(--foreground); }
.icon-btn svg, .nav-toggle svg { width: 1.1rem; height: 1.1rem; }

/* Theme toggle sun/moon swap driven by [data-theme] on <html>. */
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }

.nav-toggle { display: none; }

.app-main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}

.app-footer {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  border-top: 1px solid var(--border);
  color: var(--muted-foreground); font-size: var(--fs-sm);
}

/* ------------------------------------------------------------- page head --- */
.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h1, .page-head h2 { margin: 0; }
.date-header { font-size: var(--fs-xl); text-transform: none; }

.stack { display: grid; gap: .85rem; }
.stack > h3 { margin: 0; }
.row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.row--between { justify-content: space-between; }

/* Daily-schedule two-region grid (table + rail); map spans full width below. */
.schedule-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17rem;
  gap: 1.25rem;
  align-items: start;
}
.schedule-layout .rail { grid-column: 2; }
.schedule-layout .map { grid-column: 1 / -1; }

/* ------------------------------------------------------------------ tables -- */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.table { width: 100%; border-collapse: collapse; font-size: var(--fs-base); }

.table th {
  text-align: left;
  color: var(--muted-foreground);
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--card);
}

.table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
/* No row-hover tint on any table — the rows aren't row-level links, so the
   highlight was just noise (maintainer, 2026-07-23). */

.table .num { font-variant-numeric: tabular-nums; color: var(--muted-foreground); }

/* Group-header row on the daily schedule. */
.table__group-row th {
  background: var(--muted);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: .5rem .85rem;
}
.table__group-row:hover th { background: var(--muted); }
.table__group {
  display: flex; align-items: center; gap: .6rem;
  margin: 0; font-size: var(--fs-xs); font-weight: 700;
  letter-spacing: .07em; text-transform: uppercase; color: var(--foreground);
}

.cell-star { width: 2.25rem; text-align: center; }
.cell-star svg { width: .95rem; height: .95rem; display: inline-block; color: var(--star); vertical-align: middle; }

.cell-time { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 550; }

.table__empty { color: var(--muted-foreground); font-style: italic; }

/* ------------------------------------------------------------------- forms -- */
.form { max-width: 34rem; }

.field { display: grid; gap: .4rem; margin-bottom: 1rem; }

.label {
  display: block; font-weight: 550; font-size: var(--fs-base);
  color: var(--foreground); margin: 0;
}
.label .req { color: var(--muted-foreground); font-weight: 400; }

.input, .select, .textarea {
  display: block; width: 100%; max-width: 32rem;
  height: var(--control-h);
  padding: 0 .7rem;
  font: inherit; color: var(--foreground);
  background: var(--background);
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  transition: border-color .12s, box-shadow .12s;
}
.textarea { height: auto; min-height: 5.5rem; padding: .55rem .7rem; resize: vertical; line-height: 1.5; }

.select {
  appearance: none; -webkit-appearance: none;
  padding-right: 2rem; cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat; background-position: right .6rem center;
}

.input::placeholder, .textarea::placeholder { color: var(--muted-foreground); }

.input--date, .input--time { max-width: 12rem; }
.input--sm { height: 2rem; }

.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--ring);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--ring) 28%, transparent);
}

/* Invalid states — native, tag-helper, client-mirror (is-invalid), and hand-authored
   markers all map to the same destructive highlight. */
.input--error,
.input[aria-invalid="true"], .select[aria-invalid="true"], .textarea[aria-invalid="true"],
.input.is-invalid, .select.is-invalid, .textarea.is-invalid,
.input-validation-error {
  border-color: var(--destructive) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--destructive) 22%, transparent);
}

.field-error, .field-validation-error {
  display: block; color: var(--destructive); font-size: var(--fs-sm); font-weight: 500;
}

/* Checkbox / switch row (the .checkbox wrapper div holds an <input> + <label>). */
.checkbox { display: flex; align-items: center; gap: .55rem; margin-bottom: 1rem; }
.field .checkbox { margin-bottom: 0; }
.checkbox .label, .checkbox label { margin: 0; font-weight: 500; cursor: pointer; }

/* Custom checkbox (e.g. Kom ihåg mig). */
.checkbox input[type="checkbox"]:not(.switch) {
  appearance: none; -webkit-appearance: none;
  width: 1.05rem; height: 1.05rem; margin: 0; cursor: pointer; flex: none;
  border: 1px solid var(--input); border-radius: 5px; background: var(--background);
  display: grid; place-content: center; transition: background .12s, border-color .12s;
}
.checkbox input[type="checkbox"]:not(.switch)::after {
  content: ""; width: .55rem; height: .55rem; transform: scale(0);
  background: var(--primary-foreground); transition: transform .12s;
  clip-path: polygon(14% 44%, 0 65%, 43% 100%, 100% 16%, 82% 0, 39% 68%);
}
.checkbox input[type="checkbox"]:not(.switch):checked { background: var(--primary); border-color: var(--primary); }
.checkbox input[type="checkbox"]:not(.switch):checked::after { transform: scale(1); }

/* Switch (Hela dagen / Fakturerad / Såld). */
.switch {
  appearance: none; -webkit-appearance: none;
  position: relative; cursor: pointer; margin: 0; flex: none;
  width: 2.25rem; height: 1.25rem; border-radius: 999px;
  background: var(--muted); border: 1px solid var(--border);
  transition: background .15s, border-color .15s;
}
.switch::after {
  content: ""; position: absolute; top: 50%; left: 2px; transform: translateY(-50%);
  width: .95rem; height: .95rem; border-radius: 999px; background: #fff;
  box-shadow: var(--shadow-xs); transition: left .15s;
}
.switch:checked { background: var(--primary); border-color: var(--primary); }
.switch:checked::after { left: calc(100% - .95rem - 2px); }

.form-actions {
  display: flex; align-items: center; gap: .5rem;
  margin-top: 1.5rem; flex-wrap: wrap;
}
.btn--end { margin-left: auto; }

/* ----------------------------------------------------------------- buttons -- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem;
  height: var(--control-h);
  padding: 0 .9rem; white-space: nowrap; cursor: pointer;
  font-size: var(--fs-base); font-weight: 550; line-height: 1;
  border: 1px solid transparent; border-radius: calc(var(--radius) - 2px);
  text-decoration: none;
  transition: background .12s, color .12s, border-color .12s, box-shadow .12s;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 1rem; height: 1rem; }
.btn--sm { height: 1.9rem; padding: 0 .65rem; font-size: var(--fs-sm); }

.btn-primary { background: var(--primary); color: var(--primary-foreground); box-shadow: var(--shadow-xs); }
.btn-primary:hover, .btn-primary:focus-visible { background: var(--primary-hover); color: var(--primary-foreground); }

.btn-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.btn-secondary:hover, .btn-secondary:focus-visible { background: color-mix(in srgb, var(--secondary) 82%, var(--foreground) 6%); }

.btn-danger { background: var(--destructive); color: #fff; box-shadow: var(--shadow-xs); }
.btn-danger:hover, .btn-danger:focus-visible { background: color-mix(in srgb, var(--destructive) 88%, #000 12%); color: #fff; }

.btn-outline { background: var(--background); color: var(--foreground); border-color: var(--border); box-shadow: var(--shadow-xs); }
.btn-outline:hover, .btn-outline:focus-visible { background: var(--accent); color: var(--foreground); }

.btn-ghost { background: transparent; color: var(--foreground); }
.btn-ghost:hover, .btn-ghost:focus-visible { background: var(--accent); color: var(--foreground); }

.btn-link {
  background: none; border: none; padding: 0; height: auto;
  color: var(--primary); font-weight: 550; cursor: pointer; font-size: var(--fs-base);
}
.btn-link:hover, .btn-link:focus-visible { text-decoration: underline; }

.btn[disabled], .btn[aria-disabled="true"] { opacity: .55; cursor: default; pointer-events: none; }

/* Leading "+" glyph for "Ny …" actions (no glyphicon font). */
.btn--add::before { content: "+"; font-size: 1.1em; line-height: 1; font-weight: 700; }

/* ------------------------------------------------------------------ badges -- */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1;
  padding: .28rem .55rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
  letter-spacing: normal; text-transform: none;
}
.badge-primary   { background: var(--primary); color: var(--primary-foreground); }
.badge-secondary { background: var(--secondary); color: var(--secondary-foreground); }
.badge-outline   { background: transparent; color: var(--muted-foreground); border-color: var(--border); }
.badge-success   { background: var(--success-bg); color: var(--success-fg); border-color: var(--success-bd); }
.badge-warn      { background: var(--warn-bg); color: var(--warn-fg); border-color: var(--warn-bd); }
.badge-destructive { background: var(--destr-bg); color: var(--destr-fg); border-color: var(--destr-bd); }
.badge .dot { width: .45rem; height: .45rem; border-radius: 999px; background: currentColor; }

/* ------------------------------------------------------------------ alerts -- */
.alert {
  display: flex; flex-wrap: wrap; gap: .7rem; align-items: flex-start;
  padding: .8rem .9rem; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--card);
  font-size: var(--fs-base); margin-bottom: 1rem;
}
.alert svg { width: 1.05rem; height: 1.05rem; flex: none; margin-top: .1rem; }
.alert__body { flex: 1; min-width: 0; }
.alert__body h2, .alert__body h3 { font-size: var(--fs-base); margin: 0 0 .35rem; }
/* asp-validation-summary injects the <ul> as a direct child of .alert (sibling of
   .alert__body): drop it onto its own full-width row and give it a sane indent. */
.alert ul { flex-basis: 100%; margin: 0; padding-left: 1.25rem; }
.alert__close {
  background: none; border: none; cursor: pointer;
  font-size: 1.15rem; line-height: 1; color: inherit; opacity: .6;
  padding: 0; margin: 0;
}
.alert__close:hover { opacity: 1; }

.alert--success { background: var(--success-bg); border-color: var(--success-bd); color: var(--success-fg); }
.alert--warn    { background: var(--warn-bg);    border-color: var(--warn-bd);    color: var(--warn-fg); }
.alert--danger  { background: var(--destr-bg);   border-color: var(--destr-bd);   color: var(--destr-fg); }
.alert--danger h2, .alert--danger h3 { color: var(--destr-fg); }
.alert--danger a { color: var(--destr-fg); }

/* The validation-summary-valid state is toggled by the tag helper. */
.validation-summary-valid { display: none; }

/* ------------------------------------------------------------- cards / dl -- */
.card {
  background: var(--card); color: var(--card-foreground);
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.25rem;
}
.card--narrow { max-width: 26rem; margin: 2rem auto; }

/* Sectioned card (head / body / foot) — padding lives on the sections, so the card
   itself is flush. Used by the entity forms and the detail-peek header. */
.card--sections { padding: 0; overflow: hidden; }
.card__head { padding: 1.1rem 1.25rem .35rem; }
.card__head h3 { font-size: var(--fs-md); font-weight: 600; margin: 0; }
.card__head .desc { color: var(--muted-foreground); font-size: var(--fs-sm); margin: .2rem 0 0; }
.card__body { padding: 1.25rem; }
.card__foot {
  padding: .9rem 1.25rem; border-top: 1px solid var(--border);
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
}

/* Two-column form grid; .col-2 spans the full width. */
.formgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; }
.formgrid .field { margin-bottom: 0; }
.formgrid .col-2 { grid-column: 1 / -1; }
.formgrid .field--switch { align-self: end; }
.formgrid .field--switch .checkbox { min-height: var(--control-h); align-items: center; margin-bottom: 0; }

.section-label {
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted-foreground); margin: .35rem 0 .6rem;
}
.divider { height: 1px; background: var(--border); border: 0; margin: 1.25rem 0; }

.dl { margin: 0; }
.dl dt { color: var(--muted-foreground); font-size: var(--fs-sm); font-weight: 500; }
.dl dd { margin: 0 0 .75rem; font-size: var(--fs-base); }
.dl dd:last-child { margin-bottom: 0; }

@media (min-width: 40rem) {
  .dl {
    display: grid;
    grid-template-columns: minmax(8rem, 14rem) 1fr;
    column-gap: 1.5rem; row-gap: .55rem;
    align-items: baseline;
  }
  .dl dt { margin: 0; }
  .dl dd { margin: 0; }
}

/* -------------------------------------------------------------------- map -- */
.map {
  width: 100%;
  height: 420px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  position: relative;
  overflow: hidden;
}
/* Booking-details map (UAT 2026-10-13): a little taller than before (320px felt cramped) and with
   breathing room below the field list. Phones keep the compact height (≤48rem override below).
   Print keeps its own fixed 640×320 size and spacing (@media print). */
.map--detail { height: 400px; }
.dl + .map, .dl + .map-placeholder { margin-top: 1.5rem; }
/* Fixed print size (UAT 2026-10-12). Applied just before printing by mitab-map.js (.map--printing)
   AND by @media print below — the two MUST stay identical, so the print layout never resizes the
   already-redrawn canvas (which is what stretched/squeezed the map). 640×320 px fits A4 and Letter
   portrait inside the @page margins. */
.map.map--printing { width: 640px; height: 320px; }

.map__caption {
  position: absolute; left: .75rem; bottom: .75rem;
  background: color-mix(in srgb, var(--card) 92%, transparent);
  border: 1px solid var(--border);
  padding: .28rem .6rem;
  border-radius: calc(var(--radius) - 2px);
  font-size: var(--fs-xs); color: var(--muted-foreground);
  pointer-events: none; box-shadow: var(--shadow-xs);
}
.map__fallback {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted-foreground); font-size: var(--fs-sm); text-align: center; padding: 1rem;
}

/* Inert placeholder shown when the MapTiler client key is unset (not an error). */
.map-placeholder {
  width: 100%; height: 160px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--muted);
  color: var(--muted-foreground); font-size: var(--fs-sm);
}

/* Red booking pin / blue HQ pin (CSS teardrop markers attached to maplibregl.Marker element). */
.map-pin {
  width: 1rem; height: 1rem;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(255,255,255,.9);
  box-shadow: 0 1px 2px rgba(0,0,0,.4);
  cursor: pointer;
}
.map-pin--booking { background: var(--destructive); }
.map-pin--hq { background: var(--primary); }
/* MapLibre popups (the persistent address label on the detail map) always have a white background
   (maplibre-gl.css), so their text must not inherit the theme's foreground — in the dark theme
   that is a pale tint and the label was barely legible (UAT 2026-10-12). */
.maplibregl-popup-content { color: #1a1b26; }

/* ------------------------------------------------------- right rail + cal -- */
.rail { display: grid; gap: 1.25rem; position: sticky; top: 4.5rem; align-content: start; }
.rail-block {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.1rem 1.25rem;
}
.rail-block h3 { font-size: var(--fs-md); font-weight: 600; margin: 0 0 .75rem; }
.rail-date-form { display: flex; align-items: flex-end; gap: .5rem; flex-wrap: wrap; }
.rail-date-form .field { margin: 0; flex: 1; }
.rail-cal-sep { height: 1px; background: var(--border); border: 0; margin: .85rem 0; }
.rail-list { list-style: none; margin: 0; padding: 0; }
.rail-list li {
  padding: .45rem .1rem; font-size: var(--fs-base);
  border-bottom: 1px solid var(--border);
}
.rail-list li:last-child { border-bottom: none; }
.rail-empty { color: var(--muted-foreground); font-size: var(--fs-sm); font-style: italic; margin: 0; }

/* Mini-calendar (JS-populated; native date input below is the no-JS fallback). */
.cal:empty { display: none; }
.cal:empty + .rail-cal-sep { display: none; }
.cal { margin-bottom: .25rem; }
.cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
.cal__title { font-size: var(--fs-base); font-weight: 600; }
.cal__nav { display: flex; gap: .25rem; }
.cal__nav button {
  width: 1.75rem; height: 1.75rem; display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--border); background: var(--background); color: var(--muted-foreground);
  border-radius: calc(var(--radius) - 2px);
}
.cal__nav button:hover { background: var(--accent); color: var(--foreground); }
.cal__nav svg { width: .9rem; height: .9rem; }
/* Leading week-number gutter column + 7 day columns. */
.cal__grid { display: grid; grid-template-columns: 1.4rem repeat(7, 1fr); gap: 2px; }
.cal__dow {
  text-align: center; font-size: var(--fs-xs); font-weight: 600;
  color: var(--muted-foreground); padding: .2rem 0; text-transform: lowercase;
}
/* ISO week numbers — muted, non-interactive; separated from the days by a faint gutter rule. */
.cal__wk-head, .cal__wk {
  display: grid; place-items: center;
  font-size: var(--fs-xs); color: var(--muted-foreground);
  font-variant-numeric: tabular-nums;
  border-right: 1px solid var(--border);
}
.cal__wk-head { font-weight: 600; text-transform: lowercase; padding: .2rem 0; }
.cal__wk { opacity: .75; }
.cal__day {
  aspect-ratio: 1; border: 0; background: transparent; cursor: pointer;
  font-size: var(--fs-sm); color: var(--foreground);
  border-radius: calc(var(--radius) - 2px);
  font-variant-numeric: tabular-nums; display: grid; place-items: center;
}
.cal__day:hover { background: var(--accent); }
.cal__day.is-out { color: var(--muted-foreground); opacity: .5; }
.cal__day.is-selected { background: var(--primary); color: var(--primary-foreground); font-weight: 650; }
/* Today (UAT 2026-10-12): an inset primary ring + bold, text keeps --foreground (AA contrast in both
   themes; the ring is a ≥3:1 non-text indicator). Today AND selected: filled, with a thin light inner
   ring so "today" stays visible on the selected cell. Inset shadows never spill into the 2px gap. */
.cal__day.is-today { box-shadow: inset 0 0 0 1.5px var(--primary); font-weight: 650; }
.cal__day.is-today.is-selected {
  box-shadow: inset 0 0 0 2px var(--primary), inset 0 0 0 3.5px var(--primary-foreground);
}

/* ------------------------------------------------------------- responsive -- */
@media (max-width: 62rem) {
  .schedule-layout { grid-template-columns: 1fr; }
  .schedule-layout .rail,
  .schedule-layout .map { grid-column: 1; }
  .rail { position: static; grid-template-columns: 1fr 1fr; }
  .rail-block--available { grid-column: auto; }
}

@media (max-width: 48rem) {
  .app-main { padding: 1.25rem 1rem 3rem; }
  .nav-toggle { display: grid; margin-left: auto; }
  .nav-auth { margin-left: 0; }
  .nav-user { display: none; }
  .nav-links {
    display: none;
    flex-direction: column; align-items: stretch;
    position: absolute; left: 0; right: 0; top: var(--header-h);
    background: var(--card);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: .5rem; gap: 0;
  }
  .nav[data-open="true"] .nav-links { display: flex; }
  .nav-link { height: auto; padding: .75rem; }
  .rail { grid-template-columns: 1fr; }
  .map { height: 320px; }
  .map--detail { height: 260px; }
}

/* ----------------------------------------------- admin user administration -- */
/* Inline action cluster in the Användare table (ADR-0010). Each mutation is its own POST
   <form> (antiforgery), so the forms are laid out inline and wrap on narrow screens. */
.row-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .9rem; }
.row-actions form { display: inline; margin: 0; }
.btn-link--danger { color: var(--destr-fg); }

/* One-time generated password reveal (UI spec §2.1). */
code.otp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: 600; padding: .1rem .35rem; border-radius: var(--radius-sm, 4px);
  background: var(--muted); border: 1px solid var(--border); user-select: all;
}

/* ------------------------------------------------------------------ print -- */
/* Booking details are printed as job sheets for the person doing the job (UAT 2026-10-12): only
   the booking — title, the structured field list and the map — on white paper, whatever the
   on-screen theme. Navigation, footer, flash messages, buttons and map controls are dropped; the
   map attribution and any logo stay (MapTiler/OSM licence). */
@media print {
  @page { margin: 14mm; }

  :root,
  [data-theme="dark"] {
    color-scheme: light;
    --background: #fff; --foreground: #111;
    --card: #fff; --card-foreground: #111;
    --muted: #f2f2f2; --muted-foreground: #444;
    --border: #bbb;
    --star: #b15c00;
  }
  html, body { background: #fff !important; color: #111 !important; }

  .skip-link, .app-header, .app-footer, .alert, .hidden-print, .form-actions, .btn,
  .maplibregl-ctrl-top-left, .maplibregl-ctrl-top-right { display: none !important; }

  .app-main { max-width: none; margin: 0; padding: 0; }
  .card { border: 0; border-radius: 0; box-shadow: none; padding: 0; background: #fff; }
  .page-head { margin: 0 0 5mm; }
  .page-head h1, .page-head h2 { font-size: 18pt; }

  .dl {
    display: grid; grid-template-columns: 36mm 1fr;
    column-gap: 6mm; row-gap: 2.2mm; align-items: baseline;
  }
  .dl dt { margin: 0; color: #444; font-size: 9.5pt; font-weight: 600; }
  .dl dd { margin: 0; font-size: 11pt; }
  .dl dt, .dl dd { break-inside: avoid; }

  .map {
    width: 640px; height: 320px; margin-top: 6mm;
    border: 1px solid #bbb; border-radius: 0; background: #fff;
    break-inside: avoid;
  }
  .maplibregl-ctrl-attrib { font-size: 7pt; }

  /* Day overview (UAT 2026-10-13): print only the date heading and the grouped bookings table — no
     date picker / "Ledigt" rail, no map. Group headers are marked with a rule + bold text (browsers
     usually drop background colours in print); column headers repeat on every page; a booking row
     never splits, and a group header is kept with its first booking. */
  .schedule-layout { display: block; }
  .schedule-layout .rail, .schedule-layout .map, .schedule-layout .map-placeholder { display: none !important; }
  .date-header { font-size: 18pt; }
  .table-scroll { overflow: visible; border: 0; border-radius: 0; background: #fff; }
  .table { font-size: 9.5pt; line-height: 1.3; }
  .table thead { display: table-header-group; }
  .table th, .table td { padding: 1.1mm 1.8mm; border-bottom: 1px solid #ccc; background: #fff; }
  .table thead th { color: #444; font-size: 8.5pt; font-weight: 600; border-bottom: 1.5px solid #444; }
  .table tbody tr { break-inside: avoid; }
  .table__group-row th { background: #fff; border-top: 1.5px solid #444; border-bottom: 1px solid #888; padding-top: 3mm; }
  .table__group-row { break-after: avoid; }
  .table__group { font-size: 9pt; color: #111; }
  .table .num { color: #222; }
  a { color: inherit; text-decoration: none; }
}
