:root {
    --bg: #F6F7FB;
    --surface: #FFFFFF;
    --border: #E6E8F0;
    --text: #15172B;
    --text-muted: #6B7088;
    --primary: #5B3DF5;
    --primary-dark: #4A2FE0;
    --sidebar-bg: #15172B;
    --sidebar-text: #B6B9CC;
    --sidebar-active: #FFFFFF;
    --shadow: 0 1px 2px rgba(21, 23, 43, 0.04), 0 8px 24px rgba(21, 23, 43, 0.04);
}
* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

/* ============ Login screen ============ */
.auth {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 1fr 1fr;
}
.auth-brand {
    background: var(--sidebar-bg);
    background-image: radial-gradient(circle at 15% 20%, rgba(91, 61, 245, 0.35), transparent 45%),
                       radial-gradient(circle at 85% 80%, rgba(91, 61, 245, 0.25), transparent 50%);
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 56px;
}
.auth-brand .mark {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 800;
    font-size: 18px;
    letter-spacing: 0.2px;
}
.auth-brand .mark .badge {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
}
.auth-brand .pitch h2 {
    font-size: 34px;
    font-weight: 800;
    line-height: 1.25;
    max-width: 420px;
    margin: 0 0 12px;
    letter-spacing: -0.5px;
}
.auth-brand .pitch p {
    font-size: 15px;
    color: #9AA0BD;
    max-width: 380px;
    line-height: 1.6;
    margin: 0;
}
.auth-brand .footnote {
    font-size: 13px;
    color: #6E7390;
}

.auth-form-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--surface);
}
.auth-form {
    width: 100%;
    max-width: 360px;
}
.auth-form h1 {
    font-size: 24px;
    font-weight: 800;
    margin: 0 0 6px;
    letter-spacing: -0.3px;
}
.auth-form p.sub {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0 0 32px;
}
.field label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}
.field input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    font-family: 'Inter', sans-serif;
    border: 1px solid var(--border);
    border-radius: 10px;
    outline: none;
    background: #FAFBFD;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.field input[type="password"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(91, 61, 245, 0.12);
    background: #fff;
}
.auth-form button {
    width: 100%;
    margin-top: 20px;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.auth-form button:hover {
    background: var(--primary-dark);
}
.auth-form .error {
    margin-top: 14px;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #B3261E;
    background: #FBEAE9;
    border-radius: 8px;
}

@media (max-width: 860px) {
    .auth { grid-template-columns: 1fr; }
    .auth-brand { display: none; }
    .auth-form-wrap { min-height: 100vh; }
}

/* ============ App shell ============ */
.app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    position: sticky;
    top: 0;
    height: 100vh;
}
.sidebar .mark {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    font-weight: 800;
    font-size: 16px;
    padding: 8px 12px 28px;
}
.sidebar .mark .badge {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 14px;
    color: #fff;
    flex-shrink: 0;
}
.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.sidebar a:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.sidebar a.active {
    background: var(--primary);
    color: #fff;
}
.sidebar .sidebar-footer {
    margin-top: auto;
    border-top: 1px solid rgba(255,255,255,0.08);
    padding-top: 12px;
}

/* ============ Nested nav groups ============ */
.sidebar .nav-group {
    display: flex;
    flex-direction: column;
}
.sidebar .nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    background: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    color: var(--sidebar-text);
    cursor: pointer;
    text-align: left;
    transition: background 0.15s ease, color 0.15s ease;
}
.sidebar .nav-group-toggle:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}
.sidebar .nav-group-toggle.active-group {
    color: #fff;
}
.sidebar .nav-group-toggle svg:first-child {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.sidebar .nav-group-toggle span {
    flex: 1;
}
.sidebar .nav-group-toggle .chevron {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}
.sidebar .nav-group.open .nav-group-toggle .chevron {
    transform: rotate(90deg);
}
.sidebar .nav-children {
    display: none;
    flex-direction: column;
    gap: 2px;
    margin: 2px 0 2px 22px;
    padding-left: 12px;
    border-left: 1px solid rgba(255,255,255,0.1);
}
.sidebar .nav-group.open .nav-children {
    display: flex;
}
.sidebar .nav-children a {
    padding: 8px 12px;
    font-size: 13px;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 32px;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar .menu-btn {
    display: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 6px;
    color: var(--text);
}
.topbar h1 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    letter-spacing: -0.2px;
}
.topbar .date {
    font-size: 13px;
    color: var(--text-muted);
}
.topbar .right {
    display: flex;
    align-items: center;
    gap: 16px;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.content {
    flex: 1;
    padding: 40px 32px;
    width: 100%;
}
.content .heading {
    margin-bottom: 32px;
}
.content .heading h2 {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 6px;
    letter-spacing: -0.5px;
}
.content .heading p {
    font-size: 15px;
    color: var(--text-muted);
    margin: 0;
}

/* ============ Shared components ============ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 24px;
}
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s ease;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.status-msg {
    margin-top: 14px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
}
.status-msg.success { color: #1B7A3D; background: #E7F6ED; }
.status-msg.error { color: #B3261E; background: #FBEAE9; }
.status-msg.info { color: var(--primary-dark); background: #EDE9FE; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
table.data-table th, table.data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
table.data-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
table.data-table tbody tr:hover { background: var(--bg); }
table.data-table th.num, table.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* ============ Mobile ============ */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.2s ease;
        z-index: 100;
        box-shadow: 0 0 0 9999px rgba(0,0,0,0);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 0 9999px rgba(15, 17, 35, 0.45);
    }
    .topbar .menu-btn { display: inline-flex; }
    .topbar { padding: 16px 20px; }
    .topbar .date { display: none; }
    .content { padding: 24px 20px; }
    .content .heading h2 { font-size: 22px; }
}
