:root {
    --ink: #14213d;
    --muted: #5d6b82;
    --line: #d9e2ef;
    --bg: #eef4fb;
    --panel: #ffffff;
    --brand: #006d77;
    --brand-2: #c2410c;
    --ok: #0f766e;
    --danger: #b42318;
    --violet: #6d5dfc;
    --sky: #0284c7;
    --gold: #d97706;
    --shadow: 0 14px 40px rgba(20, 33, 61, .08);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 12% 10%, rgba(109,93,252,.12), transparent 30%),
        radial-gradient(circle at 88% 18%, rgba(0,109,119,.13), transparent 28%),
        var(--bg);
}
a { color: inherit; text-decoration: none; }
.topbar {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 14px clamp(16px, 4vw, 44px);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}
.sidebar-toggle {
    display: none;
    background: #edf2f7;
    color: var(--ink);
}
.sidebar {
    position: fixed;
    left: 0;
    top: 73px;
    bottom: 0;
    z-index: 9;
    width: 248px;
    padding: 18px 14px;
    overflow-y: auto;
    overflow-x: hidden;
    color: #e8f3ff;
    background: linear-gradient(180deg, #102a43, #0f3f4a 58%, #09333b);
    border-right: 1px solid rgba(255,255,255,.12);
    transition: width 0.35s cubic-bezier(.4,0,.2,1), padding 0.35s cubic-bezier(.4,0,.2,1);
}
.sidebar-collapse-btn {
    display: flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; margin: 0 auto 10px; padding: 0;
    background: rgba(255,255,255,.1); border: none; border-radius: 6px;
    color: rgba(255,255,255,.8); font-size: 14px; cursor: pointer;
    transition: background 0.2s, transform 0.35s cubic-bezier(.4,0,.2,1);
}
.sidebar-collapse-btn:hover { background: rgba(255,255,255,.2); }
body.sidebar-collapsed .sidebar-collapse-btn { transform: rotate(180deg); }
body.sidebar-collapsed .sidebar {
    width: 64px;
    padding: 18px 0;
}
body.sidebar-collapsed .sidebar-title strong,
body.sidebar-collapsed .sidebar-title span { font-size: 0; opacity: 0; }
body.sidebar-collapsed .sidebar-title { padding: 10px 4px 16px; border-bottom-color: rgba(255,255,255,.08); }
body.sidebar-collapsed .side-nav a { justify-content: center; padding: 10px 0; gap: 0; min-height: 42px; }
body.sidebar-collapsed .side-nav a .nav-label { font-size: 0; width: 0; overflow: hidden; opacity: 0; transition: opacity .2s, width .25s; }
body.sidebar-collapsed .side-nav a .nav-icon { font-size: 18px; }
body.sidebar-collapsed .side-subnav { display: none; }
.sidebar-title {
    display: grid;
    gap: 4px;
    padding: 10px 12px 16px;
    border-bottom: 1px solid rgba(255,255,255,.14);
    margin-bottom: 12px;
}
.sidebar-title span {
    color: rgba(255,255,255,.68);
    font-size: 13px;
}
.side-nav {
    display: grid;
    gap: 6px;
}
.side-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 7px;
    color: rgba(255,255,255,.88);
    font-weight: 800;
}
.side-nav a:hover {
    background: rgba(255,255,255,.12);
    color: #fff;
}
.side-nav a.active {
    background: rgba(255,255,255,.18);
    color: #fff;
    box-shadow: inset 3px 0 0 #fbbf24;
}
.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.nav-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.side-subnav {
    display: none;
    gap: 4px;
    margin: -2px 0 4px 18px;
}
.side-subnav.open {
    display: grid;
}
.side-subnav a {
    min-height: 34px;
    font-size: 13px;
    color: rgba(255,255,255,.72);
}
.side-nav a.has-children { cursor: pointer; }
.side-nav a.has-children .nav-arrow {
    margin-left: auto;
    transition: transform .2s;
    font-size: 11px;
}
.side-nav a.has-children.open .nav-arrow { transform: rotate(90deg); }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 8px;
    color: white;
    background: var(--brand);
    font-weight: 800;
    overflow: hidden;
}
.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}
.brand small, .muted { color: var(--muted); }
.brand span:last-child { display: grid; gap: 2px; }
.top-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.user-pill {
    border: 1px solid var(--line);
    background: #f8fafc;
    border-radius: 999px;
    padding: 9px 12px;
    font-size: 14px;
}
.shell {
    width: min(1180px, calc(100% - 32px));
    margin: 28px auto 56px;
}
.shell.with-sidebar {
    width: min(1180px, calc(100% - 288px));
    margin-left: calc(248px + clamp(20px, 4vw, 44px));
    transition: width 0.35s cubic-bezier(.4,0,.2,1), margin-left 0.35s cubic-bezier(.4,0,.2,1);
}
body.sidebar-collapsed .shell.with-sidebar {
    width: min(1180px, calc(100% - 100px));
    margin-left: calc(64px + clamp(20px, 4vw, 44px));
}
.dashboard-hero {
    position: relative;
    overflow: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 18px;
    align-items: end;
    padding: clamp(24px, 5vw, 46px);
    color: #fff;
    background:
        linear-gradient(135deg, rgba(0,109,119,.96), rgba(109,93,252,.86)),
        radial-gradient(circle at top right, rgba(255,255,255,.35), transparent 36%);
    border-radius: 10px;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}
