/* ============================================================
   AssetFlow — design system
   ============================================================ */
:root {
  --brand-cyan: #59d5db;
  --brand-cyan-dark: #11a6af;
  --brand-pink: #f65abc;
  --brand-pink-dark: #cf2d91;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --ring: 0 0 0 3px var(--focus-ring);
  --tab-bar-h: 56px;
  font-synthesis-weight: none;
}

/* ---- Light theme ---- */
:root, [data-theme="light"] {
  --bg: #eef2f7;
  --bg-grad-1: rgba(89, 213, 219, .22);
  --bg-grad-2: rgba(246, 90, 188, .14);
  --surface: #ffffff;
  --surface-2: #f6f9fc;
  --surface-3: #eef3f8;
  --surface-glass: rgba(255, 255, 255, .72);
  --border: #e3e9f1;
  --border-strong: #d2dbe6;
  --text: #0d1626;
  --text-soft: #41506a;
  --text-muted: #6b7a91;
  --primary: #0d9aa3;
  --primary-strong: #0a7f87;
  --primary-soft: #e4f7f8;
  --accent: #e0429f;
  --accent-soft: #fdeaf6;
  --success: #0a8f6b;
  --success-soft: #e3f8ef;
  --warning: #b06c00;
  --warning-soft: #fff3dc;
  --danger: #d33b57;
  --danger-soft: #fdeaef;
  --info-soft: #eef1f6;
  --focus-ring: rgba(13, 154, 163, .28);
  --shadow-sm: 0 1px 2px rgba(16, 32, 56, .06), 0 2px 8px rgba(16, 32, 56, .05);
  --shadow: 0 6px 20px rgba(16, 32, 56, .10);
  --shadow-lg: 0 24px 60px rgba(16, 32, 56, .20);
  --chart-track: #eaeff5;
  color-scheme: light;
}

/* ---- Dark theme ---- */
[data-theme="dark"] {
  --bg: #070b12;
  --bg-grad-1: rgba(17, 166, 175, .20);
  --bg-grad-2: rgba(246, 90, 188, .14);
  --surface: #121826;
  --surface-2: #161e2e;
  --surface-3: #1c2638;
  --surface-glass: rgba(18, 24, 38, .72);
  --border: #243049;
  --border-strong: #324063;
  --text: #e9eef7;
  --text-soft: #b7c2d6;
  --text-muted: #7e8ba6;
  --primary: #2dd4bf;
  --primary-strong: #14b8a6;
  --primary-soft: rgba(45, 212, 191, .14);
  --accent: #f65abc;
  --accent-soft: rgba(246, 90, 188, .16);
  --success: #34d399;
  --success-soft: rgba(52, 211, 153, .14);
  --warning: #fbbf24;
  --warning-soft: rgba(251, 191, 36, .14);
  --danger: #fb7185;
  --danger-soft: rgba(251, 113, 133, .14);
  --info-soft: rgba(255, 255, 255, .06);
  --focus-ring: rgba(45, 212, 191, .34);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow: 0 8px 28px rgba(0, 0, 0, .5);
  --shadow-lg: 0 30px 70px rgba(0, 0, 0, .65);
  --chart-track: #1f2a3f;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Inter", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1100px 520px at 8% -8%, var(--bg-grad-1), transparent 60%),
    radial-gradient(900px 460px at 100% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

.ico { width: 18px; height: 18px; flex: 0 0 auto; fill: currentColor; }
.hidden { display: none !important; }

button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--primary); }
.btn:active { transform: translateY(0); }
.btn.sm { min-height: 32px; padding: 0 11px; border-radius: 8px; font-size: 13px; box-shadow: none; }
.btn .ico { width: 17px; height: 17px; }

.btn.primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--primary) 40%, transparent);
}
.btn.primary:hover { filter: brightness(1.05); border-color: transparent; }
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); box-shadow: none; }
.btn.danger:hover { background: color-mix(in srgb, var(--danger) 20%, transparent); border-color: transparent; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 10px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .14s ease, box-shadow .14s ease, color .14s ease, border-color .14s ease, background .14s ease;
}
.icon-btn:hover { transform: translateY(-1px); color: var(--primary); border-color: var(--primary); box-shadow: var(--shadow); }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 8px; box-shadow: none; }

