:root {
    --refy-emerald: #10B981;
    --refy-emerald-dark: #047857;
    --refy-emerald-light: #34D399;
    --refy-amber: #F59E0B;
    --refy-blue: #3B82F6;
    --refy-purple: #8B5CF6;
    --bg-dark: #090D16;
    --sidebar-bg: #0F172A;
    --surface-dark: #111827;
    --surface-elevated: #1E293B;
    --surface-border: #334155;
    --text-primary: #F8FAFC;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --error-red: #EF4444;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
}

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

/* Sidebar */
.admin-sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--surface-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.sidebar-brand {
    padding: 20px;
    border-bottom: 1px solid var(--surface-border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-emblem {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--refy-emerald), #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
}

.sidebar-nav {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-section-label {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 10px 12px 6px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: rgba(16, 185, 129, 0.16);
    color: var(--refy-emerald-light);
    border: 1px solid rgba(16, 185, 129, 0.35);
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--surface-border);
}

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

.admin-topbar {
    background: rgba(17, 24, 39, 0.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--surface-border);
    padding: 14px 28px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.admin-content {
    padding: 28px;
    max-width: 1440px;
    width: 100%;
    margin: 0 auto;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--surface-dark);
    border: 1px solid var(--surface-border);
    border-radius: 16px;
    padding: 18px 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 900;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.kpi-sub {
    font-size: 0.76rem;
    color: var(--text-muted);
}

/* Panels & Tables */
.admin-panel {
    background: var(--surface-dark);
    border: 1px solid var(--surface-border);
    border-radius: 18px;
    padding: 20px;
    margin-bottom: 22px;
}

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

.panel-title {
    font-size: 1.08rem;
    font-weight: 800;
}

.toolbar-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 18px;
}

.filter-tabs {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.filter-tab {
    padding: 7px 14px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--surface-elevated);
    border: 1px solid var(--surface-border);
    color: var(--text-secondary);
    cursor: pointer;
}

.filter-tab.active {
    background: rgba(16, 185, 129, 0.16);
    border-color: var(--refy-emerald);
    color: var(--refy-emerald-light);
    font-weight: 700;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.86rem;
}

.admin-table th {
    padding: 12px 14px;
    font-size: 0.74rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--surface-border);
    background: rgba(30, 41, 59, 0.45);
    white-space: nowrap;
}

.admin-table td {
    padding: 13px 14px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    vertical-align: middle;
}

.admin-table tr:hover td {
    background: rgba(30, 41, 59, 0.35);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.badge-emerald {
    background: rgba(16, 185, 129, 0.16);
    color: #34D399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-amber {
    background: rgba(245, 158, 11, 0.18);
    color: #FBBF24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-red {
    background: rgba(239, 68, 68, 0.18);
    color: #F87171;
    border: 1px solid rgba(239, 68, 68, 0.4);
}

.badge-blue {
    background: rgba(59, 130, 246, 0.18);
    color: #60A5FA;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.badge-slate {
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border: 1px solid var(--surface-border);
}

/* Buttons */
.btn-sm {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 6px 11px;
    border-radius: 8px;
    font-size: 0.76rem;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--refy-emerald);
    color: #fff;
}

.btn-primary:hover {
    background: var(--refy-emerald-dark);
}

.btn-amber {
    background: var(--refy-amber);
    color: #000;
}

.btn-ghost {
    background: var(--surface-elevated);
    border-color: var(--surface-border);
    color: var(--text-primary);
}

.btn-ghost:hover {
    border-color: var(--refy-emerald);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.4);
    color: #F87171;
}

.btn-danger:hover {
    background: var(--error-red);
    color: #fff;
}

/* Forms & Modals */
.admin-input, .admin-select, .admin-textarea {
    background: var(--surface-elevated);
    border: 1px solid var(--surface-border);
    color: var(--text-primary);
    padding: 9px 12px;
    border-radius: 10px;
    font-size: 0.86rem;
    outline: none;
    width: 100%;
}

.admin-input:focus, .admin-select:focus, .admin-textarea:focus {
    border-color: var(--refy-emerald);
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

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

.form-group label {
    display: block;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    z-index: 100;
}

.modal-backdrop.open {
    display: flex;
}

.modal-box {
    background: var(--surface-dark);
    border: 1px solid var(--surface-border);
    border-radius: 20px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
}

/* Brand Logo helper inside admin */
.brand-logo-box {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: #fff;
    border: 1.5px solid rgba(16, 185, 129, 0.4);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}

.brand-logo-box img {
    width: 72%;
    height: 72%;
    object-fit: contain;
}

.brand-logo-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 900;
}

@media (max-width: 960px) {
    .admin-shell {
        flex-direction: column;
    }
    .admin-sidebar {
        width: 100%;
        height: auto;
        position: static;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
    }
    .form-grid-2 {
        grid-template-columns: 1fr;
    }
}
