/* ==========================================================================
   LifeCommand design system
   Layered on Bootstrap 5.3. Tokens are CSS custom properties so light and dark
   themes (data-bs-theme) share one set of component rules.
   ========================================================================== */

:root,
[data-bs-theme="light"] {
  --lc-primary: #0f766e;
  --lc-primary-rgb: 15, 118, 110;
  --lc-primary-hover: #115e59;
  --lc-primary-soft: #ccfbf1;
  --lc-primary-soft-text: #115e59;
  --lc-accent: #f59e0b;

  --lc-bg: #f5f7f9;
  --lc-surface: #ffffff;
  --lc-surface-2: #f0f3f6;
  --lc-border: #e2e8f0;
  --lc-text: #0f172a;
  --lc-text-muted: #5b6678;

  --lc-sidebar-bg: #0b1f24;
  --lc-sidebar-text: #c7d6d9;
  --lc-sidebar-text-strong: #ffffff;
  --lc-sidebar-active-bg: rgba(45, 212, 191, 0.14);
  --lc-sidebar-active-text: #5eead4;

  --lc-radius: 0.75rem;
  --lc-radius-sm: 0.5rem;
  --lc-shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --lc-shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.10);
  --lc-sidebar-width: 260px;
  --lc-topbar-height: 56px;

  --bs-body-bg: var(--lc-bg);
  --bs-body-color: var(--lc-text);
  --bs-secondary-color: var(--lc-text-muted);
  --bs-border-color: var(--lc-border);
  --bs-primary: var(--lc-primary);
  --bs-primary-rgb: var(--lc-primary-rgb);
  --bs-link-color: var(--lc-primary);
  --bs-link-color-rgb: var(--lc-primary-rgb);
  --bs-link-hover-color: var(--lc-primary-hover);
  --bs-border-radius: var(--lc-radius-sm);
  --bs-border-radius-lg: var(--lc-radius);
  --bs-font-sans-serif: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --bs-focus-ring-color: rgba(var(--lc-primary-rgb), 0.3);
}

[data-bs-theme="dark"] {
  --lc-primary: #2dd4bf;
  --lc-primary-rgb: 45, 212, 191;
  --lc-primary-hover: #5eead4;
  --lc-primary-soft: rgba(45, 212, 191, 0.14);
  --lc-primary-soft-text: #5eead4;

  --lc-bg: #0b1215;
  --lc-surface: #121c20;
  --lc-surface-2: #182429;
  --lc-border: #24343a;
  --lc-text: #e6edf0;
  --lc-text-muted: #94a6ad;

  --lc-sidebar-bg: #071013;
  --lc-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --lc-shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45);

  --bs-body-bg: var(--lc-bg);
  --bs-body-color: var(--lc-text);
  --bs-secondary-color: var(--lc-text-muted);
  --bs-border-color: var(--lc-border);
  --bs-tertiary-bg: var(--lc-surface-2);
}

body {
  background: var(--lc-bg);
  color: var(--lc-text);
  font-family: var(--bs-font-sans-serif);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: var(--lc-radius-sm); }
.btn-primary {
  --bs-btn-bg: var(--lc-primary);
  --bs-btn-border-color: var(--lc-primary);
  --bs-btn-hover-bg: var(--lc-primary-hover);
  --bs-btn-hover-border-color: var(--lc-primary-hover);
  --bs-btn-active-bg: var(--lc-primary-hover);
  --bs-btn-active-border-color: var(--lc-primary-hover);
  --bs-btn-disabled-bg: var(--lc-primary);
  --bs-btn-disabled-border-color: var(--lc-primary);
  --bs-btn-color: #fff;
  --bs-btn-hover-color: #fff;
  --bs-btn-active-color: #fff;
}
[data-bs-theme="dark"] .btn-primary {
  --bs-btn-color: #04201d;
  --bs-btn-hover-color: #04201d;
  --bs-btn-active-color: #04201d;
}
.btn-outline-primary {
  --bs-btn-color: var(--lc-primary);
  --bs-btn-border-color: var(--lc-primary);
  --bs-btn-hover-bg: var(--lc-primary);
  --bs-btn-hover-border-color: var(--lc-primary);
  --bs-btn-active-bg: var(--lc-primary);
}
.form-control:focus, .form-select:focus { border-color: var(--lc-primary); box-shadow: 0 0 0 .25rem var(--bs-focus-ring-color); }
.form-check-input:checked { background-color: var(--lc-primary); border-color: var(--lc-primary); }
.form-label { font-weight: 500; }

