/* ============================================================
   KI Business Compass — Modern Theme Redesign
   Brand: Cyan #00BCD4 · Blue #4285F4 · Purple #7C6FCD · Magenta #B565D4
   Modern, High-Contrast, Mobile-First Design
   ============================================================ */

/* ── CSS Custom Properties ─────────────────────────────────── */
:root {
  --cyan:    #00BCD4;
  --blue:    #4285F4;
  --purple:  #7C6FCD;
  --magenta: #B565D4;

  --grad-primary: linear-gradient(135deg, #00BCD4 0%, #4285F4 40%, #7C6FCD 70%, #B565D4 100%);
  --grad-card:    linear-gradient(135deg, rgba(0,188,212,.08) 0%, rgba(66,133,244,.08) 100%);
  --grad-sidebar: linear-gradient(180deg, #1a2332 0%, #0f1620 100%);

  /* Light theme backgrounds */
  --bg:        #FFFFFF;
  --bg-alt:    #F9FAFB;
  --surface:   #FFFFFF;
  --surface2:  #F3F4F6;
  --border:    #E5E7EB;
  --text:      #111827;
  --text-muted:#6B7280;
  --text-light:#9CA3AF;

  --sidebar-w: 260px;
  --topbar-h:  64px;

  --radius-sm: 10px;
  --radius:    16px;
  --radius-lg: 24px;
  --radius-xl: 32px;

  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  --shadow:    0 4px 16px rgba(0,0,0,.08);
  --shadow-lg: 0 12px 32px rgba(0,0,0,.12);
  --shadow-colored: 0 12px 40px rgba(66,133,244,.15);
  --shadow-hover: 0 8px 24px rgba(66,133,244,.2);

  --transition: all .24s cubic-bezier(.4,0,.2,1);

  --dept-op:  #00BCD4;
  --dept-tr:  #4285F4;
  --dept-sa:  #B565D4;
  --dept-co:  #7C6FCD;
  --dept-mg:  #FF9800;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }
img { max-width: 100%; display: block; }
ul { list-style: none; }

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--grad-sidebar);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  border-right: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  gap: 0;
}
.sidebar-logo img {
  filter: drop-shadow(0 4px 12px rgba(0,188,212,.35));
  width: 56px;
  height: auto;
  border-radius: var(--radius-lg);
  transition: var(--transition);
}
.sidebar-logo img:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 6px 16px rgba(0,188,212,.45));
}
.logo-icon { flex-shrink: 0; }
.logo-text { display: flex; flex-direction: column; }
.logo-main {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 800;
  font-size: 13px;
  color: #FFFFFF;
  letter-spacing: .5px;
  margin-top: 12px;
  text-align: center;
}
.logo-sub {
  font-size: 9px;
  color: rgba(255,255,255,.5);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  margin-top: auto;
}
.user-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: #FFF;
  flex-shrink: 0;
  background: var(--grad-primary);
}
.user-name { font-size: 13px; font-weight: 600; color: #FFF; }
.user-role { font-size: 11px; color: rgba(255,255,255,.5); margin-top: 1px; }

.sidebar-nav { padding: 8px 0; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.65);
  border-radius: 0;
  transition: var(--transition);
  position: relative;
  margin: 0 8px;
}
.nav-item:hover { 
  color: #FFF; 
  background: rgba(255,255,255,.08); 
  border-radius: var(--radius-lg);
}
.nav-item.active {
  color: #FFF;
  background: var(--grad-primary);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(66,133,244,.25);
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 0;
}
.nav-item i { width: 18px; font-size: 15px; text-align: center; flex-shrink: 0; }
.nav-item span { flex: 1; }
.nav-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 100px;
  letter-spacing: .5px;
  background: rgba(255,255,255,.2);
  color: #FFF;
}
.live-badge { 
  background: #EF4444; 
  color: #FFF; 
  animation: pulseBadge 2s infinite;
  box-shadow: 0 0 12px rgba(239,68,68,.4);
}
@keyframes pulseBadge { 0%,100%{opacity:1} 50%{opacity:.7} }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.btn-signout {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255,255,255,.5);
  padding: 10px 14px;
  border-radius: var(--radius);
  transition: var(--transition);
  width: 100%;
}
.btn-signout:hover { 
  color: #FFF;
  background: rgba(239,68,68,.2); 
}

