/* =====================================================================
   Equipment Tracker — design system
   Hand-written, no build step. Light + dark, token driven.
   ===================================================================== */

/* ---------------------------------------------------------------- 1. Tokens */
:root {
  color-scheme: light;

  --brand-50:  #eef4ff;
  --brand-100: #dbe6ff;
  --brand-200: #bfd2ff;
  --brand-300: #94b3ff;
  --brand-400: #6289fb;
  --brand-500: #3f63f3;
  --brand-600: #2c46e0;
  --brand-700: #2436b8;
  --brand-800: #223192;
  --brand-900: #212f74;

  --bg:          #f6f7fb;
  --bg-elevated: #ffffff;
  --bg-sunken:   #eef0f6;
  --bg-hover:    #f3f5fa;
  --bg-active:   #eaeefb;
  --surface-nav: #0f1424;

  --text:        #171a23;
  --text-muted:  #5c6478;
  --text-subtle: #868ea3;
  --text-invert: #ffffff;

  --border:        #e3e6ef;
  --border-strong: #cdd3e1;

  --ok:     #15803d;  --ok-bg:     #e7f8ee;  --ok-bd:     #b7ead0;
  --warn:   #a15c07;  --warn-bg:   #fdf3e0;  --warn-bd:   #f3ddb2;
  --danger: #be2f36;  --danger-bg: #fdecec;  --danger-bd: #f6c9c9;
  --info:   #1d5fd0;  --info-bg:   #e9f1ff;  --info-bd:   #c3d8fb;
  --violet: #6d33cf;  --violet-bg: #f2ebfe;  --violet-bd: #dcc9f8;
  --orange: #b4541a;  --orange-bg: #fdefe5;  --orange-bd: #f7d3b8;
  --slate:  #566076;  --slate-bg:  #eef0f5;  --slate-bd:  #d8dde8;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-xs: 0 1px 2px rgba(16, 22, 43, .05);
  --shadow-sm: 0 1px 3px rgba(16, 22, 43, .07), 0 1px 2px rgba(16, 22, 43, .04);
  --shadow:    0 4px 14px rgba(16, 22, 43, .07), 0 1px 3px rgba(16, 22, 43, .05);
  --shadow-lg: 0 18px 45px rgba(16, 22, 43, .14), 0 4px 12px rgba(16, 22, 43, .07);
  --ring:      0 0 0 3px rgba(63, 99, 243, .22);

  --nav-w: 254px;
  --topbar-h: 62px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono",
          Menlo, Consolas, monospace;

  --ease: cubic-bezier(.22, .68, .32, 1);
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg:          #0c0f18;
  --bg-elevated: #141926;
  --bg-sunken:   #0a0d15;
  --bg-hover:    #1a2031;
  --bg-active:   #1e2740;
  --surface-nav: #090c14;

  --text:        #e9ecf5;
  --text-muted:  #9aa3b8;
  --text-subtle: #6d768c;

  --border:        #232a3b;
  --border-strong: #333c52;

  --ok:     #4ade80;  --ok-bg:     #10261a;  --ok-bd:     #1d4630;
  --warn:   #fbbf4e;  --warn-bg:   #2a1f0b;  --warn-bd:   #4b3714;
  --danger: #fb7185;  --danger-bg: #2c1219;  --danger-bd: #52212c;
  --info:   #7ba6ff;  --info-bg:   #111c33;  --info-bd:   #1f3157;
  --violet: #b794f6;  --violet-bg: #1e1633;  --violet-bd: #362a56;
  --orange: #fb9a54;  --orange-bg: #2a1710;  --orange-bd: #4a2a19;
  --slate:  #94a0b8;  --slate-bg:  #171d2b;  --slate-bd:  #2a3346;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, .5);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .55);
  --shadow:    0 6px 18px rgba(0, 0, 0, .5);
  --shadow-lg: 0 22px 55px rgba(0, 0, 0, .62);
  --ring:      0 0 0 3px rgba(98, 137, 251, .3);
}

/* ---------------------------------------------------------------- 2. Reset */
*, *::before, *::after { box-sizing: border-box; }
* { margin: 0; }

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

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv02", "cv03", "cv04", "tnum" 0;
}

