@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500&family=IBM+Plex+Sans:wght@300;400;500;600;700;800&display=swap');

/* ===== GLOBAL ===== */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #FFFFFF;
    color: #222222;
}

.neg {
    color: #b00020 !important;
}

.negative,
.metric-negative,
.text-danger {
    color: #b00020 !important;
}

body.dark-mode .neg {
    color: #ff7a8a !important;
}

body.dark-mode .negative,
body.dark-mode .metric-negative,
body.dark-mode .text-danger {
    color: #ff7a8a !important;
}

/* ===== P&L SUMMARY TABLE DARK MODE FIX ===== */
body.dark-mode .pnl-sticky-table thead th {
    background: #243447 !important;
    color: #dbe9f7 !important;
    border-color: #3a526d !important;
}
body.dark-mode .pnl-sticky-table th:first-child,
body.dark-mode .pnl-sticky-table td:first-child {
    background: #1e2d3d !important;
    color: #dbe9f7 !important;
    border-color: #3a526d !important;
    min-width: 180px !important;
    box-sizing: border-box;
}
.pnl-sticky-table th:first-child,
.pnl-sticky-table td:first-child {
    min-width: 180px;
    box-sizing: border-box;
}
body.dark-mode .pnl-sticky-table thead th:first-child {
    z-index: 4;
}
body.dark-mode .pnl-sticky-table td {
    border-color: #31465c !important;
}

/* ===== HEADER ===== */
header {
    padding: 10px 20px;
    background-color: #0070C0;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo-title .app-title {
    font-size: 24px;
    font-weight: bold;
    color: #fff;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-toggle {
    background-color: #005A9C;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-weight: bold;
    cursor: pointer;
}

.nav-toggle:hover {
    background-color: #004b82;
}

.theme-toggle {
    background-color: #005A9C;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    font-weight: bold;
    cursor: pointer;
}

.theme-toggle:hover {
    background-color: #004b82;
}

/* ===== LAYOUT ===== */
.layout {
    display: flex; /* sidebar + main side by side */
    align-items: stretch; /* make children match height */
    min-height: 100vh; /* ensure layout is at least full viewport tall */
}

.layout.nav-hidden nav {
    display: none;
}

/* ===== SIDEBAR NAV ===== */
nav {
    width: 200px;
    background-color: #005A9C;
    padding: 20px;
    display: flex;
    flex-direction: column; /* stack buttons vertically */
    gap: 10px;
    min-height: 100vh; /* at least viewport tall; will stretch if main grows */
    align-self: stretch; /* allow flexbox to stretch this column to match content height */
}

nav button {
    width: 100%;
    background-color: #0070C0;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 10px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

nav button:hover {
    background-color: #005A9C;
}

/* Dropdown container */
.dropdown {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
}

/* Dropdown button styling */
.dropbtn {
    cursor: pointer;
    width: 100%;
}

/* Dropdown content hidden by default */
.dropdown-content {
    display: none;
    background-color: #005A9C;
    box-shadow: 0px 4px 8px rgba(0,0,0,0.1);
    z-index: 1;
    flex-direction: column;
    gap: 10px;
    padding: 10px;
    margin-top: 5px;
}

/* Links inside dropdown */
.dropdown-content button {
    width: 100%;
    background-color: #0070C0;
    color: white;
}

.dropdown-content button:hover {
    background-color: #005A9C;
}

/* Show dropdown when open class is applied */
.dropdown.open .dropdown-content {
    display: flex;
}

/* ===== MAIN CONTENT ===== */
main {
    flex: 1;
    padding: 20px;
}

/* ===== TABLE STYLING ===== */
table {
    border-collapse: collapse;
    width: 100%;
    margin-top: 20px;
}

th, td {
    padding: 10px;
    border: 1px solid #DDD;
    text-align: left;
}

th {
    background-color: #F9F9F9;
}

th.sortable-header {
    cursor: pointer;
}

th.reorderable-header {
    user-select: none;
}

th.reorderable-header.dragging-column {
    opacity: 0.55;
}

th.reorderable-header.drag-over-column {
    outline: 2px dashed #0070c0;
    outline-offset: -3px;
}

th.reorderable-header.drag-over-column-before {
    box-shadow: inset 3px 0 0 #0070c0;
}

th.reorderable-header.drag-over-column-after {
    box-shadow: inset -3px 0 0 #0070c0;
}

th.sortable-header.sort-asc::after,
th.sortable-header.sort-desc::after {
    margin-left: 6px;
    font-size: 12px;
    opacity: 0.85;
}

th.sortable-header.sort-asc::after {
    content: "▲";
}

th.sortable-header.sort-desc::after {
    content: "▼";
}

/* ===== FORM ELEMENTS ===== */
input, select, textarea {
    padding: 8px;
    width: 100%;
    border: 1px solid #CCCCCC;
    border-radius: 3px;
    margin-top: 4px;
    margin-bottom: 12px;
}

/* ===== BUTTONS INSIDE MAIN CONTENT ===== */
main button {
    background-color: #0070C0;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

main button:hover {
    background-color: #005A9C;
}

/* Make table rows clickable */
table tr.clickable-row {
    cursor: pointer;
}

[onclick],
#costChart,
#monthlyChart {
    cursor: pointer;
}

/* Optional: highlight row on hover */
table tr.clickable-row:hover {
    background-color: #f0f0f0; /* adjust to your theme */
}

/* Alternate selector for tables marked as clickable-table */
.clickable-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.clickable-table tbody tr:hover {
    background-color: #f0f0f0;
}

#equipment-table tbody tr,
#material-table tbody tr,
#labour-table tbody tr,
#disposal-table tbody tr {
    cursor: pointer;
}

.list-controls {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin: 8px 0 10px;
}

.list-controls .list-filter-input,
.list-controls .list-sort-column,
.list-controls .list-sort-direction {
    width: auto;
    min-width: 170px;
    margin: 0;
}

.list-controls .list-filter-status {
    font-size: 13px;
    color: #666;
    margin-left: auto;
}

.list-controls .column-controls {
    position: relative;
}

.list-controls .column-controls > summary {
    list-style: none;
    cursor: pointer;
    user-select: none;
    font-size: 13px;
    border: 1px solid #d0d7e2;
    border-radius: 6px;
    padding: 6px 10px;
    background: #ffffff;
}

.list-controls .column-controls > summary::-webkit-details-marker {
    display: none;
}

.list-controls .column-controls-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 220px;
    max-height: 280px;
    overflow: auto;
    background: #ffffff;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.12);
    padding: 8px;
    z-index: 50;
}

.column-toggle-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 2px;
    font-size: 13px;
}

.column-toggle-item input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.dashboard-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 0;
}

.dashboard-item-row .column-toggle-item {
    flex: 1;
    min-width: 0;
}

.dashboard-card-color-input {
    width: 28px;
    min-width: 28px;
    height: 20px;
    border: 1px solid #9fb2ca;
    border-radius: 6px;
    padding: 0;
    margin: 0;
    background: transparent;
    cursor: pointer;
}

th.resizable-column {
    position: relative;
}

.column-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 8px;
    height: 100%;
    cursor: col-resize;
    user-select: none;
    touch-action: none;
}

.column-resizer:hover {
    background: rgba(0, 112, 192, 0.2);
}

.filter-banner {
    margin: 8px 0 14px;
    padding: 8px 12px;
    border: 1px solid #d6e3f0;
    border-radius: 6px;
    background-color: #f3f8fd;
    color: #1f2d3d;
    font-size: 13px;
}

table tfoot .subtotal-row td {
    font-weight: 600;
    background: var(--surface2);
    color: var(--text);
    border-color: var(--border);
}

