/* =====================================================================
   SBM — Smart Building Management · Admin design system
   Tokens → base → layout → components → utilities
   ===================================================================== */

:root {
  --brand-50:  #eef4ff;
  --brand-100: #dbe7ff;
  --brand-200: #bed3ff;
  --brand-400: #5b8cff;
  --brand-500: #2f6bff;
  --brand-600: #1f56f0;
  --brand-700: #1a45c7;
  --brand-900: #0f2566;

  --bg:          #f4f6fb;
  --surface:     #ffffff;
  --surface-2:   #f8fafd;
  --surface-3:   #eef2f8;
  --border:      #e4e9f2;
  --border-strong:#d3dbe8;
  --text:        #0f172a;
  --text-2:      #475569;
  --text-3:      #8592a8;

  --success: #12a150; --success-bg: #e8f8ef;
  --warning: #d97706; --warning-bg: #fff5e5;
  --danger:  #e5383b; --danger-bg:  #fdecec;
  --info:    #0891b2; --info-bg:    #e6f7fb;
  --purple:  #7c3aed; --purple-bg:  #f2ecff;

  --sidebar-bg:    #0b1324;
  --sidebar-bg-2:  #111c33;
  --sidebar-text:  #9aa8c2;
  --sidebar-hover: rgba(255,255,255,.06);
  --sidebar-active:#ffffff;

  --radius-sm: 8px;
  --radius:    12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 6px 24px -6px rgba(15,23,42,.10), 0 2px 6px rgba(15,23,42,.04);
  --shadow-lg: 0 24px 60px -12px rgba(15,23,42,.25);

  --sidebar-w: 264px;
  --topbar-h:  64px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Plus Jakarta Sans', 'Inter', system-ui, sans-serif;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg:          #0a0f1c;
  --surface:     #111827;
  --surface-2:   #0f1624;
  --surface-3:   #1a2336;
  --border:      #1f2a40;
  --border-strong:#2b3852;
  --text:        #e7ecf5;
  --text-2:      #a3b0c7;
  --text-3:      #6b7a96;
  --brand-50:    #13213f;
  --brand-100:   #172a52;
  --success-bg: rgba(18,161,80,.14);
  --warning-bg: rgba(217,119,6,.15);
  --danger-bg:  rgba(229,56,59,.15);
  --info-bg:    rgba(8,145,178,.15);
  --purple-bg:  rgba(124,58,237,.16);
  --sidebar-bg:  #070b15;
  --sidebar-bg-2:#0c1220;
  --shadow:    0 6px 24px -6px rgba(0,0,0,.5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-700); }
h1,h2,h3,h4,h5 { font-family: var(--font-display); margin: 0; color: var(--text); letter-spacing: -.01em; }
p { margin: 0; }
hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.ic { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }
svg.lucide { width: 18px; height: 18px; stroke-width: 1.9; flex-shrink: 0; }

