:root {
    --bg: #08080c;
    --bg-2: #11111a;
    --card: #181824;
    --card-2: #15151d;
    --border: #2a2a3a;
    --text: #f5f5f7;
    --muted: #a1a1aa;
    --purple: #7c3aed;
    --purple-2: #9333ea;
    --red-dark: #991b1b;
    --success: #22c55e;
    --danger: #ef4444;
    --warning: #f59e0b;
    --radius: 8px;
    --sidebar: 256px;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 15px;
    letter-spacing: 0;
}

body.pdv-light-page {
    background: #f8fafc;
}

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

button,
input,
select,
textarea {
    font: inherit;
}

code {
    background: #0d0d14;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 2px 6px;
}

.shell {
    display: grid;
    grid-template-columns: var(--sidebar) minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 0;
    background: var(--bg-2);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    overflow: hidden;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 42px;
    margin-bottom: 24px;
    text-transform: uppercase;
    font-weight: 800;
}

.brand img,
.auth-logo {
    width: 38px;
    height: 38px;
}

.brand small {
    color: var(--purple-2);
    font-size: 10px;
    font-weight: 800;
}

.side-nav {
    display: grid;
    gap: 5px;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding-right: 2px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.side-nav::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.side-group {
    display: grid;
    gap: 4px;
}

.side-group-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    gap: 4px;
    align-items: center;
}

.side-nav a,
.side-subnav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 12px;
    color: var(--muted);
    border-radius: var(--radius);
}

.side-group-toggle {
    width: 34px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    background: transparent;
    border: 0;
    border-radius: var(--radius);
    cursor: pointer;
}

.side-nav a:hover,
.side-nav a.active,
.side-subnav a:hover,
.side-subnav a.active,
.side-group-toggle:hover {
    background: rgba(124, 58, 237, .24);
    color: var(--text);
}

.side-subnav {
    display: grid;
    gap: 2px;
    margin: 0 0 4px 18px;
    padding-left: 10px;
    border-left: 1px solid var(--border);
}

.side-group:not(.is-open) .side-subnav {
    display: none;
}

.side-group:not(.is-open) .side-group-toggle svg {
    transform: rotate(-90deg);
}

.side-subnav a {
    min-height: 34px;
    font-size: 14px;
    padding: 0 10px;
}

.side-nav svg,
.topbar svg,
.icon-button svg,
.module-icon svg {
    width: 18px;
    height: 18px;
}

.side-nav .side-subnav svg {
    width: 15px;
    height: 15px;
}

.side-footer {
    flex: 0 0 auto;
    margin-top: 12px;
    color: var(--muted);
    font-size: 12px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.main {
    min-width: 0;
    padding: 28px;
}

.pdv-light-page .main {
    background: #f8fafc;
    color: #0f172a;
}

.pdv-light-page .topbar h1 {
    color: #0f172a;
}

.pdv-light-page .topbar .eyebrow,
.pdv-light-page .footer {
    color: #64748b;
}

.pdv-light-page .user-pill,
.pdv-light-page .icon-button {
    color: #0f172a;
    background: #ffffff;
    border-color: #dfe3ea;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
}

.topbar h1 {
    margin: 3px 0 0;
    font-size: 28px;
    line-height: 1.1;
}

.eyebrow {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

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

.logout-inline-form {
    margin: 0;
}

.user-pill,
.icon-button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 38px;
    border-radius: var(--radius);
}

.user-pill {
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0 12px;
}

.icon-button {
    width: 38px;
    border: 1px solid var(--border);
    color: var(--muted);
    background: transparent;
    cursor: pointer;
}

.page-content {
    display: grid;
    gap: 22px;
}

.panel,
.metric-card,
.module-card,
.data-card,
.kanban-column {
    background: var(--card-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.panel {
    padding: 18px;
}

.panel h2,
.section-title {
    margin: 0 0 16px;
    font-size: 18px;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 12px;
}

.btn {
    border: 1px solid var(--border);
    background: #111119;
    color: var(--text);
    padding: 0 16px;
    font-weight: 700;
    cursor: pointer;
}

.btn.primary {
    border-color: transparent;
    background: linear-gradient(135deg, var(--purple), var(--purple-2));
}

.btn.ghost {
    background: transparent;
}

.btn.full {
    width: 100%;
}

.flash,
.alert {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    margin-bottom: 16px;
}

.flash.success,
.alert.success {
    color: var(--success);
    background: rgba(34, 197, 94, .08);
}

.flash.error {
    color: var(--danger);
    background: rgba(239, 68, 68, .08);
}

.flash.warning,
.alert.warning {
    color: var(--warning);
    background: rgba(245, 158, 11, .08);
}

.footer {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    color: var(--muted);
    font-size: 12px;
    padding: 26px 0 4px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
}

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

th,
td {
    text-align: left;
    border-bottom: 1px solid var(--border);
    padding: 12px 10px;
    vertical-align: top;
}

td small {
    display: block;
    color: var(--muted);
    margin-top: 3px;
}

th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

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

    .sidebar {
        position: relative;
        height: auto;
        overflow: visible;
    }

    .side-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        overflow: visible;
    }

    .side-subnav {
        margin-left: 8px;
    }

    .main {
        padding: 18px;
    }

    .topbar,
    .footer {
        align-items: flex-start;
        flex-direction: column;
    }
}
