:root {
    --bg: #f4f7fb;
    --surface: #ffffff;
    --surface-muted: #eef5ff;
    --text: #132033;
    --muted: #64748b;
    --line: #dbe4f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --accent-cyan: #0891b2;
    --accent-teal: #0f766e;
    --accent-violet: #7c3aed;
    --accent-amber: #d97706;
    --accent-rose: #e11d48;
    --success: #15803d;
    --warning: #b45309;
    --danger: #b91c1c;
    --radius: 8px;
    --shadow: 0 18px 48px rgba(15, 23, 42, 0.09);
    --shadow-soft: 0 10px 28px rgba(15, 23, 42, 0.06);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    padding-left: 260px;
    color: var(--text);
    background:
        linear-gradient(135deg, rgba(37, 99, 235, 0.08), rgba(8, 145, 178, 0.05) 34%, rgba(217, 119, 6, 0.07) 100%),
        var(--bg);
    font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
    letter-spacing: 0;
}

a {
    color: inherit;
    text-decoration: none;
}

.topbar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 24px;
    width: 260px;
    height: 100vh;
    padding: 22px 16px;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.94);
    border-right: 1px solid var(--line);
    box-shadow: 10px 0 32px rgba(15, 23, 42, 0.06);
    backdrop-filter: blur(12px);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-width: 0;
    padding: 6px 4px 18px;
    border-bottom: 1px solid var(--line);
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    flex: 0 0 46px;
    width: 46px;
    height: 46px;
    color: #fff;
    overflow: hidden;
    background: #0f172a;
    border-radius: var(--radius);
    font-weight: 800;
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.22);
}

.brand-logo-mark {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.brand-icon,
.nav-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.brand-icon {
    width: 22px;
    height: 22px;
    stroke-width: 2;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.mobile-nav-toggle,
.mobile-nav-backdrop {
    display: none;
}

.brand strong,
.brand small {
    display: block;
    line-height: 1.2;
}

.brand small {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.nav-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    width: 100%;
    flex: 1;
}

.topbar .button,
.topbar .user-chip {
    width: 100%;
    justify-content: flex-start;
}

.nav-link,
.nav-group {
    width: 100%;
}

.nav-link,
.nav-group summary,
.nav-sub-link {
    display: flex;
    align-items: center;
    min-height: 40px;
    border-radius: var(--radius);
    font-weight: 800;
}

.nav-link,
.nav-group summary {
    justify-content: space-between;
    padding: 0 12px;
    color: var(--text);
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--line);
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.03);
    transition: color 0.16s ease, background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.nav-label {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
}

.nav-link:hover,
.nav-link.is-active,
.nav-group.is-active > summary,
.nav-group summary:hover {
    color: var(--primary-dark);
    background: #eef5ff;
    border-color: #bfdbfe;
    transform: translateX(2px);
}

.nav-link-danger {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border-color: transparent;
}

.nav-link-danger:hover {
    color: #fff;
    background: linear-gradient(135deg, var(--primary-dark), #0e7490);
    border-color: transparent;
}

.nav-link-logout {
    margin-top: auto;
}

.nav-group summary {
    list-style: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group summary::after {
    content: "";
    width: 7px;
    height: 7px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.16s ease;
}

.nav-group[open] summary::after {
    transform: rotate(225deg);
}

.nav-submenu {
    display: grid;
    gap: 6px;
    margin-top: 8px;
    padding: 8px 0 0 12px;
    border-left: 2px solid #bfdbfe;
}

.nav-sub-link {
    min-height: 34px;
    padding: 0 10px;
    color: var(--muted);
    background: transparent;
    font-size: 13px;
}

.nav-sub-link:hover,
.nav-sub-link.is-active {
    color: var(--primary-dark);
    background: #eef5ff;
}

.page {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 34px 0 54px;
}

.footer {
    padding: 24px;
    color: var(--muted);
    text-align: center;
    border-top: 1px solid var(--line);
}

.page-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 24px;
}

.heading-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.page-heading h1 {
    margin: 6px 0 8px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.12;
}

.page-heading p {
    max-width: 700px;
    margin: 0;
    color: var(--muted);
    line-height: 1.7;
}

.eyebrow {
    margin: 0;
    color: var(--accent-cyan);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

.login-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 360px;
    gap: 24px;
    align-items: start;
}

.panel,
.login-panel,
.stat-card,
.action-item {
    position: relative;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.panel::before,
.login-panel::before,
.stat-card::before,
.action-item::before,
.library-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--accent-cyan), var(--accent-amber));
}