:where(button, input, select, textarea, [tabindex]):focus-visible { outline: none; box-shadow: var(--ring); border-color: var(--primary); }

/* ---------- App bar ---------- */
.appbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 16px;
  padding: 12px 22px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.brand-mark { border-radius: 9px; box-shadow: var(--shadow-sm); }
.brand-text { display: grid; line-height: 1.15; }
.brand-text strong { font-size: 17px; letter-spacing: -.01em; }
.brand-text span { font-size: 11.5px; color: var(--text-muted); }

.appbar-search {
  flex: 1 1 auto; max-width: 560px;
  display: flex; align-items: center; gap: 9px;
  padding: 0 14px; height: 42px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text-muted);
  transition: border-color .14s ease, box-shadow .14s ease;
}
.appbar-search:focus-within { border-color: var(--primary); box-shadow: var(--ring); }
.appbar-search input { border: 0; background: transparent; flex: 1; outline: none; min-width: 0; }

.appbar-actions { display: flex; align-items: center; gap: 9px; margin-left: auto; }

.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 40px; padding: 0 13px;
  border-radius: 10px; border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text-soft);
  font-weight: 600; font-size: 13px; cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, color .14s ease, background .14s ease;
}
.chip .ico { width: 16px; height: 16px; }
.chip.ok { color: var(--success); border-color: color-mix(in srgb, var(--success) 40%, var(--border)); }
.chip.warn { color: var(--warning); border-color: color-mix(in srgb, var(--warning) 45%, var(--border)); background: var(--warning-soft); }

/* theme toggle */
.ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }
[data-theme="dark"] .ico-moon { display: block; }

/* menu */
.menu-wrap { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: 252px; padding: 7px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  z-index: 60; display: grid; gap: 2px;
  animation: pop .12s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(-6px) scale(.98); } }
.menu-panel button {
  display: flex; align-items: center; gap: 11px;
  width: 100%; padding: 9px 11px; border: 0; background: transparent;
  color: var(--text-soft); border-radius: 9px; cursor: pointer;
  font-weight: 550; text-align: left; font-size: 13.5px;
}
.menu-panel button .ico { width: 17px; height: 17px; color: var(--text-muted); }
.menu-panel button:hover { background: var(--primary-soft); color: var(--primary-strong); }
.menu-panel button:hover .ico { color: var(--primary); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 6px; }

/* ---------- Tabs ---------- */
.tabs {
  position: sticky; top: 67px; z-index: 30;
  display: flex; gap: 4px; align-items: center;
  padding: 8px 22px; height: var(--tab-bar-h);
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  overflow-x: auto; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 16px; border: 0; border-radius: 10px;
  background: transparent; color: var(--text-muted);
  font-weight: 600; cursor: pointer; white-space: nowrap;
  transition: background .14s ease, color .14s ease;
}
.tab .ico { width: 18px; height: 18px; }
.tab:hover { background: var(--surface-2); color: var(--text-soft); }
.tab.active { background: var(--primary-soft); color: var(--primary-strong); }

/* ---------- Layout ---------- */
main {
  display: grid;
  grid-template-columns: 286px minmax(0, 1fr);
  align-items: start;
  gap: 0;
}
main.no-sidebar { grid-template-columns: minmax(0, 1fr); }
main.no-sidebar #sidebar { display: none; }

aside#sidebar {
  position: sticky; top: 123px;
  align-self: start;
  height: calc(100vh - 123px);
  overflow: auto;
  padding: 16px 14px;
  border-right: 1px solid var(--border);
  display: grid; gap: 14px; align-content: start;
}

.content { padding: 20px 22px 40px; min-width: 0; }

/* ---------- View head ---------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.view-head h2 { margin: 0; font-size: 23px; letter-spacing: -.02em; }
.view-sub { margin: 3px 0 0; color: var(--text-muted); font-size: 13px; }
.view-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }

/* ---------- Fields ---------- */
.field-label { display: grid; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-muted); letter-spacing: .02em; }
.field-label.inline { grid-auto-flow: column; align-items: center; gap: 8px; }
.field-label.full { grid-column: 1 / -1; }
input, select, textarea {
  width: 100%; padding: 9px 11px; min-height: 40px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--text-muted); }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.check-label { grid-auto-flow: column; justify-content: start; align-items: center; gap: 9px; color: var(--text-soft); font-size: 13px; }
