/* ==============================================
   HYGRADE-INSPIRED DESIGN SYSTEM - Dark Theme
   Orchid Platform + Bootstrap 5.3
   ============================================== */

/* ==============================================
   DESIGN TOKENS
   ============================================== */

:root {
    /* Fonts */
    --font-sans: "DM Sans", system-ui, -apple-system, sans-serif;
    --font-display: "Outfit", "DM Sans", system-ui, sans-serif;
    --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace;

    /* Primary blue */
    --bs-blue: #0795e2 !important;
    --bs-primary: #0795e2 !important;
    --bs-primary-rgb: 7, 149, 226 !important;
    --bs-link-color: #0795e2 !important;
    --bs-link-hover-color: #0580c4 !important;
    --primary-color: #0795e2;
    --primary-hover: #0580c4;
    --primary-dark: #035688;
    --primary-light: #2da5e8;

    /* Palette */
    --color-navy: #1a2e42;
    --color-maroon: #3d1f20;
    --color-maroon-light: #5c3234;
    --color-gold: #e6cc00;

    /* Dark surfaces */
    --canvas: #1a1d23;
    --surface: #22252b;
    --surface-2: #282c33;
    --surface-hover: #2d3239;
    --color-menu: #1c1b22;

    /* Borders */
    --border: #333840;
    --border-light: #3d444c;

    /* Text */
    --text: #e2e5ea;
    --text-2: #b0b8c4;
    --text-muted: #7d8694;

    /* Legacy aliases */
    --color-bg: var(--canvas);
    --color-card: var(--surface);
}

/* ==============================================
   BASE TYPOGRAPHY
   ============================================== */

html, body {
    font-family: var(--font-sans) !important;
    font-size: 15px !important;
    line-height: 1.5 !important;
    background-color: var(--canvas) !important;
    color: var(--text) !important;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body, p, span, div, td, th, li, small, label {
    color: var(--text);
    font-family: var(--font-sans);
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    font-family: var(--font-display) !important;
    color: var(--text) !important;
    font-weight: 300 !important;
}

h1, .h1 {
    font-size: 28px !important;
    font-weight: 200 !important;
    color: #0795e2 !important;
    letter-spacing: -0.01em;
}

h2, .h2 { font-size: 23px !important; }
h3, .h3 { font-size: 19px !important; }
h4, .h4 { font-size: 17px !important; font-weight: 400 !important; }
h5, .h5 { font-size: 15px !important; font-weight: 500 !important; }
h6, .h6 { font-size: 14px !important; font-weight: 600 !important; }

/* ==============================================
   LINKS
   ============================================== */

a {
    color: #4db8ff !important;
    text-decoration: none;
    transition: color 0.15s ease;
}

a:hover, a:focus {
    color: #80ccff !important;
}

a.text-white {
    color: #ffffff !important;
}

/* ==============================================
   GLOBAL PRIMARY BLUE OVERRIDES
   ============================================== */

/* Primary buttons */
.btn-primary {
    background-color: #0795e2 !important;
    border-color: #0795e2 !important;
}

.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
    background-color: #0580c4 !important;
    border-color: #0580c4 !important;
}

.btn-primary:focus, .btn-primary:focus-visible {
    box-shadow: 0 0 0 0.2rem rgba(7, 149, 226, 0.3) !important;
}

/* Outline primary buttons */
.btn-outline-primary {
    color: #0795e2 !important;
    border-color: #0795e2 !important;
}

.btn-outline-primary:hover, .btn-outline-primary:focus, .btn-outline-primary:active {
    background-color: #0795e2 !important;
    border-color: #0795e2 !important;
    color: white !important;
}

/* Link buttons */
.btn-link {
    color: #0795e2 !important;
}

.btn-link:hover, .btn-link:focus {
    color: #0580c4 !important;
}

/* Info buttons */
.btn-info {
    background-color: #0795e2 !important;
    border-color: #0795e2 !important;
}

.btn-info:hover, .btn-info:focus {
    background-color: #0580c4 !important;
    border-color: #0580c4 !important;
}

/* Primary badge */
.badge.bg-primary, .badge.badge-primary {
    background-color: #0795e2 !important;
}

/* Info badge */
.badge.bg-info, .badge.badge-info {
    background-color: #0795e2 !important;
    color: white !important;
}

/* Alerts */
.alert-primary {
    background-color: rgba(7, 149, 226, 0.12) !important;
    border-color: rgba(7, 149, 226, 0.25) !important;
    color: #4db8ff !important;
}

.alert-info {
    background-color: rgba(7, 149, 226, 0.12) !important;
    border-color: rgba(7, 149, 226, 0.25) !important;
    color: #4db8ff !important;
}

/* Form focus states */
.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
    border-color: #0795e2 !important;
    box-shadow: 0 0 0 0.2rem rgba(7, 149, 226, 0.2) !important;
}

/* Checkboxes and radios */
.form-check-input:checked {
    background-color: #0795e2 !important;
    border-color: #0795e2 !important;
}

.form-check-input:focus {
    border-color: #0795e2 !important;
    box-shadow: 0 0 0 0.2rem rgba(7, 149, 226, 0.2) !important;
}

/* Switches */
.form-switch .form-check-input:checked {
    background-color: #0795e2 !important;
}

/* Progress bars */
.progress-bar, .bg-primary {
    background-color: #0795e2 !important;
}

/* Nav tabs and pills */
.nav-tabs .nav-link.active {
    color: #0795e2 !important;
    border-bottom-color: #0795e2 !important;
}