.login-panel,
.panel {
    padding: 24px;
}

.panel + .panel {
    margin-top: 22px;
}

.intro-panel {
    position: relative;
    overflow: hidden;
    padding: 30px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.intro-panel::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-cyan), var(--accent-violet), var(--accent-rose));
}

.intro-panel h1 {
    margin: 0 0 14px;
    font-size: clamp(30px, 5vw, 52px);
    line-height: 1.08;
}

.login-brand-logo {
    display: block;
    width: min(100%, 420px);
    margin: 0 0 22px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-soft);
}

.intro-panel p,
.panel p,
.action-item p {
    color: var(--muted);
    line-height: 1.7;
}

.login-panel h2,
.panel h2 {
    margin: 0 0 18px;
    font-size: 22px;
}

.login-body {
    position: relative;
    isolation: isolate;
    height: 100vh;
    padding-left: 0;
    overflow: hidden;
    color: #f8fafc;
    background:
        linear-gradient(116deg, rgba(34, 211, 238, 0.2) 0 11%, transparent 11% 23%, rgba(249, 115, 22, 0.16) 23% 33%, transparent 33% 100%),
        linear-gradient(244deg, transparent 0 43%, rgba(168, 85, 247, 0.2) 43% 55%, transparent 55% 100%),
        linear-gradient(135deg, #07111f 0%, #102627 32%, #24143d 64%, #341826 100%);
}

.login-body::before,
.login-body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

.login-body::before {
    background:
        repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.06) 0 1px, transparent 1px 88px),
        repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.045) 0 1px, transparent 1px 88px);
    mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.68), transparent 78%);
}

.login-body::after {
    background:
        linear-gradient(128deg, transparent 8%, rgba(56, 189, 248, 0.28) 9%, transparent 18%),
        linear-gradient(138deg, transparent 54%, rgba(250, 204, 21, 0.2) 55%, transparent 63%),
        linear-gradient(37deg, transparent 66%, rgba(244, 63, 94, 0.18) 67%, transparent 76%);
}

.login-body .page {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100% - 32px, 520px);
    height: 100vh;
    padding: 14px 0;
}

.login-body .footer {
    display: none;
}

.login-layout-solo {
    display: flex;
    flex-direction: column;
    justify-content: center;
    width: 100%;
    max-height: calc(100vh - 28px);
}

.login-panel-hero {
    width: 100%;
    padding: clamp(18px, 3.8vh, 30px);
    color: #eef6ff;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.06)),
        rgba(6, 16, 33, 0.78);
    border-color: rgba(226, 232, 240, 0.24);
    box-shadow:
        0 28px 80px rgba(0, 0, 0, 0.34),
        inset 0 1px 0 rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(18px);
}

