:root {
  --bg: #f6f7f9; --surface: #ffffff; --text: #1f2430; --muted: #6b7280; --border: #e8eaef; --thead: #f3f4f6;
  --brand: #cc4a0c; --brand-text: #b5420b; --brand-ink: #ffffff; --brand-soft: #fff1ea; --accent: #f26522;
  --logo: #e8590c; --dark: #0f3d4a;
  --ok: #157f3d; --ok-soft: #e6f6ec; --warn: #a15c00; --warn-soft: #fff4e0; --bad: #c0262d; --bad-soft: #fdecec;
  --info: #1d5fa8; --info-soft: #e8f1fb;
  --radius: 10px; --shadow: 0 1px 3px rgba(16, 24, 40, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #13161c; --surface: #1b1f27; --text: #e7e9ee; --muted: #9aa3b2; --border: #2a303b; --thead: #222731;
    --brand: #fb923c; --brand-text: #fb923c; --brand-ink: #1b1f27; --brand-soft: #3a2418; --accent: #fb923c; --logo: #fb923c; --dark: #2a6375;
    --ok: #4cc27a; --ok-soft: #15291e; --warn: #f0b04a; --warn-soft: #2d2412; --bad: #ff6b6b; --bad-soft: #331a1c;
    --info: #7ab3f0; --info-soft: #172536; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #13161c; --surface: #1b1f27; --text: #e7e9ee; --muted: #9aa3b2; --border: #2a303b; --thead: #222731;
  --brand: #fb923c; --brand-text: #fb923c; --brand-ink: #1b1f27; --brand-soft: #3a2418; --accent: #fb923c; --logo: #fb923c; --dark: #2a6375;
  --ok: #4cc27a; --ok-soft: #15291e; --warn: #f0b04a; --warn-soft: #2d2412; --bad: #ff6b6b; --bad-soft: #331a1c;
  --info: #7ab3f0; --info-soft: #172536; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-text); }
h1, h2, h3 { margin: 0; line-height: 1.25; }
h1 { font-size: 22px; } h2 { font-size: 16px; } h3 { font-size: 16px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* logo */
.logo { display: inline-block; height: 28px; aspect-ratio: 2008 / 696; background: var(--logo);
  -webkit-mask: url(/stark-logo.svg) no-repeat center / contain; mask: url(/stark-logo.svg) no-repeat center / contain; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-in { max-width: 1240px; margin: 0 auto; padding: 0 16px; height: 60px; display: flex; align-items: center; gap: 20px; }
.brand { display: flex; align-items: flex-end; gap: 8px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand-sub { font-weight: 700; font-size: 17px; line-height: 1; padding-bottom: 2px; }
.tabs { display: flex; gap: 2px; height: 100%; overflow-x: auto; scrollbar-width: none; }
.tabs a { display: flex; align-items: center; gap: 7px; padding: 0 12px; color: var(--muted); text-decoration: none; font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--text); }
.tabs a.on { color: var(--brand-text); border-bottom-color: var(--brand); }
.tabs svg { width: 17px; height: 17px; }
.top-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.who { text-align: right; line-height: 1.2; }
.who b { display: block; font-size: 13px; } .who span { font-size: 11.5px; color: var(--muted); text-transform: capitalize; }

/* layout */
main { max-width: 1240px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; align-items: start; }
@media (max-width: 960px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { padding: 14px 16px; }
.stat .k { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 26px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }
@media (max-width: 720px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.type-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.type-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--text); }
.type-chip .n { font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--thead); padding: 0 7px; border-radius: 999px; }
.type-chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-text); }
.type-chip.on .n { background: var(--surface); color: var(--brand-text); }

/* forms */
.form { display: grid; gap: 14px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .row { grid-template-columns: 1fr; } }
label.f { display: block; font-size: 13px; font-weight: 600; }
label.f > input, label.f > select, label.f > textarea { display: block; margin-top: 5px; }
label.f > .hint { margin-left: 4px; }
label.f > select + .hint, label.f > input + .hint { display: block; margin: 5px 0 0; }
label.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); outline: none; min-height: 40px; }
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.req { color: var(--bad); }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { border: 0; background: var(--surface); padding: 7px 14px; cursor: pointer; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--brand-soft); color: var(--brand-text); }
.subbox { border: 1px dashed var(--border); border-radius: 8px; padding: 14px; display: grid; gap: 14px; background: var(--bg); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 0 14px; height: 38px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; text-decoration: none; color: var(--text); white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 22px; line-height: 1; color: var(--muted); padding: 4px 8px; border-radius: 6px; }
.icon-btn:hover { background: var(--thead); color: var(--text); }

/* tables */
.toolbar { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { flex: 1 1 240px; }
.toolbar select { width: auto; min-width: 150px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--thead); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; white-space: nowrap; }
th.sortable { cursor: pointer; user-select: none; } th.sortable:hover { color: var(--text); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--thead) 55%, transparent); }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.tag { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.td-actions { text-align: right; white-space: nowrap; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }
.count-note { padding: 10px 16px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--border); }

.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.available { color: var(--ok); background: var(--ok-soft); }
.pill.issued { color: var(--info); background: var(--info-soft); }
.pill.repair { color: var(--warn); background: var(--warn-soft); }
.pill.retired { color: var(--muted); background: var(--thead); }
.cat { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.cat svg { width: 16px; height: 16px; color: var(--muted); }

/* lists (settings) */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-bottom: 1px solid var(--border); }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .meta { font-size: 12px; color: var(--muted); }
.add-row { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--bg); border-radius: 0 0 var(--radius) var(--radius); }
.add-row input.prefix { width: 80px; flex: none; text-transform: uppercase; }

/* recent */
.recent li { padding: 11px 18px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-text); display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: radial-gradient(1200px 500px at 100% 0%, var(--brand-soft), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 32px 28px; }
.auth-card .logo { height: 44px; }
.auth-card h1 { margin: 18px 0 4px; font-size: 20px; }
.auth-card .err { color: var(--bad); font-size: 13px; min-height: 18px; }

/* modal + toast */
.modal { position: fixed; inset: 0; background: rgba(10, 14, 20, .45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal-card { background: var(--surface); border-radius: 12px; width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
#modal-body { padding: 18px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.2); max-width: calc(100vw - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

.dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 14px; margin: 0 0 16px; }
.dl dt { color: var(--muted); font-size: 13px; } .dl dd { margin: 0; font-weight: 600; }

@media (max-width: 760px) {
  .topbar-in { height: auto; flex-wrap: wrap; padding-top: 10px; gap: 0 12px; }
  .tabs { order: 3; width: 100%; height: 44px; margin: 0 -4px; }
  .who { display: none; }
  .hide-sm { display: none; }
}
@media print { .topbar, .toolbar, .td-actions, .page-head .actions { display: none !important; } }