.check-label input { width: 18px; height: 18px; min-height: 0; accent-color: var(--primary); }

.filters { display: grid; gap: 10px; }

.rail-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 0; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.rail-head-actions { display: flex; gap: 4px; }

.category-list { display: grid; gap: 4px; }
.category-button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; padding: 9px 11px; text-align: left;
  border: 1px solid transparent; border-radius: 10px;
  background: transparent; color: var(--text-soft);
  cursor: pointer; font-weight: 550; font-size: 13.5px;
  transition: background .14s ease, color .14s ease, border-color .14s ease;
}
.category-button:hover { background: var(--surface-2); }
.category-button strong { font-weight: 700; font-size: 12px; color: var(--text-muted); background: var(--surface-3); border-radius: 999px; padding: 2px 9px; min-width: 26px; text-align: center; }
.category-button.active { background: var(--primary-soft); color: var(--primary-strong); border-color: color-mix(in srgb, var(--primary) 32%, transparent); }
.category-button.active strong { background: color-mix(in srgb, var(--primary) 22%, transparent); color: var(--primary-strong); }
.category-button .dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 auto; }
.category-button .cat-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.category-button .cat-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.card-head-actions { display: flex; align-items: center; gap: 7px; }
.card-body { padding: 16px; }

/* ---------- KPI ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  position: relative; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px 16px 15px;
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-ico { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 12px; }
.kpi-ico .ico { width: 21px; height: 21px; }
.kpi-val { font-size: 28px; font-weight: 750; letter-spacing: -.03em; line-height: 1; }
.kpi-label { color: var(--text-muted); font-size: 12.5px; margin-top: 5px; }
.kpi-sub { font-size: 11.5px; margin-top: 6px; font-weight: 600; }
.tone-primary .kpi-ico { background: var(--primary-soft); color: var(--primary); }
.tone-accent  .kpi-ico { background: var(--accent-soft); color: var(--accent); }
.tone-success .kpi-ico { background: var(--success-soft); color: var(--success); }
.tone-warning .kpi-ico { background: var(--warning-soft); color: var(--warning); }
.tone-info    .kpi-ico { background: var(--info-soft); color: var(--text-soft); }

/* ---------- Dashboard grid ---------- */
.dash-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.dash-grid .span-2 { grid-column: span 2; }

/* donut */
.donut-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.donut { width: 168px; height: 168px; border-radius: 50%; position: relative; flex: 0 0 auto; }
.donut::after { content: ""; position: absolute; inset: 24px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 1px 3px rgba(0,0,0,.08); }
.donut-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 1; }
.donut-center strong { font-size: 26px; font-weight: 750; letter-spacing: -.02em; }
.donut-center span { color: var(--text-muted); font-size: 11.5px; }
.legend { display: grid; gap: 8px; flex: 1 1 160px; min-width: 150px; }
.legend-row { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.legend-row .dot { width: 11px; height: 11px; border-radius: 3px; flex: 0 0 auto; }
.legend-row .lg-name { color: var(--text-soft); }
.legend-row .lg-val { margin-left: auto; font-weight: 700; }

/* category bars */
.bars { display: grid; gap: 11px; }
.bar-row { display: grid; gap: 5px; }
.bar-top { display: flex; justify-content: space-between; font-size: 13px; }
.bar-top .b-name { color: var(--text-soft); font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-top .b-val { color: var(--text-muted); font-weight: 700; }
.bar-track { height: 9px; border-radius: 999px; background: var(--chart-track); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand-cyan), var(--brand-cyan-dark)); transition: width .5s cubic-bezier(.2,.7,.2,1); }