.login-panel-hero::before {
    height: 4px;
    background: linear-gradient(90deg, #38bdf8, #a855f7, #f97316, #facc15);
}

.login-panel-hero h2 {
    margin: 0 0 14px;
    color: #fff;
    font-size: 22px;
    text-align: center;
}

.login-brand-block {
    margin-bottom: 16px;
    text-align: center;
}

.login-brand-block h1 {
    margin: 10px 0 0;
    color: #fff;
    font-size: clamp(34px, 8vw, 52px);
    line-height: 1.05;
    text-shadow: 0 10px 30px rgba(56, 189, 248, 0.32);
}

.login-brand-block p {
    margin: 0;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 800;
}

.login-panel-hero .login-brand-logo {
    width: clamp(76px, 13vh, 104px);
    height: clamp(76px, 13vh, 104px);
    margin: 0 auto;
    border: 1px solid rgba(226, 232, 240, 0.34);
    border-radius: 28px;
    box-shadow:
        0 0 0 8px rgba(56, 189, 248, 0.08),
        0 22px 44px rgba(0, 0, 0, 0.3),
        0 0 46px rgba(249, 115, 22, 0.18);
}

.login-panel-hero label {
    color: #dbeafe;
}

.login-panel-hero input,
.login-panel-hero select {
    color: #f8fafc;
    background: rgba(15, 23, 42, 0.74);
    border-color: rgba(148, 163, 184, 0.34);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.login-panel-hero input:focus,
.login-panel-hero select:focus {
    outline: 3px solid rgba(56, 189, 248, 0.18);
    border-color: #38bdf8;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.09),
        0 0 0 1px rgba(56, 189, 248, 0.28);
}

.login-panel-hero select option {
    color: #111827;
    background: #fff;
}

.login-panel-hero .button-primary {
    min-height: 44px;
    margin-top: 6px;
    background: linear-gradient(135deg, #2563eb, #0891b2 45%, #f97316);
    box-shadow: 0 18px 34px rgba(8, 145, 178, 0.24);
}

.login-panel-hero .button-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #7c3aed 48%, #ea580c);
}

.login-panel-hero .alert {
    color: #fecdd3;
    background: rgba(127, 29, 29, 0.52);
    border-color: rgba(251, 113, 133, 0.44);
}

.login-panel-hero .form-group {
    margin-bottom: 12px;
}

.login-panel-hero input,
.login-panel-hero select {
    min-height: 40px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 14px;
    font-weight: 700;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 7px;
}

.label-row label {
    margin-bottom: 0;
}

.label-row .button {
    min-height: 30px;
    padding: 0 10px;
    font-size: 13px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    color: var(--text);
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    font: inherit;
    transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: 3px solid rgba(37, 99, 235, 0.16);
    border-color: var(--primary);
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.05);
    transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.09);
}

.button-primary,
.button-dark {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
}

.button-primary:hover,
.button-dark:hover {
    background: linear-gradient(135deg, var(--primary-dark), #0e7490);
}

.button-light {
    color: var(--text);
    background: #fff;
    border-color: var(--line);
}

.button-light:hover {
    border-color: #bfdbfe;
    background: #eef5ff;
}

.button-danger {
    color: #fff;
    background: var(--danger);
}

.button-danger:hover {
    background: #991b1b;
}

.button-block {
    width: 100%;
}

.user-chip,
.pill {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    gap: 8px;
    color: #24507a;
    background: var(--surface-muted);
    border: 1px solid #d7e7ff;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.stat-grid,
.action-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 22px;
}

.action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.stat-card,
.action-item,
.library-card {
    padding: 18px;
}

.library-card {
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 18px;
    min-height: 310px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.library-card-body {
    display: grid;
    gap: 14px;
}

.library-card-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    flex-wrap: wrap;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.library-card-top .pill {
    min-height: 28px;
    padding: 0 9px;
    font-size: 12px;
}

.library-date {
    margin-left: auto;
    white-space: nowrap;
}

.library-card h2 {
    margin: 0;
    font-size: 22px;
    line-height: 1.35;
    word-break: break-word;
}

.library-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.library-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin: 0;
}

.library-meta div {
    padding: 10px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.library-meta dt,
.library-meta dd {
    margin: 0;
}

.library-meta dt {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.library-meta dd {
    margin-top: 5px;
    font-weight: 800;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 22px;
    color: var(--muted);
    font-weight: 800;
}

a.action-item {
    display: block;
    transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

a.action-item:hover {
    border-color: #bfdbfe;
    box-shadow: 0 22px 54px rgba(37, 99, 235, 0.12);
    transform: translateY(-2px);
}

.stat-card span,
.action-item span {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.action-item span::before {
    content: "";
    width: 26px;
    height: 26px;
    flex: 0 0 26px;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38), 0 8px 18px rgba(37, 99, 235, 0.2);
}

.action-item .action-kicker::before {
    display: none;
}

.action-icon {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    padding: 5px;
    color: #fff;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--primary), var(--accent-cyan));
    border-radius: var(--radius);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.38), 0 8px 18px rgba(37, 99, 235, 0.2);
}

.action-item:nth-child(5n+2)::before,
.action-item:nth-child(5n+2) span::before {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-teal), var(--accent-cyan));
}

.action-item:nth-child(5n+2) .action-icon {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-teal), var(--accent-cyan));
}

.action-item:nth-child(5n+3)::before,
.action-item:nth-child(5n+3) span::before {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-violet), var(--primary));
}

.action-item:nth-child(5n+3) .action-icon {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-violet), var(--primary));
}

