:root {
    --font-body: "Trebuchet MS", "Segoe UI Variable", sans-serif;
    --font-display: "Gill Sans", "Trebuchet MS", sans-serif;
    --bg: #f6f1e8;
    --bg-accent: rgba(247, 128, 79, 0.16);
    --surface: rgba(255, 252, 247, 0.78);
    --surface-strong: rgba(255, 255, 255, 0.96);
    --border: rgba(58, 45, 38, 0.12);
    --text: #201813;
    --muted: #6f6259;
    --primary: #be4d1d;
    --primary-soft: rgba(190, 77, 29, 0.12);
    --success: #1f7a5a;
    --warning: #b7791f;
    --danger: #b43b33;
    --shadow: 0 24px 48px rgba(47, 26, 10, 0.12);
}

html[data-theme="dark"] {
    --bg: #11161d;
    --bg-accent: rgba(81, 146, 255, 0.16);
    --surface: rgba(19, 27, 37, 0.82);
    --surface-strong: rgba(24, 34, 47, 0.96);
    --border: rgba(163, 184, 204, 0.16);
    --text: #edf2f7;
    --muted: #94a3b8;
    --primary: #6ac2ff;
    --primary-soft: rgba(106, 194, 255, 0.12);
    --success: #4dd4ac;
    --warning: #f2bf62;
    --danger: #ff7c7c;
    --shadow: 0 24px 56px rgba(2, 6, 23, 0.4);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, var(--bg-accent), transparent 28rem),
        linear-gradient(160deg, rgba(255, 255, 255, 0.04), transparent 40%),
        var(--bg);
    color: var(--text);
    font-family: var(--font-body);
}

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

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

.auth-shell,
.panel-shell {
    min-height: 100vh;
}

.auth-shell {
    display: grid;
    place-items: center;
    padding: 2rem;
    position: relative;
    overflow: hidden;
}

.auth-backdrop {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(0, 0, 0, 0.08), transparent),
        radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.2), transparent 24rem),
        linear-gradient(120deg, rgba(190, 77, 29, 0.18), rgba(34, 82, 164, 0.12));
}

.auth-card,
.card,
.metric-card,
.flash,
.sidebar,
.topbar,
.tabs,
.empty-state {
    backdrop-filter: blur(18px);
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(100%, 32rem);
    padding: 2rem;
    border-radius: 1.5rem;
    position: relative;
    z-index: 1;
}

.auth-card h1,
.brand-lockup h1,
.hero h1,
.topbar h2,
.page-header h1,
.metric-card strong {
    font-family: var(--font-display);
    letter-spacing: 0.02em;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-size: 0.72rem;
}

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

.panel-shell {
    display: grid;
    grid-template-columns: 18rem 1fr;
}

.sidebar {
    padding: 1.5rem;
    margin: 1rem;
    border-radius: 1.75rem;
    position: sticky;
    top: 1rem;
    height: calc(100vh - 2rem);
}

.brand-lockup {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 2rem;
}

.brand-mark {
    width: 3rem;
    height: 3rem;
    display: grid;
    place-items: center;
    border-radius: 0.9rem;
    background: linear-gradient(140deg, var(--primary), rgba(0, 0, 0, 0.2));
    color: white;
    font-weight: 700;
}

.sidebar-nav {
    display: grid;
    gap: 0.45rem;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    color: var(--muted);
    transition: 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
    color: var(--text);
    background: var(--primary-soft);
}

.nav-code {
    min-width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.75rem;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.08);
    font-size: 0.8rem;
}

