/* ============================================================================
   Clearspace — Product UI component styles
   Semantic component classes for the Flask + Jinja2 + Tailwind stack.

   Load order on every page:
     1. colors_and_type.css   (tokens: --cs-*, --btn-*, type ramp, .cs-btn, .cs-required)
     2. clearspace-components.css   (this file — sidebar, shell, tables, toolbar, …)
     3. Tailwind (CDN) for page-level layout utilities

   These classes encode the prescriptive contracts in README.md
   (sidebar structure, pinned button heights, required-field marker, sortable
   tables, multi-select filters). Tailwind is for layout/spacing utilities in
   page templates — the components themselves stay as these semantic classes so
   the contract lives in one place.
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* ── App shell ────────────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; overflow: hidden; }
.app button { font-family: inherit; cursor: pointer; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden; }
.content { padding: 36px 40px; }
.stack { display: flex; flex-direction: column; gap: 32px; }
.stack-sm { display: flex; flex-direction: column; gap: 24px; }

/* ── Sidebar — prescribed, non-negotiable. (README § Sidebar navigation) ──
   HARD RULE: the sidebar NEVER scrolls horizontally. `.sidebar` stays
   `overflow: visible` — the collapse-button nub sits at right:-14px and a
   scroll container would clip it AND spawn an h-scrollbar. The vertical scroll
   for long nav lives on the inner `.sidebar-nav` (flex:1; min-height:0). */