img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; font-weight: 640; letter-spacing: -.015em; }
h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
table { border-collapse: collapse; width: 100%; }
:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-xs); }
::selection { background: var(--brand-200); color: var(--brand-900); }
:root[data-theme="dark"] ::selection { background: var(--brand-800); color: #fff; }

/* Scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--border-strong); border-radius: 99px;
  border: 3px solid transparent; background-clip: content-box;
}
*::-webkit-scrollbar-track { background: transparent; }

/* ---------------------------------------------------------------- 3. Layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--nav-w);
  flex: 0 0 var(--nav-w);
  background: var(--surface-nav);
  color: #cbd3e6;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  border-right: 1px solid rgba(255, 255, 255, .06);
}

.sidebar__brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  color: #fff;
}
.sidebar__brand:hover { text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; flex: none;
  border-radius: 10px;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-600) 60%, var(--brand-800));
  display: grid; place-items: center;
  box-shadow: 0 4px 14px rgba(63, 99, 243, .42);
}
.brand-mark svg { width: 19px; height: 19px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text b { font-size: 14.5px; font-weight: 640; letter-spacing: -.01em; }
.brand-text span {
  font-size: 10.5px; letter-spacing: .09em; text-transform: uppercase;
  color: #7b87a6; font-weight: 600;
}

.nav { flex: 1; overflow-y: auto; padding: 6px 12px 18px; }
.nav__group { margin-top: 18px; }
.nav__label {
  font-size: 10.5px; font-weight: 680; letter-spacing: .1em;
  text-transform: uppercase; color: #626e8c;
  padding: 0 10px 8px;
}
.nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 8px 10px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: #b3bcd4; font-weight: 520; font-size: 13.5px;
  transition: background .14s var(--ease), color .14s var(--ease);
  position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.is-active { background: rgba(63, 99, 243, .18); color: #fff; }
.nav a.is-active::before {
  content: ""; position: absolute; left: -12px; top: 50%;
  width: 3px; height: 18px; margin-top: -9px;
  background: var(--brand-400); border-radius: 0 3px 3px 0;
}
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .82; }
.nav a.is-active svg { opacity: 1; }
.nav__count {
  margin-left: auto; font-size: 11px; font-weight: 640;
  background: rgba(255, 255, 255, .09); color: #cfd6e8;
  padding: 1px 7px; border-radius: 99px; min-width: 22px; text-align: center;
}
.nav a.is-active .nav__count { background: rgba(255, 255, 255, .18); color: #fff; }
.nav__count--alert { background: rgba(251, 113, 133, .2); color: #ffb3bd; }

.sidebar__foot {
  border-top: 1px solid rgba(255, 255, 255, .07);
  padding: 12px;
}
.userchip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; border-radius: var(--radius-sm);
  color: #cbd3e6; width: 100%; text-align: left;
  background: none; border: 0; cursor: pointer;
  transition: background .14s var(--ease);
}
.userchip:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
.userchip__meta { min-width: 0; flex: 1; }
.userchip__meta b { display: block; font-size: 13px; color: #fff; font-weight: 580;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userchip__meta span { font-size: 11.5px; color: #7b87a6; }

.avatar {
  width: 32px; height: 32px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 680; letter-spacing: .02em;
  background: linear-gradient(140deg, var(--brand-400), var(--brand-700));
  color: #fff;
}
.avatar--sm { width: 24px; height: 24px; font-size: 9.5px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 26px;
  background: color-mix(in srgb, var(--bg-elevated) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 17px; font-weight: 620; }
.topbar__spacer { flex: 1; }

.content { padding: 24px 26px 60px; flex: 1; }
.content--narrow { max-width: 880px; }

.page-head {
  display: flex; align-items: flex-start; gap: 16px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.page-head__text { flex: 1; min-width: 240px; }
.page-head h1 { margin-bottom: 3px; }
.page-head p { color: var(--text-muted); font-size: 13.5px; }
.page-head__actions { display: flex; gap: 8px; flex-wrap: wrap; }

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-subtle); margin-bottom: 8px;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb svg { width: 13px; height: 13px; opacity: .55; }

/* ---------------------------------------------------------------- 4. Search */
.omnisearch { position: relative; flex: 1; max-width: 420px; }
.omnisearch svg {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--text-subtle); pointer-events: none;
}
.omnisearch input {
  width: 100%; height: 36px;
  padding: 0 62px 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
.omnisearch input:focus {
  background: var(--bg-elevated);
  border-color: var(--brand-400); box-shadow: var(--ring); outline: none;
}
.omnisearch input::placeholder { color: var(--text-subtle); }
.omnisearch kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  pointer-events: none;
}

