/* Panel — light theme sharing the landing's palette (see landing.css). */

:root {
    /* Brand palette: #1D52F2 #1D64F2 #6B98F2 #F2EEEB #F26A4B */
    --brand: #1d52f2;
    --brand-light: #6b98f2;
    --cream: #f2eeeb;
    --bg-hi: #f2eeeb;
    --bg: #ffffff;
    --bg-soft: #f7f5f3;
    --bg-soft-2: #f2eeeb;
    --bg-card: #ffffff;
    --border: #e8e3de;
    --text-hi: #111a3a;
    --text: #4f5673;
    --text-dim: #868ca3;
    --accent: #1d64f2;
    --accent-hi: #1d52f2;
    --accent-soft: #e6eefd;
    --warm: #f26a4b;
    --warm-soft: #fde8e2;
    --success: #14b892;
    --success-soft: #e2f8f2;
    --warn: #e0892a;
    --warn-soft: #fff3e0;
    --error: #e5484d;
    --error-soft: #fdecec;
    --shadow-sm: 0 1px 2px rgba(17, 26, 58, 0.04), 0 4px 14px -6px rgba(17, 26, 58, 0.08);
    --shadow: 0 24px 60px -20px rgba(17, 26, 58, 0.18);
    --ring: 0 0 0 4px rgba(107, 152, 242, 0.3);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --dur-fast: 0.12s;
    --dur: 0.2s;
    --dur-slow: 0.32s;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-hi);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 6px;
}

::selection {
    background: var(--accent-soft);
    color: var(--text-hi);
}

.app-shell {
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 22px;
    padding: 36px 32px;
    box-shadow: var(--shadow-sm);
}

.panel-main > .card + .card,
.panel-main > .stat-grid + .card {
    margin-top: 18px;
}

.panel-main > .card:not(.table-card):not(.chat-rooms):not(.chat-pane) {
    max-width: none;
    padding: 24px;
}

.card-title {
    margin: 0 0 8px;
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-hi);
}

.card-h2 {
    margin: 0 0 16px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-hi);
}

.card-message {
    margin: 0;
    font-size: 15px;
    color: var(--text);
}

.card-meta {
    display: flex;
    gap: 8px;
    margin: 20px 0 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.5;
    border-radius: 100px;
    border: 1px solid transparent;
    background: var(--bg-soft-2);
    color: var(--text);
    white-space: nowrap;
}

.badge[data-state]::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.badge[data-state="ok"],
.badge[data-state="active"],
.badge[data-state="open"],
.badge[data-state="completed"],
.badge[data-state="graduated"] {
    color: #0b8a6c;
    background: var(--success-soft);
}

.badge[data-state="in_progress"] {
    color: var(--accent-hi);
    background: var(--accent-soft);
}

.badge[data-state="checking"],
.badge[data-state="pending"],
.badge[data-state="planned"] {
    color: #c2571f;
    background: var(--warm-soft);
}

.badge[data-state="error"],
.badge[data-state="suspended"],
.badge[data-state="dropped"] {
    color: #c9363b;
    background: var(--error-soft);
}

.badge[data-state="inactive"],
.badge[data-state="closed"] {
    color: var(--text-dim);
    background: var(--bg-soft-2);
}

.card-link {
    display: inline-block;
    margin-top: 20px;
    font-weight: 600;
    text-decoration: none;
    color: var(--accent);
}

.card-link:hover {
    color: var(--accent-hi);
}

.card-footer {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
}

@media (max-width: 480px) {
    .card {
        padding: 24px 20px;
    }
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    border-radius: 100px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text-hi);
    cursor: pointer;
    text-decoration: none;
    transition: border-color var(--dur) var(--ease-out), color var(--dur) var(--ease-out),
        background var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out),
        transform var(--dur-fast) var(--ease-out);
}

.btn:hover {
    color: var(--text-hi);
    border-color: var(--text-hi);
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.btn-primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
    box-shadow: 0 10px 24px -10px rgba(29, 82, 242, 0.5);
}

.btn-primary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 14px 30px -10px rgba(29, 100, 242, 0.55);
}

.btn-danger {
    color: var(--error);
    border-color: rgba(229, 72, 77, 0.3);
    background: var(--bg);
}

