:root {
    --navy: #1C3A6B;
    --navy2: #0F1E30;
    --navy3: #162D54;
    --gold: #C8980E;
    --gold2: #E8B832;
    --teal: #0C6E5E;
    --teal2: #0A5A4C;
    --red: #C0392B;
    --orange: #E67E22;
    --green: #1E8449;
    --purple: #6C3483;
    --white: #FFFFFF;
    --bg: #F0F4F8;
    --bg2: #E8EDF4;
    --card: #FFFFFF;
    --border: #D4DCE8;
    --text: #1C2B3A;
    --muted: #6A7A8A;
    --sidebar-w: 312px;
}

* {
    box-sizing: border-box;
}

html {
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: "DM Sans", Arial, sans-serif;
    font-size: 16px;
    overflow-x: hidden;
}

a {
    color: inherit;
}

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

.auth-block {
    max-width: 520px;
    margin: 12vh auto;
    padding: 32px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 8px 28px rgba(15, 30, 48, .12);
}

.auth-block h1 {
    margin: 0 0 8px;
    color: var(--navy);
    font-family: "DM Serif Display", serif;
}

.auth-logo {
    display: block;
    width: 92px;
    height: 92px;
    margin: 0 0 22px;
    object-fit: contain;
}

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: linear-gradient(180deg, var(--navy2) 0%, #132947 100%);
    display: flex;
    flex-direction: column;
    min-height: 0;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0, 0, 0, .2);
}

.sidebar-brand {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}

.sidebar-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
}

.sidebar-brand-mark {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    padding: 6px;
    background: #fff;
    border: 1px solid rgba(200, 152, 14, .38);
    border-radius: 6px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, .16);
}

.sidebar-brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-brand-text {
    min-width: 0;
}

.sidebar-brand-name {
    display: block;
    color: #fff;
    font-family: "DM Serif Display", serif;
    font-size: 22px;
    letter-spacing: 0;
    line-height: 1.2;
}

.sidebar-brand-sub {
    display: block;
    margin-top: 4px;
    color: var(--gold);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 1.6px;
    text-transform: uppercase;
}

.sidebar-user {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 4px 12px;
    padding: 14px 20px;
    border-top: 1px solid rgba(255, 255, 255, .08);
    background: rgba(15, 30, 48, .2);
}

