:root {
    --bg: #0b1220;
    --bg-soft: #101b2d;
    --panel: #111f33;
    --panel-strong: #16263f;
    --card: #182b46;
    --card-alt: #1c345a;
    --text: #edf4ff;
    --muted: #a7bbd9;
    --primary: #5aa7ff;
    --primary-strong: #3c82f6;
    --success: #29c17b;
    --warning: #f5b942;
    --danger: #ff6f7d;
    --gray: #6e7f9f;
    --border: rgba(255,255,255,0.08);
    --shadow: 0 18px 40px rgba(0,0,0,0.22);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: linear-gradient(180deg, #08121d 0%, #0f172a 100%);
    color: var(--text);
}

body {
    min-height: 100vh;
}

img {
    max-width: 100%;
}

.container {
    width: min(1200px, calc(100% - 32px));
    margin: 0 auto;
}

.topbar {
    background: rgba(8, 15, 24, 0.85);
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.nav-wrap {
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 78px;
}

.brand-wrap {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), #7c72ff);
    color: #fff;
    border-radius: 12px;
    font-weight: 700;
    box-shadow: var(--shadow);
}

.brand-mark.large {
    width: 58px;
    height: 58px;
    border-radius: 16px;
    margin: 0 auto 12px;
}

.brand-wrap small {
    display: block;
    color: var(--muted);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 18px;
}

.nav-menu a,
.sidebar-nav a,
.sidebar-user a,
.table-actions a,
.link-button,
.button {
    text-decoration: none;
}

.nav-menu a {
    color: var(--muted);
    font-weight: 600;
}

.page-content {
    padding: 42px 0 80px;
}

.hero-panel {
    background: linear-gradient(135deg, rgba(90, 167, 255, 0.1), rgba(124, 114, 255, 0.12));
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 36px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 28px;
}

.hero-panel h1 {
    margin: 10px 0 8px;
    font-size: clamp(2rem, 5vw, 3.2rem);
}

.eyebrow {
    display: inline-block;
    background: rgba(90, 167, 255, 0.12);
    border: 1px solid rgba(90, 167, 255, 0.3);
    color: #b6d7ff;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.hero-panel p {
    color: var(--muted);
    max-width: 620px;
    line-height: 1.6;
    margin: 0;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 22px;
}

.card {
    background: linear-gradient(180deg, rgba(24, 43, 70, 0.94), rgba(17, 31, 51, 0.96));
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.post-card {
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.post-card h2 {
    margin: 0;
    font-size: 1.65rem;
}

.post-card p {
    margin: 0;
    color: var(--muted);
    line-height: 1.6;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    color: var(--muted);
    font-size: 0.85rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: 1px solid transparent;
    padding: 6px 10px;
    font-size: 11px;
    line-height: 1;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.badge.success {
    background: rgba(41, 193, 123, 0.15);
    border-color: rgba(41, 193, 123, 0.25);
    color: #aef0ca;
}

.badge.neutral {
    background: rgba(126, 146, 176, 0.14);
    border-color: rgba(126, 146, 176, 0.24);
    color: #d6e1f6;
}

.link-button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    transition: transform 0.2s ease, opacity 0.2s ease;
    cursor: pointer;
}

.button:hover,
.link-button:hover {
    transform: translateY(-1px);
}

.button.primary,
.link-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: white;
    border-color: rgba(255,255,255,0.1);
}

.button.secondary {
    background: rgba(255,255,255,0.02);
    color: var(--text);
}

.button.danger {
    background: linear-gradient(135deg, #ff6f7d, #d2485d);
    color: white;
    border-color: rgba(255,255,255,0.12);
}

.button.block {
    width: 100%;
}

.button.small {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.site-footer {
    border-top: 1px solid var(--border);
    padding: 18px 0 32px;
    color: var(--muted);
}

.auth-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    padding: 26px;
}

.auth-shell {
    width: min(480px, 100%);
}

.auth-card {
    padding: 28px;
}

.auth-header {
    text-align: center;
    margin-bottom: 22px;
}

.auth-header h1 {
    margin: 0;
    font-size: 2rem;
}

.auth-header p {
    color: var(--muted);
    margin: 8px 0 0;
}

.auth-form,
.stack-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

label {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: var(--muted);
    font-weight: 600;
}

input, textarea, select, button {
    font: inherit;
}

input, textarea, select {
    width: 100%;
    border: 1px solid var(--border);
    background: rgba(8, 15, 24, 0.75);
    color: var(--text);
    border-radius: 12px;
    padding: 12px 14px;
}

textarea {
    resize: vertical;
    min-height: 120px;
}

.demo-box {
    border: 1px dashed rgba(90, 167, 255, 0.4);
    background: rgba(90, 167, 255, 0.05);
    border-radius: 12px;
    padding: 12px 14px;
    color: var(--muted);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-body {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: rgba(8, 15, 24, 0.9);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px 18px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 28px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav a {
    color: var(--muted);
    padding: 12px 14px;
    border-radius: 12px;
    transition: 0.2s ease;
}

.sidebar-nav a.active,
.sidebar-nav a:hover {
    background: rgba(90, 167, 255, 0.08);
    color: var(--text);
}

.sidebar-user {
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-top: 1px solid var(--border);
    padding-top: 18px;
}

.sidebar-user span {
    color: var(--muted);
}

.admin-main {
    flex: 1;
    padding: 32px;
}

.admin-header {
    margin-bottom: 24px;
}

.admin-header h1 {
    margin: 10px 0 0;
    font-size: clamp(2rem, 3vw, 2.5rem);
}

.stats-grid,
.panel-grid {
    display: grid;
    gap: 20px;
    margin-bottom: 24px;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.stat-card {
    padding: 22px 18px;
}

.stat-card span {
    color: var(--muted);
    display: block;
    margin-bottom: 14px;
}

.stat-card strong {
    font-size: clamp(1.5rem, 2vw, 2rem);
}

.panel {
    padding: 20px;
}

.panel-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
}

.panel-head h2 {
    margin: 0;
    font-size: 1.3rem;
}

.panel-head a {
    color: #b9d4ff;
    text-decoration: none;
}

.role-list,
.list-compact {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.role-list li,
.list-compact li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(320px, 1.1fr) minmax(380px, 1.5fr);
    gap: 20px;
}

.form-panel,
.table-panel {
    min-height: 100%;
}

.button-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.editor-block {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(255,255,255,0.02);
}

.editor-toolbar button,
.editor-toolbar select {
    border: 1px solid var(--border);
    background: rgba(8, 15, 24, 0.7);
    color: var(--text);
    border-radius: 10px;
    padding: 8px 10px;
    font-weight: 700;
    cursor: pointer;
}

.editor-surface {
    min-height: 260px;
    padding: 16px 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(8, 15, 24, 0.78);
    color: var(--text);
    line-height: 1.7;
    white-space: normal;
    word-break: break-word;
    direction: ltr;
    text-align: left;
    outline: none;
}

.editor-surface p,
.editor-surface div {
    margin: 0 0 8px;
}

.preview-output {
    direction: ltr;
    text-align: left;
}

.editor-surface:empty::before {
    content: attr(data-placeholder);
    color: var(--muted);
}

.preview-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: rgba(8, 15, 24, 0.48);
    overflow: hidden;
}

.preview-header {
    border-bottom: 1px solid var(--border);
    padding: 10px 14px;
    font-weight: 700;
    color: #dfeeff;
    background: rgba(255,255,255,0.02);
}

.preview-output {
    padding: 16px 14px;
    min-height: 150px;
    line-height: 1.8;
    color: var(--text);
}

.preview-output p,
.preview-output ul,
.preview-output ol,
.preview-output h1,
.preview-output h2,
.preview-output h3 {
    margin-top: 0;
    margin-bottom: 12px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
    text-align: left;
    vertical-align: top;
}

.data-table th {
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.table-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.table-actions a {
    color: #d7ebff;
    font-size: 0.8rem;
}

.inline-form {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.user-edit-form {
    align-items: flex-start;
    flex-direction: column;
    width: 100%;
}

.user-inline-grid {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    width: 100%;
}

.user-inline-grid.compact {
    width: auto;
    min-width: 240px;
}

.user-inline-grid input,
.user-inline-grid select {
    min-width: 160px;
}

.muted-note {
    color: var(--muted);
    font-size: 0.8rem;
}

.checkbox-inline {
    flex-direction: row !important;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
}

.checkbox-inline input {
    width: 16px;
    height: 16px;
}

.db-check-panel {
    margin-top: 20px;
}

.db-check-box {
    padding: 18px 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: rgba(255,255,255,0.02);
}

.db-check-box.ok {
    border-color: rgba(41, 193, 123, 0.3);
    background: rgba(41, 193, 123, 0.08);
}

.db-check-box.error {
    border-color: rgba(255, 111, 125, 0.35);
    background: rgba(255, 111, 125, 0.08);
}

.db-check-box p {
    margin: 10px 0 0;
    color: var(--muted);
    word-break: break-word;
}

.alert {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    border: 1px solid transparent;
    font-weight: 600;
}

.alert-success {
    background: rgba(41, 193, 123, 0.12);
    border-color: rgba(41, 193, 123, 0.3);
    color: #b8f3d3;
}

.alert-danger {
    background: rgba(255, 111, 125, 0.12);
    border-color: rgba(255, 111, 125, 0.3);
    color: #ffc2ca;
}

.light-page .article-shell {
    padding-top: 48px;
    padding-bottom: 64px;
}

.article {
    padding: 28px;
}

.article-header h1 {
    margin: 16px 0 10px;
    font-size: clamp(2.2rem, 4vw, 3.4rem);
}

.article-content {
    color: #ebf3ff;
    line-height: 1.8;
}

.article-content h1,
.article-content h2,
.article-content h3 {
    margin-top: 1.4em;
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 18px 0;
    background: rgba(0,0,0,0.12);
}

.article-content th,
.article-content td {
    border: 1px solid var(--border);
    padding: 12px;
    text-align: left;
    vertical-align: top;
}

.article-content ul,
.article-content ol {
    padding-left: 22px;
}

.notice {
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.1);
    margin: 16px 0;
    background: rgba(255,255,255,0.04);
}

.notice.warning {
    border-color: rgba(245, 185, 66, 0.3);
    background: rgba(245, 185, 66, 0.08);
}

.empty-state {
    padding: 34px 22px;
    margin-top: 32px;
}

@media (max-width: 980px) {
    .admin-body {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: 0;
        border-bottom: 1px solid var(--border);
    }

    .content-grid {
        grid-template-columns: 1fr;
    }

    .hero-panel {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 640px) {
    .nav-wrap {
        flex-direction: column;
        justify-content: center;
        gap: 10px;
        padding: 14px 0;
    }

    .nav-menu {
        flex-wrap: wrap;
        justify-content: center;
    }

    .admin-main {
        padding: 20px;
    }

    .data-table,
    .data-table thead,
    .data-table tbody,
    .data-table th,
    .data-table td,
    .data-table tr {
        display: block;
    }

    .data-table thead {
        display: none;
    }

    .data-table tr {
        border: 1px solid var(--border);
        border-radius: 12px;
        margin-bottom: 12px;
        padding: 10px;
    }

    .data-table td {
        border-bottom: 0;
        padding: 8px 0;
    }
}
