:root {
  --bg: #0C0F16;
  --surface: #131922;
  --surface2: #1A2235;
  --surface3: #1F2A40;
  --border: #1E2840;
  --border2: #263350;
  --red: #E53935;
  --redBright: #FF5252;
  --redDark: #B71C1C;
  --redDim: rgba(229,57,53,0.14);
  --redBorder: rgba(229,57,53,0.28);
  --redGradient: linear-gradient(135deg, #B71C1C, #E53935);
  --textHi: #EDF2FF;
  --textMid: #7D95BB;
  --textLo: #3A4F72;
  --green: #22C55E;
  --greenDim: rgba(34,197,94,0.12);
  --greenBorder: rgba(34,197,94,0.22);
  --blue: #3B82F6;
  --blueDim: rgba(59,130,246,0.12);
  --blueBorder: rgba(59,130,246,0.22);
  --warning: #FFC107;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;
  --mono: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  --sidebar-width: 240px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--textHi);
  min-height: 100vh;
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

input, button, textarea, select {
  font-family: var(--font);
  font-size: 14px;
  outline: none;
}

input, textarea, select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--textHi);
  padding: 13px 16px;
  width: 100%;
  transition: border-color 0.2s;
}
input:focus, textarea:focus, select:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--redDim);
}

button { cursor: pointer; border: none; font-weight: 700; transition: all 0.2s; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }

label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  color: var(--textLo);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

/* ============ APP LAYOUT ============ */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 200;
}

.main-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  min-width: 0;
}

/* ============ SIDEBAR ============ */
.sidebar-header {
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 34px;
  height: 34px;
  background: var(--redGradient);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 8px rgba(229,57,53,0.3);
  flex-shrink: 0;
}

.sidebar-brand h3 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: -0.2px;
  line-height: 1.2;
  color: var(--textHi);
}

.sidebar-brand span {
  font-size: 7px;
  font-weight: 700;
  color: var(--textLo);
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 8px 0;
}

.sidebar-section-label {
  font-size: 8px;
  font-weight: 700;
  color: var(--textLo);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 10px 16px 6px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin: 1px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  text-decoration: none;
  color: var(--textMid);
  font-size: 13px;
  font-weight: 500;
  position: relative;
}

.sidebar-item:hover {
  background: var(--surface2);
  color: var(--textHi);
  text-decoration: none;
}

.sidebar-item.active {
  background: rgba(229,57,53,0.08);
  color: var(--textHi);
  font-weight: 600;
}

.sidebar-item .si-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-item .si-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-item .si-badge {
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.6;
  color: #fff;
  background: var(--border2);
  flex-shrink: 0;
}

.sidebar-item.active .si-badge {
  background: var(--redDim);
  color: var(--red);
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 14px;
}

.sidebar-bottom {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  margin-bottom: 4px;
}

.sidebar-avatar {
  width: 30px;
  height: 30px;
  background: var(--redGradient);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  box-shadow: 0 2px 6px rgba(229,57,53,0.25);
  flex-shrink: 0;
}

.sidebar-user .su-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--textHi);
}

.sidebar-user .su-role {
  font-size: 9px;
  color: var(--textLo);
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  margin: 4px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--textLo);
  background: none;
  border: none;
  width: calc(100% - 16px);
  text-align: left;
}

.sidebar-logout:hover {
  background: var(--redDim);
  color: var(--red);
}

/* ============ TOP BAR (breadcrumb, inside main-area) ============ */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--red);
  font-size: 16px;
  flex-shrink: 0;
  cursor: pointer;
  text-decoration: none;
}
.back-btn:hover { border-color: var(--red); }

.topbar-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.2px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-subtitle {
  font-size: 10px;
  color: var(--textLo);
  display: block;
}

/* ============ PAGE CONTENT ============ */
.page-wrap {
  padding: 20px 24px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn 0.25s;
}

/* no max-width for full-width content areas */
.page-wrap-full {
  padding: 20px 24px;
  width: 100%;
  animation: fadeIn 0.25s;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ============ MOBILE HEADER (replaces sidebar on mobile) ============ */
.mobile-header {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mobile-header-logo {
  width: 28px;
  height: 28px;
  background: var(--redGradient);
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(229,57,53,0.3);
  flex-shrink: 0;
}

.mobile-header-brand { flex: 1; min-width: 0; }
.mobile-header-brand h1 { font-size: 13px; font-weight: 800; letter-spacing: -0.2px; line-height: 1.2; }
.mobile-header-brand p { font-size: 7px; font-weight: 700; color: var(--textLo); letter-spacing: 1.5px; text-transform: uppercase; }

.mobile-header-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--textMid);
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  text-decoration: none;
}
.mobile-header-btn:hover { border-color: var(--red); color: var(--textHi); }
.mobile-header-btn.accent { background: var(--redDim); border-color: var(--redBorder); color: var(--red); }

