:root { 
  --bg: #f7f8fa;
  --text: #1a1a1a;
  --muted: #6b7280;
  --primary: #0a84ff;
  --primary-light: rgba(10,132,255,.1);
  --border: #e5e7eb;
  --card-bg: #fff;
  --header-bg: #fff;
  --menu-bg: #fff;
  --success: #2e7d32;
  --success-light: rgba(46,125,50,.1);
  --danger: #d32f2f;
  --danger-light: rgba(211,47,47,.1);
  --warning: #f9a825;
  --warning-light: rgba(249,168,37,.1);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.12);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --font-xs: 11px;
  --font-sm: 13px;
  --font-md: 15px;
  --font-lg: 18px;
  --font-xl: 22px;
  --font-2xl: 28px;
}

body.dark-mode {
  --bg: #0f1117;
  --text: #e4e4e7;
  --muted: #9ca3af;
  --border: #2a2d35;
  --card-bg: #1a1d25;
  --header-bg: #1a1d25;
  --menu-bg: #1a1d25;
  --primary-light: rgba(10,132,255,.15);
  --success-light: rgba(46,125,50,.15);
  --danger-light: rgba(211,47,47,.15);
  --warning-light: rgba(249,168,37,.15);
  --shadow-sm: 0 1px 2px rgba(0,0,0,.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.4);
}

body { 
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; 
  margin: 0; 
  padding-top: env(safe-area-inset-top); 
  background-color: var(--bg); 
  color: var(--text); 
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Fixed Header */
header { 
  display: block; 
  padding: 0; 
  border-bottom: 1px solid var(--border); 
  position: fixed; top: 0; left: 0; right: 0; 
  background: var(--header-bg); z-index: 100; 
  padding-top: env(safe-area-inset-top);
  height: auto; 
  box-sizing: border-box;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Spacer to prevent content hiding behind fixed header */
#headerSpacer { height: calc(60px + env(safe-area-inset-top)); }

.logo { 
  width: 100%; 
  height: 60px; 
  object-fit: cover; 
  display: block; 
}

header .subtitle { display: none; } 

.icon-btn { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text); padding: 4px; }

/* Menu Button Overlay */
header #menuBtn {
  position: absolute;
  right: 10px;
  top: calc(env(safe-area-inset-top) + 10px);
  background: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  z-index: 101;
}
body.dark-mode header #menuBtn {
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
}

/* ── Enhanced Menu Styles ──────────────────────────────────── */
.side-menu-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); z-index: 200; display: none; opacity: 0; transition: opacity .25s; }
.side-menu-overlay.open { display: block; opacity: 1; }
.side-menu { 
  position: fixed; top: 0; right: 0; bottom: 0; width: 300px; 
  background: var(--menu-bg); z-index: 201; 
  transform: translateX(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
  box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top);
}
.side-menu.open { transform: translateX(0); }

