:root {
    --bg: #0f172a;
    --panel: #ffffff;
    --line: #dbe4ee;
    --text: #102032;
    --muted: #5b6b7f;
    --brand: #0f766e;
    --brand-dark: #115e59;
    --danger: #b91c1c;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.12);
    --radius: 18px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: linear-gradient(180deg, #eef2ff 0%, #f8fafc 100%);
    color: var(--text);
    font-family: Inter, Arial, Helvetica, sans-serif;
}

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

.admin-shell {
    width: min(1220px, calc(100% - 28px));
    margin: 26px auto 40px;
}

.login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 18px;
}

.login-card,
.admin-panel,
.flash,
.table-card,
.editor-shell {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.login-card {
    width: min(460px, 100%);
    padding: 28px;
}

.login-card h1,
.admin-heading h1 {
    margin-top: 0;
    margin-bottom: 10px;
}

.login-hint,
.muted {
    color: var(--muted);
}

.admin-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 22px;
}

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 999px;
    font-weight: 700;
    padding: 11px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: .2s ease;
}

.button.primary { background: var(--brand); color: #fff; }
.button.primary:hover { background: var(--brand-dark); text-decoration: none; }
.button.secondary { background: #fff; border-color: var(--line); color: var(--text); }
.button.secondary:hover { text-decoration: none; border-color: #bdc8d6; }
.button.danger { background: #fff1f2; color: var(--danger); border-color: #fecdd3; }

.flash {
    padding: 16px 18px;
    margin-bottom: 18px;
}

.flash.success { border-color: #a7f3d0; background: #ecfdf5; color: #065f46; }
.flash.error { border-color: #fecaca; background: #fef2f2; color: #991b1b; }

.table-card,
.admin-panel {
    padding: 22px;
}

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

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

.field.full { grid-column: 1 / -1; }

label {
    font-weight: 700;
    font-size: 14px;
}

input[type="text"],
input[type="date"],
input[type="password"],
input[type="file"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px 14px;
    font: inherit;
    color: var(--text);
    background: #fff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.editor-shell {
    overflow: hidden;
    border-radius: 16px;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}

.editor-toolbar button,
.editor-toolbar select {
    padding: 8px 10px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    font: inherit;
}

.editor-surface {
    min-height: 340px;
    padding: 18px;
    outline: none;
}

.editor-source {
    display: none;
    border: 0;
    border-top: 1px solid var(--line);
    border-radius: 0;
    min-height: 340px;
}

.editor-shell.is-source .editor-surface { display: none; }
.editor-shell.is-source .editor-source { display: block; }

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 14px 10px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
}

.badge {
    display: inline-flex;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 13px;
    font-weight: 700;
}

.badge.published { background: #ecfdf5; color: #065f46; }
.badge.draft { background: #eff6ff; color: #1d4ed8; }

.thumb-preview {
    width: min(240px, 100%);
    aspect-ratio: 16 / 9;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #f8fafc;
}

.thumb-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.inline-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.hint-list {
    margin: 10px 0 0;
    padding-left: 18px;
    color: var(--muted);
}

@media (max-width: 860px) {
    .form-grid { grid-template-columns: 1fr; }
    .admin-topbar { flex-direction: column; align-items: flex-start; }
    table, thead, tbody, th, td, tr { display: block; }
    thead { display: none; }
    tr {
        border-bottom: 1px solid var(--line);
        padding: 10px 0;
    }
    td {
        border: 0;
        padding: 6px 0;
    }
    td::before {
        content: attr(data-label);
        display: block;
        color: var(--muted);
        font-size: 13px;
        text-transform: uppercase;
        margin-bottom: 4px;
        letter-spacing: .04em;
    }
}