.sidebar-user-role {
    color: var(--gold);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.sidebar-user-name {
    min-width: 0;
    margin-top: 0;
    color: rgba(255, 255, 255, .85);
    font-size: 15px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sidebar-logout-form {
    grid-column: 2;
    grid-row: 1 / span 2;
    margin: 0;
}

.sidebar-logout {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, .14);
    border-radius: 6px;
    background: transparent;
    color: rgba(255, 255, 255, .76);
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.sidebar-logout .nav-icon {
    width: auto;
    font-size: 16px;
}

.sidebar-logout-text {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.sidebar-logout:hover {
    background: rgba(255, 255, 255, .08);
    border-color: rgba(200, 152, 14, .45);
    color: #fff;
}

.sidebar-nav {
    flex: 1;
    min-height: 0;
    padding: 10px 12px 16px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, .22) transparent;
}

.nav-section {
    margin: 0 0 6px;
}

.nav-section-label {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    min-height: 36px;
    padding: 0 10px 0 12px;
    border-radius: 6px;
    color: rgba(255, 255, 255, .48);
    cursor: pointer;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.8px;
    list-style: none;
    text-transform: uppercase;
    transition: background .15s, color .15s;
}

.nav-section-label::-webkit-details-marker {
    display: none;
}

.nav-section-label::after {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 2px solid rgba(255, 255, 255, .38);
    border-bottom: 2px solid rgba(255, 255, 255, .38);
    transform: rotate(45deg);
    transition: transform .15s, border-color .15s;
}

.nav-section[open] .nav-section-label::after {
    transform: rotate(225deg);
}

.nav-section-label:hover::after,
.nav-section[open] .nav-section-label::after {
    border-color: rgba(255, 255, 255, .72);
}

.nav-section-label:hover,
.nav-section[open] .nav-section-label {
    background: rgba(255, 255, 255, .06);
    color: rgba(255, 255, 255, .82);
}

.nav-section-items {
    padding: 4px 0 6px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 38px;
    padding: 8px 10px 8px 12px;
    border-radius: 6px;
    color: rgba(255, 255, 255, .66);
    cursor: pointer;
    font-size: 15px;
    font-weight: 500;
    text-decoration: none;
    transition: background .15s, color .15s, box-shadow .15s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, .06);
    color: #fff;
}

.nav-item.active {
    background: rgba(200, 152, 14, .16);
    box-shadow: inset 3px 0 0 var(--gold);
    color: #fff;
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 22px;
    color: currentColor;
    text-align: center;
}

.nav-icon-svg {
    display: block;
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sidebar-logout .nav-icon-svg {
    width: 17px;
    height: 17px;
}

.mobile-nav-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 130;
    width: 48px;
    height: 48px;
    border: 0;
    border-radius: 4px;
    background: var(--navy);
    color: #fff;
    box-shadow: 0 4px 16px rgba(15, 30, 48, .2);
}

.main {
    min-height: 100vh;
    margin-left: var(--sidebar-w);
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    min-height: 98px;
    padding: 18px 48px;
    background: #fff;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.topbar-title {
    color: var(--navy);
    font-family: "DM Serif Display", serif;
    font-size: 30px;
    line-height: 1.1;
}

.topbar-sub {
    margin-top: 6px;
    color: var(--muted);
    font-size: 17px;
}

.topbar-actions,
.toolbar {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.page {
    padding: 78px 48px;
}

.page-band {
    margin-bottom: 34px;
}

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

.kpi-card {
    position: relative;
    overflow: hidden;
    min-height: 136px;
    padding: 30px 34px;
    background: #fff;
    border-left: 5px solid var(--navy);
    border-radius: 4px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
}

.kpi-card::after {
    content: "";
    position: absolute;
    top: -10px;
    right: -10px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(28, 58, 107, .04);
}

.kpi-card.gold-border {
    border-left-color: var(--gold);
}

.kpi-card.teal-border {
    border-left-color: var(--teal);
}

.kpi-card.red-border {
    border-left-color: var(--red);
}

.kpi-label {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.kpi-value {
    margin: 8px 0;
    color: var(--navy);
    font-family: "DM Serif Display", serif;
    font-size: 36px;
    font-weight: 700;
    line-height: 1.1;
}

.kpi-change {
    color: var(--green);
    font-size: 15px;
    font-weight: 500;
}

.kpi-change.down {
    color: var(--red);
}

.two-col,
.three-col {
    display: grid;
    gap: 30px;
    margin-bottom: 34px;
}

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

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

.card,
.table-wrap {
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 1px 8px rgba(0, 0, 0, .06);
}

.card {
    padding: 31px 33px;
}

.card-header,
.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
}

.card-header {
    margin-bottom: 24px;
}

.card-title,
.table-title {
    color: var(--navy);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.18;
}

.card-sub,
.table-subtitle {
    margin-top: 5px;
    color: var(--muted);
    font-size: 17px;
}

.table-wrap {
    overflow: hidden;
    margin-bottom: 34px;
}

.table-header {
    min-height: 99px;
    padding: 25px 32px;
    border-bottom: 1px solid var(--border);
}

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

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

.table-scroll table:not(.permission-matrix) {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

thead tr {
    background: var(--navy2);
}

thead th {
    padding: 12px 14px;
    color: rgba(255, 255, 255, .72);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .7px;
    line-height: 1.25;
    text-align: left;
    text-transform: uppercase;
    overflow-wrap: normal;
    white-space: nowrap;
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background .1s;
}

tbody tr:hover {
    background: var(--bg);
}

tbody td {
    padding: 12px 14px;
    color: var(--text);
    font-size: 14px;
    line-height: 1.35;
    overflow-wrap: break-word;
    vertical-align: middle;
}

.table-scroll table:not(.permission-matrix) th:last-child,
.table-scroll table:not(.permission-matrix) td:last-child {
    width: 132px;
}

.table-scroll table:not(.permission-matrix) td:last-child .btn,
.table-scroll table:not(.permission-matrix) td:last-child .toggle-switch {
    margin: 2px 4px 2px 0;
}

.table-scroll table:not(.permission-matrix) .btn-sm {
    min-height: 32px;
    padding: 6px 10px;
    font-size: 13px;
}

.table-scroll table:not(.permission-matrix) .badge {
    max-width: 100%;
    padding: 4px 8px;
    font-size: 10px;
    letter-spacing: .2px;
    line-height: 1.15;
    text-align: center;
    white-space: normal;
}

.table-scroll table:not(.permission-matrix) .td-mono,
.table-scroll table:not(.permission-matrix) .mono {
    font-size: 13px;
}

.permission-matrix {
    width: max-content;
    min-width: 100%;
    table-layout: auto;
}

.permission-matrix thead tr {
    background: #DADADA;
}

.permission-matrix th,
.permission-matrix td {
    padding: 8px 12px;
    font-size: 14px;
    text-align: center;
    vertical-align: middle;
}

.permission-matrix thead th {
    color: #000;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0;
    text-transform: none;
}

.permission-matrix .permission-label-header,
.permission-matrix .permission-row-label {
    position: sticky;
    left: 0;
    z-index: 2;
    width: 260px;
    min-width: 260px;
    text-align: left;
}

.permission-matrix .permission-label-header {
    z-index: 3;
    background: #DADADA;
}

.permission-matrix .permission-row-label {
    background: #fff;
    color: var(--text);
    font-weight: 700;
}

.permission-matrix tbody tr:hover .permission-row-label {
    background: var(--bg);
}

.permission-role-header {
    width: 130px;
    min-width: 130px;
    text-align: center;
    white-space: normal;
}

.permission-role-header .td-mono {
    margin-top: 4px;
    color: #666;
    font-size: 11px;
}

.permission-module-row th {
    padding: 10px 12px;
    background: var(--bg2);
    color: var(--navy);
    font-size: 15px;
    text-align: left;
}

.permission-module-row.is-open th {
    background: #DFE7F2;
}

.permission-accordion-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 28px;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font: inherit;
    text-align: left;
}

.permission-accordion-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    border-radius: 3px;
    background: var(--navy);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    line-height: 1;
}

.permission-accordion-toggle span:not(.permission-accordion-icon) {
    color: var(--muted);
    font-size: 12px;
    font-weight: 600;
}

.permission-module-row .td-mono {
    color: var(--muted);
    font-size: 12px;
}

.permission-check-cell {
    width: 130px;
    min-width: 130px;
}

.permission-check {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--navy);
    cursor: pointer;
}