.btn-danger:hover {
    color: #fff;
    background: var(--error);
    border-color: var(--error);
}

.btn-ghost {
    background: transparent;
}

.btn-sm {
    padding: 5px 12px;
    font-size: 12px;
}

.btn-block {
    width: 100%;
}

.input {
    width: 100%;
    padding: 10px 14px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-hi);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    outline: none;
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.input::placeholder {
    color: var(--text-dim);
}

.input:hover {
    border-color: #d9d2cb;
}

.input:focus {
    border-color: var(--accent);
    box-shadow: var(--ring);
}

select.input {
    appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
        linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 36px;
}

textarea.input {
    resize: vertical;
    min-height: 84px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field > span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-hi);
}

.field.inline {
    flex-direction: row;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
}

.field.inline > span {
    color: var(--text);
}

.field.inline .input {
    min-width: 220px;
}

.field-error {
    font-size: 12px;
    color: var(--error);
    margin-top: -2px;
}

.field.has-error > span {
    color: var(--error);
}

.field.has-error .input {
    border-color: var(--error);
}

.field.has-error .input:focus {
    box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.14);
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.form-error {
    margin: 0;
    padding: 10px 14px;
    font-size: 13px;
    color: #b52d32;
    background: var(--error-soft);
    border: 1px solid rgba(229, 72, 77, 0.25);
    border-radius: 12px;
}

.form-hint {
    margin: 0;
    font-size: 12px;
    color: var(--text-dim);
}

.login-card {
    max-width: 420px;
}

/* ---------- Login ---------- */

.auth-shell {
    position: relative;
    overflow: hidden;
    min-height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.auth-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.9;
    pointer-events: none;
}

.auth-orb-1 { width: 420px; height: 420px; top: -140px; left: -100px; background: var(--accent-soft); }
.auth-orb-2 { width: 340px; height: 340px; bottom: -120px; right: -80px; background: var(--success-soft); }
.auth-orb-3 { width: 240px; height: 240px; top: 40%; left: 62%; background: var(--warm-soft); }

.auth-card {
    position: relative;
    z-index: 1;
    max-width: 430px;
    padding: 34px 34px 26px;
    border-radius: 28px;
    box-shadow: var(--shadow);
}

.auth-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

.auth-mark {
    flex: 0 0 auto;
    width: 50px;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: var(--brand);
    box-shadow: 0 10px 24px -8px rgba(29, 82, 242, 0.45);
}

.auth-mark img {
    width: 64%;
    height: auto;
    display: block;
}

.auth-heading {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.auth-title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-hi);
}

.auth-sub {
    margin: 0;
    font-size: 14px;
    color: var(--text);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.field-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-hi);
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap .input-icon {
    position: absolute;
    left: 14px;
    width: 17px;
    height: 17px;
    color: var(--text-dim);
    pointer-events: none;
    z-index: 1;
    transition: color var(--dur) var(--ease-out);
}

.input-wrap:focus-within .input-icon {
    color: var(--accent);
}

.input-wrap input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    font-family: inherit;
    font-size: 14px;
    color: var(--text-hi);
    background: var(--bg-soft);
    border: 1px solid var(--border);
    border-radius: 14px;
    outline: none;
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out),
        background var(--dur) var(--ease-out);
}

.input-wrap:has(.input-toggle) input {
    padding-right: 52px;
}

.input-wrap input::placeholder {
    color: var(--text-dim);
}

.input-wrap input:focus {
    background: var(--bg);
    border-color: var(--accent);
    box-shadow: var(--ring);
}

.input-toggle {
    position: absolute;
    right: 8px;
    padding: 4px 10px;
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 100px;
    cursor: pointer;
}

.input-toggle:hover {
    color: var(--accent);
    background: var(--accent-soft);
}

.btn-label {
    display: inline-block;
}

.btn-spinner {
    display: none;
}

.btn[data-loading] .btn-spinner {
    display: inline-block;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.35);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.btn[data-loading] .btn-label {
    display: none;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.auth-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.auth-footer .card-link {
    margin-top: 0;
    font-size: 14px;
}

.auth-copy {
    font-size: 12px;
    color: var(--text-dim);
}

@media (max-width: 480px) {
    .auth-card {
        padding: 26px 20px 20px;
    }
}

/* ---------- Shell / sidebar ---------- */

.panel-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 256px;
    flex: 0 0 256px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px 14px;
    background: var(--bg);
    border-right: 1px solid var(--border);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px 16px;
}

