:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --surface-2: #eef2ff;
    --text: #172033;
    --muted: #667085;
    --line: #e4e7ec;
    --primary: #2457e6;
    --primary-dark: #173ba1;
    --accent: #ffb547;
    --success: #087a55;
    --danger: #b42318;
    --radius: 18px;
    --shadow: 0 16px 45px rgba(22, 34, 66, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; }
button, input, select, textarea { font: inherit; }
.container { width: min(1160px, calc(100% - 32px)); margin-inline: auto; }

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(14px);
    border-bottom: 1px solid rgba(228, 231, 236, .85);
}
.nav-wrap { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand { display: inline-flex; align-items: center; gap: 11px; min-width: 0; }
.brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(145deg, var(--primary), #7b42f6);
    box-shadow: 0 9px 24px rgba(36, 87, 230, .25);
    font-weight: 900;
}
.brand span:last-child { display: grid; line-height: 1.2; }
.brand strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--muted); font-size: .76rem; }
.main-nav { display: flex; gap: 8px; align-items: center; }
.main-nav a { padding: 9px 13px; border-radius: 10px; color: #344054; font-weight: 650; font-size: .92rem; }
.main-nav a:hover { background: var(--surface-2); color: var(--primary); }
.nav-toggle { display: none; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 11px; }

.hero {
    overflow: hidden;
    position: relative;
    padding: 72px 0 54px;
    background:
        radial-gradient(circle at 80% 10%, rgba(255,181,71,.24), transparent 24%),
        radial-gradient(circle at 15% 15%, rgba(123,66,246,.15), transparent 24%),
        linear-gradient(135deg, #101b3f 0%, #173b8d 60%, #2457e6 100%);
    color: #fff;
}
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr); gap: 54px; align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 8px; font-size: .8rem; font-weight: 800; text-transform: uppercase; letter-spacing: .12em; color: #cbd8ff; }
.hero h1 { margin: 14px 0 15px; font-size: clamp(2.3rem, 6vw, 4.9rem); line-height: .98; letter-spacing: -.055em; max-width: 850px; }
.hero p { margin: 0; max-width: 720px; color: #dce4ff; font-size: clamp(1rem, 2vw, 1.18rem); }
.search-box { margin-top: 28px; display: flex; gap: 10px; background: #fff; padding: 8px; border-radius: 16px; box-shadow: 0 18px 45px rgba(0,0,0,.22); max-width: 700px; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: 0; padding: 12px 14px; color: var(--text); background: transparent; }
.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border: 0;
    border-radius: 12px;
    padding: 11px 17px;
    font-weight: 800;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 9px 22px rgba(36,87,230,.24); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-light { background: #fff; color: var(--primary); }
.btn-outline { border: 1px solid var(--line); background: #fff; color: var(--text); }
.btn-danger { background: #fee4e2; color: var(--danger); }
.hero-card { background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.19); border-radius: 24px; padding: 25px; backdrop-filter: blur(10px); }
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.stat { padding: 18px; border-radius: 16px; background: rgba(255,255,255,.09); }
.stat strong { display: block; font-size: 1.75rem; line-height: 1.1; }
.stat span { font-size: .82rem; color: #dce4ff; }

.section { padding: 58px 0; }
.section-tight { padding: 34px 0; }
.section-head { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.section-head h2, .page-head h1 { margin: 0; letter-spacing: -.035em; line-height: 1.1; }
.section-head h2 { font-size: clamp(1.65rem, 3vw, 2.45rem); }
.section-head p, .page-head p { margin: 7px 0 0; color: var(--muted); }
.link-arrow { color: var(--primary); font-weight: 800; white-space: nowrap; }

.exam-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.exam-card { display: grid; min-height: 210px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 0 rgba(16,24,40,.02); transition: .2s ease; }
.exam-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); border-color: #c7d3ff; }
.exam-icon { width: 47px; height: 47px; display: grid; place-items: center; border-radius: 14px; background: var(--surface-2); color: var(--primary); font-weight: 900; }
.exam-card h3 { margin: 18px 0 7px; font-size: 1.08rem; line-height: 1.35; }
.exam-card p { margin: 0; color: var(--muted); font-size: .92rem; }
.exam-meta { align-self: end; display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 9px; background: #f2f4f7; color: #475467; font-size: .76rem; font-weight: 750; }

.paper-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.paper-card { display: flex; flex-direction: column; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; min-height: 250px; }
.paper-card:hover { border-color: #b8c8ff; box-shadow: 0 12px 34px rgba(25,43,88,.08); }
.paper-card .paper-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.year-badge { background: #ecfdf3; color: var(--success); border-radius: 9px; padding: 5px 9px; font-size: .76rem; font-weight: 850; }
.pdf-badge { color: #c11574; background: #fdf2fa; border-radius: 9px; padding: 5px 9px; font-size: .72rem; font-weight: 850; }
.paper-card h3 { margin: 15px 0 8px; font-size: 1.05rem; line-height: 1.43; }
.paper-card p { margin: 0; color: var(--muted); font-size: .9rem; }
.paper-tags { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 15px; }
.paper-actions { display: flex; gap: 9px; margin-top: auto; padding-top: 18px; }
.paper-actions .btn { flex: 1; padding: 9px 11px; font-size: .85rem; }

.page-head { padding: 48px 0 30px; background: linear-gradient(180deg, #eef2ff, transparent); }
.page-head h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
.breadcrumbs { font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.breadcrumbs a { color: var(--primary); }

.filters { display: grid; grid-template-columns: 2fr repeat(3, 1fr) auto; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 24px; }
.input, .select, .textarea { width: 100%; border: 1px solid #d0d5dd; border-radius: 11px; padding: 10px 12px; outline: none; background: #fff; color: var(--text); }
.input:focus, .select:focus, .textarea:focus { border-color: #84a2ff; box-shadow: 0 0 0 3px rgba(36,87,230,.12); }
.textarea { min-height: 120px; resize: vertical; }

.paper-detail { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 26px; align-items: start; }
.content-card, .side-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 25px; }
.content-card h2, .content-card h3 { letter-spacing: -.02em; }
.meta-list { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; margin: 20px 0; }
.meta-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.meta-item span { display: block; color: var(--muted); font-size: .75rem; }
.meta-item strong { display: block; margin-top: 2px; }
.side-card { position: sticky; top: 94px; }
.side-card .btn { width: 100%; margin-top: 9px; }
.note { border-radius: 12px; padding: 13px 15px; background: #fff8e8; color: #704c00; font-size: .9rem; }

.pagination { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-top: 28px; }
.pagination a, .pagination span { min-width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; border: 1px solid var(--line); background: #fff; font-weight: 700; }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.empty-state { text-align: center; background: #fff; border: 1px dashed #cfd4dc; border-radius: var(--radius); padding: 48px 20px; color: var(--muted); }
.ad-slot { margin-block: 16px; overflow: hidden; text-align: center; }

.site-footer { margin-top: 55px; padding: 42px 0 20px; background: #11182b; color: #d5d9e4; }
.footer-grid { display: grid; grid-template-columns: 1fr auto; gap: 30px; }
.footer-grid p { max-width: 560px; color: #9da5b8; }
.footer-links { display: flex; gap: 16px; align-items: start; }
.copyright { border-top: 1px solid #283147; margin-top: 26px; padding-top: 18px; color: #8f98ac; font-size: .85rem; }

/* Admin */
.admin-body { background: #f4f6fa; }
.admin-shell { display: grid; grid-template-columns: 245px minmax(0, 1fr); min-height: 100vh; }
.admin-sidebar { background: #11182b; color: #fff; padding: 22px 14px; }
.admin-sidebar .brand { padding: 0 8px 22px; color: #fff; }
.admin-nav { display: grid; gap: 5px; }
.admin-nav a { padding: 10px 12px; border-radius: 9px; color: #c8cfdd; font-weight: 650; }
.admin-nav a:hover, .admin-nav a.active { background: #26304a; color: #fff; }
.admin-main { min-width: 0; }
.admin-top { background: #fff; border-bottom: 1px solid var(--line); padding: 14px 24px; display: flex; justify-content: space-between; gap: 15px; align-items: center; }
.admin-content { padding: 25px; }
.admin-content h1 { margin-top: 0; letter-spacing: -.03em; }
.dashboard-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; }
.dashboard-card { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.dashboard-card span { color: var(--muted); font-size: .82rem; }
.dashboard-card strong { display: block; font-size: 1.8rem; line-height: 1.2; margin-top: 5px; }
.admin-card { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 20px; margin-top: 18px; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: top; font-size: .88rem; }
th { color: #475467; background: #f9fafb; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.form-field { display: grid; gap: 5px; }
.form-field.full { grid-column: 1 / -1; }
.form-field label { font-weight: 750; font-size: .86rem; }
.flash { padding: 12px 14px; border-radius: 11px; margin-bottom: 12px; }
.flash-success { background: #ecfdf3; color: #067647; }
.flash-error { background: #fef3f2; color: #b42318; }
.flash-info { background: #eff8ff; color: #175cd3; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: linear-gradient(135deg, #11182b, #2457e6); }
.login-card { width: min(430px, 100%); background: #fff; border-radius: 20px; padding: 27px; box-shadow: 0 25px 80px rgba(0,0,0,.25); }
.login-card h1 { margin: 0 0 5px; }
.login-card .form-field { margin-top: 13px; }
.import-log { background: #111827; color: #d1fae5; padding: 15px; border-radius: 12px; max-height: 420px; overflow: auto; white-space: pre-wrap; font: 12px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; }
.status { display: inline-flex; border-radius: 999px; padding: 4px 8px; font-size: .72rem; font-weight: 800; }
.status-published, .status-completed { background: #ecfdf3; color: #067647; }
.status-draft, .status-running { background: #fffaeb; color: #b54708; }
.status-failed, .status-completed_with_errors { background: #fef3f2; color: #b42318; }

@media (max-width: 960px) {
    .hero-grid, .paper-detail { grid-template-columns: 1fr; }
    .hero-card { max-width: 620px; }
    .exam-grid, .paper-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filters > :first-child { grid-column: 1 / -1; }
    .side-card { position: static; }
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
    .nav-toggle { display: inline-flex; }
    .main-nav { display: none; position: absolute; left: 16px; right: 16px; top: 66px; background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 8px; box-shadow: var(--shadow); }
    .main-nav.open { display: grid; }
    .hero { padding-top: 48px; }
    .hero-grid { gap: 28px; }
    .hero h1 { font-size: clamp(2.25rem, 13vw, 3.7rem); }
    .search-box { display: grid; }
    .exam-grid, .paper-grid { grid-template-columns: 1fr; }
    .section { padding: 42px 0; }
    .section-head { align-items: start; flex-direction: column; }
    .filters { grid-template-columns: 1fr; }
    .filters > :first-child { grid-column: auto; }
    .meta-list { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .footer-links { flex-wrap: wrap; }
    .admin-shell { display: block; }
    .admin-sidebar { position: static; }
    .admin-nav { grid-template-columns: repeat(2, 1fr); }
    .admin-content { padding: 16px; }
    .form-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .form-field.full { grid-column: auto; }
}