/* alerts + activity */
.alert-item, .activity-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface-2); margin-bottom: 9px; cursor: pointer;
  transition: border-color .14s ease, transform .14s ease;
}
.alert-item:hover, .activity-item:hover { border-color: var(--primary); transform: translateX(2px); }
.alert-item:last-child, .activity-item:last-child { margin-bottom: 0; }
.alert-badge { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; }
.alert-badge .ico { width: 18px; height: 18px; }
.alert-badge.bad { background: var(--danger-soft); color: var(--danger); }
.alert-badge.warn { background: var(--warning-soft); color: var(--warning); }
.alert-badge.ok { background: var(--success-soft); color: var(--success); }
.alert-main { min-width: 0; flex: 1; }
.alert-main strong { display: block; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-main small { color: var(--text-muted); }
.alert-when { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

/* register health */
.health-wrap { display: flex; align-items: center; gap: 22px; flex-wrap: wrap; }
.health-ring { width: 132px; height: 132px; border-radius: 50%; position: relative; flex: 0 0 auto; }
.health-ring::after { content: ""; position: absolute; inset: 15px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 1px 3px rgba(0,0,0,.08); }
.health-center { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; z-index: 1; }
.health-center strong { font-size: 27px; font-weight: 750; letter-spacing: -.02em; }
.health-center span { color: var(--text-muted); font-size: 11px; }
.health-gaps { flex: 1 1 210px; min-width: 200px; display: grid; gap: 7px; align-content: start; }
.gap-row { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border: 1px solid var(--border); border-radius: 11px; background: var(--surface-2); cursor: pointer; transition: border-color .14s ease, transform .14s ease; }
.gap-row:hover { border-color: var(--primary); transform: translateX(2px); }
.gap-row .g-count { font-weight: 750; min-width: 26px; color: var(--text); }
.gap-row .g-label { flex: 1; color: var(--text-soft); font-size: 13px; }
.gap-row .g-go { width: 15px; height: 15px; color: var(--text-muted); }
.gap-row.clean { cursor: default; }
.gap-row.clean:hover { transform: none; border-color: var(--border); }
.gap-row.clean .ico { color: var(--success); }

.gap-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 15px; margin-bottom: 14px; border: 1px solid color-mix(in srgb, var(--primary) 32%, var(--border)); background: var(--primary-soft); border-radius: 12px; font-size: 13.5px; color: var(--primary-strong); }
.gap-banner strong { font-weight: 750; }
.gap-banner button { border: 0; background: transparent; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; }

/* ---------- Split (table + detail) ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.maintenance-split { grid-template-columns: minmax(0, 1fr) 300px; }
/* Compact detail panel (list shows the key columns; full info on click) */
.detail-card .detail-grid { grid-template-columns: 1fr; }
.detail-card .detail { padding: 14px; gap: 13px; }
/* DESKTOP asset list: show only Asset Tag, Make/Model, Assigned To (+ actions).
   The rest of the detail appears when you open the asset. Mobile keeps every column (scrollable). */
@media (min-width: 981px) {
  #assetTable th:nth-child(2), #assetTable td:nth-child(2),   /* Category */
  #assetTable th:nth-child(4), #assetTable td:nth-child(4),   /* Serial */
  #assetTable th:nth-child(6), #assetTable td:nth-child(6),   /* Status */
  #assetTable th:nth-child(7), #assetTable td:nth-child(7),   /* Warranty */
  #assetTable th:nth-child(8), #assetTable td:nth-child(8),   /* Purchased */
  #assetTable th:nth-child(9), #assetTable td:nth-child(9) {  /* Logs */
    display: none;
  }
}