.nav-pills .nav-link.active {
    background-color: #0795e2 !important;
}

.nav-link:hover, .nav-link:focus {
    color: #0795e2 !important;
}

/* Pagination */
.page-link {
    color: var(--text-2) !important;
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
    font-size: 14px;
}

.page-link:hover, .page-link:focus {
    color: #0795e2 !important;
    background-color: var(--surface-hover) !important;
}

.page-item.active .page-link {
    background-color: #0795e2 !important;
    border-color: #0795e2 !important;
    color: white !important;
}

/* List groups */
.list-group-item.active {
    background-color: #0795e2 !important;
    border-color: #0795e2 !important;
}

.list-group-item-action:hover, .list-group-item-action:focus {
    color: #0795e2 !important;
}

/* Dropdown active/hover */
.dropdown-item.active, .dropdown-item:active {
    background-color: #0795e2 !important;
}

.dropdown-item:hover, .dropdown-item:focus {
    background-color: rgba(7, 149, 226, 0.1) !important;
    color: #0795e2 !important;
}

/* Text utilities */
.text-primary { color: #0795e2 !important; }
.text-info { color: #0795e2 !important; }

/* Border utilities */
.border-primary { border-color: #0795e2 !important; }
.border-info { border-color: #0795e2 !important; }

/* Selection highlight */
::selection { background-color: rgba(7, 149, 226, 0.3); }
::-moz-selection { background-color: rgba(7, 149, 226, 0.3); }

/* Orchid sidebar active */
.aside .nav-link.active,
.aside-menu .nav-link.active,
aside .nav-link.active {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.08) !important;
    border-left: 3px solid var(--color-gold) !important;
}

.aside .nav-link:hover,
.aside-menu .nav-link:hover,
aside .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

/* Orchid icons in active state */
.aside .nav-link.active svg,
.aside-menu .nav-link.active svg {
    color: #0795e2 !important;
}

/* Orchid screen command bar buttons */
.command-bar .btn-link {
    color: #0795e2 !important;
}

.command-bar .btn-link:hover {
    color: #0580c4 !important;
}

/* Orchid table sort icons */
.table th a, table th a {
    color: var(--text-muted) !important;
}

.table th a:hover {
    color: #0795e2 !important;
}

/* Orchid modals */
.modal-header {
    border-bottom-color: var(--border) !important;
}

/* Loading spinner */
.spinner-border {
    color: #0795e2 !important;
}

/* Orchid turbo progress bar */
.turbo-progress-bar {
    background-color: #0795e2 !important;
}

/* Card header accent */
.card-header.bg-primary {
    background-color: #0795e2 !important;
}

/* Table hover */
.table-hover tbody tr:hover {
    background-color: var(--surface-hover) !important;
}

/* Orchid notifications */
.toast-header {
    border-bottom-color: var(--border) !important;
}

/* Accordion */
.accordion-button:not(.collapsed) {
    color: #0795e2 !important;
    background-color: rgba(7, 149, 226, 0.08) !important;
}

.accordion-button:focus {
    border-color: #0795e2 !important;
    box-shadow: 0 0 0 0.2rem rgba(7, 149, 226, 0.2) !important;
}

/* Breadcrumb active */
.breadcrumb-item.active {
    color: var(--text) !important;
}

/* Card links */
.card a:not(.btn) {
    color: #4db8ff !important;
}

.card a:not(.btn):hover {
    color: #80ccff !important;
}

/* ==============================================
   LAYOUT & SPACING
   ============================================== */

/* Container padding */
.container, .container-fluid, .container-lg, .container-md, .container-sm, .container-xl {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
}

/* Main content area */
.wrapper {
    padding: 1rem !important;
}

main, .main {
    padding: 1rem !important;
}

/* Page headers */
.page-header, .screen-header {
    padding: 0.5rem 0 !important;
    margin-bottom: 1rem !important;
}

.page-title, h1.mb-3, h1.mb-4 {
    margin-bottom: 0.5rem !important;
}

/* ==============================================
   CARDS - Hygrade Style
   ============================================== */

.card {
    background-color: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
    color: var(--text) !important;
    margin-bottom: 1rem !important;
    overflow: hidden;
}

.card-header {
    background-color: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text) !important;
    padding: 14px 18px !important;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--font-sans);
}

.card-body {
    background-color: var(--surface) !important;
    color: var(--text) !important;
    padding: 18px 22px !important;
}

.card-footer {
    background-color: var(--surface) !important;
    border-top: 1px solid var(--border) !important;
    padding: 12px 18px !important;
}

/* Ledger pages - larger stat cards */
.page-platform-timber-lodge-ledger .stat-cards-row,
.page-platform-nwos-ledger .stat-cards-row {
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px !important;
}
.page-platform-timber-lodge-ledger .stat-card,
.page-platform-nwos-ledger .stat-card {
    padding: 12px 16px !important;
    border-radius: 8px !important;
}
.page-platform-timber-lodge-ledger .stat-card .stat-value,
.page-platform-nwos-ledger .stat-card .stat-value {
    font-size: 1.4rem !important;
}
.page-platform-timber-lodge-ledger .stat-card .stat-label,
.page-platform-nwos-ledger .stat-card .stat-label {
    font-size: 0.75rem !important;
}

/* ==============================================
   TABLES - Hygrade Style
   ============================================== */

.table, table {
    margin-bottom: 1rem !important;
    color: var(--text) !important;
    --bs-table-bg: transparent !important;
    --bs-table-striped-bg: var(--surface-2) !important;
    --bs-table-hover-bg: var(--surface-hover) !important;
    --bs-table-border-color: var(--border) !important;
    font-size: 14.5px;
}

.table thead th, table thead th {
    padding: 10px 14px !important;
    line-height: 1.3 !important;
    font-family: var(--font-mono) !important;
    font-size: 11.5px !important;
    font-weight: 600 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.1em !important;
    color: var(--text-muted) !important;
    background-color: var(--surface-2) !important;
    border-color: var(--border) !important;
    white-space: nowrap;
}

.table tbody td, table tbody td {
    padding: 12px 14px !important;
    line-height: 1.45 !important;
    vertical-align: middle !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.table > thead {
    background-color: var(--surface-2) !important;
}

.table > tbody > tr > td,
.table td {
    background-color: var(--canvas) !important;
}

.table-striped > tbody > tr:nth-of-type(even) > td {
    background-color: var(--surface-2) !important;
}

.table-hover > tbody > tr:hover > td {
    background-color: var(--surface-hover) !important;
}

.table tbody tr, table tbody tr {
    height: auto !important;
    transition: background-color 0.1s ease;
}

/* Table wrapper spacing */
.table-wrapper, .table-responsive {
    margin-bottom: 1rem !important;
}

/* Table header border */
thead {
    border-bottom: 2px solid var(--border) !important;
}

/* ==============================================
   FORMS - Hygrade Style
   ============================================== */

.row {
    --bs-gutter-y: 0.75rem !important;
}

.mb-3, .my-3 {
    margin-bottom: 0.75rem !important;
}

.mb-4, .my-4 {
    margin-bottom: 1rem !important;
}

.form-group, .mb-3.row {
    margin-bottom: 0.75rem !important;
}

.form-label, label {
    margin-bottom: 0.35rem !important;
    color: var(--text) !important;
    font-size: 14px;
    font-weight: 500;
}

.form-control, .form-select, input, select, textarea {
    padding: 8px 12px !important;
    height: auto !important;
    background-color: var(--canvas) !important;
    border: 1px solid var(--border) !important;
    border-radius: 6px !important;
    color: var(--text) !important;
    font-size: 15px;
    font-family: var(--font-sans);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea.form-control {
    padding: 10px 12px !important;
}

.form-control:focus,
.form-select:focus {
    background-color: var(--surface) !important;
    border-color: #0795e2 !important;
    color: var(--text) !important;
}

.form-control::placeholder {
    color: var(--text-muted) !important;
}

.form-text, .invalid-feedback, .valid-feedback {
    margin-top: 0.25rem !important;
    font-size: 13px;
}

/* Override for specific input types */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"] {
    background-color: var(--canvas) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

/* Form group row labels */
.form-group.row > label {
    padding-top: 8px !important;
    padding-bottom: 8px !important;
}

/* Select2 dropdowns */
.select2-container--default .select2-selection--single {
    height: calc(1.5em + 1rem + 2px) !important;
    padding: 8px 12px !important;
}

/* ==============================================
   BUTTONS - Hygrade Style
   ============================================== */

.btn {
    padding: 8px 14px !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    font-family: var(--font-sans) !important;
    border-radius: 6px !important;
    transition: all 0.15s ease !important;
    line-height: 1.4;
}

.btn-sm {
    padding: 5px 10px !important;
    font-size: 13px !important;
}

.btn-lg {
    padding: 10px 18px !important;
    font-size: 16px !important;
}

/* Button groups and toolbars */
.btn-group, .btn-toolbar {
    gap: 0.3rem !important;
}

/* ==============================================
   BADGES - Hygrade Style
   ============================================== */

.badge {
    padding: 0.3em 0.6em !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    font-family: var(--font-sans) !important;
    border-radius: 5px !important;
    box-shadow: none !important;
}

/* Custom Badge Colors - Blue Gradient Theme */
.badge.bg-primary {
    background: linear-gradient(135deg, #0795e2 0%, #035688 100%) !important;
    color: white !important;
    border: none !important;
}

.badge.bg-success {
    background: linear-gradient(135deg, #0795e2 0%, #046ba6 100%) !important;
    color: white !important;
    border: none !important;
}

.badge.bg-info {
    background: linear-gradient(135deg, #2da5e8 0%, #0580c4 100%) !important;
    color: white !important;
    border: none !important;
}

.badge.bg-warning {
    background: linear-gradient(135deg, #0795e2 0%, #02416a 100%) !important;
    color: white !important;
    border: none !important;
}

.badge.bg-danger {
    background: linear-gradient(135deg, #c23a3a 0%, #7a1f1f 100%) !important;
    color: white !important;
    border: none !important;
}

/* ==============================================
   ALERTS
   ============================================== */

.alert {
    padding: 12px 16px !important;
    margin-bottom: 1rem !important;
    border-radius: 8px !important;
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
    font-size: 14px;
}

/* ==============================================
   BREADCRUMBS
   ============================================== */

.breadcrumb {
    padding: 0.5rem 0 !important;
    margin-bottom: 1rem !important;
    background-color: transparent !important;
    font-size: 14px;
}

.breadcrumb-item + .breadcrumb-item::before {
    padding-left: 0.5rem !important;
    padding-right: 0.5rem !important;
}

.breadcrumb-item,
.breadcrumb-item a {
    color: var(--text-muted) !important;
}

.breadcrumb-item.active {
    color: var(--text) !important;
}

/* ==============================================
   PAGINATION
   ============================================== */

.pagination {
    margin-bottom: 0.75rem !important;
    margin-top: 0.75rem !important;
}

/* ==============================================
   DROPDOWNS
   ============================================== */

.dropdown-menu {
    padding: 6px 0 !important;
    background-color: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.dropdown-item {
    padding: 8px 14px !important;
    color: var(--text) !important;
    font-size: 14px;
}

.dropdown-item:hover,
.dropdown-item:focus {
    background-color: var(--surface-hover) !important;
    color: #ffffff !important;
}

.dropdown-divider {
    margin: 4px 0 !important;
    border-color: var(--border);
}

/* ==============================================
   MODALS
   ============================================== */

.modal-content {
    background-color: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px !important;
    color: var(--text) !important;
}

.modal-header {
    padding: 16px 20px !important;
    border-color: var(--border) !important;
}

.modal-body {
    padding: 20px !important;
}

.modal-footer {
    padding: 12px 20px !important;
    border-color: var(--border) !important;
}

/* ==============================================
   NAV TABS
   ============================================== */

.nav-tabs {
    margin-bottom: 1rem !important;
    border-color: var(--border);
}

.nav-tabs .nav-link {
    padding: 10px 14px !important;
    font-size: 14px;
    color: var(--text-2);
}

/* ==============================================
   LIST GROUPS
   ============================================== */

.list-group-item {
    padding: 12px 16px !important;
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

/* ==============================================
   INPUT GROUPS
   ============================================== */

.input-group-text {
    padding: 8px 12px !important;
    background-color: var(--surface-2) !important;
    border-color: var(--border) !important;
    color: var(--text-2) !important;
}

/* ==============================================
   ORCHID METRICS / LEGEND
   ============================================== */

.metrics, .metrics-list {
    gap: 1rem !important;
    margin-bottom: 1rem !important;
}

.metric {
    padding: 1rem !important;
    border-radius: 8px;
}

.metric-value, .metric h3 {
    margin-bottom: 0.25rem !important;
}

.metric-label, .metric p {
    margin-bottom: 0 !important;
}

/* Orchid legend component */
.orchid-legend, .legend {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
}

.orchid-legend dl, .legend dl { margin-bottom: 0 !important; }
.orchid-legend dt, .legend dt { margin-bottom: 0.25rem !important; }
.orchid-legend dd, .legend dd { margin-bottom: 0.5rem !important; }

/* ==============================================
   COMMAND BAR
   ============================================== */

.command-bar, .btn-toolbar {
    margin-bottom: -5rem !important;
    gap: 0.5rem !important;
}

.command-bar .btn {
    margin-right: 0.25rem !important;
}

/* ==============================================
   SPACING UTILITIES - slightly reduced
   ============================================== */

.p-3 { padding: 0.75rem !important; }
.p-4 { padding: 1rem !important; }
.p-5 { padding: 1.25rem !important; }

.pt-3, .py-3 { padding-top: 0.75rem !important; }
.pt-4, .py-4 { padding-top: 1rem !important; }
.pt-5, .py-5 { padding-top: 1.25rem !important; }

.pb-3, .py-3 { padding-bottom: 0.75rem !important; }
.pb-4, .py-4 { padding-bottom: 1rem !important; }
.pb-5, .py-5 { padding-bottom: 1.25rem !important; }

.ps-3, .px-3 { padding-left: 0.75rem !important; }
.ps-4, .px-4 { padding-left: 1rem !important; }
.ps-5, .px-5 { padding-left: 1.25rem !important; }

.pe-3, .px-3 { padding-right: 0.75rem !important; }
.pe-4, .px-4 { padding-right: 1rem !important; }
.pe-5, .px-5 { padding-right: 1.25rem !important; }

.m-3 { margin: 0.75rem !important; }
.m-4 { margin: 1rem !important; }
.m-5 { margin: 1.25rem !important; }

.mt-3, .my-3 { margin-top: 0.75rem !important; }
.mt-4, .my-4 { margin-top: 1rem !important; }
.mt-5, .my-5 { margin-top: 1.25rem !important; }

/* ==============================================
   SIDEBAR - Hygrade Style (240px)
   ============================================== */

.aside,
aside,
.aside-menu,
nav.aside,
.v-md-aside {
    background-color: var(--color-menu) !important;
    width: 240px !important;
    min-width: 240px !important;
    max-width: 240px !important;
    flex: 0 0 240px !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    margin: 0 !important;
    padding-top: 0 !important;
    overflow-y: auto !important;
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
    z-index: 1040;
    border: none !important;
    transition: all 0.3s ease;
}

.aside::-webkit-scrollbar,
aside::-webkit-scrollbar,
.aside-menu::-webkit-scrollbar,
nav.aside::-webkit-scrollbar,
.v-md-aside::-webkit-scrollbar {
    display: none !important;
}

/* Sidebar nav links */
.aside-menu .nav-link, .sidebar .nav-link {
    padding: 5px 14px !important;
    font-size: 13.5px !important;
    font-weight: 500 !important;
    font-family: var(--font-sans) !important;
    color: var(--text-2) !important;
    border-left: 3px solid transparent;
    transition: all 0.15s ease;
    line-height: 1.4 !important;
}

/* Sidebar section labels (uppercase monospace) */
.aside .nav-link.p-0,
.aside-menu .nav-link.p-0,
.aside .list-group-item-action.p-0,
.aside-collapse-toggle,
.aside .nav-item > .nav-link[data-bs-toggle],
.aside-menu small,
aside .nav-item > span,
.v-md-aside .list-group span.text-muted {
    font-family: var(--font-mono) !important;
    font-size: 10px !important;
    text-transform: uppercase !important;
    letter-spacing: 0.12em !important;
    color: var(--text-muted) !important;
    font-weight: 600 !important;
    padding-top: 10px !important;
    padding-bottom: 2px !important;
}

/* Reduce spacing between sidebar nav items */
.aside .nav-item,
.aside-menu .nav-item,
aside .nav-item {
    margin-bottom: 0 !important;
}

.aside .nav,
.aside-menu .nav,
aside .nav {
    row-gap: 0 !important;
    gap: 0 !important;
}

/* Offset main content for fixed sidebar */
.container-fluid > .row > .col-xxl,
.container-fluid > .row > .col-xl-9,
.container-fluid > .row > .col-12:not(.aside) {
    margin-left: 246px !important;
}

/* Remove container-fluid left padding so sidebar is flush */
.container-fluid {
    padding-left: 0 !important;
}

/* Remove white line between sidebar and content */
.row {
    --bs-gutter-x: 0 !important;
}

.aside + .col-xxl,
.aside + .col-xl-9,
aside + .col-xxl,
aside + .col-xl-9 {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* Remove any white/light borders on sidebar */
.aside,
aside,
.col-xxl,
.col-xl-9 {
    border: none !important;
}

/* ==============================================
   SIDEBAR TOGGLE FUNCTIONALITY
   ============================================== */

.sidebar-toggle-btn {
    position: fixed;
    top: 6px;
    left: 228px;
    z-index: 1050;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    font-size: 0.65rem;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s ease;
}

.sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: var(--text);
}

/* When sidebar is hidden */
body.sidebar-collapsed .aside,
body.sidebar-collapsed aside,
body.sidebar-collapsed .aside-menu,
body.sidebar-collapsed nav.aside,
body.sidebar-collapsed .v-md-aside {
    transform: translateX(-100%);
    width: 0 !important;
    min-width: 0 !important;
    overflow: hidden;
    opacity: 0;
    padding: 0 !important;
    margin: 0 !important;
}

body.sidebar-collapsed .aside-collapse {
    display: none !important;
}

/* Expand main content when sidebar hidden */
body.sidebar-collapsed .workspace,
body.sidebar-collapsed main,
body.sidebar-collapsed .main-content,
body.sidebar-collapsed .v-md-workspace {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.sidebar-collapsed .container-fluid > .row > .col-xxl,
body.sidebar-collapsed .container-fluid > .row > .col-xl-9,
body.sidebar-collapsed .container-fluid > .row > .col-12:not(.aside) {
    margin-left: 0 !important;
}

body.sidebar-collapsed .container-fluid {
    padding-left: 1rem !important;
}

/* When sidebar is collapsed, keep button at top-left corner */
body.sidebar-collapsed .sidebar-toggle-btn {
    left: 6px;
}

/* Smooth transitions */
.workspace,
main,
.main-content,
.v-md-workspace,
.sidebar-toggle-btn {
    transition: all 0.3s ease;
}

/* ==============================================
   WORKSPACE PADDING
   ============================================== */

.workspace,
.v-md-workspace,
main.workspace {
    padding-left: 0.5rem !important;
}

body.sidebar-collapsed .workspace,
body.sidebar-collapsed main.workspace {
    padding-left: 2rem !important;
}

/* ==============================================
   DARK MODE - Backgrounds
   ============================================== */

/* Global dark background */
.container-fluid,
.container-fluid > .row,
.col-xxl,
.col-xl-9,
.col-12,
.mx-auto {
    background-color: var(--canvas) !important;
}

/* Main content background */
.workspace,
main.workspace,
.v-md-workspace {
    background-color: var(--canvas) !important;
}

/* Screen/content area */
.screen,
#post-form {
    background-color: var(--canvas) !important;
    color: var(--text) !important;
}

/* ==============================================
   DARK MODE - BG-WHITE OVERRIDES
   ============================================== */

.bg-white,
.bg-light,
.bg-body,
[class*="bg-white"],
[class*="bg-light"],
div.bg-white,
div.bg-light,
.bg-white.rounded,
.bg-white.rounded.shadow-sm,
.bg-white.rounded.shadow-sm.p-4,
.bg-white.rounded.shadow-sm.p-3,
.bg-white.rounded.shadow-sm.p-4.mb-3,
.bg-white.rounded.shadow-sm.p-3.mb-3,
.screen .bg-white,
.screen div.bg-white,
.screen > div,
.screen > .bg-white,
#post-form > div,
#post-form .bg-white,
.workspace .bg-white,
.layout .bg-white,
fieldset .bg-white,
.d-flex.flex-column .bg-white {
    background-color: var(--canvas) !important;
    background: var(--canvas) !important;
}

/* Orchid layout wrappers */
.screen > div.bg-white.rounded.shadow-sm,
.screen > fieldset > div.bg-white,
fieldset > .col-12 > .bg-white,
fieldset .shadow-sm,
.layout-wrapper,
.d-flex.flex-column.layout-wrapper {
    background-color: var(--canvas) !important;
    background: var(--canvas) !important;
}

/* Force all direct children of screen to be dark */
.screen > * {
    background-color: var(--canvas);
}

/* Override any inline white backgrounds */
[style*="background-color: white"],
[style*="background-color: #fff"],
[style*="background-color: #ffffff"],
[style*="background: white"],
[style*="background: #fff"],
[style*="background: #ffffff"] {
    background-color: var(--canvas) !important;
    background: var(--canvas) !important;
}

/* ==============================================
   DARK MODE - TEXT COLORS
   ============================================== */

.text-muted { color: var(--text-muted) !important; }
.text-body, .text-body-emphasis { color: var(--text) !important; }
.text-dark { color: var(--text) !important; }

/* Page titles and descriptions */
header h1,
header small,
.command-bar-wrapper h1,
.command-bar-wrapper small {
    color: var(--text) !important;
}

.fw-light,
h1.fw-light,
h1.m-0 {
    color: var(--text) !important;
}

/* Legend/metric card text */
.legend,
.legend span,
.legend small,
.bg-white span,
.bg-white small,
.rounded span,
.rounded small {
    color: var(--text) !important;
}

/* Month/group header rows in tables */
.table tr.bg-light,
.table tr[class*="bg-"],
.table .bg-light,
.table .text-muted,
tr.bg-light td,
tr.bg-light th {
    background-color: var(--canvas) !important;
    color: var(--text) !important;
}

/* Fieldset legends */
fieldset,
legend {
    color: var(--text) !important;
}

/* Any remaining gray text */
.text-secondary,
.text-gray,
.text-black-50 {
    color: var(--text-muted) !important;
}

/* Orchid metrics component */
[class*="metric"],
.metrics span,
.metrics small,
.metrics div {
    color: var(--text) !important;
}

.link-body-emphasis {
    color: var(--text) !important;
}

/* ==============================================
   DARK MODE - TomSelect
   ============================================== */

.ts-control,
.ts-wrapper .ts-control {
    background-color: var(--canvas) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.ts-control input,
.ts-control .item {
    color: var(--text) !important;
}

.ts-control.focus,
.ts-wrapper.focus .ts-control {
    background-color: var(--surface) !important;
    border-color: #0795e2 !important;
    color: var(--text) !important;
}

.ts-dropdown,
.ts-dropdown-content {
    background-color: var(--surface) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.ts-dropdown .option,
.ts-dropdown .optgroup-header,
.ts-dropdown .no-results {
    color: var(--text) !important;
    background-color: var(--surface) !important;
}

.ts-dropdown .option:hover,
.ts-dropdown .option.active {
    background-color: var(--surface-hover) !important;
    color: #ffffff !important;
}

.ts-dropdown .option.selected {
    background-color: #0795e2 !important;
    color: #ffffff !important;
}

/* ==============================================
   BUTTON OUTLINE STYLES - Dark Mode Visible
   ============================================== */

.btn-outline-warning {
    color: #ffc107 !important;
    border-color: #ffc107 !important;
    background-color: transparent !important;
}

.btn-outline-warning:hover,
.btn-outline-warning:focus,
.btn-outline-warning:active {
    color: #000 !important;
    background-color: #ffc107 !important;
    border-color: #ffc107 !important;
}

.btn-outline-secondary {
    color: #adb5bd !important;
    border-color: #adb5bd !important;
    background-color: transparent !important;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
    color: #000 !important;
    background-color: #adb5bd !important;
}

.btn-secondary {
    background-color: #6c757d !important;
    border-color: #6c757d !important;
    color: #fff !important;
}

/* ==============================================
   PAGE HEADER / COMMAND BAR - Force Dark Background
   ============================================== */

.command-bar,
.command-bar-wrapper,
.d-flex.flex-wrap.mb-2,
.d-sm-flex.align-items-center.justify-content-between,
header.d-sm-flex,
.screen > header,
.screen > div:first-child,
.row.g-0.mb-2,
div[class*="command"],
.mb-md-0,
.order-first,
.order-last {
    background-color: var(--canvas) !important;
    background: var(--canvas) !important;
}

/* Page title area specifically */
.screen > .row:first-child,
.screen > .d-flex:first-child,
.screen > .d-sm-flex:first-child,
.screen > .mb-2:first-child,
.screen > .mb-3:first-child {
    background-color: var(--canvas) !important;
}

/* Title text */
.screen h1,
.screen h2,
.screen .h1,
.screen .h2,
.command-bar h1,
.command-bar-wrapper h1,
header h1 {
    color: #0795e2 !important;
    background-color: transparent !important;
}

/* Description text */
.screen small,
.screen p.text-muted,
.command-bar small,
header small {
    color: var(--text-muted) !important;
    background-color: transparent !important;
}

/* Orchid header wrapper */
.bg-white.rounded.shadow-sm.mb-2,
.bg-white.rounded.shadow-sm.mb-3 .d-flex,
.p-4.mb-3.d-flex,
.d-flex.flex-wrap {
    background-color: var(--canvas) !important;
    background: var(--canvas) !important;
}

/* Nuclear option - any element with white bg in screen */
.screen *[style*="background"] {
    background-color: var(--canvas) !important;
}

/* Override body */
body, html {
    background-color: var(--canvas) !important;
}

/* ==============================================
   BOOTSTRAP 5.3 DARK MODE OVERRIDES
   ============================================== */

.text-body-emphasis { color: var(--text) !important; }
.text-body { color: var(--text) !important; }

/* Command bar wrapper specific */
.command-bar-wrapper { background-color: var(--canvas) !important; }
.command-bar-wrapper .layout { background-color: var(--canvas) !important; }
.command-bar-wrapper header { background-color: var(--canvas) !important; }
.command-bar-wrapper h1 { color: #0795e2 !important; background: transparent !important; }
.command-bar-wrapper small { color: var(--text-muted) !important; }

/* Main content column */
.col-xxl.col-xl-9,
.col-xxl,
.mx-auto {
    background-color: var(--canvas) !important;
}

/* Workspace area */
.workspace,
.workspace-limit {
    background-color: var(--canvas) !important;
}

/* Container */
.container-fluid,
.container-xl {
    background-color: var(--canvas) !important;
}

/* Row backgrounds */
.row {
    background-color: transparent !important;
}

/* Any div with body bg via Bootstrap */
div[class*="bg-body"],
.bg-body,
.bg-body-secondary,
.bg-body-tertiary {
    background-color: var(--canvas) !important;
}

/* ==============================================
   DARK MODE - Shadows & Borders
   ============================================== */

.shadow-sm {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
}

.border {
    border-color: var(--border) !important;
}

.rounded {
    background-color: var(--canvas) !important;
}

/* ==============================================
   STAT CARDS - Dashboard Wells (Global)
   ============================================== */

.stat-cards-row {
    display: grid !important;
    grid-template-columns: repeat(6, 1fr) !important;
    gap: 8px !important;
}

.stat-card {
    background: var(--surface-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
    padding: 8px 10px !important;
    text-align: center !important;
}

.stat-card .stat-value {
    font-size: 1.1rem !important;
    font-weight: 700 !important;
    font-family: var(--font-mono) !important;
    line-height: 1.2 !important;
    color: var(--text) !important;
}

.stat-card .stat-label {
    font-size: 0.65rem !important;
    font-family: var(--font-mono) !important;
    color: var(--text-muted) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
}

.stat-card.highlight {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
}

.stat-card.highlight .stat-value {
    color: white !important;
}

.stat-card.highlight .stat-label {
    color: rgba(255,255,255,0.8) !important;
}

/* Month divider rows in tables */
.month-divider {
    background: var(--border-light) !important;
    color: var(--text) !important;
}

.month-divider td {
    background: var(--border-light) !important;
    color: var(--text) !important;
}

.month-divider .month-name {
    color: var(--text) !important;
}

/* Kalshi menu balance - muted style */
.aside-menu a[href*="kalshi"] .badge {
    background: transparent !important;
    color: var(--text-muted) !important;
    font-weight: normal !important;
    font-size: 0.8rem !important;
}

/* Remove workspace width constraints */
.workspace-limit {
    max-width: none !important;
}
.container-xl {
    max-width: 100% !important;
}

/* ==============================================
   CUSTOM METRIC CARD COLORS - Blue Gradient
   ============================================== */

.metrics .metric:nth-child(1) {
    background: linear-gradient(135deg, #0795e2 0%, #035688 100%) !important;
    color: white !important;
}

.metrics .metric:nth-child(2) {
    background: linear-gradient(135deg, #0795e2 0%, #02416a 100%) !important;
    color: white !important;
}

.metrics .metric:nth-child(3) {
    background: linear-gradient(135deg, #2da5e8 0%, #0580c4 100%) !important;
    color: white !important;
}

.metrics .metric:nth-child(4) {
    background: linear-gradient(135deg, #0795e2 0%, #046ba6 100%) !important;
    color: white !important;
}

.metrics .metric:nth-child(5) {
    background: linear-gradient(135deg, #53b5ee 0%, #035688 100%) !important;
    color: white !important;
}

.metrics .metric:nth-child(6) {
    background: linear-gradient(135deg, #0795e2 0%, #012c4c 100%) !important;
    color: white !important;
}

.metrics .metric h3,
.metrics .metric p,
.metrics .metric .metric-value,
.metrics .metric .metric-label {
    color: white !important;
}

.metrics .metric {
    box-shadow: 0 4px 6px rgba(7, 149, 226, 0.15) !important;
    border: none !important;
}

/* ==============================================
   HIDE EMPTY HEADERS / CONFIGURE COLUMNS
   ============================================== */

/* Hide empty screen headers */
.screen-header:empty,
.page-header:empty {
    display: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.bg-white.rounded.shadow-sm.p-4.mb-3 h1:empty,
.bg-white.rounded.shadow-sm.p-4.mb-3 h2:empty,
.bg-white.rounded.shadow-sm.p-4.mb-3 .h1:empty,
.bg-white.rounded.shadow-sm.p-4.mb-3 .h2:empty {
    display: none !important;
}

/* Hide empty title and description in Orchid screens */
.bg-white.rounded.shadow-sm.p-4.mb-3:has(h1:only-child:empty),
.bg-white.rounded.shadow-sm.p-3.mb-3:has(h1:only-child:empty),
div[class*="bg-white"]:has(> h1:only-child:empty),
div[class*="bg-white"]:has(> h2:only-child:empty) {
    display: none !important;
}

/* Target empty header sections */
.bg-white.rounded:empty {
    display: none !important;
}

/* Reduce margin on custom header cards */
.bg-white.rounded.shadow-sm.mb-3,
.bg-white.rounded.shadow-sm.mb-2 {
    margin-bottom: 0.5rem !important;
}

/* Remove top margin/padding from first screen element */
.screen > .bg-white:first-child:empty {
    display: none !important;
}

/* Command bar when empty */
.command-bar:empty {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

.command-bar-wrapper:has(.command-bar:empty) {
    display: none !important;
}

.command-bar-wrapper:has(h1:empty) {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Aggressively hide Orchid's auto-generated header wrapper */
.wrapper .screen > div:first-of-type:not(.row):not([id]) {
    display: none !important;
}

/* Target the specific Orchid header container */
.bg-white.rounded.shadow-sm.p-4.mb-3:not(:has(*:not(:empty))) {
    display: none !important;
}

/* When screen title/description is null/empty */
.screen > div:first-child:empty,
.screen > div:first-child:has(> :empty:only-child) {
    display: none !important;
}

/* Hide configure columns button from all table views */
.btn-group.dropup {
    display: none !important;
}

/* ==============================================
   FIX TABLE LAYOUT ISSUES
   ============================================== */

.page-platform-customers-list #post-form,
.page-platform-projects-list #post-form {
    height: auto !important;
    min-height: auto !important;
}

.page-platform-customers-list .workspace,
.page-platform-projects-list .workspace {
    height: auto !important;
}

form#post-form {
    height: auto !important;
}

.workspace.h-100 {
    height: auto !important;
}

/* ==============================================
   ORCHID SCREEN CONTENT SPACING
   ============================================== */

.screen-content {
    margin-bottom: 1rem !important;
}

.screen-footer {
    padding-top: 1rem !important;
}

/* Reduce spacing between form rows */
.bg-white.rounded.shadow-sm.p-4.mb-3,
.bg-white.rounded.shadow-sm.p-3.mb-3 {
    padding: 1rem !important;
    margin-bottom: 1rem !important;
}

/* Compact filter controls */
.filter-item {
    margin-bottom: 0.5rem !important;
}

/* DL spacing in white containers */
.bg-white dl { margin-bottom: 0 !important; }
.bg-white dt { margin-bottom: 0.25rem !important; padding-top: 0.5rem !important; }
.bg-white dd { margin-bottom: 0.5rem !important; padding-bottom: 0.5rem !important; }

/* Metrics cards */
.bg-white.rounded.shadow-sm {
    background-color: var(--canvas) !important;
}

/* ==============================================
   FLATPICKR DATE PICKER - Dark Mode
   ============================================== */

.flatpickr-calendar {
    background: var(--color-menu) !important;
    border: 1px solid var(--border) !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5) !important;
    border-radius: 8px !important;
}

.flatpickr-months {
    background: var(--color-menu) !important;
}

.flatpickr-months .flatpickr-month {
    background: var(--color-menu) !important;
    color: var(--text) !important;
    fill: var(--text) !important;
}

.flatpickr-current-month {
    color: var(--text) !important;
    font-family: var(--font-sans) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months {
    background: var(--color-menu) !important;
    color: var(--text) !important;
}

.flatpickr-current-month .flatpickr-monthDropdown-months option {
    background: var(--color-menu) !important;
    color: var(--text) !important;
}

.flatpickr-current-month input.cur-year {
    color: var(--text) !important;
}

.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--text) !important;
    fill: var(--text) !important;
}

.flatpickr-months .flatpickr-prev-month svg,
.flatpickr-months .flatpickr-next-month svg {
    fill: var(--text) !important;
}

.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    color: #ffffff !important;
}

.flatpickr-months .flatpickr-prev-month:hover svg,
.flatpickr-months .flatpickr-next-month:hover svg {
    fill: #ffffff !important;
}

.flatpickr-weekdays {
    background: var(--color-menu) !important;
}

span.flatpickr-weekday {
    background: var(--color-menu) !important;
    color: var(--text-muted) !important;
    font-weight: 600 !important;
    font-family: var(--font-mono) !important;
    font-size: 10px !important;
}

.flatpickr-days {
    background: var(--color-menu) !important;
    border: none !important;
}

.dayContainer {
    background: var(--color-menu) !important;
}

.flatpickr-day {
    color: var(--text) !important;
    border-color: transparent !important;
    border-radius: 6px !important;
    font-family: var(--font-sans) !important;
}

.flatpickr-day:hover {
    background: var(--surface-hover) !important;
    border-color: var(--border) !important;
    color: #ffffff !important;
}

.flatpickr-day.today {
    border-color: #0795e2 !important;
}

.flatpickr-day.today:hover {
    background: #0795e2 !important;
    color: #ffffff !important;
}

.flatpickr-day.selected,
.flatpickr-day.selected:hover {
    background: #0795e2 !important;
    border-color: #0795e2 !important;
    color: #ffffff !important;
}

.flatpickr-day.prevMonthDay,
.flatpickr-day.nextMonthDay {
    color: var(--text-muted) !important;
}

.flatpickr-day.prevMonthDay:hover,
.flatpickr-day.nextMonthDay:hover {
    background: var(--surface-hover) !important;
    color: var(--text-2) !important;
}

.flatpickr-day.flatpickr-disabled,
.flatpickr-day.flatpickr-disabled:hover {
    color: var(--border) !important;
}

.numInputWrapper span {
    border-color: var(--border) !important;
}

.numInputWrapper span:hover {
    background: var(--surface-hover) !important;
}

.numInputWrapper span svg path {
    fill: var(--text) !important;
}

.flatpickr-time {
    background: var(--color-menu) !important;
    border-top: 1px solid var(--border) !important;
}

.flatpickr-time input {
    color: var(--text) !important;
    background: var(--color-menu) !important;
}

.flatpickr-time .flatpickr-am-pm {
    color: var(--text) !important;
    background: var(--color-menu) !important;
}

.flatpickr-time .flatpickr-am-pm:hover {
    background: var(--surface-hover) !important;
}

/* ==============================================
   PRIVACY MODE - Hide financial totals bar
   ============================================== */

body.privacy-blur .fin-summary-row {
    display: none !important;
}