.permission-check:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.permission-bulk-row th,
.permission-bulk-row td {
    background: rgba(12, 110, 94, .06);
}

.permission-bulk-row .permission-row-label {
    color: var(--teal);
}

.permission-matrix-row:nth-child(even) td,
.permission-matrix-row:nth-child(even) .permission-row-label {
    background: rgba(232, 237, 244, .45);
}

.permission-matrix-row.permission-bulk-row td,
.permission-matrix-row.permission-bulk-row .permission-row-label {
    background: rgba(12, 110, 94, .06);
}

.permission-card-list {
    display: none;
}

.permission-module-card {
    padding: 20px 22px;
    border-top: 1px solid var(--border);
}

.permission-module-card-head {
    display: flex;
    align-items: baseline;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 0;
}

.permission-module-card.is-open .permission-module-card-head {
    margin-bottom: 16px;
}

.permission-module-card-head strong {
    color: var(--navy);
    font-size: 18px;
}

.permission-module-card-head span:not(.td-mono):not(.permission-accordion-icon) {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.permission-card-scroll {
    overflow-x: auto;
}

.permission-card-grid {
    display: grid;
    min-width: 560px;
    align-items: center;
}

.permission-card-grid-head {
    background: var(--bg2);
    color: var(--navy);
    font-size: 12px;
    font-weight: 700;
    text-align: center;
}

.permission-card-grid > div {
    min-height: 36px;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.permission-card-label {
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
}

.permission-card-bulk-row > div {
    background: rgba(12, 110, 94, .06);
}

.permission-card-bulk-row .permission-card-label {
    color: var(--teal);
}

.permission-card-check {
    text-align: center;
}

.td-mono,
.mono {
    font-family: "DM Mono", monospace;
    font-size: 15px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 43px;
    padding: 10px 20px;
    border: 0;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, opacity .15s;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.btn-primary {
    background: var(--navy);
    color: #fff;
}

.btn-primary:hover {
    background: var(--navy3);
}

.btn-gold {
    background: var(--gold);
    color: #fff;
}

.btn-gold:hover {
    background: var(--gold2);
    color: var(--navy2);
}

.btn-ghost {
    background: transparent;
    border: 1.5px solid var(--border);
    color: var(--navy);
}

.btn-ghost:hover {
    background: var(--bg);
    border-color: var(--navy);
}

.btn-danger {
    background: var(--red);
    color: #fff;
}

.btn-teal {
    background: var(--teal);
    color: #fff;
}

.btn-sm {
    min-height: 43px;
    padding: 10px 18px;
    font-size: 16px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 3px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .5px;
    text-transform: uppercase;
    white-space: nowrap;
}

.badge-active,
.badge-paid,
.badge-verified,
.badge-approved,
.badge-complete,
.badge-disbursed,
.badge-ready {
    background: rgba(30, 132, 73, .1);
    color: var(--green);
}

.badge-pending,
.badge-submitted,
.badge-partial,
.badge-in-progress,
.badge-watch,
.badge-held,
.badge-incomplete {
    background: rgba(230, 126, 34, .12);
    color: var(--orange);
}

.badge-closed,
.badge-cancelled,
.badge-archived,
.badge-waived {
    background: rgba(106, 122, 138, .12);
    color: var(--muted);
}

.badge-overdue,
.badge-rejected,
.badge-loss,
.badge-written-off {
    background: rgba(192, 57, 43, .1);
    color: var(--red);
}

.badge-new,
.badge-draft,
.badge-returned {
    background: rgba(28, 58, 107, .1);
    color: var(--navy);
}

.badge-gold {
    background: rgba(200, 152, 14, .12);
    color: var(--gold);
}

.toggle-switch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    cursor: pointer;
    vertical-align: middle;
}

.toggle-switch:disabled {
    cursor: not-allowed;
    opacity: .55;
}

.toggle-switch-track {
    position: relative;
    display: block;
    width: 42px;
    height: 24px;
    border: 1px solid rgba(106, 122, 138, .35);
    border-radius: 999px;
    background: #DDE4EC;
    transition: background .16s, border-color .16s, box-shadow .16s;
}

.toggle-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 4px rgba(15, 30, 48, .25);
    transition: transform .16s;
}

.toggle-switch.is-on .toggle-switch-track {
    border-color: var(--teal);
    background: var(--teal);
}

.toggle-switch.is-on .toggle-switch-thumb {
    transform: translateX(18px);
}

.toggle-switch:hover .toggle-switch-track,
.toggle-switch:focus-visible .toggle-switch-track {
    box-shadow: 0 0 0 3px rgba(12, 110, 94, .16);
}

.toggle-switch:focus-visible {
    outline: none;
}

.toggle-switch-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    padding: 8px 14px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
}