.subtotal-row td:first-child {
    white-space: nowrap;
}

/* list-controls dark mode handled in the main dark-mode overrides section */

body.dark-mode .dashboard-card-color-input {
    border-color: #4a6280;
}

body.dark-mode .dashboard-drop-zone-active {
    outline-color: rgba(125, 211, 252, 0.45);
}

body.dark-mode .column-resizer:hover {
    background: rgba(125, 211, 252, 0.25);
}

body.dark-mode th.reorderable-header.drag-over-column {
    outline-color: #7dd3fc;
}

body.dark-mode th.reorderable-header.drag-over-column-before {
    box-shadow: inset 3px 0 0 #7dd3fc;
}

body.dark-mode th.reorderable-header.drag-over-column-after {
    box-shadow: inset -3px 0 0 #7dd3fc;
}

/* Package detail page styling */
.package-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 30px 0;
}

.summary-card {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
}

.summary-card h3 {
    margin: 0 0 10px 0;
    color: #666;
    font-size: 14px;
    text-transform: uppercase;
}

.summary-value {
    margin: 0;
    font-size: 24px;
    font-weight: bold;
    color: #333;
}

.item-type {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.item-type-equipment {
    background-color: #e3f2fd;
    color: #1976d2;
}

.item-type-material {
    background-color: #f3e5f5;
    color: #7b1fa2;
}

.item-type-labour {
    background-color: #e8f5e9;
    color: #388e3c;
}

.item-type-disposal {
    background-color: #fce4ec;
    color: #c2185b;
}

.mode-badge {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
}

.mode-fixed {
    background-color: #f3f5f5;
    color: #6a1b9a;
}

.mode-dynamic {
    background-color: #e3f2fd;
    color: #1565c0;
}

.cost-hint {
    font-size: 12px;
    color: #999;
    font-weight: normal;
}

.header-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Package item form styling */
.price-display {
    background: #f5f5f5;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.price-display label {
    font-weight: bold;
    margin: 0;
}

.price-display span {
    font-size: 18px;
    font-weight: bold;
    color: #1976d2;
}

body.dark-mode .price-display {
    background: #223244;
    border: 1px solid #425367;
}

body.dark-mode .price-display label {
    color: #f8fafc;
}

body.dark-mode .price-display span {
    color: #8ec5ff;
}

/* Bulk action bar styling to ensure legibility in light and dark modes */
#bulk-action-bar {
     display: inline-flex;
     align-items: center;
     gap: 0.5rem;
     padding: 0.35rem 0.6rem;
     border: 1px solid var(--border-color, #ddd);
     border-radius: 4px;
     background: var(--bg-subtle, #f5f5f5);
     color: var(--text-primary, #222);
}

 #bulk-action-bar select,
 #bulk-action-bar button {
     font-size: 0.85em;
 }

 body.dark-mode #bulk-action-bar {
     background: #223244;
     border-color: #425367;
     color: #f1f5f9;
 }

 body.dark-mode #bulk-action-bar select,
 body.dark-mode #bulk-action-bar button {
     background: #1a2531;
     color: #f1f5f9;
     border-color: #425367;
 }

/* Ensure dropdown option text is readable in dark mode for bulk selects */
#bulk-action-bar select,
#bulk-action-bar select option {
    background: var(--bg-card, #ffffff) !important;
    color: var(--text-primary, #222222) !important;
}

body.dark-mode #bulk-action-bar select,
body.dark-mode #bulk-action-bar select option {
    background: #1a2531 !important;
    color: #f1f5f9 !important;
}

.checkbox-group {
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    margin: 0;
    font-weight: normal;
}

.checkbox-group input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-group span {
    cursor: pointer;
}

.hint-text {
    display: block;
    font-size: 13px;
    color: #666;
    margin-top: 5px;
}

/* CSV Upload Styling */
.csv-upload-section {
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin: 15px 0;
}

.csv-upload-section h3 {
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 16px;
    color: #333;
}

.csv-upload-section form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.csv-upload-section input[type="file"] {
    width: auto;
    flex: 1;
    margin: 0;
}

.csv-upload-section button {
    width: auto;
    padding: 8px 16px;
}

.form-hint {
    margin: 4px 0 8px;
    font-size: 11px;
    color: var(--dim);
    font-style: italic;
}

/* Flash Messages */
.flash-messages {
    margin: 20px 0;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ===== NAV ICONS: SIMPLE OUTLINE STYLE ===== */
nav button::before,
.dropbtn::before,
.dropdown-content button::before {
    content: none !important;
}

nav button,
.dropbtn,
.dropdown-content button {
    padding-left: 12px !important;
}

.nav-item-content {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.dropdown-content .nav-item-content {
    justify-content: flex-start;
}

.nav-icon {
    display: inline-flex;
    width: 14px;
    height: 14px;
    flex: 0 0 14px;
    opacity: 0.92;
}

.nav-icon svg {
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-section-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--dim);
    font-size: 11px;
    font-family: var(--mono);
    font-weight: 400;
    letter-spacing: 0.06em;
}

.app-shell-single {
    width: min(100% - 32px, 1280px);
    margin: 16px auto;
    display: block;
}

.app-portal-wrap {
    background: transparent;
}

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

.app-portal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    display: flex;
    flex-direction: column;
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.app-portal-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent, var(--brand-blue));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.app-portal-card:hover {
    border-color: var(--border-bright);
    background: var(--surface2);
    transform: translateY(-1px);
}

.app-portal-card:active {
    transform: translateY(0);
}

.auth-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    max-width: 520px;
}

.auth-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

a.nav-toggle,
a.theme-toggle {
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.forecast-form-grid .forecast-notes {
    grid-column: 1 / -1;
}

/* .app-section-badge uses CSS variables — no dark-mode override needed */

.blank-canvas-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 320px;
}

/* ── System-wide health banner ────────────────────────────── */
.forecasting-health-banner {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.health-banner-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    border-radius: 5px;
    font-size: 0.875rem;
    font-weight: 500;
}

.health-banner-danger {
    background: #4a1a1a;
    color: #f8a0a0;
    border: 1px solid #7a2a2a;
}

.health-banner-warning {
    background: #3d2e00;
    color: #f5c842;
    border: 1px solid #6b5200;
}

.health-banner-msg {
    flex: 1;
}

.health-banner-link {
    color: inherit;
    text-decoration: underline;
    white-space: nowrap;
}

.health-banner-dismiss {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.7;
}

.health-banner-dismiss:hover {
    opacity: 1;
}

#forecastingLayout,
#forecastingNav,
#forecastingNav .dropdown {
    overflow: visible;
}

#forecastingNav {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

#forecastingLayout.nav-hidden #forecastingNav {
    display: none !important;
}

#forecastingNav > button,
#forecastingNav > .dropdown > .dropbtn {
    width: auto !important;
    flex: 0 0 auto !important;
    text-align: center !important;
    order: 1;
}

#forecastingNav .dropdown {
    display: contents;
}

#forecastingNav .dropdown-content {
    position: static !important;
    display: none;
    flex-basis: 100%;
    order: 2;
    margin-top: 6px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

#forecastingNav .dropdown.open .dropdown-content {
    display: flex !important;
    visibility: visible !important;
    pointer-events: auto;
}

#forecastingNav .dropdown-content button {
    width: auto !important;
}

.forecast-dashboard-static .stats-cards,
.forecast-dashboard-static .chart-cards {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    grid-auto-rows: auto !important;
    grid-auto-flow: row !important;
    gap: 12px !important;
    justify-content: stretch !important;
    align-items: stretch !important;
}

.forecast-dashboard-static .stats-cards .dashboard-widget,
.forecast-dashboard-static .chart-cards .dashboard-widget {
    min-height: 118px !important;
    max-width: none !important;
    max-height: none !important;
}

