:root {
    --bg: #f4f7fb;
    --sidebar: #0f172a;
    --sidebar-muted: #94a3b8;
    --sidebar-active: rgba(255,255,255,0.08);
    --card: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --danger: #dc2626;
    --warning: #f59e0b;
    --success: #16a34a;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
    --radius: 18px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 92px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    font-family: Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body {
    min-height: 100vh;
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

img {
    max-width: 100%;
    display: block;
}

.app {
    display: flex;
    min-height: 100vh;
    align-items: stretch;
}

/* OVERLAY */
.mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    transition: 0.25s ease;
    z-index: 40;
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
    color: #fff;
    padding: 24px 18px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: width 0.25s ease, transform 0.25s ease, padding 0.25s ease;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 50;
    flex-shrink: 0;
}

.sidebar-header {
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 10px 18px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-icon {
    width: 42px;
    height: 42px;
    min-width: 42px;
    border-radius: 14px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 18px;
    box-shadow: 0 10px 24px rgba(37, 99, 235, 0.35);
}

.brand-text {
    overflow: hidden;
}

.brand-text strong {
    display: block;
    font-size: 24px;
    margin: 0;
    line-height: 1.1;
    white-space: nowrap;
}

.brand-text span {
    display: block;
    margin: 3px 0 0;
    color: var(--sidebar-muted);
    font-size: 13px;
    white-space: nowrap;
}

.sidebar-body {
    display: flex;
    flex-direction: column;
    gap: 18px;
    flex: 1;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.nav-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-section-title {
    color: var(--sidebar-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0 10px;
    margin-top: 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #fff;
    text-decoration: none;
    padding: 12px 14px;
    border-radius: 14px;
    transition: 0.2s ease;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
}

.nav-item:hover,
.nav-item.active {
    background: var(--sidebar-active);
}

.nav-icon {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,0.06);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    color: #cbd5e1;
}

.nav-icon svg {
    width: 18px;
    height: 18px;
}

.nav-item.active .nav-icon {
    background: rgba(37, 99, 235, 0.22);
    color: #93c5fd;
}

.nav-label {
    transition: opacity 0.2s ease, width 0.2s ease;
}

.nav-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 10px 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255,255,255,0.05);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.sidebar-user-avatar,
.topbar-user-avatar {
    width: 34px;
    height: 34px;
    min-width: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, #2563eb, #1e40af);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 14px;
    color: #fff;
}

.sidebar-user-info,
.topbar-user-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sidebar-user-info strong,
.topbar-user-info strong {
    color: #fff;
    font-size: 14px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 120px;
}

.sidebar-user-info span {
    color: var(--sidebar-muted);
    font-size: 11px;
    line-height: 1.1;
}

.logout-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.10);
    background: rgba(255,255,255,0.06);
    color: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

.logout-btn .nav-icon {
    width: auto;
    height: auto;
    min-width: auto;
    background: transparent;
    color: inherit;
}

/* COLLAPSED DESKTOP */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    padding-left: 12px;
    padding-right: 12px;
}

body.sidebar-collapsed .brand {
    padding-left: 6px;
    padding-right: 6px;
}

body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .nav-section-title,
body.sidebar-collapsed .nav-label,
body.sidebar-collapsed .sidebar-user-info,
body.sidebar-collapsed .nav-badge {
    opacity: 0;
    width: 0;
    overflow: hidden;
    display: inline-block;
}

body.sidebar-collapsed .sidebar-footer {
    padding-left: 6px;
    padding-right: 6px;
}

body.sidebar-collapsed .sidebar-user {
    padding: 8px;
    justify-content: center;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding-left: 10px;
    padding-right: 10px;
}

body.sidebar-collapsed .brand {
    justify-content: center;
}

/* CONTENT */
.content {
    flex: 1;
    padding: 24px;
    min-width: 0;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar-left {
    display: flex;
    align-items: flex-start;
    gap: 14px;
}

.topbar-heading h1 {
    margin: 0;
    font-size: 28px;
}

.topbar-heading p {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 14px;
}

.topbar-right,
.topbar-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 8px 12px;
}

.topbar-user-info strong {
    color: var(--text);
    max-width: none;
}

.topbar-user-info span {
    color: var(--muted);
    font-size: 12px;
    line-height: 1.1;
}

.sidebar-toggle {
    width: 44px;
    height: 44px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    color: var(--text);
    flex-shrink: 0;
}

.sidebar-toggle svg {
    width: 18px;
    height: 18px;
}

.page-body {
    min-width: 0;
}

/* BUTTONS */
.btn {
    border: 0;
    border-radius: 14px;
    padding: 12px 18px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 10px 20px rgba(37, 99, 235, 0.18);
}

.btn-secondary,
.btn-light {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.btn-row,
.actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

/* WELCOME */
.welcome-card {
    background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 100%);
    border-radius: 24px;
    padding: 24px;
    color: #fff;
    box-shadow: var(--shadow);
    margin-bottom: 22px;
}

