/* ====================================================================
   School Connect — Shared Stylesheet (Gen v7)
   Single source of truth used by every page in the platform.
   Fixes D-09 (was: each page inlined ~10KB of duplicated CSS).
   ==================================================================== */

:root {
  --primary: #4f46e5;
  --primary-dark: #3730a3;
  --primary-light: #818cf8;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --dark: #0f172a;
  --gray-900: #1e293b;
  --gray-800: #334155;
  --gray-700: #475569;
  --gray-600: #64748b;
  --gray-500: #94a3b8;
  --gray-400: #cbd5e1;
  --gray-300: #e2e8f0;
  --gray-200: #f1f5f9;
  --gray-100: #f8fafc;
  --white: #ffffff;
  --gradient: linear-gradient(135deg, #4f46e5 0%, #06b6d4 100%);
  --gradient-dark: linear-gradient(135deg, #3730a3 0%, #0891b2 100%);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.1);
  --shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.25);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dark mode variables */
[data-theme="dark"] {
  --dark: #f8fafc;
  --gray-900: #f1f5f9;
  --gray-800: #e2e8f0;
  --gray-700: #cbd5e1;
  --gray-600: #94a3b8;
  --gray-500: #64748b;
  --gray-400: #475569;
  --gray-300: #334155;
  --gray-200: #1e293b;
  --gray-100: #0f172a;
  --white: #0f172a;
  background: var(--gray-100);
  color: var(--gray-800);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font, 'Inter'), -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--white);
  color: var(--gray-900);
  line-height: 1.6;
  overflow-x: hidden;
  transition: background-color 0.3s, color 0.3s;
}

a { color: var(--primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; height: auto; display: block; }

button { font-family: inherit; cursor: pointer; border: none; background: none; }

input, textarea, select { font-family: inherit; font-size: 1rem; }

.container { max-width: 1280px; margin: 0 auto; padding: 0 24px; }

/* ===== Navigation ===== */
.nav {
  position: fixed; top: 0; left: 0; right: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  transition: var(--transition);
}
[data-theme="dark"] .nav { background: rgba(15,23,42,0.92); border-bottom-color: var(--gray-300); }
.nav-inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; height: 70px; }
.nav-logo { display: flex; align-items: center; gap: 10px; color: var(--dark); font-weight: 700; font-size: 1.2rem; }
.nav-logo img { width: 40px; height: 40px; border-radius: 10px; }
.nav-links { display: flex; align-items: center; gap: 6px; list-style: none; }
.nav-links a { color: var(--gray-700); font-size: 0.92rem; font-weight: 500; padding: 8px 14px; border-radius: 8px; transition: var(--transition); }
.nav-links a:hover { background: var(--gray-100); color: var(--primary); }
.nav-links a.active { background: rgba(79,70,229,0.1); color: var(--primary); }
.nav-links .btn-primary { background: var(--primary); color: white; padding: 10px 22px; border-radius: 10px; font-weight: 600; }
.nav-links .btn-primary:hover { background: var(--primary-dark); color: white; }
.mobile-toggle { display: none; padding: 8px; color: var(--gray-700); }
.mobile-toggle svg { width: 24px; height: 24px; }

/* ===== Hero ===== */
.hero { padding: 140px 24px 80px; text-align: center; position: relative; background: linear-gradient(180deg, #f8faff 0%, var(--white) 100%); overflow: hidden; }
.hero::before { content: ''; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 0%, rgba(79,70,229,0.08) 0%, transparent 70%); pointer-events: none; }
.hero-badge { display: inline-flex; align-items: center; gap: 8px; background: linear-gradient(135deg, rgba(79,70,229,0.08) 0%, rgba(6,182,212,0.08) 100%); border: 1px solid rgba(79,70,229,0.15); padding: 8px 20px; border-radius: 50px; font-size: 0.85rem; font-weight: 600; color: var(--primary); margin-bottom: 24px; }
.hero h1 { font-size: clamp(2.5rem, 6vw, 4.5rem); font-weight: 900; color: var(--dark); line-height: 1.1; margin-bottom: 20px; max-width: 900px; margin-left: auto; margin-right: auto; }
.hero h1 .highlight { background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { font-size: 1.2rem; color: var(--gray-600); max-width: 720px; margin: 0 auto 40px; line-height: 1.7; }
.hero-actions { display: flex; align-items: center; justify-content: center; gap: 16px; flex-wrap: wrap; margin-bottom: 60px; }
.btn-hero { display: inline-flex; align-items: center; gap: 10px; padding: 16px 36px; border-radius: 14px; font-size: 1.05rem; font-weight: 700; transition: var(--transition); }
.btn-hero-primary { background: var(--gradient); color: white; box-shadow: 0 8px 24px rgba(79,70,229,0.35); }
.btn-hero-primary:hover { transform: translateY(-2px); box-shadow: 0 12px 32px rgba(79,70,229,0.45); color: white; }
.btn-hero-secondary { background: white; color: var(--gray-800); border: 2px solid var(--gray-200); }
.btn-hero-secondary:hover { border-color: var(--primary); color: var(--primary); transform: translateY(-2px); }

/* ===== Section ===== */
.section { padding: 80px 24px; }
.section-head { text-align: center; margin-bottom: 60px; }
.section-eyebrow { display: inline-block; padding: 6px 16px; background: rgba(79,70,229,0.08); color: var(--primary); border-radius: 50px; font-size: 0.85rem; font-weight: 700; margin-bottom: 16px; letter-spacing: 0.5px; }
.section-title { font-size: clamp(1.8rem, 4vw, 2.8rem); font-weight: 900; color: var(--dark); line-height: 1.2; margin-bottom: 16px; }
.section-sub { font-size: 1.1rem; color: var(--gray-600); max-width: 700px; margin: 0 auto; }

/* ===== Cards / Grids ===== */
.grid { display: grid; gap: 24px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.card { background: white; border-radius: var(--radius-lg); padding: 28px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); transition: var(--transition); }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); }
.card h3 { font-size: 1.2rem; font-weight: 800; color: var(--dark); margin-bottom: 10px; display: flex; align-items: center; gap: 10px; }
.card p { color: var(--gray-700); font-size: 0.95rem; line-height: 1.6; }
.card-icon { font-size: 2.2rem; margin-bottom: 12px; }
.tag { display: inline-block; padding: 3px 10px; border-radius: 50px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
.tag-new { background: rgba(16,185,129,0.12); color: var(--success); }
.tag-pop { background: rgba(245,158,11,0.12); color: var(--warning); }
.tag-core { background: rgba(79,70,229,0.12); color: var(--primary); }
.tag-enterprise { background: rgba(217,70,239,0.12); color: #c026d3; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; gap: 8px; padding: 10px 20px; border-radius: 10px; font-weight: 600; font-size: 0.95rem; transition: var(--transition); border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); color: white; }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); }
.btn-secondary:hover { background: var(--gray-200); color: var(--dark); }
.btn-outline { background: transparent; border: 1px solid var(--gray-300); color: var(--gray-700); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: 12px; }
.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== Forms ===== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; font-size: 0.9rem; color: var(--gray-700); margin-bottom: 6px; }
.form-input, .form-textarea, .form-select { width: 100%; padding: 12px 16px; border: 1.5px solid var(--gray-300); border-radius: 10px; background: white; color: var(--gray-900); transition: var(--transition); font-size: 0.95rem; }
.form-input:focus, .form-textarea:focus, .form-select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,0.12); }
.form-textarea { resize: vertical; min-height: 100px; }
.form-help { font-size: 0.82rem; color: var(--gray-500); margin-top: 4px; }
.form-error { color: var(--danger); font-size: 0.85rem; margin-top: 4px; }