.search-box input {
    width: min(220px, 45vw);
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--text);
    font-size: 16px;
}

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

.permission-grant-grid {
    grid-template-columns:
        minmax(180px, 1.1fr)
        minmax(230px, 1.35fr)
        minmax(140px, .75fr)
        minmax(150px, .85fr)
        minmax(150px, .75fr);
    align-items: end;
}

.permission-grant-grid .form-group {
    margin-bottom: 0;
}

.form-group {
    margin-bottom: 20px;
}

.form-group.full {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.required {
    color: var(--red);
}

.form-control {
    width: 100%;
    min-height: 46px;
    padding: 11px 14px;
    border: 1.5px solid var(--border);
    border-radius: 4px;
    outline: 0;
    background: #fff;
    color: var(--text);
    font-size: 16px;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus {
    border-color: var(--navy);
    box-shadow: 0 0 0 3px rgba(28, 58, 107, .08);
}

textarea.form-control {
    min-height: 112px;
    resize: vertical;
}

.form-hint {
    margin-top: 6px;
    color: var(--muted);
    font-size: 14px;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(15, 30, 48, .6);
    backdrop-filter: blur(2px);
}

.modal-overlay.open {
    display: flex;
}

.modal {
    width: min(90vw, 860px);
    max-height: 88vh;
    overflow: auto;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
}

.modal.modal-wide {
    width: min(96vw, 1180px);
}

.modal-header {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 26px 30px 20px;
    background: #fff;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    color: var(--navy);
    font-size: 22px;
    font-weight: 700;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: var(--bg);
    color: var(--muted);
    cursor: pointer;
}

.modal-body {
    padding: 26px 30px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 16px;
    padding: 20px 30px;
    border-top: 1px solid var(--border);
}

.steps {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 34px;
}

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

.step-num {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--border);
    color: var(--muted);
    font-size: 16px;
    font-weight: 700;
}

.step.done .step-num {
    background: var(--teal);
    color: #fff;
}

.step.active .step-num {
    background: var(--navy);
    color: #fff;
}

.step-label {
    color: var(--muted);
    font-size: 15px;
    font-weight: 600;
}

.step.active .step-label {
    color: var(--navy);
}

.step.done .step-label {
    color: var(--teal);
}

.step-line {
    flex: 1;
    height: 3px;
    background: var(--border);
}

.step-line.done {
    background: var(--teal);
}

.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 9px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    margin-bottom: 22px;
}

