/* =====================================================================
   Helmm — TheGafGroup · Design system
   Minimal light UI · Montserrat + JetBrains Mono
   ===================================================================== */

:root {
  --bg: #FFFFFF;
  --surface: #F8FAFC;
  --border: #E2E8F0;
  --text: #0F172A;
  --muted: #64748B;
  --navy: #0A2540;
  --blue: #0284C7;
  --blue-soft: #E0F2FE;
  --blue-hover: #0369A1;
  --success: #15803D;
  --success-soft: #DCFCE7;
  --warning: #B45309;
  --warning-soft: #FEF3C7;
  --danger: #B91C1C;
  --danger-soft: #FEE2E2;
  --info-soft: #EDE9FE;
  --info: #6D28D9;
  --slate-soft: #F1F5F9;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.18);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.25; letter-spacing: -0.01em; }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 12px; }
p { margin: 0 0 8px; }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-hover); }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.icon { flex-shrink: 0; vertical-align: middle; }
[hidden] { display: none !important; }
.req { color: var(--danger); }

/* ---------- Layout ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 40;
  transition: width .2s ease, transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 18px 16px 14px; gap: 8px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-name { font-weight: 700; font-size: 17px; color: var(--navy); letter-spacing: -0.02em; }
.brand-sub { font-size: 11px; color: var(--muted); font-weight: 500; white-space: nowrap; }
.sidebar-nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; white-space: nowrap;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: var(--surface); color: var(--text); }
.nav-link.active { background: var(--blue-soft); color: var(--blue-hover); font-weight: 600; }
.sidebar-footer { padding: 10px; border-top: 1px solid var(--border); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px 10px; min-width: 0; }
.user-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.user-name { font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-email { font-size: 11px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  background: var(--navy); color: #fff; font-weight: 700; font-size: 13px;
  display: inline-flex; align-items: center; justify-content: center;
}
.avatar-lg { width: 40px; height: 40px; font-size: 15px; }
.sidebar-toggle { color: var(--muted); }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; transition: margin-left .2s ease; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(160%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-subtitle { margin: 0; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.topbar-subtitle .crumb { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.topbar-subtitle .crumb:hover { color: var(--blue); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-menu { display: none; }
.content { padding: 24px 28px 40px; display: flex; flex-direction: column; gap: 20px; }
.app-footer { padding: 14px 28px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.mobile-nav { display: none; }

/* Collapsed sidebar */
body.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .main { margin-left: var(--sidebar-w-collapsed); }
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .user-meta { display: none; }
body.sidebar-collapsed .sidebar-brand { justify-content: center; flex-direction: column; gap: 10px; }
body.sidebar-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
body.sidebar-collapsed .nav-link { justify-content: center; padding: 11px; }
body.sidebar-collapsed .user-chip { justify-content: center; }