/* ------------------------------------------------------------------ layout */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: var(--sidebar-text);
  position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px; height: var(--topbar-h);
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; color: #fff;
  box-shadow: 0 8px 20px -6px rgba(59,130,246,.7);
}
.brand-mark svg { width: 22px; height: 22px; }
.brand-text strong { display: block; color: #fff; font-family: var(--font-display); font-size: 17px; letter-spacing: -.02em; }
.brand-text span { font-size: 11px; color: #6c7c99; letter-spacing: .02em; }

.sidebar-society {
  margin: 14px 14px 6px; padding: 10px 12px;
  border-radius: var(--radius);
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.06);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-society .s-ic { width: 32px; height: 32px; border-radius: 9px; background: rgba(59,130,246,.15); color: #7aa7ff; display: grid; place-items: center; }
.sidebar-society strong { color: #e6ecf7; font-size: 13px; display: block; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }
.sidebar-society span { font-size: 11px; color: #6c7c99; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 10px 20px; scrollbar-width: thin; scrollbar-color: #24304a transparent; }
.nav-section { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .09em; color: #4f5d78; padding: 16px 12px 6px; }
.nav-link {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px; margin: 1px 0;
  border-radius: 9px;
  color: var(--sidebar-text); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s;
  position: relative;
}
.nav-link:hover { background: var(--sidebar-hover); color: #dfe6f3; }
.nav-link.active { background: linear-gradient(90deg, rgba(47,107,255,.95), rgba(47,107,255,.75)); color: #fff; box-shadow: 0 8px 18px -8px rgba(47,107,255,.8); }
.nav-link .nav-count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 20px; background: rgba(255,255,255,.1); color: #dbe4f3; }
.nav-link .nav-count.alert { background: #e5383b; color: #fff; }
.sidebar-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.06); }
.sidebar-foot .plan { font-size: 12px; padding: 12px; border-radius: var(--radius); background: linear-gradient(135deg, rgba(59,130,246,.18), rgba(124,58,237,.18)); color: #c9d5ec; }
.sidebar-foot .plan strong { color: #fff; display: block; font-size: 13px; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  position: sticky; top: 0; z-index: 30;
}
.topbar .menu-toggle { display: none; }
.search-box {
  flex: 1; max-width: 460px;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; padding: 0 12px; height: 40px; color: var(--text-3);
}
.search-box input { border: 0; background: transparent; outline: none; flex: 1; font: inherit; color: var(--text); }
.search-box kbd { font-family: var(--font); font-size: 11px; border: 1px solid var(--border-strong); border-radius: 6px; padding: 1px 6px; color: var(--text-3); background: var(--surface); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2);
  cursor: pointer; position: relative; transition: all .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); border-color: var(--border-strong); }
.icon-btn .pip { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px var(--surface); }
.sos-pill { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 10px; background: var(--danger); color: #fff; font-weight: 600; font-size: 12.5px; animation: pulse 1.6s infinite; }
.sos-pill:hover { color: #fff; }
@keyframes pulse { 0%{box-shadow:0 0 0 0 rgba(229,56,59,.55)} 70%{box-shadow:0 0 0 12px rgba(229,56,59,0)} 100%{box-shadow:0 0 0 0 rgba(229,56,59,0)} }

.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 6px 4px 4px; border-radius: 12px; cursor: pointer; border: 1px solid transparent; position: relative; }
.user-chip:hover { background: var(--surface-2); border-color: var(--border); }
.user-chip .meta strong { display: block; font-size: 13px; line-height: 1.2; }
.user-chip .meta span { font-size: 11.5px; color: var(--text-3); text-transform: capitalize; }

.dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 60; }
.dropdown.open { display: block; }
.dropdown a, .dropdown button { display: flex; width: 100%; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; color: var(--text-2); font: inherit; border: 0; background: none; cursor: pointer; text-align: left; }
.dropdown a:hover, .dropdown button:hover { background: var(--surface-2); color: var(--text); }
.dropdown .sep { height: 1px; background: var(--border); margin: 6px 0; }

.content { padding: 26px 28px 40px; flex: 1; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { font-size: 24px; font-weight: 700; }
.page-head .sub { color: var(--text-3); margin-top: 4px; font-size: 13.5px; }
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.crumbs a { color: var(--text-3); }
.crumbs a:hover { color: var(--brand-600); }
.crumbs .sep { opacity: .5; }
.page-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.footer { padding: 16px 28px; color: var(--text-3); font-size: 12px; display: flex; justify-content: space-between; border-top: 1px solid var(--border); }

/* --------------------------------------------------------------- grid */
.grid { display: grid; gap: 18px; }
.g-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.g-5 { grid-template-columns: repeat(5, minmax(0,1fr)); }
.g-2-1 { grid-template-columns: minmax(0,2fr) minmax(0,1fr); }
.g-1-2 { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }
.g-3-2 { grid-template-columns: minmax(0,3fr) minmax(0,2fr); }
.span-2 { grid-column: span 2; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }

/* -------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-head .hint { font-size: 12.5px; color: var(--text-3); font-weight: 400; }
.card-body { padding: 20px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* KPI tile */
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi .kpi-top { display: flex; align-items: center; justify-content: space-between; }
.kpi .kpi-label { color: var(--text-2); font-size: 13px; font-weight: 500; }
.kpi .kpi-ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; }
.kpi .kpi-value { font-family: var(--font-display); font-size: 26px; font-weight: 700; margin-top: 10px; letter-spacing: -.02em; }
.kpi .kpi-foot { margin-top: 6px; font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.trend-up { color: var(--success); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }
.tone-blue   { background: var(--brand-50);   color: var(--brand-600); }
.tone-green  { background: var(--success-bg); color: var(--success); }
.tone-amber  { background: var(--warning-bg); color: var(--warning); }
.tone-red    { background: var(--danger-bg);  color: var(--danger); }
.tone-cyan   { background: var(--info-bg);    color: var(--info); }
.tone-purple { background: var(--purple-bg);  color: var(--purple); }

/* hero banner */
.hero {
  border-radius: var(--radius-xl); padding: 26px 28px; color: #fff; position: relative; overflow: hidden;
  background: radial-gradient(120% 140% at 100% 0%, #4f8bff 0%, #1f56f0 45%, #12307f 100%);
  box-shadow: 0 20px 40px -18px rgba(31,86,240,.6);
}
.hero::after { content: ""; position: absolute; right: -60px; top: -60px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.08); }
.hero::before { content: ""; position: absolute; right: 120px; bottom: -90px; width: 200px; height: 200px; border-radius: 50%; background: rgba(255,255,255,.06); }
.hero h2 { color: #fff; font-size: 22px; }
.hero p { color: rgba(255,255,255,.8); margin-top: 6px; }
.hero .hero-stats { display: flex; gap: 32px; margin-top: 20px; position: relative; z-index: 1; flex-wrap: wrap; }
.hero .hero-stats div strong { display: block; font-size: 22px; font-family: var(--font-display); }
.hero .hero-stats div span { font-size: 12px; color: rgba(255,255,255,.75); }

/* ------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 16px; border-radius: 10px;
  font: 600 13.5px var(--font); cursor: pointer; white-space: nowrap;
  border: 1px solid transparent; transition: all .15s; text-decoration: none;
}
.btn .ic, .btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--brand-600); color: #fff; box-shadow: 0 6px 14px -6px rgba(31,86,240,.7); }
.btn-primary:hover { background: var(--brand-700); color: #fff; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-2); color: var(--text); }
.btn-ghost { background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(.95); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.95); color: #fff; }
.btn-soft { background: var(--brand-50); color: var(--brand-700); }
.btn-soft:hover { background: var(--brand-100); color: var(--brand-700); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 34px; height: 34px; padding: 0; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* --------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px 18px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .help { font-size: 12px; color: var(--text-3); }
.req::after { content: " *"; color: var(--danger); }
.input, .select, .textarea, input[type=text].input, input[type=number].input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); color: var(--text);
  font: 14px var(--font); outline: none; transition: border .15s, box-shadow .15s;
}
.textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; }
.select { 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='%238592a8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-500); box-shadow: 0 0 0 4px rgba(47,107,255,.14); }
.input-group { display: flex; align-items: stretch; }
.input-group .addon { display: grid; place-items: center; padding: 0 12px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text-3); font-weight: 600; }
.input-group .addon:first-child { border-radius: 10px 0 0 10px; border-right: 0; }
.input-group .addon:last-child { border-radius: 0 10px 10px 0; border-left: 0; }
.input-group .input:not(:first-child) { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.input-group .input:not(:last-child) { border-top-right-radius: 0; border-bottom-right-radius: 0; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 500; color: var(--text-2); }
.switch input { display: none; }
.switch .track { width: 38px; height: 22px; border-radius: 22px; background: var(--border-strong); position: relative; transition: background .2s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch input:checked + .track { background: var(--brand-600); }
.switch input:checked + .track::after { transform: translateX(16px); }

.choice-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px,1fr)); gap: 12px; }
.choice { position: relative; border: 1.5px solid var(--border-strong); border-radius: var(--radius); padding: 14px; cursor: pointer; transition: all .15s; background: var(--surface); }
.choice input { position: absolute; opacity: 0; }
.choice strong { display: block; font-size: 14px; }
.choice span { font-size: 12.5px; color: var(--text-3); }
.choice:hover { border-color: var(--brand-400); }
.choice:has(input:checked) { border-color: var(--brand-600); background: var(--brand-50); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }

/* -------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; }
.table th {
  text-align: left; font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-3); padding: 11px 16px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 13px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .muted { color: var(--text-3); font-size: 12.5px; }
.table .actions { text-align: right; white-space: nowrap; }
.cell-user { display: flex; align-items: center; gap: 10px; }
.cell-user strong { display: block; font-weight: 600; line-height: 1.25; }
.cell-user span { font-size: 12px; color: var(--text-3); }

.toolbar { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.toolbar .input, .toolbar .select { height: 36px; width: auto; min-width: 150px; }
.toolbar .grow { flex: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 16px; overflow-x: auto; }
.tabs a { padding: 12px 14px; color: var(--text-3); font-weight: 600; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; display: flex; align-items: center; gap: 8px; }
.tabs a:hover { color: var(--text); }
.tabs a.active { color: var(--brand-600); border-color: var(--brand-600); }
.tabs .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); padding: 1px 7px; border-radius: 20px; }
.segmented { display: inline-flex; background: var(--surface-3); border-radius: 10px; padding: 3px; gap: 2px; }
.segmented a, .segmented button { padding: 6px 12px; border-radius: 8px; color: var(--text-2); font: 600 12.5px var(--font); border: 0; background: none; cursor: pointer; }
.segmented .active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* -------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 30px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-primary { background: var(--brand-50);   color: var(--brand-600); }
.badge-purple  { background: var(--purple-bg);  color: var(--purple); }
.badge-neutral { background: var(--surface-3);  color: var(--text-2); }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 600; background: var(--surface-3); color: var(--text-2); }

.avatar { width: 36px; height: 36px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; color: #fff; background: var(--av, var(--brand-600)); flex-shrink: 0; }
.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-lg { width: 52px; height: 52px; font-size: 18px; }
.avatar-xl { width: 72px; height: 72px; font-size: 24px; }

/* --------------------------------------------------------------- alerts */
.alert { display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px; border-radius: var(--radius); margin-bottom: 18px; font-weight: 500; border: 1px solid transparent; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.alert-error, .alert-danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 25%, transparent); }
.alert-info { background: var(--brand-50); color: var(--brand-700); border-color: var(--brand-100); }

.empty-state { text-align: center; padding: 48px 20px; color: var(--text-3); }
.empty-state .ic, .empty-state svg { width: 44px; height: 44px; stroke-width: 1.4; color: var(--border-strong); margin-bottom: 10px; }
.empty-state h4 { color: var(--text); font-size: 15px; margin-bottom: 4px; }
.empty-state p { margin-bottom: 14px; }

/* ------------------------------------------------------------ list rows */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 20px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .li-ic { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0; }
.list-item .li-main { flex: 1; min-width: 0; }
.list-item .li-main strong { display: block; font-weight: 600; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .li-main span { font-size: 12.5px; color: var(--text-3); }
.list-item .li-side { text-align: right; font-size: 12.5px; color: var(--text-3); white-space: nowrap; }

.progress { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 8px; background: var(--brand-600); }

.stat-line { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.stat-line:last-child { border-bottom: 0; }
.stat-line span { color: var(--text-2); }
.stat-line strong { font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------- modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(8,12,24,.55); backdrop-filter: blur(3px); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 6vh 16px; overflow-y: auto; }
.modal-backdrop.open { display: flex; animation: fade .15s ease; }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); animation: rise .2s ease; }
.modal.lg { max-width: 820px; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes rise { from { transform: translateY(12px); opacity: 0 } to { transform: none; opacity: 1 } }

/* toast */
.toast-stack { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 200; }
.toast { min-width: 280px; max-width: 380px; display: flex; gap: 10px; align-items: flex-start; padding: 13px 16px; border-radius: 12px; background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); animation: rise .2s ease; font-weight: 500; }
.toast.success .ic { color: #4ade80; }
.toast.error .ic { color: #f87171; }

/* -------------------------------------------- property map (buildings) */
.building-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 18px; }
.building-card { border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--border); overflow: hidden; transition: transform .15s, box-shadow .15s; display: flex; flex-direction: column; }
.building-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.building-card .bc-top { padding: 18px; color: #fff; position: relative; background: linear-gradient(135deg, var(--bc, #2f6bff), color-mix(in srgb, var(--bc, #2f6bff) 60%, #0b1324)); }
.building-card .bc-top h3 { color: #fff; font-size: 18px; }
.building-card .bc-top span { font-size: 12.5px; opacity: .85; }
.building-card .bc-top .bc-code { position: absolute; right: 16px; top: 14px; font-family: var(--font-display); font-size: 40px; font-weight: 800; opacity: .25; }
.building-card .bc-body { padding: 16px 18px; flex: 1; }
.occ-bar { display: flex; height: 8px; border-radius: 8px; overflow: hidden; background: var(--surface-3); margin: 10px 0 8px; }
.occ-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

.tower { display: flex; flex-direction: column; gap: 8px; }
.floor-row { display: flex; align-items: stretch; gap: 10px; }
.floor-label { width: 92px; flex-shrink: 0; display: flex; flex-direction: column; justify-content: center; padding: 6px 10px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); }
.floor-label strong { font-size: 13px; }
.floor-label span { font-size: 11px; color: var(--text-3); }
.floor-units { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.unit-tile {
  width: 118px; padding: 10px 11px; border-radius: 11px; cursor: pointer; position: relative;
  background: var(--surface); border: 1.5px solid var(--border); transition: all .15s; text-align: left;
  font: inherit; color: inherit;
}
.unit-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand-400); }
.unit-tile strong { display: block; font-size: 13.5px; font-family: var(--font-display); }
.unit-tile span { display: block; font-size: 11px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unit-tile .ut-due { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); }
.unit-tile.occ-owner_occupied { border-left: 4px solid var(--success); }
.unit-tile.occ-rented { border-left: 4px solid var(--brand-500); }
.unit-tile.occ-vacant { border-left: 4px solid var(--warning); background: var(--surface-2); }
.unit-tile.occ-under_maintenance { border-left: 4px solid var(--purple); }
.unit-tile.occ-blocked { border-left: 4px solid var(--text-3); opacity: .7; }
.add-tile { width: 118px; border: 1.5px dashed var(--border-strong); border-radius: 11px; display: grid; place-items: center; color: var(--text-3); cursor: pointer; background: transparent; min-height: 58px; }
.add-tile:hover { color: var(--brand-600); border-color: var(--brand-500); background: var(--brand-50); }

/* drawer */
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 100%; background: var(--surface); box-shadow: var(--shadow-lg); z-index: 110; transform: translateX(100%); transition: transform .25s ease; display: flex; flex-direction: column; }
.drawer.open { transform: none; }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.drawer-body { flex: 1; overflow-y: auto; padding: 22px; }
.drawer-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; gap: 10px; }

/* wizard steps */
.steps { display: flex; gap: 0; margin-bottom: 22px; }
.step { flex: 1; display: flex; align-items: center; gap: 10px; color: var(--text-3); font-weight: 600; font-size: 13px; }
.step .n { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 2px solid var(--border-strong); background: var(--surface); }
.step.done .n { background: var(--success); border-color: var(--success); color: #fff; }
.step.active { color: var(--text); }
.step.active .n { border-color: var(--brand-600); color: var(--brand-600); box-shadow: 0 0 0 4px rgba(47,107,255,.14); }
.step:not(:last-child)::after { content: ""; flex: 1; height: 2px; background: var(--border); margin: 0 10px; }

/* invoice / print */
.invoice-sheet { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 36px; max-width: 860px; margin: 0 auto; }
.invoice-sheet .inv-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 22px; border-bottom: 2px solid var(--text); }
.invoice-sheet .inv-total { background: var(--surface-2); border-radius: var(--radius); padding: 16px 18px; }

/* gateway cards */
.gw-card { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px; background: var(--surface); display: flex; flex-direction: column; gap: 12px; position: relative; transition: box-shadow .15s; }
.gw-card:hover { box-shadow: var(--shadow); }
.gw-card .gw-logo { width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; color: #fff; background: var(--gw, #2f6bff); }
.gw-card.default { border-color: var(--brand-500); box-shadow: 0 0 0 3px rgba(47,107,255,.12); }
.gw-card .ribbon { position: absolute; top: 14px; right: 14px; }

/* misc utilities */
.muted { color: var(--text-3); }
.text-2 { color: var(--text-2); }
.small { font-size: 12.5px; }
.xs { font-size: 11.5px; }
.bold { font-weight: 700; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
.right { text-align: right; }
.center { text-align: center; }
.mt-0 { margin-top: 0 } .mt-1 { margin-top: 6px } .mt-2 { margin-top: 12px } .mt-3 { margin-top: 18px } .mt-4 { margin-top: 26px }
.mb-0 { margin-bottom: 0 } .mb-1 { margin-bottom: 6px } .mb-2 { margin-bottom: 12px } .mb-3 { margin-bottom: 18px } .mb-4 { margin-bottom: 26px }
.ml-auto { margin-left: auto; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); } .text-brand { color: var(--brand-600); }
.fw-600 { font-weight: 600; }
.nowrap { white-space: nowrap; }
.chart-box { position: relative; height: 280px; }
.chart-box.sm { height: 200px; }
.donut-center { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; pointer-events: none; }
.donut-center strong { display: block; font-size: 20px; font-family: var(--font-display); }
.donut-center span { font-size: 12px; color: var(--text-3); }
.pagination { display: flex; gap: 6px; align-items: center; justify-content: flex-end; padding: 12px 16px; border-top: 1px solid var(--border); }
.pagination a, .pagination strong { min-width: 32px; height: 32px; padding: 0 8px; border-radius: 8px; display: inline-grid; place-items: center; border: 1px solid var(--border); color: var(--text-2); font-weight: 600; font-size: 12.5px; }
.pagination strong { background: var(--brand-600); color: #fff; border-color: var(--brand-600); }

/* ---------------------------------------------------------- auth pages */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--surface); }
.auth-art { position: relative; overflow: hidden; color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(90% 80% at 80% 10%, #3b82f6 0%, transparent 60%), radial-gradient(80% 80% at 10% 90%, #7c3aed 0%, transparent 55%), #0b1324; }
.auth-art h1 { color: #fff; font-size: 40px; line-height: 1.12; letter-spacing: -.03em; max-width: 520px; }
.auth-art p { color: rgba(255,255,255,.72); max-width: 460px; margin-top: 14px; font-size: 15px; }
.auth-feature { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08); backdrop-filter: blur(6px); }
.auth-feature .fi { width: 38px; height: 38px; border-radius: 10px; background: rgba(255,255,255,.1); display: grid; place-items: center; }
.auth-form { display: grid; place-items: center; padding: 40px; }
.auth-form .box { width: 100%; max-width: 400px; }
.role-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.role-chips span { padding: 6px 12px; border-radius: 30px; font-size: 12px; font-weight: 600; background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12); }

/* ------------------------------------------------------------ responsive */
@media (max-width: 1280px) {
  .g-5 { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .g-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 35; }
  .main { margin-left: 0; }
  .topbar .menu-toggle { display: grid; }
  .g-3, .g-2-1, .g-1-2, .g-3-2 { grid-template-columns: minmax(0,1fr); }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { display: none; }
}
@media (max-width: 720px) {
  .content { padding: 18px 16px 30px; }
  .topbar { padding: 0 16px; }
  .g-2, .g-4, .g-5, .form-grid, .form-grid.cols-3 { grid-template-columns: minmax(0,1fr); }
  .span-2 { grid-column: auto; }
  .user-chip .meta, .user-chip > .ic, .user-chip > svg, .search-box kbd { display: none; }
  .topbar { gap: 8px; }
  .search-box { min-width: 0; }
  .topbar-actions { gap: 6px; }
  .page-actions .btn { flex: 1; }
  .floor-label { width: 70px; }
  .unit-tile, .add-tile { width: calc(50% - 4px); }
  .invoice-sheet { padding: 20px; }
}

@media print {
  .sidebar, .topbar, .footer, .page-actions, .no-print { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; }
  body { background: #fff; }
  .invoice-sheet { border: 0; }
}

/* brand: INOCRYPT HSM */
.brand-text strong { letter-spacing: -.01em; }
.brand-text strong em { font-style: normal; color: #7aa7ff; }