#forecastingLayout main .stats-cards,
#forecastingLayout main .chart-cards {
    display: grid !important;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
    grid-auto-rows: auto !important;
    grid-auto-flow: row !important;
    gap: 12px !important;
    justify-content: stretch !important;
    align-items: stretch !important;
}

#forecastingLayout main .stats-cards .dashboard-widget,
#forecastingLayout main .chart-cards .dashboard-widget {
    min-height: 118px !important;
    max-width: none !important;
    max-height: none !important;
}

.forecast-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ===== FINAL CHART TITLE BAND STYLE ===== */
.chart-cards .dashboard-widget {
    display: flex !important;
    flex-direction: column !important;
    padding: 0 !important;
    overflow: hidden !important;
}

.chart-cards .dashboard-widget .card-body {
    order: 1 !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
}

.chart-cards .dashboard-widget:not([data-widget-id="jobs_map"]) .card-body {
    padding: 12px !important;
}

.chart-cards .dashboard-widget .card-header {
    order: 2 !important;
    margin: 0 !important;
    padding: 10px 12px !important;
    border-top: 1px solid rgba(255, 255, 255, 0.12) !important;
    background: var(--dashboard-accent-color, #5b84d7) !important;
    color: #ffffff !important;
    font-size: 12px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.45px !important;
    box-shadow: none !important;
}

/* ===== DEFINITIVE DASHBOARD ITEMS WIDTH FIX (keep last) ===== */
.dashboard-controls,
.dashboard-controls .column-controls,
#dashboardItemsControls,
#dashboardItemsControls[open],
#dashboardItemsControls .column-controls-menu {
    overflow: visible !important;
}

.dashboard-controls {
    position: relative !important;
}

#dashboardItemsControls {
    position: relative !important;
}

#dashboardItemsControls .column-controls-menu {
    position: absolute !important;
    top: calc(100% + 6px) !important;
    left: 0 !important;
    right: auto !important;
    width: clamp(220px, 56vw, 340px) !important;
    min-width: 220px !important;
    max-width: min(92vw, 700px) !important;
    z-index: 9999 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

#dashboardItemsMenu {
    width: 100% !important;
}

#dashboardItemsMenu .dashboard-item-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 10px !important;
}

#dashboardItemsMenu .dashboard-item-row .column-toggle-item {
    flex: 1 1 auto !important;
    min-width: 0 !important;
}

#dashboardItemsMenu .dashboard-item-row .column-toggle-item span {
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
}

#dashboardItemsMenu input.dashboard-card-color-input {
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    flex: 0 0 28px !important;
}

#dashboardItemsMenu select.dashboard-card-color-select {
    width: 96px !important;
    min-width: 96px !important;
    max-width: 96px !important;
    flex: 0 0 96px !important;
    margin: 0 !important;
    padding: 4px 6px !important;
    border-radius: 6px !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
}

#dashboardItemsMenu .dashboard-card-palette {
    display: flex !important;
    align-items: center !important;
    gap: 6px !important;
    flex: 0 0 auto !important;
}

#dashboardItemsMenu .dashboard-card-swatch {
    width: 18px !important;
    height: 18px !important;
    border-radius: 999px !important;
    border: 1px solid rgba(148, 163, 184, 0.75) !important;
    background: var(--swatch-color) !important;
    padding: 0 !important;
    margin: 0 !important;
    cursor: pointer !important;
    box-sizing: border-box !important;
}

#dashboardItemsMenu .dashboard-card-swatch.is-active {
    border-color: #ffffff !important;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.7) !important;
}

@media (max-width: 900px) {
    #dashboardItemsControls .column-controls-menu {
        width: min(92vw, 520px) !important;
        min-width: min(92vw, 520px) !important;
        max-width: 92vw !important;
    }
}

/* ===== DASHBOARD ITEMS MENU FIX ===== */
.list-controls .column-controls-menu {
    width: min(92vw, 980px) !important;
    min-width: 720px !important;
    max-width: min(96vw, 1080px) !important;
    left: 0 !important;
    right: auto !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
}

#dashboardItemsMenu {
    width: 100% !important;
    min-width: 0 !important;
}

#dashboardItemsMenu .dashboard-item-row {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: 8px !important;
    padding: 3px 0 !important;
    width: 100% !important;
}

#dashboardItemsMenu .dashboard-item-row .column-toggle-item {
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: visible !important;
}

#dashboardItemsMenu .dashboard-item-row .column-toggle-item span {
    display: block !important;
    white-space: normal !important;
    overflow: visible !important;
    text-overflow: clip !important;
}

#dashboardItemsMenu input.dashboard-card-color-input {
    flex: 0 0 28px !important;
    width: 28px !important;
    min-width: 28px !important;
    max-width: 28px !important;
    height: 20px !important;
    padding: 0 !important;
    margin: 0 !important;
    border-radius: 6px !important;
    box-sizing: border-box !important;
}

.dashboard-widget-hidden,
.dashboard-widget.dashboard-widget-hidden,
.stats-cards .dashboard-widget.dashboard-widget-hidden,
.chart-cards .dashboard-widget.dashboard-widget-hidden {
    display: none !important;
}

/* ===== DASHBOARD CARD STYLE ===== */
/* Clean: small monospace label on top, large number below */
.stats-cards .dashboard-widget {
    display: block !important;
    padding: 18px !important;
    overflow: hidden !important;
}

.stats-cards .dashboard-widget .card-header {
    font-size: 11px !important;
    font-family: var(--mono) !important;
    text-transform: uppercase !important;
    letter-spacing: 0.07em !important;
    font-weight: 400 !important;
    color: var(--dim) !important;
    margin-bottom: 10px !important;
    background: none !important;
    padding: 0 !important;
    order: unset !important;
    border: none !important;
    box-shadow: none !important;
}

.stats-cards .dashboard-widget .card-body {
    padding: 0 !important;
    order: unset !important;
    display: block !important;
}

.stats-cards .dashboard-widget .stat-number {
    font-size: 30px !important;
    font-weight: 600 !important;
    line-height: 1.2 !important;
    letter-spacing: -0.02em !important;
    color: var(--text) !important;
    font-family: var(--font) !important;
}

.chart-cards .dashboard-widget .card-header {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    box-shadow: none;
}

/* ===== TRUE LAST DASHBOARD CLIP FIX ===== */
main {
    width: auto !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.content-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    gap: 10px !important;
}

.content-header > * {
    min-width: 0 !important;
}

.content-header h2 {
    flex: 0 1 auto !important;
    margin: 0 auto 0 0 !important;
}

.content-header .date-range-form {
    display: flex !important;
    flex: 1 1 620px !important;
    max-width: 100% !important;
    min-width: 0 !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    align-items: flex-end !important;
    margin: 0 !important;
}

.content-header .date-range-form label {
    flex: 1 1 128px !important;
    min-width: 110px !important;
    max-width: 150px !important;
    margin: 0 !important;
}

.content-header .date-range-form input,
.content-header .date-range-form select {
    width: 100% !important;
    min-width: 0 !important;
}

.content-header .date-range-form button,
.content-header > .btn {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
}

@media (max-width: 1780px) {
    .content-header > .btn {
        flex-basis: 100% !important;
    }

    .content-header .date-range-form {
        justify-content: flex-start !important;
    }
}

/* ===== EDGE CLIP HOTFIX (must stay last) ===== */
.layout {
    width: min(100% - 40px, 1840px) !important;
    margin: 16px auto !important;
}

.content-header {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: flex-end !important;
    justify-content: flex-start !important;
    gap: 10px !important;
}

.content-header > * {
    min-width: 0;
}

