/* immos-web-shell — the Trinora design system's single stylesheet (plan/39).

   One file for every house web app: the token layer, the signed-in shell
   (topbar, tab nav, user menu), and the shared components. Transplanted from
   immos-manager-webapp's portal.css — the reference implementation of the
   Immos design system (Claude Design handoff, vendored there at
   design/handoff/immos-manager-ui-design); where apps disagreed, the
   manager's values are canonical. Hand-written, no build step; dark mode
   follows prefers-color-scheme with no toggle. Fonts are self-hosted —
   every shell must render offline (plan/03 §2.4).

   Load order is the override mechanism: an app's own CSS links AFTER this
   file and wins same-specificity conflicts by order — never !important. */
@font-face {
  font-family: "Archivo";
  src: url("../fonts/archivo-600.b18d7c2198ef.ttf") format("truetype");
  font-weight: 400 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-regular.4bc2240b8b83.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Sans";
  src: url("../fonts/ibm-plex-sans-semibold.f75f5cc52c38.ttf") format("truetype");
  font-weight: 500 700;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("../fonts/ibm-plex-mono-regular.6b63b3f38003.ttf") format("truetype");
  font-weight: 400 700;
  font-display: swap;
}

:root {
  /* Basalt neutrals (cool slate ramp) */
  --basalt-50: #f6f7f9;
  --basalt-100: #eceef2;
  --basalt-200: #d8dde4;
  --basalt-300: #b9c0cc;
  --basalt-400: #8b94a3;
  --basalt-500: #66707f;
  --basalt-600: #4b5563;
  --basalt-700: #363e4a;
  --basalt-800: #232a33;
  --basalt-900: #161b21;
  --basalt-950: #0d1116;
  --white: #ffffff;

  /* Teal — signature primary */
  --teal-100: #c3ede6;
  --teal-300: #5accbb;
  --teal-500: #0e9c8a;
  --teal-600: #0a7e70;
  --teal-700: #0a645a;

  /* Semantic hues */
  --green-100: #d9f2e3; --green-500: #1e9e5a; --green-600: #158048;
  --amber-100: #fbeecb; --amber-600: #b47f0e;
  --red-100: #fbdedd;   --red-500: #d83a3a;   --red-600: #bd2c2c; --red-700: #96201f;
  --blue-100: #dbe7fb;  --blue-600: #2159c1;

  /* Accent (default palette: teal) */
  --accent-tint: #c3ede6;
  --accent: #0e9c8a;
  --accent-hover: #0a7e70;
  --accent-strong: #0a645a;
  --accent-on: #ffffff;
  --accent-ring: rgba(14, 156, 138, 0.4);

  /* Semantic aliases — surfaces, text, borders, status */
  --surface-page: var(--basalt-50);
  --surface-card: var(--white);
  --surface-raised: var(--white);
  --surface-sunken: var(--basalt-100);
  --text-strong: var(--basalt-900);
  --text-body: var(--basalt-700);
  --text-muted: var(--basalt-500);
  --text-subtle: var(--basalt-400);
  --text-link: var(--accent-hover);
  --border-subtle: var(--basalt-200);
  --border-default: var(--basalt-300);
  --border-strong: var(--basalt-400);
  --divider: var(--basalt-200);
  --status-success: var(--green-600); --status-success-bg: var(--green-100);
  --status-warning: var(--amber-600); --status-warning-bg: var(--amber-100);
  --status-danger:  var(--red-600);   --status-danger-bg:  var(--red-100);
  --status-info:    var(--blue-600);  --status-info-bg:    var(--blue-100);

  /* Elevation — subtle, slate-tinted; borders over drop shadows */
  --shadow-sm: 0 1px 2px rgba(13, 17, 22, 0.06), 0 2px 4px rgba(13, 17, 22, 0.05);
  --shadow-lg: 0 4px 8px rgba(13, 17, 22, 0.06), 0 14px 28px rgba(13, 17, 22, 0.12);
  --shadow-focus: 0 0 0 3px var(--accent-ring);

  /* Type */
  --font-display: "Archivo", ui-sans-serif, system-ui, sans-serif;
  --font-sans: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --surface-page: var(--basalt-950);
    --surface-card: var(--basalt-900);
    --surface-raised: var(--basalt-800);
    --surface-sunken: #0a0d11;
    --text-strong: var(--basalt-50);
    --text-body: var(--basalt-200);
    --text-muted: var(--basalt-400);
    --text-subtle: var(--basalt-500);
    --text-link: var(--teal-300);
    --border-subtle: #2a333e;
    --border-default: var(--basalt-700);
    --border-strong: var(--basalt-600);
    --divider: #2a333e;
    --status-success: #4ec27e; --status-success-bg: #133021;
    --status-warning: #e8b84a; --status-warning-bg: #33280d;
    --status-danger:  #ec6a6a; --status-danger-bg:  #331616;
    --status-info:    #6f9ff0; --status-info-bg:    #14243f;
    --accent-tint: #133038;
    --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.35), 0 14px 28px rgba(0, 0, 0, 0.5);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-page);
  color: var(--text-body);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