.sidebar { width: 260px; background: var(--cs-dark-blue); color: #fff; flex-shrink: 0; display: flex; flex-direction: column; transition: width 0.2s ease; position: sticky; top: 0; height: 100vh; max-height: 100vh; overflow: visible; z-index: 5; }
.sidebar.collapsed { width: 72px; }
.sidebar-brand { padding: 24px 20px 18px; height: 88px; box-sizing: border-box; position: relative; display: flex; flex-direction: column; justify-content: center; }
.sidebar.collapsed .sidebar-brand { padding: 24px 10px 18px; align-items: center; justify-content: center; }

/* ── Brand logo safeguard — NON-NEGOTIABLE, defense in depth ────────────────
   The Clearspace wordmark is ~6:1. A logo distorts whenever a pinned height
   meets a width that is smaller than its natural width — a narrow brand panel,
   a `max-width:100%` clamp, flex `align-items:stretch`, or an explicit
   width+height a consumer sets by hand. `object-fit:contain` makes the pixels
   ALWAYS preserve aspect ratio inside whatever box they are given: it can
   letterbox, but it can NEVER stretch. This rule applies it to every brand
   logo — the named classes AND any <img alt="Clearspace"> a consuming app
   drops in — so a stretched logo is impossible no matter how it's sized.
   object-position:left keeps any letterboxing flush-left to match the
   left-aligned brand layout. */
.login-hero-logo,
.sidebar-brand img,
img[alt="Clearspace"] { object-fit: contain; object-position: left center; }

/* Logo sizing — NON-NEGOTIABLE. The brand zone is a flex column (align-items:
   stretch by default) which would stretch a child <img> to the full 220px
   cross-axis width and distort the wordmark. Opt the logo OUT with width:auto +
   align-self:flex-start + flex-shrink:0, and object-fit:contain (above) as the
   hard backstop. Collapsed mark centers instead. */
.sidebar-brand img.wordmark,
.sidebar-brand img[alt="Clearspace"]:not(.mark) { height: 22px; width: auto; max-width: 100%; align-self: flex-start; flex-shrink: 0; margin-bottom: 8px; }
.sidebar-brand img.mark { width: 22px; height: 22px; object-position: center; align-self: center; flex-shrink: 0; }

/* Exactly ONE brand mark per state — wordmark expanded, underscore mark
   collapsed. `.collapsed` selectors out-specify the base toggles. */
.sidebar-brand .brand-link { display: block; }
.sidebar.collapsed .sidebar-brand .brand-link { display: flex; justify-content: center; }
.sidebar-brand .wordmark { display: block; }
.sidebar-brand .mark { display: none; }
.sidebar.collapsed .sidebar-brand .wordmark { display: none; }
.sidebar.collapsed .sidebar-brand img.mark,
.sidebar.collapsed .sidebar-brand .mark { display: block; }
.sidebar-brand .brand-sysname { font-size: 12px; color: #fff; letter-spacing: 0.04em; text-transform: uppercase; font-weight: 500; }
.sidebar.collapsed .sidebar-brand .brand-sysname { display: none; }

.sidebar-collapse-btn { position: absolute; top: 32px; right: -14px; width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 9999px; color: var(--cs-n-500); background: #fff; border: 1px solid var(--cs-n-200); cursor: pointer; z-index: 10; box-shadow: 0 1px 4px rgba(22, 25, 26, 0.06); padding: 0; transition: all 0.15s ease; }
.sidebar-collapse-btn:hover { color: var(--cs-charcoal); border-color: var(--cs-n-300); }
.sidebar-collapse-btn svg { width: 14px; height: 14px; stroke-width: 2; transition: transform 0.2s ease; }
.sidebar.collapsed .sidebar-collapse-btn svg { transform: rotate(180deg); }

.sidebar-nav { flex: 1; padding: 0 10px; display: flex; flex-direction: column; gap: 2px; min-height: 0; overflow-y: auto; overflow-x: hidden; }
.nav-link { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 8px; color: rgba(255,255,255,0.9); font-size: 16px; letter-spacing: -0.01em; transition: all 0.15s ease; cursor: pointer; white-space: nowrap; overflow: hidden; background: none; border: 0; width: 100%; text-align: left; }
.sidebar.collapsed .nav-link { justify-content: center; gap: 0; padding: 11px 0; }
.sidebar.collapsed .nav-divider { margin: 12px 14px; }
.sidebar.collapsed .sidebar-foot .user-row { justify-content: center; gap: 0; padding: 11px 0; }
.nav-link:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-link.active { color: var(--cs-light-blue); background: rgba(59,171,255,0.12); font-weight: 500; }
.nav-link svg { width: 22px; height: 22px; flex-shrink: 0; stroke-width: 1.5; }
.nav-label { min-width: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .nav-label { display: none; }
.nav-divider { height: 1px; background: rgba(255,255,255,0.08); margin: 12px 12px; }
.sidebar-foot { padding: 0 10px 14px; margin: 0; display: flex; flex-direction: column; gap: 2px; }
.sidebar-foot .user-row { display: flex; align-items: center; gap: 14px; padding: 11px 14px; border-radius: 8px; color: rgba(255,255,255,0.9); }
.sidebar-foot .user-icon { width: 22px; height: 22px; flex-shrink: 0; stroke-width: 1.5; }
.sidebar-foot .name { color: #fff; font-size: 16px; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .sidebar-foot .name { display: none; }

/* ── Build SHA — the live deployed commit, set as ambient metadata above the
   foot divider. Muted mono, near-flush with the nav padding so it reads quiet;
   brightens a touch on hover for discoverability without ever competing with
   the nav. Aligns to the same 14px gutter as the nav rows. */
.sidebar-commit { display: flex; align-items: center; gap: 8px; padding: 4px 14px 8px; font-family: var(--font-mono); font-size: 11px; line-height: 1; letter-spacing: 0.02em; color: rgba(255,255,255,0.34); text-decoration: none; transition: color 0.15s ease; white-space: nowrap; overflow: hidden; }
.sidebar-commit:hover { color: rgba(255,255,255,0.6); }
.sidebar-commit .commit-dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,0.28); flex-shrink: 0; }
.sidebar-commit:hover .commit-dot { background: var(--cs-light-green); }
.sidebar-commit .commit-sha { overflow: hidden; text-overflow: ellipsis; }
.sidebar.collapsed .sidebar-commit { justify-content: center; padding: 4px 0 8px; gap: 0; }
.sidebar.collapsed .sidebar-commit .commit-sha { display: none; }

/* ── Account — foot user row shows identity (icon + name) with a direct Log out
   icon button on the right. When the rail collapses the name hides and the
   Log out button centers, so sign-out stays one click away. */
.logout-btn { margin-left: auto; flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 8px; color: rgba(255,255,255,0.5); transition: color 0.15s ease, background 0.15s ease; }
.logout-btn svg { width: 18px; height: 18px; stroke-width: 1.6; }
.logout-btn:hover { color: var(--cs-light-red); background: rgba(240,90,90,0.12); }
.logout-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.sidebar.collapsed .sidebar-foot .user-row { position: relative; }
.sidebar.collapsed .user-icon { display: none; }
.sidebar.collapsed .logout-btn { margin: 0; }

/* ── Page header ──────────────────────────────────────────────────────── */
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.page-header h1 { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; color: var(--cs-charcoal); margin: 0; }
.page-header p { font-size: 15px; color: #6B7280; margin: 4px 0 0; }

/* ── Cards ────────────────────────────────────────────────────────────── */
.card { background: #fff; border: 1px solid #E5E7EB; border-radius: 14px; padding: 28px; }
/* Table/toolbar card — MUST NOT clip its content. This card wraps a filter
   toolbar ABOVE a table; an `overflow:hidden` here (previously used only to
   tuck the table's square corners into the 14px radius) ALSO guillotines any
   filter dropdown/popover that opens from the toolbar — the exact bug where
   the Status menu got cut off. Keep overflow VISIBLE so popovers escape, and
   round the actual corner cells/children instead so the table still tucks into
   the card. RULE: any container hosting a .filter-multi (or any popover) must
   never use overflow:hidden. */
.card.p-0 { padding: 0; overflow: visible; }
.card.p-0 > :first-child { border-top-left-radius: 14px; border-top-right-radius: 14px; }
.card.p-0 > :last-child { border-bottom-left-radius: 14px; border-bottom-right-radius: 14px; }
.card.p-0 .table-main thead tr:first-child th:first-child { border-top-left-radius: 14px; }
.card.p-0 .table-main thead tr:first-child th:last-child { border-top-right-radius: 14px; }
.card.p-0 .table-main tbody tr:last-child td:first-child { border-bottom-left-radius: 14px; }
.card.p-0 .table-main tbody tr:last-child td:last-child { border-bottom-right-radius: 14px; }
.card-title { font-size: 12px; font-weight: 600; color: #9CA3AF; text-transform: uppercase; letter-spacing: 0.07em; margin: 0 0 16px; }

/* ── Stat cards ───────────────────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.stat-card { background: #fff; border: 1px solid #E5E7EB; border-radius: 14px; padding: 24px 28px; }
.stat-label { font-size: 11px; font-weight: 600; color: #9CA3AF; text-transform: uppercase; letter-spacing: 0.07em; margin: 0; }
.stat-label .muted { color: #D1D5DB; font-weight: 400; }
.stat-value { font-size: 32px; font-weight: 600; line-height: 1.15; margin-top: 6px; letter-spacing: -0.03em; color: var(--cs-charcoal); }
.stat-value.blue { color: var(--cs-light-blue); }
.stat-value.green-dark { color: var(--cs-dark-green); }
.stat-value.amber { color: #F59E0B; }

/* ── Inputs ───────────────────────────────────────────────────────────── */
.input-field { display: block; padding: 9px 14px; font-size: 15px; line-height: 1.5; border: 1px solid #D1D5DB; border-radius: 8px; background: #fff; color: var(--cs-charcoal); transition: all 0.15s ease; font-family: inherit; width: 100%; }
.input-field:focus { outline: none; border-color: var(--cs-light-blue); box-shadow: 0 0 0 3px rgba(59,171,255,0.1); }
.input-field::placeholder { color: #9CA3AF; }
select.input-field { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; cursor: pointer; }
.field-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; color: #334155; }

/* ── Tables ───────────────────────────────────────────────────────────── */
.table-main { border-collapse: collapse; width: 100%; }
.table-main thead { background: #F9FAFB; border-bottom: 1px solid #E5E7EB; }
.table-main th { padding: 14px 20px; font-size: 11px; font-weight: 600; color: #9CA3AF; text-transform: uppercase; letter-spacing: 0.07em; text-align: left; }
.table-main th.right { text-align: right; }

/* Sortable headers — EVERY column header is sortable. (Hard rule.) */
.table-main th .th-sort { display: inline-flex; align-items: center; gap: 6px; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; user-select: none; }
.table-main th.right .th-sort { justify-content: flex-end; }
.table-main th .th-sort:hover { color: var(--cs-n-600); }
.table-main th .th-sort:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 4px; }
.table-main th .sort-ico { width: 8px; height: 11px; flex-shrink: 0; }
.table-main th .sort-ico path { fill: currentColor; opacity: 0.28; transition: opacity 0.12s ease; }
.table-main th .th-sort.is-asc { color: var(--cs-charcoal); }
.table-main th .th-sort.is-desc { color: var(--cs-charcoal); }
.table-main th .th-sort.is-asc .up { opacity: 1; }
.table-main th .th-sort.is-desc .down { opacity: 1; }
.table-main td { padding: 16px 20px; font-size: 15px; border-bottom: 1px solid #F3F4F6; color: var(--cs-charcoal); }
.table-main tbody tr:last-child td { border-bottom: none; }
.table-main tbody tr.clickable { cursor: pointer; transition: background 0.15s ease; }
.table-main tbody tr.clickable:hover td { background: #FAFAFA; }
.table-main td.muted { color: #6B7280; font-size: 14px; }
.table-main td.dim { color: #9CA3AF; font-size: 12px; }
.table-main td.right { text-align: right; font-variant-numeric: tabular-nums; }
.table-main td.num { font-variant-numeric: tabular-nums; }
.link-blue { color: var(--cs-light-blue); }
.link-blue:hover { text-decoration: underline; }
.table-main tr.subtotal td { background: #F9FAFB; font-size: 12px; font-weight: 600; color: #6B7280; }
.table-main tr.group-row td { background: #F9FAFB; font-size: 11px; font-weight: 600; color: #6B7280; text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 20px; }
.table-main tr.is-hidden { display: none; }

/* ── Stage badges ─────────────────────────────────────────────────────── */
.stage-badge { display: inline-block; padding: 3px 10px; font-size: 12px; font-weight: 500; border-radius: 9999px; white-space: nowrap; letter-spacing: -0.005em; }
.stage-identified, .stage-qualified, .stage-feasibility { background: var(--cs-light-blue); color: #fff; }
.stage-on-hold { background: #F3F4F6; color: #9CA3AF; }
.stage-closed-won { background: rgba(179,193,0,0.15); color: var(--cs-dark-green); }
.stage-closed-lost { background: rgba(240,90,90,0.1); color: #C0392B; }

/* ── Table toolbar — search (left) + multi-select filters (right). (Hard rule.) ── */
.table-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.toolbar-search { position: relative; flex: 1 1 240px; min-width: 0; max-width: 360px; }
.toolbar-search .search-ico { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: #9CA3AF; pointer-events: none; stroke-width: 2; }
.toolbar-search .input-field { width: 100%; padding-left: 36px; height: var(--btn-h-md); box-sizing: border-box; padding-top: 0; padding-bottom: 0; }
.toolbar-search .input-field[type="search"]::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.toolbar-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* multi-select dropdown */
.filter-multi { position: relative; }
.filter-multi-btn { display: inline-flex; align-items: center; gap: 8px; height: var(--btn-h-md); min-height: var(--btn-h-md); box-sizing: border-box; padding: 0 12px; border-radius: 8px; border: 1px solid var(--cs-n-200); background: #fff; color: var(--cs-charcoal); font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.15s ease; }
.filter-multi-btn:hover { border-color: var(--cs-n-300); background: var(--cs-n-50); }
.filter-multi-btn.has-value { border-color: var(--cs-light-blue); color: var(--cs-charcoal); }
.filter-multi-btn:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.filter-multi-btn .filter-count[hidden] { display: none; }
.filter-multi-btn .filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--cs-light-blue); color: #fff; font-size: 11px; font-weight: 600; }
.filter-multi-btn .filter-caret { width: 14px; height: 14px; color: #9CA3AF; }
.filter-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; min-width: 200px; max-height: 320px; overflow-y: auto; background: #fff; border: 1px solid var(--cs-n-200); border-radius: 8px; box-shadow: 0 8px 28px rgba(22,25,26,0.12); padding: 6px; }
.filter-menu[hidden] { display: none; }
.filter-menu-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 8px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #9CA3AF; }
.filter-clear { border: 0; background: none; color: var(--cs-light-blue); font-size: 12px; font-weight: 500; cursor: pointer; padding: 0; text-transform: none; letter-spacing: 0; }
.filter-clear:hover { text-decoration: underline; }
.filter-opt { display: flex; align-items: center; gap: 10px; padding: 8px 8px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--cs-charcoal); }
.filter-opt:hover { background: var(--cs-n-50); }
.filter-opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.filter-check { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex-shrink: 0; border: 1.5px solid var(--cs-n-300); border-radius: 5px; background: #fff; transition: all 0.12s ease; }
.filter-check svg { width: 12px; height: 12px; color: #fff; opacity: 0; }
.filter-opt input:checked + .filter-check { background: var(--cs-light-blue); border-color: var(--cs-light-blue); }
.filter-opt input:checked + .filter-check svg { opacity: 1; }
.filter-opt input:focus-visible + .filter-check { box-shadow: var(--focus-ring); }

/* Column selector — a .filter-multi specialised to toggle table columns.
   Shares the button + popover; adds a lead icon, a right-anchored menu, and a
   locked (always-on) option state. Hidden columns get .col-hidden on the
   matching th + every body td at that index. */
.filter-multi-btn .filter-lead { width: 15px; height: 15px; color: var(--cs-n-500); flex-shrink: 0; }
.filter-menu--right { left: auto; right: 0; }
.filter-opt.is-locked { cursor: default; color: var(--cs-n-400); }
.filter-opt.is-locked:hover { background: none; }
.table-main th.col-hidden, .table-main td.col-hidden { display: none; }

/* ── Flash ────────────────────────────────────────────────────────────── */
.flash { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: 8px; font-size: 15px; }
.flash.success { background: #F0FDF4; color: var(--cs-dark-green); border: 1px solid #BBF7D0; }
.flash .close { opacity: 0.6; font-size: 18px; line-height: 1; background: none; border: none; cursor: pointer; }
.flash .close:hover { opacity: 1; }

/* ── Login (split-screen Microsoft-365 SSO) ──────────────────────────────── */
.login-split { display: grid; grid-template-columns: 1fr 1fr; min-height: 100vh; }

/* Left — dark brand panel */
.login-brand { position: relative; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 56px 60px; background: var(--cs-dark-blue); color: #fff; overflow: hidden; }
/* width:auto in a flex column (align-items:stretch) stretches the wordmark to
   the full panel width — opt out with align-self:flex-start + flex-shrink:0
   (same fix as .sidebar-brand img.wordmark above). */
/* Fixed height + width:auto keeps the natural ratio; max-width:100% prevents
   overflow on a narrow panel; object-fit:contain (brand-logo safeguard above)
   guarantees the clamp letterboxes instead of stretching. */
.login-hero-logo { height: 64px; width: auto; max-width: 100%; align-self: flex-start; flex-shrink: 0; display: block; }
.login-lede { max-width: 420px; margin: 0; font-size: 18px; line-height: 1.6; color: rgba(255,255,255,0.62); }
.login-foot { position: absolute; left: 60px; right: 60px; bottom: 40px; display: flex; gap: 26px; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(255,255,255,0.34); }

/* Right — sign-in panel */
.login-signin { display: flex; align-items: center; justify-content: center; padding: 48px; background: #fff; }
.login-card { width: 100%; max-width: 400px; border: 1px solid var(--cs-n-200); border-radius: var(--radius-xl); padding: 36px; box-shadow: var(--shadow-card); }
.login-card-title { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; color: var(--cs-charcoal); }
.login-card-sub { font-size: 14px; line-height: 1.5; color: var(--cs-n-500); margin: 0 0 26px; }
.login-btn-ms { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; height: var(--btn-h-lg); padding: 0 16px; font-family: inherit; font-size: 15px; font-weight: 500; color: #1E293B; background: #fff; border: 1px solid var(--cs-n-300); border-radius: var(--radius-md); cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.login-btn-ms:hover { background: var(--cs-n-50); border-color: var(--cs-n-400); }
.login-note { margin: 22px 0 0; font-size: 13px; line-height: 1.5; color: var(--cs-n-400); }

/* Standalone page (no app shell) — collapse to one column on phones.
   767.98px matches --bp-mobile-max. */
@media (max-width: 767.98px) {
  .login-split { grid-template-columns: 1fr; min-height: 100vh; }
  .login-brand { padding: 40px 28px; gap: 16px; min-height: 38vh; justify-content: flex-end; }
  .login-hero-logo { height: 44px; }
  .login-lede { font-size: 16px; }
  .login-foot { display: none; }
  .login-signin { padding: 28px 24px; align-items: flex-start; }
}

/* ── Misc utilities ───────────────────────────────────────────────────── */
.flex-row { display: flex; align-items: center; gap: 8px; }
.space-between { justify-content: space-between; }
.muted { color: #6B7280; }
.dim { color: #9CA3AF; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }
.field-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px 32px; }
.field-grid.single { grid-template-columns: 1fr; }

/* ── Modal / dialog — prescribed. (README § Modals) ───────────────────────
   HARD RULES:
   · The overlay sits ABOVE every chrome layer — including the mobile bottom
     tab bar (z 60) and drawer scrim (z 45). Modal z-index is 200; never lower.
   · Page scroll is locked while open (JS adds .cs-modal-lock to <html>); the
     ONLY thing that scrolls is `.modal-body` (overflow-y:auto). overscroll-
     behavior:contain on both overlay and body stops scroll chaining to the
     page behind. The dialog itself never scrolls — head/foot stay pinned. */
.modal-overlay { position: fixed; inset: 0; z-index: 200; display: none; align-items: center; justify-content: center; padding: 24px; background: rgba(22,25,26,0.45); overflow-y: auto; overscroll-behavior: contain; }
.modal-overlay.is-open { display: flex; }
.modal { background: #fff; border-radius: var(--radius-xl); box-shadow: var(--shadow-modal); width: 100%; max-width: 480px; max-height: calc(100vh - 48px); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { flex-shrink: 0; padding: 24px 24px 16px; display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; color: var(--cs-charcoal); }
.modal-sub { margin: 4px 0 0; font-size: 14px; color: var(--cs-n-500); }
.modal-close { flex-shrink: 0; width: 32px; height: 32px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--cs-n-500); border-radius: var(--radius-md); cursor: pointer; transition: background 0.15s ease, color 0.15s ease; }
.modal-close:hover { background: var(--cs-n-100); color: var(--cs-charcoal); }
.modal-close svg { width: 20px; height: 20px; stroke-width: 2; }
.modal-body { flex: 1 1 auto; min-height: 0; padding: 0 24px; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.modal-foot { flex-shrink: 0; padding: 16px 24px 24px; display: flex; align-items: center; justify-content: flex-end; gap: 12px; }
html.cs-modal-lock, html.cs-modal-lock body { overflow: hidden; }

/* ── Avatar ───────────────────────────────────────────────────────────
   Initials chip with a small set of brand-tinted backgrounds. Used by the
   comments thread and anywhere a person needs a compact identity mark. */
.cs-avatar { width: 32px; height: 32px; border-radius: 9999px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 500; line-height: 1; letter-spacing: 0; user-select: none; overflow: hidden; }
.cs-avatar img { width: 100%; height: 100%; object-fit: cover; }
.cs-avatar--sm { width: 28px; height: 28px; font-size: 11px; }
.cs-avatar--blue  { background: var(--cs-blue-100);  color: var(--cs-blue-700); }
.cs-avatar--green { background: var(--cs-green-100); color: var(--cs-green-800); }
.cs-avatar--red   { background: var(--cs-red-100);   color: var(--cs-red-700); }
.cs-avatar--slate { background: var(--cs-n-200);     color: var(--cs-n-700); }

/* ── Comments / activity thread ───────────────────────────────────────
   Anchored to a record (opportunity, account, …). A flat list of comments.
   Row actions reveal on hover. The composer reuses .cs-btn--primary for the
   submit. */
.cs-comments { display: flex; flex-direction: column; }
.cs-comments-head { display: flex; align-items: center; gap: 8px; margin-bottom: 20px; }
.cs-comments-head h3 { font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--cs-n-500); margin: 0; }
.cs-comments-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 18px; padding: 0 6px; border-radius: 9999px; background: var(--cs-n-100); color: var(--cs-n-500); font-size: 12px; font-weight: 600; }

.cs-comment-list { display: flex; flex-direction: column; gap: 22px; }
.cs-comment { display: flex; gap: 12px; }
.cs-comment-main { flex: 1; min-width: 0; }
.cs-comment-head { display: flex; align-items: center; gap: 8px; min-height: 24px; }
.cs-comment-author { font-size: 14px; font-weight: 500; color: var(--cs-charcoal); letter-spacing: -0.01em; white-space: nowrap; }
.cs-comment-meta { font-size: 13px; color: var(--cs-n-400); white-space: nowrap; }
.cs-comment-meta .dot { margin: 0 4px; }
.cs-comment-acts { margin-left: auto; display: flex; align-items: center; gap: 2px; opacity: 0; transition: opacity 0.12s ease; }
.cs-comment:hover .cs-comment-acts, .cs-comment:focus-within .cs-comment-acts { opacity: 1; }
.cs-comment-act { display: inline-flex; align-items: center; gap: 5px; height: 26px; padding: 0 8px; border: 0; background: none; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--cs-n-500); cursor: pointer; font-family: inherit; transition: background 0.12s ease, color 0.12s ease; }
.cs-comment-act:hover { background: var(--cs-n-100); color: var(--cs-charcoal); }
.cs-comment-act svg { width: 15px; height: 15px; stroke-width: 1.8; }
.cs-comment-act.icon { width: 26px; padding: 0; justify-content: center; }
.cs-comment-body { font-size: 15px; line-height: 1.55; color: var(--cs-n-700); margin-top: 2px; text-wrap: pretty; }
.cs-comment-body p { margin: 0 0 8px; }
.cs-comment-body p:last-child { margin-bottom: 0; }
.cs-mention { color: var(--cs-blue-700); font-weight: 500; }

.cs-composer { display: flex; gap: 12px; margin-top: 24px; }
.cs-composer-box { flex: 1; min-width: 0; border: 1px solid var(--cs-n-300); border-radius: 12px; background: #fff; overflow: hidden; transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.cs-composer-box:focus-within { border-color: var(--cs-light-blue); box-shadow: var(--focus-ring); }
.cs-composer-input { display: block; width: 100%; border: 0; outline: none; resize: none; background: transparent; font-family: inherit; font-size: 15px; line-height: 1.5; color: var(--cs-charcoal); padding: 12px 14px; }
.cs-composer-input::placeholder { color: var(--cs-n-400); }
.cs-composer-foot { display: flex; align-items: center; gap: 4px; padding: 6px 8px 8px; }
.cs-composer-tool { width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: none; border-radius: 7px; color: var(--cs-n-500); cursor: pointer; transition: background 0.12s ease, color 0.12s ease; }
.cs-composer-tool:hover { background: var(--cs-n-100); color: var(--cs-charcoal); }
.cs-composer-tool svg { width: 18px; height: 18px; stroke-width: 1.8; }
.cs-composer-send { margin-left: auto; }

/* ── Command palette (action / search bar) — global overlay. (README § Command palette) ──
   ONE reusable overlay, opened app-wide by ⌘K / Ctrl-K or any [data-cs-command-open]
   affordance. Combines record search + runnable commands, filters as you type, scope
   chips, full keyboard nav, footer hints. Sits ABOVE modals (z 210). Markup: the
   command_bar() macro in components/ui.html; behaviour: initCommandBar() in clearspace-ui.js. */
.cmdbar-overlay { position: fixed; inset: 0; z-index: 210; display: none; align-items: flex-start; justify-content: center; padding: 12vh 16px 16px; background: rgba(22,25,26,0.45); overscroll-behavior: contain; }
.cmdbar-overlay.is-open { display: flex; }
.cmdbar { width: 100%; max-width: 640px; max-height: min(560px, 76vh); background: #fff; border: 1px solid var(--cs-n-200); border-radius: var(--radius-xl); box-shadow: var(--shadow-modal); display: flex; flex-direction: column; overflow: hidden; }

/* Search row — large input, no border; the search icon leads. */
.cmdbar-search { flex-shrink: 0; display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--cs-n-100); }
.cmdbar-search-ico { width: 20px; height: 20px; color: var(--cs-n-400); flex-shrink: 0; stroke-width: 2; }
.cmdbar-input { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font-family: inherit; font-size: 18px; font-weight: 300; line-height: 1.3; letter-spacing: -0.01em; color: var(--cs-charcoal); padding: 0; }
.cmdbar-input::placeholder { color: var(--cs-n-400); }
.cmdbar-input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

/* Scope / refinement chips — toggleable. "Title only" narrows live matching to titles;
   the menu chips (Created by / In) are faceted-filter affordances apps wire to their data. */
.cmdbar-scopes { flex-shrink: 0; display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--cs-n-100); flex-wrap: wrap; }
.cmdbar-chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; box-sizing: border-box; padding: 0 10px; border: 1px solid var(--cs-n-200); border-radius: var(--radius-md); background: #fff; color: var(--cs-n-600); font-family: inherit; font-size: 13px; font-weight: 400; letter-spacing: -0.005em; white-space: nowrap; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.cmdbar-chip:hover { background: var(--cs-n-50); border-color: var(--cs-n-300); color: var(--cs-charcoal); }
.cmdbar-chip:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cmdbar-chip.is-active { background: var(--cs-blue-50); border-color: var(--cs-light-blue); color: var(--cs-charcoal); }
.cmdbar-chip-ico { width: 14px; height: 14px; color: var(--cs-n-500); flex-shrink: 0; }
.cmdbar-chip.is-active .cmdbar-chip-ico { color: var(--cs-blue-700); }
.cmdbar-chip-caret { width: 12px; height: 12px; color: var(--cs-n-400); flex-shrink: 0; }

/* Results — grouped, scrollable. position:relative anchors keyboard scroll math. */
.cmdbar-results { position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 6px; }
.cmdbar-group.is-hidden { display: none; }
.cmdbar-group-label { padding: 10px 12px 4px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--cs-n-400); }
.cmdbar-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 9px 12px; border: 0; background: none; border-radius: var(--radius-md); color: var(--cs-charcoal); font-family: inherit; text-align: left; text-decoration: none; cursor: pointer; user-select: none; }
.cmdbar-item.is-hidden { display: none; }
.cmdbar-item:hover { background: var(--cs-n-50); }
.cmdbar-item.is-active { background: var(--cs-n-100); }
.cmdbar-item.is-active:hover { background: var(--cs-n-100); }
.cmdbar-item:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cmdbar-item-ico { flex-shrink: 0; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; color: var(--cs-n-500); }
.cmdbar-item-ico svg { width: 20px; height: 20px; }
.cmdbar-item.is-active .cmdbar-item-ico { color: var(--cs-n-600); }
.cmdbar-item-text { flex: 1; min-width: 0; display: flex; align-items: baseline; white-space: nowrap; overflow: hidden; }
.cmdbar-item-title { flex-shrink: 0; max-width: 70%; font-size: 15px; font-weight: 500; letter-spacing: -0.01em; color: var(--cs-charcoal); overflow: hidden; text-overflow: ellipsis; }
.cmdbar-item-meta { flex: 0 1 auto; min-width: 0; font-size: 14px; color: var(--cs-n-400); overflow: hidden; text-overflow: ellipsis; }
.cmdbar-item-meta::before { content: "—"; margin: 0 8px; color: var(--cs-n-300); }
.cmdbar-mark { color: var(--cs-light-blue); font-weight: 600; }
.cmdbar-item-kbd { flex-shrink: 0; margin-left: auto; padding-left: 12px; }

/* Empty state */
.cmdbar-empty { padding: 40px 20px; text-align: center; font-size: 14px; color: var(--cs-n-400); }
.cmdbar-empty[hidden] { display: none; }

/* Footer — keyboard hints. */
.cmdbar-foot { flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 9px 14px; border-top: 1px solid var(--cs-n-100); background: var(--cs-n-50); }
.cmdbar-hints { display: flex; align-items: center; gap: 16px; min-width: 0; overflow: hidden; }
.cmdbar-hint { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cs-n-500); white-space: nowrap; }
.cmdbar-kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; box-sizing: border-box; padding: 0 5px; border: 1px solid var(--cs-n-200); border-bottom-width: 2px; border-radius: 5px; background: #fff; font-family: inherit; font-size: 11px; font-weight: 500; line-height: 1; color: var(--cs-n-500); }

/* Command-palette trigger — the app-wide search affordance (search field look,
   opens the palette on click). Sized to the standard control height. */
.cs-cmd-trigger { display: inline-flex; align-items: center; gap: 8px; height: var(--btn-h-md); min-height: var(--btn-h-md); box-sizing: border-box; padding: 0 10px 0 12px; min-width: 200px; border: 1px solid var(--cs-n-200); border-radius: var(--radius-md); background: #fff; color: var(--cs-n-500); font-family: inherit; font-size: 14px; letter-spacing: -0.005em; cursor: pointer; transition: background 0.15s ease, border-color 0.15s ease; }
.cs-cmd-trigger:hover { background: var(--cs-n-50); border-color: var(--cs-n-300); }
.cs-cmd-trigger:focus-visible { outline: none; box-shadow: var(--focus-ring); }
.cs-cmd-trigger-ico { width: 16px; height: 16px; color: var(--cs-n-400); flex-shrink: 0; stroke-width: 2; }
.cs-cmd-trigger-label { flex: 1; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-cmd-trigger-kbd { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; }

/* Mobile chrome — hidden by default at every size, shown < 768px. */
.bottom-nav { display: none; }
.app-scrim { display: none; }

/* ============================================================================
   RESPONSIVE — desktop-first. Literal px MUST match the --bp-* tokens.
     tablet   768–1023px   sidebar kept · grids step to 2-col
     mobile   < 768px      bottom tab bar (4) + bottom-sheet drawer · stacked
   ============================================================================ */
@media (min-width: 768px) and (max-width: 1023.98px) {
  .content     { padding: 28px 28px; }
  .stat-grid   { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3      { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 767.98px) {
  .app { flex-direction: column; height: auto; overflow: visible; }
  .main { overflow: visible; }

  /* hide scrollbars — mobile apps show no scroll track */
  .content, .sidebar, .table-card-reflow { scrollbar-width: none; -ms-overflow-style: none; }
  .content::-webkit-scrollbar, .sidebar::-webkit-scrollbar, .table-card-reflow::-webkit-scrollbar { width: 0; height: 0; display: none; }

  /* iOS chrome — PRESCRIBED. theme-color (set in base.html) paints Safari's
     status bar + bottom toolbar to --bg-app so the browser chrome blends with
     the page. The layout must then keep content out of the unsafe zones:
     pad the top by the notch/Dynamic-Island inset and inset the floating
     chrome by the side insets (landscape). The status-bar region stays the
     surface color — no top app bar — so it reads continuous with the chrome. */

  /* bottom tab bar — always exactly 4 items */
  .bottom-nav { display: flex; position: fixed; z-index: 60; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); bottom: calc(10px + env(safe-area-inset-bottom, 0px)); background: var(--cs-dark-blue); border-radius: 14px; padding: 6px; box-shadow: 0 10px 30px rgba(22,25,26,0.30); }
  .bottom-nav .tab { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px 4px; min-height: var(--touch-min); border: 0; background: transparent; cursor: pointer; color: rgba(255,255,255,0.62); border-radius: 8px; transition: color 0.15s ease, background 0.15s ease; }
  .bottom-nav .tab svg { width: 22px; height: 22px; stroke-width: 1.8; flex-shrink: 0; }
  .bottom-nav .tab .tab-label { font-size: 11px; font-weight: 500; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
  .bottom-nav .tab.active { color: #fff; background: rgba(255,255,255,0.12); }
  .bottom-nav .tab .tab-icon-wrap { position: relative; display: flex; }
  .bottom-nav .tab .tab-badge { position: absolute; top: -4px; right: -8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--cs-light-red); color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center; }

  /* sidebar becomes a bottom sheet */
  .sidebar { position: fixed; left: max(12px, env(safe-area-inset-left, 0px)); right: max(12px, env(safe-area-inset-right, 0px)); top: auto; width: auto; max-width: none; height: auto; max-height: 74vh; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); border-radius: 14px; transform: translateY(calc(100% + 84px)); transition: transform 0.26s cubic-bezier(.32,.72,0,1), border-radius 0.2s ease; z-index: 50; box-shadow: none; padding-bottom: 16px; }
  .sidebar::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: rgba(255,255,255,0.28); margin: 10px auto 2px; }
  .sidebar .sidebar-collapse-btn { display: none; }
  .sidebar .drawer-close-btn { position: absolute; top: 8px; right: 10px; width: var(--touch-min); height: var(--touch-min); display: flex; align-items: center; justify-content: center; background: transparent; border: 0; cursor: pointer; color: rgba(255,255,255,0.85); border-radius: 10px; transition: background 0.15s ease, color 0.15s ease; }
  .sidebar .drawer-close-btn:hover { background: rgba(255,255,255,0.10); color: #fff; }
  .sidebar .drawer-close-btn svg { width: 22px; height: 22px; stroke-width: 2; }
  /* the bottom sheet always shows full labels (never the rail) */
  .sidebar.collapsed { width: auto; }
  .sidebar.collapsed .nav-label, .sidebar.collapsed .sidebar-foot .name, .sidebar.collapsed .sidebar-brand .brand-sysname { display: block; }
  /* sheet is full-width — restore identity icon + name + inline Log out button */
  .sidebar .user-icon, .sidebar .logout-btn { display: flex; }
  .sidebar .logout-btn { margin-left: auto; }
  .sidebar.collapsed .sidebar-brand .wordmark { display: block; }
  .sidebar.collapsed .sidebar-brand .mark { display: none; }
  .sidebar.collapsed .nav-link { justify-content: flex-start; gap: 14px; padding: 11px 14px; }
  /* When open, the sheet and the tab bar dock into a single continuous panel:
     facing corners flatten and the bottom-nav becomes the sheet's footer. */
  .app--drawer-open .sidebar { transform: translateY(0); box-shadow: 0 -16px 40px rgba(22,25,26,0.30); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
  .app--drawer-open .bottom-nav { border-top-left-radius: 0; border-top-right-radius: 0; box-shadow: 0 16px 40px rgba(22,25,26,0.30); transition: border-radius 0.2s ease; }
  .app-scrim { display: block; position: fixed; inset: 0; background: rgba(22,25,26,0.45); z-index: 45; opacity: 0; pointer-events: none; transition: opacity 0.2s ease; }
  .app--drawer-open .app-scrim { opacity: 1; pointer-events: auto; }
  .drawer-close-btn { display: flex; }

  .main { width: 100%; }
  /* Top pad clears the notch / Dynamic Island; side pads clear the landscape
     notch; bottom pad clears the floating tab bar + home indicator. The space
     above the first content is the surface color, continuous with the
     theme-color'd status bar. */
  .content { padding: max(20px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) calc(86px + env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }

  /* Modal docks as a bottom sheet that clears the tab bar + home indicator.
     Still z 200, so it renders above .bottom-nav (z 60). */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 90vh; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .stack { gap: 24px; }
  .stack-sm { gap: 20px; }

  /* data table → stacked cards. Cells MUST carry data-label="…". */
  .table-card-reflow, .table-card-reflow tbody { display: block; width: 100%; }
  .table-card-reflow thead { display: none; }
  .table-card-reflow tr { display: block; background: #fff; border: 1px solid var(--cs-n-200); border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; }
  .table-card-reflow tr:last-child { margin-bottom: 0; }
  .table-card-reflow tr.clickable:hover td { background: transparent; }
  .table-card-reflow td { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; padding: 6px 0; border: none; font-size: 14px; text-align: right; }
  .table-card-reflow td::before { content: attr(data-label); flex-shrink: 0; text-align: left; font-size: 11px; font-weight: 600; color: var(--cs-n-400); text-transform: uppercase; letter-spacing: 0.06em; transform: translateY(1px); }
  .table-card-reflow td[data-label=""], .table-card-reflow td.card-title-cell { display: block; text-align: left; font-size: 16px; font-weight: 500; padding: 2px 0 8px; margin-bottom: 6px; border-bottom: 1px solid var(--cs-n-100); }
  .table-card-reflow td[data-label=""]::before, .table-card-reflow td.card-title-cell::before { content: none; }
  .table-card-reflow td .stage-badge { margin-left: auto; }

  /* grids collapse */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .stat-card { padding: 16px; min-width: 0; }
  .stat-value { font-size: 24px; overflow-wrap: anywhere; }
  .grid-2, .grid-3, .field-grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }

  /* page header stacks; primary action full width */
  .page-header { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-header h1 { font-size: 24px; }
  .page-header .flex-row { width: 100%; }
  .page-header .flex-row > .cs-btn { flex: 1; width: 100%; }

  /* table toolbar → stacked, full-width */
  .table-toolbar { flex-direction: column; align-items: stretch; gap: 10px; }
  .toolbar-search { max-width: none; flex-basis: auto; }
  .toolbar-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar-filters .filter-multi { width: 100%; }
  .filter-multi-btn { width: 100%; justify-content: space-between; height: var(--touch-min); }
  .toolbar-search .input-field { height: var(--touch-min); }
  .toolbar-actions { margin-left: 0; }
  .toolbar-actions > * { flex: 1; }
  .filter-menu { left: 0; right: 0; min-width: 0; }

  /* touch targets grow to 44px */
  .cs-btn:not(.cs-btn--sm) { height: var(--touch-min); min-height: var(--touch-min); }
  .input-field { padding-top: 11px; padding-bottom: 11px; }

  /* no hover on touch — comment row actions stay visible */
  .cs-comment-acts { opacity: 1; }

  /* Command palette — near-full-width sheet from the top; footer key hints
     drop (no physical keyboard on touch), result rows grow for the finger. */
  .cmdbar-overlay { padding: 7vh 10px 10px; }
  .cmdbar { max-width: none; max-height: 84vh; }
  .cmdbar-input { font-size: 16px; }            /* 16px floor — no iOS zoom */
  .cmdbar-item { padding: 12px; }
  .cmdbar-chip { height: 34px; }
  .cmdbar-foot { display: none; }
}

@media print {
  .app-scrim { display: none !important; }
  .sidebar { position: static; transform: none; }
}

/* ── Clearspace Forms — app-specific extensions ──────────────────────────
   Following the same pattern as .stage-* / .flash.success: this app's own
   status vocabulary, added locally rather than forking the shared file. */
.flash.error { background: #FEF2F2; color: var(--cs-dark-red); border: 1px solid #FCA5A5; }
.stage-published { background: rgba(179,193,0,0.15); color: var(--cs-dark-green); }
.stage-draft { background: #F3F4F6; color: #9CA3AF; }
.stage-required { background: rgba(240,90,90,0.1); color: #C0392B; }

/* Tailwind's CDN JIT scan is unreliable for classes that only ever appear via
   server-rendered Jinja conditionals (it can miss them entirely, as opposed to
   classes typed literally in a template file) — define this one ourselves so
   the show/hide toggle in the question builder/editor doesn't depend on it. */
.hidden { display: none !important; }