.table-card { overflow: hidden; }
.table-wrap { overflow: auto; max-height: calc(100vh - 220px); }
table { width: 100%; border-collapse: collapse; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface-3); color: var(--text-muted);
  text-align: left; font-size: 11px; font-weight: 750; text-transform: uppercase; letter-spacing: .05em;
  padding: 11px 14px; white-space: nowrap; border-bottom: 1px solid var(--border);
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
tbody tr { cursor: pointer; transition: background .12s ease; }
tbody tr:hover td { background: var(--surface-2); }
tbody tr.selected td { background: var(--primary-soft); }
tbody tr:last-child td { border-bottom: 0; }
.sort-button { border: 0; background: transparent; color: inherit; font: inherit; font-weight: 750; cursor: pointer; padding: 0; text-transform: inherit; letter-spacing: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort-button.active { color: var(--primary); }
.sort-button.active::after { content: attr(data-direction); font-size: 10px; }

.asset-tag-chip { display: inline-flex; align-items: center; max-width: 160px; padding: 3px 10px; border-radius: 7px; background: var(--primary-soft); color: var(--primary-strong); font-weight: 700; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; }

.table-actions { display: inline-flex; gap: 3px; }
.table-actions .icon-btn { width: 30px; height: 30px; border: 0; background: transparent; box-shadow: none; border-radius: 8px; color: var(--text-muted); }
.table-actions .icon-btn:hover { background: var(--surface-3); transform: none; }
.table-actions .icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.table-actions .ico { width: 16px; height: 16px; }

/* ---------- Pills & badges ---------- */
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--info-soft); color: var(--text-soft); white-space: nowrap; }
.pill.good { background: var(--success-soft); color: var(--success); }
.pill.warn { background: var(--warning-soft); color: var(--warning); }
.pill.bad  { background: var(--danger-soft); color: var(--danger); }
.pill.info { background: var(--primary-soft); color: var(--primary-strong); }
.pill .ico { width: 13px; height: 13px; }

.wbadge { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 650; }
.wbadge.ok { color: var(--success); }
.wbadge.soon { color: var(--warning); }
.wbadge.expired { color: var(--danger); }
.wbadge.none { color: var(--text-muted); }
.wbadge .ico { width: 14px; height: 14px; }

/* ---------- Detail ---------- */
.detail { padding: 16px; display: grid; gap: 16px; max-height: calc(100vh - 220px); overflow: auto; }
.empty { padding: 40px 20px; text-align: center; color: var(--text-muted); line-height: 1.5; }
.detail-title { display: flex; justify-content: space-between; align-items: start; gap: 12px; }
.detail-title h3 { margin: 0 0 3px; font-size: 19px; letter-spacing: -.01em; overflow-wrap: anywhere; }
.detail-title p { margin: 0; color: var(--text-muted); font-size: 13px; }
.detail-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.detail-grid.full-detail-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field {
  border: 1px solid var(--border); border-radius: 12px; padding: 11px 12px;
  background: var(--surface-2); min-width: 0; border-left: 3px solid var(--primary);
}
.field.full { grid-column: 1 / -1; }
.field span { display: block; color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.field strong { display: block; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }

.detail-section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.detail-section-head h4 { margin: 0; font-size: 14px; }

/* QR thumb in detail */
.qr-thumb { display: flex; align-items: center; gap: 14px; padding: 12px; border: 1px dashed var(--border-strong); border-radius: 12px; background: var(--surface-2); }
.qr-thumb .qr-mini { width: 92px; height: 92px; background: #fff; border-radius: 8px; padding: 6px; flex: 0 0 auto; display: grid; place-items: center; }
.qr-thumb .qr-mini svg, .qr-thumb .qr-mini img, .qr-thumb .qr-mini canvas { width: 100%; height: 100%; }
.qr-thumb-text strong { display: block; font-size: 13.5px; }
.qr-thumb-text small { color: var(--text-muted); }

/* logs */
.log-list { display: grid; gap: 9px; }
.log-entry { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.log-entry header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.log-entry header strong { font-size: 13.5px; }
.log-entry small { color: var(--text-muted); white-space: nowrap; }
.log-entry p { margin: 0; color: var(--text-soft); overflow-wrap: anywhere; }
.log-meta { margin-top: 6px; color: var(--text-muted); font-size: 12px; }
.edit-log-button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 8px; padding: 3px 10px; font-size: 12px; font-weight: 650; cursor: pointer; color: var(--text-soft); }
.edit-log-button:hover { border-color: var(--primary); color: var(--primary); }

/* maintenance task */
.maintenance-task-list { display: grid; gap: 9px; }
.maintenance-task { border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: var(--surface-2); }
.maintenance-task header { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 6px; }

/* images & attachments */
.image-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; }
.asset-image { border: 1px solid var(--border); border-radius: 12px; overflow: hidden; background: var(--surface-2); position: relative; }
.asset-image img { display: block; width: 100%; aspect-ratio: 4/3; object-fit: cover; cursor: pointer; background: var(--surface-3); }
.asset-image figcaption { padding: 6px 8px; color: var(--text-muted); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.remove-image-button { position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 999px; }
.attachment-list { display: grid; gap: 8px; }
.attachment-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
.attachment-main { min-width: 0; }
.attachment-main strong, .attachment-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-main small { color: var(--text-muted); }
.attachment-actions { display: flex; gap: 6px; flex-shrink: 0; }
.image-manager { grid-column: 1 / -1; display: grid; gap: 10px; }

/* ---------- Notes ---------- */
.notes-grid { display: grid; grid-template-columns: minmax(250px, 0.85fr) minmax(270px, 1fr) minmax(0, 1.55fr); gap: 16px; align-items: start; }
.notes-search { display: grid; gap: 11px; padding: 16px; }
.notes-search .filter-row { grid-template-columns: 1fr; }
.notes-list { display: grid; gap: 9px; padding: 12px; max-height: calc(100vh - 240px); overflow: auto; }
.note-card { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); padding: 12px; display: grid; gap: 8px; cursor: pointer; transition: border-color .14s ease; }
.note-card:hover { border-color: var(--border-strong); }
.note-card.selected { border-color: var(--primary); background: var(--primary-soft); }
.note-card header { display: flex; justify-content: space-between; align-items: start; gap: 10px; }
.note-card h4 { margin: 0; font-size: 14.5px; overflow-wrap: anywhere; }
.note-meta { color: var(--text-muted); font-size: 12px; }
.note-card-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.note-detail-body { border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); min-height: 160px; padding: 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.security-note { border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border)); background: var(--warning-soft); color: var(--warning); border-radius: 12px; padding: 11px 13px; font-size: 12.5px; }

