/* VaultOS — operator cockpit
   Aesthetic: calm industrial. Linear's density × Verkada's telemetry × Stripe's clarity.
*/

:root {
  /* Accent palette — Deep Indigo (default) */
  --accent-50:  #eef0ff;
  --accent-100: #dde0ff;
  --accent-200: #b9bfff;
  --accent-300: #8d96ff;
  --accent-400: #6b73ff;
  --accent-500: #4f46e5;
  --accent-600: #4338ca;
  --accent-700: #3730a3;

  /* Semantic */
  --ok:    #10b981;
  --warn:  #f59e0b;
  --bad:   #ef4444;
  --info:  #38bdf8;
  --cyan:  #22d3ee;   /* Smart lock active */
  --violet:#a78bfa;

  /* Surface (dark) */
  --bg-0: #07080b;        /* page */
  --bg-1: #0c0e13;        /* panel */
  --bg-2: #11141b;        /* card */
  --bg-3: #161a23;        /* hover / nested */
  --bg-4: #1d2230;        /* active */
  --line-1: rgba(255,255,255,0.06);
  --line-2: rgba(255,255,255,0.10);
  --line-3: rgba(255,255,255,0.16);

  /* Text */
  --tx-1: #e9ecf2;
  --tx-2: #aab1bf;
  --tx-3: #6b7280;
  --tx-4: #4b5260;

  /* Type */
  --font-sans: "Geist", "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Geist Mono", ui-monospace, "JetBrains Mono", "SF Mono", Menlo, monospace;

  /* Density (default: comfortable) */
  --row-h: 36px;
  --gutter: 16px;
  --card-pad: 18px;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* Motion */
  --ease: cubic-bezier(.2,.7,.2,1);
}

/* density variants */
:root[data-density="compact"] {
  --row-h: 30px;
  --gutter: 12px;
  --card-pad: 14px;
}
:root[data-density="roomy"] {
  --row-h: 42px;
  --gutter: 22px;
  --card-pad: 22px;
}

/* light theme */
:root[data-theme="light"] {
  --bg-0: #f6f7f9;
  --bg-1: #ffffff;
  --bg-2: #ffffff;
  --bg-3: #f1f3f7;
  --bg-4: #e8ecf3;
  --line-1: rgba(15,18,28,0.06);
  --line-2: rgba(15,18,28,0.10);
  --line-3: rgba(15,18,28,0.18);
  --tx-1: #0d1117;
  --tx-2: #475066;
  --tx-3: #6b7280;
  --tx-4: #9aa3b2;
}

/* accent variants — set on :root via data-accent */
:root[data-accent="cyan"] {
  --accent-300:#67e8f9; --accent-400:#22d3ee; --accent-500:#06b6d4; --accent-600:#0891b2; --accent-700:#0e7490;
  --accent-100:#cffafe; --accent-200:#a5f3fc; --accent-50:#ecfeff;
}
:root[data-accent="emerald"] {
  --accent-300:#6ee7b7; --accent-400:#34d399; --accent-500:#10b981; --accent-600:#059669; --accent-700:#047857;
  --accent-100:#d1fae5; --accent-200:#a7f3d0; --accent-50:#ecfdf5;
}
:root[data-accent="amber"] {
  --accent-300:#fcd34d; --accent-400:#fbbf24; --accent-500:#f59e0b; --accent-600:#d97706; --accent-700:#b45309;
  --accent-100:#fef3c7; --accent-200:#fde68a; --accent-50:#fffbeb;
}

/* base */
* { box-sizing: border-box; }
html, body, #root { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 13px;
  line-height: 1.45;
  color: var(--tx-1);
  background: var(--bg-0);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01","cv11","tnum";
}
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
::selection { background: color-mix(in oklab, var(--accent-500) 50%, transparent); }

/* scrollbars */
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--bg-4); border: 2px solid transparent; background-clip: padding-box;
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: var(--line-3); background-clip: padding-box; border: 2px solid transparent; }
*::-webkit-scrollbar-track { background: transparent; }

