:root {
    --sidebar-w: 260px;
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-muted: #64748b;
    --primary: #0f766e;
    --primary-hover: #0d9488;
    --primary-soft: #ecfdf5;
    --primary-ring: rgba(15, 118, 110, 0.15);
    --danger: #dc2626;
    --danger-soft: #fef2f2;
    --warning: #d97706;
    --warning-soft: #fffbeb;
    --success: #059669;
    --success-soft: #ecfdf5;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
    --radius: 14px;
    --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    font-family: "Inter", "Segoe UI", system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

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

/* Shell */
.admin-shell {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
    color: #e2e8f0;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    border-right: 1px solid rgba(255,255,255,0.06);
}

.admin-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.admin-brand__logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.admin-brand__mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(135deg, #14b8a6, #0f766e);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    color: #fff;
    font-size: 18px;
    box-shadow: 0 8px 20px rgba(20, 184, 166, 0.35);
}

.admin-brand__text strong {
    display: block;
    font-size: 15px;
    color: #fff;
    letter-spacing: -0.02em;
}

.admin-brand__text span {
    display: block;
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}

.admin-nav {
    padding: 16px 12px;
    flex: 1;
    overflow-y: auto;
}

.admin-nav__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #64748b;
    padding: 8px 12px 6px;
}

.admin-nav__link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 12px;
    margin-bottom: 4px;
    border-radius: 10px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background .15s, color .15s;
}

.admin-nav__link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
    text-decoration: none;
}

.admin-nav__link.is-active {
    background: rgba(20, 184, 166, 0.16);
    color: #5eead4;
    box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.18);
}

.admin-nav__icon {
    width: 18px;
    text-align: center;
    opacity: 0.9;
    font-size: 15px;
}

