:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-2: #f0f3f4;
  --border: #dde3e6;
  --text: #1c2a30;
  --muted: #5d6f77;
  --accent: #0e7c86;
  --accent-ink: #ffffff;
  --accent-soft: #e2f3f4;
  --danger: #c0392b;
  --danger-soft: #fbe9e7;
  --warn: #b26a00;
  --warn-soft: #fff4e0;
  --ok: #2e7d4f;
  --ok-soft: #e5f4ea;
  --info-soft: #e8eef9;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 32, 40, .06), 0 2px 8px rgba(16, 32, 40, .04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11181b; --surface: #182226; --surface-2: #1f2b30; --border: #2c3a40;
    --text: #e3eaed; --muted: #94a6ad; --accent: #3fb6c0; --accent-ink: #062126;
    --accent-soft: #163a3e; --danger: #ef7d6e; --danger-soft: #3a1f1c; --warn: #f0b04a;
    --warn-soft: #3a2c14; --ok: #6fcf97; --ok-soft: #173225; --info-soft: #1c2840;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
p { margin: 0 0 .75rem; }
code, .mono { font-family: var(--mono); font-size: .88em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* ---------- layout ---------- */
.topbar {
  display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem; height: 56px;
  background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 650; color: var(--text); white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.brand small { font-weight: 400; color: var(--muted); }
.nav { display: flex; gap: .25rem; flex: 1; overflow-x: auto; scrollbar-width: none; }
.nav a {
  padding: .4rem .7rem; border-radius: 7px; color: var(--muted); font-weight: 500; white-space: nowrap;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.userbox { display: flex; align-items: center; gap: .6rem; white-space: nowrap; }
.userbox form { margin: 0; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--border);
  display: grid; place-items: center; font-size: .78rem; font-weight: 600; color: var(--muted);
}
main { max-width: 1280px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
main.narrow { max-width: 820px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.page-head .actions form { margin: 0; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1.1rem 1.25rem; }
.card + .card { margin-top: 1rem; }
.stats > .card, .grid > .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1.25rem; align-items: start; }
@media (max-width: 960px) {
  .split, .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.25rem; }
.stat { padding: .9rem 1rem; display: block; color: var(--text); }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .label { color: var(--muted); font-size: .82rem; }
.stat .value { font-size: 1.7rem; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat.alert .value { color: var(--danger); }

.bar-row { display: grid; grid-template-columns: 150px 1fr 36px; gap: .6rem; align-items: center; font-size: .88rem; padding: .2rem 0; }
.bar-row .track { background: var(--surface-2); border-radius: 4px; height: 8px; overflow: hidden; }
.bar-row .fill { background: var(--accent); height: 100%; border-radius: 4px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .6rem .75rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
td .sub { display: block; color: var(--muted); font-size: .82rem; }
.row-link { color: var(--text); font-weight: 550; }
.empty { padding: 2.5rem 1rem; text-align: center; color: var(--muted); }

/* ---------- badges ---------- */
.badge {
  display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .76rem; font-weight: 600;
  background: var(--surface-2); color: var(--muted); white-space: nowrap; border: 1px solid transparent;
}
.badge.s-new { background: var(--info-soft); color: #3561b8; }
.badge.s-open { background: var(--accent-soft); color: var(--accent); }
.badge.s-pending { background: var(--warn-soft); color: var(--warn); }
.badge.s-resolved, .badge.s-closed, .badge.a-in_use { background: var(--ok-soft); color: var(--ok); }
.badge.p-urgent { background: var(--danger); color: #fff; }
.badge.p-high { background: var(--danger-soft); color: var(--danger); }
.badge.p-normal { background: var(--surface-2); color: var(--muted); }
.badge.p-low { background: transparent; border-color: var(--border); color: var(--muted); }
.badge.a-in_stock { background: var(--info-soft); color: #3561b8; }
.badge.a-repair { background: var(--warn-soft); color: var(--warn); }
.badge.a-retired { background: var(--surface-2); color: var(--muted); }
.overdue { color: var(--danger); font-weight: 600; }
@media (prefers-color-scheme: dark) { .badge.s-new, .badge.a-in_stock { color: #9db8f0; } }

.fdot { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; font-weight: 600; color: var(--muted); white-space: nowrap; }
.fdot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.fdot.f-online { color: var(--ok); }
.fdot.f-offline, .fdot.f-new { color: var(--muted); }
.fdot.f-removed, .fdot.f-missing { color: var(--warn); }

/* ---------- forms ---------- */
label { display: block; font-weight: 550; font-size: .88rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.hint { color: var(--muted); font-size: .82rem; margin-top: .25rem; font-weight: 400; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=tel],
select, textarea {
  width: 100%; padding: .55rem .7rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 140px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
input[type=file] { font: inherit; font-size: .88rem; }
.check { display: flex; align-items: center; gap: .45rem; font-weight: 500; }
.check input { width: auto; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; padding: .75rem; border-bottom: 1px solid var(--border); }
.filters select, .filters input { width: auto; min-width: 130px; padding: .4rem .55rem; font-size: .88rem; }
.filters input[type=search] { min-width: 220px; flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .5rem .95rem;
  border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--danger); }
.btn.small { padding: .3rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.link { border: 0; background: none; color: var(--muted); padding: .3rem .4rem; }
.btn.google { background: var(--surface); width: 100%; padding: .7rem; font-size: 1rem; }

.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg a { padding: .35rem .8rem; color: var(--muted); font-size: .88rem; font-weight: 550; }
.seg a + a { border-left: 1px solid var(--border); }
.seg a.on { background: var(--accent-soft); color: var(--accent); }
.seg a:hover { text-decoration: none; background: var(--surface-2); }

/* ---------- flashes ---------- */
.flash { padding: .7rem 1rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid transparent; }
.flash.success { background: var(--ok-soft); color: var(--ok); }
.flash.error { background: var(--danger-soft); color: var(--danger); }
.flash.info { background: var(--info-soft); }

/* ---------- ticket thread ---------- */
.thread { display: flex; flex-direction: column; gap: .9rem; }
.msg { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.msg-head { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border-bottom: 1px solid var(--border); font-size: .88rem; flex-wrap: wrap; }
.msg-head .who { font-weight: 600; }
.msg-head .when { margin-left: auto; color: var(--muted); }
.msg-body { padding: .85rem 1rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.staff { border-left: 3px solid var(--accent); }
.msg.internal { background: var(--warn-soft); border-color: #e9c98a; border-left: 3px solid var(--warn); }
@media (prefers-color-scheme: dark) { .msg.internal { border-color: #5b4520; } }
.files { display: flex; flex-wrap: wrap; gap: .4rem; padding: 0 1rem .8rem; }
.file-chip { display: inline-flex; gap: .35rem; align-items: center; border: 1px solid var(--border); border-radius: 6px; padding: .2rem .55rem; font-size: .83rem; background: var(--surface-2); }
.reply-box textarea { min-height: 110px; }
.reply-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.reply-actions .spacer { flex: 1; }

.meta { display: grid; grid-template-columns: 105px 1fr; gap: .45rem .75rem; font-size: .9rem; }
.meta dt { color: var(--muted); }
.meta dd { margin: 0; overflow-wrap: anywhere; }
.timeline { list-style: none; margin: 0; padding: 0; font-size: .84rem; }
.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.timeline li:last-child { border: 0; }
.timeline .when { color: var(--muted); display: block; font-size: .78rem; }
.sidebar .card-body + .card-body { border-top: 1px solid var(--border); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 400px; }
.login-card .brand { justify-content: center; font-size: 1.15rem; margin-bottom: 1.25rem; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .82rem; margin: 1.1rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

/* ---------- QR labels ---------- */
.qr { background: #fff; padding: 6px; border-radius: 6px; display: inline-block; line-height: 0; }
.qr svg { width: 140px; height: 140px; }
.labels { display: grid; grid-template-columns: repeat(auto-fill, minmax(2.6in, 1fr)); gap: .15in; }
.qr-label {
  display: flex; gap: .12in; align-items: center; border: 1px dashed #b9c4c8; border-radius: 6px; padding: .1in;
  background: #fff; color: #000; break-inside: avoid; height: 1.15in;
}
.qr-label .qr { padding: 0; }
.qr-label .qr svg { width: .95in; height: .95in; }
.qr-label .tag { font: 700 14pt var(--mono); }
.qr-label .lname { font-size: 8.5pt; line-height: 1.25; }
.qr-label .help { font-size: 7.5pt; margin-top: 3px; }
@media print {
  .topbar, .no-print, .flash { display: none !important; }
  body, main { background: #fff; padding: 0; margin: 0; max-width: none; }
  .qr-label { border-color: #ddd; }
}
@media (max-width: 640px) {
  .topbar { padding: .5rem .75rem 0; gap: .5rem; height: auto; flex-wrap: wrap; }
  .topbar .brand { flex: 1; }
  .nav { order: 3; flex-basis: 100%; padding-bottom: .4rem; }
  .brand small, .userbox .uname { display: none; }
  main { padding: 1rem .75rem 3rem; }
  .bar-row { grid-template-columns: 110px 1fr 30px; }
  .hide-sm { display: none; }
}
