:root {
    --bg: #ffffff;
    --card: #ffffff;
    --muted: #6c757d;
    --text: #212529;
    --primary: #0d6efd; /* Bootstrap primary */
    --primary-700: #0b5ed7;
    --border: #dee2e6;
    --accent: #198754; /* Bootstrap success */
    --danger: #dc3545;
    --warning: #ffc107;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text); font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Helvetica Neue, Arial, "Apple Color Emoji", "Segoe UI Emoji"; line-height: 1.6; }

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

/* Header tweaks on top of Bootstrap */
/* Light, airy navbar with subtle translucency */
header.navbar { position: sticky; top: 0; z-index: 10; backdrop-filter: saturate(180%) blur(6px); background: rgba(255,255,255,0.85); border-bottom: 1px solid rgba(222,226,230,.8); }
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 600; letter-spacing: .2px; }
.brand .clock { display: inline-block; font-size: 1.2rem; line-height: 1; }
/* Bigger user icon in navbar */
.navbar .fa-circle-user { font-size: 1.5rem; line-height: 1; }
/* Do not underline navbar links on hover/focus/active */
.navbar .nav-link:hover,
.navbar .nav-link:focus,
.navbar .nav-link:active,
.navbar .navbar-brand:hover,
.navbar .navbar-brand:focus,
.navbar .navbar-brand:active { text-decoration: none; }

/* Card look over Bootstrap base */
.card { background: var(--card); border: 1px solid rgba(222,226,230,.6); border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.05); margin-bottom: 1.25rem; }
.card-plain { box-shadow: none !important; border-color: rgba(222,226,230,.6); }
.card.pad { padding: 1rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: space-between; align-items: baseline; margin-bottom: .5rem; }