.sidebar-home {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.sidebar-mark {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--brand);
    flex: 0 0 auto;
}

.sidebar-mark img {
    width: 64%;
    height: auto;
    display: block;
}

.sidebar-logo-img {
    display: block;
    height: 48px;
    width: auto;
}

.sidebar-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-hi);
    letter-spacing: -0.02em;
}

.sidebar-brand .badge,
.mobile-topbar .badge {
    color: var(--accent);
    background: var(--accent-soft);
}

.mobile-topbar .badge {
    margin-left: auto;
}

.sidebar-nav {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 3px;
    flex: 1;
    overflow-y: auto;
}

.nav-group {
    margin: 16px 10px 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    text-decoration: none;
    border: 1px solid transparent;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sidebar-link:hover {
    color: var(--text-hi);
    background: var(--bg-soft);
}

/* GSAP-driven hover highlight that glides between links (see panel-fx.js). */
.sidebar-nav.has-glow .sidebar-link {
    position: relative;
    z-index: 1;
}

.sidebar-nav.has-glow .sidebar-link:not(.is-active):hover {
    background: transparent;
}

.nav-glow {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 0;
    border-radius: 12px;
    background: var(--bg-soft);
    opacity: 0;
    pointer-events: none;
}

.mobile-topbar,
.sidebar-backdrop {
    display: none;
}

.sidebar-link.is-active {
    color: var(--accent-hi);
    font-weight: 600;
    background: var(--accent-soft);
}

.nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
    opacity: 0.85;
}

.sidebar-link.is-active .nav-icon {
    color: var(--accent);
    opacity: 1;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 14px;
    background: var(--bg-soft);
}

.user-avatar {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.user-meta {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.25;
}

.user-meta strong {
    font-size: 13px;
    color: var(--text-hi);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    font-size: 11px;
    color: var(--text-dim);
}

.panel-main {
    flex: 1;
    min-width: 0;
    padding: 32px 40px 56px;
}

.page-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 26px;
}

.page-title {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-hi);
    letter-spacing: -0.025em;
}

.page-subtitle {
    margin: 2px 0 0;
    font-size: 15px;
    color: var(--text);
}

/* ---------- Tables ---------- */

.table-card {
    max-width: none;
    padding: 20px;
}

.list-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.list-toolbar > .input[type="search"] {
    flex: 1 1 240px;
    max-width: 360px;
    padding-left: 38px;
    background-color: var(--bg-soft);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8ea8' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 13px 50%;
    background-size: 16px 16px;
}

.list-toolbar > .input[type="search"]:focus {
    background-color: var(--bg);
}

.list-count {
    margin-left: auto;
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
}

.table-wrap {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

.data-table th {
    text-align: left;
    padding: 10px 14px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-dim);
    background: var(--bg-soft);
    white-space: nowrap;
}

.data-table th:first-child {
    border-radius: 12px 0 0 12px;
}

.data-table th:last-child {
    border-radius: 0 12px 12px 0;
}

.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr {
    transition: background var(--dur-fast);
}

.data-table tbody tr:hover {
    background: #fbfaf8;
}

.data-table td strong {
    color: var(--text-hi);
}

.data-table code {
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--accent-soft);
    font-family: ui-monospace, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--accent-hi);
}

.row-actions {
    text-align: right;
}

.row-actions-inner {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
}

.list-empty {
    padding: 36px 26px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
}

/* ---------- Dashboard ---------- */

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat {
    --stat-tint: var(--accent);
    --stat-soft: var(--accent-soft);
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 20px 22px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out),
        transform var(--dur) var(--ease-out);
}

.stat:nth-child(3n + 2) {
    --stat-tint: var(--success);
    --stat-soft: var(--success-soft);
}

.stat:nth-child(3n + 3) {
    --stat-tint: var(--warm);
    --stat-soft: var(--warm-soft);
}

.stat::before {
    content: "";
    width: 28px;
    height: 4px;
    margin-bottom: 10px;
    border-radius: 4px;
    background: var(--stat-tint);
}