/* ============ BOTTOM NAV (mobile only) ============ */
.bottom-nav {
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 4px 0;
  position: sticky;
  bottom: 0;
  z-index: 100;
}

.nav-tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; padding: 6px 4px 8px;
  cursor: pointer; position: relative; transition: color 0.15s;
  text-decoration: none;
}
.nav-tab .nav-icon { font-size: 20px; }
.nav-tab .nav-label { font-size: 9px; font-weight: 700; letter-spacing: 0.3px; color: var(--textLo); }
.nav-tab .nav-badge {
  position: absolute; top: 2px; right: calc(50% - 22px);
  background: var(--border2); border-radius: 8px;
  padding: 1px 5px; font-size: 8px; font-weight: 800; color: #fff; line-height: 1.4;
}
.nav-tab.active .nav-label { color: inherit; }
.nav-tab.active .nav-badge { background: inherit; }
.nav-tab .nav-indicator {
  position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  height: 2px; border-radius: 1px; transition: width 0.2s;
}
.nav-tab.active .nav-indicator { width: 20px; }
.nav-tab:not(.active) .nav-indicator { width: 0; }

/* ============ ADMIN BANNER ============ */
.admin-banner {
  display: flex; align-items: center; gap: 6px;
  background: var(--redDim);
  padding: 7px 20px;
  font-size: 11px; font-weight: 600; color: var(--red); letter-spacing: 0.3px;
  border-bottom: 1px solid var(--redBorder);
}

/* ============ BUTTONS ============ */
.btn {
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.btn-red {
  background: var(--redGradient);
  color: #fff;
  box-shadow: 0 4px 16px rgba(229,57,53,0.35);
}
.btn-red:hover { background: var(--red); transform: translateY(-1px); }
.btn-sm { padding: 8px 16px; font-size: 12px; }
.btn-block { padding: 14px; font-size: 14px; width: 100%; border-radius: 10px; }
.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--textMid);
  font-weight: 600;
}
.btn-outline:hover { border-color: var(--red); color: var(--textHi); }

/* ============ CARDS ============ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 8px;
}

/* ============ LOADING / ERROR / EMPTY ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--textLo);
  gap: 12px;
  font-size: 14px;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.err-msg {
  background: var(--redDim);
  border: 1px solid var(--redBorder);
  border-radius: 8px;
  padding: 12px 16px;
  color: var(--red);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.err-msg.active { display: flex; align-items: center; gap: 8px; }
.err-msg::before { content: '⚠'; font-size: 16px; }

.empty {
  display: flex; flex-direction: column; align-items: center;
  padding: 48px 24px; color: var(--textLo); gap: 8px;
}
.empty svg { width: 48px; height: 48px; opacity: 0.4; }
.empty .et { font-size: 14px; font-weight: 600; color: var(--textHi); }
.empty .es { font-size: 12px; }

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 10px;
  font-weight: 700;
  color: var(--textMid);
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.badge-red { background: var(--redDim); border-color: var(--red); color: var(--red); }
.badge-green { background: var(--greenDim); border-color: var(--green); color: var(--green); }
.badge-blue { background: var(--blueDim); border-color: var(--blue); color: var(--blue); }

/* ============ TOAST ============ */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  animation: fadeIn 0.3s;
}
.toast-ok { background: rgba(34,197,94,0.1); border: 1px solid var(--green); color: var(--green); }
.toast-err { background: var(--redDim); border: 1px solid var(--red); color: var(--red); }

