:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --panel-2: #fbfcfd;
  --ink: #16191d;
  --ink-2: #5a6472;
  --ink-3: #8b94a3;
  --line: #e3e7ec;
  --line-2: #eef1f5;
  --accent: #3b5bdb;
  --accent-soft: #e8edfb;
  --ok: #1f9254;
  --ok-soft: #e3f4ea;
  --warn: #9a6400;
  --warn-soft: #fdf1da;
  --store: #7c3aed;
  --store-soft: #f1ebfe;
  --gone: #4c6b6f;
  --gone-soft: #e6efef;
  --gift: #b3306e;
  --gift-soft: #fce8f1;
  --give: #0e7490;
  --give-soft: #e2f2f7;
  --bad: #c0392b;
  --bad-soft: #fbe9e7;
  --mute-soft: #eef0f3;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --panel: #171b21;
    --panel-2: #1c2129;
    --ink: #e8ecf1;
    --ink-2: #a4aebd;
    --ink-3: #78828f;
    --line: #262c35;
    --line-2: #20252d;
    --accent: #7f9cf5;
    --accent-soft: #22293c;
    --ok: #55d68d;
    --ok-soft: #12291d;
    --warn: #e0b25a;
    --warn-soft: #2c2415;
    --store: #c4b5fd;
    --store-soft: #272040;
    --gone: #8fc0c4;
    --gone-soft: #1e2a2c;
    --gift: #f0a0c8;
    --gift-soft: #331f2a;
    --give: #7dd3fc;
    --give-soft: #10262f;
    --bad: #f08b7f;
    --bad-soft: #2e1b19;
    --mute-soft: #232830;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }

/* ---------------------------------------------------------------- layout -- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: var(--accent); color: #fff;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.brand-text strong { font-size: 13.5px; }
.brand-text span { font-size: 11px; color: var(--ink-3); }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  padding: 8px 10px; border-radius: 7px; color: var(--ink-2);
  font-size: 13.5px; display: flex; justify-content: space-between; align-items: center;
}
.nav a:hover { background: var(--line-2); color: var(--ink); }
.nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav em { font-style: normal; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.nav a.active em { color: var(--accent); }
/* Listed after .nav a.active em so the badge keeps white-on-red when active. */
.nav em.alert,
.nav a.active em.alert {
  color: #fff; background: var(--bad);
  padding: 1px 7px; border-radius: 20px; font-weight: 600;
}

.sidebar-foot { margin-top: auto; font-size: 12.5px; color: var(--ink-2); display: grid; gap: 8px; }
.sidebar-foot summary { cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.sidebar-foot summary:hover { background: var(--line-2); }
.export-links { display: grid; gap: 2px; padding: 6px 6px 2px; }
.export-links a { color: var(--accent); font-size: 12.5px; padding: 2px 0; }
.export-links a:hover { text-decoration: underline; }
.linklike {
  background: none; border: 0; color: var(--ink-2); cursor: pointer;
  font: inherit; text-align: left; padding: 4px 6px; border-radius: 6px;
}
.linklike:hover { background: var(--line-2); color: var(--ink); }

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

.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; gap: 12px; align-items: center;
  padding: 12px 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.search-wrap { position: relative; flex: 1; max-width: 560px; }
#search {
  width: 100%; padding: 8px 12px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  font: inherit;
}
#search:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

.search-results {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 60vh; overflow: auto; z-index: 40; padding: 6px;
}
.search-results h4 {
  margin: 8px 8px 4px; font-size: 11px; text-transform: uppercase;
  letter-spacing: .06em; color: var(--ink-3);
}
.search-results a { display: block; padding: 7px 8px; border-radius: 6px; font-size: 13px; }
.search-results a:hover { background: var(--line-2); }
.search-results .sub { color: var(--ink-3); font-size: 12px; }

.view { padding: 22px; display: grid; gap: 18px; align-content: start; }

/* ----------------------------------------------------------- components -- */
.page-head { display: flex; align-items: flex-start; gap: 14px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; }
.page-head .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.page-head .spacer { flex: 1; }

