:root {
    --bg: #f3f6fb;
    --bg-alt: #eef3fb;
    --surface: rgba(255, 255, 255, 0.92);
    --surface-strong: #ffffff;
    --surface-muted: #f7f9fc;
    --line: #dfe7f3;
    --line-strong: #cfd9ea;
    --text: #162033;
    --text-soft: #5d6b85;
    --text-faint: #7f8ca3;
    --primary: #265df2;
    --primary-strong: #1748cc;
    --primary-soft: rgba(38, 93, 242, 0.12);
    --success: #198754;
    --success-soft: rgba(25, 135, 84, 0.12);
    --warning: #c98a00;
    --warning-soft: rgba(201, 138, 0, 0.16);
    --danger: #d54853;
    --danger-soft: rgba(213, 72, 83, 0.14);
    --info: #0f7ce8;
    --info-soft: rgba(15, 124, 232, 0.14);
    --shadow-lg: 0 24px 64px rgba(20, 35, 65, 0.12);
    --shadow-md: 0 12px 32px rgba(24, 40, 72, 0.08);
    --shadow-sm: 0 6px 18px rgba(17, 28, 53, 0.06);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 14px;
    --radius-sm: 10px;
    --transition: 0.18s ease;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(38, 93, 242, 0.08), transparent 32%),
        radial-gradient(circle at top right, rgba(15, 124, 232, 0.08), transparent 22%),
        linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
}

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

a:hover { color: var(--primary-strong); }

h1, h2, h3, h4, p { margin-top: 0; }

h1 {
    font-size: clamp(1.9rem, 2vw, 2.5rem);
    margin-bottom: 10px;
    letter-spacing: -0.03em;
}

h2 {
    font-size: 1.18rem;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

p { color: var(--text-soft); line-height: 1.6; }

ul { margin: 0; padding-left: 20px; }

small, .muted { color: var(--text-soft); }

code, .kbd, small.code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

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

.sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    height: 100vh;
    padding: 18px;
    background: linear-gradient(180deg, #0f1728 0%, #13203a 100%);
    color: rgba(255, 255, 255, 0.9);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 40;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    gap: 18px;
    height: 100%;
}

.brand-block {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 14px 18px;
}

.brand-mark {
    width: 46px;
    height: 46px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    background: linear-gradient(135deg, #6fa2ff 0%, #2558e9 100%);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.04em;
    box-shadow: 0 14px 28px rgba(18, 55, 164, 0.38);
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
}

.brand-subtitle {
    font-size: 0.85rem;
    color: rgba(222, 231, 255, 0.72);
    margin-top: 2px;
}

.sidebar-group {
    display: grid;
    gap: 10px;
}

.sidebar-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: rgba(213, 226, 255, 0.52);
    padding: 0 14px;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 46px;
    padding: 0 14px;
    border-radius: 14px;
    color: rgba(233, 240, 255, 0.85);
    transition: background var(--transition), color var(--transition), transform var(--transition), box-shadow var(--transition);
}

.nav-link:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(2px);
}

.nav-link.is-active {
    color: #fff;
    background: linear-gradient(135deg, rgba(79, 129, 255, 0.22), rgba(32, 86, 232, 0.38));
    border: 1px solid rgba(149, 182, 255, 0.16);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 24px rgba(10, 24, 55, 0.28);
}

.sidebar-meta {
    margin-top: auto;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(199, 215, 255, 0.08);
    color: rgba(255, 255, 255, 0.88);
}

.app-main {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 22px 28px 16px;
    backdrop-filter: blur(18px);
    background: linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(248, 251, 255, 0.8));
    border-bottom: 1px solid rgba(220, 230, 243, 0.9);
}