.content-header h2 {
    flex: 1 1 220px !important;
    margin: 0 !important;
}

.content-header .date-range-form {
    display: flex !important;
    flex: 1 1 760px !important;
    max-width: 100% !important;
    flex-wrap: wrap !important;
    justify-content: flex-end !important;
    align-items: flex-end !important;
    margin: 0 !important;
}

.content-header .date-range-form label {
    flex: 1 1 150px !important;
    min-width: 120px !important;
    max-width: 180px !important;
    margin: 0 !important;
}

.content-header .date-range-form input,
.content-header .date-range-form select {
    width: 100% !important;
    min-width: 0 !important;
}

.content-header .date-range-form button,
.content-header > .btn {
    flex: 0 0 auto !important;
    white-space: nowrap !important;
}

@media (max-width: 1500px) {
    .content-header .date-range-form {
        justify-content: flex-start !important;
        flex: 1 1 100% !important;
    }
}

@media (max-width: 900px) {
    .layout {
        width: calc(100% - 16px) !important;
        margin: 8px auto !important;
    }

    .content-header .date-range-form label {
        flex: 1 1 140px !important;
        max-width: none !important;
    }
}

/* ===== DASHBOARD HEADER CLIP FIX v2 ===== */
.content-header .date-range-form {
    flex: 1 1 560px !important;
    min-width: 0 !important;
}

.content-header .date-range-form label {
    flex: 1 1 128px !important;
    min-width: 110px !important;
    max-width: 155px !important;
}

.content-header > .btn {
    margin-left: 0 !important;
}

@media (max-width: 1820px) {
    .content-header > .btn {
        flex-basis: 100% !important;
        justify-self: flex-start !important;
    }
}

/* ===== FINAL OVERRIDES (keep at end) ===== */
.layout {
    width: min(100% - 32px, 1880px) !important;
    max-width: none !important;
    margin: 16px auto !important;
}

.content-header {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
}

.content-header h2 {
    margin: 0 auto 0 0 !important;
    flex: 0 1 auto !important;
}

.content-header .date-range-form {
    display: flex !important;
    align-items: center !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
    margin: 0 !important;
    margin-left: auto !important;
    max-width: 100% !important;
}

.content-header .date-range-form label {
    min-width: 110px;
}

.content-header > .btn {
    margin-left: 0 !important;
    white-space: nowrap !important;
    flex: 0 0 auto !important;
}

.dashboard-controls {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-wrap: wrap !important;
    gap: 10px !important;
}

@media (max-width: 1500px) {
    .content-header h2 {
        flex-basis: 100% !important;
    }

    .content-header .date-range-form {
        margin-left: 0 !important;
    }
}

@media (max-width: 900px) {
    .layout {
        width: calc(100% - 16px) !important;
        margin: 8px auto !important;
    }
}

/* ===== VISUAL REFRESH (home-apps inspired) ===== */
:root {
    /* home-apps design system */
    --bg:            #f5f7fa;
    --surface:       #ffffff;
    --surface2:      #f0f3f8;
    --border:        rgba(0, 0, 0, 0.08);
    --border-bright: rgba(0, 0, 0, 0.15);
    --text:          #111318;
    --muted:         #6b7280;
    --dim:           #9ca3af;
    --font:          'IBM Plex Sans', Arial, sans-serif;
    --mono:          'IBM Plex Mono', monospace;
    --radius:        10px;
    --radius-lg:     14px;
    /* brand */
    --brand-blue:       #0070C0;
    --brand-blue-deep:  #005A9C;
    /* legacy aliases kept for compatibility */
    --surface-soft:  #f0f3f8;
    --text-main:     #111318;
    --text-soft:     #6b7280;
    --line-soft:     rgba(0, 0, 0, 0.08);
    --shadow-soft:   0 8px 24px rgba(15, 23, 42, 0.08);
    --shadow-card:   0 4px 16px rgba(15, 23, 42, 0.07);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
}

header {
    background: var(--surface);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding: 10px 20px;
}

.logo-title img {
    height: 36px;
    width: auto;
}

.logo-title .app-title {
    color: var(--text);
    font-size: 15px;
    font-weight: 500;
    letter-spacing: 0;
}

.header-controls {
    gap: 8px;
}

.nav-toggle,
.theme-toggle {
    background: transparent;
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 10px;
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
}

.nav-toggle:hover,
.theme-toggle:hover {
    background: var(--surface2);
    border-color: var(--border-bright);
    color: var(--text);
}

.header-controls .btn,
.header-controls .btn-secondary {
    padding: 5px 10px;
    font-size: 13px;
}

.layout {
    max-width: 1520px;
    margin: 18px auto;
    min-height: calc(100vh - 36px);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
}

nav {
    width: 220px;
    background: var(--surface2);
    border-right: 1px solid var(--border);
    padding: 12px 8px;
    gap: 2px;
}

nav button,
.dropbtn,
.dropdown-content button {
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: var(--radius);
    text-align: left;
    font-weight: 400;
    font-size: 13px;
    padding: 7px 10px;
    font-family: var(--font);
    transition: background 0.1s, color 0.1s;
}

nav button:hover,
.dropbtn:hover,
.dropdown-content button:hover {
    background: var(--surface);
    color: var(--text);
}

.dropdown-content {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 4px;
}

.dropdown-content button {
    font-size: 12px;
    padding: 6px 10px;
}

main {
    background: var(--bg);
    padding: 24px;
}

h1, h2, h3 {
    color: var(--text);
    letter-spacing: -0.01em;
}

.card,
.table-container,
.csv-upload-section,
.summary-card,
.checkbox-group {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: border-color 0.15s, background 0.15s, transform 0.1s;
}

.card:hover,
.summary-card:hover {
    border-color: var(--border-bright);
    transform: translateY(-1px);
}

.card {
    padding: 16px;
}

.card-header {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 12px;
}

.table-container {
    padding: 14px;
}

table {
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    border-radius: 12px;
}

th {
    background: var(--surface2);
    color: var(--dim);
    font-size: 11px;
    font-family: var(--mono);
    letter-spacing: 0.07em;
    text-transform: uppercase;
    font-weight: 400;
    border-color: var(--border);
}

td {
    border-color: var(--border);
    color: var(--text);
}

tr:nth-child(even) {
    background-color: transparent;
}

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

input,
select,
textarea {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--border-bright);
    box-shadow: 0 0 0 3px rgba(0, 112, 192, 0.14);
}

.btn,
main button {
    border-radius: 10px;
    font-weight: 700;
}

.btn-primary,
main button,
.date-range-form button {
    background: linear-gradient(135deg, var(--brand-blue) 0%, var(--brand-blue-deep) 100%);
    color: #fff;
}

.btn-primary:hover,
main button:hover,
.date-range-form button:hover {
    filter: brightness(0.96);
}

.flash-messages .alert {
    border-radius: 10px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
}

body.dark-mode {
    /* home-apps dark palette via variables */
    --bg:            #0e0e10;
    --surface:       #18181b;
    --surface2:      #1f1f23;
    --border:        rgba(255, 255, 255, 0.08);
    --border-bright: rgba(255, 255, 255, 0.15);
    --text:          #efeff1;
    --muted:         #adadb8;
    --dim:           #5a5a6e;
    /* legacy aliases */
    --surface-soft:  #1f1f23;
    --text-main:     #efeff1;
    --text-soft:     #adadb8;
    --line-soft:     rgba(255, 255, 255, 0.08);
    --shadow-card:   0 4px 16px rgba(0, 0, 0, 0.35);
    background: var(--bg);
    color: var(--text);
}

