/* HOA HQ — Midnight Slate Theme */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
.color-swatch { width: 24px; height: 24px; border-radius: 50%; cursor: pointer; border: 2px solid transparent; transition: transform 0.15s, border-color 0.15s; }
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border-color: #fff; }

/* ── DARK MODE (default) ── */
:root {
  --navy:       #0f1923;
  --navy-mid:   #151f2e;
  --navy-light: #1a2740;
  --sky:        #38bdf8;
  --sky-light:  rgba(56,189,248,0.12);
  --cream:      #f0f4f8;
  --white:      #ffffff;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --ink:        #0f172a;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #f43f5e;
  --success-bg: #d1fae5;
  --warning-bg: #fef3c7;
  --danger-bg:  #ffe4e6;
  --page-bg:    #f0f4f8;
  --card-bg:    #ffffff;
  --sidebar-bg: #151f2e;
  --topnav-bg:  #0f1923;
  --row-hover:  #f8fafc;
  --input-bg:   #ffffff;
  --nav-text:          rgba(255,255,255,0.45);
  --nav-text-hover:    rgba(255,255,255,0.85);
  --nav-text-active:   #38bdf8;
  --nav-active-bg:     rgba(56,189,248,0.12);
  --nav-active-border: #38bdf8;
  --nav-group-color:   rgba(255,255,255,0.25);
  --nav-divider-color: rgba(255,255,255,0.06);
  --nav-border:        1px solid rgba(255,255,255,0.06);
  --nav-hover-bg:      rgba(255,255,255,0.06);
}