kbd {
  font-family: var(--font); font-size: 10.5px; font-weight: 600;
  color: var(--text-subtle);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px; padding: 1px 5px;
}

/* ---------------------------------------------------------------- 5. Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 13.5px; font-weight: 560;
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: background .14s var(--ease), border-color .14s var(--ease),
              transform .1s var(--ease), box-shadow .14s var(--ease), opacity .14s;
  text-decoration: none;
}
.btn:hover { background: var(--bg-hover); text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn--primary {
  background: var(--brand-600); border-color: var(--brand-600); color: #fff;
  box-shadow: 0 1px 2px rgba(44, 70, 224, .35);
}
.btn--primary:hover { background: var(--brand-700); border-color: var(--brand-700); }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(.93); }
:root[data-theme="dark"] .btn--danger { color: #2c1219; }

.btn--ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn--ghost:hover { background: var(--bg-hover); }

.btn--sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--radius-xs); }
.btn--sm svg { width: 13px; height: 13px; }
.btn--lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn--block { width: 100%; }
.btn--icon { width: 36px; padding: 0; }
.btn--icon.btn--sm { width: 30px; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; pointer-events: none; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.btn-group .btn.is-on { background: var(--bg-active); border-color: var(--brand-400); color: var(--brand-700); z-index: 1; }
:root[data-theme="dark"] .btn-group .btn.is-on { color: var(--brand-300); }

/* ---------------------------------------------------------------- 6. Cards */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card__head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.card__head h2 { flex: 1; }
.card__head p { font-size: 12.5px; color: var(--text-muted); }
.card__body { padding: 18px; }
.card__body--flush { padding: 0; }
.card__foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  background: var(--bg-sunken);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex; align-items: center; gap: 10px;
}