/* ===== Tables ===== */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; }
th { padding: 14px 16px; background: var(--gray-100); text-align: left; font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; color: var(--gray-600); border-bottom: 2px solid var(--gray-200); }
td { padding: 14px 16px; border-bottom: 1px solid var(--gray-200); font-size: 0.92rem; color: var(--gray-800); }
tbody tr:hover { background: var(--gray-100); }

/* ===== Badges & Status ===== */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 50px; font-size: 0.75rem; font-weight: 700; }
.badge-success { background: rgba(16,185,129,0.12); color: var(--success); }
.badge-warning { background: rgba(245,158,11,0.12); color: var(--warning); }
.badge-danger { background: rgba(239,68,68,0.12); color: var(--danger); }
.badge-info { background: rgba(59,130,246,0.12); color: var(--info); }

/* ===== Modal ===== */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.6); z-index: 2000; display: none; align-items: center; justify-content: center; padding: 20px; backdrop-filter: blur(8px); }
.modal-backdrop.show { display: flex; }
.modal { background: white; border-radius: var(--radius-xl); max-width: 560px; width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-xl); }
.modal-header { padding: 24px 28px; border-bottom: 1px solid var(--gray-200); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 1.3rem; font-weight: 800; color: var(--dark); }
.modal-close { background: var(--gray-100); border-radius: 50%; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; font-size: 1.2rem; color: var(--gray-700); }
.modal-close:hover { background: var(--gray-200); }
.modal-body { padding: 28px; }
.modal-footer { padding: 20px 28px; border-top: 1px solid var(--gray-200); display: flex; justify-content: flex-end; gap: 12px; }

/* ===== Toast — Robust Legible (V12.26) — single definition, no conflict, WCAG AA ====
   BEFORE: Two conflicting .toast definitions — one white bg dark text, one dark bg #0f172a white text — second overrode first's bg but .toast-msg still had var(--gray-700) dark gray on dark bg → NOT legible. That's popup bug.
   AFTER: Single robust definition with high contrast, works in light AND dark modes, with type-specific light backgrounds + dark text for legibility (like platform-health fallback toast), plus dark mode override that keeps contrast.
   ==================================================================== */