.stat::after {
    content: "";
    position: absolute;
    inset: auto -40px -60px auto;
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: var(--stat-soft);
    pointer-events: none;
}

.stat > * {
    position: relative;
    z-index: 1;
}

.stat:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: var(--text-hi);
    font-variant-numeric: tabular-nums;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
}

.profile-rows {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 10px;
}

.profile-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    background: var(--bg-soft);
    border-radius: 14px;
}

.profile-row span {
    font-size: 12px;
    color: var(--text-dim);
}

.profile-row strong {
    font-size: 14px;
    color: var(--text-hi);
}

.academic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.academic-card-inner {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 18px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    transition: border-color var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out);
}

.academic-card-inner:hover {
    border-color: #d9d2cb;
    box-shadow: var(--shadow-sm);
}

.academic-card-inner h3 {
    margin: 0;
    font-size: 16px;
    color: var(--text-hi);
}

.academic-card-inner p {
    margin: 0;
    font-size: 13px;
    color: var(--text);
}

.academic-card-inner .mini-schedule {
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-self: stretch;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--text);
    background: var(--bg-soft);
    border-radius: 12px;
}

.academic-card-inner .btn {
    align-self: flex-start;
    margin-top: 4px;
}

.stat-grid-admin {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (min-width: 1360px) {
    .stat-grid-admin { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .stat-grid-admin { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    .stat-grid-admin .stat { padding: 16px; }
    .stat-grid-admin .stat-value { font-size: 26px; }
    .dash-table .dash-col-teacher { display: none; }
}

.stat-note {
    font-size: 12px;
    color: var(--text-dim);
}

.dash-header {
    align-items: flex-end;
}

.dash-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

@media (max-width: 1100px) {
    .dash-grid { grid-template-columns: minmax(0, 1fr); }
}

.dash-grid > .dash-card {
    max-width: none;
    padding: 22px 24px;
}

.dash-card-wide {
    grid-column: 1 / -1;
}

.dash-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.dash-card-head .card-h2 {
    margin: 0;
}

.dash-card-head .card-link {
    margin-top: 0;
    font-size: 13px;
}

.dash-muted {
    font-size: 13px;
    color: var(--text-dim);
}

.dash-empty {
    margin: 0 0 12px;
}

.dash-ok {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--success-soft);
    color: #0b8a6c;
    font-size: 14px;
    font-weight: 600;
}

.dash-alerts {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-alerts a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 14px;
    border-radius: 14px;
    background: var(--warn-soft);
    color: var(--text-hi);
    font-size: 14px;
    text-decoration: none;
    transition: background var(--dur) var(--ease-out);
}

.dash-alerts a:hover {
    background: #ffe8c7;
}

.dash-alerts .bi:first-child {
    color: #b8651a;
}

.dash-alerts strong {
    font-variant-numeric: tabular-nums;
}

.dash-alerts span {
    flex: 1;
    color: var(--text);
}

.dash-alert-go {
    color: var(--text-dim);
}

.dash-slots {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dash-slot {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bg-soft);
    border-left: 4px solid var(--accent);
}

.dash-slot.is-done {
    opacity: 0.55;
    border-left-color: var(--border);
}

.dash-slot-time {
    flex: none;
    min-width: 92px;
    font-size: 13px;
    font-weight: 700;
    color: var(--accent-hi);
    font-variant-numeric: tabular-nums;
}

.dash-slot-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.dash-slot-main strong {
    font-size: 14px;
    color: var(--text-hi);
}

.dash-slot-main small {
    font-size: 12px;
    color: var(--text-dim);
}

.dash-bars {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.dash-bar-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13.5px;
}

.dash-bar-label > span:first-child {
    flex: 1;
    min-width: 0;
    color: var(--text-hi);
}

.dash-bar-label small {
    color: var(--text-dim);
}

.dash-bar-value {
    font-weight: 700;
    color: var(--text-hi);
    font-variant-numeric: tabular-nums;
}

.dash-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 100px;
    font-size: 11.5px;
    font-weight: 600;
}

.dash-tag[data-state="high"] {
    color: #b8651a;
    background: var(--warn-soft);
}

.dash-tag[data-state="full"] {
    color: #c62f35;
    background: var(--error-soft);
}

.dash-bar {
    height: 8px;
    border-radius: 8px;
    background: var(--bg-soft-2);
    overflow: hidden;
}

.dash-bar > span {
    display: block;
    height: 100%;
    border-radius: 8px;
    background: var(--accent);
}

.dash-bar > span[data-state="high"] {
    background: var(--warn);
}

.dash-bar > span[data-state="full"] {
    background: var(--error);
}

.dash-bar-thin {
    height: 6px;
}

.dash-bar-thin > span {
    background: var(--brand-light);
}

.dash-big {
    margin: 0 0 14px;
    font-size: 14px;
    color: var(--text);
}

.dash-big strong {
    font-size: 26px;
    color: var(--text-hi);
    font-variant-numeric: tabular-nums;
}

.dash-columns {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 10px;
    height: 150px;
}

.dash-col {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    outline: none;
}

.dash-col-track {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.dash-col-fill {
    display: block;
    width: 100%;
    max-width: 34px;
    border-radius: 4px 4px 0 0;
    background: var(--accent);
    transition: background var(--dur) var(--ease-out);
}

.dash-col-value {
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-hi);
}

.dash-col-day {
    text-align: center;
    font-size: 12px;
    color: var(--text-dim);
    text-transform: capitalize;
}

.dash-col-day.is-today {
    color: var(--text-hi);
    font-weight: 700;
}

.dash-col:hover .dash-col-fill,
.dash-col:focus-visible .dash-col-fill {
    background: var(--accent-hi);
}

.dash-col:hover::after,
.dash-col:focus-visible::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    padding: 6px 10px;
    border-radius: 10px;
    background: var(--text-hi);
    color: #fff;
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
}