.grid { display: grid; gap: 16px; }
.grid--stats { grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.stack { display: grid; gap: 16px; }

/* Stat tiles */
.stat {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
  display: block; color: inherit;
  transition: border-color .15s var(--ease), transform .15s var(--ease), box-shadow .15s var(--ease);
  position: relative; overflow: hidden;
}
a.stat:hover {
  text-decoration: none; border-color: var(--border-strong);
  transform: translateY(-1px); box-shadow: var(--shadow);
}
.stat__top { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.stat__dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.stat__label {
  font-size: 12px; font-weight: 580; color: var(--text-muted);
  letter-spacing: .01em;
}
.stat__value {
  font-size: 27px; font-weight: 660; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.1;
}
.stat__hint { font-size: 11.5px; color: var(--text-subtle); margin-top: 4px; }
.stat--accent { background: linear-gradient(150deg, var(--brand-600), var(--brand-800)); border-color: transparent; }
.stat--accent .stat__label, .stat--accent .stat__hint { color: rgba(255, 255, 255, .72); }
.stat--accent .stat__value { color: #fff; }

/* Tone helpers */
.t-green  { color: var(--ok); }      .bgt-green  { background: var(--ok); }
.t-amber  { color: var(--warn); }    .bgt-amber  { background: var(--warn); }
.t-red    { color: var(--danger); }  .bgt-red    { background: var(--danger); }
.t-blue   { color: var(--info); }    .bgt-blue   { background: var(--info); }
.t-violet { color: var(--violet); }  .bgt-violet { background: var(--violet); }
.t-orange { color: var(--orange); }  .bgt-orange { background: var(--orange); }
.t-slate  { color: var(--slate); }   .bgt-slate  { background: var(--slate); }

/* ---------------------------------------------------------------- 7. Badges */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px 2px 7px;
  border-radius: 99px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .005em;
  border: 1px solid transparent; white-space: nowrap;
}
.badge::before {
  content: ""; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; flex: none;
}
.badge--nodot::before { display: none; }
.badge--green  { color: var(--ok);     background: var(--ok-bg);     border-color: var(--ok-bd); }
.badge--amber  { color: var(--warn);   background: var(--warn-bg);   border-color: var(--warn-bd); }
.badge--red    { color: var(--danger); background: var(--danger-bg); border-color: var(--danger-bd); }
.badge--blue   { color: var(--info);   background: var(--info-bg);   border-color: var(--info-bd); }
.badge--violet { color: var(--violet); background: var(--violet-bg); border-color: var(--violet-bd); }
.badge--orange { color: var(--orange); background: var(--orange-bg); border-color: var(--orange-bd); }
.badge--slate  { color: var(--slate);  background: var(--slate-bg);  border-color: var(--slate-bd); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: var(--radius-xs);
  font-size: 11px; font-weight: 580;
  background: var(--bg-sunken); border: 1px solid var(--border);
  color: var(--text-muted);
}

.mono { font-family: var(--mono); font-size: 12.5px; letter-spacing: -.01em; }
.serial {
  font-family: var(--mono); font-size: 12.5px; font-weight: 550;
  letter-spacing: -.005em;
}

/* ---------------------------------------------------------------- 8. Tables */
.table-wrap { overflow-x: auto; }

.table { font-size: 13.5px; }
.table thead th {
  text-align: left; font-size: 11px; font-weight: 660;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-subtle);
  padding: 10px 14px;
  background: var(--bg-sunken);
  border-bottom: 1px solid var(--border);
  white-space: nowrap; position: sticky; top: 0; z-index: 2;
}
.table thead th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.table thead th a:hover { color: var(--text); text-decoration: none; }
.table thead th svg { width: 12px; height: 12px; opacity: .5; }
.table thead th a.is-sorted svg { opacity: 1; color: var(--brand-600); }

.table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background .12s var(--ease); }
.table tbody tr:hover { background: var(--bg-hover); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.shrink, .table th.shrink { width: 1%; white-space: nowrap; }
.table .muted { color: var(--text-muted); }
.table a.row-link { color: var(--text); font-weight: 560; }
.table a.row-link:hover { color: var(--brand-600); }

.cell-2 { display: flex; flex-direction: column; gap: 1px; }
.cell-2 small { color: var(--text-subtle); font-size: 11.5px; }

/* ---------------------------------------------------------------- 9. Forms */
.field { display: grid; gap: 6px; margin-bottom: 15px; }
.field > label, .label {
  font-size: 12.5px; font-weight: 600; color: var(--text);
  display: flex; align-items: center; gap: 6px;
}
.field .req { color: var(--danger); font-weight: 700; }
.field .hint { font-size: 12px; color: var(--text-subtle); }
.field .err { font-size: 12px; color: var(--danger); font-weight: 540; }

.input, .select, .textarea {
  width: 100%; height: 38px;
  padding: 0 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  color: var(--text);
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; resize: vertical; line-height: 1.55; }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand-500); box-shadow: var(--ring);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--bg-sunken); color: var(--text-subtle); cursor: not-allowed;
}
.input.is-invalid, .select.is-invalid { border-color: var(--danger); }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23868ea3' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row--3 { grid-template-columns: repeat(3, 1fr); }

.check {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 11px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: border-color .14s var(--ease), background .14s var(--ease);
}
.check:hover { background: var(--bg-hover); }
.check input { margin-top: 2px; accent-color: var(--brand-600); width: 15px; height: 15px; flex: none; }
.check span { font-size: 13px; }
.check small { display: block; color: var(--text-subtle); font-size: 11.5px; }
.check:has(input:checked) { border-color: var(--brand-400); background: var(--bg-active); }