.dashboard-hero h1 {
    margin: 0 0 8px;
    font-size: clamp(30px, 5vw, 56px);
    line-height: 1.05;
}
.dashboard-hero p {
    max-width: 760px;
    color: rgba(255,255,255,.82);
}
.hero-chip {
    display: inline-flex;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.16);
    border: 1px solid rgba(255,255,255,.28);
    font-weight: 800;
}
.hero {
    display: grid;
    grid-template-columns: 1.15fr .85fr;
    gap: 28px;
    align-items: center;
    min-height: calc(100vh - 128px);
}
/* ── Login Page ───────────────────────────────────────────────── */

#login-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

body:has(.login-wrap) {
    background: linear-gradient(-45deg, #0b1120, #14213d, #0f2b3d, #1a1a2e);
    background-size: 400% 400%;
    animation: bgShift 18s ease infinite;
    min-height: 100vh;
}
@keyframes bgShift {
    0%   { background-position: 0% 50%; }
    50%  { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.login-bg-shapes {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}
.bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.35;
}
.c1 {
    width: 500px; height: 500px;
    background: #006d77;
    top: -10%; left: -5%;
    animation: orbFloat1 20s ease-in-out infinite;
}
.c2 {
    width: 400px; height: 400px;
    background: #6d5dfc;
    bottom: -8%; right: -5%;
    animation: orbFloat2 25s ease-in-out infinite;
}
.c3 {
    width: 300px; height: 300px;
    background: #c2410c;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    animation: orbFloat3 22s ease-in-out infinite;
}
@keyframes orbFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(40px, 50px) scale(1.1); }
    66% { transform: translate(-20px, 30px) scale(0.9); }
}
@keyframes orbFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(-40px, -30px) scale(1.15); }
    66% { transform: translate(30px, -50px) scale(0.85); }
}
@keyframes orbFloat3 {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.25; }
    50% { transform: translate(-50%, -50%) scale(1.5); opacity: 0.4; }
}

/* ── Layout ── */
.login-wrap {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(30px, 5vw, 80px);
    min-height: 100vh;
    padding: 24px;
}

/* ── Login Card ── */
.login-card {
    width: 100%;
    max-width: 420px;
    background: rgba(255,255,255,.06);
    backdrop-filter: blur(24px) saturate(1.4);
    -webkit-backdrop-filter: blur(24px) saturate(1.4);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 24px;
    padding: 40px 36px 32px;
    box-shadow: 0 32px 80px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.08);
    animation: cardEntry 0.8s ease-out both;
}
@keyframes cardEntry {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.login-card-top {
    text-align: center;
    margin-bottom: 32px;
}
.login-brand {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    padding: 6px;
    border-radius: 16px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.12);
    box-shadow: 0 8px 32px rgba(0,0,0,.25);
    margin-bottom: 20px;
    animation: brandPop 0.6s cubic-bezier(.34,1.56,.64,1) 0.2s both;
}
@keyframes brandPop {
    from { opacity: 0; transform: scale(0.5); }
    to { opacity: 1; transform: scale(1); }
}
.login-brand img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.login-title {
    font-size: 26px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 6px;
    animation: fadeUp 0.6s ease-out 0.3s both;
}
.login-subtitle {
    font-size: 15px;
    color: rgba(255,255,255,.55);
    margin: 0;
    animation: fadeUp 0.6s ease-out 0.35s both;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Form ── */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-field {
    animation: fadeUp 0.6s ease-out both;
}
.login-field:nth-child(1) { animation-delay: 0.4s; }
.login-field:nth-child(2) { animation-delay: 0.5s; }

.login-field label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,.7);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 12px;
    transition: border-color .25s ease, background .25s ease, box-shadow .25s ease, transform .2s ease;
    overflow: hidden;
}
.login-input-wrap:hover {
    border-color: rgba(255,255,255,.2);
    background: rgba(255,255,255,.1);
}
.login-input-wrap:focus-within {
    border-color: rgba(0,109,119,.6);
    background: rgba(255,255,255,.08);
    box-shadow: 0 0 0 4px rgba(0,109,119,.15), 0 4px 20px rgba(0,0,0,.2);
    transform: translateY(-1px);
}

