/* =====================================================================
   shadcn/ui look for the whole app — loaded LAST.

   shadcn's components are React + Tailwind; this app is server-rendered
   Bootstrap. So this file gives Bootstrap's own classes (.btn, .card,
   .form-control, .table, .modal, .dropdown-menu, .badge, .nav ...) the
   shadcn design: its neutral "zinc" palette, hairline borders, small
   radii, quiet shadows, 36px controls, focus rings and tab / dialog /
   sheet shapes. No template needs to change, and removing this file's
   <link> in base.html returns the previous look.

   The brand colour (Branding or the active theme) stays the one accent.
   Phone layout rules are at the end.
   ===================================================================== */

:root {
  --background: #ffffff;
  --foreground: #09090b;
  --card: #ffffff;
  --muted: #f4f4f5;
  --muted-foreground: #71717a;
  --accent: #f4f4f5;
  --border: #e4e4e7;
  --input: #e4e4e7;
  --ring: var(--app-primary, #4f46e5);
  --destructive: #dc2626;
  --radius: .5rem;
  --radius-md: calc(var(--radius) - 2px);
  --radius-sm: calc(var(--radius) - 4px);
  --radius-xl: .75rem;
  --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / .05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --control-h: 2.25rem;

  /* the older layers read these, so they follow automatically */
  --ui-bg: #fafafa;
  --ui-surface: var(--card);
  --ui-border: var(--border);
  --ui-border-strong: #d4d4d8;
  --ui-text: var(--foreground);
  --ui-text-2: #52525b;
  --ui-text-3: var(--muted-foreground);
  --ui-radius: var(--radius-xl);
  --ui-radius-sm: var(--radius-md);
  --ui-shadow-xs: var(--shadow-xs);
  --ui-shadow-sm: var(--shadow-xs);
  --ui-shadow-md: var(--shadow-md);
  --app-sidebar-hover: var(--accent);
  --app-sidebar-active-bg: var(--accent);
  --bs-border-color: var(--border);
  --bs-body-color: var(--foreground);
  --bs-secondary-color: var(--muted-foreground);
  --bs-tertiary-bg: var(--muted);
  --bs-border-radius: var(--radius-md);
}
[data-bs-theme="dark"] {
  --background: #09090b;
  --foreground: #fafafa;
  --card: #0c0c0e;
  --muted: #27272a;
  --muted-foreground: #a1a1aa;
  --accent: #27272a;
  --border: #27272a;
  --input: #27272a;
  --ui-bg: #09090b;
  --ui-border-strong: #3f3f46;
  --ui-text-2: #d4d4d8;
  --bs-body-bg: #09090b;
}

/* ---- Base ------------------------------------------------------------ */
body, .app-main { background: var(--ui-bg); color: var(--foreground); }
body { font-size: .875rem; line-height: 1.5; font-feature-settings: "cv11", "ss01"; }
h1, h2, h3, h4, h5, h6, .h1, .h2, .h3, .h4, .h5, .h6 { font-weight: 600; letter-spacing: -.02em; color: var(--foreground); }
.text-secondary, .text-muted, .form-text, small.text-secondary { color: var(--muted-foreground) !important; }
hr { border-color: var(--border); opacity: 1; }
::selection { background: color-mix(in srgb, var(--ring) 22%, transparent); }

/* ---- Button ---------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .375rem;
  min-height: var(--control-h); padding: 0 1rem; border-radius: var(--radius-md);
  font-size: .875rem; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; box-shadow: none;
  transition: background-color .15s, color .15s, border-color .15s, box-shadow .15s;
}
.btn > .bi { margin: 0 !important; font-size: 1em; }
.btn-sm { min-height: 2rem; padding: 0 .75rem; font-size: .8125rem; border-radius: var(--radius-md); }
.btn-lg { min-height: 2.5rem; padding: 0 1.5rem; font-size: .9375rem; }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring) !important; }
.btn:disabled, .btn.disabled { opacity: .5; pointer-events: none; }

.btn-primary, .view-switcher .btn.btn-primary, .view-switcher .btn.btn-primary.active {
  background: var(--app-primary) !important; border-color: var(--app-primary) !important;
  color: #fff !important; box-shadow: var(--shadow-xs);
}
.btn-primary:hover { background: color-mix(in srgb, var(--app-primary) 90%, #000) !important; border-color: transparent !important; }
.btn-secondary { background: var(--muted) !important; border-color: transparent !important; color: var(--foreground) !important; }
.btn-secondary:hover { background: color-mix(in srgb, var(--muted) 80%, var(--foreground) 8%) !important; }
.btn-outline-secondary, .btn-outline-primary, .btn-outline-dark, .btn-light, .btn-outline-light {
  background: var(--background) !important; border-color: var(--input) !important;
  color: var(--foreground) !important; box-shadow: var(--shadow-xs);
}
.btn-outline-secondary:hover, .btn-outline-primary:hover, .btn-outline-dark:hover, .btn-light:hover,
.btn-outline-secondary.active, .btn-outline-primary.active, .btn-check:checked + .btn-outline-secondary,
.btn-check:checked + .btn-outline-primary, .btn-outline-secondary.show, .btn-outline-primary.show {
  background: var(--accent) !important; color: var(--foreground) !important; border-color: var(--input) !important;
}
.btn-outline-primary { color: var(--app-primary-dark, var(--app-primary)) !important; }
.btn-danger { background: var(--destructive) !important; border-color: var(--destructive) !important; color: #fff !important; box-shadow: var(--shadow-xs); }
.btn-danger:hover { background: color-mix(in srgb, var(--destructive) 90%, #000) !important; }
.btn-outline-danger { background: var(--background) !important; border-color: var(--input) !important; color: var(--destructive) !important; box-shadow: var(--shadow-xs); }
.btn-outline-danger:hover { background: color-mix(in srgb, var(--destructive) 8%, var(--background)) !important; }
.btn-success { background: #16a34a !important; border-color: #16a34a !important; color: #fff !important; box-shadow: var(--shadow-xs); }
.btn-success:hover { background: #15803d !important; }
.btn-warning { background: #f59e0b !important; border-color: #f59e0b !important; color: #1c1917 !important; }
.btn-outline-warning { background: var(--background) !important; border-color: #fcd34d !important; color: #b45309 !important; }
.btn-outline-warning:hover { background: #fffbeb !important; }
.btn-link { color: var(--foreground) !important; text-underline-offset: 4px; padding: 0 .5rem; }
.btn-link:hover { text-decoration: underline !important; }
.btn-close { opacity: .6; border-radius: var(--radius-sm); }
.btn-close:hover { opacity: 1; }
.btn-group > .btn { box-shadow: none; }

/* ---- Input, Select, Textarea, Label ---------------------------------- */
.form-label, label.form-label { font-size: .875rem; font-weight: 500; color: var(--foreground); margin-bottom: .375rem; line-height: 1.2; }
.form-control, .form-select {
  min-height: var(--control-h); padding: .375rem .75rem; font-size: .875rem;
  background-color: var(--background); color: var(--foreground);
  border: 1px solid var(--input); border-radius: var(--radius-md); box-shadow: var(--shadow-xs);
  transition: border-color .15s, box-shadow .15s;
}
.form-control-sm, .form-select-sm { min-height: 2rem; padding: .25rem .625rem; font-size: .8125rem; border-radius: var(--radius-md); }
.form-select { padding-right: 2rem; background-position: right .625rem center; background-size: 14px 10px; }
textarea.form-control { min-height: 4.5rem; padding-top: .5rem; }
.form-control::placeholder { color: var(--muted-foreground); opacity: 1; }
.form-control:focus, .form-select:focus {
  border-color: var(--ring); box-shadow: 0 0 0 1px var(--ring), var(--shadow-xs) !important; outline: none;
}
.form-control:disabled, .form-select:disabled, .form-control[readonly] { background: var(--muted); opacity: .7; cursor: not-allowed; }
.form-text { font-size: .8125rem; margin-top: .375rem; }
.input-group > .btn { box-shadow: none; }
.input-group-text { background: var(--muted); border-color: var(--input); color: var(--muted-foreground); font-size: .875rem; border-radius: var(--radius-md); }
.form-check-input {
  width: 1rem; height: 1rem; margin-top: .2rem; border: 1px solid var(--ui-border-strong);
  border-radius: var(--radius-sm); background-color: var(--background); box-shadow: var(--shadow-xs);
}
.form-check-input[type="radio"] { border-radius: 50%; }
.form-check-input:checked { background-color: var(--app-primary); border-color: var(--app-primary); }
.form-check-input:focus { border-color: var(--ring); box-shadow: 0 0 0 2px var(--background), 0 0 0 4px var(--ring); }
.form-switch .form-check-input { width: 2.25rem; height: 1.25rem; border-radius: 999px; border-color: transparent; background-color: var(--input); margin-top: .125rem; }
.form-switch .form-check-input:checked { background-color: var(--app-primary); }
.form-check-label { font-size: .875rem; }
fieldset.form-section, .form-section {
  border: 1px solid var(--border) !important; border-radius: var(--radius-xl) !important;
  background: var(--card) !important; box-shadow: none !important;
  padding: 1.25rem !important; margin: 0 0 1rem !important;
}
fieldset.form-section > legend, .form-section > legend {
  float: left; width: 100%; padding: 0 !important; margin: 0 0 1rem !important; border: 0 !important;
  font-size: .9375rem; font-weight: 600; letter-spacing: -.01em; text-transform: none; color: var(--foreground);
}
.form-section > legend + * { clear: both; }
.form-section .form-control, .form-section .form-select { background-color: var(--background); border-color: var(--input); }
.form-section .form-control.bg-body-secondary, .form-control.bg-body-secondary { background-color: var(--muted) !important; }
/* a picker with a button beside it fills the row */
.input-group > .searchable-select, .input-group > .form-select, .input-group > .form-control { flex: 1 1 auto; width: 1%; min-width: 0; }
.input-group > .searchable-select > .form-control, .input-group > .searchable-select > .form-select { width: 100%; }
.input-group > .btn { min-height: var(--control-h); border-color: var(--input) !important; }

/* ---- Card ------------------------------------------------------------ */
.card, .widget-card, .kpi-card {
  background: var(--card); color: var(--foreground);
  border: 1px solid var(--border) !important; border-radius: var(--radius-xl) !important;
  box-shadow: var(--shadow-xs) !important;
}
.card:hover, .widget-card:hover, .kpi-card:hover { transform: none; box-shadow: var(--shadow-xs) !important; }
.card-header {
  background: transparent !important; border-bottom: 1px solid var(--border);
  padding: .875rem 1.25rem; font-size: .9375rem; font-weight: 600; letter-spacing: -.01em; color: var(--foreground);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0 !important;
}
.card-header .bi:first-child { color: var(--muted-foreground); }
.card-body { padding: 1.25rem; }
.card-footer { background: transparent; border-top: 1px solid var(--border); padding: .875rem 1.25rem; }
.kpi-card { padding: 1.125rem 1.25rem; gap: .875rem; }
.kpi-label { font-size: .8125rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted-foreground); }
.kpi-value { font-size: 1.5rem; font-weight: 700; letter-spacing: -.025em; line-height: 1.2; color: var(--foreground); }
.kpi-sub { font-size: .75rem; color: var(--muted-foreground); }
.kpi-icon { width: 2.25rem; height: 2.25rem; border-radius: var(--radius-md); font-size: 1rem; }
.kpi-card.kpi-link:hover { border-color: var(--ui-border-strong) !important; background: color-mix(in srgb, var(--muted) 40%, var(--card)); }