/* ============ LOGIN / REGISTER PAGES ============ */
html.auth-page, html.auth-page body {
  display: flex; align-items: center; justify-content: center;
  height: 100vh;
}
.auth-wrap {
  width: 100%; max-width: 440px; padding: 20px;
}
.auth-logo {
  text-align: center; margin: 40px 0 32px;
}
.auth-logo .a-icon {
  width: 72px; height: 72px; margin: 0 auto 14px;
  background: var(--redGradient); border-radius: 20px;
  display: flex; align-items: center; justify-content: center;
  font-size: 32px; box-shadow: 0 8px 24px rgba(229,57,53,0.35);
}
.auth-logo h1 {
  font-size: 26px; font-weight: 900; letter-spacing: -0.5px;
}
.auth-logo h1 span { color: var(--red); }
.auth-logo p {
  font-size: 10px; font-weight: 700; color: var(--textLo);
  letter-spacing: 3px; margin-top: 4px; text-transform: uppercase;
}
.auth-footer {
  text-align: center; font-size: 10px; color: var(--textLo);
  letter-spacing: 0.5px; margin-top: 24px;
}

.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 40px; }
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--textLo); cursor: pointer;
  font-size: 18px; padding: 4px;
}
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; }
.divider-line { flex: 1; height: 1px; background: var(--border); }
.divider-text { font-size: 11px; color: var(--textLo); }

/* ============ SAVED ACCOUNTS CHIPS ============ */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--redDim); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 15px;
  font-size: 13px; font-weight: 500; color: var(--textHi); cursor: pointer;
  transition: all 0.15s;
}
.chip:hover { background: rgba(229,57,53,0.18); border-color: var(--red); }
.chip .c-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--red); display: flex; align-items: center; justify-content: center; font-size: 8px; color: #fff; flex-shrink: 0; }
.chip .c-rm { color: var(--textLo); font-size: 14px; cursor: pointer; line-height: 1; padding: 2px; }
.chip .c-rm:hover { color: var(--red); }

/* ============ OBJECT GRID ============ */
.obj-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
}
.obj-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  color: inherit;
}
.obj-card:hover { text-decoration: none; border-color: var(--red); transform: translateY(-2px); box-shadow: 0 4px 16px rgba(229,57,53,0.08); }
.obj-card-body { display: flex; align-items: flex-start; gap: 12px; padding: 14px; }
.obj-card-stripe { width: 3px; align-self: stretch; min-height: 40px; border-radius: 2px; flex-shrink: 0; }
.obj-card-icon {
  width: 40px; height: 40px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
  margin-top: 2px;
}
.obj-card-info { flex: 1; min-width: 0; }
.obj-card-name { font-size: 13px; font-weight: 700; color: var(--textHi); line-height: 1.35; overflow-wrap: break-word; }
.obj-card-id { font-size: 10px; color: var(--textLo); font-family: var(--mono); letter-spacing: 0.5px; margin-top: 4px; }
.obj-card-status {
  display: flex; align-items: center; gap: 4px;
  background: var(--greenDim); border: 1px solid var(--greenBorder); border-radius: 20px;
  padding: 3px 7px; font-size: 8px; font-weight: 700; color: var(--green); letter-spacing: 0.5px;
  flex-shrink: 0;
  margin-top: 4px;
}
.obj-card-status::before { content: ''; width: 4px; height: 4px; border-radius: 50%; background: var(--green); }

/* ============ EVENTS ============ */
.meta-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 57px; z-index: 50;
}
.meta-count { font-size: 15px; font-weight: 800; color: var(--red); }
.meta-text { font-size: 11px; font-weight: 700; color: var(--textHi); }
.meta-range { font-size: 9px; color: var(--textLo); font-family: var(--mono); margin-left: auto; }

.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-chip {
  padding: 8px 14px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 12px; font-weight: 600; color: var(--textMid); cursor: pointer;
}
.quick-chip:hover { border-color: var(--red); color: var(--textHi); }

