:root {
    --navy-950: #0a1929;
    --navy-900: #0f2440;
    --blue-600: #2563eb;
    --blue-500: #3b82f6;
    --amber-500: #f59e0b;
    --red-600: #dc2626;
    --green-700: #047857;
    --slate-900: #111827;
    --slate-700: #374151;
    --slate-500: #6b7280;
    --slate-200: #e5e7eb;
    --slate-100: #f3f4f6;
    --slate-50: #f9fafb;
    --white: #ffffff;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: var(--slate-900);
    background: var(--slate-50);
}

a { color: var(--blue-600); text-decoration: none; }

.admin-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--navy-950);
    color: rgba(255,255,255,0.8);
    display: flex;
    flex-direction: column;
    padding: 24px 0;
}
.sidebar-brand {
    padding: 0 20px 20px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--white);
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 12px;
}
.sidebar-brand strong { color: var(--blue-500); }
.sidebar-brand span { display: block; font-size: 0.72rem; font-weight: 500; color: rgba(255,255,255,0.45); margin-top: 2px; }
.view-site-link {
    margin: 4px 20px 12px;
    padding: 8px 12px;
    border-radius: 8px;
    background: rgba(59, 130, 246, 0.12);
    color: var(--blue-500);
    font-size: 0.82rem;
    font-weight: 600;
    text-align: center;
}
.view-site-link:hover { background: rgba(59, 130, 246, 0.22); }
.sidebar-nav { display: flex; flex-direction: column; flex: 1; }
.sidebar-nav a {
    padding: 10px 20px;
    color: rgba(255,255,255,0.75);
    font-size: 0.9rem;
    font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.06); color: var(--white); }
.nav-section {
    padding: 18px 20px 6px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.35);
}
.logout-form { padding: 12px 20px; }
.logout-btn {
    width: 100%;
    padding: 9px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
    color: var(--white);
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
}
.logout-btn:hover { background: rgba(255,255,255,0.15); }

.content { padding: 32px 40px; }
.content-header h1 { font-size: 1.4rem; margin: 0 0 20px; }

.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 20px; font-size: 0.9rem; }
.alert-success { background: #ecfdf5; color: var(--green-700); border: 1px solid #a7f3d0; }
.alert-error { background: #fef2f2; color: var(--red-600); border: 1px solid #fecaca; }

/* Stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 32px; }
.stat-card {
    background: var(--white);
    border: 1px solid var(--slate-200);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.stat-card-alert { border-color: var(--amber-500); background: #fffbeb; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--navy-950); }
.stat-label { font-size: 0.82rem; color: var(--slate-500); }

/* Panels */
.panel { background: var(--white); border: 1px solid var(--slate-200); border-radius: 12px; padding: 24px; }
.panel-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 10px; }
.panel-header h2 { font-size: 1.05rem; margin: 0; }
.link { font-size: 0.85rem; font-weight: 600; }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--slate-100);
    color: var(--slate-500);
    font-weight: 600;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.data-table td { padding: 12px; border-bottom: 1px solid var(--slate-100); vertical-align: middle; }
.data-table .truncate { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-cell { font-size: 1.2rem; }
.reorder-cell { display: flex; gap: 4px; }
.reorder-cell form { display: inline; }
.row-actions { display: flex; gap: 12px; align-items: center; white-space: nowrap; }
.row-actions form { display: inline; }

.link-btn {
    background: none;
    border: none;
    color: var(--blue-600);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }
.link-btn-danger { color: var(--red-600); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; }
.badge-success { background: #ecfdf5; color: var(--green-700); }
.badge-warning { background: #fffbeb; color: #b45309; }

.empty-state { color: var(--slate-500); font-size: 0.9rem; padding: 24px 0; }

/* Forms */
.admin-form, .login-card form { max-width: 560px; }
.form-row { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: 0.85rem; font-weight: 600; color: var(--slate-700); }
.form-row input[type="text"],
.form-row input[type="password"],
.form-row input[type="email"],
.form-row input:not([type]),
.form-row textarea {
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
}
.form-row-checkbox { flex-direction: row; align-items: center; }
.form-row-checkbox label { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.field-error { color: var(--red-600); font-size: 0.8rem; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 22px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: var(--blue-600); color: var(--white); }
.btn-primary:hover { background: var(--blue-500); }
.btn-ghost { background: transparent; color: var(--slate-700); border-color: var(--slate-200); }
.btn-ghost:hover { background: var(--slate-100); }
.btn-sm { padding: 8px 16px; font-size: 0.82rem; }
.btn-block { width: 100%; }

/* Login */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--navy-950), var(--navy-900));
    padding: 20px;
}
.login-card {
    background: var(--white);
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 380px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.login-brand { font-weight: 700; font-size: 1.2rem; margin-bottom: 24px; color: var(--navy-950); }
.login-brand strong { color: var(--blue-600); }
.login-brand span { display: block; font-size: 0.75rem; font-weight: 500; color: var(--slate-500); margin-top: 2px; }

/* Profile */
.profile-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; align-items: start; }
.current-value { font-size: 0.9rem; color: var(--slate-500); margin-bottom: 16px; }
.current-value strong { color: var(--slate-900); }
@media (max-width: 900px) {
    .profile-grid { grid-template-columns: 1fr; }
}

/* DataTables overrides */
.dataTables_wrapper { font-size: 0.9rem; }
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    padding: 7px 10px;
    border-radius: 8px;
    border: 1px solid var(--slate-200);
    font-family: inherit;
    margin-left: 6px;
}
.dataTables_wrapper .dataTables_filter { margin-bottom: 12px; }
.dataTables_wrapper .dataTables_info { color: var(--slate-500); padding-top: 12px; }
.dataTables_wrapper .dataTables_paginate {
    padding-top: 12px;
    display: flex;
    gap: 4px;
    justify-content: flex-end;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    padding: 6px 12px;
    border-radius: 6px;
    border: 1px solid var(--slate-200);
    cursor: pointer;
    color: var(--slate-700) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current {
    background: var(--blue-600) !important;
    color: var(--white) !important;
    border-color: var(--blue-600);
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled {
    color: var(--slate-200) !important;
    cursor: not-allowed;
}
table.dataTable thead th { position: relative; }

/* Screenshot admin grid */
.screenshot-admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 20px; }
.screenshot-admin-card { border: 1px solid var(--slate-200); border-radius: 12px; overflow: hidden; background: var(--white); }
.screenshot-admin-card img { width: 100%; aspect-ratio: 16/10; object-fit: contain; object-position: top; background: var(--slate-100); }
.screenshot-admin-body { padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; }

/* Mobile top bar + off-canvas sidebar */
.panel-topbar {
    display: none;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--navy-950);
    position: sticky;
    top: 0;
    z-index: 1001;
}
.panel-nav-toggle {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}
.panel-nav-toggle span { display: block; width: 22px; height: 2px; background: var(--white); border-radius: 1px; }
.panel-topbar-brand { color: var(--white); font-weight: 700; font-size: 1rem; }
.panel-topbar-brand strong { color: var(--blue-500); }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
}
.sidebar-backdrop.open { display: block; }

@media (max-width: 900px) {
    .panel-topbar { display: flex; }
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        width: 260px;
        max-width: 80vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
        overflow-y: auto;
    }
    .sidebar.open { transform: translateX(0); }
    .content { padding: 20px 16px; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .data-table { display: block; overflow-x: auto; white-space: nowrap; }
    .row-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-value { font-size: 1.4rem; }
    .content-header h1 { font-size: 1.2rem; }
}