.action-item:nth-child(5n+4)::before,
.action-item:nth-child(5n+4) span::before {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-amber), #f59e0b);
}

.action-item:nth-child(5n+4) .action-icon {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-amber), #f59e0b);
}

.action-item:nth-child(5n+5)::before,
.action-item:nth-child(5n+5) span::before {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-rose), var(--accent-violet));
}

.action-item:nth-child(5n+5) .action-icon {
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0) 52%),
        linear-gradient(135deg, var(--accent-rose), var(--accent-violet));
}

.stat-card strong {
    display: block;
    margin-top: 10px;
    font-size: 32px;
    line-height: 1;
}

.stat-card:nth-child(5n+1)::before {
    background: var(--primary);
}

.stat-card:nth-child(5n+1) strong {
    color: var(--primary-dark);
}

.stat-card:nth-child(5n+2)::before {
    background: var(--accent-teal);
}

.stat-card:nth-child(5n+2) strong {
    color: var(--accent-teal);
}

.stat-card:nth-child(5n+3)::before {
    background: var(--accent-violet);
}

.stat-card:nth-child(5n+3) strong {
    color: var(--accent-violet);
}

.stat-card:nth-child(5n+4)::before {
    background: var(--accent-amber);
}

.stat-card:nth-child(5n+4) strong {
    color: var(--accent-amber);
}

.stat-card:nth-child(5n+5)::before {
    background: var(--accent-rose);
}

.stat-card:nth-child(5n+5) strong {
    color: var(--accent-rose);
}

.action-item h3 {
    margin: 10px 0 6px;
    font-size: 18px;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: var(--shadow-soft);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
    background: #fff;
}

th,
td {
    padding: 13px 14px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}

th {
    color: #40536d;
    background: #f1f5f9;
    font-size: 13px;
    font-weight: 800;
}

tbody tr {
    transition: background 0.14s ease;
}

tbody tr:hover {
    background: #f8fbff;
}

#exam-list th,
#exam-list td {
    padding: 8px 10px;
    vertical-align: middle;
}

#exam-list .pill {
    min-height: 26px;
    padding: 0 9px;
    font-size: 12px;
}

#exam-list .button {
    min-height: 32px;
    padding: 0 10px;
    font-size: 13px;
}

.admin-exam-table {
    min-width: 900px;
}

.admin-report-table {
    min-width: 980px;
}

.admin-exam-table th:nth-child(1),
.admin-exam-table td:nth-child(1) {
    width: 42%;
}

.admin-exam-table th:nth-child(2),
.admin-exam-table td:nth-child(2) {
    width: 28%;
}

.admin-exam-table th:nth-child(3),
.admin-exam-table td:nth-child(3) {
    width: 15%;
}

.admin-exam-table th:nth-child(4),
.admin-exam-table td:nth-child(4) {
    width: 15%;
}

.table-primary,
.table-subtext {
    display: block;
}

.table-primary {
    margin-bottom: 4px;
    line-height: 1.35;
}

.table-subtext {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.45;
}

