/* Portal density: every screen matches the Schedule grids (.78rem text, tight padding, #999 grid lines).
   :where() keeps these at zero specificity so a screen's own rules (e.g. the schedule grid's cells) still win. */
:where(#content, #modals) .p-panel { margin-bottom: .5rem !important; }
:where(#content, #modals) .p-panel-header { padding: .4rem .6rem !important; }
:where(#content, #modals) .p-panel-title { font-size: .9rem; }
:where(#content, #modals) .p-panel-content { padding: .3rem .4rem !important; font-size: .78rem; }
:where(#modals) .p-dialog-header { padding: .5rem .75rem !important; }
:where(#modals) .p-dialog-title { font-size: .9rem !important; }
:where(#modals) .p-dialog-content { padding: .25rem .5rem .5rem !important; }
/* Tables */
:where(#content, #modals) .p-datatable-table { font-size: .78rem; }
:where(#content, #modals) .p-datatable-table th, :where(#content, #modals) .p-datatable-table td { padding: 1px 4px !important; border-color: #999 !important; vertical-align: top; }
:where(#content, #modals) .p-datatable-thead th { position: sticky; top: 0; z-index: 1; line-height: 1.2; }
/* matches the theme's own selector (so it wins by coming later) without !important, so a header's inline colour still shows */
:where(#content, #modals) .p-datatable .p-datatable-thead > tr > th { background: #f8f9fa; }
:where(#content, #modals) .p-sortable-column-icon { font-size: .65rem; margin-left: .25rem; }
/* Form fields */
:where(#content, #modals) .jmt-field { font-size: .78rem; }
:where(#content, #modals) .jmt-field-caption { padding: 1px 3px; }
:where(#content, #modals) .jmt-field .p-inputtext { height: 22px; padding: 1px 3px; font-size: .78rem; }
:where(#content, #modals) .jmt-field textarea.p-inputtext { height: auto; }
:where(#content, #modals) .jmt-field .p-inputgroup-addon { height: 22px; min-width: 2rem; padding: 0 .4rem; font-size: .78rem; }
:where(#content, #modals) .jmt-field-checkbox { min-height: 22px; }
/* Editable table cells (a captioned cell is a .jmt-field row, sized by the Form fields rules above) */
:where(#content, #modals) .jmt-cell { padding: 0 !important; }
:where(#content, #modals) .jmt-cell .jmt-cell-input { min-height: 22px; padding: 1px 3px; font-size: .78rem; }
:where(#content, #modals) .jmt-cell input.jmt-cell-input, :where(#content, #modals) .jmt-cell select.jmt-cell-input { height: 22px; }
:where(#content, #modals) .jmt-field .jmt-cell-check, :where(#content, #modals) .jmt-field .jmt-cell-multi,
:where(#content, #modals) .jmt-field .jmt-color { min-height: 22px; }
:where(#content, #modals) .jmt-cell-check, :where(#content, #modals) .jmt-cell-multi { gap: .1rem .6rem; }
:where(#content, #modals) .jmt-color { gap: .3rem; font-size: .78rem; }
/* Buttons, panel-header tools (Add / Update / status filter) */
:where(#content, #modals) .p-button:not(.fb-mini):not(.p-button-icon-only) { font-size: .78rem; padding: .2rem .5rem; }
:where(#content, #modals) .jmt-panel-tools { font-size: .78rem; gap: .4rem; }

/* JMT_TIMETABLE_GRID */
.fb-tt { overflow-x: auto; font-size: .78rem; }
.fb-tt-row { display: grid; grid-template-columns: 50px repeat(7, 140px); gap: 2px; margin-bottom: 2px; min-width: 1040px; }
.fb-tt-header { font-weight: 600; color: #1e3a8a; line-height: 1.2; }
.fb-tt-head { text-align: center; }
.fb-tt-time { font-weight: 600; color: #374151; display: flex; align-items: center; }
.fb-tt-cell { min-height: 34px; border-radius: 3px; border: 1px solid #999; padding: 2px; overflow: hidden; display: flex; flex-direction: column; gap: 2px; }
.fb-tt-empty { flex-grow: 1; display: flex; align-items: center; justify-content: center; color: #fff; }
.fb-tt-booking { padding: 1px 3px; border-radius: 3px; background: #fff; border: 1px solid #999; color: #111; line-height: 1.25; }
.fb-tt-start { font-weight: 700; color: #1e3a8a; }
.fb-tt-venue { font-size: .7rem; color: #6b7280; }
.fb-tt-zone { font-weight: 600; color: #374151; }
/* Calendar */
.fb-cal td { padding: 0 !important; height: 1.8rem; }
.fb-cal td:nth-child(-n+3) { padding: 0 4px !important; vertical-align: middle; }
.fb-cal-day { width: 100%; height: 100%; min-height: 1.8rem; display: flex; justify-content: center; align-items: center; position: relative; overflow: hidden; }
.fb-cal-type { background: #000; color: #fff; position: absolute; bottom: 4px; left: 0; right: 0; text-align: center; font-size: .7rem; opacity: 0;
               transition: opacity .2s; pointer-events: none; }
.fb-cal-day:hover .fb-cal-type { opacity: 1; }
/* Schedule grid */
table.fb-sched { font-size: .78rem; }
/* Grid panel: lean padding; the grid scrolls inside it (schedule.js sizes it to end at the bottom of the screen) */
.fb-sched-panel { margin-bottom: 0 !important; }
.fb-sched-scroll { overflow: auto; }
table.fb-sched th { position: sticky; top: 0; z-index: 2; padding: .2rem .3rem !important; text-align: center; line-height: 1.2; }
.fb-sched-cycle { font-weight: 400; font-size: .7rem; opacity: .9; }
table.fb-sched td { vertical-align: top; padding: 0 !important; }
table.fb-sched td:nth-child(-n+2) { padding: 1px 4px !important; }
/* Time and Zone stay put when the grid scrolls sideways (fixed widths, so Zone knows where Time ends) */
table.fb-sched th:nth-child(-n+2), table.fb-sched td:nth-child(-n+2) { position: sticky; z-index: 1; background: #fff; }
table.fb-sched th:nth-child(1), table.fb-sched td:nth-child(1) { left: 0; width: 46px; min-width: 46px; max-width: 46px; }
table.fb-sched th:nth-child(2), table.fb-sched td:nth-child(2) { left: 46px; width: 82px; min-width: 82px; max-width: 82px; box-shadow: inset -2px 0 0 #999; }
table.fb-sched th:nth-child(-n+2) { z-index: 3; background: #f8f9fa; }
tr.fb-sched-editing td:nth-child(-n+2) { background: #eef4ff; }
/* Filters above the grid */
.fb-sched-filters { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .25rem; }
.fb-sched-filter { width: auto; min-width: 130px; height: 26px; padding: 0 .4rem; font-size: .78rem; }
.fb-sched-filters .fb-sched-jump { height: 26px; margin: 0 !important; }
.fb-sched-closed { background: #e5e7eb; }
/* A week between billing cycles (no slots); a day before today (read only) */
table.fb-sched th.fb-sched-nocycle { background: #e5e7eb; color: #374151; }
.fb-sched-past { opacity: .55; }
/* A day column is as wide as its content (~125px); the lock is an inset outline, so it takes no space */
/* A grid cell: class in the upper half, instructor in the lower, each filled with its own colour */
.fb-sched-cell { min-width: 125px; cursor: pointer; }
.fb-half { height: 16px; line-height: 16px; padding: 0 4px; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-half + .fb-half { border-top: 1px solid rgba(0,0,0,.15); }
.fb-half-none { font-style: italic; opacity: .5; }
.fb-locked { outline: 2px solid #000; outline-offset: -2px; }
/* A class / instructor in Conflicts: a badge in its own colour */
.fb-badge { display: inline-block; max-width: 140px; height: 15px; line-height: 15px; padding: 0 4px; border-radius: 3px; font-size: .72rem;
            font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; vertical-align: top; }
.fb-badges { display: flex; flex-wrap: wrap; gap: 2px; }
.fb-sched-edit { display: flex; gap: 2px; padding: 1px; }
.fb-sched-tools { display: flex; flex-direction: column; gap: 1px; }
.fb-sched-tools .fb-mini { height: 18px; padding: 0 .25rem; }
.fb-sched-tools .p-button-icon { font-size: .7rem; margin: 0; }
.fb-sched-select { display: block; width: 115px; height: 18px; padding: 0 2px; font-size: .72rem; margin-bottom: 1px; }
/* A day being edited: lock / fill forward / reset stacked small on the left, the two dropdowns filling the rest */
.fb-sched-edit { align-items: stretch; }
.fb-sched-tools .fb-mini { width: 20px; height: 17px; padding: 0; justify-content: center; }
.fb-sched-picks { flex: 1 1 auto; display: flex; flex-direction: column; gap: 1px; min-width: 110px; }
.fb-sched-picks .fb-sched-select { width: 100%; flex: 1 1 0; height: auto; min-height: 17px; margin: 0; }
/* A conflict opened from Conflicts: its time + lane cells in red, its day's cell outlined red; the conflict row itself marked */
table.fb-sched td.fb-conflict-hl, tr.fb-sched-editing td.fb-conflict-hl { background: #dc2626 !important; color: #fff !important; }
table.fb-sched td.fb-conflict-day { outline: 3px solid #dc2626 !important; outline-offset: -3px; }
.fb-conflicts tr.fb-conflict-open td { background: #fee2e2; color: #111; }
.fb-mini { height: 22px; width: auto; padding: 0 .4rem; margin: 0 !important; }
tr.fb-sched-editing td { background: #eef4ff; }
.fb-no-cycle { margin: 20px auto; padding: 15px 20px; font-weight: bold; font-size: 16px; color: #b71c1c; background: #ffcdd2; border: 1px solid #f44336;
               border-radius: 6px; text-align: center; max-width: 400px; }
/* Theme preview */
.fb-preview { border-radius: 20px; overflow: hidden; max-width: 400px; margin: 0 auto; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.fb-preview-header { padding: 1rem; font-weight: bold; font-size: 1.1rem; display: flex; align-items: center; gap: .75rem; }
.fb-preview-logo { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
.fb-preview-footer { display: flex; justify-content: space-around; padding: .75rem 0; font-size: 1.2rem; }
.fb-answer { white-space: pre-wrap; margin: 0; line-height: 1.5; }

/* Bookings: the Search button at the end of the Filter box */
.fb-search-button { border: none; gap: .3rem; font-weight: 600; }
.fb-search-button:hover { filter: brightness(1.1); }

/* Stats / Reports / Exceptions (JMT_STAT_TILE, JMT_THERMOMETER, JMT_FILL_BARS, JMT_COUNT_BARS, JMT_COLUMN_CHART, JMT_PERIOD_FILTER).
   One hue for amounts (booked = blue, free = its light tint); status colours only for good / warning / critical, always with a label. */
:root { --fb-ink: #1f2937; --fb-muted: #6b7280; --fb-line: #d1d5db; --fb-surface: #ffffff; --fb-booked: #2a78d6; --fb-free: #cfe0f5;
        --fb-good: #1baf7a; --fb-warning: #d99100; --fb-critical: #d62c2b; --fb-info: #2a78d6; }
.jmt-dark { --fb-ink: #f3f4f6; --fb-muted: #9ca3af; --fb-line: #3f3f46; --fb-surface: #1e1e1e; --fb-booked: #5b9cf0; --fb-free: #2b3d55;
            --fb-good: #3cc48f; --fb-warning: #f0b429; --fb-critical: #f0625f; --fb-info: #5b9cf0; }
.fb-muted { color: var(--fb-muted); }
.fb-note { margin: .4rem .2rem; font-size: .75rem; }
.fb-filter-row { align-items: center; margin-bottom: 0; }
.fb-filter-row > div { padding-top: .2rem; padding-bottom: .2rem; }
.fb-quick-row { display: flex; flex-wrap: wrap; gap: .25rem; padding: 0 .5rem .3rem; }
.fb-quick-row .p-button { margin: 0 !important; }

.fb-tile { display: block; height: 100%; padding: .7rem .9rem; border: 1px solid var(--fb-line); border-left: 4px solid var(--fb-booked);
           border-radius: 8px; background: var(--fb-surface); color: var(--fb-ink); text-decoration: none; }
.fb-tile-label { font-size: .75rem; color: var(--fb-muted); display: flex; gap: .35rem; align-items: center; }
.fb-tile-value { font-size: 1.7rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.fb-tile-sub { font-size: .72rem; color: var(--fb-muted); }
.fb-tile.fb-tone-good { border-left-color: var(--fb-good); }
.fb-tile.fb-tone-warning { border-left-color: var(--fb-warning); }
.fb-tile.fb-tone-critical { border-left-color: var(--fb-critical); }
.fb-tile.fb-tone-info { border-left-color: var(--fb-info); }

.fb-thermos { display: flex; justify-content: space-around; flex-wrap: wrap; gap: 12px; padding: .6rem 0; }
.fb-thermo { display: flex; flex-direction: column; align-items: center; min-width: 96px; padding: .4rem; border-radius: 10px; border: 2px solid transparent;
             color: var(--fb-ink); --fb-fill: var(--fb-booked); }
.fb-thermo.fb-tone-good { --fb-fill: var(--fb-good); }
.fb-thermo.fb-tone-warning { --fb-fill: var(--fb-warning); }
.fb-thermo.fb-tone-critical { --fb-fill: var(--fb-critical); }
.fb-thermo.fb-tone-none { --fb-fill: var(--fb-line); color: var(--fb-muted); }
.fb-thermo-today { border-color: var(--fb-booked); }
.fb-thermo-title { font-weight: 600; margin-bottom: 6px; font-size: .8rem; }
.fb-thermo-body { display: flex; align-items: flex-end; gap: 6px; }
.fb-thermo-glass { display: flex; flex-direction: column; align-items: center; }
.fb-thermo-tube { position: relative; width: 22px; height: 150px; border-radius: 11px 11px 0 0; border: 2px solid var(--fb-line); border-bottom: none;
                  overflow: hidden; background: var(--fb-surface); }
.fb-thermo-fill { position: absolute; bottom: 0; left: 0; right: 0; background: var(--fb-fill); transition: height .6s ease; }
.fb-thermo-mark { position: absolute; right: 0; width: 7px; border-top: 1px solid var(--fb-muted); }
.fb-thermo-bulb { width: 38px; height: 38px; margin-top: -5px; border-radius: 50%; border: 2px solid var(--fb-line); background: var(--fb-fill); }
.fb-thermo-scale { height: 186px; display: flex; flex-direction: column; justify-content: space-between; padding-bottom: 36px; font-size: .65rem; color: var(--fb-muted); }
.fb-thermo-pct { font-size: 1.15rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

.fb-bars { display: flex; flex-direction: column; gap: 4px; padding: .3rem .2rem; }
.fb-legend { display: flex; align-items: center; gap: .35rem; font-size: .72rem; color: var(--fb-muted); margin-bottom: .2rem; }
.fb-key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-left: .4rem; }
.fb-key-booked { background: var(--fb-booked); } .fb-key-free { background: var(--fb-free); }
.fb-bar-row { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 92px; align-items: center; gap: 8px; color: var(--fb-ink); }
.fb-bar-row:hover { background: rgba(127, 127, 127, .08); }
.fb-bar-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fb-bar-track { height: 14px; }
.fb-bar { display: flex; height: 100%; gap: 2px; min-width: 2px; }
.fb-bar-booked { background: var(--fb-booked); border-radius: 4px 0 0 4px; height: 100%; }
.fb-bar-free { background: var(--fb-free); border-radius: 0 4px 4px 0; height: 100%; }
.fb-bar-solo { border-radius: 0 4px 4px 0; min-width: 2px; }
.fb-bar-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.fb-fill-row { grid-template-columns: minmax(90px, 30%) 1fr 72px 40px; }
.fb-fill-bar { height: 100%; width: 100%; border-radius: 4px; overflow: hidden; background: var(--fb-free); }
.fb-fill-bar .fb-bar-booked { border-radius: 0; }

.fb-cols { display: flex; align-items: flex-end; gap: 3px; height: 180px; padding: 1.2rem .3rem 0; border-bottom: 1px solid var(--fb-line); }
.fb-col { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; min-width: 6px; position: relative; }
.fb-col:hover .fb-col-bar { filter: brightness(1.15); }
.fb-col-bar { width: 100%; max-width: 28px; background: var(--fb-booked); border-radius: 4px 4px 0 0; min-height: 1px; }
.fb-col-value { font-size: .7rem; color: var(--fb-ink); font-weight: 600; }
.fb-col-label { position: absolute; bottom: -1.1rem; font-size: .62rem; color: var(--fb-muted); }
.fb-cols + * { margin-top: 1.2rem; }

.fb-report-card { display: block; height: 100%; padding: .6rem .8rem; border: 1px solid var(--fb-line); border-radius: 8px; color: var(--fb-ink);
                  background: var(--fb-surface); text-decoration: none; cursor: pointer; }
.fb-report-card:hover { border-color: var(--fb-booked); }
.fb-report-active { border: 2px solid var(--fb-booked); box-shadow: 0 0 0 3px rgba(42, 120, 214, .15); }
.fb-report-title { display: flex; gap: .4rem; align-items: center; font-weight: 600; margin-bottom: .2rem; }
.fb-report-tools { display: flex; align-items: center; gap: .5rem; padding: .3rem .5rem; }

.fb-check { cursor: pointer; }
.fb-check-head { display: flex; justify-content: space-between; align-items: center; }
.fb-check-title { font-size: .8rem; }
.fb-badge { display: inline-flex; align-items: center; gap: .2rem; font-size: .7rem; font-weight: 600; padding: .1rem .45rem; border-radius: 999px;
            border: 1px solid currentColor; }
.fb-badge.fb-tone-good { color: var(--fb-good); } .fb-badge.fb-tone-warning { color: var(--fb-warning); }
.fb-badge.fb-tone-critical { color: var(--fb-critical); } .fb-badge.fb-tone-info { color: var(--fb-info); }
@media (max-width: 640px) { .fb-bar-row { grid-template-columns: 80px 1fr 76px; } .fb-fill-row { grid-template-columns: 80px 1fr 60px 36px; } .fb-thermo { min-width: 80px; } }

/* Report Writer */
.fb-rw-default { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.fb-rw-line { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .2rem; }
.fb-rw-label { min-width: 6.5rem; font-weight: 600; font-size: .78rem; color: var(--fb-ink); }
.fb-rw-sub { font-weight: 600; font-size: .75rem; margin: .5rem .2rem .2rem; color: var(--fb-muted); }
:where(#content) .fb-rw-input { height: 24px; padding: 1px 4px; font-size: .78rem; min-width: 0; }
.fb-rw-line .fb-rw-input { flex: 1; min-width: 8rem; }
.fb-rw-table { width: 100%; border-collapse: collapse; font-size: .75rem; }
.fb-rw-table th { text-align: left; font-weight: 600; color: var(--fb-muted); padding: 2px; }
.fb-rw-table td { padding: 2px; vertical-align: middle; }
.fb-rw-table .fb-rw-input { width: 100%; }
.fb-rw-buttons { white-space: nowrap; }
.fb-rw-icon { border: 1px solid var(--fb-line); background: var(--fb-surface); color: var(--fb-ink); border-radius: 4px; width: 24px; height: 24px;
              padding: 0; cursor: pointer; font-size: .7rem; }
.fb-rw-icon:hover { border-color: var(--fb-booked); color: var(--fb-booked); }
.fb-rw-checks { display: flex; flex-wrap: wrap; gap: .3rem .9rem; padding: .2rem; }
.fb-rw-check { display: inline-flex; align-items: center; gap: .3rem; font-size: .78rem; cursor: pointer; }
.fb-rw-chips { display: flex; flex-wrap: wrap; gap: .3rem; padding: .2rem; }
.fb-rw-chip { display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem; border: 1px solid var(--fb-line); border-radius: 999px;
              font-size: .75rem; color: var(--fb-ink); text-decoration: none; background: var(--fb-surface); }
.fb-rw-chip:hover { border-color: var(--fb-booked); }
.fb-rw-chip-active { border-color: var(--fb-booked); background: var(--fb-free); }
.fb-rw-example .pi { color: var(--fb-warning); }
.fb-rw-error { color: var(--fb-critical); padding: .5rem; font-weight: 600; }
.fb-rw-sql { font-size: .72rem; white-space: pre-wrap; background: rgba(127, 127, 127, .08); padding: .5rem; border-radius: 6px; margin: 0; }
/* JMT_APP_TOPBAR: the current tenant (a list to switch to when the user has several; Bizbot's) */
.jmt-tenant { border-radius: 10px; height: 2.4rem; padding: 0 12px; display: flex; align-items: center; font-size: .875rem;
              font-weight: 600; white-space: nowrap; max-width: 40vw; overflow: hidden; text-overflow: ellipsis; opacity: .85; list-style: none; }
.jmt-tenant::-webkit-details-marker { display: none; }
.jmt-tenant-name { overflow: hidden; text-overflow: ellipsis; }
.jmt-tenant-many { cursor: pointer; opacity: 1; }
.jmt-tenant-options { min-width: 220px; }
/* Dash: the tenant picked in the Tenants list */
.jmt-row-selected > td { background-color: #e8f0fe !important; font-weight: 600; }