/* ── Main Wrapper ──────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left .3s cubic-bezier(.4,0,.2,1);
  background: var(--bg-alt);
}

/* ── Topbar ────────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 28px;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}
.hamburger {
  font-size: 18px;
  color: var(--text-muted);
  display: none;
  padding: 10px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius);
  transition: var(--transition);
  position: relative;
}
.hamburger:hover { background: rgba(66,133,244,.08); color: var(--blue); }
.hamburger:active { background: rgba(66,133,244,.12); }
.topbar-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 8px 12px;
}
.topbar-logo img {
  filter: drop-shadow(0 2px 8px rgba(66,133,244,.2));
  height: 36px;
  width: auto;
  border-radius: var(--radius-lg);
}
.topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.topbar-search i {
  position: absolute; left: 16px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: 14px; pointer-events: none;
}
.topbar-search input {
  width: 100%;
  padding: 11px 16px 11px 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: var(--transition);
}
.topbar-search input:focus { 
  border-color: var(--blue); 
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(66,133,244,.1);
}
.topbar-search input::placeholder {
  color: var(--text-light);
}

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 300;
}
.search-results.show { display: block; animation: slideDown .2s ease; }
@keyframes slideDown { from{opacity:0;transform:translateY(-8px)} to{opacity:1;transform:none} }
.search-result-item {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--surface2); }
.search-result-item .sr-badge {
  font-size: 10px; padding: 3px 8px; border-radius: 100px;
  font-weight: 600;
  background: rgba(66,133,244,.1); color: var(--blue);
}

.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.role-badge {
  font-size: 11px; font-weight: 700;
  padding: 5px 13px; border-radius: 100px;
  letter-spacing: .5px;
  background: rgba(66,133,244,.1);
  color: var(--blue);
  border: 1px solid rgba(66,133,244,.3);
}
.admin-badge { 
  color: var(--purple); 
  background: rgba(124,111,205,.1); 
  border-color: rgba(124,111,205,.3); 
}

.notif-btn {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--surface2);
  border: 1.5px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 16px;
  transition: var(--transition);
  min-width: 44px;
  min-height: 44px;
  padding: 2px;
}
.notif-btn:hover { 
  border-color: var(--blue); 
  color: var(--blue);
  background: rgba(66,133,244,.05);
}
.notif-btn:active { background: rgba(66,133,244,.1); }
.notif-count {
  position: absolute; top: -6px; right: -6px;
  min-width: 20px; height: 20px;
  background: #EF4444; color: #FFF;
  font-size: 10px; font-weight: 700;
  border-radius: 100px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 5px;
  box-shadow: 0 2px 8px rgba(239,68,68,.3);
}

.notif-dropdown {
  position: absolute; right: 28px; top: calc(var(--topbar-h) + 8px);
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: none; z-index: 300;
}
.notif-dropdown.show { display: block; animation: fadeDown .2s ease; }
@keyframes fadeDown { from{opacity:0;transform:translateY(-12px)} to{opacity:1;transform:none} }
.notif-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 700; font-size: 14px;
}
.mark-all-read { font-size: 12px; color: var(--blue); font-weight: 600; cursor: pointer; }
.notif-list { max-height: 340px; overflow-y: auto; }
.notif-item {
  display: flex; gap: 12px;
  padding: 14px 20px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid var(--border);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--surface2); }
.notif-item.unread { background: rgba(66,133,244,.05); }
.notif-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.notif-icon.type-task    { background: rgba(66,133,244,.15); color: var(--blue); }
.notif-icon.type-meeting { background: rgba(0,188,212,.15);  color: var(--cyan); }
.notif-icon.type-kpi     { background: rgba(181,101,212,.15);color: var(--magenta); }
.notif-icon.type-system  { background: rgba(124,111,205,.15);color: var(--purple); }
.notif-title { font-size: 13.5px; font-weight: 600; }
.notif-msg   { font-size: 12.5px; color: var(--text-muted); margin-top: 3px; }
.notif-time  { font-size: 11px; color: var(--text-light); margin-top: 6px; }
.notif-empty { text-align: center; padding: 32px; color: var(--text-muted); font-size: 13.5px; }

/* ── Page Content ──────────────────────────────────────────── */
.page-content { 
  padding: 32px 28px; 
  flex: 1; 
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header { margin-bottom: 32px; }
.page-header h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px; font-weight: 800;
  color: #111827;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}
.page-header p { 
  font-size: 15px; 
  color: #374151;
  font-weight: 500;
  margin-top: 4px;
}
.page-header-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap;
}

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}
.stat-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1.5px solid #E5E7EB;
  position: relative;
  overflow: hidden;
  transition: var(--transition);
}
.stat-card:hover { 
  transform: translateY(-4px); 
  box-shadow: 0 8px 24px rgba(66,133,244,.15);
  border-color: #4285F4;
}
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: linear-gradient(90deg, #4285F4, #7C6FCD);
}
.stat-icon {
  width: 52px; height: 52px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; margin-bottom: 16px;
}
.stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 32px; font-weight: 800; line-height: 1;
  color: var(--text);
}
.stat-label { 
  font-size: 12px; 
  color: var(--text-muted); 
  margin-top: 6px; 
  font-weight: 600; 
  text-transform: uppercase; 
  letter-spacing: .6px; 
}
.stat-change { font-size: 13px; margin-top: 10px; font-weight: 600; }
.stat-change.up   { color: #22C55E; }
.stat-change.down { color: #EF4444; }

/* Icon color themes */
.icon-cyan    { background: rgba(0,188,212,.15);   color: var(--cyan); }
.icon-blue    { background: rgba(66,133,244,.15);  color: var(--blue); }
.icon-purple  { background: rgba(124,111,205,.15); color: var(--purple); }
.icon-magenta { background: rgba(181,101,212,.15); color: var(--magenta); }
.icon-green   { background: rgba(34,197,94,.15);   color: #22C55E; }
.icon-orange  { background: rgba(249,115,22,.15);  color: #F97316; }
.icon-red     { background: rgba(239,68,68,.15);   color: #EF4444; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  border: 1.5px solid #E5E7EB;
  overflow: clip;
  box-shadow: 0 2px 8px rgba(0,0,0,.04);
  transition: var(--transition);
}
.card:hover {
  border-color: #4285F4;
  box-shadow: 0 4px 16px rgba(66,133,244,.12);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 2px solid #E5E7EB;
  background: linear-gradient(135deg, #F3F4F6 0%, #F9FAFB 100%);
}
.card-title { 
  font-size: 16px; 
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.3px;
}
.card-body { 
  padding: 24px; 
  color: #1F2937;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 24px;
  border-radius: var(--radius);
  font-size: 14px; font-weight: 700;
  transition: var(--transition);
  white-space: nowrap;
  border: none;
  cursor: pointer;
  letter-spacing: 0.3px;
}
.btn-primary {
  background: linear-gradient(135deg, #4285F4 0%, #7C6FCD 100%);
  color: #FFFFFF;
  box-shadow: 0 4px 16px rgba(66,133,244,.3);
}
.btn-primary:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 6px 20px rgba(66,133,244,.4);
}
.btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(66,133,244,.2);
}
.btn-outline {
  border: 1.5px solid #D1D5DB;
  color: #1F2937;
  background: #FFFFFF;
  font-weight: 600;
}
.btn-outline:hover { 
  border-color: #4285F4; 
  color: #4285F4;
  background: #F0F4FF;
}
.btn-danger { background: #EF4444; color: #FFF; box-shadow: 0 2px 8px rgba(239,68,68,.2); }
.btn-danger:hover { background: #DC2626; box-shadow: 0 4px 12px rgba(239,68,68,.3); }
.btn-success { background: #22C55E; color: #FFF; box-shadow: 0 2px 8px rgba(34,197,94,.2); }
.btn-success:hover { background: #16A34A; box-shadow: 0 4px 12px rgba(34,197,94,.3); }
.btn-info { background: var(--blue); color: #FFF; }
.btn-info:hover { background: #3B82F6; }
.btn-warning { background: #F59E0B; color: #FFF; }
.btn-warning:hover { background: #D97706; }
.btn-sm { padding: 8px 16px; font-size: 13px; }
.btn-xs { padding: 5px 12px; font-size: 12px; border-radius: 8px; }

/* ── Badges / Pills ────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  padding: 6px 14px; border-radius: 100px;
  letter-spacing: 0.3px;
  border: 1px solid;
}
.badge-green   { background: #DCFCE7; color: #166534; border-color: #86EFAC; }
.badge-amber   { background: #FEF3C7; color: #92400E; border-color: #FCD34D; }
.badge-red     { background: #FEE2E2; color: #991B1B; border-color: #FECACA; }
.badge-blue    { background: #EFF6FF; color: #1E40AF; border-color: #BFDBFE; }
.badge-purple  { background: #F3E8FF; color: #6B21A8; border-color: #E9D5FF; }
.badge-cyan    { background: #ECFDFF; color: #0e556a; border-color: #A5F3FC; }
.badge-magenta { background: #FDF2F8; color: #831843; border-color: #FBCFE8; }

.dept-badge {
  display: inline-flex; align-items: center;
  font-size: 12px; font-weight: 700;
  padding: 6px 14px; border-radius: 100px;
  border: 1px solid;
}

/* ── Status Pills ──────────────────────────────────────────── */
.status-open       { background: #FEE2E2; color: #991B1B; font-weight: 700; border: 1px solid #FECACA; }
.status-in_progress{ background: #FEF3C7; color: #92400E; font-weight: 700; border: 1px solid #FCD34D; }
.status-completed  { background: #DCFCE7; color: #166534; font-weight: 700; border: 1px solid #86EFAC; }
.status-live       { background: #FEE2E2; color: #991B1B; font-weight: 700; border: 1px solid #FECACA; }

/* ── Action Buttons Group ──────────────────────────────────── */
.action-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.action-buttons .btn-xs {
  display: inline-flex;
  padding: 7px 10px;
  transition: var(--transition);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 20px; }
.form-label { 
  display: block; 
  font-size: 13.5px; 
  font-weight: 600; 
  margin-bottom: 8px; 
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid #D1D5DB;
  border-radius: var(--radius);
  font-size: 14px; 
  color: #1F2937;
  background: #FFFFFF;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
  font-weight: 500;
}
.form-control:focus { 
  border-color: #4285F4; 
  box-shadow: 0 0 0 3px rgba(66,133,244,.15);
  background: #FFFFFF;
}
.form-control:disabled { 
  background: #F3F4F6; 
  cursor: not-allowed; 
  opacity: 0.6;
}
.form-control::placeholder {
  color: #9CA3AF;
  font-weight: 500;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 5px; }

/* ── Tables ────────────────────────────────────────────────– */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; 
  padding: 16px 18px;
  font-size: 12px; 
  font-weight: 700;
  text-transform: uppercase; 
  letter-spacing: 0.8px;
  color: #FFFFFF !important;
  background: linear-gradient(135deg, #4285F4 0%, #7C6FCD 100%) !important;
  border-bottom: 2px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
}
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
  font-weight: 500;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: var(--transition); background: #FFFFFF; }
tbody tr:hover { 
  background: #F0F4FF;
  box-shadow: inset 0 0 12px rgba(66,133,244,.08);
}
tbody tr:nth-child(even) {
  background: #FAFBFC;
}

/* ── Responsive ────────────────────────────────────────────– */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 768px) {
  :root { 
    --sidebar-w: 100%;
    --radius: 12px;
    --radius-lg: 18px;
  }
  
  .sidebar { 
    width: 100%;
    height: auto;
    max-height: 100vh;
    transform: translateX(-100%); 
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.2); }
  
  .main-wrapper { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar { padding: 0 16px; height: 56px; }
  .page-header h1 { font-size: 22px; }
  .page-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 16px; margin-bottom: 24px; }
  .stat-card { padding: 18px; }
  .stat-value { font-size: 24px; }
  .stat-icon { width: 40px; height: 40px; font-size: 20px; }
  
  .card { border-radius: var(--radius-lg); }
  .form-row { grid-template-columns: 1fr; }
  .topbar-search { max-width: 100%; }
  .team-grid { grid-template-columns: 1fr 1fr; }
  table { font-size: 13px; }
  td, th { padding: 12px 12px; }
}

@media (max-width: 480px) {
  :root { 
    --sidebar-w: 100%;
    font-size: 15px;
    --radius: 10px;
    --radius-lg: 16px;
  }
  
  .stats-grid { 
    grid-template-columns: 1fr; 
    gap: 12px;
    margin-bottom: 20px;
  }
  .stat-card { 
    padding: 16px; 
  }
  .stat-value { font-size: 22px; }
  .stat-label { font-size: 11px; }
  
  .page-header h1 { font-size: 18px; }
  .page-content { padding: 16px 12px; }
  
  .team-grid { grid-template-columns: 1fr; }
  .modal-box { width: 95%; padding: 24px; }
  .card { border-radius: var(--radius-lg); }
  
  /* Larger touch targets on mobile */
  button, .btn, input, select, textarea {
    min-height: 44px;
    font-size: 16px; /* Prevents iOS auto-zoom */
    padding: 11px 16px;
  }
  
  .nav-item {
    padding: 14px 16px;
    min-height: 48px;
    font-size: 14px;
  }
  
  /* Mobile optimized tables */
  table { font-size: 13px; }
  td, th { padding: 10px 8px; }
  
  /* Mobile form optimization */
  .form-control {
    padding: 12px 14px;
    min-height: 44px;
    font-size: 16px;
  }
  
  select.form-control {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 18px;
    padding-right: 40px;
  }
}

/* Safe area insets (iPhone X, iPad notches) */
@supports (padding: max(0px)) {
  .topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  
  .sidebar {
    padding-left: max(0px, env(safe-area-inset-left));
  }
  
  .page-content {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
}

/* iPad specific optimizations */
@media (min-width: 768px) and (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .team-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { margin-bottom: 24px; }
}

/* Landscape orientation */
@media (max-height: 600px) and (orientation: landscape) {
  .sidebar { max-height: 100vh; overflow-y: auto; }
  .topbar { height: 48px; padding: 0 12px; }
  .page-content { padding: 12px 16px; }
  .stats-grid { gap: 12px; margin-bottom: 16px; }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  button:active, .btn:active { opacity: 0.85; transform: scale(0.98); }
  a:active { opacity: 0.7; }
  .notif-btn:active { background: rgba(66,133,244,.1); }
  
  /* Larger touch targets on touch devices */
  button, .btn, a[role="button"] { 
    min-width: 44px;
    min-height: 44px;
  }
  input[type="checkbox"], 
  input[type="radio"] { 
    min-width: 24px; 
    min-height: 24px; 
  }
}

/* High DPI displays */
@media (min-width: 1920px) {
  :root {
    --sidebar-w: 300px;
    font-size: 17px;
  }
  .page-header h1 { font-size: 32px; }
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
.action-buttons {
  display: flex;
  gap: 6px;
  align-items: center;
}
.action-buttons .btn-xs {
  display: inline-flex;
  padding: 6px 8px;
  transition: var(--transition);
}

/* ── Alert Messages ────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
}
.alert-warning {
  background: rgba(245,158,11,.1);
  border: 1px solid rgba(245,158,11,.2);
  color: #92400E;
}
.alert-warning i {
  color: #D97706;
  flex-shrink: 0;
  margin-top: 2px;
}
.alert-danger {
  background: rgba(239,68,68,.1);
  border: 1px solid rgba(239,68,68,.2);
  color: #7F1D1D;
}
.alert-success {
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.2);
  color: #15803D;
}
.alert-info {
  background: rgba(66,133,244,.1);
  border: 1px solid rgba(66,133,244,.2);
  color: #1E40AF;
}
/* ── KPI Progress ──────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 22px;
  border: 1px solid var(--border);
  transition: var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 14px; }
.kpi-title { font-size: 14px; font-weight: 600; }
.kpi-dept  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.kpi-values {
  display: flex; align-items: baseline; gap: 6px; margin-bottom: 12px;
}
.kpi-current {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px; font-weight: 700;
}
.kpi-target { font-size: 12px; color: var(--text-muted); }
.kpi-bar-bg {
  height: 8px; border-radius: 100px;
  background: var(--surface2);
  border: 1px solid var(--border);
  overflow: hidden;
}
.kpi-bar-fill {
  height: 100%; border-radius: 100px;
  transition: width .8s cubic-bezier(.4,0,.2,1);
}
.kpi-green  .kpi-bar-fill { background: linear-gradient(90deg, #22C55E, #86EFAC); }
.kpi-amber  .kpi-bar-fill { background: linear-gradient(90deg, #F59E0B, #FCD34D); }
.kpi-red    .kpi-bar-fill { background: linear-gradient(90deg, #EF4444, #FCA5A5); }
.kpi-green  .kpi-current { color: #16A34A; }
.kpi-amber  .kpi-current { color: #D97706; }
.kpi-red    .kpi-current { color: #DC2626; }
.kpi-pct { font-size: 12px; font-weight: 600; margin-top: 6px; }
.kpi-footer { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; }
.kpi-remaining { font-size: 11px; color: var(--text-muted); }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 16px 18px;
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.8px;
  color: #FFFFFF !important;
  background: linear-gradient(135deg, #4285F4 0%, #7C6FCD 100%) !important;
  border-bottom: 2px solid var(--border);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.1);
}
td {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
  font-weight: 500;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: var(--transition); background: #FFFFFF; }
tbody tr:hover { 
  background: #F0F4FF;
  box-shadow: inset 0 0 12px rgba(66,133,244,.08);
  border-left: 3px solid var(--blue);
  padding-left: 15px;
}
tbody tr:nth-child(even) {
  background: #FAFBFC;
}

/* ── Member Cards (Teams page) ─────────────────────────────── */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 18px;
}
.member-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--border);
  text-align: center;
  transition: var(--transition);
  position: relative;
}
.member-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.member-avatar {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
  color: #FFF;
  margin: 0 auto 14px;
  position: relative;
}
.member-status-dot {
  position: absolute; bottom: 2px; right: 2px;
  width: 14px; height: 14px; border-radius: 50%;
  background: #22C55E;
  border: 2px solid var(--surface);
}
.member-name { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.member-title { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.member-contacts { font-size: 12px; color: var(--text-muted); display: flex; flex-direction: column; gap: 4px; margin-top: 10px; }
.member-contacts a { display: flex; align-items: center; gap: 6px; justify-content: center; transition: var(--transition); }
.member-contacts a:hover { color: var(--blue); }
.reports-to { font-size: 11px; color: var(--text-light); margin-top: 8px; }

/* ── Leaderboard Podium ────────────────────────────────────── */
.podium {
  display: flex; align-items: flex-end; justify-content: center;
  gap: 16px; padding: 32px 0 0;
  margin-bottom: 32px;
}
.podium-slot {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-width: 120px;
}
.podium-rank-label {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--text-muted);
}
.podium-avatar {
  width: 64px; height: 64px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #FFF;
  position: relative;
}
.podium-avatar .medal {
  position: absolute; bottom: -6px; right: -6px;
  font-size: 20px; line-height: 1;
}
.podium-name { font-size: 13px; font-weight: 700; text-align: center; }
.podium-dept { font-size: 11px; color: var(--text-muted); }
.podium-score {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px; font-weight: 700; color: var(--blue);
}
.podium-base {
  width: 100%;
  border-radius: var(--radius) var(--radius) 0 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; font-weight: 800; color: rgba(255,255,255,.4);
}
.podium-slot:nth-child(1) .podium-base { height: 80px; background: linear-gradient(180deg, #C0A960, #A08832); }
.podium-slot:nth-child(2) .podium-base { height: 110px; background: var(--grad-primary); }
.podium-slot:nth-child(3) .podium-base { height: 64px; background: linear-gradient(180deg, #9AABB8, #7B8E99); }
.podium-slot:nth-child(2) .podium-avatar { width: 80px; height: 80px; font-size: 26px; }

.leaderboard-list { display: flex; flex-direction: column; gap: 10px; }
.lb-row {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px;
  background: var(--surface2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: var(--transition);
}
.lb-row:hover { background: var(--surface); box-shadow: var(--shadow-sm); }
.lb-rank {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  background: var(--surface);
  border: 1.5px solid var(--border);
  color: var(--text-muted);
  flex-shrink: 0;
}
.lb-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; color: #FFF;
  flex-shrink: 0;
}
.lb-info { flex: 1; }
.lb-name { font-size: 14px; font-weight: 600; }
.lb-meta { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.lb-score {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 16px; font-weight: 700; color: var(--blue);
}

/* ── Calendar Grid ─────────────────────────────────────────── */
.attendance-calendar {
  display: grid; grid-template-columns: repeat(7, 1fr);
  gap: 6px; padding: 16px;
}
.cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
  transition: var(--transition);
}
.cal-day.present   { background: rgba(34,197,94,.15);  color: #16A34A; }
.cal-day.absent    { background: rgba(239,68,68,.12);  color: #DC2626; }
.cal-day.weekend   { background: var(--surface2); color: var(--text-light); }
.cal-day.future    { background: var(--surface2); color: var(--text-light); opacity: .5; }
.cal-day.today     { border: 2px solid var(--blue); }

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px; color: var(--text);
  background: var(--surface);
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none; /* Remove iOS default styling */
  appearance: none;
}
.form-control:focus { 
  border-color: var(--blue); 
  box-shadow: 0 0 0 3px rgba(66,133,244,.1); 
}
.form-control:disabled { 
  background: var(--surface2); 
  cursor: not-allowed; 
  opacity: 0.6;
}

/* Mobile-optimized form controls */
@media (max-width: 768px) {
  .form-control {
    font-size: 16px; /* Prevent iOS auto-zoom */
    padding: 12px 16px;
    min-height: 44px;
  }
  
  select.form-control {
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><polyline points="6 9 12 15 18 9"></polyline></svg>');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
    padding-right: 40px;
  }
  
  textarea.form-control {
    resize: vertical;
    min-height: 100px;
  }
}

/* Remove default iOS styling from checkboxes and radios */
input[type="checkbox"],
input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  outline: none;
  transition: var(--transition);
}

input[type="checkbox"]:checked,
input[type="radio"]:checked {
  background: var(--blue);
  border-color: var(--blue);
}

input[type="radio"] {
  border-radius: 50%;
}

/* Mobile-friendly select */
select {
  -webkit-appearance: none;
  appearance: none;
}

/* Better mobile file input */
input[type="file"] {
  padding: 8px;
}

input[type="file"]::file-selector-button {
  padding: 8px 14px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 600;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--surface2); border-radius: var(--radius); border: 1px solid var(--border); }
.tab-btn {
  padding: 8px 18px;
  border-radius: calc(var(--radius) - 2px);
  font-size: 13px; font-weight: 600;
  color: var(--text-muted);
  transition: var(--transition);
}
.tab-btn.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(13,27,42,.55);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: none; align-items: center; justify-content: center;
}
.modal-overlay.show { display: flex; animation: fadeIn .18s ease; }
.modal-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 32px;
  width: 90%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  position: relative;
  animation: slideUp .22s cubic-bezier(.4,0,.2,1);
}
.modal-close {
  position: absolute; top: 18px; right: 18px;
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--surface2);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 14px;
  transition: var(--transition);
}
.modal-close:hover { background: #EF4444; color: #FFF; }
.modal-title { font-family: 'Space Grotesk', sans-serif; font-size: 20px; font-weight: 700; margin-bottom: 24px; }
@keyframes fadeIn  { from{opacity:0} to{opacity:1} }
@keyframes slideUp { from{opacity:0;transform:translateY(20px)} to{opacity:1;transform:none} }

/* ── Toast ─────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 600; display: flex; flex-direction: column; gap: 10px; }
.toast {
  min-width: 280px; max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 14px 18px;
  display: flex; align-items: flex-start; gap: 12px;
  animation: toastIn .25s cubic-bezier(.4,0,.2,1);
}
.toast.removing { animation: toastOut .2s ease forwards; }
@keyframes toastIn  { from{opacity:0;transform:translateX(40px)} to{opacity:1;transform:none} }
@keyframes toastOut { from{opacity:1;transform:none} to{opacity:0;transform:translateX(40px)} }
.toast-icon { font-size: 16px; flex-shrink: 0; padding-top: 2px; }
.toast.success .toast-icon { color: #22C55E; }
.toast.error   .toast-icon { color: #EF4444; }
.toast.info    .toast-icon { color: var(--blue); }
.toast-msg { font-size: 13.5px; line-height: 1.5; }

/* ── Landing Page ──────────────────────────────────────────── */
.landing-body { margin: 0; display: block; background: #0D1B2A; min-height: 100vh; }
.landing-hero {
  min-height: 100vh;
  background: linear-gradient(135deg, #0D1B2A 0%, #0A1F3D 50%, #13133A 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 40px 24px;
  position: relative; overflow: hidden;
}
.landing-hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% 30%, rgba(66,133,244,.18) 0%, transparent 70%),
              radial-gradient(ellipse 60% 40% at 80% 70%, rgba(181,101,212,.12) 0%, transparent 60%),
              radial-gradient(ellipse 50% 40% at 20% 60%, rgba(0,188,212,.1) 0%, transparent 60%);
}
.hero-content { position: relative; z-index: 1; max-width: 700px; }
.hero-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 100px; padding: 6px 16px;
  font-size: 12px; font-weight: 600; color: rgba(255,255,255,.7);
  letter-spacing: .5px; text-transform: uppercase;
  margin-bottom: 28px;
}
.hero-badge-dot { width: 8px; height: 8px; border-radius: 50%; background: #22C55E; animation: pulseBadge 2s infinite; }
.hero-logo-mark {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  margin-bottom: 24px;
}
.hero-wordmark {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px; font-weight: 700; color: #FFF; text-align: left;
}
.hero-wordmark span { font-size: 11px; font-weight: 400; color: rgba(255,255,255,.45); display: block; letter-spacing: 2px; text-transform: uppercase; }
.hero-h1 {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 800; color: #FFF;
  line-height: 1.1; margin-bottom: 20px;
}
.hero-h1 .grad-text {
  background: var(--grad-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-tagline { font-size: 18px; color: rgba(255,255,255,.6); margin-bottom: 40px; line-height: 1.6; }
.hero-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.btn-hero-primary {
  padding: 15px 36px;
  background: var(--grad-primary);
  color: #FFF; border-radius: var(--radius-lg);
  font-size: 16px; font-weight: 700;
  box-shadow: 0 8px 32px rgba(66,133,244,.4);
  transition: var(--transition);
}
.btn-hero-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 40px rgba(66,133,244,.5); }
.btn-hero-secondary {
  padding: 15px 36px;
  background: rgba(255,255,255,.06);
  color: #FFF; border-radius: var(--radius-lg);
  border: 1.5px solid rgba(255,255,255,.12);
  font-size: 16px; font-weight: 600;
  transition: var(--transition);
}
.btn-hero-secondary:hover { background: rgba(255,255,255,.1); }

.hero-stats {
  display: flex; gap: 48px; justify-content: center;
  margin-top: 60px; padding-top: 40px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-wrap: wrap;
}
.hero-stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 36px; font-weight: 800;
  background: var(--grad-primary);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-stat-label { font-size: 13px; color: rgba(255,255,255,.5); margin-top: 4px; }

.glance-card {
  margin-top: 60px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius-xl);
  padding: 28px;
  text-align: left; max-width: 440px; width: 100%;
}
.glance-title {
  font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.5px;
  color: rgba(255,255,255,.4); margin-bottom: 16px;
}
.glance-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,.06);
}
.glance-row:last-child { border-bottom: none; }
.glance-key { font-size: 13px; color: rgba(255,255,255,.6); }
.glance-val { font-size: 13px; font-weight: 600; color: #FFF; }

/* ── Dashboard Welcome Banner ──────────────────────────────── */
.welcome-banner {
  background: var(--grad-primary);
  border-radius: var(--radius-xl);
  padding: 28px 32px;
  margin-bottom: 28px;
  position: relative; overflow: hidden;
  color: #FFF;
}
.welcome-banner::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 200px; height: 200px; border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.welcome-banner::before {
  content: '';
  position: absolute; right: 60px; bottom: -50px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.welcome-text { position: relative; z-index: 1; }
.welcome-text h2 { font-family: 'Space Grotesk', sans-serif; font-size: 22px; font-weight: 700; }
.welcome-text p  { font-size: 14px; opacity: .85; margin-top: 4px; }
.welcome-meta    { display: flex; gap: 20px; margin-top: 16px; flex-wrap: wrap; }
.welcome-chip {
  display: flex; align-items: center; gap: 7px;
  background: rgba(255,255,255,.15);
  border-radius: 100px; padding: 6px 14px;
  font-size: 12.5px; font-weight: 500;
}

/* ── Live indicator ────────────────────────────────────────── */
.live-indicator {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: #EF4444;
  letter-spacing: .5px;
}
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #EF4444; animation: pulseLive 1.5s infinite; }
@keyframes pulseLive { 0%,100%{transform:scale(1);opacity:1} 50%{transform:scale(1.3);opacity:.7} }

/* ── Toggle (Settings) ─────────────────────────────────────── */
.toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 0; border-bottom: 1px solid var(--border); }
.toggle-row:last-child { border-bottom: none; }
.toggle-label h4 { font-size: 14px; font-weight: 600; }
.toggle-label p  { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle {
  position: relative; width: 44px; height: 24px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border); border-radius: 100px; cursor: pointer;
  transition: var(--transition);
}
.toggle-slider::before {
  content: '';
  position: absolute; left: 3px; top: 3px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #FFF; transition: var(--transition);
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
}
.toggle input:checked + .toggle-slider { background: var(--grad-primary); }
.toggle input:checked + .toggle-slider::before { transform: translateX(20px); }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 32px rgba(0,0,0,.3); }
  .main-wrapper { margin-left: 0; }
  .hamburger { display: flex; }
  .topbar { padding: 0 16px; }
  .page-content { padding: 20px 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .podium { flex-wrap: wrap; }
  .team-grid { grid-template-columns: 1fr 1fr; }
  .hero-stats { gap: 28px; }
  .welcome-banner { padding: 20px; }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .team-grid { grid-template-columns: 1fr; }
  .hero-h1 { font-size: 30px; }
  
  /* Mobile-optimized form fields */
  input, select, textarea {
    font-size: 16px; /* Prevents auto-zoom on iOS */
    padding: 12px 14px;
    min-height: 44px; /* iOS touch target */
  }
  
  /* Buttons - larger touch targets on mobile */
  button, .btn {
    min-height: 44px;
    min-width: 44px;
    padding: 10px 16px;
    font-size: 16px;
  }
  
  /* Mobile nav items - larger tap targets */
  .nav-item {
    padding: 14px 16px;
    min-height: 48px;
    font-size: 14px;
  }
  
  /* Better mobile search */
  .topbar-search {
    max-width: 100%;
    flex: 1;
    margin: 0 8px;
  }
  
  /* Stack form rows vertically */
  .form-row { grid-template-columns: 1fr; }
  
  /* Mobile table optimization */
  table { font-size: 14px; }
  td, th { padding: 10px 8px; }
  
  /* Modal on mobile */
  .modal-box {
    width: 95%;
    max-height: 85vh;
    margin: auto;
  }
}

/* Safe area insets for notch support (iPhone X+) */
@supports (padding: max(0px)) {
  body {
    padding-left: max(0px, env(safe-area-inset-left));
    padding-right: max(0px, env(safe-area-inset-right));
  }
  
  .topbar {
    padding-left: max(16px, env(safe-area-inset-left));
    padding-right: max(16px, env(safe-area-inset-right));
  }
  
  .sidebar {
    padding-left: max(0px, env(safe-area-inset-left));
  }
}

/* Landscape orientation adjustments */
@media (max-height: 600px) and (orientation: landscape) {
  .sidebar { display: none; }
  .hamburger { display: flex; }
  .main-wrapper { margin-left: 0; }
  .page-content { padding: 12px; }
  .topbar { padding: 8px 12px; }
  input, select, textarea, button { padding: 8px 12px; min-height: 40px; }
}

/* Extra small devices (< 360px) */
@media (max-width: 359px) {
  :root { font-size: 14px; }
  .sidebar { width: 100%; }
  .hamburger { font-size: 16px; }
  input, select, textarea { padding: 10px 12px; }
  .page-content { padding: 12px; }
}

/* Touch-friendly adjustments */
@media (hover: none) and (pointer: coarse) {
  /* Remove hover effects on touch devices */
  button:hover { background: unset; }
  .nav-item:hover { background: unset; }
  a:active { opacity: 0.7; }
  
  /* Add active states instead */
  button:active, .btn:active { opacity: 0.8; }
  .nav-item:active { background: rgba(0,188,212,.15); }
  
  /* Larger interactive elements */
  .notif-btn { min-width: 48px; min-height: 48px; }
  input[type="checkbox"], input[type="radio"] { min-width: 24px; min-height: 24px; }
}

/* Improve readability on high-density displays */
@media (min-width: 1920px) {
  :root {
    --sidebar-w: 280px;
    font-size: 17px;
  }
}

/* Dark mode preferences (OS) — skipped if user manually chose light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0B1220;
    --bg-alt: #0E1626;
    --surface: #131C2E;
    --surface2: #1B2740;
    --border: #26324B;
    --text: #E7ECF3;
    --text-muted: #9AA6B8;
    --text-light: #6B7893;
    --grad-card: linear-gradient(135deg, rgba(0,188,212,.10) 0%, rgba(124,111,205,.10) 100%);
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ── Utility ───────────────────────────────────────────────── */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.full-width { width: 100%; }
.separator { height: 1px; background: var(--border); margin: 20px 0; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-state i { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-state p  { font-size: 14px; }

/* ════════════════════════════════════════════════════════════
   MODERN UI + FULL MOBILE RESPONSIVENESS  (appended — overrides above)
   Upgrades every page that uses shared classes, in one place.
   ════════════════════════════════════════════════════════════ */

/* ── Polish: softer, more modern surfaces ──────────────────── */
.card {
  border: 1px solid #EDEFF3;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(17,24,39,.04), 0 8px 24px rgba(17,24,39,.04);
}
.card:hover {
  border-color: #E3E6EC;
  box-shadow: 0 2px 4px rgba(17,24,39,.05), 0 16px 40px rgba(17,24,39,.08);
}
.card-header {
  border-bottom: 1px solid #F0F2F6;
  background: transparent;
  padding: 18px 22px;
}
.card-title { font-size: 15.5px; }

.stat-card {
  border: 1px solid #EDEFF3;
  border-radius: 18px;
  box-shadow: 0 1px 2px rgba(17,24,39,.03);
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 14px 36px rgba(17,24,39,.10);
  border-color: #E3E6EC;
}
.stat-icon { border-radius: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.06); }

.btn { border-radius: 12px; }
.btn-primary { box-shadow: 0 6px 18px rgba(66,133,244,.28); }
.btn-outline:hover { background: #F5F8FF; }

.page-header h1 { letter-spacing: -.6px; }

/* Tables: cleaner header, smoother row hover */
.table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: 14px; }
table thead th {
  background: #F8FAFC;
  color: #6B7280;
  font-size: 11.5px;
  letter-spacing: .5px;
  text-transform: uppercase;
}
table tbody tr { transition: background .15s ease; }
table tbody tr:hover { background: #F8FAFC; }

/* ════════════════════════════════════════════════════════════
   RESPONSIVE: collapse hard-coded inline two-column grids
   ════════════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .grid-2,
  [class="grid-2"],
  [style*="grid-template-columns:1fr 360px"],
  [style*="grid-template-columns: 1fr 360px"],
  [style*="grid-template-columns:300px 1fr"],
  [style*="grid-template-columns: 300px 1fr"],
  [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 768px) {
  .page-header h1 { font-size: 21px; }
  .page-header p { font-size: 13px; }

  .page-header-row {
    flex-direction: column;
    align-items: stretch !important;
    gap: 14px;
  }
  .page-header-row > .btn,
  .page-header-row .btn-primary { width: 100%; }

  [style*="minmax(300px"],
  [style*="minmax(250px"] { grid-template-columns: 1fr !important; }

  .card-body { padding: 18px; }
  .card-header { padding: 14px 16px; }

  #deptFilter, .dept-filter-btn { flex-wrap: wrap; }

  .modal, .modal-box, .modal-content {
    max-width: 100% !important;
    width: 100% !important;
  }

  .welcome-banner { padding: 20px !important; }
  .welcome-banner h2 { font-size: 19px !important; }
  .welcome-meta { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr !important; }
  .stats-grid { grid-template-columns: 1fr 1fr !important; gap: 12px; }
  .card-body [style*="display:flex"][style*="gap"] { flex-wrap: wrap; }
  table { font-size: 12.5px; }
  td, th { padding: 10px 10px !important; }
}

@media (max-width: 400px) {
  .stats-grid { grid-template-columns: 1fr !important; }
  .page-header h1 { font-size: 19px; }
  .btn { padding: 11px 16px; }
}

@media (max-width: 768px) {
  .page-content, .main-content { overflow-x: hidden; }
  img, table { max-width: 100%; }
}

/* ════════════════════════════════════════════════════════════
   DARK MODE — manual toggle + hard-coded-color fixes
   Two triggers are active everywhere below:
     • html[data-theme="dark"]                 (user chose dark)
     • @media dark + html:not([data-theme="light"])  (OS dark, user didn't force light)
   ════════════════════════════════════════════════════════════ */

/* Manual dark: set the palette variables */
:root[data-theme="dark"] {
  --bg: #0B1220;
  --bg-alt: #0E1626;
  --surface: #131C2E;
  --surface2: #1B2740;
  --border: #26324B;
  --text: #E7ECF3;
  --text-muted: #9AA6B8;
  --text-light: #6B7893;
  --grad-card: linear-gradient(135deg, rgba(0,188,212,.10) 0%, rgba(124,111,205,.10) 100%);
}

/* Smooth transition when flipping */
body, .card, .stat-card, .topbar, .sidebar, input, select, textarea, table {
  transition: background-color .25s ease, border-color .25s ease, color .25s ease;
}

/* ---------- Hard-coded-color fixes (departments, daily_report, etc.) ----------
   These pages set literal light colors in inline styles which variables can't reach,
   so we override them when dark. Kept scoped to obvious light values. */

/* WHITE / near-white backgrounds -> dark surface */
:root[data-theme="dark"] [style*="background:#fff" i],
:root[data-theme="dark"] [style*="background: #fff" i],
:root[data-theme="dark"] [style*="background:white"],
:root[data-theme="dark"] [style*="background: white"],
:root[data-theme="dark"] [style*="background:#F8FAFC" i],
:root[data-theme="dark"] [style*="background:#F9FAFB" i],
:root[data-theme="dark"] [style*="background:#F3F4F6" i],
:root[data-theme="dark"] [style*="background:#ECFDF5" i],
:root[data-theme="dark"] [style*="background:#ECFDFF" i] {
  background-color: var(--surface2) !important;
}

/* Light card borders -> dark border */
:root[data-theme="dark"] [style*="#E5E7EB" i],
:root[data-theme="dark"] [style*="#EDEFF3" i],
:root[data-theme="dark"] [style*="#EEF0F4" i],
:root[data-theme="dark"] [style*="#F0F2F6" i],
:root[data-theme="dark"] [style*="#F1F3F7" i] {
  border-color: var(--border) !important;
}

/* Near-black text -> light text */
:root[data-theme="dark"] [style*="color:#111827" i],
:root[data-theme="dark"] [style*="color: #111827" i],
:root[data-theme="dark"] [style*="color:#1F2937" i],
:root[data-theme="dark"] [style*="color: #1F2937" i],
:root[data-theme="dark"] [style*="color:#374151" i],
:root[data-theme="dark"] [style*="color:#166534" i],
:root[data-theme="dark"] [style*="color:#0e556a" i] {
  color: var(--text) !important;
}

/* daily_report coloured boxes: keep the accent but darken the fill */
:root[data-theme="dark"] .accomplishment-box { background: var(--surface) !important; border-color: var(--border) !important; }
:root[data-theme="dark"] .accomplishment-item { background: var(--surface2) !important; border-color: var(--border) !important; }
:root[data-theme="dark"] .accomplishment-item .item-text { color: var(--text) !important; }
:root[data-theme="dark"] .accomplishment-header h2 { color: var(--text) !important; }

/* departments cards */
:root[data-theme="dark"] .dept-card,
:root[data-theme="dark"] .dept-stat { background: var(--surface) !important; border-color: var(--border) !important; }
:root[data-theme="dark"] .dept-metric,
:root[data-theme="dark"] .dept-head-row { background: var(--surface2) !important; }
:root[data-theme="dark"] .dept-card-name,
:root[data-theme="dark"] .dept-metric-val,
:root[data-theme="dark"] .dept-stat-val { color: var(--text) !important; }
:root[data-theme="dark"] .dept-card-actions { background: var(--surface) !important; border-color: var(--border) !important; }

/* form controls with white bg */
:root[data-theme="dark"] input.form-control,
:root[data-theme="dark"] select.form-control,
:root[data-theme="dark"] textarea.form-control {
  background: var(--surface2) !important;
  color: var(--text) !important;
  border-color: var(--border) !important;
}
:root[data-theme="dark"] .form-control::placeholder { color: var(--text-light) !important; }

/* Theme toggle button in the topbar */
.theme-toggle {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 40px; height: 40px; border-radius: 12px;
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 15px; transition: all .2s ease;
}
.theme-toggle:hover { color: var(--blue); border-color: var(--blue); }

/* Show sun in dark mode, moon in light mode */
.theme-toggle .icon-sun  { display: none; }
.theme-toggle .icon-moon { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-sun  { display: inline; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .theme-toggle .icon-sun  { display: inline; }
  :root:not([data-theme="light"]) .theme-toggle .icon-moon { display: none; }
}