/* Theme variables */
:root { --bg: #0b0f17; --text: #e7edf7; --muted: #94a3b8; --card: #121826; --border: #1f2937; --primary: #3b82f6; --danger: #ef4444; --sidebar-active-bg: #1a2233; --accent: #22c55e; --checkbox-bg: #0f172a; --checkbox-checked: #3b82f6; --checkbox-border: #3a4a63; }
:root[data-theme="light"] { --bg: #f8fafc; --text: #0f172a; --muted: #475569; --card: #ffffff; --border: #e2e8f0; --primary: #2563eb; --danger: #dc2626; --sidebar-active-bg: #e6eef8; --accent: #16a34a; --checkbox-bg: #eef2f7; --checkbox-checked: #2563eb; --checkbox-border: #d7dee8; }

* , *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
body.no-scroll { overflow: hidden; }

.container { max-width: 1100px; margin: 0 auto; padding: 24px; }
.container.blank { padding: 0; max-width: none; }

/* App shell */
.app-shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--card); border-right: 1px solid var(--border); padding: 16px 12px; }
.sidebar .nav-item { display: block; padding: 10px 12px; border-radius: 8px; color: var(--text); text-decoration: none; margin-bottom: 6px; }
.sidebar button.nav-item { background: transparent; border: none; -webkit-appearance: none; appearance: none; cursor: pointer; width: 100%; text-align: left; color: var(--text); }
.sidebar .nav-item.active, .sidebar .nav-item:hover { background: var(--sidebar-active-bg); }
.content { padding: 16px 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }

/* Notifications */
.notif-badge { position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 2px 6px; line-height: 1; border: 1px solid var(--border); }
.notif-panel { position: absolute; right: 24px; top: 60px; width: 360px; max-width: calc(100vw - 48px); background: var(--card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,.35); z-index: 50; }
.notif-header { padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
.notif-list { max-height: 360px; overflow: auto; }
.notif-item { padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; display: flex; gap: 8px; align-items: flex-start; }
.notif-item:hover { background: rgba(59,130,246,.08); }
.notif-item .icon { font-size: 18px; line-height: 1; margin-top: 2px; }
.notif-item .content { flex: 1; }
.notif-item .title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.notif-item .text { font-size: 13px; color: var(--muted); }
.notif-empty { padding: 14px 12px; color: var(--muted); }

[data-theme="light"] .notif-item:hover { background: rgba(37,99,235,.08); }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 10px; padding: 16px; margin-bottom: 16px; }
.card h3 { margin-top: 0; }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.metric { background: #0e1421; border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.metric .label { margin: 0; font-size: 12px; color: var(--muted); }
.metric .value { font-size: 22px; font-weight: 700; margin-top: 6px; }
.badge { display: inline-block; padding: 6px 10px; border-radius: 999px; font-size: 12px; border: 1px solid var(--border); background: #172034; }
.badge.ok { background: #0f3d1e; border-color: #1f7a3a; color: #d1fae5; }
.badge.warn { background: #3b2f17; border-color: #8b5e34; color: #fde68a; }
.badge.danger { background: #3d0f14; border-color: #7a1f2a; color: #fecaca; }
.progress { height: 10px; background: #0e1421; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.progress .bar { height: 100%; background: var(--primary); width: 0; transition: width .3s ease; }

.input, select, textarea { width: 100%; padding: 10px 12px; background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 8px; outline: none; font-size: 16px; }
.input:focus, select:focus, textarea:focus { border-color: var(--primary); }

.btn { padding: 12px 16px; border-radius: 8px; border: 1px solid var(--border); background: var(--card); color: var(--text); cursor: pointer; font-size: 16px; text-decoration: none; display: inline-block; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: white; }
.btn.link { background: transparent; border: none; color: var(--text); padding: 0; }

.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, 1fr); }
.grid.three { grid-template-columns: repeat(3, 1fr); }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); }

/* Inline edit styles */
.inline-edit-input { border: none; border-radius: 6px; background: rgba(59, 130, 246, 0.12); padding: 8px 10px; }
.inline-edit-input:focus { border: none; box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25) inset; }
.editing-td { background: rgba(59, 130, 246, 0.08); }
.table td.editing-td { border-bottom: none; }

.alert { padding: 10px 12px; border-radius: 8px; background: #1f2937; border: 1px solid var(--border); color: var(--text); }
.alert.warn { background: #3b2f17; border-color: #8b5e34; }
.alert.info { background: #102a43; border-color: #1f4b99; }

.footer { padding: 16px 24px; border-top: 1px solid var(--border); color: var(--muted); text-align: center; }

.form-row { margin-bottom: 12px; }
.label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 14px; }

.flash { margin: 12px 0; }
.flash .ok { background: #0f3d1e; border: 1px solid #1f7a3a; padding: 10px 12px; border-radius: 8px; }
.flash .err { background: #3d0f14; border: 1px solid #7a1f2a; padding: 10px 12px; border-radius: 8px; }

/* Centered login */
.center-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card { width: 100%; max-width: 456px; border-radius: 16px; margin: 0 auto; }
.login-form { max-width: 384px; margin: 0 auto; }
.login-form .btn { width: 100%; }

/* Custom file input */
.file-input-hidden { position: absolute; left: -9999px; }
.file-trigger { cursor: pointer; }

/* Styled checkboxes for students table */
input[type="checkbox"].styled { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 6px; border: 1px solid var(--checkbox-border); background: var(--checkbox-bg); display: inline-block; position: relative; cursor: pointer; vertical-align: middle; transition: border-color .15s ease, background-color .15s ease, box-shadow .15s ease; }
input[type="checkbox"].styled:hover { border-color: var(--primary); }
input[type="checkbox"].styled:focus { outline: none; box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35); }
input[type="checkbox"].styled:checked { background: var(--checkbox-checked); border-color: var(--checkbox-checked); }
input[type="checkbox"].styled:checked::after { content: none; display: none; }

/* Chat UI */
.chat-wrap { display: flex; flex-direction: column; height: 480px; }
.chat-messages { flex: 1; overflow: auto; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: #0e1421; }
.chat-row { display: flex; margin: 8px 0; }
.chat-row.me { justify-content: flex-end; }
.chat-row.them { justify-content: flex-start; }
.chat-row .bubble { max-width: 70%; padding: 10px 12px; border-radius: 12px; background: #1f2937; color: var(--text); border: 1px solid var(--border); }
.chat-row.me .bubble { background: #1e3a8a; border-color: #1e3a8a; color: #fff; }
.chat-row .bubble .meta { font-size: 12px; color: #cbd5e1; margin-bottom: 6px; opacity: .8; }
.chat-row.me .bubble .meta { color: #e2e8f0; }
.chat-input-row { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; }
.chat-input { resize: vertical; }

/* Light theme overrides for better contrast on light backgrounds */
[data-theme="light"] .metric { background: var(--card); }
[data-theme="light"] .badge { background: #eef2f7; border-color: var(--border); color: var(--text); }
[data-theme="light"] .badge.ok { background: #dcfce7; border-color: #86efac; color: #14532d; }
[data-theme="light"] .badge.warn { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
[data-theme="light"] .badge.danger { background: #fee2e2; border-color: #fca5a5; color: #7f1d1d; }
[data-theme="light"] .progress { background: #eef2f7; }
[data-theme="light"] .alert { background: #f1f5f9; border-color: var(--border); color: var(--text); }
[data-theme="light"] .alert.warn { background: #fef3c7; border-color: #fcd34d; color: #78350f; }
[data-theme="light"] .alert.info { background: #e0f2fe; border-color: #93c5fd; color: #0c4a6e; }
[data-theme="light"] .flash .ok { background: #dcfce7; border-color: #86efac; }
[data-theme="light"] .flash .err { background: #fee2e2; border-color: #fca5a5; }
[data-theme="light"] .chat-messages { background: var(--card); }
[data-theme="light"] .chat-row .bubble { background: var(--card); color: var(--text); border-color: var(--border); }
[data-theme="light"] .chat-row .bubble .meta { color: #64748b; }
[data-theme="light"] .chat-row.me .bubble .meta { color: #475569; }