.btn {
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 13px; border-radius: 8px; font: inherit; cursor: pointer;
}
.btn:hover { background: var(--line-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, var(--line)); }
.btn.small { padding: 4px 9px; font-size: 12.5px; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-head {
  padding: 13px 16px; border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { font-size: 14px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 13px 15px;
}
.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.stat .value { font-size: 25px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.stat .hint { font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.stat a { color: var(--accent); }

.cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 18px; align-items: start; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
thead th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); font-weight: 600; padding: 9px 12px;
  border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2);
  position: sticky; top: 0;
}
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { color: var(--ink); }
tbody td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--line-2); }
.table-wrap { overflow-x: auto; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .muted, .muted { color: var(--ink-3); }
td.mono, .mono { font-family: var(--mono); font-size: 12.5px; }
.nowrap { white-space: nowrap; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: var(--mute-soft); color: var(--ink-2);
}
.pill.assigned { background: var(--ok-soft); color: var(--ok); }
.pill.unassigned { background: var(--accent-soft); color: var(--accent); }
.pill.storage { background: var(--store-soft); color: var(--store); }
.pill.sold { background: var(--warn-soft); color: var(--warn); }
.pill.stolen { background: var(--bad-soft); color: var(--bad); }
.pill.retired { background: var(--mute-soft); color: var(--ink-3); }
.pill.discarded { background: var(--gone-soft); color: var(--gone); }
/* Equipment statuses. storage / sold / discarded deliberately reuse the
   computer colours so the same word means the same thing on both pages. */
.pill.gifted { background: var(--gift-soft); color: var(--gift); }
.pill.donated { background: var(--give-soft); color: var(--give); }
.pill.office { background: var(--ok-soft); color: var(--ok); }
.pill.with-staff { background: var(--accent-soft); color: var(--accent); }
.pill.repair { background: var(--bad-soft); color: var(--bad); }

/* Status dropdown in the computers list: reads as a pill, behaves as a select.
   The chevron is a fixed mid grey so it stays legible on every status colour
   in both light and dark themes. */
.status-select {
  appearance: none; -webkit-appearance: none;
  border: 1px solid transparent; border-radius: 20px;
  padding: 3px 21px 3px 9px;
  font: inherit; font-size: 11.5px; font-weight: 600;
  text-transform: capitalize; cursor: pointer;
  background-color: var(--mute-soft); color: var(--ink-2);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'><path d='M2 4l3 3 3-3' fill='none' stroke='%238b94a3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 6px center;
}
.status-select:hover { border-color: var(--line); }
.status-select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.status-select option { text-transform: capitalize; color: var(--ink); background: var(--panel); }
.status-select.assigned { background-color: var(--ok-soft); color: var(--ok); }
.status-select.unassigned { background-color: var(--accent-soft); color: var(--accent); }
.status-select.storage { background-color: var(--store-soft); color: var(--store); }
.status-select.sold { background-color: var(--warn-soft); color: var(--warn); }
.status-select.stolen { background-color: var(--bad-soft); color: var(--bad); }
.status-select.retired { background-color: var(--mute-soft); color: var(--ink-3); }
.status-select.discarded { background-color: var(--gone-soft); color: var(--gone); }
.status-select.gifted { background-color: var(--gift-soft); color: var(--gift); }
.status-select.donated { background-color: var(--give-soft); color: var(--give); }
.status-select.office { background-color: var(--ok-soft); color: var(--ok); }
.status-select.with-staff { background-color: var(--accent-soft); color: var(--accent); }
.status-select.repair { background-color: var(--bad-soft); color: var(--bad); }
.pill.high { background: var(--bad-soft); color: var(--bad); }
.pill.medium { background: var(--warn-soft); color: var(--warn); }
.pill.low { background: var(--mute-soft); color: var(--ink-2); }

.filters { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 5px 12px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-2); cursor: pointer; font: inherit;
  font-size: 13px;
}
.chip:hover { background: var(--line-2); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.chip em { font-style: normal; opacity: .7; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* Secondary filter row: same controls, visually subordinate to the row above. */
.subfilters { align-items: center; margin-top: -6px; }
.subfilters .chip { font-size: 12.5px; padding: 4px 10px; }
.filter-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--ink-3); margin-right: 2px;
}

.empty { padding: 34px 16px; text-align: center; color: var(--ink-3); }

