:root {
    --bg: #0f1419;
    --bg-card: #1a2332;
    --bg-input: #111827;
    --sidebar: #121a27;
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --accent: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --text: #e5e7eb;
    --text-muted: #94a3b8;
    --border: #2d3a4f;
    --radius: 12px;
    --shadow: 0 10px 40px rgba(0,0,0,.35);
}

.admin-panel {
    --bg: #eef2f7;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --sidebar: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --border: #dbe3ef;
    --shadow: 0 4px 20px rgba(15, 23, 42, 0.08);
    background:
        radial-gradient(circle at 0% 0%, rgba(59, 130, 246, 0.08), transparent 42%),
        radial-gradient(circle at 100% 0%, rgba(16, 185, 129, 0.06), transparent 38%),
        radial-gradient(circle at 50% 100%, rgba(99, 102, 241, 0.05), transparent 45%),
        #eef2f7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: #60a5fa; }

/* Auth pages */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 20%, rgba(59,130,246,.15), transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(16,185,129,.12), transparent 40%),
        var(--bg);
    padding: 24px;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 36px;
    box-shadow: var(--shadow);
}

.setup-card { max-width: 560px; }

.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-brand .brand-icon {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    display: flex; align-items: center; justify-content: center;
    font-size: 28px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 16px;
}
.auth-brand h1 { font-size: 1.5rem; margin-bottom: 6px; }
.auth-brand p { color: var(--text-muted); font-size: .95rem; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex; gap: 12px; align-items: center;
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand .brand-icon {
    width: 42px; height: 42px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 10px; font-size: 20px;
}
.sidebar-brand strong { display: block; font-size: .95rem; }
.sidebar-brand small { color: var(--text-muted); font-size: .75rem; }

.sidebar-nav { flex: 1; padding: 16px 12px; }
.sidebar-nav a {
    display: block;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    margin-bottom: 4px;
    transition: .2s;
}
.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(59,130,246,.12);
    color: var(--primary-dark);
}

.admin-panel .sidebar {
    box-shadow: 2px 0 20px rgba(15, 23, 42, 0.06);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.admin-panel .sidebar-brand {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.06), rgba(16, 185, 129, 0.04));
}