/* ---- Table ----------------------------------------------------------- */
.table { --bs-table-bg: transparent; --bs-table-hover-bg: color-mix(in srgb, var(--muted) 50%, transparent); color: var(--foreground); margin-bottom: 0; font-size: .875rem; }
.table > :not(caption) > * > * { padding: .625rem .75rem; border-bottom: 1px solid var(--border); background: transparent; }
.table > thead > tr > th, .table thead.table-light th, .table-light {
  --bs-table-bg: transparent; background: transparent !important;
  color: var(--muted-foreground); font-size: .8125rem; font-weight: 500; letter-spacing: 0; text-transform: none;
  height: 2.5rem; vertical-align: middle; white-space: nowrap; border-bottom: 1px solid var(--border);
}
.table > tbody > tr:last-child > * { border-bottom: 0; }
.table-hover > tbody > tr:hover > * { background: color-mix(in srgb, var(--muted) 50%, transparent); }
.table tfoot.table-light td, .table > tfoot > tr > * { background: color-mix(in srgb, var(--muted) 50%, transparent) !important; font-weight: 500; border-top: 1px solid var(--border); }
.table-bordered > :not(caption) > * > * { border: 1px solid var(--border); }
.table a:not(.btn) { color: var(--foreground); font-weight: 500; }
.table a:not(.btn):hover { text-decoration: underline; text-underline-offset: 3px; }
.card > .table-responsive:last-child { border-radius: 0 0 var(--radius-xl) var(--radius-xl); }

