* {
    box-sizing: border-box;
}

html {
    min-width: 320px;
    min-height: 100%;
}

body {
    min-height: 100vh;
    margin: 0;
    color: var(--color-body);
    background: var(--color-background);
    font-family: var(--font-family);
    line-height: 1.5;
    transition: color .18s ease, background-color .18s ease;
}

.page-loader {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: grid;
    place-items: center;
    background: var(--color-background);
    opacity: 1;
    visibility: visible;
    transition: opacity .2s ease, visibility .2s ease;
}

.page-loader.is-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.page-loader-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: loader-spin .7s linear infinite;
}

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

@keyframes loader-spin {
    to {
        transform: rotate(360deg);
    }
}

body.drawer-open {
    overflow: hidden;
}

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

a {
    color: var(--color-primary);
    text-decoration: none;
}

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

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

p {
    color: var(--color-text-muted);
}

.topbar {
    position: sticky;
    z-index: 40;
    top: 0;
    height: 64px;
    background: color-mix(in srgb, var(--color-surface) 95%, transparent);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(10px);
}

.topbar-inner {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 0 16px;
}

.topbar-brand,
.header-brand,
.user-menu-trigger {
    display: flex;
    align-items: center;
}

.topbar-brand {
    gap: 12px;
}

.header-brand {
    gap: 9px;
    color: var(--color-text);
    font-size: 1.1rem;
    font-weight: 750;
    letter-spacing: -.02em;
}

.brand-mark {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--color-primary);
    border-radius: var(--radius-md);
    font-size: .78rem;
    font-weight: 800;
}

.brand-mark img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: inherit;
}

.icon-button {
    width: 40px;
    height: 40px;
    display: inline-grid;
    place-items: center;
    padding: 0;
    color: var(--color-text);
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.icon-button:hover {
    background: var(--color-surface-muted);
}

.user-menu-wrap {
    position: relative;
}

.user-menu-trigger {
    gap: 9px;
    padding: 5px 7px;
    color: var(--color-text);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
}

.user-menu-trigger:hover {
    background: var(--color-surface-muted);
}

.avatar {
    position: relative;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    color: #fff;
    background: var(--color-primary);
    border-radius: 50%;
    font-size: .78rem;
    font-weight: 700;
}

.avatar i {
    position: absolute;
    top: 0;
    right: 0;
    width: 10px;
    height: 10px;
    background: var(--color-success);
    border: 2px solid var(--color-surface);
    border-radius: 50%;
}

.user-menu-copy {
    min-width: 0;
    text-align: left;
}

.user-menu-copy strong,
.user-menu-copy small {
    display: block;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-copy strong {
    font-size: .75rem;
}

.user-menu-copy small {
    color: var(--color-text-muted);
    font-size: .68rem;
}

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

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 256px;
    display: none;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 18px 40px rgb(15 23 42 / 18%);
}

.user-dropdown.is-open {
    display: block;
}

.user-dropdown-heading {
    padding: 13px 16px;
    border-bottom: 1px solid var(--color-border);
}

.user-dropdown-heading strong,
.user-dropdown-heading small {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-dropdown-heading strong {
    color: var(--color-text);
    font-size: .875rem;
}

.user-dropdown-heading small {
    color: var(--color-text-muted);
    font-size: .75rem;
}

.user-dropdown-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    font-size: .875rem;
    border-bottom: 1px solid var(--color-border);
}

.logout-form {
    margin: 0;
    padding: 6px;
}

.dropdown-action {
    width: 100%;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--color-body);
    font-size: .875rem;
    font-weight: 550;
    text-align: left;
}

.dropdown-action:hover {
    color: var(--color-text);
    background: var(--color-surface-muted);
}

.user-dropdown-links {
    display: grid;
    padding-block: 6px;
    border-bottom: 1px solid var(--color-border);
}

.danger-text {
    color: var(--color-danger);
}

.profile-layout {
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
    gap: 20px;
    align-items: start;
}

.profile-summary {
    display: flex;
    align-items: center;
    gap: 16px;
}

.profile-summary h2,
.profile-summary p {
    margin: 0;
}

.profile-summary p {
    margin-top: 4px;
    color: var(--color-text-muted);
}

.profile-avatar {
    width: 56px;
    height: 56px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    background: var(--color-primary);
    border-radius: 50%;
    font-size: 1.2rem;
    font-weight: 750;
}

.profile-details {
    display: grid;
    gap: 14px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border);
}

.profile-details div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.profile-details span {
    color: var(--color-text-muted);
}

.permission-list {
    display: grid;
    gap: 10px;
    max-height: 480px;
    overflow-y: auto;
    padding-right: 6px;
    scrollbar-gutter: stable;
}

.access-notice {
    display: grid;
    gap: 3px;
    margin-bottom: 14px;
    padding: 13px 15px;
    color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
    border: 1px solid color-mix(in srgb, var(--color-primary) 28%, var(--color-border));
    border-radius: var(--radius-md);
}

.access-notice span {
    color: var(--color-body);
    font-size: .82rem;
}

.permission-list-item {
    min-height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 11px 13px;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.permission-list-item strong,
.permission-list-item small {
    display: block;
}

.permission-list-item small {
    margin-top: 3px;
    color: var(--color-text-muted);
}

.empty-state {
    margin: 0;
    padding: 20px;
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    border-radius: var(--radius-md);
    text-align: center;
}

.theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: inline;
}