/* utility */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum","zero"; }
.tnum { font-variant-numeric: tabular-nums; }
.hairline { border: 1px solid var(--line-1); }
.muted { color: var(--tx-2); }
.dim { color: var(--tx-3); }
.divider { height: 1px; background: var(--line-1); }

/* layout */
.app {
  display: grid;
  grid-template-columns: 232px 1fr;
  grid-template-rows: 100vh;
  height: 100vh;
  overflow: hidden;
}
.app[data-sidebar="collapsed"] { grid-template-columns: 56px 1fr; }

.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line-1);
  display: flex; flex-direction: column;
  min-height: 0;
}
.main {
  display: grid;
  grid-template-rows: 52px 1fr;
  min-height: 0;
  background: var(--bg-0);
}
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-1);
  background: var(--bg-0);
  position: relative;
  z-index: 5;
}
.content {
  overflow: auto;
  padding: 18px;
  min-height: 0;
}

/* sidebar nav */
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line-1);
}
.brand-mark {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(140deg, var(--accent-500), var(--accent-700));
  display:grid; place-items:center; color:white;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 6px 12px -6px var(--accent-500);
  position: relative;
}
.brand-mark::after {
  content:""; position:absolute; inset:6px; border-radius:3px;
  border: 1.5px solid rgba(255,255,255,0.85);
  border-top-color: transparent; border-right-color: transparent;
}
.brand-name {
  font-size: 13px; font-weight: 600; letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 10.5px; color: var(--tx-3); text-transform: uppercase; letter-spacing: 0.1em;
  margin-top: 1px;
}

.nav-section { padding: 10px 8px; }
.nav-label {
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--tx-3); padding: 6px 10px 4px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: 6px;
  color: var(--tx-2);
  cursor: pointer;
  user-select: none;
  position: relative;
  height: var(--row-h);
}
.nav-item:hover { background: var(--bg-3); color: var(--tx-1); }
.nav-item[data-active="true"] {
  background: var(--bg-3);
  color: var(--tx-1);
}
.nav-item[data-active="true"]::before {
  content: ""; position: absolute; left: -8px; top: 8px; bottom: 8px;
  width: 2px; border-radius: 2px;
  background: var(--accent-400);
}
.nav-item .icon { flex-shrink: 0; opacity: 0.85; }
.nav-item .lbl { flex: 1; font-size: 13px; }
.nav-item .badge {
  font-size: 10.5px; padding: 1px 6px; border-radius: 99px;
  background: var(--bg-4); color: var(--tx-2);
  font-variant-numeric: tabular-nums;
}
.nav-item .badge.warn { background: color-mix(in oklab, var(--warn) 18%, transparent); color: #fbbf24; }
.nav-item .badge.bad  { background: color-mix(in oklab, var(--bad) 18%, transparent); color: #fca5a5; }

.app[data-sidebar="collapsed"] .lbl,
.app[data-sidebar="collapsed"] .nav-label,
.app[data-sidebar="collapsed"] .brand-name,
.app[data-sidebar="collapsed"] .brand-sub,
.app[data-sidebar="collapsed"] .badge { display: none; }
.app[data-sidebar="collapsed"] .brand { justify-content: center; padding: 12px 8px; }
.app[data-sidebar="collapsed"] .nav-item { justify-content: center; }

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--line-1);
  display: flex; align-items: center; gap: 10px;
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  background: linear-gradient(140deg, #f59e0b, #ef4444);
  display:grid; place-items:center; color:white; font-weight:600; font-size:11px;
  flex-shrink: 0;
}
.facility-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-3); border: 1px solid var(--line-1);
  padding: 4px 8px 4px 6px; border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
}
.facility-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.facility-pill:hover { border-color: var(--line-3); }

/* topbar */
.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line-1);
  padding: 0 10px;
  height: 30px;
  border-radius: 7px;
  flex: 0 1 360px;
  color: var(--tx-3);
}
.search input {
  background: transparent; border: 0; outline: 0;
  width: 100%; color: var(--tx-1);
  font-size: 12.5px;
}
.search kbd {
  font-family: var(--font-mono);
  font-size: 10.5px;
  background: var(--bg-3); padding: 1px 5px; border-radius: 4px;
  color: var(--tx-3); border: 1px solid var(--line-1);
}
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--tx-3); }
.crumbs .here { color: var(--tx-1); }
.topbar-spacer { flex: 1; }

