:root {
    --brand-50: #eef7ff;
    --brand-100: #d9ecff;
    --brand-500: #2563eb;
    --brand-600: #1d4ed8;
    --brand-700: #1e40af;
    --slate-25: #f8fafc;
    --slate-50: #f1f5f9;
    --slate-100: #e2e8f0;
    --slate-200: #cbd5e1;
    --slate-300: #94a3b8;
    --slate-500: #64748b;
    --slate-700: #334155;
    --slate-900: #0f172a;
    --green-100: #dcfce7;
    --green-700: #166534;
    --amber-100: #fef3c7;
    --amber-700: #92400e;
    --red-100: #fee2e2;
    --red-700: #991b1b;
    --shadow-soft: 0 18px 55px rgba(15, 23, 42, .08);
    --shadow-card: 0 10px 25px rgba(15, 23, 42, .06);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.08), transparent 28%),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.07), transparent 22%),
        linear-gradient(180deg, #f8fbff 0%, #f8fafc 100%);
    color: var(--slate-900);
    min-height: 100vh;
}

body.login-page {
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.14), transparent 32%),
        radial-gradient(circle at bottom right, rgba(14, 165, 233, 0.12), transparent 30%),
        linear-gradient(180deg, #eff6ff 0%, #f8fafc 100%);
}

::selection {
    background: rgba(37, 99, 235, .15);
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-thumb {
    background: rgba(148, 163, 184, .55);
    border-radius: 999px;
}

.app-shell {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.5rem;
}

.content-shell {
    display: grid;
    gap: 1.5rem;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    backdrop-filter: blur(14px);
    background: rgba(255, 255, 255, .82);
    border-bottom: 1px solid rgba(226, 232, 240, .9);
}

.topbar-inner {
    max-width: 1440px;
    margin: 0 auto;
    padding: 1rem 1.5rem;
}

.brand-mark {
    width: 2.75rem;
    height: 2.75rem;
    border-radius: 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--brand-600), #0ea5e9);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 12px 25px rgba(37, 99, 235, .25);
}

.nav-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
    padding: .7rem 1rem;
    border-radius: 999px;
    color: var(--slate-700);
    font-size: .94rem;
    font-weight: 600;
    transition: all .2s ease;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
    color: var(--brand-700);
    background: rgba(37, 99, 235, .08);
}

.card,
.surface-card {
    background: rgba(255, 255, 255, .92);
    border: 1px solid rgba(226, 232, 240, .85);
    border-radius: 1.5rem;
    padding: 1.4rem;
    box-shadow: var(--shadow-card);
}

.surface-card.hero-card {
    padding: 1.75rem;
    box-shadow: var(--shadow-soft);
}

.metric-card {
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: "";
    position: absolute;
    right: -2rem;
    top: -2rem;
    width: 7rem;
    height: 7rem;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(37, 99, 235, .18), rgba(14, 165, 233, .08));
}

.metric-value {
    font-size: clamp(1.8rem, 2.5vw, 2.4rem);
    line-height: 1;
    font-weight: 700;
    color: var(--slate-900);
    margin: .75rem 0 .25rem;
}

.page-title {
    font-size: clamp(1.6rem, 2.4vw, 2rem);
    line-height: 1.1;
    font-weight: 700;
    margin: 0;
    color: var(--slate-900);
}

.section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--slate-900);
    margin: 0;
}

.section-subtitle,
small,
.muted {
    color: var(--slate-500);
}

.kicker {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .35rem .75rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, .08);
    color: var(--brand-700);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-transform: uppercase;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .55rem;
    min-height: 2.75rem;
    padding: .75rem 1rem;
    border-radius: 1rem;
    border: 1px solid transparent;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .16s ease, box-shadow .16s ease, opacity .16s ease, background .16s ease;
    box-shadow: 0 10px 18px rgba(37, 99, 235, .18);
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 22px rgba(37, 99, 235, .22);
}

.btn:disabled {
    opacity: .65;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background: #fff;
    color: var(--slate-700);
    border-color: rgba(203, 213, 225, .9);
    box-shadow: none;
}