.login-input-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: rgba(255,255,255,.35);
    margin-left: 14px;
    transition: color .25s ease;
}
.login-input-wrap:focus-within .login-input-icon {
    color: rgba(0,109,119,.7);
}

.login-input-wrap input {
    flex: 1;
    border: 0;
    background: transparent;
    padding: 14px 12px;
    font-size: 15px;
    color: #fff;
    outline: 0;
    min-width: 0;
}
.login-input-wrap input::placeholder {
    color: rgba(255,255,255,.25);
}

.login-pw-toggle {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-right: 6px;
    border: 0;
    background: transparent;
    color: rgba(255,255,255,.35);
    cursor: pointer;
    border-radius: 8px;
    transition: color .2s ease, background .2s ease;
}
.login-pw-toggle:hover {
    color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.08);
}
.login-pw-toggle svg {
    width: 18px;
    height: 18px;
}
.login-pw-toggle .eye-closed { display: none; }
.login-pw-toggle.visible .eye-open { display: none; }
.login-pw-toggle.visible .eye-closed { display: block; }

/* ── Submit Button ── */
.login-btn {
    position: relative;
    min-height: 50px;
    border: 0;
    border-radius: 12px;
    background: linear-gradient(135deg, #006d77, #6d5dfc);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    overflow: hidden;
    transition: transform .25s ease, box-shadow .25s ease;
    animation: fadeUp 0.6s ease-out 0.6s both;
    letter-spacing: 0.3px;
}
.login-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, #6d5dfc, #006d77);
    opacity: 0;
    transition: opacity .4s ease;
    border-radius: 12px;
}
.login-btn:hover::before { opacity: 1; }
.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 40px rgba(0,109,119,.35);
}
.login-btn:active {
    transform: translateY(0) scale(0.98);
}
.login-btn .btn-text,
.login-btn .btn-loader {
    position: relative;
    z-index: 1;
}
.login-btn .btn-loader {
    display: none;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255,255,255,.3);
    border-top-color: #fff;
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.7s linear infinite;
}
.login-btn.loading .btn-text { display: none; }
.login-btn.loading .btn-loader { display: block; }
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Card Footer ── */
.login-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,.06);
    animation: fadeUp 0.6s ease-out 0.7s both;
}
.login-footer .badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(15,118,110,.2);
    color: #5eead4;
    border: 1px solid rgba(15,118,110,.3);
}
.login-kicker {
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Right Info Panel ── */
.login-info {
    display: none;
    max-width: 380px;
    animation: infoSlideIn 0.8s ease-out 0.3s both;
}
@keyframes infoSlideIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: translateX(0); }
}
.login-info-badge {
    display: inline-flex;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #5eead4;
    background: rgba(15,118,110,.15);
    border: 1px solid rgba(15,118,110,.25);
    margin-bottom: 16px;
}
.login-info h2 {
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 12px;
    line-height: 1.15;
}
.login-info p {
    font-size: 16px;
    color: rgba(255,255,255,.5);
    line-height: 1.7;
    margin: 0 0 24px;
}
.login-info-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}
.login-info-tags span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255,255,255,.7);
    background: rgba(255,255,255,.06);
    border: 1px solid rgba(255,255,255,.08);
}
.login-info-tags strong {
    color: #5eead4;
}