@media (max-width: 1100px) {
    .layout {
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
        max-width: none;
    }

    nav {
        width: 210px;
    }

    main {
        padding: 18px;
    }
}

/* ===== SECOND PASS UI POLISH ===== */
.content-header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: end;
    gap: 14px;
    margin-bottom: 16px;
}

.content-header h2 {
    margin: 0;
    font-size: 28px;
    font-weight: 800;
    letter-spacing: 0.2px;
}

.date-range-form {
    justify-self: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 10px;
    box-shadow: var(--shadow-card);
}

.date-range-form label {
    font-size: 12px;
    color: var(--muted);
    font-weight: 600;
}

.date-range-form input,
.date-range-form select {
    min-width: 120px;
    margin: 2px 0 0;
    padding: 8px 10px;
}

.dashboard-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 10px;
}

.dashboard-controls .column-controls > summary {
    border-radius: 10px;
    padding: 7px 10px;
    background: #f1f7ff;
    border: 1px solid #d6e5f6;
    font-weight: 700;
    color: #355273;
}

.stats-cards {
    --dashboard-grid-gap: 12px;
}

.stats-cards .dashboard-widget {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: 110px;
}

.stats-cards .dashboard-widget::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 2px;
    background: var(--accent, var(--brand-blue));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stats-cards .dashboard-widget:nth-child(3n + 1) { --accent: #0070C0; }
.stats-cards .dashboard-widget:nth-child(3n + 2) { --accent: #16a0d8; }
.stats-cards .dashboard-widget:nth-child(3n + 3) { --accent: #2f88cf; }

.chart-cards {
    --dashboard-grid-gap: 14px;
}

.chart-cards .dashboard-widget {
    border-radius: 14px;
}

.chart-cards .dashboard-widget .card-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    font-size: 15px;
}

.dashboard-widget:hover {
    border-color: var(--border-bright);
    transform: translateY(-1px);
    box-shadow: var(--shadow-card);
}

nav {
    padding-top: 14px;
}

nav button,
.dropbtn,
.dropdown-content button {
    position: relative;
}

body.dark-mode .stats-cards .dashboard-widget .card-header {
    color: var(--muted);
}

body.dark-mode .stats-cards .stat-number {
    color: var(--text);
}

@media (max-width: 1260px) {
    .content-header {
        grid-template-columns: 1fr;
        align-items: stretch;
    }

    .date-range-form {
        justify-self: start;
        flex-wrap: wrap;
    }
}

/* ===== FINAL MATCH TUNING ===== */
.layout {
    width: 100%;
    max-width: none;
    margin: 0;
    border-radius: 8px;
}

nav {
    width: 250px;
    padding: 14px 12px;
}

main {
    padding: 22px 24px;
}

h1 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

h3 {
    font-size: 16px;
    font-weight: 500;
}

.content-header h2 {
    font-size: 30px;
}

table,
input,
select,
textarea,
button,
.btn {
    font-size: 14px;
}

.stats-cards {
    --dashboard-grid-gap: 14px;
}

.stats-cards .dashboard-widget {
    min-height: 120px;
}

.chart-cards {
    --dashboard-grid-gap: 16px;
}

.chart-cards .dashboard-widget {
    min-height: 300px;
}

.chart-cards .dashboard-widget[data-widget-id="jobs_map"] {
    min-height: 340px;
}

.chart-cards .dashboard-widget .card-header {
    font-size: 15px;
    font-weight: 700;
}

.table-container {
    border-radius: 14px;
    padding: 16px;
}

body.dark-mode nav {
    width: 250px;
}

@media (max-width: 1100px) {
    nav,
    body.dark-mode nav {
        width: 210px;
    }
}

/* ===== TOP NAV LAYOUT ===== */
.layout {
    display: block;
}

nav {
    width: auto;
    min-height: 0;
    border-right: none;
    border-bottom: 1px solid var(--line-soft);
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
}

nav > button,
nav > .dropdown {
    flex: 0 0 auto;
}

nav button,
.dropbtn {
    width: auto;
    min-height: 36px;
    text-align: center;
    padding: 8px 14px;
}

.dropdown {
    display: contents;
}

.dropdown-content {
    display: none;
    flex-basis: 100%;
    margin-top: 8px;
    padding: 8px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    border-radius: 12px;
}

.dropdown.open .dropdown-content {
    display: flex;
}

.dropdown-content button {
    width: auto;
    min-height: 34px;
    padding: 7px 12px;
}

main {
    width: 100%;
}

body.dark-mode nav {
    width: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
}

@media (max-width: 1100px) {
    nav,
    body.dark-mode nav {
        gap: 6px;
        padding: 8px 10px;
    }

    nav button,
    .dropbtn,
    .dropdown-content button {
        padding: 7px 10px;
        font-size: 13px;
    }
}

/* ===== PAGE WIDTH BALANCE ===== */
.layout {
    width: min(100% - 32px, 1920px);
    margin: 16px auto;
}

@media (max-width: 900px) {
    .layout {
        width: calc(100% - 16px);
        margin: 8px auto;
    }
}

/* ===== DASHBOARD OVERFLOW FIX ===== */
.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.content-header h2 {
    margin-right: auto;
}

.content-header .date-range-form {
    margin-left: auto;
    max-width: 100%;
    flex-wrap: wrap;
}

.content-header > .btn {
    white-space: nowrap;
    flex: 0 0 auto;
}

.dashboard-controls {
    flex-wrap: wrap;
}

@media (max-width: 1500px) {
    .content-header h2 {
        flex-basis: 100%;
        margin-right: 0;
    }

    .content-header .date-range-form {
        margin-left: 0;
    }
}

/* Explicit dark-mode surface overrides (belt-and-suspenders alongside CSS variables) */
body.dark-mode .card,
body.dark-mode .table-container,
body.dark-mode .summary-card,
body.dark-mode .csv-upload-section,
body.dark-mode .checkbox-group,
body.dark-mode .dashboard-widget,
body.dark-mode .date-range-form,
body.dark-mode .dashboard-controls {
    background: #18181b;
    border-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode main {
    background: #0e0e10;
}

body.dark-mode th {
    background: #1f1f23;
    color: #adadb8;
}

body.dark-mode td {
    border-color: rgba(255, 255, 255, 0.06);
    color: #efeff1;
}

body.dark-mode tbody tr:hover {
    background: #1f1f23;
}

/* Stat card labels: use muted (not dim) for readability on dark bg */
body.dark-mode .stats-cards .dashboard-widget .card-header {
    color: #adadb8 !important;
}

body.dark-mode .stats-cards .stat-number,
body.dark-mode .stats-cards .dashboard-widget .stat-number {
    color: #efeff1 !important;
}

/* List controls in dark mode */
body.dark-mode .list-controls .column-controls > summary {
    background: #1f1f23;
    border-color: rgba(255, 255, 255, 0.08);
    color: #adadb8;
}

body.dark-mode .list-controls .column-controls-menu {
    background: #18181b;
    border-color: rgba(255, 255, 255, 0.08);
    color: #efeff1;
}

body.dark-mode .list-controls .list-filter-input,
body.dark-mode .list-controls .list-sort-column,
body.dark-mode .list-controls .list-sort-direction {
    background: #1f1f23;
    border-color: rgba(255, 255, 255, 0.08);
    color: #efeff1;
}

body.dark-mode .list-filter-status {
    color: #adadb8;
}

/* Chart card header border */
body.dark-mode .chart-cards .dashboard-widget .card-header {
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

body.dark-mode input,
body.dark-mode select,
body.dark-mode textarea {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode input:focus,
body.dark-mode select:focus,
body.dark-mode textarea:focus {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 2px rgba(0, 112, 192, 0.2);
}

body.dark-mode input::placeholder,
body.dark-mode textarea::placeholder {
    color: var(--dim);
}

body.dark-mode .metric-positive,
body.dark-mode .metric-neutral {
    color: inherit;
    background-color: transparent;
}

.metrics-table td:first-child {
    font-weight: 600;
}

.value-cell {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.metric-positive,
.metric-neutral {
    color: inherit;
    background-color: transparent;
    font-weight: 700;
}

.threshold-red {
    color: #a31515;
    background-color: #ffeaea;
    font-weight: 700;
}

.threshold-amber {
    color: #8a5300;
    background-color: #fff4df;
    font-weight: 700;
}

.threshold-green {
    color: #1f6f2b;
    background-color: #e9f8ed;
    font-weight: 700;
}

body.dark-mode .threshold-red {
    color: #ffb3b3;
    background-color: #3a1f24;
}

body.dark-mode .threshold-amber {
    color: #ffd38a;
    background-color: #3a301f;
}

body.dark-mode .threshold-green {
    color: #9be3b1;
    background-color: #193324;
}

.summary-table th {
    background: var(--surface2);
}

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

.summary-table td:nth-child(2),
.summary-table td:nth-child(3) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.breakdown-grid {
    margin: 12px 0 20px 0;
}

.breakdown-grid .grid-label {
    font-weight: 700;
}

.breakdown-grid td.value-cell {
    text-align: right;
    font-weight: 700;
}

.breakdown-grid input,
.breakdown-grid select {
    margin: 0;
    width: 100%;
}

.mobile-material-name {
    display: none;
    font-weight: 600;
}

.mobile-equipment-name,
.mobile-labour-name,
.mobile-disposal-name {
    display: none;
    font-weight: 600;
}

.mobile-fixed-name,
.mobile-overhead-name,
.mobile-extraordinary-name {
    display: none;
    font-weight: 600;
}

#fixed-table tbody tr,
#overhead-table tbody tr,
#extraordinary-table tbody tr {
    cursor: pointer;
}

.table-container > h3 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.section-collapse-toggle {
    margin: 0;
    padding: 4px 8px;
    font-size: 0.85rem;
    line-height: 1.2;
}

.table-container.section-collapsed > :not(h3) {
    display: none !important;
}

.material-editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1200;
    padding: 16px;
}

.material-editor-modal {
    width: min(460px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: #ffffff;
    border: 1px solid #d0d7e2;
    border-radius: 8px;
    padding: 16px;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.2);
}

.material-editor-modal h4 {
    margin: 0 0 12px;
}

.material-editor-modal label {
    display: block;
    margin: 8px 0 4px;
    font-weight: 700;
}

.material-editor-modal input,
.material-editor-modal select {
    width: 100%;
    margin: 0 0 8px;
}

.material-editor-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 8px;
}

body.dark-mode .material-editor-modal {
    background: #1f2937;
    border-color: #3b4b61;
    color: #e2e8f0;
}

@media (max-width: 900px) {
    .layout {
        display: block;
    }

    .layout nav {
        width: auto;
        min-height: 0;
        padding: 12px;
    }

    .layout.nav-hidden nav {
        display: none;
    }
}

@media (max-width: 900px) {
    .breakdown-grid tbody tr {
        display: flex;
        flex-wrap: wrap;
    }

    .breakdown-grid tbody tr td {
        width: 50%;
        box-sizing: border-box;
    }

    #equipment-table,
    #material-table,
    #labour-table,
    #disposal-table {
        width: 100%;
        table-layout: fixed;
    }

    #equipment-table thead,
    #material-table thead,
    #labour-table thead,
    #disposal-table thead,
    #equipment-table tbody,
    #material-table tbody,
    #labour-table tbody,
    #disposal-table tbody {
        display: block;
        width: 100%;
    }

    #equipment-table thead tr,
    #equipment-table tbody tr,
    #disposal-table thead tr,
    #disposal-table tbody tr {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    #material-table thead tr,
    #material-table tbody tr {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }

    #labour-table thead tr,
    #labour-table tbody tr {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    #equipment-table thead tr,
    #material-table thead tr,
    #labour-table thead tr,
    #equipment-table tbody tr,
    #material-table tbody tr,
    #labour-table tbody tr,
    #disposal-table thead tr,
    #disposal-table tbody tr {
        display: grid;
        align-items: stretch;
        width: 100%;
        margin-bottom: 10px;
    }

    #equipment-table thead tr,
    #material-table thead tr,
    #labour-table thead tr,
    #disposal-table thead tr {
        margin-bottom: 6px;
    }

    #equipment-table thead tr th,
    #material-table thead tr th,
    #labour-table thead tr th,
    #disposal-table thead tr th,
    #equipment-table tbody tr td,
    #material-table tbody tr td,
    #labour-table tbody tr td,
    #disposal-table tbody tr td {
        display: block;
        width: 100%;
        min-width: 0;
        box-sizing: border-box;
        padding: 6px;
    }

    #equipment-table tbody tr td select,
    #equipment-table tbody tr td input,
    #material-table tbody tr td select,
    #material-table tbody tr td input,
    #labour-table tbody tr td select,
    #labour-table tbody tr td input,
    #disposal-table tbody tr td select,
    #disposal-table tbody tr td input,
    #fixed-table tbody tr td select,
    #fixed-table tbody tr td input,
    #overhead-table tbody tr td select,
    #overhead-table tbody tr td input,
    #extraordinary-table tbody tr td select,
    #extraordinary-table tbody tr td input,
    #equipment-table tbody tr td button,
    #material-table tbody tr td button,
    #labour-table tbody tr td button,
    #disposal-table tbody tr td button,
    #fixed-table tbody tr td button,
    #overhead-table tbody tr td button,
    #extraordinary-table tbody tr td button {
        width: 100%;
        margin: 0;
    }

    #material-table thead tr,
    #material-table tbody tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #equipment-table thead tr,
    #equipment-table tbody tr,
    #labour-table thead tr,
    #labour-table tbody tr,
    #disposal-table thead tr,
    #disposal-table tbody tr,
    #fixed-table thead tr,
    #fixed-table tbody tr,
    #overhead-table thead tr,
    #overhead-table tbody tr,
    #extraordinary-table thead tr,
    #extraordinary-table tbody tr {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #material-table thead tr th,
    #material-table tbody tr td {
        display: none;
    }

    #material-table thead tr th:nth-child(4),
    #material-table thead tr th:nth-child(8),
    #material-table tbody tr td:nth-child(4),
    #material-table tbody tr td:nth-child(8) {
        display: block;
        width: 100%;
    }

    #material-table tbody tr {
        cursor: pointer;
    }

    #material-table tbody tr td:nth-child(4) select {
        display: none;
    }

    #material-table tbody tr td:nth-child(4) .mobile-material-name {
        display: block;
    }

    #equipment-table thead tr th,
    #equipment-table tbody tr td,
    #labour-table thead tr th,
    #labour-table tbody tr td,
    #disposal-table thead tr th,
    #disposal-table tbody tr td,
    #fixed-table thead tr th,
    #fixed-table tbody tr td,
    #overhead-table thead tr th,
    #overhead-table tbody tr td,
    #extraordinary-table thead tr th,
    #extraordinary-table tbody tr td {
        display: none;
    }

    #equipment-table thead tr th:nth-child(2),
    #equipment-table thead tr th:nth-child(6),
    #equipment-table tbody tr td:nth-child(2),
    #equipment-table tbody tr td:nth-child(6),
    #labour-table thead tr th:nth-child(2),
    #labour-table thead tr th:nth-child(5),
    #labour-table tbody tr td:nth-child(2),
    #labour-table tbody tr td:nth-child(5),
    #disposal-table thead tr th:nth-child(2),
    #disposal-table thead tr th:nth-child(6),
    #disposal-table tbody tr td:nth-child(2),
    #disposal-table tbody tr td:nth-child(6),
    #fixed-table thead tr th:nth-child(2),
    #fixed-table thead tr th:nth-child(6),
    #fixed-table tbody tr td:nth-child(2),
    #fixed-table tbody tr td:nth-child(6),
    #overhead-table thead tr th:nth-child(2),
    #overhead-table thead tr th:nth-child(5),
    #overhead-table tbody tr td:nth-child(2),
    #overhead-table tbody tr td:nth-child(5),
    #extraordinary-table thead tr th:nth-child(2),
    #extraordinary-table thead tr th:nth-child(6),
    #extraordinary-table tbody tr td:nth-child(2),
    #extraordinary-table tbody tr td:nth-child(6) {
        display: block;
        width: 100%;
    }

    #equipment-table tbody tr,
    #labour-table tbody tr,
    #disposal-table tbody tr,
    #fixed-table tbody tr,
    #overhead-table tbody tr,
    #extraordinary-table tbody tr {
        cursor: pointer;
    }

    #equipment-table tbody tr td:nth-child(2) select,
    #labour-table tbody tr td:nth-child(2) select,
    #disposal-table tbody tr td:nth-child(2) select,
    #fixed-table tbody tr td:nth-child(2) select,
    #overhead-table tbody tr td:nth-child(2) select,
    #extraordinary-table tbody tr td:nth-child(2) select {
        display: none;
    }

    #equipment-table tbody tr td:nth-child(2) .mobile-equipment-name,
    #labour-table tbody tr td:nth-child(2) .mobile-labour-name,
    #disposal-table tbody tr td:nth-child(2) .mobile-disposal-name,
    #fixed-table tbody tr td:nth-child(2) .mobile-fixed-name,
    #overhead-table tbody tr td:nth-child(2) .mobile-overhead-name,
    #extraordinary-table tbody tr td:nth-child(2) .mobile-extraordinary-name {
        display: block;
    }
}

