:root {
    --bg: #f6f7fb;
    --panel: #ffffff;
    --line: #e6e8ef;
    --text: #1f2430;
    --muted: #6d7482;
    --brand: #CB2F24;
    --brand-dark: #9f2119;
    --brand-soft: #fff0ee;
    --accent: #f3b33d;
    --danger: #b42318;
    --success: #16803c;
    --sidebar: #211c1c;
    --sidebar-muted: #cfc8c7;
    --shadow: 0 18px 45px rgba(33, 28, 28, 0.08);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 14px;
    margin: 0;
}

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

a:hover {
    color: var(--brand);
}

.app-shell {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: 100vh;
    transition: grid-template-columns 0.22s ease;
}

.sidebar {
    background:
        linear-gradient(180deg, rgba(203, 47, 36, 0.18), rgba(203, 47, 36, 0) 260px),
        var(--sidebar);
    color: #ffffff;
    padding: 26px 20px;
}

.brand,
.auth-heading {
    align-items: center;
    display: flex;
    gap: 12px;
}

.brand {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 8px 22px;
    position: relative;
}

.brand-mark {
    align-items: center;
    background: var(--brand);
    border-radius: 8px;
    box-shadow: 0 14px 32px rgba(203, 47, 36, 0.3);
    color: #ffffff;
    display: inline-flex;
    flex: 0 0 auto;
    font-size: 20px;
    font-weight: 800;
    height: 46px;
    justify-content: center;
    width: 46px;
}

.login-logo-wrap {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 16px 36px rgba(203, 47, 36, 0.14);
    display: inline-flex;
    flex: 0 0 auto;
    height: 58px;
    justify-content: center;
    padding: 8px;
    width: 58px;
}

.login-logo {
    display: block;
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
}

.brand strong,
.brand small,
.auth-heading h1 {
    display: block;
}

.brand strong {
    font-size: 16px;
    letter-spacing: 0;
}

.brand small {
    color: var(--sidebar-muted);
    font-size: 12px;
    margin-top: 3px;
}

.nav-menu {
    display: grid;
    gap: 5px;
    margin-top: 22px;
}