.date-range { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.date-range input { width: 180px; }
.date-range span { color: var(--textMid); font-size: 13px; }

.event-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px; margin-bottom: 8px;
  cursor: pointer; position: relative; overflow: hidden;
}
.event-card:hover { border-color: var(--red); }
.event-card::after {
  content: ''; position: absolute; right: 0; top: 0; bottom: 0; width: 40px;
  background: linear-gradient(270deg, var(--redDim), transparent);
  border-radius: 0 12px 12px 0;
}
.ev-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 6px; }
.ev-time { font-size: 15px; font-weight: 800; color: var(--textHi); font-family: var(--mono); letter-spacing: 0.5px; }
.ev-date { font-size: 9px; color: var(--textLo); margin-left: 8px; }
.ev-badge {
  padding: 3px 8px; border-radius: 5px; font-size: 8px; font-weight: 700; letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 3px;
}
.ev-badge.has { background: var(--redDim); border: 1px solid var(--redBorder); color: var(--red); }
.ev-badge.no { background: var(--surface2); border: 1px solid var(--border); color: var(--textLo); }
.ev-volume { font-size: 22px; font-weight: 800; color: var(--red); font-family: var(--mono); line-height: 1; margin: 4px 0; grid-column: 1 / -1; }
.ev-unit { font-size: 11px; color: var(--textLo); font-weight: 600; }
.ev-rows { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.ev-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; gap: 8px; }
.ev-row .r-label { font-size: 9px; font-weight: 700; color: var(--textLo); letter-spacing: 0.3px; white-space: nowrap; flex-shrink: 0; }
.ev-row .r-val { font-size: 11px; font-weight: 500; color: var(--textMid); text-align: right; font-family: var(--mono); letter-spacing: 0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev-watch { display: flex; align-items: center; justify-content: flex-end; gap: 4px; margin-top: 4px; font-size: 11px; font-weight: 600; color: var(--red); }

/* ============ EVENT DETAIL ============ */
.hl-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-bottom: 10px; }
.highlight-box { padding: 14px 16px; border-radius: 12px; text-align: center; }
.highlight-box.accent { background: var(--redDim); border: 1px solid var(--redBorder); }
.highlight-box.normal { background: var(--surface); border: 1px solid var(--border); }
.hl-value { font-size: 24px; font-weight: 800; font-family: var(--mono); line-height: 1; }
.hl-value.accent { color: var(--red); }
.hl-unit { font-size: 12px; color: var(--textLo); font-weight: 600; margin-top: 2px; }
.hl-label { font-size: 9px; font-weight: 700; color: var(--textLo); text-transform: uppercase; letter-spacing: 0.8px; margin-top: 4px; }

.info-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 10px; border-bottom: 1px solid rgba(30,40,64,0.5); }
.info-row:last-child { border-bottom: none; }
.info-key { color: var(--textLo); font-size: 12px; }
.info-val { font-weight: 600; font-size: 13px; text-align: right; color: var(--textHi); }
.info-val.accent { font-size: 14px; font-weight: 800; color: var(--red); font-family: var(--mono); }

.section-title {
  font-size: 9px; font-weight: 700; color: var(--textLo);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 10px 14px 8px;
}

