:root {
    --brand-blue: #1d73be;
    --brand-blue-dark: #155a96;
    --brand-blue-light: #3a8bc8;
    --brand-gold: #ec8b4b;
    --brand-gold-dark: #c96d2d;
    --brand-gold-light: #f0a770;
    --brand-copper: #e09a30;
    --brand-cream: #fdf8f0;
    --brand-ink: #2b1012;
    --surface: #ffffff;
    --page: #f6f3ef;
    --line: #e5dcdc;
    --muted: #766b6e;
    --danger: #a51d2d;
    --success: #2d6a45;
    --shadow: 0 2px 8px rgb(43 16 18 / 8%);
    color: #2b2226;
    background: var(--page);
    font-family:
        Inter,
        ui-sans-serif,
        system-ui,
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
    font-size: 15px;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    background: var(--page);
}

.callout {
    margin: 0 0 18px;
    padding: 12px 14px;
    border-left: 4px solid var(--brand-gold-dark);
    border-radius: 6px;
    background: #fff8d8;
    color: var(--brand-ink);
}

.inline-reason {
    display: flex;
    min-width: 260px;
    gap: 6px;
}

.inline-reason input {
    min-width: 145px;
}

.settings-section {
    display: grid;
    grid-template-columns: minmax(180px, 0.35fr) minmax(0, 1fr);
    gap: 24px;
    margin-bottom: 16px;
}

.settings-section h2 {
    margin-bottom: 5px;
}

.sticky-actions {
    position: sticky;
    bottom: 12px;
    display: flex;
    justify-content: flex-end;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgb(255 255 255 / 94%);
    box-shadow: var(--shadow);
}

.permission-role {
    margin-bottom: 12px;
}

.permission-role > summary {
    display: flex;
    cursor: pointer;
    justify-content: space-between;
    gap: 16px;
    padding: 4px 0 14px;
}

.permission-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 12px;
}

.permission-grid fieldset {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 7px;
}

.permission-grid legend {
    padding: 0 5px;
    color: var(--brand-blue);
    font-weight: 750;
}

.permission-grid .check-label {
    margin: 7px 0;
}

.color-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 6px;
}

.color-field .color-picker {
    width: 46px;
    height: 34px;
    padding: 2px;
    border: 1px solid #d7cbcb;
    border-radius: 6px;
    background: #ffffff;
    cursor: pointer;
}

.color-field .color-hex {
    width: 112px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-variant-numeric: tabular-nums;
}

