:root {
    color-scheme: dark;
    --bg: #090d12;
    --panel: #111821;
    --panel-2: #151f2b;
    --line: #263241;
    --text: #eef4f8;
    --muted: #92a3b4;
    --accent: #36c2a0;
    --accent-2: #2f8cff;
    --danger: #ff5d5d;
    --warning: #f3b950;
    --shadow: 0 18px 45px rgba(0, 0, 0, .32);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
    background: var(--bg);
}

body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background:
        linear-gradient(135deg, rgba(47, 140, 255, .11), transparent 36rem),
        linear-gradient(315deg, rgba(54, 194, 160, .10), transparent 34rem),
        var(--bg);
    letter-spacing: 0;
}

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

code {
    color: #cce4ff;
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: .88rem;
}

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

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1.25rem;
    border-right: 1px solid var(--line);
    background: rgba(10, 15, 22, .86);
    backdrop-filter: blur(18px);
}

.brand {
    display: flex;
    align-items: center;
    gap: .8rem;
}

.brand-mark {
    display: grid;
    width: 2.75rem;
    height: 2.75rem;
    place-items: center;
    border: 1px solid rgba(54, 194, 160, .55);
    border-radius: .5rem;
    background: linear-gradient(135deg, rgba(54, 194, 160, .22), rgba(47, 140, 255, .16));
    color: var(--text);
    font-weight: 800;
}

.brand strong,
.brand small {
    display: block;
}

.brand small {
    margin-top: .12rem;
    color: var(--muted);
    font-size: .78rem;
}

.nav {
    display: grid;
    gap: .35rem;
}

.nav a,
.sidebar-footer a,
.button,
.icon-button {
    min-height: 2.5rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    border-radius: .5rem;
    transition: border-color .16s ease, background .16s ease, color .16s ease;
}

.nav a {
    justify-content: flex-start;
    padding: 0 .85rem;
    color: var(--muted);
}

.nav a:hover,
.nav a.active {
    border-color: rgba(54, 194, 160, .38);
    background: rgba(54, 194, 160, .11);
    color: var(--text);
}

.sidebar-footer {
    margin-top: auto;
    display: grid;
    gap: .65rem;
    color: var(--muted);
    font-size: .9rem;
}

.sidebar-footer a {
    background: rgba(255, 255, 255, .04);
}

.main {
    min-width: 0;
    padding: 2rem;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.4rem;
}

.eyebrow {
    margin: 0 0 .35rem;
    color: var(--accent);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 0;
    font-size: clamp(1.75rem, 3vw, 2.65rem);
    line-height: 1.05;
}

h2 {
    margin-bottom: 0;
    font-size: 1.08rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.stat-card,
.panel,
.auth-card {
    border: 1px solid var(--line);
    border-radius: .5rem;
    background: rgba(17, 24, 33, .88);
    box-shadow: var(--shadow);
}

.stat-card {
    padding: 1rem;
}

.stat-card span {
    display: block;
    color: var(--muted);
    font-size: .84rem;
}

.stat-card strong {
    display: block;
    margin-top: .55rem;
    font-size: 2rem;
}

.panel {
    padding: 1rem;
}

.panel.narrow {
    max-width: 58rem;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

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

table {
    width: 100%;
    min-width: 58rem;
    border-collapse: collapse;
}

th,
td {
    padding: .82rem .75rem;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: top;
}

th {
    color: var(--muted);
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
}

td {
    color: #dce7ee;
}

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

.compact-list {
    max-width: 18rem;
    word-break: break-word;
}

.actions-col {
    width: 22rem;
}

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

.actions form {
    margin: 0;
}

.button,
.icon-button {
    cursor: pointer;
    padding: 0 .9rem;
    color: var(--text);
    background: rgba(255, 255, 255, .05);
    font: inherit;
}

.button:hover,
.icon-button:hover {
    border-color: rgba(255, 255, 255, .18);
    background: rgba(255, 255, 255, .08);
}

.button.primary {
    border-color: rgba(54, 194, 160, .48);
    background: linear-gradient(135deg, #1f9e85, #2778d9);
    color: #ffffff;
    font-weight: 700;
}

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

.button.danger,
.icon-button.danger {
    border-color: rgba(255, 93, 93, .42);
    color: #ffd7d7;
}

.button.full {
    width: 100%;
}

.badge {
    display: inline-flex;
    min-height: 1.65rem;
    align-items: center;
    border-radius: 999px;
    padding: 0 .65rem;
    font-size: .78rem;
    font-weight: 700;
}

.badge.success,
.alert.success {
    background: rgba(54, 194, 160, .14);
    color: #84f0d4;
}

.badge.danger,
.alert.danger {
    background: rgba(255, 93, 93, .14);
    color: #ffb7b7;
}

.badge.warning {
    background: rgba(243, 185, 80, .15);
    color: #ffd891;
}

.badge.muted {
    background: rgba(146, 163, 180, .14);
    color: #c5d0da;
}

.alert {
    margin-bottom: 1rem;
    border: 1px solid currentColor;
    border-radius: .5rem;
    padding: .8rem 1rem;
}

.empty {
    color: var(--muted);
    text-align: center;
}

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

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

.full-row {
    grid-column: 1 / -1;
}

label span {
    display: block;
    margin-bottom: .4rem;
    color: var(--muted);
    font-size: .86rem;
    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .85rem .9rem;
    color: var(--text);
    background: rgba(6, 10, 16, .72);
    font: inherit;
}

textarea {
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid rgba(54, 194, 160, .28);
    border-color: rgba(54, 194, 160, .7);
}

.check {
    display: flex;
    align-items: center;
    gap: .7rem;
}

.check input {
    width: 1.15rem;
    height: 1.15rem;
}

.check span {
    margin: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: .7rem;
}

.license-id-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    border: 1px solid var(--line);
    border-radius: .5rem;
    padding: .9rem 1rem;
    background: rgba(255, 255, 255, .035);
}

.license-id-line span {
    color: var(--muted);
}

.danger-zone p {
    color: var(--muted);
}

.auth-page {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 1.25rem;
}

.auth-card {
    width: min(100%, 27rem);
    padding: 1.35rem;
}

.auth-brand {
    margin-bottom: 1.25rem;
}

.auth-card h1 {
    margin-bottom: 1rem;
    font-size: 1.8rem;
}

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

    .sidebar {
        position: relative;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    .nav {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .sidebar-footer {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

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

@media (max-width: 700px) {
    .main {
        padding: 1rem;
    }

    .page-header {
        align-items: stretch;
        flex-direction: column;
    }

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

    .nav {
        grid-template-columns: 1fr;
    }

    .form-actions {
        justify-content: stretch;
    }

    .form-actions .button {
        flex: 1 1 auto;
    }
}