.dash-table-wrap {
    overflow-x: auto;
}

.dash-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
}

.dash-table th {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
}

.dash-table td {
    padding: 11px 12px;
    border-bottom: 1px solid var(--border);
    color: var(--text);
    vertical-align: middle;
}

.dash-table tr:last-child td {
    border-bottom: 0;
}

.dash-table td strong {
    color: var(--text-hi);
}

.dash-table td small {
    display: block;
    font-size: 12px;
    color: var(--text-dim);
}

.dash-breakdown {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dash-breakdown li {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr) 32px;
    align-items: center;
    gap: 12px;
}

.dash-breakdown .badge {
    justify-self: start;
}

.dash-breakdown strong {
    text-align: right;
    color: var(--text-hi);
    font-variant-numeric: tabular-nums;
}

.panel-main > .dash-grid + .card,
.panel-main > .stat-grid + .dash-grid {
    margin-top: 0;
}

/* ---------- Chat ---------- */

.chat-shell {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 18px;
    align-items: stretch;
}

.chat-rooms {
    padding: 16px;
    max-width: none;
    display: flex;
    flex-direction: column;
}

.chat-rooms .list-toolbar > .input[type="search"] {
    max-width: none;
}

.chat-room-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    overflow-y: auto;
    max-height: calc(100vh - 230px);
}

.chat-room {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 12px 14px;
    font-family: inherit;
    text-align: left;
    background: var(--bg);
    border: 1px solid transparent;
    border-radius: 14px;
    cursor: pointer;
    color: var(--text);
    transition: border-color 0.15s, background 0.15s;
}

.chat-room:hover {
    background: var(--bg-soft);
}

.chat-room.is-active {
    background: var(--accent-soft);
    border-color: rgba(29, 100, 242, 0.25);
}

.chat-room strong {
    font-size: 14px;
    color: var(--text-hi);
}

.chat-room span {
    font-size: 13px;
}

.chat-room small {
    font-size: 12px;
    color: var(--text-dim);
}

.chat-pane {
    max-width: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    min-height: 540px;
    overflow: hidden;
}

.chat-pane-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border);
}