.color-swatch {
    display: inline-block;
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    border: 1px solid rgb(0 0 0 / 15%);
    border-radius: 4px;
    vertical-align: middle;
    background-image:
        linear-gradient(45deg, #e2dcdc 25%, transparent 25%),
        linear-gradient(-45deg, #e2dcdc 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e2dcdc 75%),
        linear-gradient(-45deg, transparent 75%, #e2dcdc 75%);
    background-size: 10px 10px;
    background-position: 0 0, 0 5px, 5px -5px, -5px 0;
}

.color-swatch-lg {
    width: 34px;
    height: 34px;
    border-radius: 7px;
    box-shadow: inset 0 0 0 1px rgb(255 255 255 / 45%);
}

.color-current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}

.color-current code {
    padding: 2px 6px;
    background: #f2ecec;
    color: var(--brand-ink);
    font-size: 11.5px;
    font-weight: 700;
}

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

button,
a {
    -webkit-tap-highlight-color: transparent;
}

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

h1,
h2,
h3 {
    color: var(--brand-ink);
}

h2 {
    font-size: 18px;
}

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

code {
    padding: 2px 6px;
    border-radius: 4px;
    background: rgb(104 0 0 / 9%);
    color: var(--brand-blue);
    font-size: 0.95em;
    font-weight: 700;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.muted,
.page-subtitle,
.field-help {
    color: var(--muted);
}

.page-title {
    margin: 0;
    font-size: clamp(22px, 2vw, 27px);
    line-height: 1.2;
}

.page-subtitle {
    margin: 6px 0 0;
    font-size: 13px;
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.page-actions,
.form-actions,
.row-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.back-link {
    display: inline-block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    text-decoration: none;
}

.back-link:hover {
    color: var(--brand-blue);
}

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

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

.shell.shell-collapsed .sidebar {
    visibility: hidden;
    transform: translateX(-100%);
}

.sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    max-height: 100vh;
    overflow-y: auto;
    background: linear-gradient(
        180deg,
        var(--brand-blue-dark),
        var(--brand-blue)
    );
    color: #f5e9e9;
    transition:
        transform 160ms ease,
        visibility 160ms ease;
}

.sidebar-head {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 16px 14px;
    border-bottom: 1px solid rgb(255 255 255 / 14%);
    color: #ffffff;
    text-decoration: none;
}

.sidebar-head img {
    width: 44px;
    height: 44px;
    flex: 0 0 auto;
    padding: 2px;
    border-radius: 50%;
    background: #ffffff;
    object-fit: contain;
}

.sidebar-head strong,
.sidebar-head small {
    display: block;
}

.sidebar-head strong {
    font-size: 16px;
}

.sidebar-head small {
    margin-top: 2px;
    color: var(--brand-gold);
    font-size: 11px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.sidebar nav {
    padding: 8px 0 28px;
}

.nav-item {
    display: block;
    padding: 8px 18px;
    color: #eedcdc;
    font-size: 13.5px;
    text-decoration: none;
}

.nav-item:hover {
    background: rgb(255 255 255 / 9%);
    color: #ffffff;
}

.nav-item.active {
    background: var(--brand-gold);
    color: var(--brand-ink);
    font-weight: 700;
}

.nav-top {
    color: #ffffff;
    font-weight: 650;
}

.nav-group {
    margin: 0;
}

.nav-group summary {
    list-style: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-group-btn {
    display: flex;
    width: 100%;
    cursor: pointer;
    align-items: center;
    justify-content: space-between;
    padding: 10px 18px 8px;
    border: 0;
    background: none;
    color: var(--brand-gold-light);
    font-size: 11.5px;
    font-weight: 750;
    letter-spacing: 0.07em;
    text-align: left;
    text-transform: uppercase;
}

.nav-group-btn::after {
    content: "›";
    font-size: 18px;
    line-height: 1;
    transform: rotate(0deg);
    transition: transform 120ms ease;
}

.nav-group[open] .nav-group-btn::after {
    transform: rotate(90deg);
}

.nav-group-btn:hover {
    color: #ffffff;
}

.nav-sub .nav-item {
    padding-left: 28px;
}

.main {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 15;
    display: flex;
    align-items: center;
    gap: 16px;
    min-height: 61px;
    padding: 10px 20px;
    border-bottom: 3px solid var(--brand-gold);
    background: rgb(255 255 255 / 96%);
    box-shadow: 0 1px 5px rgb(43 16 18 / 6%);
    backdrop-filter: blur(8px);
}

.burger {
    padding: 4px 6px;
    border: 0;
    background: none;
    color: var(--brand-blue);
    cursor: pointer;
    font-size: 21px;
}

.global-search {
    width: min(520px, 50vw);
}

.global-search input,
.table-toolbar input {
    width: 100%;
}

.global-search input {
    padding: 9px 15px;
    border: 1px solid #ddd2d2;
    border-radius: 22px;
    background: #fbfafa;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
    font-weight: 600;
}

.topbar-user form {
    margin: 0;
}

.content {
    width: 100%;
    max-width: 1500px;
    padding: 26px;
}

.panel,
.chart-card,
.reports-list {
    border: 1px solid rgb(104 0 0 / 5%);
    border-radius: 11px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.panel,
.chart-card {
    padding: 20px;
}

.card-strip {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 12px;
    margin: 0 0 18px;
}

.stat-card {
    display: flex;
    min-width: 0;
    flex-direction: column;
    gap: 6px;
    padding: 15px 16px;
    border-left: 4px solid var(--brand-blue);
    border-radius: 9px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.stat-card.stat-warn {
    border-left-color: var(--brand-gold);
}

.stat-card.stat-accent {
    border-left-color: var(--brand-copper);
}

.stat-label {
    color: var(--muted);
    font-size: 11.5px;
    letter-spacing: 0.045em;
    text-transform: uppercase;
}

.stat-value {
    overflow: hidden;
    color: var(--brand-ink);
    font-size: 21px;
    font-weight: 750;
    text-overflow: ellipsis;
}

.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
    gap: 16px;
}

.chart-card h2 {
    margin-bottom: 16px;
}

.bars-v {
    display: flex;
    height: 180px;
    align-items: flex-end;
    gap: 8px;
}

.bars-v .bar-row {
    display: flex;
    height: 100%;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
}

.bar-track-v {
    position: relative;
    width: min(26px, 80%);
    height: 145px;
    overflow: hidden;
    border-radius: 5px 5px 0 0;
    background: #f1e7e7;
}

.bar-fill-v {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    min-height: 2px;
    border-radius: 5px 5px 0 0;
    background: linear-gradient(
        180deg,
        var(--brand-blue-light),
        var(--brand-blue)
    );
}

.bar-label-v {
    margin-top: 6px;
    color: var(--muted);
    font-size: 10px;
}

.bars-h {
    display: grid;
    gap: 9px;
}

.bars-h .bar-row {
    display: grid;
    grid-template-columns: minmax(80px, 145px) 1fr auto;
    align-items: center;
    gap: 9px;
}

.bar-label {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bar-track {
    height: 10px;
    overflow: hidden;
    border-radius: 5px;
    background: #f1e7e7;
}

.bar-fill {
    height: 100%;
    min-width: 2px;
    border-radius: 5px;
    background: var(--brand-blue);
}

.bar-value {
    color: var(--muted);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.table-toolbar {
    display: flex;
    align-items: center;
    gap: 9px;
    max-width: 650px;
    margin-bottom: 14px;
}

.table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: var(--surface);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    padding: 11px 13px;
    border-bottom: 1px solid #eee7e7;
    text-align: left;
    vertical-align: top;
}

th {
    background: #f8f2f2;
    color: var(--brand-blue);
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: 0.045em;
    text-transform: uppercase;
    white-space: nowrap;
}

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

tbody tr:hover td {
    background: #fffdf9;
}

.empty-row {
    padding: 28px;
    text-align: center;
}

.row-actions {
    justify-content: flex-end;
    white-space: nowrap;
}

.row-actions form {
    margin: 0;
}

.badge {
    display: inline-flex;
    padding: 2px 7px;
    border-radius: 999px;
    background: #ede7e7;
    color: #5f5658;
    font-size: 11px;
    font-weight: 700;
}

.badge-success {
    background: #e4f2e9;
    color: var(--success);
}

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 16px;
    color: var(--muted);
    font-size: 13px;
}

.btn-primary,
.btn-ghost,
.btn-danger,
.btn-link {
    display: inline-flex;
    min-height: 34px;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    text-decoration: none;
    transition:
        background 120ms ease,
        border-color 120ms ease,
        color 120ms ease;
}

.btn-primary {
    padding: 9px 15px;
    border: 1px solid var(--brand-blue);
    background: var(--brand-blue);
    color: #ffffff;
}

.btn-primary:hover {
    border-color: var(--brand-blue-dark);
    background: var(--brand-blue-dark);
}

.btn-ghost {
    padding: 8px 11px;
    border: 1px solid #d9cccc;
    background: #ffffff;
    color: var(--brand-blue);
}

.btn-ghost:hover {
    border-color: var(--brand-blue);
    background: #fff8f8;
}

.btn-danger {
    padding: 8px 11px;
    border: 1px solid #e4bdc3;
    background: #fff7f8;
    color: var(--danger);
}

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

.btn-link {
    min-height: auto;
    border: 0;
    background: transparent;
    color: var(--muted);
}

.btn-block {
    width: 100%;
}

.disabled {
    cursor: not-allowed;
    opacity: 0.48;
}

input,
select,
textarea {
    width: 100%;
    padding: 9px 11px;
    border: 1px solid #d7cbcb;
    border-radius: 6px;
    outline: none;
    background: #ffffff;
    color: #2b2226;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--brand-blue-light);
    box-shadow: 0 0 0 3px rgb(104 0 0 / 8%);
}

textarea {
    resize: vertical;
}

label > span:first-child {
    display: block;
    margin-bottom: 5px;
    color: #51474a;
    font-size: 12.5px;
    font-weight: 700;
}

.record-form {
    max-width: 980px;
}

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

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

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
}

.check-label input {
    width: auto;
    margin: 0;
    accent-color: var(--brand-blue);
}

.field-checkbox {
    align-self: end;
    min-height: 38px;
    padding-bottom: 8px;
    font-weight: 700;
}

.field-help,
.field-error {
    display: block;
    margin-top: 5px;
    font-size: 11px;
}

.password-control {
    position: relative;
    display: block;
}

.password-control input {
    padding-right: 58px;
}

.password-toggle {
    position: absolute;
    top: 50%;
    right: 8px;
    width: auto;
    padding: 4px 7px;
    border: 0;
    background: transparent;
    color: var(--brand-blue);
    font-size: 11px;
    font-weight: 800;
    cursor: pointer;
    transform: translateY(-50%);
}

.password-toggle:hover {
    text-decoration: underline;
}

.field-error,
.req {
    color: var(--danger);
}

.req {
    margin-left: 2px;
    font-style: normal;
}

.form-actions {
    justify-content: flex-end;
    margin-top: 22px;
    padding-top: 17px;
    border-top: 1px solid var(--line);
}

.roles-fieldset {
    margin: 24px 0 0;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.roles-fieldset legend {
    padding: 0 6px;
    color: var(--brand-ink);
    font-size: 14px;
    font-weight: 800;
}

.roles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 10px;
}

.flash,
.form-error {
    margin-bottom: 16px;
    padding: 12px 14px;
    border-radius: 7px;
    font-size: 13px;
}

.flash-success {
    border: 1px solid #b7dac3;
    background: #edf8f1;
    color: #275e3d;
}

.flash-warning {
    border: 1px solid #ead27a;
    background: #fff8d9;
    color: #6d5700;
}

.form-error {
    border: 1px solid #e3b9c0;
    background: #fff3f4;
    color: #8c1727;
}

.form-error ul {
    margin: 7px 0 0;
    padding-left: 20px;
}

.reports-layout {
    display: grid;
    grid-template-columns: 275px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.reports-list {
    max-height: calc(100vh - 130px);
    padding: 10px;
    overflow-y: auto;
}

.report-group {
    margin-bottom: 15px;
}

.report-group h2 {
    margin: 8px 8px 5px;
    color: var(--muted);
    font-size: 10.5px;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.report-item {
    display: block;
    padding: 8px 9px;
    border-radius: 6px;
    color: #51474a;
    font-size: 12.5px;
    text-decoration: none;
}

.report-item:hover,
.report-item.active {
    background: rgb(104 0 0 / 8%);
    color: var(--brand-blue);
}

.report-item.active {
    font-weight: 750;
}

.report-result {
    min-width: 0;
    min-height: 330px;
}

.empty-state {
    display: grid;
    min-height: 220px;
    place-content: center;
    text-align: center;
}

.empty-state h2 {
    margin-bottom: 6px;
}

.search-results {
    display: grid;
    gap: 16px;
}

.login-wrap {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 28px 16px;
    background: linear-gradient(135deg, var(--brand-blue-dark), var(--brand-blue) 45%, var(--brand-gold));
}

.login-card {
    width: min(420px, 100%);
    padding: 31px;
    border-top: 5px solid var(--brand-gold);
    border-radius: 13px;
    background: rgb(255 255 255 / 98%);
    box-shadow: 0 20px 55px rgb(0 0 0 / 28%);
}

.login-logo {
    display: block;
    width: 92px;
    height: 92px;
    margin: 0 auto 10px;
    object-fit: contain;
}

.login-card h1 {
    margin-bottom: 4px;
    text-align: center;
}

.login-sub {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 12.5px;
    text-align: center;
}

.login-card > label:not(.check-label) {
    display: block;
    margin-bottom: 15px;
    color: #51474a;
    font-size: 12.5px;
    font-weight: 700;
}

.login-card > label input {
    margin-top: 6px;
}

.login-card .check-label {
    margin: 4px 0 16px;
}

.login-forgot {
    margin: 14px 0 0;
    font-size: 12.5px;
    text-align: center;
}

.login-forgot a {
    color: var(--brand-blue);
    font-weight: 700;
    text-decoration: none;
}

.login-forgot a:hover {
    text-decoration: underline;
}

.login-foot {
    margin: 18px 0 0;
    color: var(--muted);
    font-size: 10.5px;
    text-align: center;
}

@media (max-width: 900px) {
    .shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: 268px;
        box-shadow: 8px 0 24px rgb(0 0 0 / 24%);
    }

    .shell.shell-collapsed .sidebar {
        visibility: hidden;
    }

    .reports-layout {
        grid-template-columns: 1fr;
    }

    .reports-list {
        max-height: none;
    }

    .settings-section {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 650px) {
    .content {
        padding: 18px 14px;
    }

    .topbar {
        gap: 8px;
        padding: 9px 12px;
    }

    .global-search {
        width: auto;
        flex: 1;
    }

    .topbar-user > span {
        display: none;
    }

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

    .page-actions {
        flex-wrap: wrap;
    }

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

    .span-2 {
        grid-column: auto;
    }

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

    .bars-h .bar-row {
        grid-template-columns: 90px 1fr auto;
    }

    .table-toolbar {
        align-items: stretch;
        flex-wrap: wrap;
    }

    .table-toolbar input {
        flex-basis: 100%;
    }

    .inline-reason {
        min-width: 200px;
        flex-direction: column;
    }

    .login-card {
        padding: 25px 20px;
    }
}
