:root {
    --blue-950: #082856;
    --blue-800: #0c3e80;
    --blue-600: #1763ad;
    --gold: #f5c542;
    --ink: #172238;
    --muted: #67758a;
    --line: #dce4ef;
    --surface: #ffffff;
    --background: #f4f7fb;
    --danger: #b42318;
    --field: #fbfcfe;
    --field-border: #cdd7e5;
    --soft: #f8fafc;
    --quiet: #eaf2fb;
    --danger-soft: #fff0ee;
    --login-glow: #ddebfa;
    --card-shadow: 0 14px 40px rgba(20, 45, 80, .08);
    color-scheme: light;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
    color: var(--ink);
    background: var(--background);
}

:root[data-theme="dark"] {
    --ink: #edf3ff;
    --muted: #a9b6c9;
    --line: #34445c;
    --surface: #142033;
    --background: #0b1320;
    --danger: #ff9188;
    --field: #0f1a2a;
    --field-border: #40536f;
    --soft: #101b2b;
    --quiet: #183451;
    --danger-soft: #3b1d21;
    --login-glow: #112b47;
    --card-shadow: 0 14px 40px rgba(0, 0, 0, .28);
    color-scheme: dark;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--background); color: var(--ink); }
a { color: var(--blue-800); text-decoration: none; }
button, input, textarea, select { font: inherit; }

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px clamp(18px, 4vw, 48px);
    color: #fff;
    background: linear-gradient(135deg, var(--blue-950), var(--blue-600));
    box-shadow: 0 8px 25px rgba(8, 40, 86, .18);
}
.topbar strong, .topbar span { display: block; }
.topbar strong { font-size: 20px; }
.topbar span { margin-top: 2px; color: #d8eaff; font-size: 13px; }
.topbar nav { display: flex; align-items: center; gap: 14px; }
.topbar nav a { color: #fff; font-weight: 700; }
.theme-toggle { display: inline-flex; min-height: 36px; padding: 7px 10px; align-items: center; gap: 7px; color: inherit; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.32); border-radius: 10px; cursor: pointer; font: inherit; font-weight: 800; }
.theme-toggle [data-theme-icon] { font-size: 18px; line-height: 1; }

.admin-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(380px, .95fr);
    gap: 22px;
    width: min(1460px, calc(100% - 36px));
    margin: 26px auto 50px;
    align-items: start;
}

.editor-card, .list-card, .login-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 20px;
    box-shadow: var(--card-shadow);
}
.editor-card, .list-card { padding: clamp(20px, 3vw, 30px); }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.section-heading h1, .section-heading h2 { margin: 0; font-size: 26px; }
.eyebrow { margin: 0 0 4px; color: var(--blue-600); font-size: 11px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.count { display: grid; min-width: 36px; height: 36px; padding: 0 10px; place-items: center; color: #fff; background: var(--blue-800); border-radius: 12px; font-weight: 900; }

.editor-form, .login-card form { display: grid; gap: 15px; }
label { display: grid; gap: 7px; color: var(--ink); font-size: 14px; font-weight: 750; }
input, textarea, select {
    width: 100%;
    padding: 12px 13px;
    color: var(--ink);
    background: var(--field);
    border: 1px solid var(--field-border);
    border-radius: 11px;
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--blue-600); box-shadow: 0 0 0 3px rgba(23, 99, 173, .12); }
textarea { resize: vertical; line-height: 1.5; }
.form-grid { display: grid; gap: 14px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 9px 15px;
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 800;
}
.button.primary { color: #fff; background: var(--blue-800); }
.button.quiet { color: var(--blue-800); background: var(--quiet); }
.button.danger { color: var(--danger); background: var(--danger-soft); }
.button.full { width: 100%; }

.alert { margin: 0 0 18px; padding: 13px 15px; border-radius: 12px; font-weight: 700; }
.alert.error { color: #8a1c13; background: #fff0ee; border: 1px solid #ffc9c2; }
.alert.success { color: #17643b; background: #eaf9f0; border: 1px solid #b7ebca; }

.content-list { display: grid; gap: 11px; }
.content-row { display: flex; justify-content: space-between; gap: 15px; padding: 16px; border: 1px solid var(--line); border-radius: 15px; }
.content-row h3 { margin: 7px 0 5px; font-size: 17px; }
.content-row small { color: var(--muted); }
.meta, .row-actions { display: flex; align-items: center; gap: 8px; }
.row-actions { align-self: center; }
.row-actions form { margin: 0; }
.pill, .status { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: 11px; font-weight: 850; }
.pill.news { color: #174a7e; background: #e6f1fc; }
.pill.event { color: #684d00; background: #fff3c4; }
.pill.notice { color: #8b2f18; background: #ffebe5; }
.pill.gallery { color: #5d2a83; background: #f2e8fb; }
.status.published { color: #17643b; background: #eaf9f0; }
.status.draft { color: #606a77; background: #eef1f5; }
.empty { padding: 28px; color: var(--muted); background: var(--soft); border-radius: 15px; text-align: center; }
.current-image { display: flex; align-items: center; gap: 14px; padding: 12px; background: var(--soft); border-radius: 12px; }
.current-image img { width: 86px; height: 66px; object-fit: cover; border-radius: 9px; }
.current-image label { display: flex; grid: none; align-items: center; gap: 8px; }
.current-image input { width: auto; }

.login-page { display: grid; min-height: 100vh; padding: 22px; place-items: center; background: radial-gradient(circle at top, var(--login-glow), var(--background) 55%); }
.login-card { width: min(100%, 440px); padding: 32px; }
.login-theme { display: flex; justify-content: flex-end; margin-bottom: 10px; }
.login-theme .theme-toggle { color: var(--ink); background: var(--soft); border-color: var(--line); }
.login-card h1 { margin: 14px 0 8px; }
.login-card > p { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }
.brand-badge { display: grid; width: 54px; height: 54px; place-items: center; color: #fff; background: var(--blue-800); border-bottom: 6px solid var(--gold); border-radius: 16px; font-weight: 950; }
code { padding: 2px 5px; background: var(--soft); border-radius: 5px; }

:root[data-theme="dark"] a { color: #83bef2; }
:root[data-theme="dark"] .button.primary { color: #fff; background: #1763ad; }
:root[data-theme="dark"] .button.quiet { color: #a9d5ff; }
:root[data-theme="dark"] .alert.error { color: #ffb0a9; background: #3b1d21; border-color: #6f3437; }
:root[data-theme="dark"] .alert.success { color: #92e2b3; background: #123426; border-color: #285d43; }
:root[data-theme="dark"] .pill.news { color: #a9d5ff; background: #173552; }
:root[data-theme="dark"] .pill.event { color: #ffe28a; background: #3e3415; }
:root[data-theme="dark"] .pill.notice { color: #ffb19d; background: #43241f; }
:root[data-theme="dark"] .pill.gallery { color: #d7b1f4; background: #352242; }
:root[data-theme="dark"] .status.published { color: #91e1b2; background: #173a2a; }
:root[data-theme="dark"] .status.draft { color: #c0c9d6; background: #2a3545; }

@media (max-width: 980px) {
    .admin-layout { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
    .topbar { align-items: flex-start; }
    .topbar nav { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
    .admin-layout { width: min(100% - 20px, 1460px); margin-top: 12px; }
    .editor-card, .list-card, .login-card { padding: 18px; border-radius: 16px; }
    .form-grid.two { grid-template-columns: 1fr; }
    .content-row { flex-direction: column; }
    .row-actions { align-self: stretch; }
    .row-actions .button, .row-actions form { flex: 1; }
    .row-actions form .button { width: 100%; }
}
