/* ==========================================================================
   Responsive + control-sizing normalization pass (2026-08-29)
   ==========================================================================
   Loaded LAST so it wins the cascade over the layered v28/v29/royal_identity
   stylesheets without editing them directly. Root-cause, shared-selector
   fixes only -- no page-specific overrides. Safe to remove by deleting the
   single <link> in base.html; nothing else depends on this file.

   Issues addressed, each backed by a conflict found in the existing CSS:
   1. No breakpoint existed between 980px and 1250px, so at 1024px (a
      required test width) the sidebar stayed fixed-width and desktop grids
      stayed active, squeezing/overflowing toolbars on tablet landscape.
   2. input/select height was declared twice with different values in the
      same file (43px then 40px later in v29_executive.css) -- one value
      wins unpredictably depending on source order. Normalized to one value.
   3. .control-bar-icon was redeclared three times across three files with
      three different sizes (34px / 38px / 35px), and its icon glyph inside
      was not sized relative to the container, producing the reported
      "icon too small inside an oversized square" look.
   ========================================================================== */

/* ---- 1. Control sizing: one authoritative value per control, touch-safe
   but compact (not the "everything tiny" trap, not the oversized-square
   trap either). ---- */
input, select, .control { height: 42px; }
textarea { height: auto; }

.btn { min-height: 40px; }
.btn-sm { min-height: 34px; }
.btn-icon, .icon-btn { width: 40px; height: 40px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-icon .ui-icon, .icon-btn .ui-icon { width: 20px; height: 20px; }

/* Icon-in-a-tinted-square controls (filter/search/status bars): one
   consistent container size, with the glyph filling a sane share of it
   instead of floating small inside a comparatively huge box. */
.control-bar-icon { width: 36px; height: 36px; display: grid; place-items: center; }
.control-bar-icon .ui-icon { width: 19px; height: 19px; }

/* Checkboxes and action squares: legible and tappable, not oversized. */
.checkbox input,
.check-row input,
input[type="checkbox"] { width: 18px; height: 18px; }
.lead-check { width: 18px; height: 18px; }

/* Icon + text vertical alignment: every button/link/nav pairing centers
   on the same cross-axis regardless of which legacy stylesheet styled it. */
.btn, .nav-link, .quick-action, .toolbar-actions .btn,
.icon-btn, .btn-icon, .row-actions a, .row-actions button {
  display: inline-flex;
  align-items: center;
}

/* ---- 2. Tablet landscape (the missing 1024px band). Mirrors the sidebar
   off-canvas behaviour that already exists at <=980px, extended to cover
   1024px so the required 768 / 820 / 1024 widths behave consistently
   instead of 1024px alone staying in the fixed-sidebar desktop layout. ---- */
@media (max-width: 1024px) {
  .main-area { margin-inline-start: 0; }
  .sidebar { transform: translateX(-110%); transition: .22s ease; }
  [dir="rtl"] .sidebar { transform: translateX(110%); }
  .app-shell.sidebar-open .sidebar { transform: translateX(0); }
  .sidebar-close { display: grid !important; }
  .mobile-menu { display: grid; }

  .filters, .filters.compact { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-2, .detail-layout { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }

  .section-toolbar { align-items: stretch; }
  .toolbar-actions, .inline-actions { width: 100%; }

  /* A real data table may still need horizontal scroll; its own toolbar
     and action buttons above it must not be the thing forcing that scroll. */
  .table-card, .table-head, .section-toolbar { max-width: 100%; overflow: visible; }
  .table-wrap { overflow-x: auto; }
}

/* ---- 3. Tablet portrait (768 / 820) already benefits from the <=980px
   rules in app.css for the sidebar; these add the control-density fixes
   that were previously only defined at <=720px, so 768-820px does not
   fall through to the denser desktop control sizing. ---- */
@media (max-width: 860px) {
  .filters, .filters.compact, .form-grid, .form-grid.cols-3 { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .pipeline { grid-template-columns: repeat(2, 1fr); }
  .lead-meta-grid { grid-template-columns: repeat(2, 1fr); }
  .modal-card { width: min(560px, 96vw); }
}