.sidebar-overlay {
    position: fixed;
    z-index: 50;
    inset: 0;
    visibility: hidden;
    opacity: 0;
    background: rgb(2 6 23 / 60%);
    backdrop-filter: blur(2px);
    transition: opacity .24s ease, visibility 0s linear .24s;
}

.sidebar-overlay.is-open {
    visibility: visible;
    opacity: 1;
    transition-delay: 0s;
}

.sidebar {
    width: var(--sidebar-width);
    max-width: 85vw;
    height: 100%;
    overflow-y: auto;
    padding: 20px;
    background: var(--color-surface);
    border-right: 1px solid var(--color-border);
    box-shadow: 0 24px 50px rgb(0 0 0 / 28%);
    overscroll-behavior: contain;
    transform: translate3d(-100%, 0, 0);
    transition: transform .28s cubic-bezier(.22, 1, .36, 1);
    will-change: transform;
    backface-visibility: hidden;
}

.sidebar.is-open {
    transform: translate3d(0, 0, 0);
}

.sidebar-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
}

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

.sidebar-heading strong {
    color: var(--color-text);
    font-size: 1.1rem;
}

.sidebar-heading small {
    color: var(--color-text-muted);
    font-size: .75rem;
}

.nav-label {
    margin: 0 12px 12px;
    color: var(--color-text-muted);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.sidebar-nav {
    display: grid;
    gap: 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--color-body);
    border-radius: var(--radius-md);
    font-size: .875rem;
    font-weight: 550;
    transition: color .15s ease, background-color .15s ease;
}

.nav-link:hover {
    color: var(--color-text);
    background: var(--color-surface-muted);
}