.topbar-left,
.topbar-right,
.user-identity {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-subtitle {
    font-size: 0.92rem;
    color: var(--text-soft);
    margin-top: 3px;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
}

.user-role {
    font-size: 0.82rem;
    color: var(--text-soft);
    margin-top: 2px;
}

.avatar {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    font-weight: 700;
    background: linear-gradient(135deg, rgba(38, 93, 242, 0.18), rgba(15, 124, 232, 0.12));
    color: var(--primary-strong);
    border: 1px solid rgba(38, 93, 242, 0.16);
}

.avatar.small {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.user-identity.compact .user-name,
.user-identity.compact .user-role {
    color: rgba(255, 255, 255, 0.92);
}

.menu-toggle {
    display: none;
    width: 46px;
    height: 46px;
    padding: 0;
    border-radius: 14px;
}

.page-container {
    padding: 28px;
}

.page-header,
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 22px;
}

.page-subtitle,
.card-subtitle {
    color: var(--text-soft);
    max-width: 72ch;
}

.eyebrow {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 8px;
}

.card {
    background: var(--surface);
    border: 1px solid rgba(212, 223, 238, 0.95);
    box-shadow: var(--shadow-sm);
    border-radius: var(--radius-xl);
    padding: 24px;
    margin-bottom: 22px;
    backdrop-filter: blur(12px);
}

.card.tight { padding: 18px; }

.card.subtle-card { box-shadow: none; }

.card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.card-title {
    font-size: 1.08rem;
    font-weight: 700;
    color: var(--text);
}

.hero-panel {
    position: relative;
    overflow: hidden;
    background:
        radial-gradient(circle at top right, rgba(76, 131, 255, 0.18), transparent 24%),
        linear-gradient(135deg, rgba(255,255,255,0.96), rgba(248,251,255,0.98));
}

.hero-panel::after {
    content: "";
    position: absolute;
    inset: auto -5% -28% auto;
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(38, 93, 242, 0.14), transparent 64%);
    pointer-events: none;
}

.grid {
    display: grid;
    gap: 18px;
}

.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)); }

.stats-grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

.stat-card {
    position: relative;
    overflow: hidden;
    padding: 22px;
}

.stat-card::before {
    content: "";
    position: absolute;
    inset: auto -28px -28px auto;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(38, 93, 242, 0.12), transparent 70%);
}

.stat-label {
    color: var(--text-soft);
    font-size: 0.92rem;
    margin-bottom: 14px;
}

.stat {
    position: relative;
    z-index: 1;
    font-size: clamp(1.8rem, 2vw, 2.35rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    color: var(--text);
}

.stat-meta {
    margin-top: 8px;
    color: var(--text-faint);
    font-size: 0.84rem;
}

.toolbar,
.button-group,
.inline-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

form.inline { display: inline-flex; }

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 14px;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
    color: #fff;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), opacity var(--transition), border-color var(--transition), background var(--transition);
    box-shadow: 0 12px 24px rgba(33, 81, 212, 0.22);
}

button:hover,
.button:hover {
    transform: translateY(-1px);
    color: #fff;
    box-shadow: 0 16px 30px rgba(33, 81, 212, 0.25);
}

button:disabled,
.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

button.secondary,
.button.secondary {
    background: #fff;
    color: var(--text);
    border-color: var(--line);
    box-shadow: none;
}

button.secondary:hover,
.button.secondary:hover {
    border-color: var(--line-strong);
    background: var(--surface-muted);
}

button.ghost,
.button.ghost {
    background: rgba(38, 93, 242, 0.08);
    color: var(--primary-strong);
    border-color: rgba(38, 93, 242, 0.08);
    box-shadow: none;
}

button.danger,
.button.danger {
    background: linear-gradient(135deg, #e45761, #c93c46);
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--text);
}

.field-hint {
    font-size: 0.82rem;
    color: var(--text-faint);
    margin-top: 7px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    min-height: 50px;
    padding: 0 14px;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.96);
    color: var(--text);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition), transform var(--transition);
}

textarea {
    min-height: 140px;
    padding: 14px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(38, 93, 242, 0.55);
    box-shadow: 0 0 0 4px rgba(38, 93, 242, 0.12);
    background: #fff;
}

input::placeholder,
textarea::placeholder { color: #98a5bb; }

input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
}

.field,
.form-row > div {
    min-width: 0;
}

.form-row {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    margin-bottom: 18px;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 6px;
}

.checkbox-stack {
    display: grid;
    gap: 12px;
    max-height: 260px;
    overflow: auto;
    padding: 8px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--surface-muted);
    border: 1px solid var(--line);
}

.checkbox-item label {
    margin: 0;
    font-weight: 600;
    cursor: pointer;
}

.table-wrap {
    overflow: auto;
    border-radius: 18px;
    border: 1px solid rgba(219, 227, 238, 0.98);
    background: #fff;
}

.table-wrap + .pagination { margin-top: 16px; }

table {
    width: 100%;
    min-width: 640px;
    border-collapse: separate;
    border-spacing: 0;
    background: #fff;
}

thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, #f9fbff 0%, #f4f8fd 100%);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
}

th,
td {
    padding: 14px 16px;
    border-bottom: 1px solid #edf2f8;
    text-align: left;
    vertical-align: top;
    font-size: 0.93rem;
}

tbody tr:hover { background: rgba(38, 93, 242, 0.03); }