/* ---------- Cards ---------- */
.card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.card-title { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; font-size: 15px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head .card-title { margin-bottom: 2px; }
.card-footer { padding-top: 12px; margin-top: 4px; border-top: 1px solid var(--border); font-size: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-top { align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.meta { margin-top: 14px; }

/* ---------- KPIs ---------- */
.kpi-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 14px; }
.kpi {
  display: flex; flex-direction: column; gap: 4px;
  padding: 18px 20px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius);
  color: var(--text); box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
a.kpi:hover { border-color: #CBD5E1; box-shadow: var(--shadow); transform: translateY(-1px); color: var(--text); }
.kpi-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.kpi-value { font-size: 28px; font-weight: 700; letter-spacing: -0.03em; line-height: 1.1; }
.kpi-foot { font-size: 12px; }
.kpi-brand { background: var(--navy); border-color: var(--navy); color: #fff; }
.kpi-brand .kpi-label, .kpi-brand .kpi-foot { color: rgba(255,255,255,0.7); }
.kpi-alert { border-color: #FCD34D; background: #FFFBEB; }
.kpi-alert .kpi-value { color: var(--warning); }
.kpi.active-filter { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.kpi-sm { padding: 12px 14px; }
.kpi-sm .kpi-value { font-size: 22px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 14px; border-radius: var(--radius-sm);
  font: inherit; font-weight: 600; font-size: 13px; line-height: 1.2;
  border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
  text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-hover); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { border-color: #CBD5E1; background: var(--surface); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #991B1B; color: #fff; }
.btn-danger-ghost { background: transparent; color: var(--danger); border-color: var(--border); }
.btn-danger-ghost:hover { background: var(--danger-soft); border-color: #FCA5A5; color: var(--danger); }
.btn-link { background: none; border: none; color: var(--blue); padding: 4px 6px; }
.btn-link:hover { color: var(--blue-hover); text-decoration: underline; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-xs { padding: 2px 6px; font-size: 11px; }
.btn-lg { padding: 12px 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn.loading { position: relative; color: transparent !important; pointer-events: none; }
.btn.loading::after {
  content: ''; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.5); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary.loading::after, .btn-ghost.loading::after { border-color: var(--border); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .35; cursor: not-allowed; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }

/* ---------- Badges & chips ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.01em; line-height: 1.5;
  white-space: nowrap;
}
.badge-status::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-active { background: var(--success-soft); color: var(--success); }
.badge-spare { background: var(--blue-soft); color: var(--blue-hover); }
.badge-in_repair { background: var(--warning-soft); color: var(--warning); }
.badge-lost_stolen { background: var(--danger-soft); color: var(--danger); }
.badge-retired { background: var(--slate-soft); color: var(--muted); }
.badge-primary { background: var(--navy); color: #fff; font-size: 10px; padding: 2px 7px; margin-left: 6px; vertical-align: middle; }
.badge-w-ok { background: var(--success-soft); color: var(--success); }
.badge-w-expiring { background: var(--warning-soft); color: var(--warning); }
.badge-w-expired { background: var(--danger-soft); color: var(--danger); }
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; font-weight: 500; color: var(--text); white-space: nowrap;
}
.chip-muted { color: var(--muted); }
.chip-link:hover { border-color: var(--blue); color: var(--blue); }
.tag-pill { background: var(--navy); color: #fff; padding: 4px 10px; border-radius: 6px; font-weight: 500; font-size: 13px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th {
  text-align: left; padding: 10px 12px;
  background: var(--surface); color: var(--muted);
  font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table th:first-child { border-top-left-radius: var(--radius-sm); }
.table th:last-child { border-top-right-radius: var(--radius-sm); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: #FCFDFE; }
.table-compact td { padding: 9px 12px; }
.table .col-check { width: 36px; }
.table .col-actions { width: 1%; white-space: nowrap; text-align: right; }
.table .col-actions .icon-btn { width: 28px; height: 28px; }
.table .col-icon { width: 120px; }
.cell-primary { display: block; font-weight: 600; color: var(--text); }
.cell-primary:hover { color: var(--blue); }
.cell-secondary { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.tag-link { font-weight: 500; color: var(--navy); }
.tag-link:hover { color: var(--blue); }
.row-muted td { opacity: .55; }
.table-inline-forms form { display: contents; }
.table-inline-forms .input-sm { width: 100%; min-width: 140px; }
.row-add td { background: var(--surface); }
.warranty { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; white-space: nowrap; }
.warranty .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.warranty-expiring .dot { background: #F59E0B; }
.warranty-expired .dot { background: var(--danger); }
.warranty-expired { color: var(--danger); }
.warranty-expiring { color: var(--warning); }

/* ---------- Toolbar / search / dropdown ---------- */
.card-toolbar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search-box {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 260px;
  padding: 0 12px; height: 40px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg);
  color: var(--muted); transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
.search-box input { flex: 1; border: none; outline: none; font: inherit; font-size: 14px; color: var(--text); background: transparent; min-width: 0; }
.toolbar-filters { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.dropdown { position: relative; }
.dropdown-toggle { height: 40px; }
.dropdown-toggle .filter-count:not(:empty) { background: var(--blue); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; min-width: 18px; text-align: center; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  min-width: 220px; max-height: 320px; overflow-y: auto;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow); padding: 6px;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown.open .dropdown-toggle { border-color: var(--blue); }
.dropdown-wide .dropdown-menu { min-width: 320px; }
.dropdown-actions { display: flex; gap: 6px; padding: 2px 6px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; user-select: none; }
.check:hover { background: var(--surface); }
.check input { width: 16px; height: 16px; accent-color: var(--blue); margin: 0; flex-shrink: 0; }
.check-inline { border: 1px solid var(--border); height: 40px; padding: 0 12px; }
.bulk-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; margin-bottom: 12px;
  background: var(--blue-soft); border: 1px solid #BAE6FD; border-radius: var(--radius-sm);
  font-size: 13px; color: var(--blue-hover);
}
.empty-state { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding: 48px 20px; color: var(--muted); }
.empty-state h3 { color: var(--text); }
.empty-state.small { padding: 26px 16px; }
.empty-state .icon { color: #CBD5E1; }

/* ---------- Forms ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text); }
.field-grow { flex: 1; }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="date"],
input[type="datetime-local"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font: inherit; font-size: 14px; color: var(--text); background: var(--bg);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-soft); }
input[readonly] { background: var(--surface); color: var(--muted); }
textarea { resize: vertical; min-height: 70px; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input-sm, .select-sm { padding: 6px 10px; font-size: 13px; }
.select-sm { padding-right: 28px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.field-full { grid-column: 1 / -1; }
.form-errors { background: var(--danger-soft); color: var(--danger); border: 1px solid #FCA5A5; border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: 13px; }
.form-errors ul { margin: 0; padding-left: 18px; }
.field.has-error input, .field.has-error select { border-color: #FCA5A5; }
.field-error { font-size: 12px; color: var(--danger); }
.form-inline-row { display: flex; gap: 10px; margin: 12px 0 16px; }
.form-inline-row input { flex: 1; }
.options-row { display: flex; flex-direction: column; gap: 4px; margin: 10px 0; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; border: 1px solid; }
.alert-error { background: var(--danger-soft); border-color: #FCA5A5; color: var(--danger); }
.alert-success { background: var(--success-soft); border-color: #86EFAC; color: var(--success); }
.alert .icon { margin-top: 1px; }

/* ---------- Modals & slide-overs ---------- */
.modal-root, .slideover-root { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.45); backdrop-filter: blur(2px); animation: fade .15s ease; }
.modal {
  position: relative; width: 100%; max-width: 560px; max-height: calc(100vh - 40px);
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: pop .18s ease;
}
.modal form { display: flex; flex-direction: column; min-height: 0; }
.modal-lg { max-width: 820px; }
.modal-sm { max-width: 420px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px 12px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 18px 22px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface); border-radius: 0 0 14px 14px; }
.slideover-root { justify-content: flex-end; padding: 0; }
.slideover {
  position: relative; width: 100%; max-width: 560px; height: 100%;
  background: var(--bg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; animation: slide .22s ease;
}
.slideover-form { display: flex; flex-direction: column; height: 100%; }
.slideover .modal-body { flex: 1; }
.slideover .modal-footer { border-radius: 0; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slide { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
body.modal-open { overflow: hidden; }

/* ---------- Toasts ---------- */
.toast-stack { position: fixed; right: 20px; bottom: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: 360px; }
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--navy); color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: toast-in .2s ease;
  border-left: 4px solid var(--blue);
}
.toast-success { border-left-color: #4ADE80; }
.toast-error { border-left-color: #F87171; }
.toast-info { border-left-color: #60A5FA; }
.toast.hide { opacity: 0; transform: translateY(6px); transition: all .25s; }
.toast button { background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer; margin-left: auto; font-size: 16px; line-height: 1; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Device hero & tabs ---------- */
.device-hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.device-hero-main { display: flex; gap: 16px; align-items: center; min-width: 0; }
.device-hero-icon { width: 56px; height: 56px; border-radius: 14px; background: var(--blue-soft); color: var(--blue-hover); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.device-hero-tags { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 6px; }
.device-hero-name { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; margin-bottom: 2px; }
.device-hero-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.status-switch { display: flex; flex-direction: column; gap: 3px; }
.status-switch-wrap select { padding: 7px 32px 7px 12px; font-weight: 600; font-size: 13px; border-radius: 999px; min-width: 150px; }
.status-switch-wrap.status-active select { background-color: var(--success-soft); color: var(--success); border-color: #86EFAC; }
.status-switch-wrap.status-spare select { background-color: var(--blue-soft); color: var(--blue-hover); border-color: #7DD3FC; }
.status-switch-wrap.status-in_repair select { background-color: var(--warning-soft); color: var(--warning); border-color: #FCD34D; }
.status-switch-wrap.status-lost_stolen select { background-color: var(--danger-soft); color: var(--danger); border-color: #FCA5A5; }
.status-switch-wrap.status-retired select { background-color: var(--slate-soft); color: var(--muted); border-color: #CBD5E1; }

.tabs { display: flex; flex-direction: column; gap: 16px; }
.tab-list { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 10px 14px; margin-bottom: -1px;
  background: none; border: none; border-bottom: 2px solid transparent;
  font: inherit; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--blue-hover); border-bottom-color: var(--blue); }
.tab-count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; font-size: 11px; color: var(--muted); }
.tab-btn.active .tab-count { background: var(--blue-soft); border-color: #BAE6FD; color: var(--blue-hover); }
.tab-panel { display: none; flex-direction: column; gap: 20px; }
.tab-panel.active { display: flex; }

.spec-list { margin: 0; display: flex; flex-direction: column; }
.spec-row { display: grid; grid-template-columns: 160px 1fr; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.spec-row:last-child { border-bottom: none; }
.spec-row dt { color: var(--muted); font-size: 13px; }
.spec-row dd { margin: 0; font-weight: 500; word-break: break-word; }
.notes { white-space: normal; line-height: 1.65; background: var(--surface); border-radius: var(--radius-sm); padding: 14px 16px; }
.warranty-card .warranty-head { display: flex; justify-content: space-between; align-items: center; }
.warranty-countdown { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 10px; }
.warranty-days { font-size: 34px; font-weight: 700; letter-spacing: -0.03em; }
.warranty-card.warranty-expired .warranty-days { color: var(--danger); }
.warranty-card.warranty-expiring .warranty-days { color: var(--warning); }
.warranty-card.warranty-ok .warranty-days { color: var(--success); }
.progress { height: 8px; background: var(--slate-soft); border-radius: 999px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--blue); border-radius: 999px; transition: width .3s; }
.warranty-expiring .progress span { background: #F59E0B; }
.warranty-expired .progress span { background: var(--danger); }
.progress-sm { height: 5px; margin-top: 8px; }
.secret { letter-spacing: 0.1em; }

/* Timeline */
.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; position: relative; }
.timeline::before { content: ''; position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 18px 32px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot { position: absolute; left: 5px; top: 14px; width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 3px solid var(--blue); }
.timeline-card { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; background: var(--bg); }
.timeline-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.timeline-head > div:first-child { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.timeline-title { font-size: 14px; }
.timeline-meta { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.timeline-meta .cost { font-weight: 600; }
.timeline-desc { margin: 10px 0 6px; color: #334155; line-height: 1.6; }
.timeline-foot { display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- Group pages ---------- */
.group-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.group-card {
  display: flex; flex-direction: column; gap: 10px; padding: 16px 18px;
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text);
  box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.group-card:hover { border-color: #CBD5E1; box-shadow: var(--shadow); transform: translateY(-1px); color: var(--text); }
.group-card-icon { width: 38px; height: 38px; border-radius: 10px; background: var(--blue-soft); color: var(--blue-hover); display: flex; align-items: center; justify-content: center; }
.group-card-muted .group-card-icon { background: var(--slate-soft); color: var(--muted); }
.group-card-body h3 { font-size: 15px; margin-bottom: 2px; }
.group-card-body p { margin: 0; }
.group-card-stats { display: flex; gap: 18px; padding-top: 10px; border-top: 1px solid var(--border); }
.stat { display: flex; flex-direction: column; line-height: 1.2; }
.stat strong { font-size: 15px; }
.stat .muted { font-size: 11px; }
.group-section { scroll-margin-top: 80px; }
.empty-cats { margin: -6px 0 0; }
.people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.person-card { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.person-card p { margin: 2px 0 8px; }
.person-devices { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Settings ---------- */
.settings-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: calc(var(--topbar-h) + 20px); display: flex; flex-direction: column; gap: 2px; }
.settings-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius-sm); color: var(--muted); font-weight: 500; }
.settings-nav a:hover { background: var(--surface); color: var(--text); }
.settings-main { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.settings-main .card { scroll-margin-top: 80px; }
.token-reveal { margin-bottom: 14px; align-items: flex-start; }
.token-box { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.token-box code { background: #fff; border: 1px solid #86EFAC; border-radius: 6px; padding: 6px 10px; font-size: 13px; color: var(--text); word-break: break-all; }
.api-help { margin-top: 14px; }
.api-help summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--blue); }
.code-block { background: var(--navy); color: #E2E8F0; border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto; font-size: 12.5px; line-height: 1.6; margin: 10px 0; }
.code-block code { font-family: var(--mono); }

/* ---------- Import / export ---------- */
.steps { margin: 0 0 16px; padding-left: 20px; color: var(--muted); }
.steps li { margin-bottom: 4px; }
.upload-form { gap: 12px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  padding: 28px 16px; border: 2px dashed var(--border); border-radius: var(--radius);
  background: var(--surface); color: var(--muted); cursor: pointer; text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--blue-soft); }
.dropzone input { display: none; }
.dropzone .icon { color: var(--blue); }
.dropzone-text { color: var(--text); }
.mapping-table th { vertical-align: top; min-width: 170px; }
.mapping-header { display: block; margin-bottom: 6px; text-transform: none; letter-spacing: 0; color: var(--text); font-weight: 600; }
.import-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.import-errors summary { cursor: pointer; font-weight: 600; font-size: 13px; }
.import-errors ul { margin: 8px 0 0; padding-left: 18px; max-height: 220px; overflow-y: auto; color: var(--muted); }

/* ---------- Auth ---------- */
.auth-body { background: var(--surface); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-wrap { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; align-items: center; }
.auth-card { width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 16px; padding: 32px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 14px; }
.auth-brand h1 { font-size: 26px; font-weight: 700; color: var(--navy); letter-spacing: -0.03em; }
.auth-brand p { margin: 0; font-size: 12.5px; }
.auth-foot { text-align: center; font-size: 12px; margin: 0; }
.auth-copy { font-size: 12px; margin: 0; }

/* ---------- Labels ---------- */
.label-toolbar .label-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 8px; }
.label-sheet { display: flex; flex-wrap: wrap; gap: 10mm; padding: 4mm; background: var(--surface); border-radius: var(--radius); border: 1px dashed var(--border); }
.label {
  display: flex; gap: 3mm; align-items: center;
  background: #fff; color: #000; border: 0.3mm solid #CBD5E1; border-radius: 1.5mm;
  padding: 2mm; box-sizing: border-box; overflow: hidden; break-inside: avoid; page-break-inside: avoid;
}
.label-qr { flex-shrink: 0; height: 100%; aspect-ratio: 1 / 1; }
.label-qr svg { display: block; width: 100%; height: 100%; }
.label-body { display: flex; flex-direction: column; justify-content: center; min-width: 0; line-height: 1.15; }
.label-brand { display: flex; align-items: center; gap: 1.2mm; font-weight: 700; color: var(--navy); }
.label-brand .brand-mark { flex-shrink: 0; }
.label-company { font-weight: 500; color: var(--muted); }
.label-tag { font-weight: 600; color: #000; letter-spacing: 0.02em; white-space: nowrap; }
.label-model, .label-serial { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #1E293B; }
.label-serial { color: var(--muted); }
.label-small { --lw: 38mm; --lh: 25mm; }
.label-medium { --lw: 62mm; --lh: 29mm; }
.label-large { --lw: 89mm; --lh: 36mm; }
.label-small .label { width: 38mm; height: 25mm; padding: 1.5mm; gap: 2mm; }
.label-small .label-brand { font-size: 5.5pt; }
.label-small .label-tag { font-size: 9pt; }
.label-small .label-model, .label-small .label-serial { font-size: 5.5pt; }
.label-medium .label { width: 62mm; height: 29mm; }
.label-medium .label-brand { font-size: 6.5pt; }
.label-medium .label-tag { font-size: 13pt; }
.label-medium .label-model, .label-medium .label-serial { font-size: 7pt; }
.label-large .label { width: 89mm; height: 36mm; padding: 3mm; gap: 4mm; }
.label-large .label-brand { font-size: 8pt; }
.label-large .label-tag { font-size: 18pt; }
.label-large .label-model, .label-large .label-serial { font-size: 9pt; }

@media print {
  @page { margin: 8mm; }
  body { background: #fff; font-size: 10pt; }
  .sidebar, .sidebar-backdrop, .topbar, .mobile-nav, .app-footer, .no-print, .toast-stack, .modal-root { display: none !important; }
  .main { margin-left: 0 !important; }
  .content { padding: 0; gap: 0; }
  .label-sheet { background: none; border: none; padding: 0; gap: 4mm; }
  .label { border-color: #E2E8F0; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* ---------- Responsive ---------- */
@media (max-width: 1200px) {
  .kpi-row { grid-template-columns: repeat(3, 1fr); }
  .kpi-brand { grid-column: span 1; }
}
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); width: var(--sidebar-w) !important; box-shadow: var(--shadow-lg); }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 35; }
  body.sidebar-collapsed .brand-text, body.sidebar-collapsed .nav-label, body.sidebar-collapsed .user-meta { display: initial; }
  body.sidebar-collapsed .nav-link { justify-content: flex-start; padding: 10px 12px; }
  .sidebar-toggle { display: none; }
  .main { margin-left: 0 !important; }
  .topbar { padding: 0 16px; }
  .topbar-menu { display: inline-flex; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 9px 11px; }
  .content { padding: 16px 16px 90px; gap: 16px; }
  .app-footer { display: none; }
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: rgba(255,255,255,0.96); backdrop-filter: blur(8px);
    border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 2px; font-size: 10.5px; font-weight: 600; color: var(--muted); border-radius: 8px; }
  .mobile-nav-link.active { color: var(--blue); }
  .grid-2, .settings-layout { grid-template-columns: 1fr; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; padding-bottom: 4px; }
  .settings-nav a { white-space: nowrap; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .kpi-brand { grid-column: span 2; }
  .toast-stack { left: 16px; right: 16px; bottom: 80px; max-width: none; }
  .modal-root { padding: 0; align-items: flex-end; }
  .modal { max-width: none; max-height: 92vh; border-radius: 14px 14px 0 0; }
  .modal-footer { border-radius: 0; }
  .slideover { max-width: none; }
  .import-summary { grid-template-columns: repeat(2, 1fr); }
  .spec-row { grid-template-columns: 120px 1fr; }
  .device-hero-actions { width: 100%; justify-content: space-between; }
}
@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 24px; }
  .card { padding: 16px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .search-box { min-width: 0; width: 100%; }
  .table-devices .cell-secondary { display: none; }
  .label-sheet { gap: 4mm; }
  .form-inline-row { flex-direction: column; }
}