.nav-link.is-active {
    color: #fff;
    background: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.nav-group {
    display: grid;
    gap: 4px;
}

.nav-group-toggle {
    min-height: 40px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    color: var(--color-body);
    background: transparent;
    border: 0;
    border-radius: var(--radius-md);
    box-shadow: none;
    font-size: .875rem;
    font-weight: 600;
    text-align: left;
}

.nav-group-toggle:hover {
    color: var(--color-text);
    background: var(--color-surface-muted);
}

.nav-group-toggle.is-active {
    color: #fff;
    background: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.nav-group-toggle svg {
    flex: 0 0 auto;
    transition: transform .18s ease;
}

.nav-group-toggle[aria-expanded="true"] svg {
    transform: rotate(180deg);
}

.nav-group-items {
    display: none;
    gap: 4px;
    margin-left: 12px;
    padding-left: 10px;
    border-left: 1px solid var(--color-border);
}

.nav-group-items.is-open {
    display: grid;
}

.nav-group-items .nav-link {
    padding-block: 8px;
    font-size: .82rem;
}

.container {
    width: 100%;
    max-width: var(--content-width);
    margin: 0 auto;
    padding: 24px 16px;
}

.page-heading {
    min-height: 80px;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.page-heading h1 {
    margin-bottom: 5px;
    font-size: clamp(1.5rem, 3vw, 1.875rem);
    line-height: 1.2;
    letter-spacing: -.025em;
}

.page-heading p {
    max-width: 672px;
    margin: 0;
    font-size: .875rem;
    line-height: 1.6;
}

.card {
    padding: 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.narrow {
    width: min(672px, 100%);
    margin-inline: auto;
}

.narrow>h1 {
    margin-bottom: 24px;
    font-size: 1.5rem;
}

form:not(.filters):not(.logout-form) {
    display: grid;
    gap: 20px;
}

.filters {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin: 16px 0;
}

.filter-group {
    display: flex;
    align-items: end;
    gap: 10px;
}

.filter-search {
    width: min(540px, 100%);
}

.filter-search label {
    flex: 1;
}

.filter-page-size {
    margin-left: auto;
}

.filter-page-size label {
    width: 92px;
}

label {
    display: grid;
    gap: 8px;
    color: var(--color-text);
    font-size: .875rem;
    font-weight: 550;
}

input,
select,
textarea {
    min-height: 40px;
    width: 100%;
    padding: 9px 12px;
    color: var(--color-text);
    background: var(--color-input);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    outline: none;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-primary) 28%, transparent);
}

textarea {
    resize: vertical;
}

button,
.button {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: fit-content;
    padding: 7px 14px;
    color: #fff;
    background: var(--color-primary);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    font-weight: 600;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--color-primary-hover);
}

.button-secondary {
    color: var(--color-body);
    background: var(--color-surface-muted);
    border-color: var(--color-border);
}

.button-secondary:hover {
    color: var(--color-text);
    background: color-mix(in srgb, var(--color-border) 70%, var(--color-surface));
    border-color: var(--color-border);
}

.icon-button,
.user-menu-trigger,
.dropdown-action {
    min-height: auto;
    box-shadow: none;
}

.icon-button:hover,
.user-menu-trigger:hover,
.dropdown-action:hover {
    color: var(--color-text);
    background: var(--color-surface-muted);
}

.danger {
    background: var(--color-danger);
}

.danger:hover {
    background: var(--color-danger-hover);
}

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

td.actions {
    display: table-cell;
}

td.actions > * + * {
    margin-left: 10px;
}

.actions a:not(.button) {
    padding: 6px 8px;
    border-radius: 6px;
    font-size: .78rem;
    font-weight: 650;
}

.actions a:not(.button):hover {
    background: color-mix(in srgb, var(--color-primary) 10%, transparent);
}

.searchable-select {
    position: relative;
    width: 100%;
}

.searchable-select__native {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    opacity: 0;
    pointer-events: none;
}

.searchable-select__input {
    padding-right: 36px;
    cursor: text;
}

.searchable-select__chevron {
    position: absolute;
    top: 50%;
    right: 12px;
    display: grid;
    place-items: center;
    color: var(--color-text-muted);
    pointer-events: none;
    transform: translateY(-50%);
    transition: transform .15s ease;
}

.searchable-select.is-open .searchable-select__chevron {
    transform: translateY(-50%) rotate(180deg);
}

.searchable-select__dropdown {
    position: absolute;
    z-index: 35;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 240px;
    display: none;
    overflow-y: auto;
    padding: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
}

.searchable-select.is-open .searchable-select__dropdown {
    display: grid;
}

.searchable-select__option {
    min-height: 36px;
    width: 100%;
    justify-content: flex-start;
    padding: 8px 10px;
    color: var(--color-body);
    background: transparent;
    border: 0;
    box-shadow: none;
    font-size: .875rem;
    text-align: left;
}

.searchable-select__option:hover,
.searchable-select__option[aria-selected="true"] {
    color: var(--color-text);
    background: var(--color-surface-muted);
}

.searchable-select__option[aria-selected="true"] {
    color: var(--color-primary);
}

.searchable-select__empty {
    margin: 0;
    padding: 10px;
    font-size: .8rem;
    text-align: center;
}

[data-theme="dark"] button:not(.icon-button):not(.user-menu-trigger):not(.dropdown-action):not(.searchable-select__option):not(.nav-group-toggle),
[data-theme="dark"] .button {
    color: #ffffff;
}

[data-theme="dark"] .button-secondary {
    color: var(--color-body);
    background: var(--color-surface-muted);
}

[data-theme="dark"] .searchable-select__dropdown,
[data-theme="dark"] .user-dropdown {
    box-shadow: 0 20px 45px rgb(0 0 0 / 45%);
}

.table-wrap {
    position: relative;
    overflow-x: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

table {
    width: 100%;
    min-width: 672px;
    border-collapse: collapse;
    text-align: left;
    font-size: .875rem;
}

thead {
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    border-bottom: 1px solid var(--color-border);
}

th {
    padding: 13px 20px;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

td {
    padding: 15px 20px;
    color: var(--color-body);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
    white-space: nowrap;
}

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

tbody tr:hover td {
    background: var(--color-surface-soft);
}

.table-empty {
    padding: 32px 20px;
    color: var(--color-text-muted);
    text-align: center;
}

.table-wrap+.pagination-bar {
    margin-top: 0;
    padding: 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: 0;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.pagination-bar p {
    margin: 0;
    font-size: .875rem;
}

.pagination {
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.pagination a {
    min-width: 36px;
    display: grid;
    place-items: center;
    padding: 7px 11px;
    color: var(--color-body);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    margin-left: -1px;
    font-size: .82rem;
    font-weight: 600;
}

.pagination a:first-child {
    margin-left: 0;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.pagination a:last-child {
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.pagination a:hover {
    color: var(--color-text);
    background: color-mix(in srgb, var(--color-border) 65%, var(--color-surface));
}

.pagination .active {
    position: relative;
    z-index: 1;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border-color: var(--color-primary);
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.module-card {
    display: block;
    transition: transform .15s ease, box-shadow .15s ease;
}

.module-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.module-card h2 {
    margin: 14px 0 5px;
    font-size: 1rem;
}

.module-card p {
    margin: 0;
    font-size: .78rem;
}

.module-icon {
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    color: var(--color-primary);
    background: var(--color-primary-soft);
    border-radius: var(--radius-lg);
}

.dashboard-hero {
    background: var(--color-surface);
}

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

.checkbox-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 13px;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.checkbox-option input {
    min-height: auto;
    width: auto;
    margin-top: 4px;
    accent-color: var(--color-primary);
}

.checkbox-option span {
    display: grid;
    gap: 3px;
}

.checkbox-option small {
    color: var(--color-text-muted);
    font-weight: 400;
}

.file-preview {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--color-text-muted);
    font-size: .8rem;
}

.file-preview img {
    width: 96px;
    height: 64px;
    object-fit: contain;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.file-preview-small img {
    width: 40px;
    height: 40px;
}

.settings-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, .8fr);
    gap: 20px;
}

.communication-service-picker {
    max-width: 520px;
    margin-bottom: 20px;
}

.communication-settings-grid {
    align-items: start;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.communication-card-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 18px;
}

.communication-card-heading h2,
.communication-card-heading p {
    margin-top: 0;
}

.compact-checkbox {
    flex: 0 0 auto;
    min-width: 112px;
}

.communication-inline-fields {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 120px;
    gap: 14px;
}

.communication-save-actions {
    margin-top: 20px;
}

.settings-grid h2,
.subheading h2 {
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.config-list {
    display: grid;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.config-list>div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--color-border);
}

.config-list>div:last-child {
    border-bottom: 0;
}

.config-list span {
    color: var(--color-text-muted);
    font-size: .82rem;
}

.config-list strong {
    color: var(--color-text);
    font-size: .85rem;
}

.config-note {
    margin: 14px 0 0;
    font-size: .8rem;
}

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

.backup-card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.backup-card h2 {
    margin-bottom: 8px;
    font-size: 1.05rem;
}

.backup-card p {
    flex: 1;
    margin-bottom: 20px;
    font-size: .85rem;
}

.backup-note {
    margin-top: 20px;
}

.backup-note p {
    margin: 6px 0;
}

.backup-note code,
.config-note code {
    color: var(--color-primary);
    overflow-wrap: anywhere;
}

.drive-settings-card {
    margin-top: 20px;
}

.drive-settings-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
}

.drive-settings-heading h2 {
    margin: 3px 0 5px;
    font-size: 1.15rem;
}

.drive-settings-heading p,
.drive-viewer-message {
    margin: 0;
    color: var(--color-text-muted);
    font-size: .86rem;
}

.drive-eyebrow {
    color: var(--color-primary);
    font-size: .7rem;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.drive-settings-layout {
    display: grid;
    grid-template-columns: minmax(250px, .75fr) minmax(0, 1.25fr);
    gap: 24px;
    padding-top: 22px;
}

.drive-setup-guide {
    padding: 18px;
    background: var(--color-surface-soft);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}

.drive-setup-guide h3 {
    margin: 0 0 12px;
    font-size: .95rem;
}

.drive-setup-guide ol {
    margin: 0;
    padding-left: 20px;
    color: var(--color-body);
    font-size: .82rem;
}

.drive-setup-guide li + li {
    margin-top: 9px;
}

.drive-setup-guide a {
    color: var(--color-primary);
    font-weight: 650;
}

.drive-guide-note {
    margin: 16px 0 0;
    padding-top: 14px;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    font-size: .78rem;
}

.drive-settings-form {
    display: grid;
    gap: 16px;
}

.drive-settings-form label {
    margin: 0;
}

.drive-settings-form small code {
    color: var(--color-primary);
}

.drive-redirect-uri {
    display: grid;
    gap: 6px;
    padding: 14px;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.drive-redirect-uri span {
    color: var(--color-text);
    font-size: .8rem;
    font-weight: 700;
}

.drive-redirect-uri code {
    color: var(--color-primary);
    overflow-wrap: anywhere;
}

.drive-settings-actions {
    flex-wrap: wrap;
}

.drive-disconnect {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.drive-viewer-message {
    padding-top: 18px;
}

.subheading {
    margin: 28px 0 14px;
}

.subheading p {
    margin-bottom: 0;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 5px 9px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
}

.seat-layout-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.seat-legend-item {
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: .78rem;
    font-weight: 700;
}

.seat-layout-decks {
    display: grid;
    gap: 18px;
    margin-bottom: 24px;
}

.seat-layout-card {
    overflow-x: auto;
}

.seat-layout-card .subheading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 0;
}

.seat-layout-grid {
    --seat-grid-columns: 4;
    min-width: calc(var(--seat-grid-columns) * 64px);
    display: grid;
    grid-template-columns: repeat(var(--seat-grid-columns), minmax(52px, 1fr));
    grid-auto-rows: minmax(58px, auto);
    gap: 10px;
    padding: 18px;
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.seat-layout-item {
    min-width: 52px;
    display: grid;
    place-content: center;
    gap: 2px;
    padding: 8px;
    border: 1px solid color-mix(in srgb, currentColor 35%, var(--color-border));
    border-radius: var(--radius-md);
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.seat-layout-item small {
    font-size: .65rem;
}

.seat-class-economy {
    color: #166534;
    background: #dcfce7;
}

.seat-class-business {
    color: #1d4ed8;
    background: #dbeafe;
}

.seat-class-executive {
    color: #7e22ce;
    background: #f3e8ff;
}

.seat-class-sleeper {
    color: #9a3412;
    background: #ffedd5;
}

.seat-layout-inactive {
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    opacity: .62;
}

.seat-layout-direction {
    margin: 10px 0 0;
    color: var(--color-text-muted);
    font-size: .78rem;
    text-align: right;
}

.booking-seat-option {
    position: relative;
    cursor: pointer;
}

.booking-seat-option input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.booking-seat-option:has(input:checked) {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

.booking-seat-available {
    color: #166534;
    background: #dcfce7;
}

.booking-seat-held {
    color: #92400e;
    background: #fef3c7;
    cursor: not-allowed;
}

.booking-seat-booked {
    color: #991b1b;
    background: #fee2e2;
    cursor: not-allowed;
}

.booking-step + .booking-step,
.booking-step + form,
form + .booking-step {
    margin-top: 18px;
}

[hidden] {
    display: none !important;
}

.booking-progress {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
}

.booking-progress li {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: .86rem;
    font-weight: 700;
}

.booking-progress li span {
    display: grid;
    flex: 0 0 26px;
    width: 26px;
    height: 26px;
    place-content: center;
    border: 1px solid currentColor;
    border-radius: 50%;
}

.booking-progress li.is-current {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 8%, var(--color-surface));
}

.booking-progress li.is-complete {
    color: #047857;
    border-color: rgb(16 185 129 / 35%);
    background: rgb(16 185 129 / 10%);
}

.booking-search-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
    align-items: end;
}

.booking-search-action {
    align-self: end;
    padding-bottom: 2px;
}

.passenger-counts {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(110px, 180px));
    gap: 12px;
    margin: 0;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.passenger-counts legend,
.passenger-detail-card legend {
    padding: 0 6px;
    font-weight: 700;
}

.passenger-counts small {
    grid-column: 1 / -1;
    color: var(--color-text-muted);
}

.trip-choice-list {
    display: grid;
    gap: 10px;
    margin: 12px 0 22px;
}

.trip-choice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    cursor: pointer;
}

.trip-choice > input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.trip-choice-marker {
    display: block !important;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    background: var(--color-surface);
}

.trip-choice:has(input:checked) .trip-choice-marker {
    border: 5px solid var(--color-primary);
}

.trip-choice:has(input:checked) {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-primary) 20%, transparent);
}

.trip-choice span {
    display: grid;
    gap: 4px;
}

.trip-choice small {
    color: var(--color-text-muted);
}

.booking-seat-list {
    display: grid;
    grid-template-columns: repeat(var(--booking-columns, 5), minmax(48px, 72px));
    gap: 9px;
    align-items: stretch;
    width: fit-content;
    max-width: 100%;
    margin: 12px 0 20px;
    padding: 54px 22px 22px;
    overflow-x: auto;
    background: var(--color-surface-muted);
    border: 2px solid var(--color-border);
    border-radius: 32px 32px 14px 14px;
    position: relative;
}

.booking-seat-list::before {
    content: "DRIVER";
    position: absolute;
    top: 16px;
    right: 22px;
    padding: 6px 10px;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .08em;
}

.booking-seat-list .booking-seat-option {
    grid-row: var(--seat-row, auto);
    grid-column: var(--seat-column, auto);
}

.report-filters { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.report-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 18px 0; }
.report-kpi { display: grid; gap: 6px; }
.report-kpi small, .report-kpi span { color: var(--color-text-muted); }
.report-kpi strong { font-size: 1.55rem; color: var(--color-text); }
.report-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(240px, 1fr); gap: 18px; margin-bottom: 18px; }
.report-panel { min-width: 0; }
.report-chart { height: 260px; display: flex; align-items: end; gap: 8px; padding: 20px 4px 0; overflow-x: auto; border-bottom: 1px solid var(--color-border); }
.report-bar-wrap { min-width: 44px; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 6px; outline: none; }
.report-bar { width: 28px; min-height: 5px; background: linear-gradient(180deg, var(--color-primary), color-mix(in srgb, var(--color-primary) 55%, #22c55e)); border-radius: 7px 7px 2px 2px; transition: filter .15s, transform .15s; }
.report-bar-wrap:hover .report-bar, .report-bar-wrap:focus .report-bar { filter: brightness(1.12); transform: scaleX(1.12); }
.report-bar-value, .report-bar-wrap small { font-size: .7rem; white-space: nowrap; }
.report-channel-list { display: grid; gap: 10px; }
.report-channel-list div { display: flex; justify-content: space-between; gap: 16px; padding: 12px; background: var(--color-surface-muted); border-radius: var(--radius-md); }

@media (max-width: 820px) {
    .report-kpis { grid-template-columns: 1fr 1fr; }
    .report-grid { grid-template-columns: 1fr; }
}

@media (max-width: 520px) {
    .report-kpis { grid-template-columns: 1fr; }
}

.booking-fare-field {
    max-width: 320px;
}

.booking-inclusions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
}

.passenger-detail-list {
    display: grid;
    gap: 14px;
}

.passenger-detail-card {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 16px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.booking-inclusions strong {
    flex-basis: 100%;
}

.booking-wizard-actions {
    justify-content: space-between;
    margin-top: 20px;
}

.booking-list-filters {
    margin-bottom: 18px;
}

.booking-table td {
    vertical-align: middle;
}

.booking-table td small {
    display: block;
    margin-top: 4px;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.ticket-number {
    color: var(--color-primary);
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}

.ticket-number:hover {
    text-decoration: underline;
}

.booking-row-actions {
    flex-wrap: nowrap;
    min-width: max-content;
}

.booking-row-actions .button {
    min-height: 34px;
    padding: 7px 10px;
    font-size: .76rem;
}

.booking-paid-label {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 6px 10px;
    color: #047857;
    font-size: .78rem;
    font-weight: 800;
}

.payment-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.payment-summary p {
    display: grid;
    gap: 4px;
    margin: 0;
    padding: 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface-muted);
}

.payment-summary p span {
    font-size: 1.05rem;
}

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

    .passenger-counts {
        grid-template-columns: 1fr;
    }

    .passenger-counts small {
        grid-column: auto;
    }
}

.status-success {
    color: #047857;
    background: rgb(16 185 129 / 14%);
}

.status-warning {
    color: #b45309;
    background: rgb(245 158 11 / 16%);
}

.status-danger {
    color: var(--color-danger);
    background: rgb(239 68 68 / 14%);
}

.inline-form {
    display: inline-flex !important;
    gap: 0 !important;
}

.inline-form button {
    min-height: 34px;
    padding: 6px 10px;
    font-size: .75rem;
}

.login-page {
    position: relative;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 48px 16px;
}

.login-container {
    width: min(448px, 100%);
}

.login-container .card {
    padding: 32px;
    box-shadow: 0 20px 44px rgb(15 23 42 / 14%);
}

.login-brand {
    min-height: 56px;
    display: grid;
    place-items: center;
    margin-bottom: 16px;
}

.login-brand img {
    display: block;
    width: min(140px, 100%);
    max-height: 72px;
    margin-inline: auto;
    object-fit: contain;
}

.login-brand span {
    color: var(--color-primary);
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: .04em;
}

.login-container h1 {
    text-align: center;
}

.toast-container {
    position: fixed;
    z-index: 1000;
    top: 20px;
    left: 50%;
    width: min(420px, calc(100vw - 32px));
    display: grid;
    gap: 10px;
    pointer-events: none;
    transform: translateX(-50%);
}

.toast {
    --toast-accent: var(--color-success);
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 11px 15px 11px 11px;
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: toast-in .32s ease both;
}

.toast--error {
    --toast-accent: var(--color-danger);
}

.toast__icon {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    display: inline-grid;
    place-items: center;
    color: var(--toast-accent);
    border: 2px solid currentColor;
    border-radius: 50%;
}

.toast__icon svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.toast__message {
    font-size: .875rem;
    font-weight: 500;
}

.toast.is-leaving {
    animation: toast-out .2s ease both;
}

.error-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.error-card {
    width: min(560px, 100%);
    text-align: center;
}

.error-code {
    margin: 0;
    color: var(--color-primary);
    font-size: 4rem;
    font-weight: 800;
    line-height: 1;
}

.error-card .button {
    margin-top: 12px;
}

.health-page {
    width: min(820px, 100%);
}

.health-container {
    width: min(900px, 100%);
}

.health-heading,
.health-panel-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.health-heading {
    margin-bottom: 22px;
}

.health-heading h1,
.health-heading p,
.health-panel-heading h2 {
    margin: 0;
}

.health-heading > div > p:last-child {
    margin-top: 6px;
    color: var(--color-text-muted);
}

.health-eyebrow {
    margin-bottom: 5px !important;
    color: var(--color-primary);
    font-size: .72rem;
    font-weight: 750;
    letter-spacing: .08em;
    text-transform: uppercase;
}

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

.health-panel {
    padding: 22px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.health-panel-heading {
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.health-details {
    display: grid;
    gap: 0;
    margin: 8px 0 0;
}

.health-details div {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
}

.health-details div:last-child {
    border-bottom: 0;
}

.health-details dt {
    color: var(--color-text-muted);
}

.health-details dd {
    margin: 0;
    color: var(--color-text);
    font-weight: 650;
    text-align: right;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(-12px) scale(.97);
    }
}

@keyframes toast-out {
    to {
        opacity: 0;
        transform: translateY(-8px) scale(.97);
    }
}

@media (min-width: 640px) {
    .topbar-inner {
        padding-inline: 24px;
    }

    .container {
        padding: 24px;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 32px;
    }
}

@media (max-width: 700px) {

    .header-brand>span:last-child,
    .user-menu-copy,
    .chevron {
        display: none;
    }

    .page-heading,
    .pagination-bar {
        flex-direction: column;
        align-items: stretch;
    }

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

    .filter-group {
        width: 100%;
        align-items: end;
    }

    .filter-search label {
        min-width: 0;
    }

    .filter-page-size {
        margin-left: 0;
    }

    .filter-page-size label {
        flex: 1;
        width: auto;
    }

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

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

    .communication-inline-fields {
        grid-template-columns: 1fr;
    }

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

    .drive-settings-heading {
        flex-direction: column;
    }

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

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

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

    .health-heading {
        flex-direction: column;
    }

    .card {
        padding: 20px;
    }

    .login-container .card {
        padding: 28px 22px;
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        transition-duration: .01ms !important;
        animation-duration: .01ms !important;
    }

    .page-loader-spinner {
        animation: none;
    }
}

.eyebrow {
    color: var(--color-primary);
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.dashboard-kpis {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.dashboard-kpi {
    position: relative;
    display: grid;
    gap: 5px;
    min-width: 0;
}

.dashboard-kpi small,
.dashboard-kpi p {
    color: var(--color-text-muted);
}

.dashboard-kpi strong {
    color: var(--color-primary);
    font-size: 1.8rem;
}

.dashboard-kpi p {
    margin: 0;
    font-size: .76rem;
}

.dashboard-kpi.is-alert strong {
    color: var(--color-danger);
}

.kpi-icon {
    position: absolute;
    top: 16px;
    right: 16px;
    padding: 4px 6px;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: .6rem;
    font-weight: 800;
}

.dashboard-section-heading {
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.load-chart {
    height: 300px;
    display: flex;
    align-items: end;
    gap: 14px;
    padding: 24px 10px 0;
    overflow-x: auto;
    border-bottom: 1px solid var(--color-border);
}

.load-chart-item {
    min-width: 72px;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: end;
    align-items: center;
    gap: 6px;
    color: var(--color-text);
    text-decoration: none;
}

.load-chart-bar {
    width: 58px;
    min-height: 4px;
    background: linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 70%, #d6b27c), #d6b27c);
    border-radius: 7px 7px 0 0;
    transition: transform .18s, filter .18s;
}

.load-chart-item:hover .load-chart-bar,
.load-chart-item:focus .load-chart-bar {
    transform: scaleX(1.08);
    filter: brightness(1.05);
}

.load-chart-value,
.load-chart-item small {
    font-size: .72rem;
}

.dashboard-actions-grid,
.live-load-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.dashboard-action {
    display: grid;
    gap: 7px;
    color: var(--color-text);
    text-decoration: none;
}

.dashboard-action span {
    color: var(--color-text-muted);
    font-size: .84rem;
}

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

.live-load-card {
    display: grid;
    gap: 14px;
}

.live-load-top,
.load-stats {
    display: flex;
    justify-content: space-between;
    gap: 12px;
}

.live-load-top h2,
.live-load-card p {
    margin: 0;
}

.load-ring {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: conic-gradient(var(--color-primary) calc(var(--load) * 1%), var(--color-border) 0);
    color: var(--color-text);
    font-size: .72rem;
    font-weight: 800;
    box-shadow: inset 0 0 0 7px var(--color-surface);
}

.live-load-route {
    font-weight: 800;
}

.live-load-route span {
    color: var(--color-primary);
}

.load-progress {
    height: 8px;
    overflow: hidden;
    background: var(--color-surface-muted);
    border-radius: 999px;
}

.load-progress span {
    display: block;
    height: 100%;
    background: var(--color-primary);
}

.load-stats div {
    display: grid;
    gap: 3px;
}

.load-stats small {
    color: var(--color-text-muted);
    font-size: .66rem;
}

@media (max-width: 1100px) {
    .dashboard-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 720px) {
    .dashboard-kpis,
    .dashboard-actions-grid,
    .live-load-grid {
        grid-template-columns: 1fr;
    }

    .load-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }
}

.heatmap-filters {
    display: flex;
    align-items: end;
    gap: 14px;
    margin-bottom: 18px;
}

.heatmap-card {
    overflow: hidden;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--color-text-muted);
    font-size: .68rem;
}

.heatmap-legend i {
    width: 20px;
    height: 16px;
    border-radius: 3px;
}

.heat-1,
.heat-level-1 { background: #e7f6ec; }
.heat-2,
.heat-level-2 { background: #bde8c9; }
.heat-3,
.heat-level-3 { background: #78cf98; }
.heat-4,
.heat-level-4 { background: #2ea866; color: #fff; }
.heat-level-5 { background: #08783d; color: #fff; }

.load-heatmap-table .heat-cell {
    min-width: 82px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.load-heatmap-table .heat-neutral { background: var(--color-surface-muted); }
.load-heatmap-table .heat-booked { background: color-mix(in srgb, #16a34a 20%, var(--color-surface)); }
.load-heatmap-table .heat-held { background: color-mix(in srgb, #f59e0b 22%, var(--color-surface)); }
.load-heatmap-table .heat-available { background: color-mix(in srgb, #3b82f6 14%, var(--color-surface)); }

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

@media (max-width: 850px) {
    .report-detail-grid {
        grid-template-columns: 1fr;
    }

    .heatmap-legend {
        display: none;
    }
}

.live-load-heading {
    margin-bottom: 20px;
}

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

.live-load-stat {
    position: relative;
    overflow: hidden;
    padding: 18px 20px;
}

.live-load-stat::before {
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    content: "";
    background: var(--color-primary);
}

.live-load-stat > * {
    display: block;
}

.live-load-stat > span,
.live-load-stat > small {
    color: var(--color-text-muted);
}

.live-load-stat > span {
    font-size: .73rem;
    font-weight: 800;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.live-load-stat > strong {
    margin: 4px 0 2px;
    color: var(--color-text);
    font-size: 1.8rem;
    line-height: 1.1;
}

.live-load-stat > small {
    font-size: .76rem;
}

.live-load-filters {
    display: grid;
    grid-template-columns: minmax(240px, 1fr) minmax(180px, .5fr) minmax(140px, .35fr) auto;
    align-items: end;
    gap: 16px;
    margin-bottom: 16px;
    padding: 18px 20px;
}

.live-load-filter-copy {
    align-self: center;
}

.live-load-filter-copy > * {
    display: block;
}

.live-load-filter-copy strong {
    color: var(--color-text);
}

.live-load-filter-copy small {
    margin-top: 3px;
    color: var(--color-text-muted);
}

.live-load-panel {
    padding: 0;
    overflow: hidden;
}

.live-load-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--color-border);
}

.live-load-toolbar h2,
.live-load-toolbar p {
    margin: 0;
}

.live-load-toolbar h2 {
    color: var(--color-text);
    font-size: 1.05rem;
}

.live-load-toolbar p {
    margin-top: 4px;
    color: var(--color-text-muted);
    font-size: .8rem;
}

.live-load-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px 14px;
}

.live-load-legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-text-muted);
    font-size: .73rem;
    white-space: nowrap;
}

.live-load-legend i {
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.legend-low { background: #3b82f6; }
.legend-medium { background: #f59e0b; }
.legend-high { background: #10b981; }
.legend-cancelled { background: #94a3b8; }

.live-load-table-wrap {
    max-height: min(68vh, 760px);
    border: 0;
    border-radius: 0;
}

.trip-matrix {
    width: max-content;
    min-width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-variant-numeric: tabular-nums;
}

.trip-matrix th,
.trip-matrix td {
    box-sizing: border-box;
    min-width: 158px;
    padding: 0;
    text-align: left;
    white-space: normal;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
}

.trip-matrix thead th {
    position: sticky;
    top: 0;
    z-index: 4;
    height: 76px;
    padding: 10px 12px;
    color: var(--color-text-muted);
    text-align: center;
    background: var(--color-surface-muted);
}

.trip-matrix thead th > * {
    display: block;
    font-style: normal;
}

.trip-matrix thead th > span,
.trip-matrix thead th > small {
    font-size: .65rem;
    font-weight: 700;
}

.trip-matrix thead th > strong {
    margin: 1px 0;
    color: var(--color-text);
    font-size: 1.15rem;
    line-height: 1;
}

.trip-matrix thead th > em {
    margin-top: 4px;
    color: var(--color-primary);
    font-size: .58rem;
}

.trip-matrix thead th.is-today {
    box-shadow: inset 0 3px 0 var(--color-primary);
    background: color-mix(in srgb, var(--color-primary) 9%, var(--color-surface));
}

.trip-matrix .trip-matrix-service {
    position: sticky;
    left: 0;
    z-index: 3;
    min-width: 225px;
    max-width: 225px;
    padding: 16px 18px;
    background: var(--color-surface);
    box-shadow: 1px 0 0 var(--color-border);
}

.trip-matrix thead .trip-matrix-service {
    z-index: 5;
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
}

.trip-matrix tbody .trip-matrix-service > * {
    display: block;
}

.trip-matrix tbody .trip-matrix-service > strong {
    margin-bottom: 7px;
    color: var(--color-primary);
    font-size: .9rem;
}

.trip-matrix tbody .trip-matrix-service > span {
    color: var(--color-text);
    font-size: .78rem;
    font-weight: 700;
    line-height: 1.3;
}

.trip-matrix tbody .trip-matrix-service > i {
    margin: 2px 0;
    color: var(--color-text-muted);
    font-style: normal;
}

.trip-matrix tbody .trip-matrix-service > small {
    margin-top: 7px;
    color: var(--color-text-muted);
    font-size: .69rem;
}

.matrix-load {
    --matrix-accent: #3b82f6;
    --matrix-bg: color-mix(in srgb, #3b82f6 7%, var(--color-surface));
    --matrix-hover-bg: color-mix(in srgb, #3b82f6 13%, var(--color-surface));
    background: var(--matrix-bg);
}

.matrix-medium {
    --matrix-accent: #d97706;
    --matrix-bg: color-mix(in srgb, #f59e0b 9%, var(--color-surface));
    --matrix-hover-bg: color-mix(in srgb, #f59e0b 16%, var(--color-surface));
}

.matrix-high {
    --matrix-accent: #059669;
    --matrix-bg: color-mix(in srgb, #10b981 10%, var(--color-surface));
    --matrix-hover-bg: color-mix(in srgb, #10b981 17%, var(--color-surface));
}

.matrix-cancelled {
    --matrix-accent: #64748b;
    --matrix-bg: color-mix(in srgb, #94a3b8 10%, var(--color-surface));
    --matrix-hover-bg: color-mix(in srgb, #94a3b8 17%, var(--color-surface));
}

.matrix-load-link {
    display: flex;
    min-height: 166px;
    flex-direction: column;
    gap: 7px;
    padding: 13px 14px;
    color: var(--color-body);
    text-decoration: none;
    transition: background-color .16s ease, box-shadow .16s ease;
}

.matrix-load-link:hover,
.matrix-load-link:focus-visible {
    color: var(--color-body);
    background: var(--matrix-hover-bg);
    box-shadow: inset 0 0 0 2px var(--matrix-accent);
    outline: 0;
}

.matrix-load-topline,
.matrix-breakdown,
.matrix-load-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.matrix-load-topline strong {
    color: var(--matrix-accent);
    font-size: 1.15rem;
}

.matrix-load-topline small {
    overflow: hidden;
    color: var(--color-text-muted);
    font-size: .65rem;
    font-weight: 800;
    text-overflow: ellipsis;
    text-transform: uppercase;
}

.matrix-progress {
    overflow: hidden;
    height: 5px;
    background: color-mix(in srgb, var(--matrix-accent) 15%, var(--color-surface));
    border-radius: 999px;
}

.matrix-progress i {
    display: block;
    height: 100%;
    background: var(--matrix-accent);
    border-radius: inherit;
}

.matrix-seat-count {
    color: var(--color-text);
    font-size: .78rem;
}

.matrix-seat-count strong {
    font-size: 1rem;
}

.matrix-breakdown small,
.matrix-load-meta small {
    color: var(--color-text-muted);
    font-size: .66rem;
}

.matrix-load-meta {
    margin-top: auto;
    padding-top: 7px;
    border-top: 1px solid color-mix(in srgb, var(--matrix-accent) 18%, var(--color-border));
}

.matrix-fare {
    color: var(--color-text);
    font-size: .69rem;
    font-weight: 800;
}

.matrix-empty {
    color: var(--color-text-muted);
    text-align: center;
    background: color-mix(in srgb, var(--color-surface-muted) 55%, var(--color-surface));
}

.matrix-empty > * {
    display: block;
}

.matrix-empty > span {
    color: color-mix(in srgb, var(--color-text-muted) 60%, transparent);
    font-size: 1.25rem;
}

.matrix-empty > small {
    margin-top: 4px;
    font-size: .64rem;
}

/* Preserve semantic matrix colors when the generic table row hover rule applies. */
.trip-matrix tbody tr:hover td.matrix-load {
    background: var(--matrix-bg);
}

.trip-matrix tbody tr:hover td.matrix-empty {
    background: color-mix(in srgb, var(--color-surface-muted) 55%, var(--color-surface));
}

@media (max-width: 1000px) {
    .live-load-summary {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .live-load-filters {
        grid-template-columns: 1fr 1fr auto;
    }

    .live-load-filter-copy {
        grid-column: 1 / -1;
    }

    .live-load-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .live-load-legend {
        justify-content: flex-start;
    }
}

@media (max-width: 640px) {
    .live-load-summary,
    .live-load-filters {
        grid-template-columns: 1fr;
    }

    .live-load-filter-copy {
        grid-column: auto;
    }

    .live-load-filters button {
        width: 100%;
    }

    .live-load-toolbar {
        padding: 18px;
    }

    .trip-matrix .trip-matrix-service {
        min-width: 180px;
        max-width: 180px;
    }
}
