:root {
    --bg: #f4f7fb;
    --panel: #ffffff;
    --panel-alt: #eef3ff;
    --surface: #f8faff;
    --sidebar: #0f172a;
    --sidebar-soft: #1f2937;
    --sidebar-text: #dbeafe;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #3b82f6;
    --primary-strong: #1d4ed8;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    --radius: 18px;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    font-family: "Inter", sans-serif;
    background: var(--bg);
    color: var(--text);
}

button, input, select, textarea {
    font: inherit;
}

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: linear-gradient(180deg, var(--sidebar) 0%, #111827 100%);
    color: var(--sidebar-text);
    padding: 28px 18px;
    border-right: 1px solid rgba(255, 255, 255, 0.06);
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 8px 12px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    margin-bottom: 18px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    font-weight: 800;
}

.brand strong {
    display: block;
    font-size: 1rem;
}

.brand small {
    color: rgba(219, 234, 254, 0.7);
}

.nav-group {
    margin-bottom: 18px;
}

.nav-label {
    margin: 0 12px 10px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.7rem;
    color: rgba(191, 219, 254, 0.7);
}

.nav-link {
    display: block;
    text-decoration: none;
    color: var(--sidebar-text);
    padding: 10px 12px;
    border-radius: 10px;
    margin: 2px 0;
    transition: 150ms ease;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(59, 130, 246, 0.12);
    color: white;
}

.main-panel {
    flex: 1;
    min-width: 0;
    padding: 26px 28px 34px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 8px 0 28px;
}

.eyebrow {
    margin: 0 0 8px;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

h1 {
    margin: 0;
    font-size: clamp(1.8rem, 2vw, 2.5rem);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.primary-button,
.ghost-button {
    border: 0;
    border-radius: 12px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
}

.primary-button {
    background: linear-gradient(135deg, var(--primary), var(--primary-strong));
    color: white;
    box-shadow: var(--shadow);
}

.ghost-button {
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
}

.page-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
}

.stat-card,
.panel {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 20px 18px;
}

.stat-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--muted);
    font-size: 0.82rem;
}

.stat-card h2 {
    margin: 18px 0 0;
    font-size: clamp(1.8rem, 2vw, 2.4rem);
}

.trend {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 5px 8px;
    border-radius: 999px;
}

.trend.up {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.panel-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 20px;
}

.panel {
    padding: 20px;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

.badge {
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.75rem;
    font-weight: 700;
}

.badge.neutral {
    background: var(--panel-alt);
    color: var(--text);
}

.badge.success {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.chart-box {
    height: 230px;
    display: flex;
    align-items: end;
}

.chart-bars {
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    height: 100%;
    align-items: end;
}

.chart-bars span {
    display: block;
    background: linear-gradient(180deg, var(--primary) 0%, #93c5fd 100%);
    border-radius: 999px 999px 0 0;
    min-height: 20%;
}

.list-stack {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 12px;
}

.list-stack li {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    color: var(--muted);
}

.list-stack li strong {
    color: var(--text);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    text-align: left;
    padding: 14px 12px;
    border-bottom: 1px solid var(--border);
}

th {
    color: var(--muted);
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.status {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 5px 9px;
    font-size: 0.72rem;
    font-weight: 700;
}

.status.ok {
    background: rgba(16, 185, 129, 0.12);
    color: var(--success);
}

.status.warning {
    background: rgba(245, 158, 11, 0.12);
    color: var(--warning);
}

.status.info {
    background: rgba(59, 130, 246, 0.12);
    color: var(--primary-strong);
}

.auth-page-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #eff6ff 0%, #f8fafc 100%);
}

.auth-shell {
    width: min(100%, 460px);
    padding: 24px;
}

.auth-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 26px;
    box-shadow: var(--shadow);
    padding: 30px 28px;
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-brand-mark {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-weight: 800;
    color: white;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
}

.auth-brand strong {
    display: block;
    font-size: 1.1rem;
}

.auth-brand small {
    color: var(--muted);
}

.auth-header h2 {
    margin: 0 0 8px;
    font-size: 2rem;
}

.auth-header p {
    margin: 0 0 20px;
    color: var(--muted);
}

.auth-form {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field label {
    font-size: 0.88rem;
    color: var(--muted);
    font-weight: 600;
}

.field input {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: #f8fafc;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: 2px solid rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.field-full {
    grid-column: 1 / -1;
}

.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    color: var(--text);
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 18px;
}

.clients-shell {
    display: grid;
    gap: 20px;
}

.inline-search {
    display: flex;
    gap: 8px;
    align-items: center;
}

.inline-search input {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
    background: #f8fafc;
}

.row-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-link,
.link-button {
    font-weight: 600;
    text-decoration: none;
    color: var(--primary-strong);
    background: transparent;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.link-button.danger {
    color: var(--danger);
}

.alert {
    padding: 12px 14px;
    border-radius: 12px;
    margin-bottom: 18px;
    font-size: 0.92rem;
    font-weight: 500;
}

.alert.error {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.18);
    color: #b91c1c;
}

.auth-button {
    width: 100%;
    margin-top: 6px;
}

.auth-meta {
    margin-top: 22px;
    text-align: center;
    color: var(--muted);
    font-size: 0.85rem;
    display: grid;
    gap: 4px;
}

.auth-meta strong {
    color: var(--text);
}

@media (max-width: 960px) {
    .app-shell {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
    }

    .stats-grid,
    .panel-grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 961px) and (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .main-panel {
        padding: 20px 16px 28px;
    }

    .topbar {
        flex-direction: column;
        align-items: flex-start;
    }

    .stats-grid,
    .panel-grid {
        grid-template-columns: 1fr;
    }
}
