:root {
    --bg: #f4f6f9;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #6b7280;
    --line: #e5e7eb;
    --sidebar: #111827;
    --sidebar-soft: #1f2937;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #b42318;
    --success: #027a48;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 14px;
}

a {
    color: inherit;
}

.plain-body {
    display: grid;
    place-items: center;
}

.admin-body {
    padding-left: 260px;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 260px;
    display: flex;
    flex-direction: column;
    background: var(--sidebar);
    color: #d1d5db;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    padding: 18px;
    color: #ffffff;
    text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    display: grid;
    width: 38px;
    height: 38px;
    place-items: center;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-weight: 800;
}

.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand small {
    margin-top: 2px;
    color: #9ca3af;
    font-size: 12px;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
    padding: 14px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 10px 12px;
    border-radius: 6px;
    color: #d1d5db;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--sidebar-soft);
    color: #ffffff;
}

.sidebar-footer {
    display: grid;
    gap: 8px;
    margin-top: auto;
    padding: 16px;
    color: #9ca3af;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-footer a {
    color: #ffffff;
    font-weight: 700;
    text-decoration: none;
}

.main-wrap {
    min-height: 100vh;
}

.admin-header {
    position: sticky;
    top: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    padding: 0 24px;
    background: var(--card);
    border-bottom: 1px solid var(--line);
}

.admin-header strong,
.admin-header span {
    display: block;
}

.admin-header span {
    margin-top: 2px;
    color: var(--muted);
    font-size: 12px;
}

.page {
    width: min(1180px, calc(100% - 40px));
    margin: 24px auto;
}

.auth-page {
    width: 100%;
    margin: 0;
}

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

.auth-box {
    width: min(420px, 100%);
    padding: 28px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(17, 24, 39, 0.08);
}

h1 {
    margin: 0 0 6px;
    color: #111827;
    font-size: 24px;
    line-height: 1.25;
}

.muted {
    margin: 0;
    color: var(--muted);
}

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

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

.summary-card {
    padding: 16px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
}

.summary-card span,
.summary-card strong {
    display: block;
}

.summary-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
}

.summary-card strong {
    margin-top: 6px;
    color: #111827;
    font-size: 22px;
}

.data-card,
.edit-form {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

.data-table {
    width: 100%;
    min-width: 820px;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    max-width: 260px;
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
    border-bottom: 1px solid var(--line);
}

.data-table th {
    color: #374151;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    background: #f9fafb;
}

.data-table tr:hover td {
    background: #f9fafb;
}

.data-table tr:last-child td {
    border-bottom: 0;
}

.actions-col {
    width: 100px;
}

.empty {
    color: var(--muted);
    text-align: center;
}

.pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px;
    border-top: 1px solid var(--line);
}

.pagination a {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
}

.form,
.edit-form {
    display: grid;
    gap: 18px;
}

.edit-form {
    padding: 20px;
}

.edit-form.narrow {
    max-width: 520px;
}

label,
.field {
    display: grid;
    gap: 7px;
    color: #374151;
    font-weight: 700;
}

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

input,
textarea {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

input {
    min-height: 40px;
    padding: 9px 11px;
}

textarea {
    min-height: 130px;
    padding: 11px;
    resize: vertical;
}

input:focus,
textarea:focus {
    border-color: var(--primary);
    outline: 0;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

input[readonly],
textarea[readonly] {
    background: #f3f4f6;
    color: var(--muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 8px 13px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    color: #374151;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-primary {
    border-color: var(--primary);
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover {
    border-color: var(--primary-dark);
    background: var(--primary-dark);
    color: #ffffff;
}

.btn-light {
    background: #f9fafb;
}

.btn-small {
    min-height: 31px;
    padding: 6px 10px;
}

.full {
    width: 100%;
}

.form-actions {
    display: flex;
    gap: 10px;
    padding-top: 4px;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 6px;
    font-weight: 700;
}

.alert-error {
    background: #fef3f2;
    color: var(--danger);
    border: 1px solid #fecdca;
}

.alert-success {
    background: #ecfdf3;
    color: var(--success);
    border: 1px solid #abefc6;
}

.editor {
    overflow: hidden;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    background: #ffffff;
}

.editor:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px;
    background: #f9fafb;
    border-bottom: 1px solid #d1d5db;
}

.editor-toolbar button {
    min-height: 32px;
    padding: 5px 9px;
    border: 1px solid #d1d5db;
    border-radius: 5px;
    background: #ffffff;
    color: #374151;
    font: inherit;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.editor-toolbar button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.editor-area {
    min-height: 340px;
    padding: 16px;
    color: var(--text);
    font-weight: 400;
    line-height: 1.65;
    outline: none;
}

.editor-area h1,
.editor-area h2,
.editor-area h3,
.editor-area h4,
.editor-area h5,
.editor-area h6 {
    margin: 16px 0 8px;
    line-height: 1.25;
}

.editor-area p {
    margin: 0 0 12px;
}

.editor-area ul,
.editor-area ol {
    margin: 0 0 12px 22px;
}

.editor-area a {
    color: var(--primary);
    text-decoration: underline;
}

@media (max-width: 900px) {
    .admin-body {
        padding-left: 0;
        padding-top: 196px;
    }

    .sidebar {
        right: 0;
        bottom: auto;
        width: auto;
        min-height: 0;
    }

    .sidebar-brand {
        min-height: 62px;
        padding: 12px 16px;
    }

    .sidebar-nav {
        display: flex;
        overflow-x: auto;
        padding: 8px 12px;
    }

    .sidebar-nav a {
        white-space: nowrap;
    }

    .sidebar-footer {
        display: none;
    }

    .admin-header {
        display: none;
    }

    .page {
        width: min(100% - 20px, 1180px);
        margin-top: 18px;
    }

    .panel-head,
    .form-actions {
        align-items: stretch;
        flex-direction: column;
    }

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