.nav-menu a {
    align-items: center;
    border-radius: 8px;
    color: #ece8e7;
    display: flex;
    font-weight: 700;
    gap: 12px;
    min-height: 42px;
    padding: 10px 12px;
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-menu a i {
    color: #ffb5af;
    font-size: 17px;
    width: 20px;
}

.nav-menu a.active,
.nav-menu a:hover {
    background: #ffffff;
    color: var(--brand);
    transform: translateX(2px);
}

.nav-menu a.active i,
.nav-menu a:hover i {
    color: var(--brand);
}

.mobile-menu-toggle,
.sidebar-close {
    align-items: center;
    border-radius: 8px;
    display: none;
    height: 42px;
    justify-content: center;
    min-height: 42px;
    padding: 0;
    width: 42px;
}

.mobile-menu-toggle {
    background: #ffffff;
    border: 1px solid var(--line);
    box-shadow: none;
    color: var(--brand);
    flex: 0 0 auto;
    font-size: 23px;
}

.mobile-menu-toggle:hover {
    background: var(--brand-soft);
    border-color: #ffc8c2;
    color: var(--brand);
    transform: none;
}

.sidebar-close {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: none;
    color: #ffffff;
    font-size: 18px;
    margin-left: auto;
}

.sidebar-close:hover {
    background: #ffffff;
    border-color: #ffffff;
    color: var(--brand);
    transform: none;
}

.sidebar-backdrop {
    background: rgba(17, 24, 39, 0.48);
    display: none;
    inset: 0;
    position: fixed;
    z-index: 1030;
}

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

.topbar {
    align-items: center;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 20px;
    padding: 18px 20px;
}

.topbar-title {
    align-items: center;
    display: flex;
    gap: 12px;
    min-width: 0;
}

.app-body:not(.sidebar-open) .mobile-menu-toggle {
    display: inline-flex;
}

.sidebar-collapsed .app-shell {
    grid-template-columns: 88px minmax(0, 1fr);
}

.sidebar-collapsed .sidebar {
    padding-left: 14px;
    padding-right: 14px;
}

.sidebar-collapsed .brand {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-collapsed .brand > div,
.sidebar-collapsed .nav-menu a span {
    display: none;
}

.sidebar-collapsed .nav-menu a {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-collapsed .nav-menu a i {
    font-size: 18px;
    width: auto;
}

.topbar h1,
.auth-heading h1 {
    color: #171923;
    font-size: 26px;
    font-weight: 800;
    line-height: 1.2;
    margin: 0;
}

.eyebrow {
    color: var(--brand);
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0;
    margin: 0 0 6px;
    text-transform: uppercase;
}

.user-menu {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.user-menu span {
    align-items: center;
    background: #f8f9fb;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #313744;
    display: inline-flex;
    font-weight: 700;
    gap: 8px;
    min-height: 42px;
    padding: 9px 12px;
}

.user-menu a,
button,
.button-link {
    align-items: center;
    background: var(--brand);
    border: 1px solid var(--brand);
    border-radius: 8px;
    box-shadow: 0 10px 22px rgba(203, 47, 36, 0.18);
    color: #ffffff;
    cursor: pointer;
    display: inline-flex;
    font-weight: 800;
    gap: 8px;
    justify-content: center;
    min-height: 42px;
    padding: 10px 16px;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.user-menu a:hover,
button:hover,
.button-link:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #ffffff;
    transform: translateY(-1px);
}

.button-link-light {
    background: var(--brand-soft);
    border-color: #ffc8c2;
    box-shadow: none;
    color: var(--brand);
}

.button-link-light:hover {
    background: #ffe2de;
    border-color: #ffb4ad;
    color: var(--brand-dark);
}

.button-link.icon-only,
.icon-button {
    align-items: center;
    border-radius: 8px;
    display: inline-flex;
    flex: 0 0 auto;
    height: 38px;
    justify-content: center;
    min-height: 38px;
    padding: 0;
    width: 38px;
}

.icon-button {
    background: var(--brand-soft);
    border: 1px solid #ffc8c2;
    color: var(--brand);
    font-size: 16px;
}

.icon-button:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

.icon-button-muted {
    background: #f1f3f7;
    border-color: #e0e4ec;
    color: #525b6a;
}

.icon-button-muted:hover {
    background: #525b6a;
    border-color: #525b6a;
    color: #ffffff;
}

.icon-button-danger {
    background: #fff0ee;
    border-color: #ffc8c2;
    color: var(--danger);
}

.icon-button-danger:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: #ffffff;
}

.actions .icon-button,
.actions .icon-button:hover {
    text-decoration: none;
}

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

.dashboard-hero {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(203, 47, 36, 0.96), rgba(159, 33, 25, 0.92)),
        var(--brand);
    border-radius: 8px;
    box-shadow: var(--shadow);
    color: #ffffff;
    display: flex;
    gap: 18px;
    justify-content: space-between;
    margin-bottom: 16px;
    overflow: hidden;
    padding: 24px;
    position: relative;
}

.dashboard-hero::after {
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    content: "";
    height: 210px;
    position: absolute;
    right: -64px;
    top: -76px;
    width: 210px;
}

.dashboard-hero-copy,
.dashboard-hero-meta {
    position: relative;
    z-index: 1;
}

.dashboard-hero-copy span {
    align-items: center;
    display: inline-flex;
    font-size: 12px;
    font-weight: 800;
    gap: 8px;
    opacity: 0.9;
    text-transform: uppercase;
}

.dashboard-hero h2 {
    font-size: 28px;
    font-weight: 800;
    margin: 8px 0;
}

.dashboard-hero p {
    color: rgba(255, 255, 255, 0.86);
    margin: 0;
    max-width: 680px;
}

.dashboard-hero-meta {
    background: rgba(255, 255, 255, 0.13);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    min-width: 180px;
    padding: 14px;
    text-align: right;
}

.dashboard-hero-meta strong,
.dashboard-hero-meta span {
    display: block;
}

.dashboard-hero-meta span {
    color: rgba(255, 255, 255, 0.78);
    margin-top: 4px;
}

.dashboard-summary {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}

.metric-card,
.panel,
.auth-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.metric-card {
    min-height: 142px;
    overflow: hidden;
    padding: 18px;
    position: relative;
}

.metric-card::before {
    background: var(--brand);
    content: "";
    height: 100%;
    left: 0;
    position: absolute;
    top: 0;
    width: 4px;
}

.metric-card span,
.metric-card p {
    color: var(--muted);
}

.metric-card span {
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.metric-card strong {
    color: #171923;
    display: block;
    font-size: 30px;
    font-weight: 800;
    margin: 14px 0 8px;
}

.metric-card p {
    line-height: 1.5;
    margin: 0;
}

.metric-card-rich {
    padding-right: 78px;
}

.metric-icon {
    align-items: center;
    background: var(--brand-soft);
    border-radius: 8px;
    color: var(--brand);
    display: inline-flex;
    font-size: 22px;
    height: 48px;
    justify-content: center;
    position: absolute;
    right: 18px;
    top: 18px;
    width: 48px;
}

.quick-actions {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    margin: 0 0 16px;
}

.quick-actions a {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 10px 24px rgba(33, 28, 28, 0.05);
    color: #313744;
    display: flex;
    font-weight: 800;
    gap: 10px;
    min-height: 54px;
    padding: 12px 14px;
}

.quick-actions a i {
    align-items: center;
    background: var(--brand-soft);
    border-radius: 8px;
    color: var(--brand);
    display: inline-flex;
    height: 34px;
    justify-content: center;
    width: 34px;
}

.quick-actions a:hover {
    border-color: #ffc8c2;
    color: var(--brand);
    transform: translateY(-1px);
}

.content-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
    margin-top: 16px;
}

.align-start {
    align-items: start;
}

.panel {
    margin-bottom: 16px;
    padding: 20px;
}

.narrow-panel {
    max-width: 820px;
}

.panel-heading {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 14px;
}

.panel-heading h2 {
    color: #171923;
    font-size: 18px;
    font-weight: 800;
    margin: 0;
}

.panel-heading span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.flow-list {
    color: #404756;
    line-height: 1.75;
    margin: 0;
    padding-left: 20px;
}

.status-list {
    display: grid;
    gap: 12px;
}

.status-list div {
    align-items: center;
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    padding-bottom: 12px;
}

.status-list div:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.status-list span {
    color: var(--muted);
}

.detail-list span {
    text-align: right;
}

.panel-actions {
    border-top: 1px solid var(--line);
    margin-top: 18px;
    padding-top: 18px;
}

.auth-page {
    align-items: center;
    background:
        linear-gradient(135deg, rgba(203, 47, 36, 0.13), rgba(255, 255, 255, 0) 42%),
        var(--bg);
    display: grid;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    justify-self: center;
    max-width: 450px;
    padding: 30px;
    width: 100%;
}

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

.form-stack {
    display: grid;
    gap: 16px;
    margin-top: 20px;
}

.form-stack label {
    display: grid;
    gap: 8px;
}

.form-stack span {
    color: #4a5160;
    font-size: 13px;
    font-weight: 800;
}

.form-stack input,
.form-stack select,
.form-stack textarea {
    background: #ffffff;
    border: 1px solid #d9dde7;
    border-radius: 8px;
    color: var(--text);
    font: inherit;
    min-height: 42px;
    padding: 10px 12px;
    width: 100%;
}

.form-stack textarea {
    min-height: 104px;
}

.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 4px rgba(203, 47, 36, 0.12);
    outline: 0;
}

.input-icon {
    position: relative;
}

.input-icon i {
    color: var(--brand);
    left: 13px;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.input-icon input {
    padding-left: 40px;
}

.form-wide button {
    justify-self: start;
    width: auto;
}

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

.span-2 {
    grid-column: 1 / -1;
}

.form-stack button {
    font: inherit;
    width: 100%;
}

.alert {
    border: 1px solid transparent;
    border-radius: 8px;
    display: block;
    line-height: 1.5;
    margin-bottom: 18px;
    margin-top: 18px;
    padding: 12px 14px;
}

.alert i {
    margin-right: 8px;
}

.alert div + div {
    margin-top: 6px;
}

.alert-error {
    background: #fff0ee;
    border-color: #ffc8c2;
    color: var(--danger);
}

.alert-success {
    background: #eefaf1;
    border-color: #bee9c9;
    color: var(--success);
}

.hint {
    color: var(--muted);
    font-size: 13px;
    margin: 18px 0 0;
}

.table-wrap {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

.pagination-wrap {
    display: flex;
    justify-content: flex-end;
    margin-top: 16px;
}

.pagination-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.pagination-list a {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #525b6a;
    display: inline-flex;
    font-weight: 800;
    height: 38px;
    justify-content: center;
    min-width: 38px;
    padding: 0 12px;
}

.pagination-list a.active,
.pagination-list a:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.tabs a {
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: #525b6a;
    font-weight: 800;
    padding: 10px 13px;
}

.tabs a.active,
.tabs a:hover {
    background: var(--brand);
    border-color: var(--brand);
    color: #ffffff;
}

table {
    background: #ffffff;
    border-collapse: collapse;
    margin: 0;
    width: 100%;
}

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

tbody tr:hover {
    background: #fff8f7;
}

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

th {
    background: #fafbfc;
    color: #6b7280;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

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

code {
    background: var(--brand-soft);
    border-radius: 6px;
    color: var(--brand-dark);
    display: inline-block;
    font-size: 13px;
    padding: 4px 7px;
}

.badge {
    background: var(--brand-soft);
    border-radius: 999px;
    color: var(--brand-dark);
    display: inline-block;
    font-size: 12px;
    font-weight: 800;
    padding: 6px 10px;
}

.badge-muted {
    background: #f1f3f7;
    color: var(--muted);
}

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

.actions form {
    margin: 0;
}

.actions a,
.text-link {
    color: var(--brand);
    font-weight: 800;
}

.actions a.button-link,
.actions a.button-link:hover,
.actions a.icon-button:hover {
    color: #ffffff;
}

.actions a.icon-button {
    color: var(--brand);
}

.actions a.icon-button-muted {
    color: #525b6a;
}

.actions a.icon-button-danger {
    color: var(--danger);
}

.actions a.button-link-light {
    color: var(--brand);
}

.actions a.button-link-light:hover {
    color: var(--brand-dark);
}

.link-danger {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--danger);
    font: inherit;
    min-height: 0;
    padding: 0;
}

.link-danger:hover {
    background: transparent;
    color: var(--brand-dark);
    transform: none;
}

.text-button {
    background: transparent;
    border: 0;
    box-shadow: none;
    color: var(--brand);
    font: inherit;
    min-height: 0;
    padding: 0;
}

.text-button:hover {
    background: transparent;
    color: var(--brand-dark);
    transform: none;
}

.checkbox-list {
    display: grid;
    gap: 10px;
}

.checkbox-list h3 {
    border-top: 1px solid var(--line);
    font-size: 14px;
    font-weight: 800;
    margin: 14px 0 2px;
    padding-top: 14px;
}

.checkbox-list h3:first-of-type {
    border-top: 0;
    margin-top: 0;
    padding-top: 0;
}

.check-row {
    align-items: center;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    gap: 12px;
    padding: 12px;
}

.check-row input {
    accent-color: var(--brand);
    height: 18px;
    width: 18px;
}

.check-row span {
    display: grid;
    gap: 3px;
}

.check-row small {
    color: var(--muted);
}

.checkbox-list button {
    justify-self: start;
    margin-top: 8px;
    width: auto;
}

details summary {
    color: var(--brand);
    cursor: pointer;
    font-weight: 800;
}

pre {
    background: #171923;
    border-radius: 8px;
    color: #f8fafc;
    margin-top: 10px;
    padding: 12px;
}

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

    .sidebar-collapsed .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        bottom: 0;
        box-shadow: 24px 0 50px rgba(17, 24, 39, 0.22);
        left: 0;
        max-width: 86vw;
        overflow-y: auto;
        position: fixed;
        top: 0;
        transform: translateX(-105%);
        transition: transform 0.22s ease;
        width: 292px;
        z-index: 1040;
    }

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

    .mobile-menu-toggle,
    .sidebar-close {
        display: inline-flex;
    }

    .sidebar-collapsed .brand > div,
    .sidebar-collapsed .nav-menu a span {
        display: block;
    }

    .sidebar-collapsed .brand {
        justify-content: flex-start;
    }

    .sidebar-collapsed .nav-menu a {
        justify-content: flex-start;
        padding-left: 12px;
        padding-right: 12px;
    }

    .sidebar-open {
        overflow: hidden;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-open .sidebar-backdrop {
        display: block;
    }
}

@media (max-width: 980px) {
    .summary-grid,
    .content-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .main-panel,
    .sidebar {
        padding: 18px;
    }

    .topbar,
    .panel-heading,
    .status-list div {
        align-items: flex-start;
        flex-direction: column;
    }

    .topbar-title {
        align-items: flex-start;
        width: 100%;
    }

    .topbar-title h1 {
        font-size: 22px;
    }

    .dashboard-hero {
        align-items: flex-start;
        flex-direction: column;
        padding: 20px;
    }

    .dashboard-hero h2 {
        font-size: 24px;
    }

    .dashboard-hero-meta {
        text-align: left;
        width: 100%;
    }

    .user-menu {
        justify-content: flex-start;
        width: 100%;
    }

    .user-menu span,
    .user-menu a {
        width: 100%;
    }
}