/* ---------- App shell: top bar, left menu, content, right column ---------- */
:root { --lc-leftnav-width: 300px; --lc-rail-width: 320px; }

.app-topbar {
  position: sticky; top: 0; z-index: 1030;
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center;
  height: var(--lc-topbar-height);
  padding: 0 1rem;
  background: var(--lc-surface);
  box-shadow: 0 1px 2px rgba(15, 23, 42, .08), 0 1px 0 var(--lc-border);
}
.topbar-left { display: flex; align-items: center; gap: .5rem; min-width: 0; }
.topbar-brand { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; text-decoration: none; color: var(--lc-primary); font-weight: 800; font-size: 1.3rem; letter-spacing: -.03em; }
.topbar-brand:hover { color: var(--lc-primary); }
.app-brand-mark { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #14b8a6, #0f766e); color: #fff; font-size: 1.15rem; }
.topbar-brand-name { display: none; }
@media (min-width: 1400px) { .topbar-brand-name { display: inline; } }
.topbar-search { position: relative; flex: 0 1 260px; min-width: 0; }
.topbar-search i { position: absolute; left: .875rem; top: 50%; transform: translateY(-50%); color: var(--lc-text-muted); }
.topbar-search .form-control { height: 40px; padding-left: 2.4rem; border: 0; border-radius: 999px; background: var(--lc-surface-2); }

.topbar-tabs { display: flex; justify-content: center; align-self: stretch; gap: .25rem; }
.topbar-tab {
  position: relative; display: grid; place-items: center;
  width: clamp(56px, 7vw, 112px); margin: 4px 0;
  border: 0; border-radius: var(--lc-radius-sm); background: transparent;
  color: var(--lc-text-muted); font-size: 1.45rem; text-decoration: none;
}
.topbar-tab:hover { background: var(--lc-surface-2); color: var(--lc-text-muted); }
.topbar-tab.active { color: var(--lc-primary); }
.topbar-tab.active:hover { background: transparent; }
.topbar-tab.active::after { content: ""; position: absolute; left: 6px; right: 6px; bottom: -4px; height: 3px; border-radius: 3px 3px 0 0; background: var(--lc-primary); }

.topbar-right { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; min-width: 0; }
.round-btn, .topbar-right .icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0; flex-shrink: 0;
  border: 0; border-radius: 50%; background: var(--lc-surface-2); color: var(--lc-text);
  font-size: 1.15rem; text-decoration: none;
}
.round-btn:hover, .topbar-right .icon-btn:hover, .round-btn:focus-visible { background: var(--lc-border); color: var(--lc-text); }
.round-btn-avatar { background: transparent; }
.round-btn-avatar:hover { background: transparent; filter: brightness(.92); }
.avatar-topbar { width: 40px; height: 40px; font-size: .85rem; }