/* Radio cards — used for choosing a workflow action */
.pick { display: grid; gap: 9px; }
.pick__item {
  display: flex; align-items: flex-start; gap: 11px;
  padding: 12px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; background: var(--bg-elevated);
  transition: border-color .14s var(--ease), background .14s var(--ease), box-shadow .14s var(--ease);
}
.pick__item:hover { border-color: var(--border-strong); background: var(--bg-hover); }
.pick__item input { margin-top: 2px; accent-color: var(--brand-600); width: 16px; height: 16px; flex: none; }
.pick__item:has(input:checked) {
  border-color: var(--brand-500); background: var(--bg-active); box-shadow: var(--ring);
}
.pick__body { flex: 1; min-width: 0; }
.pick__title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pick__desc { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }
.pick__item--danger:has(input:checked) { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(190, 47, 54, .18); }

.filters {
  display: flex; gap: 9px; flex-wrap: wrap; align-items: flex-end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.filters .field { margin: 0; min-width: 150px; }
.filters .field--grow { flex: 1; min-width: 200px; }
.filters .input, .filters .select { height: 34px; font-size: 13px; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 26px; padding: 0 6px 0 10px;
  background: var(--bg-active); border: 1px solid var(--brand-200);
  color: var(--brand-700);
  border-radius: 99px; font-size: 12px; font-weight: 550;
}
:root[data-theme="dark"] .chip { border-color: var(--brand-800); color: var(--brand-300); }
.chip button {
  background: none; border: 0; cursor: pointer; padding: 2px;
  display: grid; place-items: center; color: inherit; opacity: .6; border-radius: 50%;
}
.chip button:hover { opacity: 1; background: rgba(0, 0, 0, .07); }
.chip svg { width: 12px; height: 12px; }

/* -------------------------------------------------------------- 10. Timeline */
.timeline { position: relative; padding-left: 4px; }
.tl-item { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ""; position: absolute;
  left: 15px; top: 32px; bottom: 0; width: 2px;
  background: var(--border);
}
.tl-item:last-child::before { display: none; }

.tl-dot {
  width: 32px; height: 32px; flex: none;
  border-radius: 50%; display: grid; place-items: center;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  position: relative; z-index: 1;
  box-shadow: var(--shadow-xs);
}
.tl-dot svg { width: 15px; height: 15px; }

.tl-body { flex: 1; min-width: 0; padding-top: 3px; }
.tl-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap;
}
.tl-title { font-weight: 600; font-size: 13.5px; }
.tl-time { font-size: 11.5px; color: var(--text-subtle); margin-left: auto; white-space: nowrap; }
.tl-meta {
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
  margin-top: 5px; font-size: 12.5px; color: var(--text-muted);
}
.tl-note {
  margin-top: 7px; padding: 8px 11px;
  background: var(--bg-sunken); border-left: 2px solid var(--border-strong);
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
  font-size: 12.5px; color: var(--text-muted); white-space: pre-wrap;
}

.route {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 550;
}
.route svg { width: 13px; height: 13px; color: var(--text-subtle); }

/* Flow strip on the unit page */
.flow {
  display: flex; align-items: center; gap: 0;
  overflow-x: auto; padding: 4px 2px;
}
.flow__step {
  display: flex; align-items: center; gap: 7px;
  padding: 6px 12px; border-radius: 99px;
  font-size: 12px; font-weight: 580; white-space: nowrap;
  background: var(--bg-sunken); color: var(--text-subtle);
  border: 1px solid var(--border);
}
.flow__step.is-done { background: var(--bg-elevated); color: var(--text-muted); }
.flow__step.is-current { border-width: 1px; font-weight: 640; }
.flow__arrow { color: var(--text-subtle); flex: none; padding: 0 3px; }
.flow__arrow svg { width: 14px; height: 14px; }

/* -------------------------------------------------------------- 11. Feedback */
.toasts {
  position: fixed; top: 16px; right: 16px; z-index: 200;
  display: flex; flex-direction: column; gap: 9px;
  max-width: min(400px, calc(100vw - 32px));
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 13px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--slate);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  animation: toast-in .32s var(--ease);
  font-size: 13.5px;
}
.toast svg { width: 17px; height: 17px; flex: none; margin-top: 1px; }
.toast p { flex: 1; }
.toast button {
  background: none; border: 0; cursor: pointer; padding: 2px;
  color: var(--text-subtle); display: grid; place-items: center; border-radius: 4px;
}
.toast button:hover { color: var(--text); background: var(--bg-hover); }
.toast--success { border-left-color: var(--ok); }
.toast--success > svg { color: var(--ok); }
.toast--error   { border-left-color: var(--danger); }
.toast--error > svg { color: var(--danger); }
.toast--warning { border-left-color: var(--warn); }
.toast--warning > svg { color: var(--warn); }
.toast--info    { border-left-color: var(--info); }
.toast--info > svg { color: var(--info); }
.toast.is-out { animation: toast-out .22s var(--ease) forwards; }