.chat-header-main {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.chat-back {
    display: none;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    padding: 0;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.chat-context {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.chat-course {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-hi);
}

.chat-with {
    font-size: 13px;
    color: var(--text-dim);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 300px;
    background: var(--bg-soft);
}

.chat-messages[data-empty] {
    justify-content: center;
    align-items: center;
}

.bubble {
    position: relative;
    max-width: 72%;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 10px 36px 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.45;
}

.bubble.bubble-new {
    animation: bubble-in var(--dur-slow) var(--ease-out);
}

@keyframes bubble-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.bubble-other {
    align-self: flex-start;
    background: var(--bg);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
}

.bubble-mine {
    align-self: flex-end;
    background: var(--accent);
    border: 1px solid var(--accent);
    border-bottom-right-radius: 6px;
}

.bubble-who {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
}

.bubble-text {
    color: var(--text-hi);
    white-space: pre-wrap;
    word-break: break-word;
}

.bubble-time {
    font-size: 11px;
    color: var(--text-dim);
    text-align: right;
}

.bubble-mine .bubble-who,
.bubble-mine .bubble-text {
    color: #fff;
}

.bubble-mine .bubble-time,
.bubble-mine .bubble-edited {
    color: rgba(255, 255, 255, 0.72);
}

.chat-composer {
    display: flex;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--border);
    background: var(--bg);
}

.chat-composer .input {
    flex: 1;
    border-radius: 100px;
    padding-left: 18px;
    background: var(--bg-soft);
}

.chat-composer .input:focus {
    background: var(--bg);
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-dim);
}

.chat-status[hidden],
.typing-indicator[hidden] {
    display: none;
}

.chat-status-sep {
    opacity: 0.6;
}

.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #cfc8c1;
    transition: background 0.2s, box-shadow 0.2s;
}

.online-dot.is-online {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(20, 184, 146, 0.18);
}

.chat-room-presence {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}

.chat-room-unread {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--warm);
    box-shadow: 0 0 0 3px var(--warm-soft);
}

.chat-conn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
}

.chat-conn-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-dim);
}

.chat-conn-dot[data-state="online"] {
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(20, 184, 146, 0.18);
}

.chat-conn-dot[data-state="connecting"] {
    background: var(--warm);
    box-shadow: 0 0 0 3px rgba(242, 106, 75, 0.18);
    animation: chat-conn-pulse 1.2s ease-in-out infinite;
}

.chat-conn-dot[data-state="offline"] {
    background: var(--error);
    box-shadow: 0 0 0 3px rgba(229, 72, 77, 0.18);
}

@keyframes chat-conn-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 22px;
    font-size: 12px;
    color: var(--text-dim);
    background: var(--bg-soft);
}

.typing-dots {
    display: inline-flex;
    gap: 3px;
}

.typing-dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--accent);
    animation: typing-bounce 1.1s infinite ease-in-out;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

.badge-admin {
    display: inline-block;
    margin-left: 5px;
    padding: 1px 7px;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.12em;
    vertical-align: middle;
    color: #fff;
    border-radius: 100px;
    background: linear-gradient(135deg, var(--warm), var(--accent) 70%);
}

.bubble-deleted {
    opacity: 0.7;
    border-style: dashed;
}

.bubble-deleted .bubble-text {
    font-style: italic;
    color: var(--text-dim);
}

.bubble-mine.bubble-deleted {
    background: var(--accent-soft);
    border-color: rgba(29, 100, 242, 0.4);
}

.bubble-mine.bubble-deleted .bubble-who {
    color: var(--accent);
}

.bubble-mine.bubble-deleted .bubble-time {
    color: var(--text-dim);
}

.bubble-edited {
    color: var(--text-dim);
    font-size: 11px;
}

.msg-menu {
    position: absolute;
    top: 9px;
    right: 10px;
    padding: 3px 7px;
    font-size: 12px;
    line-height: 1;
    color: var(--text-dim);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    opacity: 0.5;
}

.bubble-mine .msg-menu {
    color: rgba(255, 255, 255, 0.8);
}

.bubble:hover .msg-menu,
.msg-menu:focus {
    opacity: 1;
}

.msg-menu[hidden] {
    display: none !important;
}

.msg-menu:hover {
    color: var(--text-hi);
    background: rgba(17, 26, 58, 0.06);
    opacity: 1;
}

.bubble-mine .msg-menu:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.18);
}