/* Phones: logo + buttons in the top bar, section tabs in a bottom bar within thumb reach (like phone apps). */
.topbar-tab-label { display: none; }
:root { --lc-bottombar-height: 0px; }
@media (max-width: 767.98px) {
  :root { --lc-bottombar-height: calc(58px + env(safe-area-inset-bottom)); }
  .app-topbar { grid-template-columns: minmax(0, 1fr) auto; padding: env(safe-area-inset-top) max(.5rem, env(safe-area-inset-right)) 0 max(.5rem, env(safe-area-inset-left)); height: calc(var(--lc-topbar-height) + env(safe-area-inset-top)); }
  .topbar-left { grid-column: 1; }
  .topbar-right { grid-column: 2; gap: .375rem; }
  .topbar-tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    height: var(--lc-bottombar-height); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); gap: 0;
    background: var(--lc-surface); border-top: 1px solid var(--lc-border); box-shadow: 0 -1px 3px rgba(15, 23, 42, .06);
  }
  .topbar-tab { flex: 1; width: auto; margin: 0; border-radius: 0; font-size: 1.3rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
  .topbar-tab:hover { background: transparent; }
  .topbar-tab-label { display: block; font-size: .68rem; font-weight: 600; line-height: 1.1; }
  .topbar-tab.active::after { top: 0; bottom: auto; left: 22%; right: 22%; border-radius: 0 0 3px 3px; }
  .topbar-search { display: none; }
  .topbar-brand-name { display: inline; font-size: 1.2rem; }
  body { padding-bottom: var(--lc-bottombar-height); }
  /* Inputs at 16px so iPhones don't zoom in when a field gets focus. */
  .form-control, .form-select, .input-group-text { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
}
@media (max-width: 380px) { .topbar-brand-name { display: none; } }

.app-frame { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }
@media (min-width: 992px) { .app-frame { grid-template-columns: var(--lc-leftnav-width) minmax(0, 1fr); } }
@media (min-width: 1200px) { .app-frame.has-rail { grid-template-columns: var(--lc-leftnav-width) minmax(0, 1fr) var(--lc-rail-width); } }

.app-leftnav { --bs-offcanvas-width: 320px; --bs-offcanvas-bg: var(--lc-bg); }
@media (min-width: 992px) {
  .app-leftnav { position: sticky; top: var(--lc-topbar-height); max-height: calc(100vh - var(--lc-topbar-height)); overflow-y: auto; background: transparent !important; scrollbar-width: thin; }
  .app-leftnav .offcanvas-body { padding: 1rem .5rem 1rem .75rem; overflow: visible; }
}
.app-rightrail { display: none; }
@media (min-width: 1200px) {
  .app-rightrail { display: block; position: sticky; top: var(--lc-topbar-height); max-height: calc(100vh - var(--lc-topbar-height)); overflow-y: auto; padding: 1rem .75rem 2rem .5rem; scrollbar-width: thin; }
}

.app-content { padding: 1.25rem 1rem 3rem; width: 100%; max-width: 1200px; margin: 0 auto; min-width: 0; }
@media (min-width: 768px) { .app-content { padding: 1.5rem 1.5rem 4rem; } }
.has-rail .app-content { max-width: 720px; }

/* Left menu */
.left-nav { display: flex; flex-direction: column; }
.left-nav-list { list-style: none; margin: 0; padding: 0; }
.left-nav-item {
  display: flex; align-items: center; gap: .75rem; width: 100%;
  padding: .4rem .5rem; border: 0; border-radius: var(--lc-radius-sm); background: transparent;
  color: var(--lc-text); font-weight: 500; text-align: left; text-decoration: none;
}
.left-nav-item:hover { background: rgba(15, 23, 42, .05); color: var(--lc-text); }
[data-bs-theme="dark"] .left-nav-item:hover { background: rgba(255, 255, 255, .06); }
.left-nav-item.active { background: var(--lc-primary-soft); color: var(--lc-primary-soft-text); font-weight: 600; }
.left-nav-me { font-weight: 600; }
.avatar-nav { width: 36px; height: 36px; font-size: .8rem; }
.left-nav-household { margin: .25rem 0 .5rem; }
.left-nav-household .household-switcher, .left-nav-household .household-switcher .btn { width: 100%; max-width: 100%; }
.left-nav-household .household-switcher .btn { justify-content: flex-start; border-radius: var(--lc-radius-sm); }
.left-nav-heading { display: block; margin-top: .5rem; padding: .875rem .5rem .375rem; border-top: 1px solid var(--lc-border); color: var(--lc-text-muted); font-weight: 600; }
.left-nav-toggle .when-expanded { display: none; }
.left-nav-toggle:not(.collapsed) .when-expanded { display: inline; }
.left-nav-toggle:not(.collapsed) .when-collapsed { display: none; }
.left-nav-toggle:not(.collapsed) .bi { transform: rotate(180deg); }
.left-nav-footer { padding: 1rem .5rem; font-size: .75rem; color: var(--lc-text-muted); }

.nav-icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 1.05rem; }
.nav-tone-teal { background: linear-gradient(135deg, #14b8a6, #0f766e); }
.nav-tone-blue { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.nav-tone-sky { background: linear-gradient(135deg, #38bdf8, #0284c7); }
.nav-tone-red { background: linear-gradient(135deg, #f87171, #dc2626); }
.nav-tone-rose { background: linear-gradient(135deg, #fb7185, #e11d48); }
.nav-tone-green { background: linear-gradient(135deg, #4ade80, #16a34a); }
.nav-tone-pink { background: linear-gradient(135deg, #f472b6, #db2777); }
.nav-tone-indigo { background: linear-gradient(135deg, #818cf8, #4f46e5); }
.nav-tone-amber { background: linear-gradient(135deg, #fbbf24, #d97706); }
.nav-tone-yellow { background: linear-gradient(135deg, #facc15, #ca8a04); }
.nav-tone-emerald { background: linear-gradient(135deg, #34d399, #059669); }
.nav-tone-slate { background: linear-gradient(135deg, #94a3b8, #475569); }
.nav-tone-orange { background: linear-gradient(135deg, #fb923c, #ea580c); }
.nav-tone-cyan { background: linear-gradient(135deg, #22d3ee, #0891b2); }
.nav-tone-gray { background: linear-gradient(135deg, #a3a3a3, #525252); }
.nav-tone-violet { background: linear-gradient(135deg, #a78bfa, #7c3aed); }
.nav-tone-muted { background: var(--lc-surface-2); color: var(--lc-text); }
.nav-tone-family { background: var(--lc-primary-soft); color: var(--lc-primary-soft-text); font-size: .78rem; font-weight: 700; }

/* "Menu" grid and account menu in the top bar */
.menu-grid-panel { width: min(400px, 92vw); padding: .75rem; }
.menu-grid-title { padding: .25rem .5rem .75rem; font-size: 1.25rem; font-weight: 700; }
.menu-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .25rem; max-height: 70vh; overflow-y: auto; }
.menu-grid-item { display: flex; align-items: center; gap: .625rem; padding: .5rem; border-radius: var(--lc-radius-sm); color: var(--lc-text); font-size: .9rem; font-weight: 500; text-decoration: none; }
.menu-grid-item:hover { background: var(--lc-surface-2); color: var(--lc-text); }
.account-menu { width: 300px; padding: .5rem; }
.account-card { display: flex; align-items: center; gap: .75rem; padding: .625rem; border-radius: var(--lc-radius); color: inherit; text-decoration: none; box-shadow: var(--lc-shadow); }
.account-card:hover { background: var(--lc-surface-2); color: inherit; }
.account-menu .dropdown-item { border-radius: var(--lc-radius-sm); }

.household-switcher .btn {
  display: flex; align-items: center; gap: .5rem;
  border: 1px solid var(--lc-border); background: var(--lc-surface);
  color: var(--lc-text); max-width: min(260px, 100%);
}
.household-switcher { min-width: 0; flex: 0 1 auto; }
.household-switcher .btn span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px;
  border-radius: var(--lc-radius-sm);
  border: 1px solid transparent;
  background: transparent; color: var(--lc-text-muted);
}
.icon-btn:hover, .icon-btn:focus-visible { background: var(--lc-surface-2); color: var(--lc-text); }

html, body { overflow-x: clip; }

.account-email { max-width: 16rem; }
.narrow-card { max-width: 560px; }
.min-w-0 { min-width: 0; }
.form-card { max-width: 720px; }

.dropdown-menu {
  --bs-dropdown-border-color: var(--lc-border);
  --bs-dropdown-bg: var(--lc-surface);
  --bs-dropdown-link-active-bg: var(--lc-primary);
  box-shadow: var(--lc-shadow-lg);
  border-radius: var(--lc-radius-sm);
}

/* ---------- Page header ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.625rem; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-header p { margin: .25rem 0 0; color: var(--lc-text-muted); }

/* ---------- Cards ---------- */
.lc-card {
  background: var(--lc-surface);
  border: 1px solid var(--lc-border);
  border-radius: var(--lc-radius);
  box-shadow: var(--lc-shadow);
}
.lc-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--lc-border);
}
.lc-card-header h2 { font-size: 1rem; font-weight: 600; margin: 0; display: flex; align-items: center; gap: .5rem; }
.lc-card-header h2 i { color: var(--lc-primary); }
.lc-card-body { padding: 1.25rem; }

.stat { display: flex; flex-direction: column; gap: .125rem; }
.stat-label { font-size: .8rem; color: var(--lc-text-muted); font-weight: 500; }
.stat-value { font-size: 1.05rem; font-weight: 600; }

.welcome-banner {
  border-radius: var(--lc-radius);
  padding: 1.5rem;
  background: linear-gradient(135deg, #0f766e 0%, #134e4a 60%, #0b1f24 100%);
  color: #fff;
  box-shadow: var(--lc-shadow-lg);
}
.welcome-banner p { color: rgba(255, 255, 255, .8); margin: .25rem 0 0; }

/* ---------- Lists ---------- */
.lc-list { list-style: none; margin: 0; padding: 0; }
.lc-list > li { display: flex; align-items: center; gap: .875rem; padding: .875rem 1.25rem; border-top: 1px solid var(--lc-border); }
.lc-list > li:first-child { border-top: 0; }

.avatar {
  flex-shrink: 0;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: .875rem;
  background: var(--lc-primary-soft); color: var(--lc-primary-soft-text);
}
.avatar-lg { width: 56px; height: 56px; font-size: 1.1rem; }

.lc-badge {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .75rem; font-weight: 600;
  padding: .2rem .55rem; border-radius: 999px;
  background: var(--lc-surface-2); color: var(--lc-text-muted);
}
.lc-badge-primary { background: var(--lc-primary-soft); color: var(--lc-primary-soft-text); }
.lc-badge-warning { background: rgba(245, 158, 11, .15); color: #b45309; }
[data-bs-theme="dark"] .lc-badge-warning { color: #fbbf24; }

.timeline-item { display: flex; gap: .75rem; padding: .75rem 1.25rem; border-top: 1px solid var(--lc-border); }
.timeline-item:first-child { border-top: 0; }
.timeline-dot { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--lc-surface-2); color: var(--lc-primary); flex-shrink: 0; }

.checklist-item { display: flex; gap: .875rem; align-items: flex-start; padding: .875rem 1.25rem; border-top: 1px solid var(--lc-border); }
.checklist-item:first-child { border-top: 0; }
.checklist-check { font-size: 1.35rem; line-height: 1; color: var(--lc-border); }
.checklist-item.done .checklist-check { color: var(--lc-primary); }
.checklist-item.done .checklist-title { text-decoration: line-through; color: var(--lc-text-muted); }

/* ---------- Empty state ---------- */
.empty-state { text-align: center; padding: 2.5rem 1.5rem; color: var(--lc-text-muted); }
.empty-state > i { font-size: 2.25rem; color: var(--lc-primary); display: block; margin-bottom: .75rem; }
.empty-state h3 { font-size: 1.05rem; color: var(--lc-text); font-weight: 600; }

/* ---------- Tables ---------- */
.table { --bs-table-bg: transparent; --bs-table-color: var(--lc-text); margin: 0; }
.table > :not(caption) > * > * { padding: .875rem 1.25rem; border-color: var(--lc-border); }
.table thead th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--lc-text-muted); font-weight: 600; background: var(--lc-surface-2); }

/* ---------- Auth / public layout ---------- */
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 992px) { .auth-shell { grid-template-columns: minmax(380px, 5fr) 7fr; } }
.auth-aside {
  display: none;
  background: radial-gradient(1200px 600px at 10% 10%, #14b8a6 0%, transparent 40%), linear-gradient(160deg, #0f766e, #0b1f24 70%);
  color: #fff; padding: 3rem;
}
@media (min-width: 992px) { .auth-aside { display: flex; flex-direction: column; justify-content: space-between; } }
.auth-aside h2 { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; }
.auth-aside li { margin-bottom: .75rem; color: rgba(255,255,255,.85); }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 2rem 1rem; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h1 { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; }
.auth-card .form-floating > label { color: var(--lc-text-muted); }

/* ---------- Landing ---------- */
.landing-hero { padding: 4rem 0 3rem; }
.landing-hero h1 { font-size: clamp(2rem, 5vw, 3.25rem); font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.landing-hero .lead { color: var(--lc-text-muted); max-width: 40rem; }
.feature-tile { padding: 1.5rem; height: 100%; }
.feature-tile i { font-size: 1.5rem; color: var(--lc-primary); }
.feature-tile h3 { font-size: 1.05rem; font-weight: 600; margin: .75rem 0 .375rem; }
.feature-tile p { color: var(--lc-text-muted); margin: 0; font-size: .95rem; }

/* ---------- Toasts ---------- */
.toast-container { z-index: 1090; }
.toast { --bs-toast-bg: var(--lc-surface); border: 1px solid var(--lc-border); box-shadow: var(--lc-shadow-lg); }

/* ---------- Accessibility ---------- */
.skip-link { position: absolute; left: -999px; top: 0; z-index: 2000; background: var(--lc-primary); color: #fff; padding: .5rem 1rem; }
.skip-link:focus { left: 1rem; top: 1rem; }
:focus-visible { outline: 2px solid var(--lc-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.app-leftnav, .app-rightrail { scrollbar-color: transparent transparent; }
.app-leftnav:hover, .app-rightrail:hover { scrollbar-color: var(--lc-border) transparent; }

/* ---------- Phone polish ---------- */
@media (max-width: 767.98px) {
  /* Toasts sit above the bottom tab bar. */
  .toast-container.bottom-0 { bottom: var(--lc-bottombar-height) !important; }
  .app-content { padding: 1rem .75rem 2rem; }
  .page-header { margin-bottom: 1rem; }
  .page-header h1 { font-size: 1.5rem; }

  /* Key figures side by side instead of one per row. */
  .row > .col-md-4:has(> .kpi) { flex: 0 0 auto; width: 33.3333%; }
  .row > .col-md-3:has(> .kpi), .row > .col-sm-6:has(> .kpi) { flex: 0 0 auto; width: 50%; }
  .kpi { padding: .625rem .75rem; }
  .kpi .value { font-size: 1.1rem; overflow-wrap: anywhere; }
  .kpi .label { font-size: .75rem; }

  /* Filters fold away behind a "Filters" button (app.js) unless some are applied. */
  .filter-toggle { display: inline-flex; align-items: center; gap: .375rem; margin-bottom: .75rem; }
  .filter-bar.is-collapsed { display: none; }
  .filter-bar .form-control, .filter-bar .form-select { flex: 1 1 100%; max-width: none; }

  /* Tables become stacked cards: each cell shows its column name (data-label, set by app.js). */
  table.table-stack thead { display: none; }
  table.table-stack, table.table-stack tbody, table.table-stack tr, table.table-stack td, table.table-stack th[scope="row"] { display: block; width: 100%; }
  table.table-stack tr { padding: .625rem .75rem; border-bottom: 1px solid var(--lc-border); }
  table.table-stack td, table.table-stack th[scope="row"] { border: 0; padding: .125rem 0; text-align: left !important; }
  table.table-stack td[data-label]:not([data-label=""]) { display: grid; grid-template-columns: 6.5rem minmax(0, 1fr); gap: .75rem; align-items: baseline; overflow-wrap: anywhere; }
  table.table-stack td[data-label]:not([data-label=""])::before { content: attr(data-label); font-size: .78rem; font-weight: 600; color: var(--lc-text-muted); }
  table.table-stack td:empty { display: none; }
  table.table-stack td, table.table-stack td .text-truncate { white-space: normal !important; overflow: visible; text-overflow: clip; max-width: none; }
  table.table-stack tbody th { display: block; width: 100%; }
}
@media (min-width: 768px) { .filter-toggle { display: none; } }
/* Already running as the installed app: no need to offer it. */
.is-standalone a[href="/app"] { display: none !important; }
/* Phones: an open conversation fills the screen under the top bar, like a messaging app (no tab bar or banners). */
@media (max-width: 767.98px) {
  body:has(.messenger-chat-view) { --lc-bottombar-height: 0px; }
  body:has(.messenger-chat-view) .topbar-tabs { display: none; }
  .messenger-chat-view.messenger, .messenger-chat-view .messenger {
    position: fixed; z-index: 1020; left: 0; right: 0; bottom: 0;
    top: calc(var(--lc-topbar-height) + env(safe-area-inset-top)); height: auto; min-height: 0;
    padding-bottom: env(safe-area-inset-bottom); background: var(--lc-bg);
  }
  .messenger-chat-view .messenger-main { border-radius: 0; border-left: 0; border-right: 0; }
}
/* One-time permissions window (phones / installed app). */
.permissions-prompt-icon { display: flex; justify-content: center; gap: .5rem; margin-bottom: .75rem; font-size: 1.6rem; color: var(--lc-primary); }
.permissions-prompt-icon i { width: 52px; height: 52px; display: grid; place-items: center; border-radius: 50%; background: var(--lc-primary-soft); }
.get-app-finish { max-width: 420px; }