tbody tr:last-child td { border-bottom: 0; }

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.badge-success { background: var(--success-soft); color: var(--success); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-muted { background: rgba(120, 136, 162, 0.12); color: #5d6b85; }

.flash-stack { display: grid; gap: 12px; margin-bottom: 18px; }

.flash {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 0 18px;
    border-radius: 16px;
    font-weight: 600;
    border: 1px solid transparent;
    box-shadow: var(--shadow-sm);
}

.flash.success { background: rgba(25, 135, 84, 0.08); color: #116740; border-color: rgba(25, 135, 84, 0.12); }
.flash.error { background: rgba(213, 72, 83, 0.08); color: #ad2430; border-color: rgba(213, 72, 83, 0.12); }
.flash.warning { background: rgba(201, 138, 0, 0.12); color: #946700; border-color: rgba(201, 138, 0, 0.14); }

.pagination {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.empty-state {
    padding: 28px;
    text-align: center;
    color: var(--text-soft);
}

.kbd {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 8px;
    border-radius: 10px;
    background: #edf3fb;
    border: 1px solid var(--line);
    color: #32425e;
}

small.code {
    display: block;
    line-height: 1.55;
    color: #445066;
    white-space: pre-wrap;
    word-break: break-word;
}

.metric-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(38, 93, 242, 0.08);
    color: var(--primary-strong);
    font-weight: 700;
}

.split-panel {
    display: grid;
    grid-template-columns: 1.2fr 1fr;
    gap: 18px;
}

.auth-body {
    background:
        radial-gradient(circle at top left, rgba(38, 93, 242, 0.16), transparent 28%),
        radial-gradient(circle at bottom right, rgba(15, 124, 232, 0.14), transparent 26%),
        linear-gradient(160deg, #07111f 0%, #0f1d36 48%, #162746 100%);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 30px;
}

.auth-container {
    width: min(1180px, 100%);
}

.auth-grid {
    display: grid;
    grid-template-columns: 1.08fr 0.92fr;
    gap: 26px;
    align-items: stretch;
}

.auth-hero,
.auth-card {
    position: relative;
    overflow: hidden;
    border-radius: 28px;
    box-shadow: 0 28px 80px rgba(4, 14, 33, 0.34);
}

.auth-hero {
    padding: 34px;
    background:
        radial-gradient(circle at top right, rgba(143, 182, 255, 0.2), transparent 24%),
        linear-gradient(145deg, rgba(20, 36, 68, 0.92), rgba(13, 24, 47, 0.96));
    color: #edf3ff;
    border: 1px solid rgba(155, 184, 255, 0.12);
}

.auth-card {
    padding: 34px;
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(220, 228, 241, 0.95);
}

.auth-kicker {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #dce7ff;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.auth-hero h1,
.auth-card h2 { color: inherit; }

.auth-hero p { color: rgba(233, 240, 255, 0.8); }

.feature-list {
    display: grid;
    gap: 12px;
    margin-top: 26px;
}

.feature-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.feature-badge {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    background: rgba(143, 182, 255, 0.18);
    color: #fff;
    font-weight: 800;
}

.auth-form { display: grid; gap: 18px; }

.auth-form .field-group {
    display: grid;
    gap: 18px;
}

.auth-footer {
    margin-top: 14px;
    color: var(--text-soft);
    font-size: 0.9rem;
}

.mobile-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 12, 26, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
    z-index: 30;
}

.text-right { text-align: right; }
.text-center { text-align: center; }
.nowrap { white-space: nowrap; }

@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .split-panel { grid-template-columns: 1fr; }
}

@media (max-width: 1024px) {
    .app-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(320px, 88vw);
        transform: translateX(-104%);
        transition: transform var(--transition);
        box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .mobile-backdrop {
        opacity: 1;
        pointer-events: auto;
    }
    .menu-toggle { display: inline-flex; }
    .topbar { padding-inline: 20px; }
    .page-container { padding: 20px; }
    .grid-2,
    .grid-3,
    .grid-4,
    .auth-grid { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
    .topbar,
    .page-header,
    .section-header,
    .card-header {
        flex-direction: column;
        align-items: stretch;
    }
    .topbar-right,
    .toolbar,
    .button-group,
    .inline-actions,
    .form-actions,
    .pagination {
        justify-content: stretch;
    }
    .topbar-right > *,
    .toolbar > *,
    .button-group > *,
    .inline-actions > *,
    .form-actions > * {
        flex: 1 1 auto;
    }
    button,
    .button,
    .topbar-right form.inline,
    form.inline button {
        width: 100%;
    }
    .card,
    .auth-card,
    .auth-hero { padding: 22px; }
    table { min-width: 560px; }
}