/* ------------------------------------------------------------- detail -- */
.detail-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 900px) { .detail-grid { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .sidebar { position: static; height: auto; } }

.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 13px; }
.field { display: grid; gap: 4px; min-width: 0; }
.field label { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.field input, .field select, .field textarea {
  width: 100%; padding: 7px 10px; border-radius: 7px; font: inherit;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}
.field textarea { min-height: 74px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--accent-soft); border-color: var(--accent);
}
.field.wide { grid-column: 1 / -1; }

.timeline { display: grid; gap: 0; }
.tl {
  display: grid; grid-template-columns: 84px 1fr auto; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--line-2); align-items: baseline;
}
.tl:last-child { border-bottom: 0; }
.tl .when { font-size: 12px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tl .what { min-width: 0; }
.tl .what .detail { font-size: 12.5px; color: var(--ink-2); margin-top: 2px; }
.tl .kind { font-size: 11px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--ink-3); }
.kv dd { margin: 0; }

/* -------------------------------------------------------------- modal -- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(12,16,22,.45);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal {
  background: var(--panel); border-radius: 12px; box-shadow: var(--shadow);
  width: min(560px, 100%); max-height: 88vh; overflow: auto;
  border: 1px solid var(--line);
}
.modal header { padding: 15px 18px; border-bottom: 1px solid var(--line-2); }
.modal header h3 { font-size: 15px; }
.modal .body { padding: 18px; display: grid; gap: 13px; }
.modal footer { padding: 13px 18px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 17px; border-radius: 20px;
  font-size: 13px; z-index: 200; box-shadow: var(--shadow);
}
.toast.bad { background: var(--bad); color: #fff; }

/* Offboarding: one row per item, each with its own return-or-keep choice. */
.offboard { display: grid; gap: 6px; }
.offboard-row {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--panel-2); flex-wrap: wrap;
}

.bar { height: 6px; border-radius: 3px; background: var(--line-2); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }

/* ---------------------------------------------- hosted-artifact additions -- */
.boot {
  min-height: 100vh; display: grid; place-items: center; padding: 32px;
  text-align: center; color: var(--ink-2);
}
.boot .inner { display: grid; gap: 10px; max-width: 46ch; }
.boot h2 { font-size: 18px; color: var(--ink); }
.boot p { font-size: 14.5px; margin: 0; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 22px; font-size: 13px;
  background: var(--warn-soft); color: var(--warn);
  border-bottom: 1px solid var(--line);
}
.banner strong { font-weight: 640; }

.whoami { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); }
.whoami img { width: 22px; height: 22px; border-radius: 50%; display: block; }

.byline { display: inline-flex; align-items: center; gap: 5px; }
.byline img { width: 15px; height: 15px; border-radius: 50%; display: block; }

.live { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; color: var(--ink-3); }
.live i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  display: block; animation: pulse 2.4s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .live i { animation: none; } }

.readonly .btn.primary, .readonly [data-write] { display: none !important; }
.readonly .status-select { pointer-events: none; opacity: .75; }

/* --- device thumbnails and photos ---------------------------------------- */
.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
th.thumbcol, td.thumbcol { width: 54px; padding-right: 0; }
.thumb {
  object-fit: cover; border-radius: 4px; display: block;
  background: var(--surface-2); border: 1px solid var(--line-2);
}
/* The drawings carry their own light plate, so they need no frame of their
   own — and no themed colour, since the bodies are the real device colours. */
.glyph, .glyph-large { display: block; line-height: 0; }
.glyph svg, .glyph-large svg { display: block; }
.glyph-large svg { width: 100%; height: auto; max-width: 232px; }

.photo-large {
  width: 100%; max-width: 232px; aspect-ratio: 4 / 3; object-fit: cover;
  border-radius: 7px; display: block; border: 1px solid var(--line-2);
  background: var(--surface-2);
}
/* The stock photographs were padded onto white, so they keep a white plate in
   both themes — the same reasoning as the drawings' plate. A themed surface
   behind one would meet the photo's own white as a visible hard edge. */