@keyframes toast-in  { from { opacity: 0; transform: translateX(22px) scale(.97); } }
@keyframes toast-out { to   { opacity: 0; transform: translateX(22px) scale(.97); } }

.alert {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 11px 13px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--bg-sunken);
  font-size: 13px; margin-bottom: 16px;
}
.alert svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.alert b { display: block; margin-bottom: 1px; }
.alert--error   { background: var(--danger-bg); border-color: var(--danger-bd); color: var(--danger); }
.alert--warning { background: var(--warn-bg);   border-color: var(--warn-bd);   color: var(--warn); }
.alert--info    { background: var(--info-bg);   border-color: var(--info-bd);   color: var(--info); }
.alert--success { background: var(--ok-bg);     border-color: var(--ok-bd);     color: var(--ok); }

.empty {
  text-align: center; padding: 52px 24px;
  color: var(--text-muted);
}
.empty__icon {
  width: 46px; height: 46px; margin: 0 auto 14px;
  border-radius: 13px; display: grid; place-items: center;
  background: var(--bg-sunken); border: 1px solid var(--border);
  color: var(--text-subtle);
}
.empty__icon svg { width: 21px; height: 21px; }
.empty h3 { margin-bottom: 5px; color: var(--text); }
.empty p { font-size: 13.5px; max-width: 380px; margin: 0 auto 16px; }

/* -------------------------------------------------------------- 12. Bar chart */
.bars { display: grid; gap: 11px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 44px; gap: 11px; align-items: center; }
.bar-row__label { font-size: 12.5px; color: var(--text-muted); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; }
.bar-row__track { height: 8px; background: var(--bg-sunken); border-radius: 99px; overflow: hidden; }
/* Width is rendered server-side so the chart is correct without JavaScript;
   the grow-in is a pure CSS flourish on top of it. */
.bar-row__fill {
  height: 100%; border-radius: 99px; min-width: 2px;
  transform-origin: left center;
  animation: bar-grow .55s var(--ease) both;
}
@keyframes bar-grow { from { transform: scaleX(0); } }
.bar-row__val { font-size: 12.5px; font-weight: 620; text-align: right;
  font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------------- 13. Pagination */
.pager {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 16px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted);
}
.pager__spacer { flex: 1; }
.pager__links { display: flex; gap: 4px; }
.pager__links a, .pager__links span {
  min-width: 32px; height: 32px; padding: 0 9px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  color: var(--text); font-size: 13px; font-weight: 550; background: var(--bg-elevated);
}
.pager__links a:hover { background: var(--bg-hover); text-decoration: none; }
.pager__links .is-current { background: var(--brand-600); border-color: var(--brand-600); color: #fff; }
.pager__links .is-off { opacity: .4; pointer-events: none; }

/* -------------------------------------------------------------- 14. Login */
.auth {
  min-height: 100vh; display: grid;
  grid-template-columns: 1fr;
  background: var(--bg);
}
.auth__panel {
  display: flex; flex-direction: column; justify-content: center;
  padding: 40px 28px;
}
.auth__inner { width: 100%; max-width: 372px; margin: 0 auto; }
.auth__brand { display: flex; align-items: center; gap: 11px; margin-bottom: 30px; }
.auth__brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; }
.auth__brand .brand-mark svg { width: 22px; height: 22px; }
.auth__brand b { font-size: 17px; font-weight: 660; letter-spacing: -.02em; display: block; }
.auth__brand span { font-size: 11px; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-subtle); font-weight: 640; }
.auth h1 { font-size: 25px; margin-bottom: 6px; }
.auth__sub { color: var(--text-muted); margin-bottom: 26px; font-size: 13.5px; }
.auth .card { padding: 0; border: 0; background: none; box-shadow: none; }
.auth__foot { margin-top: 22px; font-size: 12px; color: var(--text-subtle); text-align: center; }