/* ---------- Dialogs ---------- */
dialog { border: 0; padding: 0; border-radius: var(--radius-lg); width: min(740px, calc(100vw - 26px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden; }
dialog::backdrop { background: rgba(8, 14, 24, .5); backdrop-filter: blur(3px); }
dialog.fullscreen-dialog { width: min(1320px, calc(100vw - 20px)); height: min(900px, calc(100vh - 20px)); }
dialog.image-dialog { width: 100vw; height: 100vh; max-width: 100vw; max-height: 100vh; border-radius: 0; }
.modal-head, .modal-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 15px 18px; background: var(--surface-2); }
.modal-head { border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-actions { border-top: 1px solid var(--border); justify-content: flex-end; }
.modal-body { padding: 18px; display: grid; gap: 13px; max-height: 70vh; overflow: auto; }
.fullscreen-dialog .modal-body { max-height: calc(100vh - 116px); align-content: start; }
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.section-title { grid-column: 1 / -1; margin: 8px 0 -2px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; font-weight: 750; color: var(--text-soft); }
.full { grid-column: 1 / -1; }
.field-picker { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(auto-fit, minmax(176px, 1fr)); gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.field-picker label { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }
.field-picker input { width: 16px; height: 16px; min-height: 0; accent-color: var(--primary); }
.export-summary { grid-column: 1 / -1; color: var(--text-muted); font-size: 13px; margin: 0; }

/* viewers */
.image-viewer { display: grid; place-items: center; min-height: calc(100vh - 116px); background: #0a0f17; padding: 14px; }
.image-viewer img { max-width: 100%; max-height: calc(100vh - 140px); object-fit: contain; border-radius: 12px; box-shadow: var(--shadow-lg); }
.document-viewer { min-height: calc(100vh - 116px); background: #0a0f17; padding: 14px; }
.document-viewer iframe { width: 100%; height: calc(100vh - 144px); border: 0; border-radius: 12px; background: #fff; }

/* qr & scan */
.qr-body { justify-items: center; text-align: center; }
.qr-canvas { background: #fff; padding: 16px; border-radius: 14px; box-shadow: var(--shadow); }
.qr-canvas svg, .qr-canvas img, .qr-canvas canvas { width: 232px; height: 232px; display: block; }
.qr-caption { color: var(--text-muted); font-size: 13px; }
.scan-body { justify-items: center; }
#scanVideo { width: 100%; max-width: 480px; aspect-ratio: 4/3; background: #000; border-radius: 14px; object-fit: cover; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  background: var(--text); color: var(--surface);
  border-radius: 12px; padding: 13px 16px; font-weight: 600; font-size: 13.5px;
  box-shadow: var(--shadow-lg); opacity: 0; transform: translateY(12px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; max-width: min(420px, calc(100vw - 40px));
}
.toast.show { opacity: 1; transform: translateY(0); }

.file-input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ---------- Cloud sync chip + account ---------- */
.chip.syncing { color: var(--text-soft); }
.menu-account { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 11px; margin-bottom: 4px; border-radius: 9px; background: var(--surface-2); }
.menu-account-info { display: grid; min-width: 0; }
.menu-account-info span { font-size: 11px; color: var(--text-muted); }
.menu-account-info strong { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Login gate ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1000px 500px at 10% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(800px 420px at 100% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  overflow: auto;
}
.auth-card {
  width: min(400px, 100%); display: grid; gap: 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 26px 24px; box-shadow: var(--shadow-lg);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 2px; }
.auth-brand img { border-radius: 10px; }
.auth-brand strong { font-size: 19px; letter-spacing: -.01em; }
.auth-card h2 { margin: 6px 0 0; font-size: 22px; letter-spacing: -.02em; }
.auth-sub { margin: 0 0 6px; color: var(--text-muted); font-size: 13px; }
.auth-card .btn.primary { margin-top: 4px; width: 100%; min-height: 44px; }
.auth-error { margin: 0; padding: 9px 11px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; font-weight: 600; }
.auth-toggle { border: 0; background: transparent; color: var(--primary); font-weight: 650; cursor: pointer; font-size: 13px; padding: 4px; }
.auth-toggle:hover { text-decoration: underline; }

/* ---------- App PIN lock ---------- */
.pin-gate {
  position: fixed; inset: 0; z-index: 300;
  display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1000px 500px at 10% -10%, var(--bg-grad-1), transparent 60%),
    radial-gradient(800px 420px at 100% 0%, var(--bg-grad-2), transparent 55%),
    var(--bg);
  overflow: auto;
}
.pin-card {
  width: min(360px, 100%); display: grid; gap: 14px; justify-items: center; text-align: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 26px 24px; box-shadow: var(--shadow-lg);
}
.pin-card h2 { margin: 4px 0 0; font-size: 22px; letter-spacing: -.02em; }
.pin-card .auth-sub { text-align: center; }
.pin-dots { display: flex; gap: 12px; min-height: 16px; align-items: center; }
.pin-dot { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--border); transition: background .12s ease, border-color .12s ease; }
.pin-dot.filled { background: var(--primary); border-color: var(--primary); }
.pin-error { margin: 0; min-height: 16px; color: var(--danger); font-size: 13px; font-weight: 600; }
.pin-keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; width: 100%; max-width: 280px; }
.pin-key {
  min-height: 60px; border-radius: 14px; border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text);
  font-size: 22px; font-weight: 650; cursor: pointer; user-select: none;
  display: grid; place-items: center; transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.pin-key:hover { border-color: var(--primary); }
.pin-key:active { transform: scale(.95); background: var(--primary-soft); }
.pin-key.action svg { width: 24px; height: 24px; }
.pin-key.ok { color: var(--primary); }
.pin-shake { animation: pinShake .4s; }
@keyframes pinShake { 0%, 100% { transform: translateX(0); } 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.pin-forgot { border: 0; background: transparent; color: var(--text-muted); font-size: 12px; font-weight: 600; cursor: pointer; padding: 4px; }
.pin-forgot:hover { color: var(--primary); text-decoration: underline; }

/* ---------- Mobile drawer + scrim (inactive on desktop) ---------- */
.scrim { position: fixed; inset: 0; background: rgba(8, 14, 24, .5); backdrop-filter: blur(2px); z-index: 50; }
.drawer-head { display: none; }
#mobileFiltersBtn { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .notes-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .notes-detail-card { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
  main, main.no-sidebar { grid-template-columns: minmax(0, 1fr); }
  /* Sidebar becomes a slide-in drawer (off-canvas) */
  aside#sidebar {
    position: fixed; top: 0; left: 0; z-index: 55;
    width: min(86vw, 330px);
    height: 100vh; height: 100dvh;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    transform: translateX(-100%); transition: transform .25s ease;
    border-right: 1px solid var(--border); border-bottom: 0;
    box-shadow: var(--shadow-lg); background: var(--surface);
  }
  body.sidebar-open aside#sidebar { transform: translateX(0); }
  .drawer-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 2px; }
  .drawer-head h3 { margin: 0; font-size: 16px; }
  #mobileFiltersBtn { display: inline-flex; }
  .split, .maintenance-split { grid-template-columns: 1fr; }
  /* On phones, details open as a full-screen sheet instead of a buried panel */
  #assetsView .detail-card,
  #maintenanceView .detail-card,
  #notesView .notes-detail-card { display: none; }
  #notesView .note-card-actions { display: none; }
  .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid .span-2 { grid-column: span 2; }
  .table-wrap { max-height: none; }
  .detail { max-height: none; }
}
@media (max-width: 720px) {
  .appbar { flex-wrap: wrap; padding: 10px 14px; }
  .appbar-search { order: 3; flex-basis: 100%; max-width: none; }
  .brand-text span { display: none; }
  .appbar-actions .btn span { display: none; }
  .tabs { top: 0; }
  .content { padding: 16px 14px 40px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* 5 KPI cards in 2 columns leaves the last one alone — center it */
  .kpi-grid .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; max-width: calc(50% - 7px); margin-inline: auto; }
  .dash-grid { grid-template-columns: 1fr; }
  .dash-grid .span-2 { grid-column: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .notes-grid { grid-template-columns: 1fr; }
}

/* ---------- Global search results dropdown ---------- */
.appbar-search { position: relative; }
.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  max-height: min(70vh, 540px); overflow-y: auto;
  padding: 6px; display: grid; gap: 2px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg);
  z-index: 80; animation: pop .12s ease;
}
.sr-group { display: flex; align-items: center; justify-content: space-between; padding: 9px 10px 4px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.sr-group span { background: var(--surface-3); border-radius: 999px; padding: 1px 8px; font-size: 11px; }
.sr-item { display: flex; align-items: center; gap: 11px; width: 100%; text-align: left; padding: 9px 11px; border: 1px solid transparent; border-radius: 10px; background: transparent; color: var(--text-soft); cursor: pointer; font: inherit; }
.sr-item:hover, .sr-item:focus-visible { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 28%, transparent); outline: none; }
.sr-item > .ico { width: 18px; height: 18px; color: var(--text-muted); flex: 0 0 auto; }
.sr-item:hover > .ico { color: var(--primary); }
.sr-main { min-width: 0; display: grid; }
.sr-main strong { font-size: 13.5px; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-main small { color: var(--text-muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-item mark { background: color-mix(in srgb, var(--primary) 32%, transparent); color: inherit; border-radius: 3px; padding: 0 1px; }
.sr-empty { padding: 22px 14px; text-align: center; color: var(--text-muted); }
.sr-more { padding: 6px 11px 9px; font-size: 12px; color: var(--text-muted); }

/* ---------- Changelog (per-day history) ---------- */
.changelog-list { display: grid; gap: 12px; }
.changelog-day { overflow: hidden; }
.changelog-day-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%; padding: 14px 16px; background: transparent; border: 0; cursor: pointer; color: var(--text); font: inherit; }
.changelog-day-head:hover { background: var(--surface-2); }
.cl-day-title { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.cl-day-title .ico { width: 18px; height: 18px; color: var(--text-muted); flex: 0 0 auto; }
.cl-day-right { display: flex; align-items: center; gap: 10px; }
.cl-chev { width: 18px; height: 18px; color: var(--text-muted); transition: transform .15s ease; }
.cl-chev.open { transform: rotate(180deg); }
.changelog-entries { padding: 12px 16px 16px; display: grid; gap: 9px; border-top: 1px solid var(--border); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