.pill-row,
.action-stack {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.action-stack {
    align-items: stretch;
}

.action-stack .button {
    width: 100%;
    justify-content: center;
    white-space: nowrap;
}

.action-stack form {
    margin: 0;
    width: 100%;
}

.count-pair {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 6px;
    align-items: baseline;
    margin-bottom: 7px;
}

.count-pair strong {
    color: var(--primary-dark);
    font-size: 16px;
    line-height: 1;
}

.count-pair span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

tr:last-child td {
    border-bottom: 0;
}

.empty-state {
    padding: 26px;
    color: var(--muted);
    background: linear-gradient(135deg, #ffffff, #f8fbff);
    border: 1px dashed #b8c7dc;
    border-radius: var(--radius);
    text-align: center;
}

.section-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.4fr) minmax(260px, 0.6fr);
    gap: 18px;
    align-items: start;
    margin-bottom: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-wide {
    grid-column: 1 / -1;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) minmax(140px, 180px) auto;
    gap: 12px;
    align-items: end;
    margin: 16px 0 18px;
    padding: 14px;
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.user-filter-bar {
    grid-template-columns: minmax(180px, 1fr) minmax(130px, 170px) minmax(130px, 170px) minmax(160px, 220px) auto;
}

.inline-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inline-form input {
    width: 150px;
    min-width: 140px;
}

.question-options {
    margin: 4px 0 16px;
    padding: 16px;
    background: #f9fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.paper-toolbar,
.paper-question-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.paper-toolbar h2 {
    margin-bottom: 6px;
}

.paper-toolbar p {
    margin: 0;
}

.paper-question-list {
    display: grid;
    gap: 18px;
}

.paper-question {
    padding: 18px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.paper-question-head {
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.paper-question-head strong {
    color: var(--primary-dark);
    font-size: 18px;
}

[data-paper-editor] .panel {
    padding: 18px;
}

[data-paper-editor] .panel h2 {
    margin-bottom: 12px;
    font-size: 20px;
}

[data-paper-editor] .form-grid {
    gap: 10px 12px;
}

[data-paper-editor] .form-group {
    margin-bottom: 8px;
}

[data-paper-editor] label {
    margin-bottom: 4px;
    font-size: 13px;
}

[data-paper-editor] input,
[data-paper-editor] select,
[data-paper-editor] textarea {
    min-height: 34px;
    padding: 6px 9px;
    font-size: 14px;
}

[data-paper-editor] textarea {
    line-height: 1.45;
}

[data-paper-editor] textarea[name$="[question_text]"] {
    height: 72px;
    min-height: 72px;
    resize: vertical;
}

[data-paper-editor] .checkbox-card {
    min-height: 34px;
    padding: 6px 9px;
}

[data-paper-editor] .checkbox-row {
    margin-bottom: 6px;
}

[data-paper-editor] .checkbox-row input,
[data-paper-editor] .checkbox-card input {
    min-height: auto;
}

[data-paper-editor] .paper-toolbar,
[data-paper-editor] .paper-question-head {
    gap: 10px;
    margin-bottom: 12px;
}

[data-paper-editor] .paper-question-list {
    gap: 12px;
}

[data-paper-editor] .paper-question {
    padding: 12px;
    background: #f8fbff;
    border-color: #93c5fd;
    box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.1);
}

[data-paper-editor] .paper-question-head {
    padding-bottom: 8px;
    border-bottom-color: #bfdbfe;
}

[data-paper-editor] .paper-question-head strong {
    font-size: 16px;
}

[data-paper-editor] .question-options {
    margin: 2px 0 10px;
    padding: 10px;
}

[data-paper-editor] .question-preview {
    width: min(100%, 240px);
    max-height: 120px;
    margin: 8px 0 10px;
}

[data-paper-editor] .option-preview {
    width: min(100%, 160px);
    max-height: 90px;
    margin: 6px 0;
}

[data-paper-editor] .file-dropzone {
    gap: 3px;
    min-height: 54px;
    margin-top: 5px;
    padding: 7px 9px;
}

[data-paper-editor] .file-dropzone-title {
    font-size: 13px;
}

[data-paper-editor] .file-dropzone-hint,
[data-paper-editor] .file-dropzone-name {
    font-size: 12px;
    line-height: 1.25;
}

[data-paper-editor] .file-dropzone-name {
    padding-top: 1px;
}

.question-thumb {
    display: block;
    width: 70px;
    height: 48px;
    object-fit: cover;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.question-image,
.question-preview {
    display: block;
    width: min(100%, 720px);
    max-height: 420px;
    margin: 14px 0 18px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.question-preview {
    width: min(100%, 360px);
    max-height: 240px;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
}

.checkbox-row input {
    width: auto;
    min-height: auto;
}

.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
}

.checkbox-grid-compact {
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    min-width: 260px;
}

.checkbox-card {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin: 0;
    padding: 10px 12px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 700;
}

.checkbox-card:hover {
    color: var(--primary-dark);
    background: #eef5ff;
    border-color: #bfdbfe;
}

.checkbox-card input {
    width: auto;
    min-height: auto;
    flex: 0 0 auto;
}

.timer {
    display: grid;
    gap: 4px;
    min-width: 150px;
    padding: 12px 14px;
    color: var(--primary-dark);
    background: #eef5ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
}

.timer span {
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
}

.timer strong {
    font-size: 28px;
    line-height: 1;
}

.timer-danger {
    color: var(--danger);
    background: #fff1f2;
    border-color: #fecaca;
}

.exam-heading-actions {
    align-items: stretch;
}

.exam-shell {
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: 18px;
    align-items: start;
}

.exam-progress-panel {
    position: sticky;
    top: 18px;
    display: grid;
    gap: 12px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.exam-progress-panel h2 {
    margin: 0;
    font-size: 18px;
}

.exam-progress-summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    padding: 10px;
    background: #eef5ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
}

.exam-progress-summary strong {
    color: var(--primary-dark);
    font-size: 18px;
    line-height: 1;
}

.exam-progress-summary span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
}

.exam-progress-muted {
    background: #fff7ed;
    border-color: #fed7aa;
}

.exam-progress-muted strong {
    color: var(--accent-amber);
}

.question-progress-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    max-height: 360px;
    overflow: auto;
    padding-right: 2px;
}

.question-progress-item {
    min-height: 48px;
    padding: 7px;
    color: var(--muted);
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: center;
    transition: border-color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.question-progress-item:hover,
.question-progress-item.is-active {
    color: var(--primary-dark);
    background: #eef5ff;
    border-color: #93c5fd;
    transform: translateY(-1px);
}

.question-progress-item strong,
.question-progress-item span {
    display: block;
}

.question-progress-item strong {
    margin-bottom: 2px;
    font-size: 15px;
}

.question-progress-item span {
    font-size: 11px;
    font-weight: 800;
}

.question-progress-item.is-answered {
    color: #166534;
    background: #f0fdf4;
    border-color: #86efac;
}

.question-progress-item.is-unanswered {
    color: #991b1b;
}

.exam-unanswered-list {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.exam-form,
.answer-list {
    display: grid;
    gap: 18px;
}

.answer-list-compact {
    gap: 10px;
}

.question-card,
.answer-card {
    padding: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.answer-list-compact .answer-card {
    padding: 14px 16px;
}

.answer-card-correct {
    border-color: #bbf7d0;
}

.answer-card-wrong {
    border-color: #fecaca;
}

.answer-card-pending {
    border-color: #fed7aa;
}

.question-card h2,
.answer-card h3 {
    margin: 12px 0 18px;
    font-size: 20px;
    line-height: 1.55;
}

.answer-list-compact .answer-card h3 {
    margin: 8px 0 10px;
    font-size: 16px;
    line-height: 1.42;
}

.question-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.question-meta span {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    color: #24507a;
    background: #eef5ff;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 800;
}

.answer-list-compact .question-meta span {
    min-height: 24px;
    padding: 0 8px;
    font-size: 12px;
}

.question-meta .answer-status-correct {
    color: #166534;
    background: #dcfce7;
}

.question-meta .answer-status-wrong {
    color: #991b1b;
    background: #fee2e2;
}

.question-meta .answer-status-pending {
    color: #9a3412;
    background: #ffedd5;
}

.option-list {
    display: grid;
    gap: 10px;
}

.answer-list-compact .option-list {
    gap: 6px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin: 0;
    padding: 12px;
    background: #f9fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
}

.answer-list-compact .option-item {
    padding: 8px 10px;
}

.option-item input {
    width: auto;
    min-height: auto;
    margin-top: 4px;
}

.option-review .option-item {
    cursor: default;
}

.option-review .option-correct {
    color: #166534;
    background: #f0fdf4;
    border-color: #86efac;
}

.option-review .option-wrong {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fca5a5;
}

.option-content {
    display: grid;
    gap: 8px;
    min-width: 0;
}

.option-content strong {
    color: var(--primary-dark);
}

.option-image,
.option-preview {
    display: block;
    width: min(100%, 320px);
    max-height: 220px;
    object-fit: contain;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.option-preview {
    width: min(100%, 220px);
    max-height: 150px;
    margin: 10px 0;
}

.compact-file {
    margin-top: 8px;
}

.file-input-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    min-height: 1px;
    margin: -1px;
    padding: 0;
    border: 0;
    opacity: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
}

.file-dropzone {
    display: grid;
    gap: 6px;
    min-height: 92px;
    margin: 8px 0 0;
    padding: 16px;
    color: var(--text);
    background: #f8fbff;
    border: 1px dashed #93c5fd;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 400;
    transition: border-color 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.file-dropzone:hover,
.file-dropzone.is-dragover,
.file-dropzone:focus-within {
    background: #eef5ff;
    border-color: var(--primary-dark);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.16);
}

.file-dropzone-title {
    color: var(--primary-dark);
    font-size: 15px;
    font-weight: 800;
}

.file-dropzone-hint,
.file-dropzone-name {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

.file-dropzone-name {
    padding-top: 4px;
    color: var(--primary-dark);
    font-weight: 800;
    word-break: break-word;
}

.file-dropzone.has-file {
    background: #fff;
    border-style: solid;
}

.code-answer {
    min-height: 220px;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.55;
}

.code-review {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: Consolas, "Courier New", monospace;
    line-height: 1.55;
}

.submit-bar {
    position: sticky;
    bottom: 0;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 0;
    background: linear-gradient(rgba(248, 247, 244, 0), var(--bg) 28%);
}

.exam-step-actions {
    justify-content: space-between;
}

.report-question-button {
    margin-left: auto;
    color: #991b1b;
    border-color: #fecaca;
    background: #fff1f2;
}

.report-question-button:hover {
    color: #7f1d1d;
    border-color: #fca5a5;
    background: #ffe4e6;
}

.answer-detail {
    display: grid;
    gap: 8px;
    margin: 0;
}

.answer-list-compact .answer-detail {
    grid-template-columns: minmax(72px, 96px) minmax(0, 1fr);
    gap: 6px 10px;
    align-items: start;
}

.answer-detail dt {
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
}

.answer-list-compact .answer-detail dt {
    padding-top: 7px;
    font-size: 12px;
}

.answer-detail dd {
    margin: 0 0 10px;
    padding: 12px;
    white-space: pre-wrap;
    background: #f9fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.answer-list-compact .answer-detail dd {
    margin: 0;
    padding: 8px 10px;
}

.answer-detail dd.answer-detail-correct {
    color: #166534;
    background: #f0fdf4;
    border-color: #86efac;
}

.answer-detail dd.answer-detail-wrong {
    color: #991b1b;
    background: #fff1f2;
    border-color: #fca5a5;
}

.answer-detail dd.answer-detail-pending {
    color: #9a3412;
    background: #fff7ed;
    border-color: #fed7aa;
}

.alert {
    margin-bottom: 18px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
}

.alert-error {
    color: var(--danger);
    border-color: #fecaca;
    background: #fff1f2;
}

.alert-success {
    color: var(--success);
    border-color: #bbf7d0;
    background: #f0fdf4;
}

.alert-info {
    color: var(--primary-dark);
    border-color: #bfdbfe;
    background: #eef5ff;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    background: rgba(23, 32, 51, 0.45);
    backdrop-filter: blur(6px);
}

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

.modal-panel {
    width: min(100%, 520px);
    max-height: min(760px, calc(100vh - 48px));
    overflow-y: auto;
    padding: 22px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 24px 70px rgba(23, 32, 51, 0.2);
}

.modal-panel-wide {
    width: min(100%, 760px);
}

.modal-head,
.modal-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.modal-head {
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.modal-head h2 {
    margin: 0;
    font-size: 22px;
}

.modal-close {
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
}

.modal-close:hover {
    color: var(--primary-dark);
    background: #eef5ff;
    border-color: #bfdbfe;
}

.modal-actions {
    justify-content: flex-end;
    margin-top: 18px;
}

.modal-actions-top {
    margin-top: 0;
    margin-bottom: 10px;
}

.modal-divider {
    width: 100%;
    margin: 20px 0;
    border: 0;
    border-top: 1px solid var(--line);
}

.modal-subtitle {
    margin: 0 0 12px;
    font-size: 17px;
}

.checkbox-list {
    display: grid;
    gap: 6px;
    max-height: 320px;
    overflow: auto;
    padding: 6px;
    background: #f8fbff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 9px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
    user-select: none;
}

.checkbox-item input {
    width: 16px;
    height: 16px;
    min-width: 16px;
    margin: 0;
}

.checkbox-item small {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
}

.checkbox-item.is-muted {
    opacity: 0.7;
    cursor: default;
}

.checkbox-list-compact {
    max-height: 360px;
}

.checkbox-list-compact .checkbox-item strong {
    font-size: 14px;
    line-height: 1.2;
}

.checkbox-item.is-drag-target {
    border-color: var(--primary);
    background: #eef5ff;
}

.demo-list {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.demo-account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    background: #f9fafc;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.demo-account code {
    color: var(--text);
    font-weight: 800;
}

.login-author-footer {
    margin: 12px 0 0;
    color: #cbd5e1;
    font-size: 13px;
    font-weight: 800;
    text-align: center;
}

@media (max-width: 880px) {
    body {
        padding-left: 0;
    }

    body.nav-open {
        overflow: hidden;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 70;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 12px;
        width: 100%;
        height: 64px;
        padding: 8px 12px;
        overflow: visible;
        border-right: 0;
        border-bottom: 1px solid var(--line);
        box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
    }

    body.nav-open .topbar {
        position: fixed;
        inset: 0;
        align-content: flex-start;
        align-items: stretch;
        width: 100%;
        height: 100vh;
        height: 100dvh;
        padding: 8px 12px max(12px, env(safe-area-inset-bottom));
        overflow-y: auto;
    }

    .brand {
        flex: 1 1 auto;
        width: auto;
        padding: 0;
        border-bottom: 0;
    }

    .brand-mark {
        flex-basis: 40px;
        width: 40px;
        height: 40px;
    }

    .brand strong {
        font-size: 17px;
    }

    .brand small {
        font-size: 11px;
    }

    .mobile-nav-toggle {
        display: inline-grid;
        place-items: center;
        flex: 0 0 44px;
        width: 44px;
        height: 44px;
        color: var(--text);
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow-soft);
        cursor: pointer;
    }

    .mobile-nav-toggle[aria-expanded="true"] {
        color: var(--primary-dark);
        background: #eef5ff;
        border-color: #bfdbfe;
    }

    .mobile-nav-backdrop:not([hidden]) {
        position: fixed;
        inset: 0;
        z-index: 60;
        display: block;
        background: rgba(15, 23, 42, 0.28);
        backdrop-filter: blur(2px);
    }

    .nav-actions {
        display: none;
        flex: 1 1 100%;
        flex-direction: column;
        justify-content: flex-start;
        align-items: stretch;
        flex-wrap: nowrap;
        width: 100%;
        max-height: none;
        margin-top: 4px;
        padding: 14px;
        overflow-y: visible;
        background: rgba(255, 255, 255, 0.98);
        border: 1px solid var(--line);
        border-radius: 12px;
        box-shadow: 0 22px 52px rgba(15, 23, 42, 0.2);
        opacity: 1;
        pointer-events: auto;
        transform: none;
    }

    .topbar .button,
    .topbar .user-chip,
    .topbar .nav-link,
    .topbar .nav-group {
        width: 100%;
        justify-content: flex-start;
    }

    body.nav-open .nav-actions {
        display: flex;
    }

    .nav-link,
    .nav-group summary {
        min-height: 48px;
        padding: 0 14px;
        box-shadow: none;
    }

    .topbar .user-chip {
        min-height: 44px;
        padding: 0 14px;
        border-radius: var(--radius);
    }

    .nav-submenu {
        gap: 4px;
        margin-top: 6px;
        padding-top: 6px;
    }

    .nav-sub-link {
        min-height: 40px;
        padding: 0 12px;
        font-size: 14px;
    }

    .nav-link-logout {
        margin-top: 8px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }

    .heading-actions {
        justify-content: flex-start;
    }

    .timer {
        width: 100%;
    }

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

    .exam-progress-panel {
        position: static;
    }

    .question-progress-grid {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        max-height: none;
    }

    .submit-bar {
        align-items: stretch;
        flex-direction: column;
    }

    .answer-list-compact .answer-detail {
        grid-template-columns: 1fr;
    }

    .answer-list-compact .answer-detail dt {
        padding-top: 0;
    }

    .paper-toolbar,
    .paper-question-head {
        flex-direction: column;
    }

    .login-layout,
    .section-grid,
    .form-grid,
    .filter-bar,
    .stat-grid,
    .action-grid,
    .library-grid {
        grid-template-columns: 1fr;
    }

    .page {
        width: min(100% - 24px, 1120px);
        padding-top: 18px;
    }

    .table-wrap {
        margin-right: -12px;
        margin-left: -12px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    table {
        min-width: 760px;
    }

    th,
    td {
        padding: 10px 12px;
        vertical-align: top;
    }
}
