:root {
    color-scheme: dark;
    --bg: #050816;
    --bg-soft: #090d1f;
    --panel: rgba(14, 20, 43, .76);
    --panel-solid: #0e142b;
    --panel-hover: #131b36;
    --line: rgba(159, 170, 209, .14);
    --line-strong: rgba(159, 170, 209, .25);
    --text: #f5f7ff;
    --muted: #929bb8;
    --muted-bright: #b8c0da;
    --purple: #8b5cf6;
    --cyan: #22d3ee;
    --blue: #5b8cff;
    --green: #34d399;
    --red: #fb7185;
    --amber: #fbbf24;
    --radius: 16px;
    --shadow: 0 24px 60px rgba(0, 0, 0, .28);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; line-height: 1.5; }
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }
[hidden] { display: none !important; }

input, select {
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 10px;
    background: rgba(5, 8, 22, .68);
    color: var(--text);
    padding: 0 13px;
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
input::placeholder { color: #717b99; }
input:focus, select:focus, button:focus-visible, a:focus-visible {
    border-color: rgba(139, 92, 246, .75);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, .16);
    outline: none;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand > span:last-child { display: flex; flex-direction: column; line-height: 1.15; }
.brand strong { font-size: 17px; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .13em; text-transform: uppercase; }
.brand-mark {
    display: grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px;
    border: 1px solid rgba(139, 92, 246, .42); border-radius: 11px;
    background: linear-gradient(145deg, rgba(139, 92, 246, .24), rgba(34, 211, 238, .12));
    color: #e9e3ff; font-size: 20px; font-weight: 750;
}

.login-body {
    display: grid; place-items: center; min-height: 100vh; padding: 24px;
    background:
        radial-gradient(circle at 18% 10%, rgba(91, 140, 255, .12), transparent 30%),
        radial-gradient(circle at 85% 85%, rgba(139, 92, 246, .11), transparent 28%),
        var(--bg);
}
.login-shell { width: min(100%, 430px); }
.login-card {
    position: relative; overflow: hidden; padding: 34px;
    border: 1px solid var(--line-strong); border-radius: 22px;
    background: linear-gradient(155deg, rgba(18, 25, 52, .92), rgba(8, 12, 29, .94));
    box-shadow: var(--shadow); backdrop-filter: blur(20px);
}
.login-card::before {
    content: ""; position: absolute; inset: 0 0 auto; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(34, 211, 238, .65), rgba(139, 92, 246, .75), transparent);
}
.login-brand { margin-bottom: 44px; }
.login-copy h1 { margin: 8px 0 7px; font-size: 30px; letter-spacing: -.04em; }
.login-copy p { margin: 0 0 28px; color: var(--muted); }
.eyebrow { color: #a9b5da; font-size: 10px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.stack { display: grid; gap: 17px; }
.stack label { display: grid; gap: 7px; color: var(--muted-bright); font-size: 12px; font-weight: 650; }
.stack input { height: 47px; background: rgba(3, 6, 17, .7); }
.primary-button, .secondary-button, .logout-button, .icon-button {
    cursor: pointer; border: 1px solid transparent; border-radius: 10px; font-weight: 650;
    transition: transform .14s ease, background .14s ease, border-color .14s ease, opacity .14s ease;
}
.primary-button { min-height: 47px; margin-top: 4px; background: linear-gradient(105deg, #7557e8, #4f7dda); color: white; }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.07); }
.primary-button:disabled, .secondary-button:disabled { cursor: wait; opacity: .55; transform: none; }
.form-error { margin: -2px 0 0; padding: 10px 12px; border: 1px solid rgba(251, 113, 133, .25); border-radius: 9px; background: rgba(251, 113, 133, .08); color: #fda4af; font-size: 12px; }
.secure-note { margin: 22px 0 0; color: #6f7895; font-size: 11px; text-align: center; }
.secure-note span { margin-right: 5px; color: var(--green); font-size: 8px; }

.app-shell { min-height: 100vh; }
.sidebar {
    position: fixed; z-index: 30; inset: 0 auto 0 0; display: flex; flex-direction: column;
    width: 244px; padding: 24px 18px 18px; border-right: 1px solid var(--line);
    background: rgba(7, 10, 25, .93); backdrop-filter: blur(18px);
}
.sidebar-brand { padding: 0 9px 23px; border-bottom: 1px solid var(--line); }
.side-nav { display: grid; gap: 4px; margin-top: 22px; }
.side-nav a {
    display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 0 12px;
    border: 1px solid transparent; border-radius: 10px; color: #9ca6c3; text-decoration: none; font-weight: 560;
}
.side-nav a span { display: inline-grid; place-items: center; width: 20px; color: #7883a5; font-size: 16px; }
.side-nav a:hover { background: rgba(255, 255, 255, .035); color: #dfe4f4; }
.side-nav a.active { border-color: rgba(139, 92, 246, .22); background: linear-gradient(90deg, rgba(139, 92, 246, .15), rgba(91, 140, 255, .07)); color: white; }
.side-nav a.active span { color: #a78bfa; }
.sidebar-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); }
.logout-button { display: flex; align-items: center; gap: 12px; width: 100%; min-height: 43px; padding: 0 12px; background: transparent; color: #9ca6c3; text-align: left; }
.logout-button:hover { background: rgba(251, 113, 133, .07); color: #fda4af; }
.sidebar-footer p { margin: 14px 12px 0; color: #5e6782; font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }

.workspace { min-height: 100vh; margin-left: 244px; }
.topbar {
    position: sticky; z-index: 20; top: 0; display: flex; align-items: center; gap: 24px;
    min-height: 78px; padding: 13px 32px; border-bottom: 1px solid var(--line);
    background: rgba(5, 8, 22, .82); backdrop-filter: blur(16px);
}
.page-heading { min-width: 210px; }
.page-heading h1 { margin: 0; font-size: 18px; letter-spacing: -.025em; }
.page-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.global-search { display: flex; align-items: center; gap: 8px; width: min(340px, 36vw); margin-left: auto; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: rgba(10, 14, 31, .72); color: #7d87a4; }
.global-search input { width: 100%; min-height: 39px; padding: 0; border: 0; background: transparent; box-shadow: none; }
.admin-chip { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 0 11px; border: 1px solid var(--line); border-radius: 10px; color: var(--muted-bright); font-size: 12px; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(52, 211, 153, .09); }
.menu-button { display: none; }
.content { width: min(1500px, 100%); margin: 0 auto; padding: 30px 32px 48px; }
.page { animation: page-in .18s ease; }
@keyframes page-in { from { opacity: .2; transform: translateY(3px); } }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-head h2 { margin: 4px 0 0; font-size: 25px; line-height: 1.2; letter-spacing: -.04em; }
.secondary-button { min-height: 39px; padding: 0 14px; border-color: var(--line-strong); background: rgba(15, 21, 44, .7); color: #c6cee4; }
.secondary-button:hover { border-color: rgba(139, 92, 246, .45); background: rgba(24, 31, 58, .9); color: white; }
.icon-button { display: grid; place-items: center; width: 38px; height: 38px; background: transparent; border-color: var(--line); }
.icon-button:hover { background: var(--panel-hover); }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.stat-card, .loading-card {
    min-height: 125px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius);
    background: linear-gradient(145deg, rgba(17, 23, 48, .8), rgba(10, 15, 34, .7));
}
.stat-label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .075em; }
.stat-icon { display: grid; place-items: center; width: 29px; height: 29px; border-radius: 8px; background: rgba(139, 92, 246, .1); color: #ad94f9; font-size: 13px; }
.stat-value { margin-top: 16px; font-size: 27px; font-weight: 720; letter-spacing: -.045em; }
.stat-note { margin-top: 2px; color: #69738f; font-size: 10px; }
.loading-card { display: grid; place-items: center; color: var(--muted); }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: 0 12px 36px rgba(0,0,0,.11); }
.activity-panel { margin-top: 18px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 19px 21px; border-bottom: 1px solid var(--line); }
.panel-head h3 { margin: 0; font-size: 14px; }
.panel-head p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.live-label { display: flex; align-items: center; gap: 6px; color: #80e5c1; font-size: 9px; font-weight: 800; letter-spacing: .12em; }
.live-label span { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.activity-feed { max-height: 520px; overflow: auto; }
.activity-item { display: grid; grid-template-columns: 74px 34px minmax(0, 1fr) auto; gap: 12px; align-items: start; padding: 15px 21px; border-bottom: 1px solid rgba(159,170,209,.08); }
.activity-item:last-child { border-bottom: 0; }
.activity-time { color: var(--muted); font-size: 11px; white-space: nowrap; }
.activity-icon { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 9px; background: rgba(91, 140, 255, .1); color: #8cacff; }
.activity-main strong { display: block; font-size: 12px; }
.activity-main p { margin: 3px 0 0; color: var(--muted); font-size: 11px; overflow-wrap: anywhere; }
.activity-actor { color: #8c96b2; font-size: 11px; }

.filter-bar { display: grid; grid-template-columns: minmax(210px, 1fr) 190px 90px auto; gap: 10px; margin-bottom: 13px; }
.filter-bar.wide { grid-template-columns: minmax(170px, 1.3fr) minmax(120px, .7fr) repeat(5, minmax(105px, .6fr)) auto; }
.table-panel { overflow: hidden; }
.table-wrap { overflow: auto; max-height: calc(100vh - 260px); min-height: 190px; }
table { width: 100%; border-collapse: collapse; text-align: left; }
thead { position: sticky; z-index: 2; top: 0; background: #10162e; }
th { height: 45px; padding: 0 15px; border-bottom: 1px solid var(--line-strong); color: #8e98b5; font-size: 10px; font-weight: 750; letter-spacing: .075em; text-transform: uppercase; white-space: nowrap; }
td { max-width: 360px; padding: 13px 15px; border-bottom: 1px solid rgba(159,170,209,.08); color: #bbc3da; font-size: 12px; vertical-align: middle; overflow-wrap: anywhere; }
tbody tr:nth-child(even) { background: rgba(255,255,255,.012); }
tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:hover { background: rgba(91, 140, 255, .055); }
tbody tr:last-child td { border-bottom: 0; }
.cell-primary { color: #edf0fa; font-weight: 620; }
.cell-secondary { display: block; margin-top: 2px; color: #78839f; font-size: 10px; }
.truncate { display: block; max-width: 410px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; border-radius: 999px; background: rgba(148,163,184,.09); color: #aab3c9; font-size: 9px; font-weight: 780; letter-spacing: .05em; text-transform: uppercase; white-space: nowrap; }
.status-pill::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.status-pill.good { background: rgba(52,211,153,.09); color: #6ee7b7; }
.status-pill.bad { background: rgba(251,113,133,.09); color: #fda4af; }
.status-pill.warn { background: rgba(251,191,36,.09); color: #fcd34d; }
.loading-state, .empty-state, .error-state { min-height: 130px; padding: 32px !important; color: var(--muted); text-align: center; }
.error-state { color: #fda4af; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 55px; padding: 9px 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.pagination button { min-width: 34px; height: 32px; border: 1px solid var(--line); border-radius: 8px; background: rgba(5,8,22,.5); color: #b3bdd5; cursor: pointer; }
.pagination button:disabled { cursor: default; opacity: .35; }
.pagination .page-count { margin-right: 5px; }

.analytics-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.chart-card { min-height: 270px; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.chart-card h3 { margin: 0; font-size: 14px; }
.chart-card > p { margin: 3px 0 0; color: var(--muted); font-size: 10px; }
.bar-chart { display: flex; align-items: end; gap: 9px; min-height: 180px; margin-top: 20px; padding-top: 18px; border-bottom: 1px solid var(--line); }
.bar-column { display: flex; flex: 1; flex-direction: column; align-items: center; justify-content: flex-end; min-width: 22px; height: 160px; }
.bar-value { margin-bottom: 5px; color: #aeb8d1; font-size: 9px; }
.bar { width: min(34px, 72%); min-height: 2px; border-radius: 6px 6px 2px 2px; background: linear-gradient(180deg, #8b5cf6, #586dd4); }
.bar.cyan { background: linear-gradient(180deg, #22d3ee, #477bca); }
.bar-label { margin-top: 7px; color: #737d9a; font-size: 9px; white-space: nowrap; }
.distribution { display: grid; gap: 12px; margin-top: 22px; }
.distribution-row { display: grid; grid-template-columns: 120px 1fr 38px; gap: 10px; align-items: center; color: #aeb7ce; font-size: 11px; }
.distribution-track { height: 7px; overflow: hidden; border-radius: 99px; background: rgba(148,163,184,.09); }
.distribution-fill { height: 100%; border-radius: inherit; background: linear-gradient(90deg, #6655d9, #4f8bda); }
.distribution-value { text-align: right; color: #7f89a5; }

.system-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.system-card { min-height: 128px; padding: 19px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.system-card .system-label { color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.system-card .system-value { margin-top: 14px; color: #edf0f9; font-size: 18px; font-weight: 680; overflow-wrap: anywhere; }
.system-card .system-note { margin-top: 5px; color: #737e9b; font-size: 10px; }

.detail-dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--line-strong); border-radius: 18px; background: #0b1024; color: var(--text); box-shadow: 0 30px 90px rgba(0,0,0,.6); }
.detail-dialog::backdrop { background: rgba(1, 3, 10, .76); backdrop-filter: blur(4px); }
.dialog-head { position: sticky; z-index: 2; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 19px 21px; border-bottom: 1px solid var(--line); background: rgba(11,16,36,.96); }
.dialog-head h2 { margin: 3px 0 0; font-size: 20px; letter-spacing: -.03em; }
.dialog-content { padding: 21px; overflow: auto; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.detail-field { padding: 13px; border: 1px solid var(--line); border-radius: 11px; background: rgba(4,7,18,.35); }
.detail-field.wide { grid-column: 1 / -1; }
.detail-field dt { color: #737e9b; font-size: 9px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.detail-field dd { margin: 5px 0 0; color: #dce1ef; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.dialog-section { margin-top: 22px; }
.dialog-section h3 { margin: 0 0 10px; font-size: 12px; }
.mini-list { display: grid; gap: 7px; }
.mini-item { padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; color: #aeb8d0; font-size: 11px; background: rgba(255,255,255,.015); }
.mini-item strong { color: #e3e7f2; }
.toast { position: fixed; z-index: 80; right: 22px; bottom: 22px; max-width: 360px; padding: 12px 15px; border: 1px solid var(--line-strong); border-radius: 11px; background: #151c36; box-shadow: var(--shadow); color: #d7deef; font-size: 12px; }

@media (max-width: 1180px) {
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .filter-bar.wide { grid-template-columns: repeat(4, minmax(120px, 1fr)); }
    .system-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: 30px 0 80px rgba(0,0,0,.5); }
    .sidebar.open { transform: translateX(0); }
    .workspace { margin-left: 0; }
    .menu-button { display: grid; }
    .topbar { min-height: 68px; padding: 10px 16px; gap: 11px; }
    .page-heading p, .admin-chip { display: none; }
    .page-heading { min-width: 0; }
    .global-search { width: min(280px, 48vw); }
    .content { padding: 23px 17px 40px; }
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-bar, .filter-bar.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .analytics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .login-card { padding: 26px 21px; }
    .login-brand { margin-bottom: 36px; }
    .global-search { display: none; }
    .stat-grid, .system-grid, .filter-bar, .filter-bar.wide { grid-template-columns: 1fr; }
    .stat-card { min-height: 112px; }
    .activity-item { grid-template-columns: 58px 28px 1fr; padding: 13px; gap: 8px; }
    .activity-actor { display: none; }
    .activity-icon { width: 28px; height: 28px; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-field.wide { grid-column: auto; }
    .section-head { align-items: center; }
    td, th { padding-left: 12px; padding-right: 12px; }
}

/* High-contrast light workspace theme. The admin remains visually separate from Tutorly's student UI. */
:root {
    color-scheme: light;
    --bg: #eef3ff;
    --bg-soft: #e5ebfa;
    --panel: rgba(255, 255, 255, .94);
    --panel-solid: #ffffff;
    --panel-hover: #edf1ff;
    --line: rgba(54, 70, 122, .15);
    --line-strong: rgba(54, 70, 122, .28);
    --text: #17203b;
    --muted: #5f6b8b;
    --muted-bright: #394563;
    --purple: #6658df;
    --cyan: #078fa8;
    --blue: #3567cf;
    --green: #087f5b;
    --red: #c43e5b;
    --amber: #9a6500;
    --shadow: 0 20px 55px rgba(42, 55, 100, .14);
}

html, body {
    background:
        radial-gradient(circle at 85% 5%, rgba(102, 88, 223, .08), transparent 28%),
        var(--bg);
}

input, select { background: #ffffff; color: var(--text); }
input::placeholder { color: #7a86a6; }
.brand-mark {
    border-color: rgba(102, 88, 223, .34);
    background: linear-gradient(145deg, #e7e4ff, #dcf5fa);
    color: #4a3ec0;
}

.login-body {
    background:
        radial-gradient(circle at 18% 10%, rgba(53, 103, 207, .12), transparent 30%),
        radial-gradient(circle at 85% 85%, rgba(102, 88, 223, .11), transparent 28%),
        var(--bg);
}
.login-card { background: rgba(255, 255, 255, .96); }
.login-copy p, .brand small { color: var(--muted); }
.eyebrow { color: #536593; }
.stack input { background: #f8faff; }
.form-error { background: #fff0f3; color: #a62343; }
.secure-note { color: #687492; }

.sidebar { background: rgba(246, 248, 255, .97); }
.side-nav a, .logout-button { color: #53607e; }
.side-nav a span { color: #6b7696; }
.side-nav a:hover { background: #e9edfb; color: #1d2947; }
.side-nav a.active {
    border-color: rgba(102, 88, 223, .25);
    background: linear-gradient(90deg, #e7e3ff, #e9f1ff);
    color: #2f267d;
}
.side-nav a.active span { color: #5a49d1; }
.logout-button:hover { background: #fff0f3; color: #ad2947; }
.sidebar-footer p { color: #7d87a2; }

.topbar { background: rgba(250, 251, 255, .92); }
.global-search { background: #ffffff; color: #6a7696; }
.secondary-button { background: #ffffff; color: #33405f; }
.secondary-button:hover { background: #edf1ff; color: #252f4d; }
.stat-card, .loading-card { background: linear-gradient(145deg, #ffffff, #f7f9ff); }
.stat-icon { background: #ece9ff; color: #5748ce; }
.stat-note { color: #6f7b9c; }
.panel, .chart-card, .system-card { box-shadow: 0 12px 34px rgba(49, 64, 111, .08); }
.activity-icon { background: #e8efff; color: #3567cf; }
.activity-actor { color: #65718f; }

thead { background: #e9eefb; }
th { color: #4f5c7c; }
td { color: #35415e; }
tbody tr:nth-child(even) { background: rgba(77, 96, 157, .035); }
tbody tr[data-id]:hover { background: #edf2ff; }
.cell-primary { color: #16213d; }
.cell-secondary { color: #667493; }
.status-pill { background: #edf0f6; color: #55617e; }
.status-pill.good { background: #dcf7ed; color: #067453; }
.status-pill.bad { background: #ffe5eb; color: #b32849; }
.status-pill.warn { background: #fff2cc; color: #8c5b00; }
.pagination button { background: #ffffff; color: #3d4a68; }

.bar-value, .distribution-row { color: #4e5c7b; }
.bar-label, .distribution-value { color: #687595; }
.distribution-track { background: #e3e8f3; }
.system-card .system-value { color: #18233e; }
.system-card .system-note { color: #687595; }

.detail-dialog { background: #ffffff; box-shadow: 0 30px 90px rgba(39, 51, 94, .25); }
.detail-dialog::backdrop { background: rgba(38, 48, 82, .35); }
.dialog-head { background: rgba(248, 250, 255, .97); }
.detail-field { background: #f7f9ff; }
.detail-field dt { color: #667493; }
.detail-field dd { color: #293552; }
.mini-item { background: #f8faff; color: #46536f; }
.mini-item strong { color: #1d2946; }
.toast { background: #ffffff; color: #293552; }