/* Menu Header / Profile */
.menu-header { 
  padding: 20px 16px 16px; border-bottom: 1px solid var(--border); 
  display: flex; justify-content: space-between; align-items: flex-start; 
}
.menu-header h3 { margin: 0; font-size: var(--font-lg); color: var(--text); }
.menu-profile { display: flex; align-items: center; gap: 12px; flex: 1; }
.menu-avatar { 
  width: 44px; height: 44px; border-radius: 50%; background: var(--primary-light); 
  display: flex; align-items: center; justify-content: center; font-size: 20px; 
  flex-shrink: 0; overflow: hidden;
}
.menu-user-info { flex: 1; min-width: 0; }
.menu-user-name { font-size: var(--font-md); font-weight: 700; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-user-status { display: flex; align-items: center; gap: 5px; font-size: var(--font-xs); color: var(--muted); margin-top: 2px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; flex-shrink: 0; }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 2px var(--success-light); }
.status-dot.offline { background: #9ca3af; }

/* Menu Content */
.menu-content { padding: 8px 0; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.menu-divider { 
  padding: 16px 16px 6px; font-size: var(--font-xs); font-weight: 700; 
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted); 
}
.menu-item { 
  padding: 10px 16px; display: flex; align-items: center; gap: 10px; color: var(--text); 
}
.menu-item label { flex: 1; font-size: var(--font-sm); }
.menu-link { 
  display: flex; align-items: center; gap: 10px; padding: 11px 16px; 
  text-decoration: none; color: var(--text); font-size: var(--font-sm); font-weight: 500;
  border-radius: 0; transition: background .1s;
}
.menu-link:active { background: var(--primary-light); }

/* Menu link icons & badges */
.ml-icon { font-size: 18px; flex-shrink: 0; width: 24px; text-align: center; }
.ml-text { flex: 1; }
.ml-chevron { color: var(--muted); font-size: 18px; }
.ml-badge { 
  font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 10px; 
  flex-shrink: 0; text-transform: uppercase; letter-spacing: .3px;
}
.ml-badge.danger { background: var(--danger); color: #fff; }
.ml-badge.new { background: var(--primary); color: #fff; }
.ml-badge.success { background: var(--success); color: #fff; }

/* Menu Actions */
.menu-actions { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
.menu-btn { 
  width: 100%; padding: 11px; border: none; border-radius: var(--radius-md); 
  font-size: var(--font-sm); font-weight: 600; cursor: pointer; text-align: center;
}
.menu-btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.menu-btn-danger { background: var(--danger-light); color: var(--danger); }
body.dark-mode .menu-btn-danger { background: rgba(211,47,47,.2); }

/* Menu Footer */
.menu-footer { 
  padding: 12px 16px; border-top: 1px solid var(--border); 
  display: flex; justify-content: space-between; font-size: var(--font-xs); color: var(--muted);
}

/* ── Toggle Switch (iOS Style) ─────────────────────────────── */
.menu-item input[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  width: 44px; height: 24px; background: var(--border); border-radius: 12px;
  position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0;
}
.menu-item input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; background: #fff; border-radius: 50%;
  transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.menu-item input[type="checkbox"]:checked { background: var(--primary); }
.menu-item input[type="checkbox"]:checked::after { transform: translateX(20px); }

/* ── Utility Classes ────────────────────────────────────────── */
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.bg-success-light { background: var(--success-light); }
.bg-danger-light { background: var(--danger-light); }
.bg-warning-light { background: var(--warning-light); }
.bg-primary-light { background: var(--primary-light); }

/* ── Card Component ─────────────────────────────────────────── */
.dui-card {
  background: var(--card-bg); border-radius: var(--radius-lg); 
  border: 1px solid var(--border); overflow: hidden;
  box-shadow: var(--shadow-sm); margin-bottom: 12px;
}
.dui-card-header { padding: 16px 16px 0; font-size: var(--font-sm); font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.dui-card-body { padding: 16px; }
.dui-card-footer { padding: 12px 16px; border-top: 1px solid var(--border); }

/* ── Pill / Tag ──────────────────────────────────────────────── */
.dui-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px; font-size: var(--font-xs); font-weight: 600;
  background: var(--bg); color: var(--muted);
}
.dui-pill.success { background: var(--success-light); color: var(--success); }
.dui-pill.danger { background: var(--danger-light); color: var(--danger); }
.dui-pill.warning { background: var(--warning-light); color: var(--warning); }
.dui-pill.primary { background: var(--primary-light); color: var(--primary); }

/* ── Button Styles ───────────────────────────────────────────── */
.dui-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: var(--radius-md); font-size: var(--font-sm); 
  font-weight: 600; cursor: pointer; border: none; transition: all .15s;
}
.dui-btn-primary { background: var(--primary); color: #fff; }
.dui-btn-primary:active { opacity: .85; }
.dui-btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.dui-btn-danger { background: var(--danger); color: #fff; }
.dui-btn-full { width: 100%; }

/* ── Stat Grid ───────────────────────────────────────────────── */
.dui-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); gap: 8px; }
.dui-stat { text-align: center; padding: 12px 8px; background: var(--bg); border-radius: var(--radius-md); }
.dui-stat-val { font-size: var(--font-xl); font-weight: 800; color: var(--text); }
.dui-stat-lbl { font-size: var(--font-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-top: 2px; }

/* ── Section List ────────────────────────────────────────────── */
.dui-list-item {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px; background: var(--card-bg); 
  border-bottom: 1px solid var(--border); cursor: pointer;
  text-decoration: none; color: inherit; transition: background .1s;
}
.dui-list-item:active { background: var(--bg); }
.dui-list-icon { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }
.dui-list-body { flex: 1; min-width: 0; }
.dui-list-title { font-size: var(--font-md); font-weight: 600; color: var(--text); }
.dui-list-desc { font-size: var(--font-sm); color: var(--muted); margin-top: 1px; }
.dui-list-chevron { color: var(--muted); font-size: 20px; flex-shrink: 0; }

/* ── Section Title ───────────────────────────────────────────── */
.dui-section-title {
  padding: 16px 16px 6px; font-size: var(--font-xs); font-weight: 700;
  text-transform: uppercase; letter-spacing: .5px; color: var(--muted);
}

/* ── Empty State ─────────────────────────────────────────────── */
.dui-empty { padding: 60px 20px; text-align: center; }
.dui-empty-icon { font-size: 48px; margin-bottom: 12px; }
.dui-empty-msg { font-size: var(--font-md); color: var(--muted); margin-bottom: 16px; }