/* ── DARK MODE (when explicitly set) ── */
[data-theme="dark"] {
  --page-bg:           #0d1520;
  --card-bg:           #131e2e;
  --sidebar-bg:        #0f1923;
  --border:            rgba(255,255,255,0.08);
  --row-hover:         rgba(255,255,255,0.04);
  --input-bg:          #0d1520;
  --ink:               #e2e8f0;
  --cream:             #1a2535;
  --success-bg:        rgba(16,185,129,0.15);
  --warning-bg:        rgba(245,158,11,0.15);
  --danger-bg:         rgba(244,63,94,0.15);
  --nav-text:          rgba(255,255,255,0.7);
  --nav-text-hover:    rgba(255,255,255,0.95);
  --nav-group-color:   rgba(255,255,255,0.35);
}
[data-theme="dark"] .badge-green { background: rgba(16,185,129,0.15); color: #34d399; }
[data-theme="dark"] .badge-amber { background: rgba(245,158,11,0.15);  color: #fcd34d; }
[data-theme="dark"] .badge-red   { background: rgba(244,63,94,0.15);   color: #fb7185; }
[data-theme="dark"] .badge-blue  { background: rgba(56,189,248,0.12);  color: #7dd3fc; }
[data-theme="dark"] .badge-gray  { background: rgba(255,255,255,0.06); color: var(--muted); }

/* ── LIGHT MODE ── */
[data-theme="light"] {
  --navy:       #1e40af;
  --navy-mid:   #1d4ed8;
  --navy-light: #2563eb;
  --sky:        #2563eb;
  --sky-light:  #dbeafe;
  --cream:      #f1f5f9;
  --white:      #ffffff;
  --muted:      #64748b;
  --border:     #e2e8f0;
  --ink:        #0f172a;
  --success:    #10b981;
  --warning:    #f59e0b;
  --danger:     #ef4444;
  --success-bg: #d1fae5;
  --warning-bg: #fef3c7;
  --danger-bg:  #fee2e2;
  --page-bg:    #f1f5f9;
  --card-bg:    #ffffff;
  --sidebar-bg: #ffffff;
  --topnav-bg:  #1e3a8a;
  --row-hover:  #f8fafc;
  --input-bg:   #ffffff;
  --nav-text:          #475569;
  --nav-text-hover:    #0f172a;
  --nav-text-active:   #1d4ed8;
  --nav-active-bg:     #dbeafe;
  --nav-active-border: #1d4ed8;
  --nav-group-color:   #94a3b8;
  --nav-divider-color: #e2e8f0;
  --nav-border:        1px solid #e2e8f0;
  --nav-hover-bg:      #f1f5f9;
}

html { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { background: var(--page-bg); color: var(--ink); min-height: 100vh; transition: background 0.2s; }

/* NAV */
.topnav {
  background: var(--topnav-bg);
  padding: 0 2rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; position: sticky; top: 0; z-index: 50;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.topnav-logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-mark { width: 30px; height: 30px; border-radius: 6px; background: var(--sky); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; color: var(--navy); }
.logo-text { font-size: 1rem; font-weight: 700; color: #fff; }
.logo-text span { color: var(--sky); }
.topnav-right { display: flex; align-items: center; gap: 4px; position: relative; }

/* Icon buttons in topnav */
.nav-icon-btn {
  width: 34px; height: 34px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.65);
  cursor: pointer; transition: all 0.15s;
  position: relative; flex-shrink: 0;
}
.nav-icon-btn:hover { background: rgba(255,255,255,0.12); color: #fff; }
.nav-avatar {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.7);
  border-color: rgba(255,255,255,0.15);
  font-size: 12px; font-weight: 700;
}
.nav-avatar:hover { background: rgba(255,255,255,0.12); color: #fff; border-color: rgba(255,255,255,0.3); }
.nav-icon-badge {
  position: absolute; top: -4px; right: -4px;
  background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--topnav-bg);
}

/* Dropdown menus */
.nav-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 220px;
  background: #1a2535;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  overflow: hidden;
  z-index: 300;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.alerts-dropdown { width: 280px; }
.nav-dropdown-header { padding: 12px 14px; }
.nav-dropdown-name { font-size: 13px; font-weight: 600; color: #fff; }
.nav-dropdown-sub { font-size: 11px; color: rgba(255,255,255,0.4); margin-top: 2px; }
.nav-dropdown-divider { height: 1px; background: rgba(255,255,255,0.08); }
.nav-dropdown-item {
  width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; font-size: 13px; color: rgba(255,255,255,0.7);
  background: none; border: none; cursor: pointer; text-align: left;
  transition: background 0.12s;
}
.nav-dropdown-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-dropdown-item.danger { color: #fb7185; }
.nav-dropdown-item.danger:hover { background: rgba(244,63,94,0.1); }

/* SIDEBAR */
.app-layout { display: grid; grid-template-columns: 210px 1fr; min-height: calc(100vh - 56px); }
.sidebar {
  background: var(--sidebar-bg);
  border-right: var(--nav-border);
  padding: 0.5rem 0 1rem;
  overflow-y: auto;
  transition: background 0.2s;
}
.nav-group-label {
  padding: 10px 1.25rem 4px;
  font-size: 9.5px; font-weight: 700;
  color: var(--nav-group-color);
  letter-spacing: 0.1em; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 1.25rem; font-size: 13px;
  color: var(--nav-text);
  cursor: pointer; border-left: 2px solid transparent;
  transition: all 0.12s; text-decoration: none;
}
.nav-item:hover { background: var(--nav-hover-bg, rgba(0,0,0,0.04)); color: var(--nav-text-hover); }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-text-active); border-left-color: var(--nav-active-border); font-weight: 500; }
.nav-item svg { opacity: 0.7; flex-shrink: 0; }
.nav-item.active svg { opacity: 1; }
.main-content { padding: 1.75rem 2rem; overflow-y: auto; background: var(--page-bg); transition: background 0.2s; }

/* PAGE HEADER */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }
.page-title { font-size: 1.2rem; font-weight: 700; color: var(--ink); }
.page-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* METRIC CARDS — Midnight colored */
.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 1.5rem; }
.metric-card {
  border-radius: 12px;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  background: var(--card-bg);
  transition: transform 0.15s, box-shadow 0.15s;
}
.metric-card[onclick] { cursor: pointer; }
.metric-card[onclick]:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.08); }
.metric-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px;
}
.metric-icon svg { width: 18px; height: 18px; }
.metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.metric-value { font-size: 1.7rem; font-weight: 700; color: var(--ink); line-height: 1; }
.metric-sub { font-size: 11px; margin-top: 5px; color: var(--muted); }
.metric-sub.up { color: var(--success); }
.metric-sub.warn { color: var(--warning); }
.metric-sub.danger { color: var(--danger); }

/* Colored metric card variants */
.metric-card.sky   { background: linear-gradient(135deg,#0c4a6e,#0369a1); border-color: #0369a1; }
.metric-card.sky .metric-value,.metric-card.sky .metric-label,.metric-card.sky .metric-sub { color: #e0f2fe; }
.metric-card.sky .metric-icon { background: rgba(255,255,255,0.15); }

/* CARDS */
.card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 1rem; }
.card-head {
  padding: 0.8rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: var(--card-bg);
}
.card-title { font-size: 13px; font-weight: 600; color: var(--ink); }
.card-body { padding: 0; }

/* DATA ROWS */
.data-row { display: flex; align-items: center; padding: 0.7rem 1.25rem; border-bottom: 1px solid var(--border); gap: 12px; font-size: 13px; }
.data-row:last-child { border-bottom: none; }
.data-row:hover { background: var(--row-hover); }
.row-primary { font-weight: 500; color: var(--ink); flex: 1; }
.row-secondary { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* BADGES */
.badge { display: inline-block; font-size: 10px; font-weight: 600; padding: 2px 8px; border-radius: 20px; white-space: nowrap; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-amber { background: #fef3c7; color: #92400e; }
.badge-red   { background: #ffe4e6; color: #9f1239; }
.badge-blue  { background: rgba(56,189,248,0.12); color: #0369a1; }
.badge-gray  { background: #f1f5f9; color: var(--muted); }

/* BUTTONS */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 0.5rem 1rem; border-radius: 7px; font-size: 13px; font-weight: 500; cursor: pointer; border: none; transition: all 0.15s; text-decoration: none; }
.btn-primary { background: var(--sky); color: var(--navy); font-weight: 600; }
.btn-primary:hover { background: #7dd3fc; }
.btn-secondary { background: var(--card-bg); color: var(--ink); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--row-hover); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* FORMS */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.form-input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--ink); background: var(--input-bg); outline: none; transition: border-color 0.15s; }
.form-input:focus { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }
.form-select { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--ink); background: var(--input-bg); }
.form-textarea { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 13px; color: var(--ink); background: var(--input-bg); min-height: 80px; resize: vertical; }
.form-input:focus,.form-textarea:focus,.form-select:focus { outline: none; border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56,189,248,0.15); }

/* MODAL */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 200; align-items: center; justify-content: center; backdrop-filter: blur(2px); }
.modal-overlay.open { display: flex; }
.modal { background: var(--card-bg); border-radius: 14px; padding: 1.5rem; width: 100%; max-width: 480px; margin: 1rem; border: 1px solid var(--border); }
.modal-title { font-size: 15px; font-weight: 700; margin-bottom: 1.25rem; color: var(--ink); }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 1.25rem; }

/* VOTE BAR */
.vote-bar-wrap { margin-bottom: 8px; }
.vote-bar-label { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.vote-bar { height: 6px; border-radius: 3px; background: var(--page-bg); overflow: hidden; }
.vote-bar-fill { height: 100%; border-radius: 3px; background: var(--sky); }

/* AI BOX */
.ai-box { background: rgba(56,189,248,0.06); border: 1px solid rgba(56,189,248,0.2); border-radius: 10px; padding: 1.25rem; margin-bottom: 1rem; }
.ai-box-label { font-size: 11px; font-weight: 700; color: #0369a1; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 8px; }
.ai-result { font-size: 13px; color: var(--ink); line-height: 1.75; white-space: pre-wrap; }

/* EMPTY STATE */
.empty-state { text-align: center; padding: 3rem 1rem; color: var(--muted); font-size: 14px; }

/* SPINNER */
.spinner { display: inline-block; width: 16px; height: 16px; border: 2px solid rgba(56,189,248,0.3); border-top-color: var(--sky); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* SCREENS */
.screen { display: none; }
.screen.active { display: block; }

/* TWO COL */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* NAV GROUP (dashboard.html uses these) */
.nav-group { padding: 10px 1.25rem 3px; font-size: 9.5px; font-weight: 700; color: var(--nav-group-color); letter-spacing: 0.1em; text-transform: uppercase; margin-top: 4px; }
.nav-divider { height: 1px; background: var(--nav-divider-color); margin: 6px 1rem; }

/* Budget chart */
.budget-chart-wrap { padding: 1rem 1.25rem; height: 280px; position: relative; }
.tx-dot-in  { width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0; margin-top: 2px; }
.tx-dot-out { width: 8px; height: 8px; border-radius: 50%; background: var(--danger);  flex-shrink: 0; margin-top: 2px; }

/* Module toggles */
.module-toggle { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.module-toggle:last-child { border-bottom: none; }
.module-toggle-label { font-size: 13px; font-weight: 500; color: var(--ink); }
.module-toggle-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.toggle { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
.toggle-track { position: absolute; inset: 0; background: var(--border); border-radius: 10px; transition: background 0.2s; cursor: pointer; }
.toggle input:checked + .toggle-track { background: var(--sky); }
.toggle-thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform 0.2s; pointer-events: none; }
.toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }

/* Parking */
.parking-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(90px,1fr)); gap: 8px; padding: 1rem; }
.parking-spot { border: 1px solid var(--border); border-radius: 8px; padding: 8px; text-align: center; font-size: 11px; background: var(--card-bg); }
.parking-spot.occupied { background: rgba(56,189,248,0.08); border-color: rgba(56,189,248,0.3); }
.parking-spot.guest    { background: rgba(16,185,129,0.08); border-color: rgba(16,185,129,0.3); }
.parking-spot.handicap { background: rgba(245,158,11,0.08); border-color: rgba(245,158,11,0.3); }
.parking-spot-num  { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.parking-spot-type { font-size: 10px; color: var(--muted); }
.parking-spot-unit { font-size: 10px; color: var(--sky); font-weight: 500; margin-top: 2px; }

/* Committee / board styles */
.committee-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 1rem; overflow: hidden; }
.committee-header { padding: 0.75rem 1.25rem; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--border); }
.committee-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.committee-title { font-size: 14px; font-weight: 500; color: var(--ink); flex: 1; }
.committee-role { font-size: 11px; color: var(--muted); background: var(--page-bg); padding: 2px 8px; border-radius: 10px; }
.committee-count { font-size: 11px; font-weight: 600; color: var(--sky); }
.queue-empty { padding: 1rem 1.25rem; font-size: 13px; color: var(--muted); }
.queue-item { padding: 0.65rem 1.25rem; border-bottom: 0.5px solid var(--border); display: flex; align-items: flex-start; gap: 10px; }
.queue-item:last-child { border-bottom: none; }
.queue-item-body { flex: 1; }
.queue-item-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.queue-item-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.member-row { display: flex; align-items: center; padding: 10px 0; border-bottom: 0.5px solid var(--border); gap: 12px; }
.member-row:last-child { border-bottom: none; }
.member-avatar { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0; }
.member-info { flex: 1; }
.member-name { font-size: 13px; font-weight: 500; color: var(--ink); }
.member-meta { font-size: 11px; color: var(--muted); }

/* Resident hero */
.resident-hero { background: var(--sidebar-bg); color: #fff; padding: 1.5rem 2rem; margin: -1.75rem -2rem 1.75rem; border-bottom: 1px solid rgba(255,255,255,0.06); }
.hero-name { font-size: 1.2rem; font-weight: 600; margin-bottom: 3px; }
.hero-sub { font-size: 12px; color: rgba(255,255,255,0.4); }
.hero-badges { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.hero-badge { background: rgba(255,255,255,0.08); border: 1px solid rgba(255,255,255,0.12); border-radius: 20px; padding: 3px 12px; font-size: 11px; color: rgba(255,255,255,0.7); }
.hero-badge.warn  { background: rgba(244,63,94,0.15);  border-color: rgba(244,63,94,0.3);  color: #fda4af; }
.hero-badge.board { background: rgba(56,189,248,0.15); border-color: rgba(56,189,248,0.3); color: #7dd3fc; }

/* Action grid (resident) */
.action-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 1.5rem; }
.action-card { background: var(--card-bg); border: 1px solid var(--border); border-radius: 10px; padding: 1rem; cursor: pointer; transition: all 0.15s; text-align: center; }
.action-card:hover { border-color: var(--sky); box-shadow: 0 0 0 3px rgba(56,189,248,0.1); transform: translateY(-1px); }
.action-icon { width: 38px; height: 38px; border-radius: 9px; background: rgba(56,189,248,0.1); display: flex; align-items: center; justify-content: center; margin: 0 auto 8px; }
.action-label { font-size: 12px; font-weight: 500; color: var(--ink); }

/* Balance card */
.balance-card { background: var(--sidebar-bg); border-radius: 12px; padding: 1.25rem 1.5rem; color: #fff; margin-bottom: 1rem; border: 1px solid rgba(255,255,255,0.08); }
.balance-label  { font-size: 11px; color: rgba(255,255,255,0.4); margin-bottom: 4px; }
.balance-amount { font-size: 2rem; font-weight: 700; }
.balance-status { font-size: 12px; margin-top: 4px; }
.balance-status.good { color: #34d399; }
.balance-status.bad  { color: #fb7185; }

/* Portal tabs */
.portal-tabs { display: flex; border-bottom: 1px solid var(--border); margin: -1.75rem -2rem 1.75rem; padding: 0 2rem; background: var(--card-bg); }
.portal-tab { font-size: 13px; font-weight: 500; padding: 12px 16px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; transition: all 0.15s; display: flex; align-items: center; gap: 6px; }
.portal-tab:hover { color: var(--ink); }
.portal-tab.active { color: var(--sky); border-bottom-color: var(--sky); }
.portal-tab .tab-badge { background: var(--danger); color: #fff; font-size: 9px; font-weight: 700; padding: 1px 5px; border-radius: 10px; min-width: 16px; text-align: center; }

@media (max-width: 768px) {
  .app-layout { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .two-col { grid-template-columns: 1fr; }
  .action-grid { grid-template-columns: repeat(2,1fr); }
  .main-content { padding: 1.25rem 1rem; padding-bottom: 80px; }

  /* Hide desktop sidebar */
  .sidebar { display: none; }

  /* Mobile hamburger button in topnav */
  .mobile-menu-btn {
    display: flex !important;
    width: 34px; height: 34px; border-radius: 8px;
    align-items: center; justify-content: center;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.7);
    cursor: pointer; flex-shrink: 0;
    margin-right: 4px;
  }

  /* Mobile drawer overlay */
  .mobile-drawer-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    backdrop-filter: blur(2px);
  }
  .mobile-drawer-overlay.open { display: block; }

  /* Mobile drawer */
  .mobile-drawer {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 80%; max-width: 280px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--nav-border);
    z-index: 201;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    padding: 0.5rem 0 2rem;
  }
  .mobile-drawer.open { transform: translateX(0); }
  .mobile-drawer-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1rem 1.25rem 0.5rem;
    border-bottom: 1px solid var(--nav-divider-color);
    margin-bottom: 0.5rem;
  }
  .mobile-drawer-close {
    width: 28px; height: 28px; border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(255,255,255,0.06);
    border: none; color: rgba(255,255,255,0.5);
    cursor: pointer;
  }

  /* Preview wrap on mobile */
  .preview-wrap { padding: 0 1rem; }

  /* Page header on mobile */
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }

  /* Tables scroll horizontally */
  .data-row { flex-wrap: wrap; gap: 8px; }
}

/* Mobile menu btn hidden on desktop */
.mobile-menu-btn { display: none; }

/* Drawer styles (shared between mobile sizes) */
.mobile-drawer-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
}
.mobile-drawer {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: 80%; max-width: 280px;
  background: var(--sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: 201;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
  padding: 0.5rem 0 2rem;
}
.mobile-drawer.open { transform: translateX(0); }
.mobile-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--nav-divider-color);
  margin-bottom: 0.5rem;
}
.mobile-drawer-close {
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.06);
  border: none; color: rgba(255,255,255,0.5);
  cursor: pointer;
}


/* ── HELP DRAWER ── */
.help-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.4); z-index: 150;
  backdrop-filter: blur(2px);
}
.help-overlay.open { display: block; }
.help-drawer {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 380px; max-width: 95vw;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  z-index: 151; display: flex; flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  overflow: hidden;
}
.help-drawer.open { transform: translateX(0); }
.help-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.help-search-wrap { padding: 0.75rem 1.25rem; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.help-search {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 13px; color: var(--ink); background: var(--page-bg);
  outline: none; font-family: inherit;
}
.help-search:focus { border-color: var(--sky); }
#help-content { overflow-y: auto; flex: 1; padding-bottom: 1rem; }
.help-category {
  padding: 14px 1.25rem 6px;
  font-size: 10px; font-weight: 700;
  color: var(--muted); letter-spacing: 0.08em; text-transform: uppercase;
}
.help-article {
  padding: 10px 1.25rem; cursor: pointer;
  border-bottom: 0.5px solid var(--border);
  transition: background 0.12s;
}
.help-article:hover { background: var(--page-bg); }
.help-article-title { font-size: 13px; font-weight: 500; color: var(--ink); margin-bottom: 2px; }
.help-article-sub { font-size: 11px; color: var(--muted); line-height: 1.4; }
.help-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: none; cursor: pointer;
  font-size: 13px; color: var(--sky); padding: 1rem 1.25rem 0.75rem;
  font-family: inherit; font-weight: 500;
}
.help-back-btn:hover { opacity: 0.8; }
#help-article-content { padding: 0 1.25rem 2rem; overflow-y: auto; flex: 1; }
#help-article-view { display: flex; flex-direction: column; flex: 1; overflow: hidden; }
.help-article-content-inner h2 { font-size: 1rem; font-weight: 700; color: var(--ink); margin-bottom: 0.75rem; }
.help-article-content-inner h3 { font-size: 13px; font-weight: 600; color: var(--ink); margin: 1rem 0 0.5rem; }
.help-article-content-inner p { font-size: 13px; color: var(--muted); line-height: 1.7; margin-bottom: 0.75rem; }
.help-article-content-inner ol, .help-article-content-inner ul { font-size: 13px; color: var(--muted); line-height: 1.7; padding-left: 1.25rem; margin-bottom: 0.75rem; }
.help-article-content-inner li { margin-bottom: 4px; }
.help-article-content-inner .tip { background: rgba(56,189,248,0.08); border: 1px solid rgba(56,189,248,0.2); border-radius: 8px; padding: 10px 14px; font-size: 12px; color: var(--ink); margin: 0.75rem 0; line-height: 1.6; }
.help-article-content-inner .tip strong { color: var(--sky); }
.help-article-content-inner code { background: var(--page-bg); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; font-size: 12px; font-family: monospace; }
.help-no-results { padding: 2rem 1.25rem; text-align: center; font-size: 13px; color: var(--muted); }

/* ── UNIT PROFILE PANEL ── */
.unit-profile-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.45); z-index: 150;
  backdrop-filter: blur(2px);
}
.unit-profile-overlay.open { display: block; }
.unit-profile-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 460px; max-width: 95vw;
  background: var(--card-bg);
  border-left: 1px solid var(--border);
  z-index: 151;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.unit-profile-panel.open { transform: translateX(0); }