:where(a) { color: var(--text-link); text-decoration: none; }
:where(a:hover) { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
@media (prefers-color-scheme: dark) {
  :where(a:hover) { color: var(--text-link); }
}

button, input, select, textarea { font-family: inherit; }
::placeholder { color: var(--text-subtle); opacity: 1; }
::selection { background: var(--accent-tint); color: var(--text-strong); }

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

/* Inline sprite icon: stroke properties live here so symbols stay bare. */
.i {
  display: block;
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.i-13 { width: 13px; height: 13px; }
.i-14 { width: 14px; height: 14px; }
.i-16 { width: 16px; height: 16px; }
.i-20 { width: 20px; height: 20px; }
.i-24 { width: 24px; height: 24px; }
.i [fill="currentColor"] { fill: currentColor; }

/* ===== Signed-in shell (the mockup's chrome) ============================== */

.topbar {
  background: var(--basalt-900);
  color: var(--basalt-100);
  height: 52px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: relative;
  z-index: 60;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -0.01em;
  white-space: nowrap;
}
/* No logo asset ships in the handoff bundle — the brand idea ("three stacked
   image layers", DS readme) is drawn as a Lucide "layers" glyph in the
   accent tile. Deviation recorded in plan/03's build log. */
.brand-tile {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-on);
  display: grid;
  place-items: center;
  flex: none;
}
.topbar-sp { flex: 1; }
.topbar form { display: flex; margin: 0; }
/* Plain text links in the bar (the staff Admin link): muted, hover lit. */
.topbar-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--basalt-300);
  background: none;
  border: 0;
  font: inherit;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
}
.topbar-link:hover { color: #fff; background: var(--basalt-800); text-decoration: none; }
/* Two-tone brand lockups ("immos id"): the bar is dark in both schemes, so
   the accent half always takes the lightened ramp value (the handoff's
   dark-lockup treatment). */
.topbar .brand-id { color: var(--teal-300); }
/* The brand-mark <img> (IMMOS_WEB_SHELL_BRAND_MARK_URL) replaces the accent
   tile at the same 26px box wherever the brand renders — topbar and card page
   alike. The artwork carries its own palette (the fixed-dark file rides the
   always-dark bar; the scheme-adaptive file serves light surfaces). */
.brand .mark { display: block; width: 26px; height: 26px; flex: none; }

/* <details> dropdowns (org switcher, user menu) — the reference app's
   disclosure pattern: summary styled as the trigger, menu drops below. */
.dd { position: relative; }
.dd > summary {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: 1px solid var(--basalt-700);
  color: #fff;
  font: inherit;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
}
.dd > summary::-webkit-details-marker { display: none; }
:where(.dd > summary):hover { background: var(--basalt-800); }
:where(.dd > summary):focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.dd--plain > summary { border-color: transparent; padding: 4px 8px 4px 4px; }
.dd-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 240px;
  background: var(--surface-raised);
  color: var(--text-body);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 70;
}
.dd--right .dd-menu { left: auto; right: 0; }
.dd-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 10px 6px;
}
.dd-item {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: none;
  border: 0;
  font: inherit;
  font-size: 14px;
  color: var(--text-strong);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  text-decoration: none;
}
:where(.dd-item):hover { background: var(--surface-sunken); }
.dd-item .sub { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dd-item .sub .muted { font-size: 12px; }
.dd-item .check { color: var(--accent); }
.dd-item-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.dd-item .ext { color: var(--text-muted); flex: none; }
.dd-head {
  padding: 10px 10px 12px;
  border-bottom: 1px solid var(--divider);
  margin-bottom: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.dd-head .muted { margin: 0; }
.dd-head .who { font-weight: 600; color: var(--text-strong); }
.dd-head .mail { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }

/* Accent tab bar under the topbar. */
.tabs-nav {
  background: var(--accent-hover);
  display: flex;
  padding: 0 16px;
  overflow-x: auto;
}
.tabs-nav a {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 96px;
  padding: 12px 14px 10px;
  border: 0;
  color: var(--accent-on);
  font-size: 13px;
  text-decoration: none;
  white-space: nowrap;
}
:where(.tabs-nav a):hover { background: var(--accent-strong); color: var(--accent-on); text-decoration: none; }
.tabs-nav a[aria-current="page"] { background: var(--accent-strong); font-weight: 600; }
:where(.tabs-nav a):focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--accent-ring); }
/* Attention dot on a tab (e.g. "two-factor is off"): pinned top-right, the
   nav's own hover shade as its ring. */