/* ---- Badge ----------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: .25rem; border-radius: var(--radius-md);
  padding: .125rem .5rem; font-size: .75rem; font-weight: 600; line-height: 1.35; border: 1px solid transparent;
}
.badge.text-bg-primary, .badge.bg-primary { background: color-mix(in srgb, var(--app-primary) 12%, var(--background)) !important; color: var(--app-primary-dark, var(--app-primary)) !important; }
.badge.text-bg-secondary, .badge.bg-secondary, .badge.text-bg-dark { background: var(--muted) !important; color: var(--foreground) !important; }
.badge.text-bg-light, .badge.bg-light { background: var(--background) !important; color: var(--foreground) !important; border-color: var(--border) !important; }
.badge.text-bg-success, .badge.bg-success { background: #dcfce7 !important; color: #166534 !important; }
.badge.text-bg-warning, .badge.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.badge.text-bg-danger, .badge.bg-danger { background: #fee2e2 !important; color: #991b1b !important; }
.badge.text-bg-info, .badge.bg-info { background: #e0f2fe !important; color: #075985 !important; }
[data-bs-theme="dark"] .badge.text-bg-success { background: #14532d !important; color: #bbf7d0 !important; }
[data-bs-theme="dark"] .badge.text-bg-warning { background: #78350f !important; color: #fde68a !important; }
[data-bs-theme="dark"] .badge.text-bg-danger { background: #7f1d1d !important; color: #fecaca !important; }
[data-bs-theme="dark"] .badge.text-bg-info { background: #0c4a6e !important; color: #bae6fd !important; }

/* ---- Dropdown menu / Popover ----------------------------------------- */
.dropdown-menu {
  min-width: 10rem; padding: .25rem; font-size: .875rem; background: var(--background); color: var(--foreground);
  border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-md);
}
.dropdown-item { border-radius: var(--radius-sm); padding: .375rem .5rem; color: var(--foreground); display: flex; align-items: center; gap: .5rem; width: 100%; }
.dropdown-item > .bi { margin: 0 !important; color: var(--muted-foreground); }
.dropdown-item:hover, .dropdown-item:focus { background: var(--accent); color: var(--foreground); }
.dropdown-item.active, .dropdown-item:active { background: var(--accent); color: var(--foreground); font-weight: 500; }
.dropdown-item.text-danger, .dropdown-item.text-danger > .bi { color: var(--destructive) !important; }
.dropdown-header { padding: .375rem .5rem; font-size: .75rem; font-weight: 600; color: var(--muted-foreground); }
.dropdown-divider { margin: .25rem -.25rem; border-color: var(--border); opacity: 1; }
.dropdown-toggle::after { border-top-width: .3em; border-left-width: .25em; border-right-width: .25em; opacity: .5; margin-left: .25rem; }
.tooltip-inner { background: var(--foreground); color: var(--background); border-radius: var(--radius-md); font-size: .75rem; padding: .375rem .625rem; }

