@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:wght@300;400;500;600;700&family=Playfair+Display:wght@400;500;600&display=swap&subset=vietnamese');

:root {
    --ink: #171412;
    --muted: #736b64;
    --line: #e6ddd4;
    --paper: #f7f3ee;
    --dark: #28211c;
    --accent: #a77955;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Be Vietnam Pro", Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: var(--paper);
}

a {
    color: inherit;
    text-decoration: none;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 20px;
    background: linear-gradient(rgba(22,18,15,.72), rgba(22,18,15,.72)), url('https://images.unsplash.com/photo-1519225421980-715cb0215aed?auto=format&fit=crop&w=1600&q=82') center/cover;
}

.login-card,
.editor,
.table-panel {
    background: #fff;
    border: 1px solid var(--line);
}

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

.login-card p,
.panel-head p {
    margin: 0 0 8px;
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.login-card h1,
.panel-head h1 {
    margin: 0 0 22px;
    font-family: "Playfair Display", Georgia, 'Times New Roman', serif;
    font-weight: 400;
    font-size: 40px;
}

.alert {
    margin-bottom: 16px;
    padding: 12px;
    color: #8a1e1e;
    background: #fff0f0;
}

label {
    display: grid;
    gap: 8px;
    margin-bottom: 16px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    padding: 12px 13px;
    color: var(--ink);
    background: #fff;
    font: inherit;
}

textarea {
    resize: vertical;
    line-height: 1.6;
}

button,
.button {
    border: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 18px;
    color: #fff;
    background: var(--dark);
    font-weight: 700;
    cursor: pointer;
}

.login-card button {
    width: 100%;
    margin-bottom: 16px;
}

.login-card a {
    color: var(--muted);
    font-size: 14px;
}

.admin-top {
    min-height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 16px clamp(18px, 5vw, 58px);
    background: #fff;
    border-bottom: 1px solid var(--line);
}

.admin-top div {
    display: grid;
    gap: 4px;
}

.admin-top span {
    color: var(--muted);
    font-size: 13px;
}

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

.admin-top nav a {
    color: var(--muted);
    font-size: 14px;
}

.admin-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 34px 18px 70px;
}

.admin-shell.narrow {
    max-width: 860px;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 18px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 22px;
}

.stat-card {
    display: grid;
    gap: 6px;
    min-height: 132px;
    padding: 18px;
    border: 1px solid var(--line);
    background: #fff;
}

.stat-card span,
.stat-card small {
    color: var(--muted);
    font-size: 12px;
}

.stat-card strong {
    font-family: "Playfair Display", Georgia, serif;
    font-size: 34px;
    font-weight: 500;
}

.filter-bar {
    display: grid;
    grid-template-columns: minmax(220px, 1.5fr) repeat(2, minmax(150px, .8fr)) auto auto;
    align-items: end;
    gap: 10px;
    margin-bottom: 14px;
    padding: 14px;
    border: 1px solid var(--line);
    background: #fff;
}

.filter-bar label {
    margin: 0;
    gap: 5px;
    font-size: 11px;
}

.filter-bar label span {
    color: var(--muted);
}

.filter-bar input,
.filter-bar select {
    min-height: 40px;
    padding: 8px 10px;
    font-size: 13px;
}

.filter-bar button {
    min-height: 40px;
    padding: 0 14px;
    font-size: 12px;
}

.clear-filter {
    align-self: center;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
}

.admin-notice {
    margin-bottom: 16px;
    padding: 12px 14px;
    color: #315d3b;
    border: 1px solid #cfe3d3;
    background: #edf7ef;
    font-size: 13px;
}

.category-manager {
    display: grid;
    grid-template-columns: minmax(260px, .34fr) minmax(0, 1fr);
    align-items: start;
    gap: 18px;
}

.category-form-panel {
    padding: 22px;
    border: 1px solid var(--line);
    background: #fff;
}

.category-form-panel h2 {
    margin: 0 0 20px;
    font-family: "Playfair Display", Georgia, serif;
    font-size: 27px;
    font-weight: 400;
}

.category-form-panel button {
    width: 100%;
}

.category-table-panel {
    min-width: 0;
}

.post-cell-slug {
    color: var(--muted);
    font-size: 12px;
}

.inline-edit {
    position: relative;
}

.inline-edit summary {
    min-height: 32px;
    padding: 8px 12px;
    color: var(--ink);
    border: 1px solid var(--line);
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    list-style: none;
}

.inline-edit summary::-webkit-details-marker {
    display: none;
}