.toast-container { position: fixed; top: 90px; right: 20px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #ffffff; color: #0f172a; padding: 14px 20px; border-radius: var(--radius); box-shadow: 0 12px 32px rgba(15,23,42,.18); border:1px solid #e2e8f0; border-left: 5px solid var(--primary); min-width: 280px; max-width: 420px; animation: slideIn 0.3s ease; font-weight:600; line-height:1.5; }
.toast-success { background:#dcfce7; color:#166534; border-color:#86efac; border-left-color: var(--success); }
.toast-warning { background:#fef3c7; color:#92400e; border-color:#fcd34d; border-left-color: var(--warning); }
.toast-danger { background:#fee2e2; color:#991b1b; border-color:#fca5a5; border-left-color: var(--danger); }
.toast-info { background:#eef2ff; color:#3730a3; border-color:#c7d2fe; border-left-color: var(--primary); }
.toast-title { font-weight: 800; font-size: 0.92rem; color: inherit; margin-bottom: 2px; }
.toast-msg { font-size: 0.88rem; color: inherit; line-height:1.45; }
[data-theme="dark"] .toast { background:#1e293b; color:#f8fafc; border-color:#334155; box-shadow:0 12px 32px rgba(0,0,0,.4); }
[data-theme="dark"] .toast-success { background:#052e16; color:#bbf7d0; border-color:#166534; }
[data-theme="dark"] .toast-warning { background:#451a03; color:#fde68a; border-color:#92400e; }
[data-theme="dark"] .toast-danger { background:#450a0a; color:#fecaca; border-color:#991b1b; }
[data-theme="dark"] .toast-info { background:#1e1b4b; color:#c7d2fe; border-color:#3730a3; }
@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { to { transform: translateX(120%); opacity: 0; } }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: white; padding: 24px; border-radius: var(--radius-lg); box-shadow: var(--shadow); border: 1px solid var(--gray-200); text-align: center; }
.stat-value { font-size: 2.2rem; font-weight: 900; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { font-size: 0.78rem; color: var(--gray-600); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; font-weight: 600; }

/* ===== Footer ===== */
.footer { background: var(--dark); color: var(--gray-300); padding: 60px 24px 30px; margin-top: 80px; }
[data-theme="dark"] .footer { background: #020617; }
.footer-grid { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 40px; }
.footer-brand h4 { color: white; font-size: 1.3rem; margin-bottom: 12px; }
.footer-brand p { font-size: 0.9rem; line-height: 1.7; opacity: 0.8; }
.footer h5 { color: white; font-size: 0.9rem; text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; font-weight: 700; }
.footer ul { list-style: none; }
.footer ul li { margin-bottom: 8px; }
.footer a { color: var(--gray-400); font-size: 0.9rem; transition: var(--transition); }
.footer a:hover { color: white; }
.footer-bottom { border-top: 1px solid rgba(255,255,255,0.1); padding-top: 24px; text-align: center; font-size: 0.85rem; opacity: 0.7; }

/* ===== Notification Bell ===== */
/* ===== Notifications Bell — Robust Legible (V12.26) — single definition, WCAG AA ===== */
.notif-bell { position: fixed; top: 14px; right: 18px; z-index: 35; background: var(--gray-100, #f1f5f9); border-radius: 50%; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: var(--transition); box-shadow: 0 2px 8px rgba(15,23,42,.12); border:1px solid var(--gray-200, #e2e8f0); }
.notif-bell:hover { background: var(--gray-200, #e2e8f0); }
.notif-bell svg { width: 20px; height: 20px; color: var(--gray-700, #475569); }
.notif-badge { position: absolute; top: -2px; right: -2px; background: var(--danger, #ef4444); color: white; font-size: 0.65rem; font-weight: 800; border-radius: 50%; min-width: 18px; height: 18px; display: flex; align-items: center; justify-content: center; padding: 0 4px; border: 2px solid white; }
.notif-dropdown { position: fixed; top: 60px; right: 14px; left: auto; background: #ffffff; color:#0f172a; border-radius: var(--radius-lg, 16px); box-shadow: 0 20px 40px rgba(15,23,42,.18); width: min(420px, calc(100vw - 32px)); max-height: min(560px, calc(100vh - 80px)); overflow-y: auto; border: 1px solid var(--gray-200, #e2e8f0); display: none; z-index: 20000; text-align:left; }
.notif-dropdown.show { display: block; }
.notif-item { position:relative; padding:14px 18px; border-bottom:1px solid var(--gray-200, #e2e8f0); cursor:pointer; transition:background .15s; background:#ffffff; color:#0f172a; }
.notif-item:hover { background: var(--gray-100, #f8fafc); }
.notif-item.notif-unread{ background:rgba(79,70,229,.06); border-left:4px solid var(--primary, #4f46e5); }
.notif-item-title { font-weight: 800; color: #0f172a; font-size: 0.92rem; margin-bottom: 4px; line-height:1.35; }
.notif-item-msg { font-size: 0.88rem; color: #334155; line-height:1.45; }
.notif-item-time { font-size: 0.75rem; color: #64748b; margin-top: 6px; }

/* ===== PWA Install Banner ===== */
.pwa-install { position: fixed; bottom: 20px; left: 20px; right: 20px; max-width: 480px; background: white; border-radius: var(--radius-lg); box-shadow: var(--shadow-xl); padding: 20px; z-index: 2500; border: 2px solid var(--primary); display: none; animation: slideUp 0.4s ease; }
[data-theme="dark"] .pwa-install { background: var(--gray-200); }
.pwa-install.show { display: block; }
.pwa-install-header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.pwa-install-icon { width: 48px; height: 48px; flex-shrink: 0; }
.pwa-install-title { font-weight: 800; color: var(--dark); font-size: 1.05rem; margin-bottom: 4px; }
.pwa-install-msg { font-size: 0.88rem; color: var(--gray-700); }
.pwa-install-actions { display: flex; gap: 10px; margin-top: 12px; }
.pwa-install-actions button { flex: 1; }
@keyframes slideUp { from { transform: translateY(100%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ===== Voting Cards ===== */
.vote-card { background: white; border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow); border: 1px solid var(--gray-200); transition: var(--transition); cursor: pointer; }
.vote-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--primary); }
.vote-card.selected { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,0.15); }
.vote-candidate-photo { width: 80px; height: 80px; border-radius: 50%; background: var(--gradient); display: flex; align-items: center; justify-content: center; color: white; font-size: 2rem; font-weight: 800; margin: 0 auto 16px; }
.vote-candidate-name { text-align: center; font-weight: 800; color: var(--dark); font-size: 1.05rem; margin-bottom: 4px; }
.vote-candidate-info { text-align: center; font-size: 0.85rem; color: var(--gray-600); }
.vote-progress { background: var(--gray-200); height: 8px; border-radius: 4px; overflow: hidden; margin-top: 12px; }
.vote-progress-bar { background: var(--gradient); height: 100%; border-radius: 4px; transition: width 0.6s ease; }
.vote-percent { text-align: center; font-weight: 700; color: var(--primary); margin-top: 6px; font-size: 0.9rem; }

/* ===== Animations ===== */
.fade-in { animation: fadeIn 0.5s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.pulse { animation: pulse 2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .nav-links { display: none; position: absolute; top: 70px; left: 0; right: 0; background: white; flex-direction: column; padding: 20px; border-bottom: 1px solid var(--gray-200); box-shadow: var(--shadow-lg); }
  [data-theme="dark"] .nav-links { background: var(--gray-200); }
  .nav-links.show { display: flex; }
  .nav-links a { width: 100%; padding: 12px 16px; }
  .mobile-toggle { display: flex; }
  .hero { padding: 110px 24px 60px; }
  .section { padding: 60px 24px; }
  .footer-grid { grid-template-columns: 1fr; gap: 30px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .pwa-install { left: 10px; right: 10px; }
  .notif-dropdown { right: 12px; left: 12px; width: auto; max-width: none; top: 64px; }
  /* update v4: touch-friendly + scalable previews on phones */
  .btn { min-height: 44px; }                 /* comfortable tap targets */
  .form-input, .form-select { font-size: 16px; min-height: 44px; }  /* prevents iOS zoom */
  .modal, .modal-content { width: 96vw !important; max-width: 96vw !important; }
  .sc-idcard, .sc-flyer, .sc-cert { max-width: 94vw !important; }
  .sc-flyer { transform-origin: top center; }
  table { font-size: 0.85rem; }
}
@media (max-width: 480px) {
  .app-content { padding: 12px; }
  .sc-idcard { width: 92vw !important; }
}

/* ===== Print ===== */
@media print {
  .nav, .footer, .pwa-install, .notif-bell, .toast-container, .btn, .modal-backdrop { display: none !important; }
  body { background: white; color: black; }
  .card, .modal { box-shadow: none; border: 1px solid #ccc; }
}

/* ===== Accessibility ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

/* =====================================================================
   APP SHELL — logged-in dashboard layout (sidebar / topnav / cards)
   These classes were previously missing, causing the disorganised UI
   after login. This block styles the full authenticated experience.
   ===================================================================== */

.app-layout { display: flex; min-height: 100vh; background: var(--gray-100); }

/* ---------- Sidebar ---------- */
.app-sidebar {
  width: 250px; flex-shrink: 0; background: var(--white);
  border-right: 1px solid var(--gray-300);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.app-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 18px; border-bottom: 1px solid var(--gray-300);
}
.app-brand img { width: 40px; height: 40px; border-radius: 10px; object-fit: contain; flex-shrink: 0; background: var(--gray-100); }
.app-brand strong { display: block; font-size: 0.95rem; font-weight: 800; color: var(--dark); line-height: 1.2; }

.app-nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; flex: 1; }
.app-nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: 10px;
  color: var(--gray-700); text-decoration: none;
  font-size: 0.9rem; font-weight: 600; line-height: 1;
  transition: var(--transition); white-space: nowrap;
}
.app-nav a:hover { background: var(--gray-200); color: var(--primary); }
.app-nav a.active { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.app-nav-icon {
  width: 24px; min-width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem; flex-shrink: 0;
}

/* ---------- Main area ---------- */
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.app-topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 24px; background: var(--white);
  border-bottom: 1px solid var(--gray-300);
  position: sticky; top: 0; z-index: 30;
}
.app-page-title { font-size: 1.25rem; font-weight: 800; color: var(--dark); margin: 0; }
.app-content { padding: 24px; flex: 1; max-width: 1280px; width: 100%; }

/* ---------- Layout variants ---------- */
/* Top-navigation variant: nav becomes a horizontal bar on top */
.app-layout.topnav { flex-direction: column; }
.app-layout.topnav .app-sidebar {
  width: 100%; height: auto; position: sticky; top: 0;
  flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden;
  border-right: none; border-bottom: 1px solid var(--gray-300);
}
.app-layout.topnav .app-brand { border-bottom: none; border-right: 1px solid var(--gray-300); }
.app-layout.topnav .app-nav { flex-direction: row; flex: 1; padding: 8px; gap: 4px; }
.app-layout.topnav .app-nav a { flex-direction: column; gap: 4px; font-size: 0.7rem; padding: 8px 12px; text-align: center; }
.app-layout.topnav .app-sidebar > div:last-child { display: none; }

/* Card-hub variant: same sidebar, but content uses big cards (handled by markup) */
.app-layout.cards .app-content .stats-grid { margin-bottom: 28px; }

/* V4 layout variants — sidebar width overrides + nav grid layout for long labels */
.app-layout.sidebar .app-sidebar { width: 286px; }
.app-layout.topnav, .app-layout.cardhub, .app-layout.mega-menu, .app-layout.tabbed, .app-layout.dashboard-pro { flex-direction: column; }
.app-layout.topnav .app-sidebar, .app-layout.cardhub .app-sidebar, .app-layout.mega-menu .app-sidebar, .app-layout.tabbed .app-sidebar, .app-layout.dashboard-pro .app-sidebar { width: 100%; height: auto; max-height: 210px; position: sticky; top: 0; flex-direction: row; align-items: stretch; overflow: hidden; border-right: none; border-bottom: 1px solid var(--gray-300); }
.app-layout.topnav .app-brand, .app-layout.cardhub .app-brand, .app-layout.mega-menu .app-brand, .app-layout.tabbed .app-brand, .app-layout.dashboard-pro .app-brand { width: 260px; min-width: 260px; border-bottom: none; border-right: 1px solid var(--gray-300); }
.app-layout.topnav .app-nav, .app-layout.cardhub .app-nav, .app-layout.mega-menu .app-nav, .app-layout.tabbed .app-nav, .app-layout.dashboard-pro .app-nav { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(116px, 150px); overflow-x: auto; overflow-y: hidden; padding: 10px; align-items: center; }
.app-layout.topnav .app-nav a, .app-layout.cardhub .app-nav a, .app-layout.mega-menu .app-nav a, .app-layout.tabbed .app-nav a, .app-layout.dashboard-pro .app-nav a { display: flex; flex-direction: column; gap: 4px; min-height: 68px; padding: 8px 10px; font-size: .75rem; text-align: center; justify-content: center; }
.app-layout.topnav .app-nav-icon, .app-layout.cardhub .app-nav-icon, .app-layout.mega-menu .app-nav-icon, .app-layout.tabbed .app-nav-icon, .app-layout.dashboard-pro .app-nav-icon { margin: auto; }
.app-layout.compact .app-sidebar, .app-layout.dock .app-sidebar { width: 224px; }
.app-layout.expanded .app-sidebar { width: 330px; }
.app-layout.minimalist .app-sidebar { box-shadow: none; }
.app-layout.floating .app-sidebar { margin: 14px; border-radius: 22px; height: calc(100vh - 28px); border: 1px solid var(--gray-300); }
.app-layout.split-view .app-content, .app-layout.grid-master .app-content, .app-layout.masonry .app-content { max-width: 1500px; }
.app-layout.vertical-hub .app-sidebar { width: 300px; }

/* Nav grid layout — supports long text labels on all layouts */
.app-nav a { display: grid !important; grid-template-columns: 32px minmax(0, 1fr) !important; align-items: center !important; gap: 10px !important; }
.app-nav-icon { width: 32px !important; min-width: 32px !important; height: 32px !important; font-size: 18px !important; line-height: 1 !important; overflow: hidden !important; flex: 0 0 32px !important; font-family: "Apple Color Emoji","Segoe UI Emoji","Noto Color Emoji",sans-serif !important; }
.app-nav-icon img,.app-nav-icon svg { width: 18px !important; height: 18px !important; max-width: 18px !important; max-height: 18px !important; object-fit: contain; display: block; }

/* Responsive sidebar drawer */
@media (max-width: 900px) {
  .app-sidebar, .app-layout.floating .app-sidebar { position: fixed !important; left: 0; top: 0; bottom: 0; width: min(86vw, 310px) !important; height: 100vh !important; margin: 0 !important; border-radius: 0 !important; transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); z-index: 100; }
  .app-sidebar.open { transform: translateX(0); }
  .app-layout.topnav .app-sidebar, .app-layout.cardhub .app-sidebar, .app-layout.mega-menu .app-sidebar, .app-layout.tabbed .app-sidebar, .app-layout.dashboard-pro .app-sidebar { position: sticky; transform: none; width: 100%; height: auto; max-height: none; flex-direction: row; border-right: none; border-bottom: 1px solid var(--gray-300); }
  .app-layout.topnav .app-nav, .app-layout.cardhub .app-nav, .app-layout.mega-menu .app-nav, .app-layout.tabbed .app-nav, .app-layout.dashboard-pro .app-nav { display: flex; flex-direction: column; overflow-y: auto; }
  .app-layout.topnav .app-nav a, .app-layout.cardhub .app-nav a, .app-layout.mega-menu .app-nav a, .app-layout.tabbed .app-nav a, .app-layout.dashboard-pro .app-nav a { display: grid; grid-template-columns: 32px minmax(0, 1fr); min-height: 42px; }
  .app-topbar .mobile-toggle { display: inline-flex !important; align-items: center; justify-content: center; background: var(--gray-100); border: 1px solid var(--gray-300); border-radius: 10px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer; }
  .user-chip { max-width: 150px; overflow: hidden; }
  .user-chip strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
}
@media (min-width: 901px) {
  .app-topbar .mobile-toggle { display: none !important; }
}

/* ---------- Dashboard cards & tables polish ---------- */
.app-content .card { margin-bottom: 20px; }
.app-content .card h3 { font-size: 1.05rem; font-weight: 800; color: var(--dark); margin-bottom: 6px; }
.app-content .grid { display: grid; gap: 20px; }
.app-content .grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.app-content .grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-300); }
.table-wrap table { width: 100%; border-collapse: collapse; min-width: 480px; background: var(--white); }
.table-wrap th { text-align: left; padding: 12px 14px; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-600); background: var(--gray-100); border-bottom: 1px solid var(--gray-300); }
.table-wrap td { padding: 12px 14px; font-size: 0.9rem; color: var(--gray-800); border-bottom: 1px solid var(--gray-200); }
.table-wrap tr:last-child td { border-bottom: none; }
.pulse { color: var(--gray-500); }

/* ---------- Dark mode for the app shell ---------- */
[data-theme="dark"] .app-layout { background: #0b1220; }
[data-theme="dark"] .app-sidebar,
[data-theme="dark"] .app-topbar { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .app-brand { border-color: #1e293b; }
[data-theme="dark"] .app-brand strong,
[data-theme="dark"] .app-page-title { color: #e2e8f0; }
[data-theme="dark"] .app-nav a { color: #94a3b8; }
[data-theme="dark"] .app-nav a:hover { background: #1e293b; color: #fff; }
[data-theme="dark"] .app-content .card { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .table-wrap, [data-theme="dark"] .table-wrap table { background: #0f172a; border-color: #1e293b; }
[data-theme="dark"] .table-wrap th { background: #111c30; color: #94a3b8; }
[data-theme="dark"] .table-wrap td { color: #cbd5e1; border-color: #1e293b; }

/* ---------- High-contrast accessibility mode (toggled by enterprise.js) ---------- */
body.sc-high-contrast { background: #fff; }
body.sc-high-contrast .app-nav a,
body.sc-high-contrast .app-page-title,
body.sc-high-contrast .table-wrap td { color: #000 !important; }
body.sc-high-contrast .app-nav a.active { background: #000 !important; color: #fff !important; }
body.sc-high-contrast .card,
body.sc-high-contrast .table-wrap { border: 2px solid #000 !important; }

/* ---------- Responsive: sidebar becomes a slide-in drawer ---------- */
@media (max-width: 900px) {
  .app-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100vh;
    transform: translateX(-100%); transition: transform 0.25s ease;
    box-shadow: var(--shadow-lg);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-layout.topnav .app-sidebar { position: sticky; transform: none; }
  .app-content { padding: 16px; }
}
@media (min-width: 901px) {
  .app-topbar .mobile-toggle { display: none; }
}
@media (max-width: 900px) {
  .app-topbar .mobile-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--gray-100); border: 1px solid var(--gray-300);
    border-radius: 8px; width: 40px; height: 40px; font-size: 1.2rem; cursor: pointer;
  }
}

/* Generated app-shell nav safety: restricted modules remain visible instead of disappearing. */
.app-nav a.nav-locked { opacity: .62; }
.app-nav a.nav-locked .app-nav-icon { filter: grayscale(.35); }
.app-nav a.nav-locked::after { content: '🔒'; font-size: .72rem; opacity: .65; justify-self: end; }
.app-nav a.nav-locked.active { opacity: 1; }

/* V4 professional visual system: calmer enterprise palette, stronger typography, safer contrast. */
:root {
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #0f172a;
  --muted-ink: #475569;
  --ring: rgba(37, 99, 235, .18);
}
body { letter-spacing: -0.01em; background: linear-gradient(180deg,#f8fafc 0%,#eef2f7 100%); }
.app-layout { background: linear-gradient(180deg,#f8fafc 0%,#eef2f7 100%) !important; }
.app-sidebar { background: linear-gradient(180deg,#ffffff 0%,#f8fafc 100%) !important; border-right: 1px solid #dbe3ef !important; }
.app-brand strong, .app-page-title, .card h3 { letter-spacing: -0.025em; }
.app-nav a { color:#334155 !important; }
.app-nav a:hover { background:#eaf2ff !important; color:var(--primary) !important; }
.app-nav a.active { background:linear-gradient(135deg,var(--primary),var(--accent)) !important; color:#fff !important; }
/* V11.4 FIX: the previous universal !important white background beat every inline
   gradient hero card (analytics, developer…), leaving white text on a white card —
   invisible until highlighted. Cards that declare their own gradient are excluded. */
.card:not([style*="linear-gradient"]), .stat-card { background:rgba(255,255,255,.96) !important; border:1px solid #dde7f3 !important; box-shadow:0 12px 30px rgba(15,23,42,.07) !important; }
.card[style*="linear-gradient"] { border:0 !important; box-shadow:0 12px 30px rgba(15,23,42,.18) !important; }
/* V12.11: legibility fix — only DARK gradients get white text. Light gradients (e.g., #eef2ff→#faf5ff for student points) keep dark text for readability.
   Previously, all gradient cards forced white text, making light-gradient cards illegible (white on light). */
.card[style*="linear-gradient(135deg,#0506ae"], .card[style*="linear-gradient(135deg,#4f46e5"], .card[style*="linear-gradient(135deg,#0f172a"], .card[style*="linear-gradient(135deg,#1e293b"] { color:#fff; }
.card[style*="linear-gradient(135deg,#0506ae"] h2, .card[style*="linear-gradient(135deg,#0506ae"] h3, .card[style*="linear-gradient(135deg,#0506ae"] h4,
.card[style*="linear-gradient(135deg,#4f46e5"] h2, .card[style*="linear-gradient(135deg,#4f46e5"] h3, .card[style*="linear-gradient(135deg,#4f46e5"] h4,
.card[style*="linear-gradient(135deg,#0f172a"] h2, .card[style*="linear-gradient(135deg,#0f172a"] h3, .card[style*="linear-gradient(135deg,#0f172a"] h4 { color:#fff; }
/* Light gradients explicitly keep dark text */
.card[style*="linear-gradient(135deg,#eef2ff"] { color:#0f172a; }
.card[style*="linear-gradient(135deg,#eef2ff"] h2, .card[style*="linear-gradient(135deg,#eef2ff"] h3, .card[style*="linear-gradient(135deg,#eef2ff"] h4, .card[style*="linear-gradient(135deg,#eef2ff"] p { color:#0f172a; }
.btn-primary { background:linear-gradient(135deg,var(--primary),var(--accent)) !important; border:0 !important; box-shadow:0 10px 22px rgba(37,99,235,.18); }
.btn-outline { background:#fff !important; border-color:#cbd5e1 !important; }
.form-input:focus, .form-select:focus, .form-textarea:focus { box-shadow:0 0 0 4px var(--ring) !important; }
.table-wrap { background:#fff; box-shadow:0 8px 22px rgba(15,23,42,.04); }
th { background:#f1f5f9 !important; color:#334155 !important; }

/* V5 secure navigation: hide role-filtered menu until profile role is resolved. */
body:not([data-role-ready="1"]) .app-nav a[data-role-allow] { visibility: visible !important; }
.app-nav a[style*="display: none"] { display: none !important; }

.dashboard-live-feed{margin-top:18px;border:1px solid var(--gray-200);background:linear-gradient(180deg,#fff,#f8fafc)}
.dashboard-live-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:14px}.feed-item{padding:12px;border-bottom:1px solid var(--gray-100)}.feed-item:last-child{border-bottom:none}.feed-item a{font-weight:800;color:var(--primary);text-decoration:none}.feed-meta{font-size:.78rem;color:var(--gray-500);margin-top:3px}.feed-body{font-size:.88rem;color:var(--gray-700);margin-top:5px;line-height:1.55}.receipt-mini{display:flex;justify-content:space-between;gap:8px;padding:10px 0;border-bottom:1px solid var(--gray-100)}

/* ENHANCEMENT: instant table search */
.sc-table-search{animation:scfade .2s ease}
.sc-table-q:focus{outline:none;border-color:var(--primary);box-shadow:0 0 0 3px rgba(79,70,229,.12)}
@keyframes scfade{from{opacity:0;transform:translateY(-4px)}to{opacity:1;transform:none}}
.table-wrap{overflow-x:auto}

/* ====================================================================
   V12.22 — Robust Theme Manager (Fleet Console + Adewale parity)
   ==================================================================== */
:root{
  --bg:#f8fafc;--bg2:#f1f5f9;--card:#ffffff;--line:#e2e8f0;--txt:#0f172a;--mut:#64748b;
  --ok:#10b981;--warn:#f59e0b;--bad:#ef4444;
}
html[data-theme="dark"], body[data-theme="dark"]{
  --bg:#0f172a;--bg2:#0b1222;--card:#1e293b;--line:#334155;--txt:#e2e8f0;--mut:#94a3b8;
  --ok:#34d399;--warn:#fbbf24;--bad:#f87171;
  --gray-100:#0f172a;--gray-200:#1e293b;--gray-300:#334155;
  --white:#0f172a;
}
html[data-theme="dark"] body, body[data-theme="dark"]{
  background:var(--bg);
  color:var(--txt);
}
.theme-preset{transition:transform .15s, box-shadow .15s}
.theme-preset:hover{transform:scale(1.08)}

/* Drive progress pill (V12.22) */
#sc-drive-progress{position:fixed;bottom:14px;right:14px;z-index:2147481000;background:#0f172a;color:#fff;font:600 12.5px/1.5 system-ui;padding:10px 14px;border-radius:12px;box-shadow:0 8px 30px rgba(0,0,0,.35);max-width:320px}
#sc-drive-progress-bar{height:100%;background:#31c48d;border-radius:3px;transition:width .25s}

/* Notifications — clear + auto-popup (V12.22) — robust legible (V12.26) — single definition above, no duplicate */
.notif-entry{padding:14px 16px;border:1px solid var(--gray-200, #e2e8f0);border-radius:12px;margin-bottom:10px;background:#ffffff;color:#0f172a;cursor:pointer;transition:border-color .15s}
.notif-entry:hover{border-color:var(--primary, #4f46e5)}
.notif-entry.unread{border-left:4px solid var(--primary, #4f46e5);background:rgba(79,70,229,.06)}
.notif-entry-icon{font-size:1.2rem;margin-bottom:6px}
.notif-entry-title{font-weight:800;color:#0f172a;margin-bottom:4px;line-height:1.35}
.notif-entry-msg{color:#334155;font-size:.9rem;line-height:1.5}
.notif-entry-time{font-size:.75rem;color:#64748b;margin-top:6px}
.channel-pill{display:inline-block;background:rgba(79,70,229,.1);color:var(--primary, #4f46e5);border-radius:6px;padding:2px 8px;font-size:.68rem;font-weight:700;margin:2px}
#sc-live-notification-tray{position:fixed;right:18px;bottom:18px;z-index:2147482500;display:flex;flex-direction:column;gap:10px;max-width:min(420px,calc(100vw - 36px));pointer-events:none}

/* Messages — ensure WhatsApp replica styles also available as static fallback */
.mc-app{border-radius:14px;overflow:hidden;box-shadow:0 10px 34px rgba(15,23,42,.16);background:#dcdcd2}
.mc-band{background:#00a884;color:#fff;padding:14px 18px;font-weight:800;display:flex;align-items:center;gap:10px}
.mc-shell{display:flex;height:72vh;min-height:480px;background:#fff}

/* PWA install banner + modal (toast already defined above robustly) */
.pwa-install-banner{position:fixed;left:16px;right:16px;bottom:16px;z-index:9990;background:#fff;border:1px solid #e2e8f0;border-radius:16px;box-shadow:0 16px 40px rgba(15,23,42,.18);padding:12px 14px;gap:12px;align-items:center}
.pwa-install-banner.show{display:flex}
.modal-backdrop{display:none;position:fixed;inset:0;background:rgba(15,23,42,.55);z-index:10000;align-items:center;justify-content:center;padding:20px}
.modal-backdrop.show{display:flex}
.modal{background:#fff;border-radius:16px;max-width:720px;width:100%;max-height:90vh;overflow:auto}
[data-theme="dark"] .modal{background:#1e293b;color:#f8fafc;border:1px solid #334155}
[data-theme="dark"] .pwa-install-banner{background:#1e293b;color:#f8fafc;border-color:#334155}

/* V12.26 — Theme robust final + legibility guard — ensure ALL hardcoded colors use vars or have dark overrides */
[data-theme="dark"] body{ background:var(--bg,#0f172a); color:var(--txt,#e2e8f0); }
[data-theme="dark"] .app-layout{ background:var(--bg,#0f172a) !important; }
[data-theme="dark"] .app-sidebar{ background:var(--bg2,#0b1222) !important; border-color:var(--line,#334155) !important; }
[data-theme="dark"] .app-topbar{ background:rgba(15,23,42,.92) !important; border-color:var(--line,#334155) !important; }
[data-theme="dark"] .card:not([style*="linear-gradient"]){ background:var(--card,#1e293b) !important; border-color:var(--line,#334155) !important; color:var(--txt,#e2e8f0) !important; }
[data-theme="dark"] .card:not([style*="linear-gradient"]) h3,
[data-theme="dark"] .card:not([style*="linear-gradient"]) h2,
[data-theme="dark"] .card:not([style*="linear-gradient"]) strong{ color:var(--txt,#e2e8f0) !important; }
[data-theme="dark"] .stat-card{ background:var(--card,#1e293b) !important; border-color:var(--line,#334155) !important; }
[data-theme="dark"] .stat-card .stat-label{ color:var(--mut,#94a3b8) !important; }
[data-theme="dark"] .table-wrap{ background:var(--card,#1e293b) !important; border-color:var(--line,#334155) !important; }
[data-theme="dark"] .table-wrap table{ background:var(--card,#1e293b) !important; }
[data-theme="dark"] .table-wrap th{ background:#111c30 !important; color:#94a3b8 !important; }
[data-theme="dark"] .table-wrap td{ color:#cbd5e1 !important; border-color:#1e293b !important; }
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select,
[data-theme="dark"] .form-textarea{ background:#0f172a !important; color:#e2e8f0 !important; border-color:#334155 !important; }
[data-theme="dark"] .btn-outline{ background:var(--card,#1e293b) !important; color:var(--txt,#e2e8f0) !important; border-color:var(--line,#334155) !important; }
[data-theme="dark"] .notif-dropdown,
[data-theme="dark"] #notif-dropdown{ background:#1e293b !important; border-color:#334155 !important; color:#e2e8f0 !important; }
[data-theme="dark"] .notif-item{ background:#1e293b !important; border-color:#334155 !important; color:#e2e8f0 !important; }
[data-theme="dark"] .notif-item-title{ color:#f8fafc !important; }
[data-theme="dark"] .notif-item-msg{ color:#cbd5e1 !important; }
[data-theme="dark"] .notif-item-time{ color:#94a3b8 !important; }
[data-theme="dark"] .notif-entry{ background:#1e293b !important; border-color:#334155 !important; color:#e2e8f0 !important; }
[data-theme="dark"] .notif-entry-title{ color:#f8fafc !important; }
[data-theme="dark"] .notif-entry-msg{ color:#cbd5e1 !important; }
[data-theme="dark"] .notif-entry-time{ color:#94a3b8 !important; }
[data-theme="dark"] .notif-entry-icon{ color:#e2e8f0 !important; }
[data-theme="dark"] .channel-pill{ background:rgba(129,140,248,.2) !important; color:#a5b4fc !important; }
[data-theme="dark"] .mc-side{ background:#1e293b !important; border-color:#334155 !important; }
[data-theme="dark"] .mc-side{ background:#1e293b !important; border-color:#334155 !important; }
[data-theme="dark"] .mc-side-head{ background:#0f172a !important; border-color:#334155 !important; }
[data-theme="dark"] .mc-search{ background:#0f172a !important; }
[data-theme="dark"] .mc-search input{ background:#1e293b !important; color:#e2e8f0 !important; }
[data-theme="dark"] .mc-list{ background:#1e293b !important; }
[data-theme="dark"] .mc-row{ border-color:#1e293b !important; }
[data-theme="dark"] .mc-row:hover{ background:#0f172a !important; }
[data-theme="dark"] .mc-main{ background:#0b1220 !important; }
[data-theme="dark"] .mc-head{ background:#0f172a !important; border-color:#334155 !important; }
[data-theme="dark"] .mc-msgs{ background:#0b1220 !important; }
[data-theme="dark"] .mc-bubble{ background:#1e293b !important; color:#e2e8f0 !important; }
[data-theme="dark"] .mc-msg.mine .mc-bubble{ background:#166534 !important; color:#dcfce7 !important; }
[data-theme="dark"] .mc-day{ background:#1e293b !important; color:#94a3b8 !important; }

/* High contrast mode */
body.sc-high-contrast{ background:#fff !important; color:#000 !important; }
body.sc-high-contrast .app-nav a,
body.sc-high-contrast .app-page-title,
body.sc-high-contrast .table-wrap td{ color:#000 !important; }
body.sc-high-contrast .app-nav a.active{ background:#000 !important; color:#fff !important; }
body.sc-high-contrast .card,
body.sc-high-contrast .table-wrap{ border:2px solid #000 !important; }

/* Reduced motion */
.sc-reduced-motion *{ animation:none !important; transition:none !important; }


/* V12.26 — Legibility for ALL light gradient cards (popup + notification page) — robust */
.card[style*="linear-gradient(135deg,#dbeafe"],
.card[style*="linear-gradient(135deg,#dcfce7"],
.card[style*="linear-gradient(135deg,#fef3c7"],
.card[style*="linear-gradient(135deg,#fee2e2"],
.card[style*="linear-gradient(135deg,#f0fdf4"],
.card[style*="linear-gradient(135deg,#f0f9ff"],
.card[style*="linear-gradient(135deg,#fff7ed"],
.card[style*="linear-gradient(135deg,#ecfdf5"]{ color:#0f172a !important; }
.card[style*="linear-gradient(135deg,#dbeafe"] h3,
.card[style*="linear-gradient(135deg,#dcfce7"] h3,
.card[style*="linear-gradient(135deg,#fef3c7"] h3,
.card[style*="linear-gradient(135deg,#fee2e2"] h3,
.card[style*="linear-gradient(135deg,#f0fdf4"] h3,
.card[style*="linear-gradient(135deg,#f0f9ff"] h3,
.card[style*="linear-gradient(135deg,#fff7ed"] h3,
.card[style*="linear-gradient(135deg,#ecfdf5"] h3,
.card[style*="linear-gradient(135deg,#dbeafe"] p,
.card[style*="linear-gradient(135deg,#dcfce7"] p,
.card[style*="linear-gradient(135deg,#fef3c7"] p,
.card[style*="linear-gradient(135deg,#fee2e2"] p,
.card[style*="linear-gradient(135deg,#f0fdf4"] p,
.card[style*="linear-gradient(135deg,#f0f9ff"] p{ color:#0f172a !important; }

/* Dark mode for light gradient cards — keep dark text? Actually in dark mode, light gradient cards should still have dark text for legibility, OR adapt to dark bg light text? For robustness, keep dark text on light gradient even in dark mode, OR override gradient to dark in dark mode. We choose to keep dark text on light gradient even in dark mode for legibility, plus add dark mode override for gradient itself to be darker if needed. */
[data-theme="dark"] .card[style*="linear-gradient(135deg,#dbeafe"],
[data-theme="dark"] .card[style*="linear-gradient(135deg,#dcfce7"],
[data-theme="dark"] .card[style*="linear-gradient(135deg,#fef3c7"],
[data-theme="dark"] .card[style*="linear-gradient(135deg,#fee2e2"],
[data-theme="dark"] .card[style*="linear-gradient(135deg,#f0fdf4"],
[data-theme="dark"] .card[style*="linear-gradient(135deg,#f0f9ff"]{ background:linear-gradient(135deg,#1e293b,#334155) !important; color:#f8fafc !important; }
[data-theme="dark"] .card[style*="linear-gradient(135deg,#dbeafe"] h3,
[data-theme="dark"] .card[style*="linear-gradient(135deg,#dcfce7"] h3,
[data-theme="dark"] .card[style*="linear-gradient(135deg,#fef3c7"] h3,
[data-theme="dark"] .card[style*="linear-gradient(135deg,#fee2e2"] h3{ color:#f8fafc !important; }

/* Notification bell dropdown — ensure ALWAYS legible, even without JS guard, in both light and dark */
#notif-dropdown{ background:#ffffff !important; color:#0f172a !important; }
#notif-dropdown .notif-item-title{ color:#0f172a !important; }
#notif-dropdown .notif-item-msg{ color:#334155 !important; }
#notif-dropdown .notif-item-time{ color:#64748b !important; }
[data-theme="dark"] #notif-dropdown{ background:#1e293b !important; color:#f8fafc !important; }
[data-theme="dark"] #notif-dropdown .notif-item{ background:#1e293b !important; color:#e2e8f0 !important; }
[data-theme="dark"] #notif-dropdown .notif-item-title{ color:#f8fafc !important; }
[data-theme="dark"] #notif-dropdown .notif-item-msg{ color:#cbd5e1 !important; }
[data-theme="dark"] #notif-dropdown .notif-item-time{ color:#94a3b8 !important; }

/* Notification page list — ALWAYS legible */
#notif-page-list .notif-entry{ background:#ffffff !important; color:#0f172a !important; }
#notif-page-list .notif-entry-title{ color:#0f172a !important; }
#notif-page-list .notif-entry-msg{ color:#334155 !important; }
#notif-page-list .notif-entry-time{ color:#64748b !important; }
[data-theme="dark"] #notif-page-list .notif-entry{ background:#1e293b !important; color:#f8fafc !important; }
[data-theme="dark"] #notif-page-list .notif-entry-title{ color:#f8fafc !important; }
[data-theme="dark"] #notif-page-list .notif-entry-msg{ color:#cbd5e1 !important; }
[data-theme="dark"] #notif-page-list .notif-entry-time{ color:#94a3b8 !important; }


/* V12.31 — Ultimate notification legibility — ensures EVERY text inside notification dropdown and page is legible on EVERY page, in BOTH themes, even with inline styles */
#notif-bell{ z-index: 20001 !important; }
#notif-dropdown{ z-index: 20002 !important; }
#notif-dropdown *{ color: inherit; }
#notif-dropdown .notif-item-title,
#notif-dropdown .notif-item-msg,
#notif-dropdown .notif-item-time,
#notif-dropdown strong,
#notif-dropdown button{ color: inherit; }
#notif-dropdown .notif-item{ background:#ffffff !important; color:#0f172a !important; border-color:#e2e8f0 !important; }
#notif-dropdown .notif-item:hover{ background:#f8fafc !important; }
#notif-dropdown .notif-item.notif-unread{ background:#eef2ff !important; border-left-color:#4f46e5 !important; }
#notif-dropdown .notif-item-title{ color:#0f172a !important; font-weight:800 !important; }
#notif-dropdown .notif-item-msg{ color:#334155 !important; }
#notif-dropdown .notif-item-time{ color:#64748b !important; }
#notif-dropdown .toast-msg{ color:#334155 !important; background:transparent !important; }
[data-theme="dark"] #notif-dropdown{ background:#1e293b !important; border-color:#334155 !important; }
[data-theme="dark"] #notif-dropdown .notif-item{ background:#1e293b !important; color:#f0f8ff !important; border-color:#334155 !important; }
[data-theme="dark"] #notif-dropdown .notif-item:hover{ background:#0f172a !important; }
[data-theme="dark"] #notif-dropdown .notif-item.notif-unread{ background:#1e1b4b !important; border-left-color:#818cf8 !important; }
[data-theme="dark"] #notif-dropdown .notif-item-title{ color:#f8fafc !important; }
[data-theme="dark"] #notif-dropdown .notif-item-msg{ color:#e0e7ff !important; }
[data-theme="dark"] #notif-dropdown .notif-item-time{ color:#cbd5e1 !important; }
[data-theme="dark"] #notif-dropdown strong{ color:#f8fafc !important; }
[data-theme="dark"] #notif-dropdown .toast-msg{ color:#cbd5e1 !important; }
#notif-page-list .notif-entry{ background:#ffffff !important; border-color:#e2e8f0 !important; color:#0f172a !important; }
#notif-page-list .notif-entry .notif-entry-title{ color:#0f172a !important; }
#notif-page-list .notif-entry .notif-entry-msg{ color:#334155 !important; }
#notif-page-list .notif-entry .notif-entry-time{ color:#64748b !important; }
#notif-page-list .notif-entry .notif-entry-icon{ color:#4f46e5 !important; }
#notif-page-list .notif-entry.unread{ background:#eef2ff !important; border-left-color:#4f46e5 !important; }
[data-theme="dark"] #notif-page-list .notif-entry{ background:#1e293b !important; border-color:#334155 !important; color:#f0f8ff !important; }
[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-title{ color:#f8fafc !important; }
[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-msg{ color:#e0e7ff !important; }
[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-time{ color:#cbd5e1 !important; }
[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-icon{ color:#a5b4fc !important; }
[data-theme="dark"] #notif-page-list .notif-entry.unread{ background:#1e1b4b !important; border-left-color:#818cf8 !important; }

/* V12.31 — Final notification legibility — force high contrast via explicit colors, no var() dependency, always legible even if inline styles try to override */
#notif-dropdown{ background:#ffffff !important; color:#0f172a !important; border:1px solid #e2e8f0 !important; box-shadow:0 20px 40px rgba(15,23,42,.18) !important; }
#notif-dropdown .notif-item{ background:#ffffff !important; color:#0f172a !important; border-color:#e2e8f0 !important; }
#notif-dropdown .notif-item:hover{ background:#f8fafc !important; }
#notif-dropdown .notif-item.notif-unread{ background:#eef2ff !important; border-left-color:#4f46e5 !important; }
#notif-dropdown .notif-item-title{ color:#0f172a !important; font-weight:800 !important; }
#notif-dropdown .notif-item-msg{ color:#334155 !important; }
#notif-dropdown .notif-item-time{ color:#64748b !important; }
#notif-dropdown .toast-msg{ color:#334155 !important; background:transparent !important; }
#notif-dropdown strong{ color:#0f172a !important; }
html[data-theme="dark"] #notif-dropdown,
body[data-theme="dark"] #notif-dropdown,
[data-theme="dark"] #notif-dropdown{ background:#ffffff !important; color:#0f172a !important; border-color:#e2e8f0 !important; }
html[data-theme="dark"] #notif-dropdown .notif-item,
body[data-theme="dark"] #notif-dropdown .notif-item,
[data-theme="dark"] #notif-dropdown .notif-item{ background:#ffffff !important; color:#0f172a !important; border-color:#e2e8f0 !important; }
html[data-theme="dark"] #notif-dropdown .notif-item:hover,
body[data-theme="dark"] #notif-dropdown .notif-item:hover{ background:#f8fafc !important; }
html[data-theme="dark"] #notif-dropdown .notif-item.notif-unread,
body[data-theme="dark"] #notif-dropdown .notif-item.notif-unread{ background:#eef2ff !important; border-left-color:#4f46e5 !important; }
html[data-theme="dark"] #notif-dropdown .notif-item-title,
body[data-theme="dark"] #notif-dropdown .notif-item-title{ color:#0f172a !important; }
html[data-theme="dark"] #notif-dropdown .notif-item-msg,
body[data-theme="dark"] #notif-dropdown .notif-item-msg{ color:#334155 !important; }
html[data-theme="dark"] #notif-dropdown .notif-item-time,
body[data-theme="dark"] #notif-dropdown .notif-item-time{ color:#64748b !important; }
html[data-theme="dark"] #notif-dropdown strong,
body[data-theme="dark"] #notif-dropdown strong{ color:#0f172a !important; }
html[data-theme="dark"] #notif-dropdown .toast-msg,
body[data-theme="dark"] #notif-dropdown .toast-msg{ color:#334155 !important; }

#notif-page-list .notif-entry{ background:#ffffff !important; border-color:#e2e8f0 !important; color:#0f172a !important; }
#notif-page-list .notif-entry .notif-entry-title{ color:#0f172a !important; }
#notif-page-list .notif-entry .notif-entry-msg{ color:#334155 !important; }
#notif-page-list .notif-entry .notif-entry-time{ color:#64748b !important; }
#notif-page-list .notif-entry .notif-entry-icon{ color:#4f46e5 !important; }
#notif-page-list .notif-entry.unread{ background:#eef2ff !important; border-left-color:#4f46e5 !important; }
html[data-theme="dark"] #notif-page-list .notif-entry,
body[data-theme="dark"] #notif-page-list .notif-entry{ background:#1e293b !important; border-color:#334155 !important; color:#f8fafc !important; }
html[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-title,
body[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-title{ color:#f8fafc !important; }
html[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-msg,
body[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-msg{ color:#e0e7ff !important; }
html[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-time,
body[data-theme="dark"] #notif-page-list .notif-entry .notif-entry-time{ color:#cbd5e1 !important; }