.msg-menu-dropdown {
    position: absolute;
    top: 30px;
    right: 10px;
    z-index: 5;
    display: flex;
    flex-direction: column;
    padding: 5px;
    min-width: 130px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.msg-menu-dropdown button {
    padding: 8px 12px;
    text-align: left;
    font-family: inherit;
    font-size: 13px;
    color: var(--text-hi);
    background: none;
    border: none;
    border-radius: 9px;
    cursor: pointer;
}

.msg-menu-dropdown button:hover {
    background: var(--accent-soft);
    color: var(--accent-hi);
}

.bubble-editing {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 220px;
}

.bubble-editing .input {
    padding: 8px 10px;
    font-size: 13px;
    border-radius: 10px;
}

.bubble-mine .bubble-editing .btn:not(.btn-primary) {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.35);
    color: #fff;
}

.bubble-mine .bubble-editing .btn-primary {
    background: #fff;
    border-color: #fff;
    color: var(--accent-hi);
}

.btn-row {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.deleted-msg {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.deleted-msg:last-child {
    border-bottom: none;
}

.deleted-msg-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
}

.deleted-msg-meta strong {
    color: var(--text-hi);
}

.deleted-msg-meta small {
    color: var(--text-dim);
}

.deleted-msg-text {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-soft);
    border-radius: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

.deleted-msg-actions {
    display: flex;
    justify-content: flex-end;
}

/* ---------- Modals / toasts ---------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(17, 26, 58, 0.38);
    backdrop-filter: blur(4px);
    animation: modal-backdrop-in var(--dur) var(--ease-out);
}

.modal-backdrop.is-closing {
    animation: modal-backdrop-in var(--dur-fast) var(--ease-in-out) reverse;
}

.modal {
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: 0 40px 80px -24px rgba(17, 26, 58, 0.35);
    animation: modal-in var(--dur-slow) var(--ease-out);
}

.modal-backdrop.is-closing .modal {
    animation: modal-in var(--dur-fast) var(--ease-in-out) reverse;
}

@keyframes modal-backdrop-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modal-in {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.015em;
    color: var(--text-hi);
}

.modal form {
    padding: 20px 24px 22px;
}

.confirm-body {
    padding: 20px 24px 4px;
    font-size: 14px;
    color: var(--text);
    line-height: 1.55;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.modal-footer.standalone {
    margin-top: 14px;
    padding: 16px 24px 22px;
}

.toasts {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 340px;
}

.toast {
    padding: 12px 16px 12px 18px;
    border-radius: 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-left: 4px solid var(--accent);
    color: var(--text-hi);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow);
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
    animation: toast-in var(--dur-slow) var(--ease-out);
}

.toast-ok {
    border-left-color: var(--success);
}

.toast-error {
    border-left-color: var(--error);
}

.toast.is-hidden {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px) scale(0.96); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.btn-lg {
    padding: 13px 26px;
    font-size: 15px;
}

/* ---------- Mobile ---------- */

@media (max-width: 900px) {
    .panel-shell {
        flex-direction: column;
    }

    .mobile-topbar {
        position: sticky;
        top: 0;
        z-index: 40;
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 10px 14px;
        background: rgba(255, 255, 255, 0.88);
        backdrop-filter: blur(10px);
        border-bottom: 1px solid var(--border);
    }

    .mobile-menu-btn {
        width: 42px;
        height: 42px;
        padding: 0;
        font-size: 20px;
        line-height: 1;
        border-radius: 12px;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 70;
        height: 100%;
        width: min(280px, 84vw);
        transform: translateX(-105%);
        box-shadow: 20px 0 60px -10px rgba(17, 26, 58, 0.25);
        transition: transform var(--dur-slow) var(--ease-out);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        z-index: 65;
        display: block;
        background: rgba(17, 26, 58, 0.35);
        backdrop-filter: blur(3px);
    }

    .sidebar-backdrop[hidden] {
        display: none;
    }

    .panel-main {
        padding: 22px 16px 40px;
    }

    .page-title {
        font-size: 24px;
    }

    .field.inline .input {
        min-width: 0;
    }

    .list-toolbar > .input[type="search"] {
        max-width: none;
    }

    .chat-shell {
        grid-template-columns: 1fr;
    }

    .chat-room-list {
        max-height: calc(100vh - 270px);
    }

    .bubble {
        max-width: 90%;
    }

    .chat-back {
        display: inline-flex !important;
    }

    .chat-shell[data-mobile-view="list"] .chat-pane {
        display: none;
    }

    .chat-shell[data-mobile-view="conversation"] .chat-rooms {
        display: none;
    }
}