/* Alerts: map to bootstrap classes via helper selectors */
.flash-success { background: rgba(16,185,129,.1); color: #065f46; border: 1px solid rgba(16,185,129,.2); padding: .5rem .75rem; border-radius: .375rem; }
.flash-error { background: rgba(239,68,68,.08); color: #7f1d1d; border: 1px solid rgba(239,68,68,.2); padding: .5rem .75rem; border-radius: .375rem; }

.muted { color: var(--muted); }
.section-title { margin: .2rem 0 1rem; font-size: 1.25rem; }
.kpi { display: inline-flex; align-items: center; gap: .5rem; padding: .35rem .6rem; background: #f8f9fa; border: 1px solid var(--border); border-radius: .5rem; }

/* Let Bootstrap style inputs; keep slight rounding */
input[type="text"], input[type="number"], select { border-radius: .5rem; }
label { color: var(--muted); font-size: .9rem; margin-right: .4rem; }
form.inline { display: inline-flex; align-items: center; gap: .4rem; }
.grid-x { display: grid; gap: 1rem; }
.grid-3 { grid-template-columns: repeat(3, minmax(270px, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(270px, 1fr)); }

/* Div-grid system */
.dg-wrap { overflow: auto; max-width: 100%; }
.dg { display: grid; border-left: 1px solid var(--border); border-top: 1px solid var(--border); }
.dg > .dg-cell { border-right: 1px solid rgba(222,226,230,.7); border-bottom: 1px solid rgba(222,226,230,.7); padding: .5rem .6rem; background: var(--card); z-index: 1; }
.dg > .dg-cell.dg-head { background: #0e162b; color: var(--muted); font-weight: 600; position: sticky; top: 52px; z-index: 20; }
.dg > .dg-cell.dg-subhead { background: #0e162b; color: var(--muted); position: sticky; top: calc(52px + 34px); z-index: 15; }
.dg-sticky-1 { position: sticky; left: 0; z-index: 50; background: var(--card); box-shadow: 2px 0 0 rgba(0,0,0,0.06); }
.dg-sticky-2 { position: sticky; left: 220px; z-index: 2; }
.v-rl { writing-mode: vertical-rl; transform: rotate(180deg); white-space: nowrap; }
@media (max-width: 900px) { .dg-sticky-2 { left: 140px; } .nav { gap: .5rem; } }

/* Keep second column behind the sticky first column (avoid relative positioning that can affect stacking across grids) */
.dg > .dg-cell:nth-child(2) { z-index: 2; }

/* Utilities to replace previous inline styles */
.justify-between { justify-content: space-between; }
.items-baseline { align-items: baseline; }
.mb-2 { margin-bottom: .5rem; }
.mb-075 { margin-bottom: .75rem; }
.minw-900 { min-width: 900px; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }
.grid-col-span-2 { grid-column: 1 / span 2; }
.grid-col-span-5 { grid-column: 1 / span 5; }
.w-90 { width: 90px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 2rem; }
.gap-1 { gap: 1rem; }
.border { border: 1px solid var(--border); }
.pad-1 { padding: 1rem; }
.minw-320 { min-width: 320px; }
.subcat-grid { grid-template-columns: 1fr 1fr 120px 160px; margin-top: .5rem; }
.cat-cols { grid-template-columns: 60px 1fr 1fr 160px 200px; }
/* helper for full-row note */
.grid-span-4 { grid-column: 1 / span 4; }
.grid-span-5 { grid-column: 1 / span 5; }

/* Agents page: disable sticky headers to avoid overlap */
.agents-grid .dg > .dg-cell.dg-head {
    position: static;
    top: auto;
    z-index: 1;
}
/* Categories page: disable sticky headers to avoid overlap */
.categories-grid .dg > .dg-cell.dg-head {
    position: static;
    top: auto;
    z-index: 1;
}
/* Subcategories page: disable sticky headers to avoid overlap and ensure headers don't overlap content */
.subcategories-grid .dg > .dg-cell.dg-head {
    position: static;
    top: auto;
    z-index: 1;
}

/* Accordion title width */
.accordion-button .accordion-title {
    width: 40%;
    min-width: 0;
}
/* Ensure consistent row height and prevent header text from overflowing into next row */
.subcategories-grid .dg > .dg-cell,
.subcategories-grid .dg > .dg-cell.dg-head {
    line-height: 1.2;
}
.subcategories-grid .dg > .dg-cell.dg-head {
    white-space: nowrap;
}

/* Ensure sticky first-column headers stay on top of all cells */
.dg > .dg-cell.dg-head.dg-sticky-1,
.dg > .dg-cell.dg-subhead.dg-sticky-1 {
    z-index: 60;
}

/* Home: category blocks on one line, except project */
.cat-row { display: flex; flex-wrap: nowrap; align-items: flex-start; gap: 1rem; overflow-x: auto; padding-bottom: .25rem; }
.cat-block { display: inline-block; min-width: 280px; max-width: 520px; vertical-align: top; }
.cat-block h5 { margin-bottom: .5rem; }
.cat-block--project { display: block; width: 100%; max-width: none; }

/* Charts: control container height to avoid excessive vertical space */
.chart-wrap { position: relative; height: 260px; }
.chart-wrap > canvas { width: 100% !important; height: 100% !important; display: block; }

/* Remove focus borders/outlines on accordion buttons (Bootstrap override) */
.accordion-button:focus,
.accordion-button:focus-visible,
.accordion-button:active {
    outline: none !important;
    box-shadow: none !important;
    border-color: transparent !important;
}

/* Softer accordion framing for a more modern feel */
.accordion-item { border: 0; }
.accordion-item + .accordion-item { border-top: 1px solid rgba(222,226,230,.6); }
.accordion-body { padding-top: 1rem; padding-bottom: 1rem; }

/* Airy density utilities */
.gap-3x { gap: 1.5rem; }
.section-gap { margin-top: 1rem; margin-bottom: 1.25rem; }
.density-comfortable .form-control { padding-top: .6rem; padding-bottom: .6rem; }
.density-comfortable .btn { padding-top: .5rem; padding-bottom: .5rem; }
.density-comfortable .accordion-button { padding-top: .9rem; padding-bottom: .9rem; }

/* Table row vertical rhythm */
table.table tbody td, table.table tbody th { padding-top: .6rem; padding-bottom: .6rem; }

/* Modernize tables: lighten borders, keep row separators only */
.table { border-collapse: separate; border-spacing: 0; }
.table thead th { border-bottom-color: rgba(222,226,230,.8); }
.table tbody tr { border-bottom: 1px solid rgba(222,226,230,.6); }
.table tbody tr:last-child { border-bottom: 0; }
/* Neutralize Bootstrap bordered grid; mimic cleaner look */
.table-bordered { border: 0 !important; }
.table-bordered > :not(caption) > * { border-width: 0 !important; }
.table-bordered > :not(caption) > * > * { border-width: 0 !important; }

/* Listing utilities: vertical separators and aligned action buttons */
.list-header,
.list-row { border-bottom: 1px solid var(--border); }
.list-header > [class^="col-"],
.list-row > [class^="col-"] { padding-top: .5rem; padding-bottom: .5rem; }
/* vertical separators on desktop */
@media (min-width: 768px) {
  .list-header > [class^="col-"],
  .list-row > [class^="col-"] {
    border-right: 1px solid var(--border);
  }
  .list-header > [class^="col-"]:last-child,
  .list-row > [class^="col-"]:last-child {
    border-right: none;
  }
}
.actions-cell { display: flex; justify-content: flex-end; align-items: center; gap: .5rem; }
.actions-cell .btn { padding-top: .25rem; padding-bottom: .25rem; }

/* Ensure labels inside modals are left-aligned */
.modal .form-label,
.modal label { text-align: left; display: block; }
/* Keep checkbox/radio labels inline with their inputs */
.modal .form-check-label { display: inline-block; margin-left: .35rem; }

/* Card header/footer borders softened */
.card-header, .card-footer { border-color: rgba(222,226,230,.6); }

/* List group: remove side borders, keep subtle separators and increase vertical space */
.list-group { border-radius: 12px; overflow: hidden; }
.list-group-item { border: 0; border-bottom: 1px solid rgba(222,226,230,.6); padding-top: .75rem; padding-bottom: .75rem; }
.list-group-item:last-child { border-bottom: 0; }

/* Global stack spacing between consecutive cards/sections */
.card + .card { margin-top: 1.25rem; }
.section-space { margin-top: 1rem; margin-bottom: 1.5rem; }
.stack-md > * + * { margin-top: 1rem; }

/* Taller table header on Agents page (requested net gain ~10–14px) */
.agents-header-tall thead th,
.agents-header-tall thead td {
    padding-top: 1rem;   /* increase vertical padding for a taller header row */
    padding-bottom: 1rem;
}

/* Utility: center placeholder dash within table cells, including right-aligned cells */
.dash-center {
    display: inline-block;
    width: 100%;
    text-align: center;
}