#quotedVsActualSummaryTable .quoted-cost-input {
    width: 100%;
    box-sizing: border-box;
}

#quotedSummaryForm.quoted-summary-locked .quoted-cost-input {
    border: none;
    background: transparent;
    box-shadow: none;
    outline: none;
    padding: 0;
    margin: 0;
    color: inherit;
    font: inherit;
    line-height: inherit;
    text-align: right;
    font-variant-numeric: tabular-nums;
    width: 100%;
    display: block;
    pointer-events: none;
}

#quotedSummaryForm.quoted-summary-locked .quoted-cost-input::-webkit-outer-spin-button,
#quotedSummaryForm.quoted-summary-locked .quoted-cost-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

#quotedSummaryForm.quoted-summary-locked .quoted-cost-input[type=number] {
    appearance: textfield;
    -moz-appearance: textfield;
}

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

/* export button style */
nav button[onclick*="/export"] {
    background-color: #28a745;
}

nav button[onclick*="/export"]:hover {
    background-color: #218838;
}

/* Card layout (used for forms/sections) */
.card {
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

/* Dashboard card groupings */
.dashboard-controls {
    margin: 0 0 12px;
}

.stats-cards,
.chart-cards {
    --dashboard-grid-col: 20px;
    --dashboard-grid-row: 20px;
    --dashboard-grid-gap: 10px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(var(--dashboard-grid-col), var(--dashboard-grid-col)));
    grid-auto-rows: var(--dashboard-grid-row);
    grid-auto-flow: row dense;
    justify-content: start;
    align-items: start;
    column-gap: var(--dashboard-grid-gap);
    row-gap: var(--dashboard-grid-gap);
}