.tab-dot {
  position: absolute;
  top: 8px;
  right: 28px;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--status-warning);
  box-shadow: 0 0 0 2px var(--accent-hover);
}

.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 28px 24px 72px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Page heads. */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-head > div { display: flex; flex-direction: column; gap: 6px; }
h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-strong);
  margin: 0;
}
.summary { margin: 0; color: var(--text-muted); font-size: 14px; }
.backlink {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-link);
}
.meta { color: var(--text-muted); }

/* Object head (detail pages): tile + name + badges + id line. */
.obj-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.obj-head .ident { display: flex; gap: 16px; align-items: center; min-width: 0; }
.obj-head .ident > .ident-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tile {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  display: grid;
  place-items: center;
  flex: none;
  color: var(--text-body);
}
.tile-lg { width: 52px; height: 52px; }
.avatar-tile {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 14px;
  flex: none;
}
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.idline { display: flex; align-items: center; gap: 4px; font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); min-width: 0; }
.idline > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===== Cards =============================================================== */

.card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 24px;
  color: var(--text-body);
  box-shadow: var(--shadow-sm);
}
.card > :last-child { margin-bottom: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card--accent-top { border-top: 3px solid var(--accent); }
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--divider);
}
.card-head h2 {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-strong);
  margin: 0;
}
.card-head .count { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.card-sub { font-size: 13px; color: var(--text-muted); }
.card-body { padding-top: 14px; display: flex; flex-direction: column; gap: 14px; }
.card-foot {
  padding-top: 16px;
  margin-top: 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.split { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.split > .grow-lg { flex: 1.6 1 480px; min-width: 0; }
.split > .grow { flex: 1 1 320px; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; align-items: start; }
.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 440px), 1fr)); gap: 20px; align-items: start; }
.grid-cards-wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); }

/* Key-value grids (Identity cards, settings identifiers). */
.kv {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px 20px;
  padding-top: 14px;
  align-items: baseline;
}
.kv > .k { color: var(--text-muted); }
.kv > .v { color: var(--text-strong); min-width: 0; overflow-wrap: anywhere; }
.kv > .v-mono { font-family: var(--font-mono); font-size: 13px; color: var(--text-strong); min-width: 0; overflow-wrap: anywhere; }
.kv-labels { grid-template-columns: 110px minmax(0, 1fr); gap: 16px 20px; align-items: start; }

