:root {
  --brand: #1b2a41;
  --brand-2: #0f4c81;
  --tabbar-h: 60px;
}
.bg-brand { background: var(--brand) !important; }
.navbar.bg-brand { padding-top: calc(.5rem + env(safe-area-inset-top)); }   /* clear the notch/status bar when running from the home screen */
.navbar-brand .app-icon { width: 28px; height: 28px; border-radius: 6px; display: block; }
/* Header label as a building/tenant switcher: looks like the brand text, a small chevron says it opens. */
.navbar-brand.context-switch { gap: .35rem; }
.navbar-brand.context-switch .bi-chevron-down { font-size: .7em; opacity: .7; flex-shrink: 0; transition: transform .15s; }
.navbar-brand.context-switch[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }
.navbar-brand.context-switch::after { display: none; }
.bg-brand-gradient { background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%); }
.min-w-0 { min-width: 0; }
body.has-tabbar { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); }

/* Mobile bottom tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
  display: flex; justify-content: space-around;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bs-body-bg); border-top: 1px solid var(--bs-border-color);
}
.tabbar-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; color: var(--bs-secondary-color); font-size: .7rem; gap: 2px;
}
.tabbar-item i { font-size: 1.35rem; line-height: 1; }
.tabbar-item.active { color: var(--brand-2); font-weight: 600; }

/* Big, thumb-friendly targets */
.btn, .form-control, .form-select { min-height: 44px; }
.btn-sm, .form-select-sm, .form-control-sm { min-height: 36px; }
.list-group-item-action { padding-top: .85rem; padding-bottom: .85rem; }

/* Stat tiles */
.stat { border-radius: .75rem; padding: .9rem 1rem; background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); }
.stat .value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat .label { font-size: .75rem; color: var(--bs-secondary-color); text-transform: uppercase; letter-spacing: .03em; }

/* Door state badges */
.state-UNLOCKED { background: var(--bs-success); }
.state-LOCKED { background: var(--bs-secondary); }
.state-UNKNOWN { background: var(--bs-warning); color: #000; }

/* Activation countdown ring */
.js-activate.is-active { border-color: var(--bs-success) !important; box-shadow: 0 0 0 .2rem rgba(25,135,84,.25); }
.js-activate.is-active .btn-danger { background: var(--bs-success); border-color: var(--bs-success); }

/* Schedule editor — day label inline with the time inputs (compact on phones) */
.sched-day { border: 1px solid var(--bs-border-color); border-radius: .5rem; padding: .35rem .4rem; }
.sched-day .day-name { font-weight: 600; width: 2.1rem; flex: 0 0 auto; font-size: .8rem; padding-top: .45rem; }
.sched-block { margin-bottom: .25rem; }
.sched-block:last-child { margin-bottom: 0; }
/* Time inputs must be allowed to shrink: browsers give them a wide intrinsic size. */
.sched-block input[type=time] {
  flex: 1 1 0; width: 100%; min-width: 0;
  padding-left: .3rem; padding-right: .15rem; font-size: .8rem;
}
.sched-day .sep { flex: 0 0 auto; font-size: .75rem; }
/* Narrow icon buttons so the row fits a 390px screen. */
.sched-day .btn { --bs-btn-padding-x: .35rem; --bs-btn-padding-y: .2rem; flex: 0 0 auto; min-height: 34px; }
.sched-day .js-empty { padding-top: .45rem; }

/* Tables: readable on phones */
@media (max-width: 575.98px) {
  .table-mobile thead { display: none; }
  .table-mobile tr { display: block; border-bottom: 1px solid var(--bs-border-color); padding: .5rem 0; }
  .table-mobile td { display: block; border: 0; padding: .15rem 0; }
  .table-mobile td[data-label]::before { content: attr(data-label) ": "; color: var(--bs-secondary-color); font-size: .8rem; }
}
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--bs-secondary-bg); display: inline-flex; align-items: center; justify-content: center; font-weight: 600; color: var(--bs-secondary-color); flex-shrink: 0; }
.card-chip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }

/* Layout utilities (CSP forbids inline style attributes) */
.mw-420 { max-width: 420px; }
.mw-480 { max-width: 480px; }
.mw-560 { max-width: 560px; }
.mw-720 { max-width: 720px; }
.fb-12 { flex-basis: 12rem; }
.scroll-220 { max-height: 220px; overflow: auto; }
.scroll-420 { max-height: 420px; overflow: auto; }
.mw-260 { max-width: 16rem; }

/* Quick door release panel */
.release-grid { display: flex; flex-wrap: wrap; gap: .6rem; }
.release-btn {
  width: 84px; height: 84px; border-radius: .9rem; border: 2px solid var(--bs-border-color);
  background: var(--bs-body-bg); color: var(--bs-body-color);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem;
  font-weight: 700; line-height: 1; cursor: pointer; transition: transform .06s ease, box-shadow .15s ease;
}
.release-btn .rl-label { font-size: 1.6rem; }
.release-btn .rl-sub { font-size: .7rem; font-weight: 500; color: var(--bs-secondary-color); }
.release-btn.is-front { border-color: var(--bs-danger); color: var(--bs-danger); }
.release-btn:active:not(:disabled) { transform: scale(.96); }
.release-btn:disabled { opacity: .5; cursor: not-allowed; }
.release-btn.is-releasing { border-color: var(--bs-success); background: var(--bs-success-bg-subtle); color: var(--bs-success-text-emphasis); }
.release-btn.is-releasing .rl-sub { color: inherit; font-weight: 700; }

/* Quick-release state dot */
.rl-dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.release-btn { position: relative; }
.release-btn.is-unlocked { border-color: var(--bs-success); }
.rl-dot.state-UNLOCKED { background: var(--bs-success); }
.rl-dot.state-LOCKED { background: var(--bs-secondary); }
.rl-dot.state-UNKNOWN { background: var(--bs-warning); }
/* legend dots sit inline */
.small .rl-dot { position: static; margin-right: .2rem; vertical-align: middle; }

/* Breadcrumb strip under the header */
.crumbbar { background: var(--bs-body-bg); border-bottom: 1px solid var(--bs-border-color); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.crumbbar::-webkit-scrollbar { display: none; }
.crumbbar .breadcrumb { white-space: nowrap; --bs-breadcrumb-divider: '\203A'; }
.crumbbar .breadcrumb-item + .breadcrumb-item::before { padding: 0 .45rem; color: var(--bs-secondary-color); }
.crumbbar .breadcrumb-item a { text-decoration: none; }
.crumbbar .breadcrumb-item a:hover { text-decoration: underline; }
.crumbbar .breadcrumb-item.active { color: var(--bs-secondary-color); }

/* Building card list: tenant name in a fixed column beside the toggle so rows line up */
.tenant-col { flex: 0 0 6.5rem; max-width: 6.5rem; }
.tenant-col .badge { max-width: 100%; display: inline-block; vertical-align: middle; }

/* Tenant home: card list beside the door/activity column. The list scrolls inside a card
   that stretches to the neighbouring column's height on wide screens; phones stack, so cap it. */
.fill-list { overflow-y: auto; max-height: 420px; }
@media (min-width: 992px) {
  .col-fill { display: flex; flex-direction: column; }
  .col-fill > .card { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
  .col-fill .fill-list { flex: 1 1 0; min-height: 0; max-height: none; }
}

/* Search box inside a card header: full row on phones, compact beside the title otherwise */
.hdr-search { flex: 1 1 7rem; min-width: 7rem; width: auto; }
@media (min-width: 576px) { .hdr-search { flex: 0 0 220px; width: 220px; } }

/* Compact quick-release (phones): a little smaller so the row fits without crowding */
.release-compact { gap: .45rem; }
.release-compact .release-btn { width: 66px; height: 66px; border-radius: .7rem; }
.release-compact .rl-label { font-size: 1.25rem; }
.release-compact .rl-sub { font-size: .65rem; }