.auth__aside {
  display: none;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(98, 137, 251, .5), transparent 62%),
    radial-gradient(760px 520px at 96% 108%, rgba(109, 51, 207, .42), transparent 58%),
    linear-gradient(155deg, #131a33, #0a0d18 62%);
  color: #fff;
  padding: 52px;
  flex-direction: column; justify-content: center;
  position: relative; overflow: hidden;
}
.auth__aside::after {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 42% 42%, #000, transparent 72%);
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__aside h2 { font-size: 29px; line-height: 1.24; letter-spacing: -.028em; margin-bottom: 14px; }
.auth__aside p { color: rgba(255, 255, 255, .68); font-size: 14.5px; max-width: 400px; }
.auth__flow { margin-top: 34px; display: grid; gap: 13px; max-width: 400px; }
.auth__flow-item { display: flex; align-items: center; gap: 13px; font-size: 13.5px; }
.auth__flow-item i {
  width: 30px; height: 30px; flex: none; border-radius: 9px;
  background: rgba(255, 255, 255, .09);
  border: 1px solid rgba(255, 255, 255, .13);
  display: grid; place-items: center; font-style: normal;
  font-size: 11.5px; font-weight: 680; color: rgba(255, 255, 255, .82);
}
.auth__flow-item span { color: rgba(255, 255, 255, .8); }
.auth__flow-item b { color: #fff; font-weight: 600; }

@media (min-width: 940px) {
  .auth { grid-template-columns: 1fr 1.05fr; }
  .auth__aside { display: flex; }
}

/* -------------------------------------------------------------- 15. Misc */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.muted   { color: var(--text-muted); }
.subtle  { color: var(--text-subtle); }
.small   { font-size: 12.5px; }
.tiny    { font-size: 11.5px; }
.right   { text-align: right; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }
.flex    { display: flex; align-items: center; gap: 8px; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.flex-wrap { flex-wrap: wrap; }
.gap-4 { gap: 4px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; } .mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }
.hide { display: none !important; }

.dl { display: grid; grid-template-columns: minmax(110px, auto) 1fr; gap: 9px 18px; font-size: 13.5px; }
.dl dt { color: var(--text-muted); font-size: 12.5px; }
.dl dd { font-weight: 540; overflow-wrap: anywhere; }

.theme-toggle { position: relative; }
.theme-toggle svg { transition: transform .3s var(--ease), opacity .2s; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
.theme-toggle .icon-sun { display: none; }

.sidebar-toggle { display: none; }
.scrim { display: none; }

/* -------------------------------------------------------------- 16. Print */
@media print {
  .sidebar, .topbar, .page-head__actions, .filters, .pager, .toasts, .no-print { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; }
  .card { border: 1px solid #ccc; box-shadow: none; break-inside: avoid; }
}

/* -------------------------------------------------------------- 17. Responsive */
@media (max-width: 1020px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    transition: transform .26s var(--ease);
    box-shadow: var(--shadow-lg);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 35;
    background: rgba(9, 12, 20, .5); backdrop-filter: blur(2px);
    animation: fade-in .2s var(--ease);
  }
  .sidebar-toggle { display: inline-flex; }
  .content { padding: 18px 16px 60px; }
  .topbar { padding: 0 16px; }
}

@keyframes fade-in { from { opacity: 0; } }

@media (max-width: 700px) {
  .form-row, .form-row--3 { grid-template-columns: 1fr; }
  .omnisearch { max-width: none; }
  .omnisearch kbd { display: none; }
  .page-head__actions { width: 100%; }
  .page-head__actions .btn { flex: 1; }
  .bar-row { grid-template-columns: 96px 1fr 38px; }
  .dl { grid-template-columns: 1fr; gap: 2px 0; }
  .dl dd { margin-bottom: 10px; }
  .stat__value { font-size: 23px; }
}

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