/* Stat cards (dashboard). */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; }
.statcard { display: flex; flex-direction: column; gap: 8px; color: inherit; text-decoration: none; }
:where(a.statcard):hover { text-decoration: none; border-color: var(--border-default); }
.statcard .eyebrow {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.statcard .eyebrow .i { color: var(--text-subtle); }
.statcard .value-sans {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.statcard .value-mono {
  font-family: var(--font-mono);
  font-size: 30px;
  font-weight: 500;
  line-height: 1.1;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.statcard .caption { font-size: 13px; color: var(--text-muted); text-wrap: pretty; }

/* ===== Buttons ============================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  -webkit-appearance: none;
  appearance: none;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.5; cursor: not-allowed; }
/* The display above would beat the UA's [hidden] rule — author styles win
   on origin, not specificity — so hiding must be spelled out again. */
.btn[hidden] { display: none; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-primary { background: var(--accent); color: var(--accent-on); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active, .btn-danger:active { transform: translateY(1px); }
.btn-secondary {
  background: var(--surface-card);
  color: var(--text-strong);
  border-color: var(--border-default);
}
.btn-secondary:hover { background: var(--surface-sunken); }
.btn-danger { background: var(--status-danger); color: #fff; }
.btn-danger:hover { background: var(--red-700); }
.btn-danger-ghost {
  background: transparent;
  color: var(--status-danger);
  border-color: transparent;
  font-weight: 500;
}
.btn-danger-ghost:hover { background: var(--surface-sunken); }
.btnlink-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--status-danger);
  cursor: pointer;
}
.btnlink-danger:hover { background: var(--surface-sunken); }
.iconbtn {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  background: none;
  border: 0;
  color: var(--text-muted);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  flex: none;
}
.iconbtn:hover { background: var(--surface-sunken); color: var(--text-strong); }
.iconbtn:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.iconbtn[disabled], .iconbtn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.iconbtn--danger { color: var(--status-danger); }
.btnrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Busy guard (the shared enhancement script): the submitter gets .is-busy. */
.btn.is-busy, .btnlink-danger.is-busy { cursor: progress; }
.btn.is-busy::before, .btnlink-danger.is-busy::before {
  content: "";
  flex: none;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: busy-spin 0.7s linear infinite;
}
@keyframes busy-spin { to { transform: rotate(1turn); } }
@media (prefers-reduced-motion: reduce) {
  .btn.is-busy::before, .btnlink-danger.is-busy::before { animation-duration: 1.6s; }
}

/* ===== Badges, tags, avatars, pills ======================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.badge--mono { font-family: var(--font-mono); }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.badge--success { background: var(--status-success-bg); color: var(--status-success); }
.badge--warning { background: var(--status-warning-bg); color: var(--status-warning); }
.badge--danger { background: var(--status-danger-bg); color: var(--status-danger); }
.badge--info { background: var(--status-info-bg); color: var(--status-info); }
.badge--neutral { background: var(--surface-sunken); color: var(--text-muted); }
.badge--accent { background: var(--accent-tint); color: var(--accent-strong); }
@media (prefers-color-scheme: dark) {
  .badge--accent { color: var(--teal-300); }
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  background: var(--surface-card);
  font-size: 12.5px;
  color: var(--text-body);
  white-space: nowrap;
}
.tag--mono { font-family: var(--font-mono); font-size: 12px; }
.tag-x {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  margin-right: -4px;
}
.tag-x:hover { background: var(--surface-sunken); color: var(--status-danger); }
.tag-x:focus-visible { outline: none; box-shadow: var(--shadow-focus); }

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 600;
  flex: none;
}
.avatar-lg { width: 32px; height: 32px; font-size: 12px; border-radius: 999px; }
.avatar-xl { width: 36px; height: 36px; font-size: 13px; }
.avatar--square { border-radius: 6px; background: var(--surface-sunken); color: var(--text-body); font-family: var(--font-mono); font-weight: 500; }
.avatar-more { background: var(--surface-sunken); color: var(--text-body); }
.avatar-stack { display: flex; align-items: center; padding-left: 6px; min-width: 0; }
.avatar-stack > * { margin-left: -6px; border: 2px solid var(--surface-card); }
.avatar-stack > *:first-child { margin-left: 0; }

.pills { display: flex; gap: 6px; flex-wrap: wrap; }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 13px;
  color: var(--text-body);
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.pill:hover { background: var(--surface-sunken); text-decoration: none; color: var(--text-strong); }
.pill[aria-current="true"] { background: var(--accent-tint); color: var(--accent-strong); font-weight: 600; }
.pill .count { font-size: 11px; color: inherit; opacity: 0.75; font-variant-numeric: tabular-nums; }

/* ===== Tables (the mockup's grid-tables as real <table>s) ================== */

.table-scroll { overflow-x: auto; }
.dtable {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-variant-numeric: tabular-nums;
}
.dtable th {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 400;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-default);
}
.dtable td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  vertical-align: middle;
  color: var(--text-body);
}
.dtable tr:last-child td { border-bottom: 0; }
.dtable a { color: var(--text-link); }
.dtable .cell-main { font-weight: 500; color: var(--text-strong); }
.dtable .cell-sub { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.dtable-devices th:nth-child(2), .dtable-devices td:nth-child(2) { width: 96px; }
.dtable-devices th:nth-child(3), .dtable-devices td:nth-child(3) { width: 104px; }
.dtable-devices th:nth-child(4), .dtable-devices td:nth-child(4) { width: 80px; }
.dtable-devices th:nth-child(5), .dtable-devices td:nth-child(5) { width: 190px; }
.dtable-devices th:nth-child(6), .dtable-devices td:nth-child(6) { width: 72px; }
.dtable-devices th:nth-child(7), .dtable-devices td:nth-child(7) { width: 100px; }
.dtable-people th:nth-child(2), .dtable-people td:nth-child(2) { width: 96px; }
.dtable-people th:nth-child(3), .dtable-people td:nth-child(3) { width: 64px; }
.dtable-people th:nth-child(4), .dtable-people td:nth-child(4) { width: 96px; }
.dtable-people th:nth-child(7), .dtable-people td:nth-child(7) { width: 92px; }
.dtable-groups th:nth-child(2), .dtable-groups td:nth-child(2) { width: 72px; }
.dtable-groups th:nth-child(4), .dtable-groups td:nth-child(4) { width: 130px; }
.dtable-commands th:nth-child(2), .dtable-commands td:nth-child(2) { width: 110px; }
.dtable-commands th:nth-child(3), .dtable-commands td:nth-child(3) { width: 110px; }
.dtable-events th:nth-child(1), .dtable-events td:nth-child(1) { width: 170px; }
.dtable-events th:nth-child(4), .dtable-events td:nth-child(4) { width: 100px; }

/* Event rows (device detail → Events): a <details> whose summary is the grid
   row, so the payload expands full-width below it — the mockup's structure. */
.ev { border-bottom: 1px solid var(--divider); }
.ev:last-child { border-bottom: 0; }
.ev > summary {
  display: grid;
  grid-template-columns: 170px minmax(120px, 1fr) minmax(120px, 1fr) 100px;
  gap: 14px;
  align-items: center;
  padding: 12px 20px;
  cursor: pointer;
  list-style: none;
  color: var(--text-body);
}
.ev > summary::-webkit-details-marker { display: none; }
.ev > summary:hover { background: var(--surface-sunken); }
.ev > summary:focus-visible { outline: none; box-shadow: inset 0 0 0 3px var(--accent-ring); }
.ev .ev-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-link);
  font-size: 13px;
  justify-self: end;
}
.ev .when-open { display: none; }
.ev[open] .when-open { display: inline; }
.ev[open] .when-closed { display: none; }
.ev[open] .chev { transform: rotate(90deg); }
.ev > .raw { margin: 0 20px 14px; }

/* ===== Feedback: alerts, messages, empty states, progress ================== */

.alert {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.5;
  text-wrap: pretty;
}
.alert--warning { background: var(--status-warning-bg); color: var(--status-warning); }
.alert--info { background: var(--status-info-bg); color: var(--status-info); }
.alert--danger { background: var(--status-danger-bg); color: var(--status-danger); }

/* Inline flash messages: Django's messages render as a `.messages` list
   just below the page heading (base.html: the heading block, then this list) —
   inside the card on auth pages — one list, one look, no overlay. */
.messages { list-style: none; margin: 0 0 1rem; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.messages li {
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 12px 12px 12px 40px;
  font-size: 14px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
/* The flash icons are Lucide marks inlined as CSS masks (CSS can't read the
   sprite) — path data mirrors the vendored files: lucide-static 1.55.0
   circle-alert / circle-check. Masks paint alpha only; the stroke color
   literal is irrelevant, recoloring happens via background: currentColor. */
.messages li::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 12px;
  width: 16px;
  height: 16px;
  background: currentColor;
  mask: center / contain no-repeat
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cline x1='12' x2='12' y1='8' y2='12'/%3E%3Cline x1='12' x2='12.01' y1='16' y2='16'/%3E%3C/svg%3E");
}
.messages .success {
  background: var(--status-success-bg);
  border-color: rgba(21, 128, 72, 0.3);
  color: var(--status-success);
}
.messages .success::before {
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='10'/%3E%3Cpath d='m16 9-5.5 5.5L8 12'/%3E%3C/svg%3E");
}
.messages .error {
  background: var(--status-danger-bg);
  border-color: rgba(189, 44, 44, 0.3);
  color: var(--status-danger);
}
.messages .warning {
  background: var(--status-warning-bg);
  border-color: rgba(180, 127, 14, 0.35);
  color: var(--status-warning);
}
.messages .info, .messages .debug {
  background: var(--status-info-bg);
  border-color: rgba(33, 89, 193, 0.3);
  color: var(--status-info);
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding: 24px 8px;
  max-width: 520px;
}
.empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--accent-tint);
  color: var(--accent-strong);
  display: grid;
  place-items: center;
}
.empty h2 { font-family: var(--font-display); font-size: 22px; font-weight: 700; letter-spacing: -0.01em; color: var(--text-strong); margin: 0; }
.empty p { margin: 0; color: var(--text-body); font-size: 15px; line-height: 1.6; text-wrap: pretty; }
.empty-inline { display: flex; flex-direction: column; gap: 6px; padding: 28px 20px; }
.empty-inline .t { font-weight: 600; color: var(--text-strong); }
.empty-inline .s { color: var(--text-muted); }
.empty-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 28px 0 12px;
}
.empty-row .badge-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--surface-sunken);
  color: var(--text-muted);
  display: grid;
  place-items: center;
  flex: none;
}