@media (min-width: 900px) {
    .login-info {
        display: block;
    }
    .login-card {
        padding: 44px 40px 36px;
    }
}
.panel, .card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}
.panel { padding: 22px; margin-bottom: 22px; }
details.panel { display: block; }
.collapsible {
    padding: 0;
    overflow: hidden;
}
.collapsible summary {
    list-style: none;
    cursor: pointer;
    padding: 18px 20px;
    font-weight: 800;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.collapsible summary::-webkit-details-marker { display: none; }
.collapsible summary::after {
    content: "+";
    width: 28px;
    height: 28px;
    border-radius: 6px;
    display: grid;
    place-items: center;
    background: #edf2f7;
    color: var(--ink);
    font-size: 18px;
    line-height: 1;
}
.collapsible[open] summary {
    border-bottom: 1px solid var(--line);
}
.collapsible[open] summary::after {
    content: "-";
}
.collapsible > form {
    padding: 18px 20px 20px;
}
.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.span-3 { grid-column: span 3; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.span-12 { grid-column: span 12; }
.card { padding: 18px; box-shadow: none; }
.stat-card {
    color: #fff;
    border: 0;
    min-height: 132px;
    display: grid;
    align-content: space-between;
    background: linear-gradient(135deg, var(--brand), var(--sky));
}
.stat-card:nth-child(2) { background: linear-gradient(135deg, var(--violet), #9b5cf6); }
.stat-card:nth-child(3) { background: linear-gradient(135deg, var(--brand-2), var(--gold)); }
.stat-card:nth-child(4) { background: linear-gradient(135deg, #0f766e, #14b8a6); }
.stat-card .muted { color: rgba(255,255,255,.78); }
.card h3, .panel h2, .panel h3 { margin-top: 0; }
.stat { font-size: 34px; font-weight: 800; }
form { display: grid; gap: 14px; }
.form-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
label { display: grid; gap: 6px; font-weight: 700; font-size: 14px; }
input, select, textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 11px 12px;
    font: inherit;
    background: #fff;
    color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
.btn, button {
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: white;
    padding: 11px 14px;
    font-weight: 800;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn.secondary { background: var(--brand-2); }
.btn.ghost { background: #edf2f7; color: var(--ink); }
.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 8px; font-size: 0.78rem; font-weight: 600; min-height: 0; border-radius: 4px; }
.btn.small.danger { background: var(--danger); }
.btn.small.warn { background: #f59e0b; color: #000; }
.actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
table .actions, .table-wrap .actions { gap: 4px; flex-wrap: nowrap; }
.compact-form { display: inline-flex; margin: 0; gap: 4px; align-items: center; }
.password-view {
    position: relative;
    min-width: 210px;
}
.password-view input {
    padding-right: 78px;
    min-width: 0;
}
.password-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--muted);
}
.password-icon:hover,
.password-icon.copied,
.password-icon.is-visible {
    background: #edf2f7;
    color: var(--brand);
}
.password-icon svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    pointer-events: none;
}
.view-icon { right: 40px; }
.copy-icon { right: 6px; }
.copy-icon.copied::after {
    content: "";
    position: absolute;
    right: 4px;
    bottom: 4px;
    width: 7px;
    height: 7px;
    border-radius: 999px;
    background: var(--ok);
}
.icon-btn {
    width: 42px;
    padding-inline: 0;
}
.copy-btn::before {
    content: "Copy";
}
.check-line { min-width: 92px; }
.check-row { display: flex; align-items: center; gap: 16px; padding: 6px 0; flex-wrap: wrap; }
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--brand, #4f46e5); cursor: pointer; flex-shrink: 0; }
.check-row label { margin: 0; font-weight: 600; font-size: 0.9rem; cursor: pointer; user-select: none; }
.check-item { display: flex; align-items: center; gap: 6px; }
.status-select.pub { color: #16a34a; font-weight: 600; }
.status-select.draft { color: #dc2626; font-weight: 600; }
.text-pub { color: #16a34a; font-weight: 600; }
.text-draft { color: #dc2626; font-weight: 600; }
details { margin: 0; }
details > .collapse-toggle,
details > summary.collapse-toggle {
    list-style: none;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.6rem 0;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
details > .collapse-toggle::before,
details > summary.collapse-toggle::before {
    content: "\25B6";
    font-size: 0.7rem;
    transition: transform 0.2s;
}
details[open] > .collapse-toggle::before,
details[open] > summary.collapse-toggle::before {
    transform: rotate(90deg);
}
details > .collapse-toggle::-webkit-details-marker,
details > summary.collapse-toggle::-webkit-details-marker {
    display: none;
}
.switch-line {
    display: inline-flex;
    grid-template-columns: none;
    align-items: center;
    gap: 8px;
    min-width: 86px;
    font-weight: 800;
}
.switch-line input {
    width: 18px;
    height: 18px;
}
.notice {
    padding: 14px 16px;
    border: 1px solid #9ae6b4;
    background: #ecfdf3;
    color: #065f46;
    border-radius: 8px;
    margin-bottom: 18px;
}
.table-wrap { overflow-x: auto; }
.clickable-row { cursor: pointer; transition: background 0.15s; }
.clickable-row:hover { background: var(--bg, #f3f4f6); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 13px; text-transform: uppercase; }
.account-table {
    min-width: 0;
    table-layout: auto;
}
.account-table th,
.account-table td {
    padding: 4px 5px;
}
.account-table input,
.account-table select {
    min-width: 0;
    padding: 4px 6px;
    font-size: 0.85rem;
}
table { border-collapse: collapse; width: 100%; }
table td, table th { padding: 4px 5px; vertical-align: middle; text-align: center; }
table td:first-child, table th:first-child { text-align: left; }
table th { white-space: normal; word-break: break-word; font-size: 0.72rem; line-height: 1.3; }
table th.diagonal { position: relative; white-space: nowrap; padding: 2px 8px 12px; }
table th.diagonal span { display: inline-block; transform: rotate(-35deg); transform-origin: center; transform-box: border-box; font-size: 0.72rem; letter-spacing: 0.02em; }
section[id], div[id]:not(.modal-overlay):not(.grid) { scroll-margin-top: 90px; }
table td form { margin: 0; }
table td input:not([type="hidden"]):not([type="checkbox"]), table td select { padding: 4px 6px; font-size: 0.85rem; min-height: 0; }
table td input[type="checkbox"] { margin: 0; }
.account-table .actions {
    flex-wrap: nowrap;
    gap: 4px;
}
.account-table .btn:not(.small),
.account-table button:not(.small) {
    min-height: 32px;
    padding: 6px 10px;
    white-space: nowrap;
}
.account-table th:last-child,
.account-table td:last-child {
    white-space: normal;
}
.badge { display: inline-flex; border-radius: 999px; padding: 5px 9px; font-size: 12px; background: #edf2f7; color: var(--ink); }
.badge.ok { background: #ccfbf1; color: #115e59; }
.badge.warn { background: #ffedd5; color: #9a3412; }
.question { border-top: 1px solid var(--line); padding-top: 18px; margin-top: 18px; }
.media-preview img, .exam-media img { max-width: 280px; border-radius: 8px; border: 1px solid var(--line); }
.exam-media video { max-width: 420px; width: 100%; }
.exam-bar {
    position: sticky;
    top: 73px;
    z-index: 8;
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 16px;
}
.timer { font-size: 24px; font-weight: 900; color: var(--danger); }
.rules-box {
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    line-height: 1.7;
    margin-bottom: 16px;
}
.rules-confirm {
    border-top: 1px solid var(--line);
    padding-top: 16px;
}
.import-students-form {
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--line);
}
.csv-help {
    margin: -4px 0 0;
    font-size: 13px;
}
.exam-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 220px;
    gap: 18px;
    align-items: start;
}
.exam-question-area {
    min-width: 0;
}
.exam-question[hidden] {
    display: none;
}
.exam-question {
    position: relative;
}
.choice-row {
    display: flex;
    grid-template-columns: none;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    font-weight: 600;
}
.choice-row input[type="radio"] {
    width: auto;
    flex: 0 0 auto;
    margin: 2px 0 0;
}
.choice-row span {
    line-height: 1.45;
}
.exam-attachment {
    float: right;
    width: 150px;
    margin: 0 0 14px 18px;
    text-align: center;
}
.exam-attachment a {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-weight: 700;
}
.exam-attachment img,
.attachment-thumb {
    width: 150px;
    height: 96px;
    border: 1px solid var(--line);
    border-radius: 8px;
    object-fit: cover;
    background: #f8fafc;
}
.attachment-thumb {
    display: grid;
    place-items: center;
    color: var(--ink);
}
.exam-nav-actions {
    display: grid;
    grid-template-columns: minmax(96px, auto) minmax(180px, 1fr) minmax(96px, auto);
    gap: 10px;
    margin-top: 22px;
    border-top: 1px solid var(--line);
    padding-top: 16px;
}
.inline-submit-btn {
    min-height: 48px;
    width: 100%;
}
.inline-submit-btn[hidden] {
    display: none;
}
.exam-start-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(20, 33, 61, .72);
}
.exam-start-overlay[hidden] {
    display: none;
}
.exam-start-panel {
    width: min(420px, 100%);
    padding: 24px;
    border-radius: 8px;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: 0 24px 70px rgba(0,0,0,.24);
    text-align: center;
}
.exam-start-panel h2 {
    margin: 0 0 8px;
}
.exam-start-panel p {
    color: var(--muted);
    line-height: 1.5;
}
.question-sidebar {
    position: sticky;
    top: 154px;
    display: grid;
    gap: 12px;
}
.question-palette {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px;
    box-shadow: var(--shadow);
}
.submit-exam-btn {
    width: 100%;
    min-height: 56px;
    font-size: 17px;
}
.question-box {
    aspect-ratio: 1;
    min-width: 0;
    padding: 0;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--ink);
    border-radius: 6px;
}
.question-box.answered {
    background: var(--ok);
    border-color: var(--ok);
    color: #fff;
}
.question-box.current {
    outline: 3px solid rgba(194, 65, 12, .3);
}
.result-box {
    text-align: center;
    padding: 36px;
}
.result-score { font-size: clamp(48px, 10vw, 96px); font-weight: 900; color: var(--ok); }
.filter-bar {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr)) auto;
    gap: 12px;
    align-items: end;
}
.report-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}
.section-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}
.section-title-row h2 {
    margin: 0;
}
.danger-notice {
    border-color: #fecaca;
    background: #fff1f2;
    color: #991b1b;
}
.report-export h1 {
    margin: 0 0 6px;
}
.print-only { display: none; }
@media (max-width: 820px) {
    .hero, .form-row { grid-template-columns: 1fr; }
    .span-3, .span-4, .span-5, .span-6, .span-7, .span-8 { grid-column: span 12; }
    .topbar { align-items: flex-start; flex-direction: column; }
    .sidebar-toggle { display: inline-flex; }
    .sidebar-collapse-btn { display: none; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .shell, .shell.with-sidebar { width: min(100% - 20px, 1180px); margin: 16px auto 56px; }
    body.sidebar-collapsed .shell.with-sidebar { width: min(100% - 20px, 1180px); margin: 16px auto 56px; }
    .dashboard-hero { grid-template-columns: 1fr; }
    .filter-bar { grid-template-columns: 1fr; }
    .exam-layout { grid-template-columns: 1fr; }
    .question-sidebar {
        position: sticky;
        top: 132px;
        order: -1;
    }
    .exam-attachment {
        float: none;
        width: 100%;
        margin: 0 0 14px;
        text-align: left;
    }
    .exam-attachment a {
        width: 150px;
    }
}
@media print {
    .topbar, .sidebar, .btn, button, form, .notice { display: none !important; }
    .shell, .shell.with-sidebar { width: 100%; margin: 0; }
    body { background: #fff; }
    .panel, .card { box-shadow: none; }
    .print-only { display: block; }
}

/* Modal System */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    overflow-y: auto;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-box {
    background: var(--panel);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    padding: 0;
    transform: translateY(-30px) scale(0.97);
    transition: transform 0.25s ease;
    position: relative;
}
.modal-overlay.active .modal-box {
    transform: translateY(0) scale(1);
}
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    background: var(--panel);
    z-index: 1;
    border-radius: 12px 12px 0 0;
}
.modal-head h2 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--ink);
}
.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: #f1f5f9;
    color: var(--ink);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}
.modal-close:hover {
    background: #e2e8f0;
    color: var(--danger);
}
.modal-body {
    padding: 24px;
}
.modal-body .panel {
    box-shadow: none;
    border: none;
    padding: 0;
    margin: 0;
}
.modal-body label {
    display: block;
    margin-bottom: 12px;
}
.modal-body input[type="text"],
.modal-body input[type="email"],
.modal-body input[type="number"],
.modal-body input[type="password"],
.modal-body textarea,
.modal-body select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--line);
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}
.modal-body input:focus,
.modal-body textarea:focus,
.modal-body select:focus {
    outline: none;
    border-color: var(--brand);
}
.modal-body .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
.modal-body .btn,
.modal-body button[type="submit"] {
    margin-top: 8px;
}
@media (max-width: 600px) {
    .modal-overlay { padding: 40px 8px 8px; }
    .modal-body .form-row { grid-template-columns: 1fr; }
}

/* Compact stat summary bar */
.stat-bar { display:flex; flex-wrap:wrap; gap:0; border-radius:8px; overflow:hidden; margin-bottom:1.2rem; border:1px solid var(--border,#e5e7eb); }
.stat-bar .stat-item { flex:1 1 0; min-width:100px; padding:0.7rem 1rem; text-align:center; border-right:1px solid var(--border,#e5e7eb); background:var(--card,#fff); }
.stat-bar .stat-item:last-child { border-right:none; }
.stat-bar a.stat-item { cursor:pointer; transition:background .15s; }
.stat-bar a.stat-item:hover { background:var(--brand,#4f46e5); color:#fff !important; }
.stat-bar a.stat-item:hover .stat-label { color:rgba(255,255,255,.8) !important; }
.stat-bar .stat-item .stat-num { font-size:1.4rem; font-weight:700; color:var(--accent,#2563eb); line-height:1.2; }
.stat-bar .stat-item .stat-label { font-size:0.75rem; color:var(--muted,#6b7280); text-transform:uppercase; letter-spacing:0.04em; }
@media (max-width:700px) { .stat-bar .stat-item { min-width:80px; padding:0.5rem 0.6rem; } .stat-bar .stat-item .stat-num { font-size:1.1rem; } }

/* Password toggle cell */
.pwd-cell { display:flex; align-items:center; gap:0.3rem; }
.pwd-cell .pwd-text { font-family:monospace; font-weight:600; color:var(--accent,#2563eb); user-select:all; }
.pwd-cell .pwd-mask { font-family:monospace; color:var(--muted,#9ca3af); letter-spacing:0.15em; }
.pwd-toggle { background:none; border:none; cursor:pointer; padding:2px 4px; color:var(--muted,#9ca3af); font-size:1rem; line-height:1; border-radius:4px; transition:color 0.15s; }
.pwd-toggle:hover { color:var(--accent,#2563eb); background:rgba(37,99,235,0.06); }
.pwd-copy { background:none; border:none; cursor:pointer; padding:2px 4px; color:var(--muted,#9ca3af); font-size:1rem; line-height:1; border-radius:4px; transition:color 0.15s; }
.pwd-copy:hover { color:#16a34a; }
.pwd-copy.copied { color:#16a34a; }

/* Pagination controls */
.pagination-bar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:0.5rem; padding:0.7rem 0; border-top:1px solid var(--border,#e5e7eb); margin-top:0.5rem; font-size:0.85rem; color:var(--muted,#6b7280); }
.pagination-bar .page-info { }
.pagination-bar .page-info strong { color:var(--text,#1f2937); }
.pagination-controls { display:flex; align-items:center; gap:0.25rem; }
.pagination-controls button { background:var(--card,#fff); border:1px solid var(--border,#e5e7eb); border-radius:4px; padding:0.3rem 0.6rem; cursor:pointer; font-size:0.8rem; color:var(--text,#374151); transition:all 0.15s; }
.pagination-controls button:hover:not(:disabled) { background:var(--accent,#2563eb); color:#fff; border-color:var(--accent,#2563eb); }
.pagination-controls button:disabled { opacity:0.4; cursor:not-allowed; }
.pagination-controls button.active { background:var(--accent,#2563eb); color:#fff; border-color:var(--accent,#2563eb); font-weight:600; }
.pagination-controls select { padding:0.3rem 0.4rem; border:1px solid var(--border,#e5e7eb); border-radius:4px; font-size:0.8rem; }
.pagination-bar .page-size-select { display:flex; align-items:center; gap:0.3rem; }
@media (max-width:600px) { .pagination-bar { flex-direction:column; align-items:stretch; } }

/* Exam question & choice animations */
@keyframes qFadeIn { from { opacity:0; transform:translateY(18px); } to { opacity:1; transform:translateY(0); } }
@keyframes qPulse { 0%{transform:scale(1);} 40%{transform:scale(1.06);} 100%{transform:scale(1);} }
@keyframes qCheckPop { 0%{transform:scale(0);opacity:0;} 60%{transform:scale(1.25);opacity:1;} 100%{transform:scale(1);opacity:1;} }

.exam-question {
    animation: qFadeIn .35s ease both;
}

.choice-row {
    cursor: pointer;
    transition: background .18s, border-color .18s, box-shadow .2s, transform .18s;
    position: relative;
    overflow: hidden;
}
.choice-row:hover {
    background: #f0f4ff;
    border-color: #c7d2de;
    transform: translateX(4px);
}
.choice-row:active { transform: scale(.985); }

.choice-row input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border: 2px solid #c7d2de;
    border-radius: 50%;
    position: relative;
    flex-shrink: 0;
    margin: 1px 0 0;
    transition: border-color .2s, box-shadow .2s;
}
.choice-row input[type="radio"]::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: transparent;
    transform: scale(0);
    transition: background .2s, transform .25s cubic-bezier(.4,0,.2,1);
}
.choice-row input[type="radio"]:checked {
    border-color: var(--brand, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
.choice-row input[type="radio"]:checked::after {
    background: var(--brand, #4f46e5);
    transform: scale(1);
}

.choice-row:has(input:checked) {
    background: linear-gradient(135deg,#eef2ff,#e8eeff);
    border-color: var(--brand, #4f46e5);
    box-shadow: 0 2px 10px rgba(79,70,229,.1);
}
.choice-row:has(input:checked) span { color: var(--brand, #4f46e5); font-weight:700; }

.choice-row.select-anim { animation: qPulse .3s ease; }
.choice-row.select-anim::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at var(--click-x,50%) var(--click-y,50%), rgba(79,70,229,.18), transparent 60%);
    animation: qCheckPop .4s ease forwards;
    pointer-events: none;
}

/* Exam bar glow */
.exam-bar {
    background: linear-gradient(135deg,#fff 0%,#f8faff 100%);
    box-shadow: 0 2px 12px rgba(0,0,0,.04);
}
.timer {
    background: linear-gradient(135deg,#fef2f2,#fff1f2);
    padding: 6px 14px;
    border-radius: 8px;
    border: 1px solid #fecaca;
}

/* Question sidebar */
.question-box.answered {
    transition: background .2s, border-color .2s, transform .15s;
}
.question-box.answered:active { transform: scale(.9); }

/* Exam rules page styles */
@keyframes fadeInUp { from { opacity:0; transform:translateY(24px); } to { opacity:1; transform:translateY(0); } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes scaleIn { from { opacity:0; transform:scale(.92); } to { opacity:1; transform:scale(1); } }

.rules-page .panel { animation: fadeInUp .45s ease-out both; }
.rules-page .panel h1 { font-size:1.6rem; animation: fadeIn .5s .1s ease both; }
.rules-page .panel .muted { animation: fadeIn .5s .15s ease both; }

.rules-page .stat-row { display:flex; gap:12px; margin:16px 0; animation: fadeInUp .45s .12s ease both; }
.rules-page .stat-box { flex:1; text-align:center; padding:10px 6px; border-radius:10px; background:linear-gradient(135deg,#f0f4ff,#e8eeff); border:1px solid var(--line,#e5e7eb); transition:transform .2s,box-shadow .2s; }
.rules-page .stat-box:hover { transform:translateY(-2px); box-shadow:0 4px 12px rgba(79,70,229,.12); }
.rules-page .stat-box .stat-num { font-size:1.5rem; font-weight:800; color:var(--brand,#4f46e5); line-height:1.2; }
.rules-page .stat-box .stat-label { font-size:.72rem; color:var(--muted,#6b7280); text-transform:uppercase; letter-spacing:.04em; margin-top:2px; }

.rules-page .rules-box { animation: fadeInUp .45s .2s ease both; max-height:260px; overflow-y:auto; }
.rules-page .rules-box::-webkit-scrollbar { width:5px; }
.rules-page .rules-box::-webkit-scrollbar-thumb { background:#c7d2de; border-radius:4px; }

.rules-page .rules-confirm { display:flex; flex-direction:column; align-items:center; gap:14px; padding-top:20px; animation: fadeInUp .45s .28s ease both; }
.rules-page .rules-confirm .check-line { min-width:auto; }
.rules-page .rules-confirm .check-line label { font-size:.95rem; font-weight:600; cursor:pointer; user-select:none; display:flex; align-items:center; gap:8px; }
.rules-page .rules-confirm .check-line input[type="checkbox"] { width:18px; height:18px; accent-color:var(--brand,#4f46e5); cursor:pointer; }
.rules-page .rules-confirm button { width:auto; padding:10px 32px; border-radius:8px; font-size:.95rem; font-weight:700; }