.stats-cards .dashboard-widget,
.chart-cards .dashboard-widget {
    margin: 0;
}

.dashboard-user-section {
    margin-top: 4px;
}

#dashboardZonesRoot > [data-dashboard-zone] {
    margin-bottom: 20px;
}

.dashboard-new-section-anchor {
    display: none;
    width: 100%;
    min-height: 44px;
    border: 2px dashed rgba(0, 112, 192, 0.35);
    border-radius: 8px;
    color: #4b5a70;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 20px;
}

.dashboard-new-section-anchor-top {
    margin-bottom: 12px;
}

.dashboard-new-section-anchor-bottom {
    margin-top: 8px;
}

body.dashboard-drag-active .dashboard-new-section-anchor {
    display: flex;
}

.dashboard-widget {
    cursor: move;
    position: relative;
    min-height: 100px;
    max-width: 1200px;
    max-height: 1200px;
    display: flex;
    flex-direction: column;
}

.dashboard-widget .card-header {
    cursor: move;
}

.dashboard-widget-hidden {
    display: none !important;
}

.dashboard-widget-dragging {
    opacity: 0.55;
}

.dashboard-resize-handle {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 14px;
    height: 14px;
    cursor: nwse-resize;
    border-right: 2px solid rgba(0, 112, 192, 0.6);
    border-bottom: 2px solid rgba(0, 112, 192, 0.6);
    border-radius: 2px;
    z-index: 5;
}

body.dark-mode .dashboard-resize-handle {
    border-right-color: rgba(125, 211, 252, 0.7);
    border-bottom-color: rgba(125, 211, 252, 0.7);
}

.dashboard-widget.dashboard-drop-before {
    box-shadow: inset 4px 0 0 #0070c0;
}

.dashboard-widget.dashboard-drop-after {
    box-shadow: inset -4px 0 0 #0070c0;
}

.dashboard-widget.dashboard-drop-top {
    box-shadow: inset 0 4px 0 #0070c0;
}

.dashboard-widget.dashboard-drop-bottom {
    box-shadow: inset 0 -4px 0 #0070c0;
}

.dashboard-drop-zone-active {
    outline: 2px dashed rgba(0, 112, 192, 0.45);
    outline-offset: 4px;
    border-radius: 8px;
}

body.dark-mode .dashboard-widget.dashboard-drop-before {
    box-shadow: inset 4px 0 0 #7dd3fc;
}

body.dark-mode .dashboard-widget.dashboard-drop-after {
    box-shadow: inset -4px 0 0 #7dd3fc;
}

body.dark-mode .dashboard-widget.dashboard-drop-top {
    box-shadow: inset 0 4px 0 #7dd3fc;
}

body.dark-mode .dashboard-widget.dashboard-drop-bottom {
    box-shadow: inset 0 -4px 0 #7dd3fc;
}

body.dark-mode .dashboard-new-section-anchor {
    border-color: rgba(125, 211, 252, 0.45);
    color: #cbd5e1;
}

.stats-cards .stat-number {
    font-size: 32px;
    font-weight: bold;
    color: #0070C0;
}

.stats-cards .dashboard-widget {
    padding: 8px 10px;
}

.stats-cards .dashboard-widget .card-header {
    margin-bottom: 6px;
}

.dashboard-widget .card-header {
    font-size: 18px;
}