.iconbtn {
  width: 30px; height: 30px; border-radius: 7px;
  display: grid; place-items: center;
  background: transparent; border: 1px solid transparent;
  color: var(--tx-2);
}
.iconbtn:hover { background: var(--bg-3); color: var(--tx-1); border-color: var(--line-1); }
.iconbtn.active { background: var(--bg-3); color: var(--tx-1); border-color: var(--line-1); }

.live-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--tx-2);
  padding: 3px 8px; border-radius: 99px;
  background: color-mix(in oklab, var(--ok) 14%, transparent);
  color: #6ee7b7;
}
.live-indicator .pulse {
  width: 6px; height: 6px; border-radius: 50%; background: var(--ok);
  box-shadow: 0 0 0 0 currentColor;
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 color-mix(in oklab, var(--ok) 60%, transparent); }
  70%  { box-shadow: 0 0 0 8px color-mix(in oklab, var(--ok) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 transparent; }
}

/* page header */
.page-head {
  display: flex; align-items: end; justify-content: space-between; gap: 16px;
  margin-bottom: 14px;
}
.page-title {
  font-size: 22px; letter-spacing: -0.02em; font-weight: 600;
  margin: 0;
}
.page-sub { color: var(--tx-2); font-size: 12.5px; margin-top: 2px; }
.head-actions { display: flex; gap: 8px; align-items: center; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px;
  border-radius: 7px;
  border: 1px solid var(--line-2);
  background: var(--bg-2);
  color: var(--tx-1);
  font-size: 12.5px; font-weight: 500;
  transition: 120ms var(--ease);
}
.btn:hover { background: var(--bg-3); border-color: var(--line-3); }
.btn.primary {
  background: var(--accent-500);
  border-color: color-mix(in oklab, var(--accent-300) 40%, transparent);
  color: white;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12), 0 1px 0 rgba(0,0,0,0.2);
}
.btn.primary:hover { background: var(--accent-400); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--tx-2); }
.btn.ghost:hover { color: var(--tx-1); background: var(--bg-3); }
.btn.danger { color: #fca5a5; }
.btn.sm { height: 24px; padding: 0 8px; font-size: 11.5px; border-radius: 5px; }

/* cards */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius);
  padding: var(--card-pad);
  position: relative;
}
.card-h {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.card-t {
  font-size: 12px; color: var(--tx-2);
  text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500;
}
.card-actions { display: flex; gap: 4px; align-items: center; }

/* KPI */
.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: var(--gutter);
  margin-bottom: var(--gutter);
}
.kpi {
  background: var(--bg-1);
  border: 1px solid var(--line-1);
  border-radius: var(--radius);
  padding: 14px 16px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--tx-2);
  letter-spacing: 0.02em;
  margin-bottom: 6px;
}
.kpi-val {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: baseline; gap: 4px;
}
.kpi-val .unit { font-size: 12px; color: var(--tx-3); font-weight: 500; letter-spacing: 0; }
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 500;
  padding: 1px 6px; border-radius: 4px;
  margin-top: 6px;
}
.kpi-delta.up   { color: #6ee7b7; background: color-mix(in oklab, var(--ok) 12%, transparent); }
.kpi-delta.down { color: #fca5a5; background: color-mix(in oklab, var(--bad) 12%, transparent); }
.kpi-spark { position: absolute; right: 10px; bottom: 8px; opacity: 0.65; }
.kpi-tag { position: absolute; top: 12px; right: 12px; font-size: 10.5px; color: var(--tx-3); }

/* badges & chips */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500;
  padding: 2px 7px; border-radius: 99px;
  background: var(--bg-3); color: var(--tx-2);
  border: 1px solid var(--line-1);
}
.chip .d { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip.ok   { color: #6ee7b7; background: color-mix(in oklab, var(--ok) 12%, transparent); border-color: color-mix(in oklab, var(--ok) 24%, transparent); }
.chip.warn { color: #fbbf24; background: color-mix(in oklab, var(--warn) 12%, transparent); border-color: color-mix(in oklab, var(--warn) 24%, transparent); }
.chip.bad  { color: #fca5a5; background: color-mix(in oklab, var(--bad) 12%, transparent); border-color: color-mix(in oklab, var(--bad) 24%, transparent); }
.chip.info { color: #7dd3fc; background: color-mix(in oklab, var(--info) 12%, transparent); border-color: color-mix(in oklab, var(--info) 24%, transparent); }
.chip.cyan { color: #67e8f9; background: color-mix(in oklab, var(--cyan) 12%, transparent); border-color: color-mix(in oklab, var(--cyan) 24%, transparent); }
.chip.violet { color: #c4b5fd; background: color-mix(in oklab, var(--violet) 12%, transparent); border-color: color-mix(in oklab, var(--violet) 24%, transparent); }

/* tables */
.table {
  width: 100%; border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
.table th {
  text-align: left; font-weight: 500; color: var(--tx-3);
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-1);
  white-space: nowrap;
}
.table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line-1);
  color: var(--tx-1);
}
.table tr:hover td { background: var(--bg-2); }
.table tr.selected td { background: color-mix(in oklab, var(--accent-500) 10%, transparent); }

/* dot legend */
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
.legend-i {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--tx-2);
}
.legend-i .sw {
  width: 10px; height: 10px; border-radius: 3px;
  border: 1px solid var(--line-2);
}

/* unit cell colors */
.u-vacant   { background: var(--bg-3); border-color: var(--line-2); color: var(--tx-3); }
.u-occupied { background: color-mix(in oklab, #4d7cdb 22%, var(--bg-2)); border-color: color-mix(in oklab, #4d7cdb 38%, transparent); color: #cbd5ef; }
.u-reserved { background: color-mix(in oklab, var(--warn) 16%, var(--bg-2)); border-color: color-mix(in oklab, var(--warn) 40%, transparent); color: #fcd34d; }
.u-delinq   { background: color-mix(in oklab, var(--bad) 18%, var(--bg-2)); border-color: color-mix(in oklab, var(--bad) 50%, transparent); color: #fca5a5; }
.u-locked   { background: color-mix(in oklab, var(--cyan) 16%, var(--bg-2)); border-color: color-mix(in oklab, var(--cyan) 44%, transparent); color: #67e8f9; }
.u-alarm    { background: color-mix(in oklab, var(--bad) 30%, var(--bg-2)); border-color: var(--bad); color: #fff; }
.u-open     { background: color-mix(in oklab, var(--accent-500) 20%, var(--bg-2)); border-color: var(--accent-400); color: var(--accent-200); }

/* tooltip */
.tip {
  position: fixed;
  background: var(--bg-3);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
  pointer-events: none;
  z-index: 100;
  min-width: 180px;
  box-shadow: 0 12px 32px -8px rgba(0,0,0,0.5);
}

/* progress / sparkbars */
.bar {
  height: 4px; background: var(--bg-3); border-radius: 99px; overflow: hidden;
}
.bar > span { display:block; height:100%; background: var(--accent-500); border-radius: 99px; }

/* Skeleton shimmer */
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}

/* slide-in panel */
.panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: 380px;
  background: var(--bg-1);
  border-left: 1px solid var(--line-1);
  display: flex; flex-direction: column;
  z-index: 20;
  box-shadow: -20px 0 40px -16px rgba(0,0,0,0.5);
  animation: slideIn 240ms var(--ease);
}
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* alert pulse */
@keyframes redpulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--bad) 50%, transparent); }
  50%      { box-shadow: 0 0 0 6px color-mix(in oklab, var(--bad) 0%, transparent); }
}
.alarm-pulse { animation: redpulse 1.6s infinite; }

@keyframes glow {
  0%, 100% { filter: brightness(1.0); }
  50%      { filter: brightness(1.35); }
}
.door-open-glow { animation: glow 2s infinite; }