.timeline-dot {
    position: absolute;
    top: 3px;
    left: -32px;
    width: 18px;
    height: 18px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: var(--navy);
    box-shadow: 0 0 0 2px var(--navy);
}

.timeline-dot.gold {
    background: var(--gold);
    box-shadow: 0 0 0 2px var(--gold);
}

.timeline-dot.red {
    background: var(--red);
    box-shadow: 0 0 0 2px var(--red);
}

.timeline-dot.teal {
    background: var(--teal);
    box-shadow: 0 0 0 2px var(--teal);
}

.timeline-date {
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .8px;
}

.timeline-text {
    margin-top: 4px;
    color: var(--text);
    font-size: 16px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    gap: 22px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg2);
    font-size: 16px;
}

.detail-row:last-child {
    border-bottom: 0;
}

.detail-key {
    color: var(--muted);
    font-weight: 500;
}

.detail-val {
    color: var(--text);
    font-weight: 600;
    text-align: right;
}

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

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

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

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

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

.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 20px;
    border-radius: 4px;
    margin-bottom: 22px;
    font-size: 16px;
}

.alert-warning {
    background: rgba(230, 126, 34, .1);
    border-left: 4px solid var(--orange);
    color: #7A4A10;
}

.alert-danger {
    background: rgba(192, 57, 43, .08);
    border-left: 4px solid var(--red);
    color: #7A1A10;
}

.alert-success {
    background: rgba(30, 132, 73, .08);
    border-left: 4px solid var(--green);
    color: #0E5226;
}

.alert-info {
    background: rgba(28, 58, 107, .08);
    border-left: 4px solid var(--navy);
    color: var(--navy);
}

.par-bar {
    height: 10px;
    margin-top: 9px;
    overflow: hidden;
    background: var(--bg2);
    border-radius: 4px;
}

.par-fill {
    height: 100%;
    border-radius: 4px;
    background: linear-gradient(90deg, var(--green), var(--gold), var(--red));
    transition: width .4s ease;
}

.chart-bar-wrap {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    height: 128px;
}

.chart-bar-col {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chart-bar {
    width: 100%;
    min-height: 2px;
    border-radius: 3px 3px 0 0;
    background: var(--navy);
    opacity: .8;
}

.chart-label {
    color: var(--muted);
    font-size: 13px;
}

.analytics-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 30px;
    margin-bottom: 34px;
}

.chart-card {
    min-width: 0;
}

.chart-card-wide {
    grid-column: span 3;
}

.dashboard-chart {
    display: block;
    width: 100%;
    height: 270px;
}

.dashboard-chart.chart-short {
    height: 230px;
}

