:root {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-2: #eef2ff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --primary: #0f172a;
    --secondary: #1e293b;
    --accent: #2563eb;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
    --radius: 18px;
    --shadow: 0 10px 30px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: Inter, Arial, Helvetica, sans-serif;
    background: var(--bg);
    color: var(--text);
}

body.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 30%),
        radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.08), transparent 35%),
        var(--bg);
}

body.app-page {
    min-height: 100vh;
}

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

.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
}

.auth-card {
    width: 100%;
    max-width: 720px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 24px;
    box-shadow: var(--shadow);
    padding: 32px;
}

.auth-card-sm {
    max-width: 520px;
}

.auth-header {
    margin-bottom: 24px;
}

.auth-header h1 {
    margin: 0 0 8px;
    font-size: 32px;
    line-height: 1.1;
}

.auth-header p {
    margin: 0;
    color: var(--muted);
}

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

.form-grid.two-cols {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 18px;
}

label {
    font-size: 14px;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    min-height: 48px;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 14px;
    font-size: 15px;
    background: #fff;
    color: var(--text);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 48px;
    padding: 0 18px;
    border: 0;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

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

.btn-secondary {
    background: var(--secondary);
    color: #fff;
}

.btn-block {
    width: 100%;
}

.alert {
    border-radius: 14px;
    padding: 14px 16px;
    margin-bottom: 18px;
    border: 1px solid transparent;
    font-size: 14px;
}

.alert ul {
    margin: 0;
    padding-left: 18px;
}

.alert-danger {
    background: rgba(220, 38, 38, 0.08);
    color: #991b1b;
    border-color: rgba(220, 38, 38, 0.18);
}

.alert-success {
    background: rgba(22, 163, 74, 0.08);
    color: #166534;
    border-color: rgba(22, 163, 74, 0.18);
}

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

.sidebar {
    background: linear-gradient(180deg, var(--primary), #020617);
    color: #fff;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-badge {
    width: 52px;
    height: 52px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    color: #fff;
    font-weight: 800;
}

.sidebar-brand strong,
.sidebar-brand span {
    display: block;
}

.sidebar-brand span {
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav a {
    padding: 12px 14px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.86);
    transition: background 0.2s ease;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-footer {
    margin-top: auto;
}

.main-content {
    padding: 28px;
}

.topbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.topbar h1 {
    margin: 0 0 6px;
    font-size: 34px;
}

.topbar p,
.topbar-meta {
    margin: 0;
    color: var(--muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card,
.panel-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 22px;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: 14px;
    margin-bottom: 10px;
}

.stat-card strong {
    display: block;
    font-size: 30px;
    line-height: 1;
    margin-bottom: 10px;
}

.stat-card small {
    color: var(--muted);
}

.content-grid.two-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.panel-header {
    padding: 20px 22px 0;
}

.panel-header h2 {
    margin: 0;
    font-size: 20px;
}

.table-wrap {
    overflow: auto;
    padding: 18px 22px 22px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead th {
    text-align: left;
    font-size: 13px;
    color: var(--muted);
    padding: 12px 10px;
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 14px 10px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 14px;
}

.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 28px;
    padding: 4px 10px;
    background: var(--surface-2);
    color: var(--accent);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

@media (max-width: 1280px) {
    .stats-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .app-layout {
        grid-template-columns: 1fr;
    }

    .sidebar {
        min-height: auto;
    }

    .stats-grid,
    .content-grid.two-columns,
    .form-grid.two-cols {
        grid-template-columns: 1fr;
    }
}
.btn-light {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
}

.badge-success {
    background: rgba(22, 163, 74, 0.10);
    color: #166534;
}

.badge-danger {
    background: rgba(220, 38, 38, 0.10);
    color: #991b1b;
}

.badge-warning {
    background: rgba(217, 119, 6, 0.12);
    color: #92400e;
}

.badge-info {
    background: rgba(37, 99, 235, 0.10);
    color: #1d4ed8;
}

.toolbar-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: 18px;
}

.toolbar-form {
    display: flex;
    gap: 16px;
    align-items: end;
    flex-wrap: wrap;
}

.toolbar-group {
    min-width: 180px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toolbar-group.grow {
    flex: 1 1 320px;
}

.toolbar-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

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

.muted-text {
    color: var(--muted);
    font-size: 14px;
}

.stats-grid-compact {
    grid-template-columns: repeat(6, minmax(0, 1fr));
}

@media (max-width: 1280px) {
    .stats-grid-compact {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 980px) {
    .toolbar-form,
    .toolbar-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .stats-grid-compact {
        grid-template-columns: 1fr;
    }
}