.admin-panel .sidebar-brand .brand-icon {
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.admin-panel .sidebar-nav a:hover,
.admin-panel .sidebar-nav a.active {
    background: linear-gradient(90deg, rgba(59, 130, 246, 0.14), rgba(59, 130, 246, 0.06));
    color: #1d4ed8;
    font-weight: 600;
    box-shadow: inset 3px 0 0 #2563eb;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}
.admin-mini { margin-bottom: 12px; }
.admin-mini strong { display: block; font-size: .9rem; }
.admin-mini span { color: var(--text-muted); font-size: .8rem; }

.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.topbar {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    background: rgba(26,35,50,.6);
    backdrop-filter: blur(8px);
    position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 1.4rem; font-weight: 600; }
.admin-panel .topbar {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.96), rgba(239, 246, 255, 0.92));
    border-bottom: 1px solid #bfdbfe;
    box-shadow: 0 2px 12px rgba(37, 99, 235, 0.06);
}
.admin-panel .topbar h1 {
    color: #0f172a;
    background: linear-gradient(90deg, #1e40af, #2563eb);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.content-area { padding: 28px 32px 48px; }

/* Cards & stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.admin-panel .stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
}
.admin-panel .stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.admin-panel .stat-card.primary {
    background: linear-gradient(145deg, #eff6ff 0%, #dbeafe 100%);
    border-color: #93c5fd;
}
.admin-panel .stat-card.primary::before { background: linear-gradient(90deg, #3b82f6, #2563eb); }
.admin-panel .stat-card.success {
    background: linear-gradient(145deg, #ecfdf5 0%, #d1fae5 100%);
    border-color: #6ee7b7;
}
.admin-panel .stat-card.success::before { background: linear-gradient(90deg, #10b981, #059669); }
.admin-panel .stat-card.warning {
    background: linear-gradient(145deg, #fffbeb 0%, #fef3c7 100%);
    border-color: #fcd34d;
}
.admin-panel .stat-card.warning::before { background: linear-gradient(90deg, #f59e0b, #d97706); }
.stat-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
.stat-icon {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    border-radius: 12px;
    flex-shrink: 0;
}
.admin-panel .stat-card.primary .stat-icon {
    background: rgba(37, 99, 235, 0.15);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.15);
}
.admin-panel .stat-card.success .stat-icon {
    background: rgba(16, 185, 129, 0.15);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}
.admin-panel .stat-card.warning .stat-icon {
    background: rgba(245, 158, 11, 0.15);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15);
}
.stat-card .label { color: var(--text-muted); font-size: .85rem; font-weight: 600; }
.stat-card .value { font-size: 2rem; font-weight: 700; color: #fff; line-height: 1.1; }
.admin-panel .stat-card .value { color: #0f172a; }
.stat-card.primary .value { color: var(--primary); }
.stat-card.success .value { color: var(--accent); }
.stat-card.warning .value { color: var(--warning); }
.admin-panel .stat-card.primary .value { color: #1d4ed8; }
.admin-panel .stat-card.success .value { color: #047857; }
.admin-panel .stat-card.warning .value { color: #b45309; }

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}
.admin-panel .card {
    border-color: #dbeafe;
    box-shadow: 0 4px 24px rgba(37, 99, 235, 0.06);
}
.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}
.admin-panel .card-title {
    color: #0f172a;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom-color: #dbeafe;
}
.admin-panel .card-title::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(180deg, #3b82f6, #2563eb);
    border-radius: 4px;
    flex-shrink: 0;
}

/* Forms */
.form-grid { display: grid; gap: 16px; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { font-size: .875rem; color: var(--text-muted); font-weight: 500; }
.form-row input, .form-row select, .form-row textarea {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    color: var(--text);
    font: inherit;
    transition: border-color .2s;
}
.form-row input:focus, .form-row select:focus, .form-row textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59,130,246,.2);
}
.form-row textarea { min-height: 100px; resize: vertical; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.section-title {
    font-size: 1rem;
    color: #fff;
    margin-top: 8px;
    grid-column: 1 / -1;
}
.admin-panel .section-title { color: #0f172a; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    border: none;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: .2s;
    text-decoration: none;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-success { background: var(--accent); color: #fff; }
.btn-success:hover { background: #059669; color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; color: #fff; }
.btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-ghost:hover { background: rgba(255,255,255,.05); color: #fff; }
.admin-panel .btn-ghost:hover { background: rgba(59,130,246,.08); color: var(--primary-dark); }
.btn-sm { padding: 7px 12px; font-size: .85rem; }
.btn-block { width: 100%; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; }

/* Table */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}
table.data-table th, table.data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
table.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}
table.data-table tr:hover td { background: rgba(255,255,255,.02); }
.admin-panel table.data-table th {
    background: linear-gradient(180deg, #eff6ff, #dbeafe);
    color: #1e40af;
    border-bottom: 2px solid #93c5fd;
}
.admin-panel table.data-table tbody tr:nth-child(even) td {
    background: rgba(239, 246, 255, 0.45);
}
.admin-panel table.data-table tr:hover td {
    background: rgba(59, 130, 246, 0.08);
}
.admin-panel .btn-ghost {
    border-color: #bfdbfe;
    color: #2563eb;
    background: #fff;
}
.admin-panel .btn-ghost:hover {
    background: linear-gradient(180deg, #eff6ff, #dbeafe);
    border-color: #93c5fd;
    color: #1d4ed8;
}
.admin-panel .badge {
    background: linear-gradient(135deg, #eff6ff, #dbeafe);
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}
table.data-table img.thumb {
    width: 48px; height: 48px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: .925rem;
}
.alert-success { background: rgba(16,185,129,.15); border: 1px solid rgba(16,185,129,.4); color: #6ee7b7; }
.alert-danger { background: rgba(239,68,68,.15); border: 1px solid rgba(239,68,68,.4); color: #fca5a5; }
.alert-warning { background: rgba(245,158,11,.15); border: 1px solid rgba(245,158,11,.4); color: #fcd34d; }
.admin-panel .alert-success { background: #ecfdf5; border-color: #a7f3d0; color: #047857; }
.admin-panel .alert-danger { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.admin-panel .alert-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }

/* Search bar */
.search-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.search-bar input[type="search"], .search-bar input[type="text"], .search-bar input[type="date"], .search-bar select {
    flex: 1;
    min-width: 180px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 11px 14px;
    color: var(--text);
    font: inherit;
}

/* Sub sections */
.sub-block {
    background: rgba(0,0,0,.2);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}
.admin-panel .sub-block {
    background: #f8fafc;
}
.sub-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: .75rem;
    font-weight: 600;
    background: rgba(59,130,246,.2);
    color: #93c5fd;
}
.admin-panel .badge {
    background: #eff6ff;
    color: #1d4ed8;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}
.detail-item label { display: block; color: var(--text-muted); font-size: .8rem; margin-bottom: 4px; }
.detail-item span, .detail-item p { font-weight: 500; }

.profile-photo {
    width: 120px; height: 120px;
    object-fit: cover;
    border-radius: 14px;
    border: 2px solid var(--border);
}

.setup-success { text-align: center; }
.setup-success p { margin-bottom: 20px; color: var(--text-muted); }

.auth-credits {
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    text-align: center;
}
.auth-credits p {
    font-size: .82rem;
    color: var(--text-muted);
    line-height: 1.6;
    margin: 0 0 6px;
}
.auth-credits p:last-child { margin-bottom: 0; }
.auth-credits strong { color: #cbd5e1; font-weight: 600; }

.filter-active-badge {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.filter-panel .filter-fields {
    display: none;
}

.filter-panel .card-title {
    margin-bottom: 12px;
}

.table-wrap.table-wrap-visible { overflow: visible; }

.edit-inline-block {
    display: block;
    margin-bottom: 12px;
}

.edit-inline-block summary {
    cursor: pointer;
    color: var(--primary);
    font-weight: 600;
    font-size: .9rem;
    list-style: none;
    padding: 8px 0;
}

.edit-inline-block summary::-webkit-details-marker {
    display: none;
}

.edit-inline-block[open] summary {
    margin-bottom: 12px;
}

.edit-form-box {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.edit-expand-row td {
    background: rgba(0, 0, 0, 0.12);
    padding: 12px 14px 16px;
    vertical-align: top;
}
.admin-panel .edit-form-box { background: #f8fafc; }
.admin-panel .edit-expand-row td { background: #f1f5f9; }

.edit-expand-row td .edit-inline-block {
    margin-bottom: 0;
}

.edit-form-box .form-row input,
.edit-form-box .form-row select,
.edit-form-box .form-row textarea {
    width: 100%;
}

.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.checkbox-col { width: 40px; text-align: center; }

.inline-delete-form {
    display: inline;
}


.favicon-settings {
    display: grid;
    grid-template-columns: 180px 1fr;
    gap: 28px;
    align-items: start;
}

.favicon-preview-wrap {
    text-align: center;
}

.favicon-preview-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.favicon-preview {
    width: 88px;
    height: 88px;
    margin: 0 auto 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    border: 1px solid #bfdbfe;
    border-radius: 16px;
    box-shadow: inset 0 2px 6px rgba(15, 23, 42, 0.04);
}

.favicon-preview img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}

.favicon-preview-note {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.favicon-upload-wrap .form-row input[type="file"] {
    background: var(--bg-input);
    border: 1px dashed var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    width: 100%;
}

.hidden-form { display: none; }

@media (max-width: 700px) {
    .favicon-settings {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .sidebar { width: 100%; position: relative; height: auto; }
    .main-content { margin-left: 0; }
    .app-shell { flex-direction: column; }
    .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
    .content-area { padding: 20px 16px; }
}

@media print {
    .sidebar, .topbar, .toolbar, .btn, .search-bar, .no-print { display: none !important; }
    .main-content { margin: 0; }
    body { background: #fff; color: #000; }
    .card { border: 1px solid #ccc; break-inside: avoid; }
}