.progress { height: 8px; border-radius: 999px; background: var(--surface-sunken); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }

/* Raw payload reveals. */
pre.raw {
  margin: 0;
  padding: 12px 14px;
  background: var(--surface-sunken);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.55;
  color: var(--text-body);
  overflow-x: auto;
  white-space: pre;
}
.chip {
  display: inline-block;
  max-width: 100%;
  padding: 3px 8px;
  background: var(--surface-sunken);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-strong);
  overflow-wrap: anywhere;
}
.codebox {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--surface-sunken);
  border-radius: 8px;
  flex-wrap: wrap;
}
.codebox .code {
  font-family: var(--font-mono);
  font-size: 26px;
  letter-spacing: 0.08em;
  color: var(--text-strong);
  font-variant-numeric: tabular-nums;
}
.linklike {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--text-link);
  cursor: pointer;
}
.linklike:hover { text-decoration: underline; }
.trustline { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: var(--text-muted); }
.trustline .i { margin-top: 2px; }
details.reveal > summary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-link);
  cursor: pointer;
  list-style: none;
  font-size: 13px;
}
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal[open] > summary { margin-bottom: 8px; }

/* ===== Forms =============================================================== */

form.flow { display: flex; flex-direction: column; gap: 16px; }
.formgrid { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 16px 20px; padding-top: 16px; align-items: start; }
.formgrid .k { color: var(--text-muted); line-height: 24px; }
.formgrid .k-top { line-height: 40px; }
.field { display: flex; flex-direction: column; gap: 8px; min-width: 0; margin: 0; }
.field > label { font-size: 14px; font-weight: 500; color: var(--text-strong); }
.field .hint { color: var(--text-muted); font-size: 12px; margin: 0; text-wrap: pretty; }
input[type="text"], input[type="password"], input[type="number"],
input[type="search"], input[type="email"], select, textarea {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface-card);
  color: var(--text-strong);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}