.btn-success {
    background: linear-gradient(135deg, #059669, #10b981);
}

.btn-warning {
    background: linear-gradient(135deg, #d97706, #f59e0b);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

.btn-ghost {
    background: transparent;
    color: var(--slate-700);
    border-color: rgba(203, 213, 225, .9);
    box-shadow: none;
}

.form-group {
    display: grid;
    gap: .5rem;
}

label {
    font-weight: 700;
    font-size: .92rem;
    color: var(--slate-700);
}

input,
select,
textarea {
    width: 100%;
    min-height: 2.9rem;
    border-radius: 1rem;
    border: 1px solid rgba(203, 213, 225, .95);
    background: rgba(255, 255, 255, .92);
    padding: .75rem .95rem;
    color: var(--slate-900);
    outline: none;
    transition: border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, .55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .11);
    background: #fff;
}

textarea {
    min-height: 5.25rem;
    resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
    width: 1rem;
    min-height: 1rem;
    height: 1rem;
    border-radius: .35rem;
    accent-color: var(--brand-600);
}

.grid {
    display: grid;
    gap: 1rem;
}

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

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

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

.d-flex {
    display: flex;
    gap: .75rem;
    align-items: center;
    flex-wrap: wrap;
}

.table-card {
    overflow: hidden;
}

.table-wrap {
    overflow: auto;
    border-radius: 1.1rem;
    border: 1px solid rgba(226, 232, 240, .95);
    background: #fff;
}

.table-wrap table,
table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap thead th,
table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
    color: var(--slate-700);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

th,
td {
    padding: .95rem 1rem;
    border-bottom: 1px solid rgba(226, 232, 240, .95);
    vertical-align: middle;
    text-align: left;
}

tr:hover td {
    background: rgba(248, 250, 252, .85);
}

tfoot th,
tfoot td {
    background: #f8fafc;
    font-weight: 700;
}

.sort-link {
    display: inline-flex;
    align-items: center;
    gap: .25rem;
    color: inherit;
    text-decoration: none;
}

.sort-link.active {
    color: var(--brand-700);
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .35rem .72rem;
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}

.badge-success {
    background: var(--green-100);
    color: var(--green-700);
}

.badge-warning {
    background: var(--amber-100);
    color: var(--amber-700);
}

.badge-error {
    background: var(--red-100);
    color: var(--red-700);
}

.info-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .4rem .75rem;
    border-radius: 999px;
    background: rgba(241, 245, 249, .95);
    color: var(--slate-700);
    font-size: .84rem;
    font-weight: 600;
}

.filters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.filters-footer {
    display: flex;
    flex-wrap: wrap;
    gap: .75rem;
    align-items: center;
    justify-content: space-between;
    padding-top: .25rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
}

.summary-card {
    padding: 1rem 1.1rem;
    border-radius: 1.2rem;
    background: linear-gradient(180deg, rgba(255,255,255,.96), rgba(248,250,252,.98));
    border: 1px solid rgba(226, 232, 240, .95);
}

.summary-label {
    display: block;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--slate-500);
    font-weight: 700;
}

.summary-value {
    display: block;
    margin-top: .35rem;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--slate-900);
}

.form-switch-row {
    display: flex;
    align-items: center;
    gap: .75rem;
    border: 1px solid rgba(226, 232, 240, .95);
    border-radius: 1rem;
    padding: .9rem 1rem;
    background: rgba(248, 250, 252, .85);
}

.login-layout {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
}

.login-shell {
    width: min(1050px, 100%);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 460px);
    gap: 1.25rem;
    align-items: stretch;
}

.login-side {
    background: linear-gradient(135deg, rgba(30, 64, 175, .97), rgba(14, 116, 144, .92));
    color: #fff;
    border-radius: 2rem;
    padding: 2rem;
    box-shadow: var(--shadow-soft);
    position: relative;
    overflow: hidden;
}

.login-side::after {
    content: "";
    position: absolute;
    inset: auto -4rem -4rem auto;
    width: 12rem;
    height: 12rem;
    border-radius: 999px;
    background: rgba(255,255,255,.10);
}

.login-card {
    border-radius: 2rem;
    padding: 2rem;
    background: rgba(255,255,255,.95);
    border: 1px solid rgba(255,255,255,.8);
    box-shadow: var(--shadow-soft);
}

.toast-stack {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 70;
    display: grid;
    gap: .75rem;
    max-width: min(420px, calc(100vw - 2rem));
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: .8rem;
    padding: 1rem 1rem;
    border-radius: 1.15rem;
    box-shadow: 0 18px 28px rgba(15, 23, 42, .12);
    border: 1px solid rgba(226, 232, 240, .95);
    background: rgba(255,255,255,.98);
    transform: translateY(-6px);
    opacity: 0;
    animation: toast-in .26s ease forwards;
}

.toast-success { border-left: 5px solid #16a34a; }
.toast-error { border-left: 5px solid #dc2626; }
.toast-info { border-left: 5px solid var(--brand-500); }

.toast-icon {
    width: 2rem;
    height: 2rem;
    border-radius: .8rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2rem;
    font-size: 1rem;
    font-weight: 700;
}

.toast-success .toast-icon { background: var(--green-100); color: var(--green-700); }
.toast-error .toast-icon { background: var(--red-100); color: var(--red-700); }
.toast-info .toast-icon { background: var(--brand-100); color: var(--brand-700); }

.toast-close {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--slate-400);
    cursor: pointer;
    padding: 0;
    font-size: 1.1rem;
}

.toast-hide {
    animation: toast-out .2s ease forwards;
}

@keyframes toast-in {
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toast-out {
    to { transform: translateY(-8px); opacity: 0; }
}

.pagination-shell {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 1rem;
}

.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: .65rem .85rem;
    border-radius: .95rem;
    border: 1px solid rgba(203, 213, 225, .95);
    background: rgba(255, 255, 255, .94);
    color: var(--slate-700);
    text-decoration: none;
    font-weight: 700;
}

.pagination a.active {
    background: linear-gradient(135deg, var(--brand-600), var(--brand-500));
    color: #fff;
    border-color: transparent;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--slate-500);
}

.stat-list {
    display: grid;
    gap: .75rem;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    border-bottom: 1px dashed rgba(203, 213, 225, .9);
    padding-bottom: .75rem;
}

.stat-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

@media (max-width: 1024px) {
    .login-shell {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 860px) {
    .topbar-inner,
    .app-shell {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .nav-panel {
        display: none;
        width: 100%;
        padding-top: .9rem;
    }

    .nav-panel.open {
        display: grid;
        gap: .65rem;
    }

    .nav-panel .nav-link,
    .nav-panel form {
        width: 100%;
    }

    .nav-panel form button {
        width: 100%;
    }
}