.sidebar-foot {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.main-shell {
    padding: 1rem 1rem 1.5rem 0;
}

.topbar {
    margin: 1rem 0 1rem;
    padding: 1rem 1.25rem;
    border-radius: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar-actions,
.button-row,
.inline-actions,
.tab-nav,
.stat-strip,
.health-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.search-form {
    width: min(25rem, 100%);
}

.search-form input,
.field {
    width: 100%;
    border-radius: 0.95rem;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    padding: 0.85rem 1rem;
    color: var(--text);
}

.textarea {
    min-height: 7rem;
    resize: vertical;
}

.icon-button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface-strong);
    color: var(--text);
    padding: 0.72rem 1.1rem;
    cursor: pointer;
    transition: 0.2s ease;
}

.button.primary {
    border-color: transparent;
    background: var(--primary);
    color: white;
}

.button.secondary,
.icon-button:hover,
.button:hover {
    background: var(--primary-soft);
}

.button.danger {
    color: white;
    background: var(--danger);
    border-color: transparent;
}

.button.ghost {
    background: transparent;
}

.pill,
.status-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.8rem;
    border: 1px solid transparent;
}

.pill {
    background: var(--primary);
    color: white;
}

.status-badge.success {
    color: var(--success);
    background: rgba(77, 212, 172, 0.12);
}

.status-badge.warning {
    color: var(--warning);
    background: rgba(242, 191, 98, 0.14);
}

.status-badge.danger {
    color: var(--danger);
    background: rgba(255, 124, 124, 0.12);
}

.status-badge.muted {
    color: var(--muted);
    background: rgba(148, 163, 184, 0.12);
}

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

.page-header,
.hero,
.card,
.metric-card,
.empty-state {
    border-radius: 1.5rem;
    padding: 1.35rem;
}

.hero {
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.04), transparent),
        linear-gradient(120deg, rgba(106, 194, 255, 0.18), rgba(190, 77, 29, 0.18)),
        var(--surface);
}

.metric-grid,
.detail-grid,
.form-grid,
.settings-grid,
.profile-grid,
.two-column {
    display: grid;
    gap: 1rem;
}

.metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}

.metric-card strong {
    display: block;
    font-size: 1.9rem;
    margin: 0.35rem 0;
}

.stat-strip {
    margin-top: 1rem;
}

.stat-pill {
    min-width: 11rem;
    border-radius: 1.2rem;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
}

.table-wrap {
    overflow-x: auto;
}

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

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

th {
    color: var(--muted);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.inline-form {
    display: inline;
}

.flash {
    border-radius: 1rem;
    padding: 1rem 1.15rem;
}

.flash.success {
    border-color: rgba(77, 212, 172, 0.3);
}

.flash.danger {
    border-color: rgba(255, 124, 124, 0.3);
}

.flash ul {
    margin: 0.6rem 0 0;
    padding-left: 1.2rem;
}

.tab-nav a {
    padding: 0.75rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
}

.tab-nav a.active {
    color: var(--text);
    background: var(--primary-soft);
}

.detail-grid,
.settings-grid,
.profile-grid,
.two-column {
    grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
}

.summary-list,
.health-list {
    display: grid;
    gap: 0.8rem;
}

.summary-row,
.health-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
}

.summary-row:last-child,
.health-row:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.footer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.8rem;
    justify-content: space-between;
    align-items: center;
}

.mobile-only {
    display: none;
}

.pagination {
    display: flex;
    justify-content: flex-end;
}

label {
    display: grid;
    gap: 0.45rem;
}

label span {
    color: var(--muted);
}

code.inline {
    padding: 0.18rem 0.42rem;
    border-radius: 0.4rem;
    background: rgba(255, 255, 255, 0.08);
}

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

    .sidebar {
        position: fixed;
        left: 1rem;
        right: 1rem;
        top: 1rem;
        height: auto;
        transform: translateY(-120%);
        transition: transform 0.25s ease;
        z-index: 20;
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .main-shell {
        padding: 1rem;
    }

    .mobile-only {
        display: inline-flex;
    }
}

@media (max-width: 720px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-actions,
    .search-form {
        width: 100%;
    }

    .button-row,
    .inline-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .footer-actions {
        align-items: stretch;
        flex-direction: column;
    }
}
