/*
 * Visual polish: alignment, visibility and proportion on every screen (SKILL.md §13, references/ui-layout.md "Visual quality").
 * Linked in layout.html after touch.css. Fluid sizes (rem / clamp), one spacing scale, aligned icon + label pairs,
 * labels that are never cut off, one clear primary action. Override per app in app.css, not by editing Bootstrap.
 */
:root {
  --app-space-1: .25rem; --app-space-2: .5rem; --app-space-3: .75rem; --app-space-4: 1rem; --app-space-5: 1.5rem; --app-space-6: 2rem;   /* the ONLY spacing scale */
  --app-fs-base: clamp(.95rem, .9rem + .25vw, 1.05rem);        /* body text grows a little with the screen, never below 15 px */
  --app-fs-h1: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem);
  --app-fs-h2: clamp(1.1rem, 1rem + .6vw, 1.4rem);
  --app-fs-small: clamp(.8rem, .78rem + .12vw, .875rem);       /* never below 12.8 px */
  --app-page-max: 90rem;                                        /* content never stretches across a 4K screen */
}
html { font-size: 100%; }
body { font-size: var(--app-fs-base); line-height: 1.5; }
h1, .h1 { font-size: var(--app-fs-h1); } h2, .h2 { font-size: var(--app-fs-h2); } .small, small { font-size: var(--app-fs-small); }
main.app-main { max-width: var(--app-page-max); margin-inline: auto; padding: var(--app-space-4) clamp(var(--app-space-3), 2vw, var(--app-space-6)); }

/* Icon + text pairs (menu items, buttons, headings, tiles): always one centred row with the same gap */
.btn { display: inline-flex; align-items: center; gap: var(--app-space-2); }
.app-nav-main, .app-nav-sub, .dropdown-item, .nav-link, h1, h2, h3, h4, h5, h6, .app-dash-tile-label { display: flex; align-items: center; gap: var(--app-space-2); }
.bi { line-height: 1; flex: none; vertical-align: -.125em; }
.app-nav-main > span, .app-nav-sub > span { flex: 1 1 auto; min-width: 0; }                  /* label takes the room, badge/chevron stay at the right edge */
.app-nav-main .app-nav-chevron { margin-left: auto; }

/* Labels and CTAs are never cut off or broken mid-word: buttons keep one line on desktop, may wrap to two on narrow screens */
.btn { white-space: nowrap; min-width: 5.5rem; justify-content: center; }
@media (max-width: 575.98px) { .btn { white-space: normal; text-align: center; } }
.form-label, label { display: block; margin-bottom: var(--app-space-1); font-weight: 500; }
.form-check-label { display: inline; margin: 0; font-weight: 400; }
.form-text { font-size: var(--app-fs-small); }
.table th { white-space: nowrap; vertical-align: middle; } .table td { vertical-align: middle; }
.table td.num, .table th.num, td[data-num], th[data-num] { text-align: right; font-variant-numeric: tabular-nums; }    /* numbers and money right-aligned, digits equal width */

/* Forms: labels above fields, one column on phones, two from md, same gaps everywhere */
.app-form-grid { display: grid; gap: var(--app-space-3) var(--app-space-4); grid-template-columns: 1fr; }
@media (min-width: 768px) { .app-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .app-form-grid .span-2 { grid-column: 1 / -1; } }

/* One primary action per view: primary = filled, everything else outline; actions grouped on one row, primary last on the right */
.app-actions { justify-content: flex-end; }
.app-actions .btn-primary { order: 2; }

/* Cards and tiles: equal inner padding, titles aligned to the same baseline */
.card-body { padding: var(--app-space-4); } .card-header { padding: var(--app-space-3) var(--app-space-4); }
.app-dash-tile-value { font-size: clamp(1.25rem, 1rem + 1.1vw, 1.75rem); line-height: 1.15; }
@media (min-width: 1600px) { :root { --app-fs-base: 1.0625rem; } }                              /* large screens: slightly larger text, same layout */