.inline-edit[open] summary {
    color: #fff;
    background: var(--dark);
}

.inline-edit form {
    position: absolute;
    z-index: 3;
    right: 0;
    top: 38px;
    display: grid;
    gap: 8px;
    width: 250px;
    padding: 12px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 12px 30px rgba(30, 20, 14, .14);
}

.inline-edit form input {
    min-height: 34px;
    padding: 7px 9px;
    font-size: 12px;
}

.inline-edit form .check {
    padding-top: 0;
    margin: 0;
    font-size: 11px;
}

.inline-edit form button {
    min-height: 34px;
    font-size: 12px;
}

.table-panel {
    overflow-x: auto;
}

.table-caption {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}

.table-caption strong {
    color: var(--ink);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 760px;
}

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

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

.post-cell {
    display: flex;
    align-items: center;
    gap: 14px;
}

.post-cell img {
    width: 74px;
    height: 58px;
    object-fit: cover;
    background: var(--paper);
}

.post-cell div {
    display: grid;
    gap: 4px;
}

.post-cell span,
.status {
    color: var(--muted);
    font-size: 13px;
}

.category-tag {
    display: inline-block;
    color: var(--accent);
    font-size: 12px;
    line-height: 1.4;
}

.status {
    padding: 5px 8px;
    border-radius: 999px;
    background: #f2eee9;
}

.status-published {
    color: #326044;
    background: #e8f3e9;
}

.status-draft {
    color: #795b22;
    background: #fbf1d8;
}

.empty-table {
    padding: 42px 16px;
    color: var(--muted);
    text-align: center;
}

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

.actions a,
.actions button {
    min-height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.actions button {
    background: #8a2f2f;
}

.editor {
    padding: 26px;
}

.rich-editor {
    margin: -4px 0 18px;
    border: 1px solid var(--line);
    background: #fff;
}

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

.editor-toolbar button {
    min-width: 34px;
    min-height: 32px;
    padding: 0 9px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    font-size: 13px;
}

.editor-toolbar button:hover,
.editor-toolbar button:focus-visible {
    color: #fff;
    background: var(--accent);
}

.editor-canvas {
    min-height: 280px;
    padding: 18px;
    outline: 0;
    line-height: 1.8;
}

.editor-canvas:focus {
    box-shadow: inset 0 0 0 2px rgba(167, 121, 85, .22);
}

.editor-canvas h2,
.editor-canvas h3 {
    font-family: "Playfair Display", Georgia, serif;
    font-weight: 500;
}

.editor-canvas blockquote {
    margin: 16px 0;
    padding: 10px 16px;
    border-left: 3px solid var(--accent);
    color: var(--muted);
}

.editor-canvas img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 16px 0;
}

.editor-meta {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    color: var(--muted);
    border-top: 1px solid var(--line);
    font-size: 11px;
}

.article-upload {
    display: grid;
    gap: 7px;
    margin: -4px 0 18px;
    padding: 12px 14px;
    border: 1px dashed var(--line);
    background: #faf7f3;
}

.article-upload label {
    margin: 0;
    color: var(--ink);
}

.article-upload input {
    padding: 8px;
    background: #fff;
}

.article-upload small {
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
}

.upload-hint {
    color: var(--muted);
    font-size: 11px;
    font-weight: 400;
}

.media-upload-panel {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px;
    border: 1px dashed var(--line);
    background: #fff;
}

.media-upload-panel label {
    margin: 0;
    color: var(--ink);
}

.media-upload-panel input {
    width: auto;
    padding: 8px;
}

.media-upload-panel span {
    color: var(--muted);
    font-size: 12px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.media-card {
    overflow: hidden;
    border: 1px solid var(--line);
    background: #fff;
}

.media-card > img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background: var(--paper);
}

.media-card > div {
    display: grid;
    gap: 9px;
    padding: 10px;
}

.media-card small {
    overflow: hidden;
    color: var(--muted);
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-card button {
    min-height: 30px;
    width: 100%;
    padding: 0 10px;
    background: #8a2f2f;
    font-size: 11px;
}

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

.check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-top: 27px;
}

.check input {
    width: auto;
}

.preview {
    width: 220px;
    max-width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    margin-bottom: 16px;
}

.editor-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

.editor-actions a {
    color: var(--muted);
}

@media (max-width: 700px) {
    .admin-top,
    .panel-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-bar {
        grid-template-columns: 1fr;
    }

    .category-manager {
        grid-template-columns: 1fr;
    }

    .media-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .table-caption {
        align-items: flex-start;
        flex-direction: column;
    }
}