textarea { height: auto; min-height: 84px; padding: 10px 12px; font-family: var(--font-mono); font-size: 12px; line-height: 1.55; resize: vertical; }
select {
  padding-right: 36px;
  text-overflow: ellipsis;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2366707f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
}
input:hover, select:hover, textarea:hover { border-color: var(--basalt-500); }
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--shadow-focus);
}
.has-error input, .has-error select, .has-error textarea {
  border-color: var(--status-danger);
  box-shadow: 0 0 0 3px rgba(189, 44, 44, 0.3);
}
.field-error { color: var(--status-danger); font-size: 12px; margin: 0; }
.field--mono input { font-family: var(--font-mono); letter-spacing: 0.08em; }
input[readonly] { border-style: dashed; color: var(--text-muted); background: var(--surface-sunken); }

/* Password show/hide affordance. */
.pw-input { position: relative; display: flex; }
.pw-input input { padding-right: 44px; }
.pw-eye {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.pw-eye:hover { background: var(--surface-sunken); color: var(--text-strong); }
.pw-eye:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.pw-eye svg { display: block; }
.pw-eye .icon-eye-off { display: none; }
.pw-showing .icon-eye { display: none; }
.pw-showing .icon-eye-off { display: block; }

/* Custom checkbox (DS Checkbox). */
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; user-select: none; position: relative; }
.check input { position: absolute; opacity: 0; width: 0; height: 0; }
.check-box {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface-card);
  color: #fff;
  transition: background 0.15s ease, border-color 0.15s ease;
  margin-top: 2px;
}
.check-box svg { opacity: 0; transform: scale(0.6); transition: opacity 0.12s ease, transform 0.12s ease; width: 12px; height: 12px; }
.check input:checked ~ .check-box { background: var(--accent); border-color: var(--accent); }
.check input:checked ~ .check-box svg { opacity: 1; transform: scale(1); }
.check input:focus-visible ~ .check-box { box-shadow: var(--shadow-focus); }
.check .check-label { line-height: 1.35; min-width: 0; }
.checklist {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  max-height: 240px;
  overflow-y: auto;
}
.checklist > label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer;
}
.checklist > label:last-child { border-bottom: 0; }
.checklist > label:hover { background: var(--surface-sunken); }
.checklist .check { flex: 1; min-width: 0; }
.checklist .who-mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); white-space: nowrap; }