.admin-sidebar__footer {
    padding: 16px 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.admin-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.admin-topbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.admin-topbar__title {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.admin-topbar__subtitle {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--text-muted);
}

.admin-topbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.admin-content {
    padding: 24px 28px 40px;
    flex: 1;
}

/* Components */
.page-header {
    margin-bottom: 22px;
}

.page-header h2 {
    margin: 0 0 6px;
    font-size: 24px;
    letter-spacing: -0.03em;
}

.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.card__title {
    margin: 0 0 6px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.card__desc {
    margin: 0 0 18px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.6;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 22px;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: linear-gradient(180deg, #14b8a6, #0f766e);
    border-radius: 4px 0 0 4px;
}

.stat-card:nth-child(2)::before { background: linear-gradient(180deg, #6366f1, #4f46e5); }
.stat-card:nth-child(3)::before { background: linear-gradient(180deg, #f59e0b, #d97706); }

.stat-card__label {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-card__value {
    margin: 0;
    font-size: 30px;
    font-weight: 800;
    letter-spacing: -0.04em;
    line-height: 1.1;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
    font-family: inherit;
}

.btn:hover {
    background: var(--surface-2);
    text-decoration: none;
    color: var(--text);
}

.btn-primary {
    background: linear-gradient(135deg, #0f766e, #0d9488);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 8px 20px rgba(15, 118, 110, 0.22);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0d9488, #14b8a6);
    color: #fff;
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    border-color: var(--border);
}

.btn-sm { padding: 8px 12px; font-size: 13px; }

.btn-secondary {
    background: var(--surface);
    border-color: var(--border-strong);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-2);
    color: var(--text);
}

.btn-primary.is-copied {
    background: linear-gradient(135deg, #059669, #10b981);
}

form.inline { display: inline; }

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    line-height: 1.5;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-soft);
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-error {
    background: var(--danger-soft);
    color: #991b1b;
    border-color: #fecaca;
}

.alert-warning {
    background: var(--warning-soft);
    color: #92400e;
    border-color: #fde68a;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data-table thead {
    background: var(--surface-2);
}

table.data-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

table.data-table td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

table.data-table tbody tr:hover {
    background: #fafbfd;
}

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

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--success-soft); color: #047857; }
.badge-warning { background: var(--warning-soft); color: #b45309; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
.badge-neutral { background: #f1f5f9; color: #475569; }

.form-control,
input[type=text],
input[type=email],
input[type=password],
input[type=url],
input[type=number],
select,
textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #fff;
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-ring);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
}

.form-hint {
    margin: 6px 0 0;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.form-group { margin-bottom: 16px; }

.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.search-bar input { flex: 1; min-width: 220px; margin-bottom: 0; }

.settings-section {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.settings-section:last-of-type {
    border-bottom: 0;
    margin-bottom: 0;
    padding-bottom: 0;
}

.settings-section__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.settings-section__icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary-soft);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.settings-section h3 {
    margin: 0;
    font-size: 16px;
}

.settings-section p.settings-hint {
    margin: 0 0 16px;
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.6;
}

.settings-field { margin-bottom: 16px; max-width: 560px; }

.settings-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 999px;
    margin-left: 8px;
    font-weight: 700;
}

.settings-badge--ok { background: var(--success-soft); color: #047857; }
.settings-badge--warn { background: var(--warning-soft); color: #b45309; }

.code-block {
    background: #0f172a;
    color: #e2e8f0;
    padding: 16px 18px;
    border-radius: var(--radius-sm);
    overflow: auto;
    font-size: 13px;
    line-height: 1.6;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.docs-list {
    margin: 0;
    padding-left: 20px;
    line-height: 1.85;
    font-size: 14px;
    color: var(--text);
}

.empty-state {
    text-align: center;
    padding: 28px 16px;
    color: var(--text-muted);
    font-size: 14px;
}

.pagination-wrap {
    margin-top: 18px;
}

.pagination-wrap nav { display: flex; gap: 6px; flex-wrap: wrap; }
.pagination-wrap a,
.pagination-wrap span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--text);
    font-size: 13px;
    text-decoration: none;
}

.pagination-wrap span[aria-current="page"] {
    background: var(--primary-soft);
    border-color: #99f6e4;
    color: var(--primary);
    font-weight: 700;
}

/* Login */
.login-page {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
}

.login-hero {
    background: linear-gradient(145deg, #0f172a 0%, #134e4a 55%, #0f766e 100%);
    color: #fff;
    padding: 48px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-hero::after {
    content: "";
    position: absolute;
    width: 420px;
    height: 420px;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
    top: -120px;
    right: -80px;
}

.login-hero__brand {
    position: relative;
    z-index: 1;
}

.login-hero__brand strong {
    display: block;
    font-size: 28px;
    letter-spacing: -0.04em;
    margin-bottom: 12px;
}

.login-hero__brand p {
    max-width: 420px;
    line-height: 1.7;
    color: rgba(255,255,255,0.82);
    font-size: 15px;
}

.login-hero__features {
    position: relative;
    z-index: 1;
    margin-top: 36px;
    display: grid;
    gap: 12px;
}

.login-feature {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.08);
    font-size: 14px;
}

.login-panel {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    background: var(--bg);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 32px;
    box-shadow: var(--shadow);
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 26px;
    letter-spacing: -0.03em;
}

.login-card .subtitle {
    margin: 0 0 24px;
    color: var(--text-muted);
    font-size: 14px;
}

.login-card .btn-primary {
    width: 100%;
    margin-top: 8px;
    padding: 12px 16px;
}

@media (max-width: 960px) {
    .admin-shell { flex-direction: column; }
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .admin-nav { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 8px; }
    .admin-nav__label { display: none; }
    .admin-nav__link { margin: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .login-page { grid-template-columns: 1fr; }
    .login-hero { padding: 32px 24px; }
    .admin-content, .admin-topbar { padding-left: 16px; padding-right: 16px; }
}

/* Snippet copy card */
.snippet-card {
    background: linear-gradient(135deg, #ecfdf5 0%, #fff 48%);
    border: 1px solid #99f6e4;
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.snippet-card__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.snippet-card__title {
    margin: 0 0 8px;
    font-size: 1.15rem;
    color: var(--text);
}

.snippet-card__desc {
    margin: 0;
    font-size: 14px;
    color: var(--text-muted);
    max-width: 640px;
    line-height: 1.55;
}

.snippet-card__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.snippet-steps {
    margin: 0 0 16px;
    padding-left: 20px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.7;
}

.snippet-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.snippet-meta code {
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 12px;
}

.snippet-source {
    position: absolute;
    left: -9999px;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.snippet-preview {
    margin-top: 8px;
}

.snippet-preview summary {
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    user-select: none;
}

.snippet-preview__code {
    max-height: 280px;
    overflow: auto;
    margin-top: 12px;
}

.snippet-theme-row {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px dashed #99f6e4;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.snippet-theme-row__label {
    margin: 0;
    font-size: 13px;
    color: var(--text-muted);
}

.snippet-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    max-width: 360px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    background: #0f172a;
    color: #f8fafc;
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
    transform: translateY(12px);
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
}

.snippet-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}