.welcome-card h2,
.welcome-card h3 {
    margin: 0 0 8px;
    font-size: 30px;
}

.welcome-card p {
    margin: 0;
    color: rgba(255,255,255,0.84);
    max-width: 850px;
    line-height: 1.6;
}

.eyebrow {
    display: inline-flex;
    margin-bottom: 12px;
    padding: 7px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.10);
    color: rgba(255,255,255,0.90);
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.welcome-content {
    display: block;
}

/* STATS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 32px;
    font-weight: bold;
    margin: 0 0 10px;
}

.stat-meta {
    color: var(--muted);
    font-size: 14px;
}

.stat-trend-up {
    color: var(--success);
}

.stat-trend-down {
    color: var(--danger);
}

/* PANELS */
.panel,
.card,
.form-card,
.table-card,
.stats-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 20px;
}

.section-header,
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.section-header h3,
.panel-header h3,
.panel-title,
.card-title {
    margin: 0;
    font-size: 22px;
}

.section-header p,
.panel-header p,
.panel-description,
.card-description {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 13px;
}

/* GRID */
.grid {
    display: grid;
    gap: 16px;
}

.grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: bold;
}

.badge-primary {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
}

.badge-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.badge-dark {
    background: #f8fafc;
    color: var(--muted);
    border: 1px solid var(--border);
}

/* FILTER BAR */
.filter-bar {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 20px;
    margin-bottom: 22px;
}

/* FORMS */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-label {
    font-size: 14px;
    font-weight: bold;
    color: var(--text);
}

.input,
.select,
.textarea {
    width: 100%;
    min-height: 46px;
    border: 1px solid var(--border);
    border-radius: 14px;
    background: #fff;
    color: var(--text);
    padding: 0 14px;
    outline: none;
}

.textarea {
    min-height: 120px;
    padding: 12px 14px;
    resize: vertical;
}

/* TABLE */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.table {
    width: 100%;
    min-width: 700px;
    border-collapse: collapse;
}

.table thead th {
    text-align: left;
    padding: 14px 12px;
    font-size: 12px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.table tbody td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    vertical-align: middle;
}

.table tbody tr:last-child td {
    border-bottom: 0;
}

/* ALERTS */
.alert {
    border-radius: 18px;
    padding: 14px 16px;
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: bold;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* EMPTY */
.empty-state {
    border: 2px dashed var(--border);
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    background: #fafcff;
}

.empty-state h3 {
    margin: 0 0 8px;
    font-size: 20px;
    color: var(--text);
}

.empty-state p {
    margin: 0;
    line-height: 1.6;
}

/* SWITCH */
.switch-group {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.switch {
    position: relative;
    width: 52px;
    height: 30px;
    display: inline-block;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: #d1d5db;
    transition: 0.25s ease;
}

.slider::before {
    content: "";
    position: absolute;
    width: 24px;
    height: 24px;
    left: 3px;
    top: 3px;
    border-radius: 999px;
    background: #fff;
    transition: 0.25s ease;
}

.switch input:checked + .slider {
    background: var(--primary);
}

.switch input:checked + .slider::before {
    transform: translateX(22px);
}

/* RESPONSIVE */
@media (max-width: 900px) {
    .mobile-overlay.active,
    body.sidebar-open .mobile-overlay {
        opacity: 1;
        visibility: visible;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        transform: translateX(-100%);
        width: 280px;
        max-width: 82vw;
        overflow-y: auto;
    }

    .sidebar.mobile-open,
    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-collapsed .sidebar {
        width: 280px;
        padding-left: 18px;
        padding-right: 18px;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-section-title,
    body.sidebar-collapsed .nav-label,
    body.sidebar-collapsed .sidebar-user-info,
    body.sidebar-collapsed .nav-badge {
        opacity: 1;
        width: auto;
        overflow: visible;
        display: inline-block;
    }

    body.sidebar-collapsed .nav-item {
        justify-content: flex-start;
        padding-left: 14px;
        padding-right: 14px;
    }

    body.sidebar-collapsed .brand {
        justify-content: flex-start;
    }

    body.sidebar-collapsed .sidebar-user {
        padding: 10px 12px;
        justify-content: space-between;
    }

    .content {
        width: 100%;
        padding: 18px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .topbar-left {
        width: 100%;
    }

    .topbar-right,
    .topbar-actions {
        width: 100%;
    }

    .topbar-actions .btn,
    .topbar-right .btn {
        flex: 1;
        min-width: 180px;
    }

    .stats-grid,
    .grid-2,
    .grid-3,
    .grid-4,
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .content {
        padding: 14px;
    }

    .welcome-card {
        padding: 18px;
    }

    .welcome-card h2,
    .welcome-card h3 {
        font-size: 24px;
    }

    .topbar-heading h1 {
        font-size: 24px;
    }

    .btn-row,
    .actions,
    .topbar-right,
    .topbar-actions {
        width: 100%;
    }

    .btn,
    .topbar-right .btn,
    .topbar-actions .btn {
        width: 100%;
    }
}