/* Switch (DS Switch) — pure CSS, no JS. */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch-track {
  flex: none;
  position: relative;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background 0.15s ease;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s ease;
  box-shadow: 0 1px 2px rgba(13, 17, 22, 0.2);
}
.switch input:checked ~ .switch-track { background: var(--accent); }
.switch input:checked ~ .switch-track::after { left: 18px; }
.switch input:focus-visible ~ .switch-track { box-shadow: var(--shadow-focus); }
.switch input[disabled] ~ .switch-track { opacity: 0.5; }
.switch-label { font-weight: 500; color: var(--text-strong); }

/* Search toolbar. */
.searchbox { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface-card); flex: 1 1 280px; max-width: 380px; }
.searchbox .i { color: var(--text-muted); }
.searchbox input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; padding: 0; height: auto; }
.searchbox:focus-within { border-color: var(--accent); box-shadow: var(--shadow-focus); }
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Inline confirm (<details> replaces the mockup's dialogs, plan/03 §0.4). */
details.confirm > summary { list-style: none; cursor: pointer; }
details.confirm > summary::-webkit-details-marker { display: none; }
details.confirm > summary:focus-visible { outline: none; box-shadow: var(--shadow-focus); border-radius: 8px; }
details.confirm > summary.btn { display: inline-flex; }
.confirm-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 12px;
  padding: 16px;
  border: 1px solid var(--border-default);
  border-radius: 12px;
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
}
.confirm-panel.danger { border-color: var(--status-danger); }
.confirm-panel p { margin: 0; color: var(--text-body); text-wrap: pretty; }
.confirm-panel .confirm-title { font-weight: 600; color: var(--text-strong); }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.confirm-inline { position: relative; display: inline-flex; }
.confirm-inline .confirm-panel { position: absolute; right: 0; top: calc(100% + 6px); width: min(440px, 90vw); z-index: 50; }