.video-wrap { margin-bottom: 20px; }
.video-wrap .v-label {
  font-size: 10px; font-weight: 700; color: var(--textLo);
  text-transform: uppercase; letter-spacing: 1px; margin-bottom: 8px;
}
.video-wrap video { width: 100%; max-height: 480px; background: #000; border-radius: 10px; }

.cam-tabs { display: flex; gap: 4px; padding: 0 14px 8px; }
.cam-tab {
  padding: 6px 12px; border-radius: 6px; font-size: 11px; font-weight: 700;
  border: 1px solid var(--border); background: var(--surface2); color: var(--textLo); cursor: pointer;
}
.cam-tab.active { background: var(--red); border-color: var(--red); color: #fff; }

/* ============ PROFILE ============ */
.hero { display: flex; align-items: center; gap: 14px; padding: 16px; }
.avatar {
  width: 54px; height: 54px;
  background: var(--redGradient); border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 800; color: #fff;
  box-shadow: 0 4px 12px rgba(229,57,53,0.3);
  flex-shrink: 0;
}
.hero-info { flex: 1; min-width: 0; }
.hero-name { font-size: 16px; font-weight: 800; letter-spacing: -0.2px; }
.hero-role { font-size: 11px; color: var(--textLo); margin-top: 2px; }
.hero-role.admin {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--redDim); border: 1px solid var(--redBorder);
  border-radius: 4px; padding: 3px 8px;
  font-size: 10px; font-weight: 700; color: var(--red); letter-spacing: 0.3px;
  margin-top: 4px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 10px 12px;
}
.stat-top { display: flex; align-items: center; gap: 10px; }
.stat-icon {
  width: 36px; height: 36px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.stat-val { font-size: 20px; font-weight: 800; color: var(--textHi); line-height: 1; }
.stat-label { font-size: 10px; color: var(--textLo); font-weight: 600; margin-top: 2px; }

.menu-item {
  display: flex; align-items: center; gap: 10px;
  padding: 14px; cursor: pointer;
  font-size: 14px; font-weight: 500; color: var(--textHi);
  border-bottom: 1px solid rgba(30,40,64,0.5);
}
.menu-item:last-child { border-bottom: none; }
.menu-item .mi-icon { font-size: 18px; color: var(--textMid); }
.menu-item .mi-arrow { margin-left: auto; font-size: 16px; color: var(--textLo); }

.logout-btn {
  margin-top: 8px;
  padding: 14px;
  background: var(--redDim);
  border: 1px solid var(--redBorder);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 700; color: var(--red);
  width: 100%; cursor: pointer;
}
.logout-btn:hover { background: rgba(229,57,53,0.2); }

/* ============ DIALOG ============ */
.dialog-overlay {
  display: none; position: fixed; inset: 0; background: rgba(12,15,22,0.85);
  z-index: 1000; align-items: center; justify-content: center;
}
.dialog-overlay.show { display: flex; }
.dialog {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 24px; width: 90%; max-width: 440px;
}
.dialog h3 { font-size: 16px; font-weight: 800; margin-bottom: 16px; }
.dialog .dbtns { display: flex; gap: 8px; margin-top: 16px; }
.dialog .dbtns button { flex: 1; }

/* ============ ADMIN ============ */
.search-bar {
  padding: 12px 16px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 50;
}
.user-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px; margin-bottom: 8px;
}
.user-row { display: flex; align-items: center; gap: 12px; }
.user-avatar {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; flex-shrink: 0;
  background: rgba(125,149,187,0.1); color: var(--textMid);
}
.user-avatar.admin { background: rgba(229,57,53,0.1); color: var(--red); }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 15px; font-weight: 600; }
.user-badge { display: inline-block; padding: 2px 6px; border-radius: 4px; font-size: 10px; font-weight: 700; color: #fff; margin-top: 2px; }
.user-badge.sa { background: var(--red); }
.user-badge.ad { background: var(--red); }
.user-stats { font-size: 12px; color: var(--textMid); margin-top: 6px; }

.section-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; font-size: 15px; font-weight: 600;
}
.section-badge {
  padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600;
}
.obj-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid rgba(30,40,64,0.3);
}
.obj-list-icon {
  width: 40px; height: 40px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.obj-list-name { font-size: 13px; font-weight: 600; }
.obj-list-id { font-size: 11px; color: var(--textLo); font-family: var(--mono); }

/* ============ TABLE VIEW ============ */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; padding: 11px 14px; font-size: 10px; font-weight: 700; color: var(--textLo); text-transform: uppercase; letter-spacing: 0.8px; border-bottom: 1px solid var(--border); background: rgba(12,15,22,0.3); }
td { padding: 12px 14px; border-bottom: 1px solid var(--border); color: var(--textMid); font-size: 13px; }
tr:hover td { background: var(--redDim); }
tr[onclick] { cursor: pointer; }
td.n { text-align: right; font-family: var(--mono); letter-spacing: 0.3px; color: var(--textHi); }
td.act { text-align: center; white-space: nowrap; }

/* ============ RESPONSIVE ============ */
/* Desktop: sidebar visible */
@media (min-width: 1024px) {
  .sidebar { display: flex; }
  .mobile-header { display: none !important; }
  .bottom-nav { display: none !important; }

  .page-wrap { padding: 24px 32px; }
  .page-wrap-full { padding: 24px 32px; }

  .obj-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
  .stat-grid { grid-template-columns: repeat(4, 1fr); }
  .hl-row { grid-template-columns: repeat(4, 1fr); }
  .ev-rows { gap: 6px 16px; }
  .event-card { padding: 16px; }
  .obj-card-body { padding: 18px 16px; }
}

/* Mobile: sidebar hidden, bottom nav visible */
@media (max-width: 1023px) {
  .app-layout { flex-direction: column; }
  .sidebar { display: none; }
  .mobile-header { display: flex; }
  .main-area { flex: 1; }

  .page-wrap { padding: 10px 12px; }
  .page-wrap-full { padding: 10px 12px; }

  .obj-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .hl-row { grid-template-columns: repeat(2, 1fr); }
  .date-range { flex-direction: column; align-items: stretch; }
  .date-range input { width: 100%; }
  .topbar-title { font-size: 14px; }
  .obj-card-name { font-size: 12px; }
  .hl-value { font-size: 20px; }
}

/* Extra-wide desktop */
@media (min-width: 1440px) {
  .page-wrap { padding: 28px 40px; }
  .page-wrap-full { padding: 28px 40px; }
  .obj-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