.thumb.generic, .photo-large.generic { background: #fff; }

/* --- credits -------------------------------------------------------------- */
.credits-link {
  display: block; margin-top: 10px; font-size: 11.5px; color: var(--ink-3);
  text-decoration: none;
}
.credits-link:hover { color: var(--ink-2); text-decoration: underline; }
.seg { display: inline-flex; gap: 6px; }
table.credits td { vertical-align: middle; }
table.credits td:first-child { width: 64px; padding-right: 0; }

/* ============================================================================
   BRAND LAYER — Quartermaster (product) sub-branded to a tenant.
   Appended as one block so it can be removed wholesale to revert.

   Quartermaster's own identity is deliberately achromatic: the TENANT owns
   the accent colour, so the same product can carry another studio's brand by
   changing --tenant alone.

   Tenant: Rebellion Design Co. — red #F02D22, taken from thisisarebellion.com.
   Red is used the way their deck uses it: hairline rules and small marks,
   never large fills. Status colours are left alone — brand red sitting in a
   table beside "stolen" red would stop stolen reading as alarming.
   ========================================================================= */
:root {
  --tenant: #F02D22;
  --tenant-ink: #C2170E;
  --tenant-soft: #fdeceb;
  --qm-disc: #121418;
  --qm-glyph: #f7f9fb;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --tenant: #FF5A4E;
    --tenant-ink: #FF7A70;
    --tenant-soft: #2e1512;
    --qm-disc: #eceff3;
    --qm-glyph: #121418;
  }
}
:root[data-theme="dark"] {
  --tenant: #FF5A4E;
  --tenant-ink: #FF7A70;
  --tenant-soft: #2e1512;
  --qm-disc: #eceff3;
  --qm-glyph: #121418;
}

/* --- brand lockup ------------------------------------------------------- */
.brand { align-items: flex-start; gap: 9px; }
.brand-mark {
  background: none; border-radius: 0; width: 30px; height: 30px;
  display: block; padding: 0;
}
.brand-mark svg { display: block; width: 30px; height: 30px; }
.brand-text { gap: 1px; }
.brand-text strong {
  font-size: 12.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .085em;
  color: var(--ink);
}
/* Scoped to .brand-text so it outranks the base `.brand-text span` rule,
   which would otherwise repaint the tenant name grey. */
.brand-text .brand-tenant {
  font-size: 9px; font-weight: 700; letter-spacing: .055em;
  text-transform: uppercase; color: var(--tenant);
  white-space: nowrap;
}
/* "for" belongs to Quartermaster's voice, not the tenant's, so it stays
   grey and lowercase — and keeps the eye on the company name. */
.brand-text .brand-for {
  color: var(--ink-3); font-weight: 500;
  text-transform: lowercase; letter-spacing: .03em;
}
/* The machine count already sits beside Computers in the nav; repeating it
   under the lockup crowded the tenant line, so it is retired here. */
.brand-text #brand-sub { display: none; }

/* --- the deck's label device: hairline rule over a small caps label ------ */
.stat .label, .card-head h2 {
  position: relative;
}
.stat { padding-top: 15px; }
.stat .label { padding-top: 9px; }
.stat .label::before {
  content: ""; position: absolute; top: 0; left: 0;
  width: 22px; height: 2px; background: var(--tenant);
}
/* Each tile's rule carries its own status colour, matching that status's pill
   in the Computers list. Tiles with no status keep the tenant accent. */
.stat.s-assigned   .label::before { background: var(--ok); }
.stat.s-unassigned .label::before { background: var(--accent); }
.stat.s-storage    .label::before { background: var(--store); }
.stat.s-gifted     .label::before { background: var(--gift); }
.stat.s-sold       .label::before { background: var(--warn); }
.stat.s-stolen     .label::before { background: var(--bad); }
.stat.s-retired    .label::before { background: var(--ink-3); }
.stat.s-discarded  .label::before { background: var(--gone); }
.stat .value { font-weight: 500; letter-spacing: -.03em; font-size: 27px; }

/* --- active navigation carries the tenant mark --------------------------- */
.nav a.active {
  background: var(--tenant-soft); color: var(--tenant-ink);
  box-shadow: inset 2px 0 0 var(--tenant);
}
.nav a.active em { color: var(--tenant-ink); }

.page-head h1 { letter-spacing: -.025em; }