.dashboard-widget .card-body {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.dashboard-widget .card-body canvas {
    width: 100% !important;
    height: 100% !important;
}

.jobs-map-status {
    background: rgba(255, 255, 255, 0.92);
    color: #1f2937;
}

body.dark-mode .jobs-map-status {
    background: rgba(15, 23, 42, 0.9);
    color: #f8fafc;
}

.dashboard-widget.dashboard-widget-small .card-header {
    font-size: 14px;
    margin-bottom: 6px;
}

.dashboard-widget.dashboard-widget-small .stat-number {
    font-size: 20px;
}

.dashboard-widget.dashboard-widget-tiny .card-header {
    font-size: 12px;
    margin-bottom: 4px;
}

.dashboard-widget.dashboard-widget-tiny .stat-number {
    font-size: 16px;
}

.stats-cards .card {
    min-width: 110px;
    min-height: 100px;
}

.chart-cards .card {
    min-width: 220px;
    min-height: 220px;
}

.card-header {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    color: #333;
}

.card-body {
    padding: 0;
}

/* General application enhancements */
body {
    background-color: #f0f2f5;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.content-header h1 {
    margin: 0;
    font-size: 24px;
    color: #333;
}

/* date range selector on dashboard */
.date-range-form {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    margin: 0; /* reset because it's inside header */
    margin-left: auto; /* push form to right edge */
}

/* make submit button match main action style */
.date-range-form button {
    background-color: #0070C0;
    color: #fff;
}
.date-range-form button:hover {
    background-color: #005A9C;
}
.date-range-form label {
    display: flex;
    flex-direction: column;
    font-size: 14px;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: bold;
    cursor: pointer;
    border: none;
    transition: background-color 0.2s;
}

.btn-primary {
    background-color: #0070C0;
    color: #fff;
}

.btn-primary:hover {
    background-color: #005A9C;
}

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

.btn-secondary:hover {
    background-color: #5a6268;
}

.table-container {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 20px;
}

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

th, td {
    padding: 12px 15px;
    border: 1px solid #ddd;
}

th {
    background-color: #f9f9f9;
    text-transform: uppercase;
    font-size: 14px;
}

tr:nth-child(even) {
    background-color: transparent;
}

input, select, textarea {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100%;
    box-sizing: border-box;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #0070C0;
    box-shadow: 0 0 3px rgba(0,112,192,0.3);
}

.flash-messages {
    margin: 20px 0;
}

.alert {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 10px;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* ===== HOME-APPS CARD COMPONENTS ===== */

.app-card-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
    background: var(--icon-bg, var(--surface2));
    border: 1px solid var(--icon-border, var(--border));
}
.app-card-icon svg { width: 20px; height: 20px; }
.app-card-name { font-size: 15px; font-weight: 500; color: var(--text); margin-bottom: 0.35rem; }
.app-card-desc { font-size: 13px; color: var(--muted); line-height: 1.5; flex: 1; margin-bottom: 1.25rem; }
.app-card-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.app-card-tag {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--dim);
    background: var(--surface2);
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 4px;
}
.app-card-open {
    font-size: 12px;
    font-weight: 500;
    color: var(--muted);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: color 0.15s;
}
.app-portal-card:hover .app-card-open { color: var(--text); }
.app-card-open svg { width: 12px; height: 12px; }

.portal-eyebrow {
    font-size: 11px;
    font-family: var(--mono);
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.4rem;
}
.portal-title { font-size: 26px; font-weight: 500; color: var(--text); margin-bottom: 0.3rem; letter-spacing: -0.01em; }
.portal-sub { font-size: 14px; color: var(--muted); margin-bottom: 1.75rem; }

.accent-blue { --accent: #0070C0; --icon-bg: rgba(0,112,192,0.08); --icon-border: rgba(0,112,192,0.2); }
.accent-blue .app-card-icon svg { color: #0070C0; }
.accent-cyan { --accent: #16a0d8; --icon-bg: rgba(22,160,216,0.08); --icon-border: rgba(22,160,216,0.2); }
.accent-cyan .app-card-icon svg { color: #16a0d8; }
.accent-amber { --accent: #e5a00d; --icon-bg: rgba(229,160,13,0.08); --icon-border: rgba(229,160,13,0.2); }
.accent-amber .app-card-icon svg { color: #e5a00d; }
.accent-purple { --accent: #7c3aed; --icon-bg: rgba(124,58,237,0.08); --icon-border: rgba(124,58,237,0.2); }
.accent-purple .app-card-icon svg { color: #7c3aed; }

/* ===== SUB-APP SHARED STYLES ===== */

.app-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    margin-bottom: 20px;
    position: relative;
}

.app-section::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--accent, var(--brand-blue));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.app-section h2 {
    margin: 0 0 16px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 14px;
}

.form-field label {
    display: block;
    font-size: 11px;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 400;
    color: var(--dim);
    margin-bottom: 4px;
}

.form-field input[type="text"],
.form-field input[type="password"],
.form-field input[type="number"],
.form-field input[type="datetime-local"] {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    box-sizing: border-box;
    font-family: var(--font);
}

.form-field input[type="text"]:focus,
.form-field input[type="password"]:focus,
.form-field input[type="number"]:focus,
.form-field input[type="datetime-local"]:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 2px rgba(0, 112, 192, 0.15);
}

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

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 4px;
}

.checkbox-row label { margin: 0; font-size: 0.875rem; font-weight: 500; }

.action-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    align-items: center;
}

.hint {
    font-size: 11px;
    color: var(--dim);
    margin-top: 3px;
    font-style: italic;
    line-height: 1.4;
}

.log-box {
    background: #0f172a;
    color: #a8d5a2;
    font-family: var(--mono);
    font-size: 0.8rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius);
    padding: 14px 16px;
    min-height: 120px;
    max-height: 420px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-word;
}

body.dark-mode .log-box { background: #060e18; }

.log-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--mono);
}

.badge-blue  { background: rgba(0, 112, 192, 0.1);  color: var(--brand-blue); }
.badge-green { background: rgba(22, 163, 74, 0.1);   color: #16a34a; }
.badge-red   { background: rgba(220, 38, 38, 0.1);   color: #dc2626; }

body.dark-mode .badge-blue  { background: rgba(0, 112, 192, 0.2);  color: #60a5fa; }
body.dark-mode .badge-green { background: rgba(22, 163, 74, 0.2);  color: #86efac; }
body.dark-mode .badge-red   { background: rgba(220, 38, 38, 0.2);  color: #fca5a5; }

.btn-danger  { background: #dc2626; color: #fff; border: none; }
.btn-danger:hover  { background: #b91c1c; }
.btn-success { background: #16a34a; color: #fff; border: none; }
.btn-success:hover { background: #15803d; }

@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.running-pulse { animation: pulse 1.2s ease-in-out infinite; }

/* ===== BARE FORM TEMPLATE LAYOUT ===== */
/* Applies only to simple add/edit forms (no .app-section children).
   Uses :has() to exclude complex settings forms automatically. */

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) br,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) br,
.card > form:not(:has(.app-section)):not(:has(.filter-sort-list)) br {
    display: none;
}

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)),
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0 20px;
    align-items: start;
}

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > h1,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > h2,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > h3,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > p,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > hr,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > button,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > input[type="submit"],
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) h1,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) h2,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) h3,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) p,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) button,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) input[type="submit"] {
    grid-column: 1 / -1;
}

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) label,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) label {
    display: block;
    font-size: 11px;
    font-family: var(--mono);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 400;
    color: var(--dim);
    margin-top: 14px;
    margin-bottom: 4px;
}

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) label > input[type="checkbox"],
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) label > input[type="checkbox"] {
    margin-right: 6px;
    width: auto;
    height: auto;
    display: inline;
    transform: translateY(1px);
}

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) input:not([type="checkbox"]):not([type="submit"]):not([type="button"]):not([type="radio"]),
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) select,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) textarea,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) input:not([type="checkbox"]):not([type="submit"]):not([type="button"]):not([type="radio"]),
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) select,
.table-container form:not(:has(.app-section)):not(:has(.filter-sort-list)):not(:has(.form-grid)) textarea {
    width: 100%;
    box-sizing: border-box;
}

main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > button,
main > form:not(.date-range-form):not(:has(.app-section)):not(:has(.filter-sort-list)) > input[type="submit"] {
    margin-top: 20px;
}