/* Danger zone (person detail). */
.danger-zone {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 24px;
  background: var(--surface-sunken);
  border: 1px solid var(--status-danger);
  border-radius: 12px;
}
.danger-zone h2 { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--status-danger); margin: 0 0 6px; }
.dz-row { display: flex; align-items: flex-start; gap: 12px 20px; padding: 12px 0; border-bottom: 1px solid var(--divider); flex-wrap: wrap; }
.dz-row:last-of-type { border-bottom: 0; }
.dz-row .dz-body { flex: 1 1 240px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.dz-row .dz-body .t { font-weight: 600; color: var(--text-strong); }
.dz-row .dz-body .s { font-size: 13px; color: var(--text-body); text-wrap: pretty; }

/* Dashboard attention rows + activity feed. */
.attend-row { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--divider); flex-wrap: wrap; }
.attend-row .txt { flex: 1 1 240px; color: var(--text-strong); text-wrap: pretty; }
.feed-row { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--divider); }
.feed-row .feed-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.feed-row .feed-when { font-size: 12px; color: var(--text-muted); }

/* Settings footer (status + discard/save). */
.settings-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}

/* ===== Card page shell (SSO / no-access / errors) =========================== */

.card-page { min-height: 100vh; display: grid; grid-template-rows: 1fr auto; padding: 24px; }
.card-page .center { display: grid; place-items: center; }
.card-page .box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 24px; }
.card-page .brand { color: var(--text-strong); justify-content: center; }
.card-page .brand-name { color: var(--text-strong); }
.card-page .card { border-top: 3px solid var(--accent); padding: 32px; }
.card-page h1 { font-size: 24px; }
.card-page .card-actions { margin-top: 1.5rem; }
.card-page .card-actions p { margin: 0; }
.card-page .messages { list-style: none; margin: 0 0 1rem; padding: 0; }
.card-page .foot { display: flex; justify-content: center; gap: 20px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; }

/* ===== Responsive =========================================================== */

@media (max-width: 900px) {
  .layout { padding: 20px 16px 56px; }
  .topbar { padding: 0 16px; }
  .formgrid, .kv-labels { grid-template-columns: 1fr; gap: 8px; }
  .formgrid .k { line-height: inherit; }
}
@media (max-width: 600px) {
  .brand-name { display: none; }
  .obj-head .btnrow { width: 100%; }
  .hide-sm { display: none; }
}