.chart-legend {
    display: flex;
    align-items: center;
    gap: 12px 16px;
    flex-wrap: wrap;
    min-height: 24px;
    margin-top: 12px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.chart-legend-grid {
    align-items: flex-start;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-legend span {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-width: 0;
}

.chart-legend i {
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.tabs {
    display: flex;
    gap: 0;
    margin-bottom: 28px;
    border-bottom: 2px solid var(--border);
    overflow-x: auto;
}

.tab {
    padding: 14px 24px;
    margin-bottom: -2px;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
}

.tab.active {
    border-bottom-color: var(--gold);
    color: var(--navy);
}

.toast-root {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 300;
    display: grid;
    gap: 12px;
}

.toast {
    min-width: 300px;
    max-width: min(420px, 90vw);
    padding: 16px 18px;
    border-left: 4px solid var(--navy);
    border-radius: 4px;
    background: #fff;
    box-shadow: 0 12px 30px rgba(15, 30, 48, .18);
    font-size: 15px;
}

.toast.success {
    border-left-color: var(--green);
}

.toast.error {
    border-left-color: var(--red);
}

.text-right {
    text-align: right;
}

.text-center {
    text-align: center;
}

.mt-16 {
    margin-top: 16px;
}

.mb-16 {
    margin-bottom: 16px;
}

::-webkit-scrollbar {
    width: 5px;
    height: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

@media (max-width: 1180px) {
    .kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .chart-card-wide {
        grid-column: span 2;
    }

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

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

@media (max-width: 860px) {
    .mobile-nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        width: min(var(--sidebar-w), 88vw);
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

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

    body.sidebar-open::after {
        content: "";
        position: fixed;
        inset: 0;
        z-index: 90;
        background: rgba(15, 30, 48, .45);
    }

    .main {
        margin-left: 0;
    }

    .topbar {
        min-height: auto;
        padding: 16px 18px 16px 78px;
        align-items: flex-start;
        flex-direction: column;
    }

    .page {
        padding: 24px 18px;
    }

    .two-col,
    .three-col,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .permissions-page .table-scroll {
        display: none;
    }

    .permissions-page .permission-card-list {
        display: block;
    }

    .steps {
        align-items: flex-start;
        flex-direction: column;
        gap: 10px;
    }

    .step-line {
        display: none;
    }
}

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

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

    .chart-card-wide {
        grid-column: auto;
    }

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

    .card,
    .kpi-card {
        padding: 20px;
    }

    .table-header,
    .card-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .modal {
        width: 100vw;
        max-height: 92vh;
    }

    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .permission-card-grid {
        min-width: 480px;
    }
}

@media (max-width: 760px) {
    .table-scroll {
        overflow-x: visible;
    }

    .table-scroll table:not(.permission-matrix),
    .table-scroll table:not(.permission-matrix) thead,
    .table-scroll table:not(.permission-matrix) tbody,
    .table-scroll table:not(.permission-matrix) tr,
    .table-scroll table:not(.permission-matrix) th,
    .table-scroll table:not(.permission-matrix) td {
        display: block;
    }

    .table-scroll table:not(.permission-matrix) thead {
        display: none;
    }

    .table-scroll table:not(.permission-matrix) tbody tr {
        padding: 10px 0;
        border-bottom: 1px solid var(--border);
    }

    .table-scroll table:not(.permission-matrix) tbody tr:hover {
        background: transparent;
    }

    .table-scroll table:not(.permission-matrix) tbody td {
        display: grid;
        grid-template-columns: minmax(98px, 36%) minmax(0, 1fr);
        gap: 12px;
        width: 100%;
        padding: 8px 16px;
        border: 0;
    }

    .table-scroll table:not(.permission-matrix) tbody td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 11px;
        font-weight: 700;
        letter-spacing: .4px;
        line-height: 1.3;
        text-transform: uppercase;
    }

    .table-scroll table:not(.permission-matrix) tbody td[colspan] {
        display: block;
        padding: 16px;
    }

    .table-scroll table:not(.permission-matrix) tbody td[colspan]::before {
        display: none;
    }
}

@media print {
    .sidebar,
    .mobile-nav-toggle,
    .topbar-actions,
    .btn,
    .toast-root {
        display: none !important;
    }

    .main {
        margin-left: 0;
    }

    .topbar,
    .card,
    .table-wrap {
        box-shadow: none;
    }
}