.unit-profile-head {
  padding: 1.25rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--navy);
  color: #fff;
}
.unit-profile-label {
  font-size: 10px; font-weight: 700;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 4px;
}
.unit-profile-name { font-size: 1.2rem; font-weight: 700; margin-bottom: 2px; }
.unit-profile-email { font-size: 12px; color: rgba(255,255,255,0.5); }
.unit-profile-badges { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.unit-profile-badge {
  font-size: 10px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.1);
}
.unit-profile-badge.good { background: rgba(16,185,129,0.2); color: #34d399; border-color: rgba(16,185,129,0.2); }
.unit-profile-badge.warn { background: rgba(244,63,94,0.2); color: #fb7185; border-color: rgba(244,63,94,0.2); }
.unit-profile-body { flex: 1; overflow-y: auto; padding: 0 0 2rem; }
.unit-profile-section {
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.5rem;
}
.unit-profile-section:last-child { border-bottom: none; }
.unit-profile-section-title {
  font-size: 10px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em; margin-bottom: 10px;
  display: flex; align-items: center; justify-content: space-between;
}
.unit-profile-row {
  display: flex; align-items: flex-start;
  justify-content: space-between; gap: 12px;
  font-size: 13px; margin-bottom: 6px;
}
.unit-profile-row:last-child { margin-bottom: 0; }
.unit-profile-row-label { color: var(--muted); flex-shrink: 0; }
.unit-profile-row-value { color: var(--ink); font-weight: 500; text-align: right; }
.unit-history-item {
  padding: 8px 0;
  border-bottom: 0.5px solid var(--border);
  display: flex; align-items: flex-start; gap: 10px;
  font-size: 12px;
}
.unit-history-item:last-child { border-bottom: none; }
.unit-history-dot {
  width: 7px; height: 7px; border-radius: 50%;
  flex-shrink: 0; margin-top: 4px;
}
.unit-profile-empty { font-size: 12px; color: var(--muted); font-style: italic; }
.unit-profile-note {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 13px; color: var(--ink);
  background: var(--input-bg); resize: vertical;
  min-height: 70px; font-family: inherit;
}
.unit-profile-note:focus { outline: none; border-color: var(--sky); }
.unit-profile-close {
  position: absolute; top: 1rem; right: 1.25rem;
  background: rgba(255,255,255,0.1); border: none;
  color: rgba(255,255,255,0.6); cursor: pointer;
  width: 28px; height: 28px; border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.unit-profile-close:hover { background: rgba(255,255,255,0.2); color: #fff; }

/* ── COMMAND PALETTE ── */
.cmd-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 300;
  backdrop-filter: blur(3px);
}
.cmd-overlay.open { display: block; }
.cmd-palette {
  position: fixed; top: 20%; left: 50%;
  transform: translateX(-50%);
  width: 580px; max-width: calc(100vw - 2rem);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  z-index: 301;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0,0,0,0.2);
}
.cmd-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.cmd-input {
  flex: 1; border: none; background: none;
  font-size: 15px; color: var(--ink);
  outline: none; font-family: inherit;
}
.cmd-input::placeholder { color: var(--muted); }
.cmd-esc-key {
  font-size: 10px; color: var(--muted);
  background: var(--cream); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; cursor: pointer;
  font-family: inherit;
}
.cmd-results { max-height: 360px; overflow-y: auto; }
.cmd-section {
  padding: 8px 16px 4px;
  font-size: 10px; font-weight: 700;
  color: var(--muted); text-transform: uppercase;
  letter-spacing: 0.08em;
}
.cmd-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; cursor: pointer;
  transition: background 0.1s;
}
.cmd-item:hover, .cmd-item.cmd-selected {
  background: var(--page-bg);
}
.cmd-item-icon {
  width: 30px; height: 30px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.cmd-item-body { flex: 1; min-width: 0; }
.cmd-item-title {
  font-size: 13px; font-weight: 500;
  color: var(--ink); white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.cmd-item-sub {
  font-size: 11px; color: var(--muted); margin-top: 1px;
}
.cmd-item-enter {
  font-size: 11px; color: var(--muted);
  flex-shrink: 0;
}
.cmd-footer {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  background: var(--page-bg);
}
.cmd-hint {
  display: flex; align-items: center; gap: 4px;
  font-size: 11px; color: var(--muted);
}
.cmd-hint kbd {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 3px; padding: 1px 5px;
  font-size: 10px; font-family: inherit;
}
.cmd-empty {
  padding: 2.5rem; text-align: center;
  font-size: 13px; color: var(--muted);
}
.nav-search-btn { display: flex; }
@media (max-width: 768px) {
  .cmd-palette { top: 10%; }
}

/* ── TEMPLATES DRAWER ── */
.tmpl-overlay { display:none;position:fixed;inset:0;background:rgba(0,0,0,0.45);z-index:150;backdrop-filter:blur(2px) }
.tmpl-overlay.open { display:block }
.tmpl-drawer { position:fixed;top:0;right:0;bottom:0;width:420px;max-width:95vw;background:var(--card-bg);border-left:1px solid var(--border);z-index:151;display:flex;flex-direction:column;transform:translateX(100%);transition:transform 0.25s ease }
.tmpl-drawer.open { transform:translateX(0) }
.tmpl-drawer-head { display:flex;align-items:center;justify-content:space-between;padding:1.25rem 1.5rem 1rem;border-bottom:1px solid var(--border);flex-shrink:0 }
.tmpl-search-wrap { padding:0.75rem 1.25rem;border-bottom:1px solid var(--border);flex-shrink:0 }
.tmpl-search { width:100%;padding:8px 12px;border:1px solid var(--border);border-radius:8px;font-size:13px;color:var(--ink);background:var(--page-bg);outline:none;font-family:inherit }
.tmpl-search:focus { border-color:var(--sky) }
.tmpl-list { overflow-y:auto;flex:1 }
.tmpl-category { padding:12px 1.25rem 4px;font-size:10px;font-weight:700;color:var(--muted);text-transform:uppercase;letter-spacing:0.08em }
.tmpl-item { padding:10px 1.25rem;cursor:pointer;border-bottom:0.5px solid var(--border);transition:background 0.12s }
.tmpl-item:hover { background:var(--page-bg) }
.tmpl-item-title { font-size:13px;font-weight:500;color:var(--ink);margin-bottom:2px }
.tmpl-item-preview { font-size:11px;color:var(--muted);line-height:1.4;white-space:nowrap;overflow:hidden;text-overflow:ellipsis }
.tmpl-detail { display:none;flex-direction:column;flex:1;overflow:hidden }
.tmpl-detail.visible { display:flex }
.tmpl-detail-head { padding:1rem 1.25rem;border-bottom:1px solid var(--border);flex-shrink:0 }
.tmpl-detail-title { font-size:14px;font-weight:600;color:var(--ink);margin-bottom:3px }
.tmpl-detail-tag { font-size:10px;color:var(--muted);text-transform:uppercase;letter-spacing:0.06em }
.tmpl-body { flex:1;overflow-y:auto;padding:1rem 1.25rem }
.tmpl-text { font-size:13px;color:var(--ink);line-height:1.8;background:var(--page-bg);border:1px solid var(--border);border-radius:8px;padding:1rem;margin-bottom:1rem;white-space:pre-wrap;font-family:inherit }
.tmpl-actions { padding:1rem 1.25rem;border-top:1px solid var(--border);display:flex;gap:8px;flex-shrink:0 }
.tmpl-back { background:none;border:none;cursor:pointer;font-size:13px;color:var(--sky);padding:0.75rem 1.25rem 0.5rem;font-family:inherit;display:flex;align-items:center;gap:5px }