/* ---- Dialog (modal) and Sheet (offcanvas) ---------------------------- */
.modal-backdrop.show, .offcanvas-backdrop.show { opacity: .6; background: #000; }
.modal-content { background: var(--background); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); }
.modal-header { border-bottom: 0; padding: 1.5rem 1.5rem .25rem; align-items: flex-start; }
.modal-title { font-size: 1.125rem; font-weight: 600; letter-spacing: -.02em; }
.modal-body { padding: 1rem 1.5rem; }
.modal-footer { border-top: 0; padding: .5rem 1.5rem 1.5rem; gap: .5rem; }
.modal-footer > * { margin: 0; }
.offcanvas { background: var(--background); border-color: var(--border) !important; box-shadow: var(--shadow-lg); }
.offcanvas-header { padding: 1.25rem 1.5rem .75rem; }
.offcanvas-title { font-size: 1.0625rem; font-weight: 600; letter-spacing: -.02em; }
.offcanvas-body { padding: .5rem 1.5rem 1.5rem; }

/* ---- Alert ----------------------------------------------------------- */
.alert { border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); color: var(--foreground); padding: .75rem 1rem; font-size: .875rem; box-shadow: none; }
.alert-success { border-color: #bbf7d0; background: #f0fdf4; color: #14532d; }
.alert-danger { border-color: #fecaca; background: #fef2f2; color: #7f1d1d; }
.alert-warning { border-color: #fde68a; background: #fffbeb; color: #78350f; }
.alert-info { border-color: #bae6fd; background: #f0f9ff; color: #0c4a6e; }
.alert-light { background: var(--background); border-color: var(--border) !important; color: var(--foreground); }
[data-bs-theme="dark"] .alert-success, [data-bs-theme="dark"] .alert-danger,
[data-bs-theme="dark"] .alert-warning, [data-bs-theme="dark"] .alert-info { background: var(--card); color: var(--foreground); }

/* ---- Tabs (nav-tabs, nav-pills, the view switcher) -------------------- */
.nav-tabs, .nav-pills, .view-switcher {
  display: inline-flex; flex-wrap: nowrap; gap: 0; padding: .25rem; border: 0;
  background: var(--muted); border-radius: var(--radius); max-width: 100%; overflow-x: auto; scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar, .nav-pills::-webkit-scrollbar, .view-switcher::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link, .nav-pills .nav-link, .view-switcher .btn {
  border: 0 !important; border-radius: var(--radius-md) !important; background: transparent !important;
  color: var(--muted-foreground) !important; font-size: .875rem; font-weight: 500;
  padding: 0 .75rem; min-height: 1.875rem; display: inline-flex; align-items: center; gap: .375rem;
  white-space: nowrap; box-shadow: none !important;
}
.nav-tabs .nav-link:hover, .nav-pills .nav-link:hover, .view-switcher .btn:hover { color: var(--foreground) !important; }
.nav-tabs .nav-link.active, .nav-pills .nav-link.active,
.view-switcher .btn.active, .view-switcher .btn.btn-primary {
  background: var(--background) !important; color: var(--foreground) !important; box-shadow: var(--shadow-xs) !important;
}

/* ---- Pagination, list group, accordion, progress ---------------------- */
.pagination { gap: .25rem; }
.page-link { border: 1px solid transparent; border-radius: var(--radius-md) !important; min-width: 2rem; min-height: 2rem; display: inline-flex; align-items: center; justify-content: center; padding: 0 .625rem; font-size: .875rem; font-weight: 500; color: var(--foreground); background: transparent; }
.page-link:hover { background: var(--accent); color: var(--foreground); border-color: transparent; }
.page-item.active .page-link { background: var(--background); border-color: var(--input); color: var(--foreground); box-shadow: var(--shadow-xs); }
.page-item.disabled .page-link { background: transparent; color: var(--muted-foreground); opacity: .5; }
.list-group-item { background: transparent; border-color: var(--border); color: var(--foreground); padding: .75rem 1.25rem; }
.accordion { --bs-accordion-border-color: var(--border); --bs-accordion-border-radius: var(--radius); --bs-accordion-inner-border-radius: var(--radius); --bs-accordion-btn-focus-box-shadow: none; --bs-accordion-active-bg: transparent; --bs-accordion-active-color: var(--foreground); --bs-accordion-bg: var(--card); }
.accordion-button { font-size: .875rem; font-weight: 500; padding: .875rem 1rem; }
.accordion-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.progress { height: .5rem; border-radius: 999px; background: var(--muted); }
.progress-bar { background: var(--app-primary); border-radius: 999px; }
kbd, .kbd-hint { background: var(--muted); color: var(--muted-foreground); border: 1px solid var(--border); border-radius: var(--radius-sm); font-size: .6875rem; font-weight: 500; padding: .0625rem .375rem; box-shadow: none; }

/* ---- Shell: sidebar and top bar -------------------------------------- */
.app-sidebar { background: var(--background); border-right: 1px solid var(--border); box-shadow: none; }
.sidebar-brand { border-bottom: 1px solid var(--border); }
.sidebar-nav .nav-link, .app-sidebar .nav-link {
  min-height: 2.125rem; padding: 0 .625rem; margin: 1px .5rem; border-radius: var(--radius-md);
  font-size: .875rem; font-weight: 500; color: var(--ui-text-2); gap: .625rem; display: flex; align-items: center;
}
.app-sidebar .nav-link .bi:first-child { font-size: 1rem; color: var(--muted-foreground); }
.app-sidebar .nav-link:hover { background: var(--accent); color: var(--foreground); }
.app-sidebar .nav-link.active { background: var(--accent); color: var(--foreground); font-weight: 600; }
.app-sidebar .nav-link.active .bi:first-child { color: var(--app-primary); }
.app-sidebar .nav-section { font-size: .75rem; font-weight: 500; letter-spacing: 0; text-transform: none; color: var(--muted-foreground); padding: 1rem 1.125rem .375rem; }
.app-sidebar .nav-sub .nav-link { min-height: 1.875rem; font-weight: 400; margin-left: 1.25rem; border-left: 1px solid var(--border); border-radius: 0 var(--radius-md) var(--radius-md) 0; padding-left: .875rem; }
.app-topbar {
  background: color-mix(in srgb, var(--background) 85%, transparent); backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border); box-shadow: none; min-height: 3.5rem; padding: 0 1rem;
}
.topbar-title h1 { font-size: 1rem; font-weight: 600; letter-spacing: -.01em; }
.topbar-search {
  min-height: 2rem; border: 1px solid var(--input); border-radius: var(--radius-md); background: var(--background);
  color: var(--muted-foreground); box-shadow: var(--shadow-xs); font-size: .8125rem;
}
.topbar-search:hover { background: var(--accent); color: var(--foreground); }
.app-content { padding: 1.25rem; }
.app-footer { border-top: 0; color: var(--muted-foreground); font-size: .75rem; background: transparent; }
.report-tile { border-radius: var(--radius-xl); border-color: var(--border); box-shadow: var(--shadow-xs); }
.report-tile:hover { border-color: var(--ui-border-strong); box-shadow: var(--shadow-xs); transform: none; background: color-mix(in srgb, var(--muted) 40%, var(--card)); }
.report-tile-icon { border-radius: var(--radius-md); background: var(--tile-soft, var(--muted)); color: var(--tile, var(--foreground)); }
.report-tile { border-left: 3px solid var(--tile, var(--border)); }
.report-tile:hover .report-tile-go { color: var(--tile, var(--app-primary)); }
/* one colour per report, so each is recognised at a glance */
.tone-blue   { --tile: #2563eb; --tile-soft: #eff6ff; }
.tone-green  { --tile: #16a34a; --tile-soft: #f0fdf4; }
.tone-violet { --tile: #7c3aed; --tile-soft: #f5f3ff; }
.tone-amber  { --tile: #d97706; --tile-soft: #fffbeb; }
.tone-rose   { --tile: #e11d48; --tile-soft: #fff1f2; }
.tone-teal   { --tile: #0d9488; --tile-soft: #f0fdfa; }
[data-bs-theme="dark"] .report-tile-icon { background: color-mix(in srgb, var(--tile, #fff) 18%, transparent); }
/* dashboard section headings */
.dash-heading { font-size: .8125rem; font-weight: 600; color: var(--muted-foreground); margin: 1rem 0 .5rem; }
.auth-form .btn { min-height: 2.5rem; }

.help-trigger { padding: 0 !important; min-height: 0 !important; }
.btn.rounded-circle { padding: 0; }

/* ---- Getting started: checklist, dashboard card, coach panel, practice banner */
.learn-tick {
  flex: 0 0 auto; width: 1.75rem; height: 1.75rem; border-radius: 999px; display: grid; place-items: center;
  font-size: .75rem; font-weight: 600; background: var(--muted); color: var(--muted-foreground); border: 1px solid var(--border);
}
.learn-tick.done { background: #16a34a; border-color: #16a34a; color: #fff; }
.learn-card {
  display: flex; align-items: center; gap: .875rem; padding: .625rem .875rem; margin-bottom: 1rem;
  background: var(--card); border: 1px solid var(--border); border-left: 3px solid var(--app-primary);
  border-radius: var(--radius-xl); color: inherit; box-shadow: var(--shadow-xs);
}
.learn-card:hover { border-color: var(--ui-border-strong); border-left-color: var(--app-primary); color: inherit; }
.learn-card-ring {
  flex: 0 0 auto; min-width: 2.5rem; height: 2.5rem; padding: 0 .375rem; border-radius: 999px; display: grid; place-items: center;
  font-size: .75rem; font-weight: 700; color: var(--app-primary-dark, var(--app-primary));
  background: color-mix(in srgb, var(--app-primary) 10%, transparent);
}
.learn-coach {
  position: fixed; right: 1rem; bottom: 4.25rem; z-index: 1040; width: min(22rem, calc(100vw - 2rem));
  background: var(--card); border: 1px solid var(--border); border-top: 3px solid var(--app-primary);
  border-radius: var(--radius-xl); box-shadow: var(--shadow-lg); padding: .75rem .875rem .875rem;
}
.learn-coach.is-done { border-top-color: #16a34a; }
.learn-coach-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .25rem; }
.learn-coach-head .btn-close { font-size: .625rem; }
.learn-coach-title { font-weight: 600; font-size: .9375rem; line-height: 1.3; margin-bottom: .25rem; }
.learn-coach ol li { margin-bottom: .125rem; }
.practice-banner {
  background: #fef3c7; color: #78350f; border: 1px solid #fde68a; border-radius: var(--radius);
  padding: .5rem .875rem; margin-bottom: 1rem; font-size: .875rem;
}
@media (max-width: 767.98px) { .learn-coach { bottom: 4.75rem; right: .5rem; left: .5rem; width: auto; } }

/* ---- Billing: numbered steps in the menu and a step strip on each screen -- */
.nav-step {
  flex: 0 0 auto; width: 1.25rem; height: 1.25rem; border-radius: 999px; display: inline-grid; place-items: center;
  font-size: .6875rem; font-weight: 600; background: var(--muted); color: var(--muted-foreground); border: 1px solid var(--border);
}
.app-sidebar .nav-link.active .nav-step { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
.flow-strip {
  display: flex; align-items: center; gap: .75rem; flex-wrap: nowrap;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl);
  padding: .5rem .75rem; margin-bottom: 1rem; box-shadow: var(--shadow-xs);
}
/* the steps share the row and shorten their captions before anything wraps */
.flow-steps { display: flex; align-items: center; gap: .25rem; flex: 1 1 auto; min-width: 0; flex-wrap: nowrap; }
.flow-step {
  display: flex; align-items: center; gap: .5rem; padding: .375rem .625rem; border-radius: var(--radius-md);
  color: var(--muted-foreground); text-decoration: none !important; border: 1px solid transparent;
  flex: 0 1 auto; min-width: 0;
}
.flow-step:hover { background: var(--accent); color: var(--foreground); }
.flow-step.active { background: color-mix(in srgb, var(--app-primary) 8%, var(--card)); border-color: color-mix(in srgb, var(--app-primary) 30%, var(--border)); color: var(--foreground); }
.flow-num {
  flex: 0 0 auto; width: 1.5rem; height: 1.5rem; border-radius: 999px; display: grid; place-items: center;
  font-size: .75rem; font-weight: 600; background: var(--muted); color: var(--muted-foreground);
}
.flow-step.active .flow-num { background: var(--app-primary); color: #fff; }
.flow-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.flow-name { font-size: .875rem; font-weight: 600; white-space: nowrap; }
.flow-what { font-size: .75rem; color: var(--muted-foreground); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.flow-arrow { color: var(--ui-border-strong); font-size: .875rem; flex: 0 0 auto; }
/* the look-up screens: same row, on the right, set apart by a rule */
.flow-side { display: flex; align-items: center; gap: .125rem; flex: 0 0 auto; margin-left: auto; padding-left: .75rem; border-left: 1px solid var(--border); }
.flow-side-label { font-size: .75rem; color: var(--muted-foreground); margin-right: .25rem; }
.flow-link { font-size: .8125rem; font-weight: 500; color: var(--muted-foreground); padding: .25rem .5rem; border-radius: var(--radius-md); text-decoration: none !important; white-space: nowrap; }
.flow-link:hover, .flow-link.active { background: var(--accent); color: var(--foreground); }
/* narrower screens: captions go first, then the look-up screens take their own row */
@media (max-width: 1399.98px) { .flow-what { display: none; } }
@media (max-width: 991.98px) {
  .flow-strip { flex-wrap: wrap; }
  .flow-side { margin-left: 0; padding: .5rem 0 0; border-left: 0; border-top: 1px solid var(--border); width: 100%; }
}

/* "Filters" button for list filter panels: phones only (app.js adds it) */
.filter-toggle { display: none; }

/* ---- Bottom navigation (phones only; markup in base.html) ------------ */
.mobile-nav { display: none; }

/* The line that says which date range is applied */
.date-range-note { color: var(--ui-text-2, #475467); background: var(--bs-primary-bg-subtle, #eef2ff);
                   border-radius: 8px; padding: .35rem .65rem; display: inline-block; }

/* Pipeline board: the line under a column heading (period and total value) */
.kanban-subhead { display: flex; justify-content: space-between; gap: .5rem; flex-wrap: wrap; font-size: .78rem;
                  color: var(--ui-text-2, #667085); padding: 0 .5rem .6rem; margin-top: -.5rem; }
.kanban-subhead strong { color: var(--ui-text, #101828); font-weight: 600; }
.kanban-column.drop-refused { outline: 2px dashed var(--bs-danger); outline-offset: -2px; }

/* The organisation's logo where the menu or the sign-in panel is off screen */
.brand-logo { display: block; width: auto; object-fit: contain; }
.brand-logo-icon { font-size: 1.5rem; line-height: 1; color: var(--bs-primary); }
.topbar-brand { display: none; align-items: center; flex: 0 0 auto; text-decoration: none; }
.topbar-brand .brand-logo { height: 28px; max-width: 104px; }
.auth-brand-mobile { display: none; }
@media (max-width: 991.98px) {
  .topbar-brand { display: inline-flex; }
  /* the page title gives way before the logo does */
  .app-topbar .topbar-title { min-width: 0; }
  .app-topbar .topbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 420px) {
  .topbar-brand .brand-logo { height: 24px; max-width: 80px; }
}

/* =====================================================================
   Phones and small tablets
   ===================================================================== */
@media (max-width: 767.98px) {
  html, body { overflow-x: hidden; }
  body { font-size: .9375rem; }
  .app-main { min-width: 0; width: 100%; }
  .app-content { padding: .75rem .75rem 5.25rem; }
  .app-footer { display: none; }

  /* top bar: title + the essentials */
  .app-topbar { padding: 0 .625rem; gap: .375rem !important; min-height: 3.25rem; position: sticky; top: 0; z-index: 1020; }
  .app-topbar .sidebar-collapse-btn, .app-topbar .kbd-hint, .app-topbar .topbar-search-text { display: none !important; }
  .app-topbar .topbar-title { min-width: 0; flex: 1 1 auto; }
  .app-topbar .topbar-title h1 { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-topbar .ms-auto { gap: .375rem !important; flex: 0 0 auto; }
  .app-topbar .topbar-search { width: 2.25rem; min-width: 0; padding: 0; justify-content: center; }
  .app-topbar .bu-switcher .btn { max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; }
  .app-topbar .btn, .app-topbar .topbar-search { min-height: 2.25rem; }
  .app-topbar .dropdown .badge { display: none; }
  .app-topbar a.btn-primary { display: none; }      /* the + lives in the bottom bar */

  /* comfortable touch targets; 16px inputs stop iOS zooming on focus */
  .btn, .btn-sm { min-height: 2.5rem; }
  .table .btn-sm, .input-group .btn, .view-switcher .btn { min-height: 2.25rem; }
  .form-control, .form-select, .form-control-sm, .form-select-sm { min-height: 2.75rem; font-size: 1rem; }
  .form-check-input { width: 1.25rem; height: 1.25rem; }
  .form-switch .form-check-input { width: 2.75rem; height: 1.5rem; }
  .dropdown-item { padding: .625rem .625rem; }

  /* page headers and button rows wrap instead of overflowing */
  .app-content > .d-flex, .card-header.d-flex { flex-wrap: wrap; gap: .5rem; }
  .app-content .d-flex.gap-2 { flex-wrap: wrap; }
  .card-body { padding: 1rem; }
  fieldset.form-section, .form-section { padding: 1rem !important; }
  .table-reflow td:first-child { flex-wrap: wrap; }
  .card-header { padding: .75rem 1rem; }
  .kpi-card { padding: .875rem; }
  .kpi-value { font-size: 1.25rem; }
  .nav-tabs, .nav-pills, .view-switcher { display: flex; width: 100%; }

  /* filter rows: one field per line, full-width action */
  form.row > [class*="col-"] { flex: 0 0 100%; max-width: 100%; }
  form.row > .col-6 { flex: 0 0 50%; max-width: 50%; }
  form .d-flex.justify-content-end { position: sticky; bottom: 4.25rem; z-index: 5; background: color-mix(in srgb, var(--ui-bg) 92%, transparent); backdrop-filter: blur(6px); padding: .625rem 0; margin-bottom: 0 !important; }
  form .d-flex.justify-content-end > .btn { flex: 1 1 0; }

  .flow-strip { padding: .5rem; }
  .flow-steps { flex-wrap: nowrap; overflow-x: auto; width: 100%; scrollbar-width: none; }
  .flow-what, .flow-arrow { display: none; }
  .flow-step { white-space: nowrap; padding: .375rem .5rem; }

  /* filter panels start closed behind the "Filters" button */
  .filter-toggle { display: inline-flex; }
  form.filter-collapsible { display: none; margin-top: .75rem; }
  form.filter-collapsible.is-open { display: flex; }

  /* tables: stacked rows where marked, sideways scroll elsewhere */
  .table-responsive { -webkit-overflow-scrolling: touch; }
  .table-reflow thead { display: none; }
  .table-reflow, .table-reflow tbody, .table-reflow tr, .table-reflow td { display: block; width: 100%; }
  .table-reflow tr { padding: .625rem .875rem; border-bottom: 1px solid var(--border); }
  .table-reflow tr:last-child { border-bottom: 0; }
  .table-reflow td { border: 0 !important; padding: .1875rem 0 !important; display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; text-align: right !important; white-space: normal !important; }
  .table-reflow td::before { content: attr(data-label); flex: 0 0 auto; color: var(--muted-foreground); font-size: .8125rem; font-weight: 500; text-align: left; }
  .table-reflow td:not([data-label])::before, .table-reflow td[data-label=""]::before { content: none; }
  .table-reflow td:not([data-label]) { justify-content: flex-end; flex-wrap: wrap; padding-top: .5rem !important; }
  .table-reflow td:first-child { font-weight: 600; font-size: .9375rem; }
  .table-reflow td[colspan] { display: block; text-align: center !important; }

  /* dialogs become bottom sheets */
  .modal-dialog { margin: 0; position: fixed; left: 0; right: 0; bottom: 0; max-width: none; }
  .modal.fade .modal-dialog { transform: translateY(100%); }
  .modal.show .modal-dialog { transform: none; }
  .modal-content { border-radius: var(--radius-xl) var(--radius-xl) 0 0; border-bottom: 0; max-height: 92vh; overflow-y: auto; }
  .modal-header { padding: 1.25rem 1rem .25rem; }
  .modal-body { padding: .75rem 1rem; }
  .modal-footer { padding: .5rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
  .modal-footer > .btn { flex: 1 1 0; }
  .dropdown-menu { max-width: calc(100vw - 1.5rem); }

  /* sign-in: the form, under the logo */
  .auth-split { display: block; }
  .auth-aside { display: none; }
  .auth-main { padding: 2rem 1.25rem; }
  .auth-brand-mobile { display: flex; flex-direction: column; align-items: center; gap: .5rem; margin-bottom: 1.75rem;
                       font-weight: 600; color: var(--ui-text-2, #475467); text-align: center; }
  .auth-brand-mobile .brand-logo { height: 52px; max-width: 220px; }
  .auth-brand-mobile .brand-logo-icon { font-size: 2.2rem; }
  .app-topbar .topbar-title h1 { font-size: .95rem; }

  /* bottom navigation */
  .mobile-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: color-mix(in srgb, var(--background) 92%, transparent); backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--border); padding: .25rem .25rem calc(.25rem + env(safe-area-inset-bottom));
  }
  .mobile-nav a, .mobile-nav button {
    flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .125rem;
    min-height: 3.25rem; border: 0; background: transparent; border-radius: var(--radius-md);
    color: var(--muted-foreground); font-size: .6875rem; font-weight: 500; text-decoration: none;
  }
  .mobile-nav .bi { font-size: 1.25rem; }
  .mobile-nav a.active { color: var(--foreground); }
  .mobile-nav a.active .bi { color: var(--app-primary); }
  .mobile-nav .mobile-nav-add span.plus {
    width: 2.75rem; height: 2.75rem; border-radius: 999px; display: grid; place-items: center;
    background: var(--app-primary); color: #fff; box-shadow: var(--shadow-md);
  }
  .mobile-nav .mobile-nav-add .bi { color: #fff; }
  .help-trigger { bottom: 4.75rem !important; }
}
