/* Shared styles for BlueCollar web app UI kit */
@import url("./fonts.css");
@import url("./colors_and_type.css");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg-subtle); color: var(--fg-1); font-family: var(--font-body); font-size: 14px; }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
  background: var(--ink-800);
  color: #fff;
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky; top: 0; height: 100vh;
  overflow-y: auto;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; }
.sidebar .brand img { height: 28px; }
/* BlueCollarAppSwitcher (sidebar brand): the component's four custom properties default
   to the kit's light-surface tokens; the sidebar is dark in BOTH themes (var(--ink-800)),
   so remap them here to the sidebar's own vocabulary — no [data-theme] dependency.
   Values match the existing sidebar idiom (.nav:hover / .divider). .app prefix is
   load-order armor: (0,3,0) beats the package's scoped rule (.bcas[b-…], (0,2,0)) on
   specificity, so this keeps winning even if the stylesheet <link> order in App.razor
   ever changes. */
.app .sidebar .bcas {
  --bcas-fg: #fff;
  --bcas-surface: var(--ink-800);
  --bcas-border: rgba(255, 255, 255, 0.08);
  --bcas-hover: rgba(255, 255, 255, 0.06);
}
/* The package's .bcas-brand flex row has no gap of its own, and .brand's 10px gap only
   reaches direct children — restore the logo↔wordmark spacing lost when the brand markup
   moved inside the switcher's Logo fragment. External class selectors aren't blocked by
   the package's scoped-CSS attribute, and (0,3,0) wins the same way the block above does. */
.app .sidebar .bcas-brand { gap: 10px; }
.sidebar .section {
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; color: rgba(255,255,255,0.45);
  padding: 16px 8px 6px;
}
.sidebar .nav {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 4px; color: rgba(255,255,255,0.75);
  cursor: pointer; font-weight: 500; font-size: 14px; text-decoration: none;
  transition: background 120ms, color 120ms;
}
.sidebar .nav:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sidebar .nav.active { background: var(--brand-500); color: #fff; }
.sidebar .nav svg { width: 18px; height: 18px; stroke-width: 1.75; flex-shrink: 0; }
.sidebar .nav img { width: 18px; height: 18px; border-radius: 3px; object-fit: cover; flex-shrink: 0; }
.sidebar .nav .count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: rgba(255,255,255,0.5); }
.sidebar .nav.active .count { color: rgba(255,255,255,0.9); }
.sidebar .divider { border-top: 1px solid rgba(255,255,255,0.08); margin: 12px 8px; }
.sidebar .nav .ext-icon { margin-left: auto; opacity: 0.5; font-size: 12px; }

.sidebar .user {
  margin-top: auto; padding: 10px; border-top: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .user .avatar {
  width: 32px; height: 32px; border-radius: 4px; background: var(--brand-500);
  display: flex; align-items: center; justify-content: center; color: #fff;
  font-weight: 700; font-size: 13px; flex-shrink: 0;
}
.sidebar .user img.avatar {
  object-fit: cover;
}
.sidebar .user .name { font-size: 13px; color: #fff; }
.sidebar .user .shop { font-size: 11px; color: rgba(255,255,255,0.5); }

/* ---------- Topbar ---------- */
.topbar {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 16px; position: sticky; top: 0; z-index: 5;
  color: var(--fg-1);
}
.topbar .crumbs {
  font-family: var(--font-display); font-weight: 700; font-size: 12px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3);
}
.topbar .crumbs .cur { color: var(--fg-1); }

/* ---------- Non-production chrome ----------
   data-env="nonprod" is set on <html> by App.razor for every environment that isn't
   Production (training, local dev). Light-touch: an amber top border on the topbar and an
   amber-ringed brand mark, plus the "TRAINING"/"DEVELOPMENT" pill in MainLayout's topbar.
   Deliberately restrained so it flags the environment without fighting the theme. */
:root[data-env="nonprod"] .topbar {
  border-top: 3px solid var(--safety-500);
}
:root[data-env="nonprod"] .sidebar .brand img {
  box-shadow: 0 0 0 2px var(--safety-500);
}
.env-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-family: var(--font-display); font-weight: 800; font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  background: var(--safety-500); color: #1a1206; white-space: nowrap;
}
/* "Who's online" avatar stack — see PresenceBar.razor. Overlapping circles, most-recently-
   loaded on top (later in DOM order), each with a surface-colored ring so they read as a
   stack rather than a smear when avatars are visually similar. */
.presence-bar { display: flex; align-items: center; }
.presence-avatar {
  width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex-shrink: 0;
  border: 2px solid var(--surface); margin-left: -10px;
}
.presence-avatar:first-child { margin-left: 0; }
.presence-avatar-fallback {
  display: flex; align-items: center; justify-content: center; background: var(--brand-500);
  color: #fff; font-weight: 700; font-size: 13px;
}

/* Left and right regions share the leftover width equally (flex-basis 0), which keeps the
   search box (GlobalSearch.razor) at the true center of the bar. */
.topbar .topbar-side { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 16px; }
.topbar .topbar-side.end { justify-content: flex-end; }
.topbar .crumbs { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Top-bar search + results panel ---------- */
.global-search { position: relative; flex: 0 1 520px; min-width: 0; }
.topbar .search {
  width: 100%; height: 36px; background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 12px 0 34px; font-size: 13px; font-family: var(--font-body);
  color: var(--fg-1);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E7888' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat; background-position: 10px center;
}
.topbar .search:focus { outline: none; border-color: var(--brand-500); }

.search-panel {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 30;
  max-height: min(70vh, 640px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: 6px;
  box-shadow: var(--shadow-lg); color: var(--fg-1);
}
.search-panel-note { padding: 16px; font-size: 13px; color: var(--fg-3); }
.search-group { padding: 8px 0; }
.search-group + .search-group { border-top: 1px solid var(--border); }
.search-group-head {
  display: flex; justify-content: space-between; align-items: center; padding: 6px 16px;
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3);
}
.search-group-count { font-family: var(--font-mono); letter-spacing: 0; }
.search-hit {
  display: flex; align-items: center; gap: 12px; padding: 8px 16px;
  color: inherit; text-decoration: none; cursor: pointer;
}
.search-hit.active, .search-hit:hover { background: var(--bg-subtle); }
.search-hit-icon { flex: none; color: var(--fg-3); display: inline-flex; }
.search-hit-icon .rzi { font-size: 20px; }
.search-hit-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.search-hit-title { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit-sub { font-size: 12px; color: var(--fg-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-hit-meta { flex: none; display: flex; align-items: center; gap: 10px; }
.search-hit-amount { display: flex; flex-direction: column; align-items: flex-end; }
.search-see-all {
  display: inline-flex; align-items: center; gap: 4px; padding: 6px 16px 4px 52px;
  font-size: 13px; color: var(--fg-2); text-decoration: none;
}
.search-see-all:hover { color: var(--brand-500); }
.search-see-all .rzi { font-size: 16px; }
.search-see-all.muted { color: var(--fg-3); cursor: default; }

/* Page-level search box (e.g. filtering the dashboard's project list) — same look as
   .topbar .search but full-width within whatever container sizes it, for use in page
   content rather than the topbar. */
.search-input {
  width: 100%; height: 36px; background: var(--bg-subtle); border: 1px solid var(--border);
  border-radius: 4px; padding: 0 12px 0 34px; font-size: 13px; font-family: var(--font-body);
  color: var(--fg-1);
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236E7888' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='8'/><path d='m21 21-4.3-4.3'/></svg>");
  background-repeat: no-repeat; background-position: 10px center;
}
.search-input:focus { outline: none; border-color: var(--brand-500); }

/* ---------- Main ---------- */
/* .content (the unnamed-in-markup wrapper around .topbar + .main — see
   MainLayout.razor) is the actual grid item/track of .app, not .main itself.
   min-width:0 overrides the grid-item default of min-width:auto — without it,
   .content refuses to shrink below its content's intrinsic minimum width,
   which can exceed the viewport when that content includes a RadzenDataGrid
   (Radzen's internal wrapper elements carry some minimum width of their own,
   independent of how many columns are actually visible). Same fix already
   applied to .page-head-title below for the same underlying CSS Grid/Flexbox
   behavior — get this on the wrong element (e.g. .main, a non-grid-item
   descendant) and it silently does nothing, since .main just inherits
   whatever width its actual-grid-item parent settles on. */
.content { min-width: 0; }
.main { padding: 24px 28px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 20px; gap: 24px; flex-wrap: wrap; }
.page-head-title { min-width: 0; flex: 1 1 auto; }
.page-head h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 28px; }
.page-head .actions { flex-shrink: 0; display: flex; gap: 8px; }
.page-head .eyebrow { font-family: var(--font-display); font-weight: 700; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3); margin-bottom: 6px; }
.page-head h1 { font-family: var(--font-display); font-weight: 800; font-size: 34px; text-transform: uppercase; letter-spacing: -0.01em; margin: 0; line-height: 1; }
.page-head .actions { display: flex; gap: 8px; }

/* ---------- Buttons ---------- */
button { font-family: inherit; cursor: pointer; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font-weight: 600; font-size: 14px; font-family: var(--font-body);
  border-radius: 4px; border: 1px solid transparent; padding: 0 14px;
  height: 36px; transition: all 120ms;
}
.btn i { width: 16px; height: 16px; stroke-width: 1.75; }
.btn.primary { background: var(--brand-500); color: #fff; }
.btn.primary:hover { background: var(--brand-600); }
.btn.secondary { background: var(--accent-500); color: #fff; }
.btn.secondary:hover { background: var(--accent-600); }
.btn.neutral { background: var(--surface); color: var(--fg-1); border-color: var(--border-strong); }
.btn.neutral:hover { background: var(--bg-subtle); border-color: var(--border-bold); }
.btn.ghost { background: transparent; color: var(--fg-1); }
.btn.ghost:hover { background: var(--bg-sunken); }
.btn.stamped { background: var(--surface); color: var(--fg-1); border: 2px solid var(--border-bold); height: 38px; }
.btn.danger { background: var(--fault-500); color: #fff; }
.btn.sm { height: 28px; font-size: 13px; padding: 0 10px; }

/* ---------- Cards + tables ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow-xs); }
.card.stamped { border: 2px solid var(--border-bold); box-shadow: none; }
.card .head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.card .head h3 { font-family: var(--font-display); font-weight: 700; font-size: 14px; letter-spacing: 0.12em; text-transform: uppercase; margin: 0; }
.card .body { padding: 18px; }
.card .body.tight { padding: 0; }

table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
.data th {
  text-align: left; padding: 10px 16px; background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display); font-weight: 700; font-size: 11px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3);
}
.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); color: var(--fg-1); }
.data tr:last-child td { border-bottom: 0; }
.data tr:hover td { background: var(--bg-subtle); cursor: pointer; }
.data .num { font-family: var(--font-mono); text-align: right; font-weight: 600; }
.data .mono { font-family: var(--font-mono); }

/* Dense variant — tighter padding, smaller text, for compact inline lists. */
table.data.dense { font-size: 12px; }
.data.dense th { padding: 4px 10px; }
.data.dense td { padding: 5px 10px; }

/* ---------- Chips / status ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-display); font-weight: 700; font-size: 10px;
  letter-spacing: 0.1em; text-transform: uppercase;
  padding: 3px 8px; border-radius: 4px;
}
.chip .dot { width: 5px; height: 5px; border-radius: 50%; }
.chip.go { background: var(--go-50); color: var(--go-600); } .chip.go .dot { background: var(--go-500); }
.chip.safety { background: #FFF4D6; color: #6E4E00; } .chip.safety .dot { background: var(--safety-500); }
.chip.fault { background: var(--fault-50); color: var(--fault-600); } .chip.fault .dot { background: var(--fault-500); }
.chip.sched { background: var(--info-50); color: var(--brand-700); } .chip.sched .dot { background: var(--brand-500); }
.chip.draft { background: var(--bg-sunken); color: var(--fg-2); } .chip.draft .dot { background: var(--ink-400); }
[data-theme="dark"] .chip.safety { background: #2A2310; color: #E5B54A; }
[data-theme="dark"] .chip.sched { color: var(--brand-200); }

.color-swatch {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 0.35rem;
  vertical-align: middle;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

/* ---------- Stats / KPI ---------- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 6px; padding: 16px; }
.stat .label { font-family: var(--font-display); font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-3); }
.stat .value { font-family: var(--font-mono); font-weight: 700; font-size: 28px; color: var(--fg-1); margin-top: 6px; letter-spacing: -0.01em; }
.stat .delta { font-size: 12px; color: var(--fg-2); margin-top: 4px; }
.stat .delta.up { color: var(--go-600); }
.stat .delta.down { color: var(--fault-500); }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 10px 14px; font-size: 13px; font-weight: 600; color: var(--fg-2);
  border: none; background: transparent; cursor: pointer; border-bottom: 2px solid transparent;
  font-family: inherit; margin-bottom: -1px;
}
.tab:hover { color: var(--fg-1); }
.tab.active { color: var(--fg-1); border-bottom-color: var(--brand-500); }

/* ---------- Form ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--fg-1); }
.field input, .field select, .field textarea {
  font-family: var(--font-body); font-size: 14px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 4px; background: var(--surface);
  color: var(--fg-1); outline: none; height: 38px; box-sizing: border-box;
}
.field input:focus { border-color: var(--brand-500); box-shadow: var(--focus-ring); }

/* ---------- Utilities ---------- */
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.hidden { display: none; }
.t-mono { font-family: var(--font-mono); }

/* ---------- Theme toggle button ---------- */
.theme-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 4px;
  background: var(--bg-subtle); border: 1px solid var(--border); color: var(--fg-2);
  cursor: pointer; transition: all 120ms;
}
.theme-toggle:hover { background: var(--bg-sunken); color: var(--fg-1); border-color: var(--border-strong); }
.theme-toggle i { width: 16px; height: 16px; stroke-width: 1.75; }

/* ---------- Report a bug / request a feature (top bar) ---------- */
.feedback-link {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  height: 36px; padding: 0 10px; border-radius: 4px; white-space: nowrap;
  background: var(--bg-subtle); border: 1px solid var(--border); color: var(--fg-2);
  font-size: 13px; text-decoration: none; transition: all 120ms;
}
.feedback-link:hover { background: var(--bg-sunken); color: var(--fg-1); border-color: var(--border-strong); }
/* Icon only where the label would crowd the search box. */
@media (max-width: 1280px) {
  .feedback-link { width: 36px; padding: 0; justify-content: center; }
  .feedback-link span { display: none; }
}

/* ---------- Sidebar toggle ---------- */
/* Visible at every width. On desktop it collapses/expands the persistent
   rail. On mobile it only ever *opens* the drawer — once open, the sidebar
   (z-index above the topbar) visually covers this same top-left screen
   region, so this button becomes unclickable; closing on mobile is handled
   by .sidebar-close (inside the drawer itself, see MainLayout.razor),
   the backdrop, or tapping a nav link. Actual show/hide is driven by the
   data-sidebar attribute on <html>, set by js/sidebar.js — see there for why
   (avoids a flash of the wrong state on load, and toggling doesn't need a
   Blazor render round-trip to take visual effect). */
.sidebar-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 4px; flex-shrink: 0;
  background: transparent; border: 1px solid var(--border); color: var(--fg-1);
  cursor: pointer;
}
.sidebar-toggle svg { width: 18px; height: 18px; stroke-width: 2; }

.sidebar-backdrop { display: none; }

.sidebar-close { display: none; }

/* ---------- Responsive: tablet / mobile — sidebar becomes an overlay ---------- */
@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 260px; height: 100dvh;
    transform: translateX(-100%); transition: transform 200ms ease; z-index: 50;
  }
  html[data-sidebar="expanded"] .sidebar { transform: translateX(0); }

  html[data-sidebar="expanded"] .sidebar-backdrop {
    display: block; position: fixed; inset: 0; background: rgba(10, 14, 20, 0.55); z-index: 40;
  }

  .sidebar-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; margin-left: auto; flex-shrink: 0;
    background: transparent; border: none; color: rgba(255, 255, 255, 0.7); cursor: pointer;
  }
  .sidebar-close:hover { color: #fff; }
  .sidebar-close svg { width: 20px; height: 20px; stroke-width: 2; }

  .stats { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- Desktop — sidebar is a persistent rail that reclaims space when collapsed ---------- */
@media (min-width: 961px) {
  .app { transition: grid-template-columns 200ms ease; }

  html[data-sidebar="collapsed"] .app { grid-template-columns: 0 1fr; }
  html[data-sidebar="collapsed"] .sidebar { padding-left: 0; padding-right: 0; overflow: hidden; }
}

/* ---------- Responsive: phone ---------- */
@media (max-width: 600px) {
  .main { padding: 14px 12px; }
  .topbar { padding: 0 12px; gap: 8px; }
  /* Room for the search box on a phone: the page title and presence avatars step aside
     (each page shows its own heading anyway), and the box takes whatever width is left. */
  .topbar .topbar-side { flex: none; gap: 8px; }
  .topbar .topbar-side .crumbs, .topbar .topbar-side .env-pill, .topbar .topbar-side .presence-bar { display: none; }
  .global-search { flex: 1 1 auto; }
  .search-panel { position: fixed; top: 56px; left: 8px; right: 8px; }

  .page-head { flex-direction: column; align-items: stretch; gap: 12px; }
  .page-head h1 { font-size: 24px; white-space: normal; }
  .page-head .actions { flex-wrap: wrap; }

  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat { padding: 12px; }
  .stat .value { font-size: 22px; }

  /* General-purpose "hide at phone width" utility. Used both on whole
     elements (e.g. Projects.razor's grid wrapper, replaced by
     .mobile-cards below) and via RadzenDataGridColumn's CssClass/
     HeaderCssClass on individual grid columns elsewhere (Competencies,
     VendorFinder, Vendors) that don't have a mobile card equivalent. */
  .hide-mobile { display: none !important; }

  /* Any grid explicitly opted into stacking on phones (see the shared
     ProjectDetail fragment in Projects.razor) — inline grid-template-columns
     needs !important to override since it's set directly on the element. */
  .expand-grid { grid-template-columns: 1fr !important; }

  /* .expand-grid's direct children (bare <div>s in the ProjectDetail
     fragment, each holding a data table) are CSS Grid items, which default
     to min-width:auto — without this they refuse to shrink below their
     table's intrinsic width even after the grid stacks to one column above,
     overflowing their own track (and, inside a mobile card, the card and
     the page). Same underlying gotcha as .content/.list-card elsewhere in
     this file, just one level deeper. */
  .expand-grid > div { min-width: 0; }

  /* Page-header pattern used across pages: a RadzenStack with
     Orientation="Horizontal" JustifyContent="SpaceBetween" holding a title
     and an action button. RadzenStack's row direction comes from Radzen's
     own .rz-flex-row class, which Radzen itself defines with !important
     (flex-direction:row !important in default-base.css) — so this needs
     !important too, plain specificity isn't enough to win. Stacks title
     above button instead of clipping the button off-screen. */
  .rz-flex-row.rz-justify-content-space-between {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.75rem;
  }
}

/* ---------- List cards — mobile replacement for a data grid ----------
   Generic "one row as a card" pattern, shared by any page that swaps its
   grid for cards on phones (Projects.razor first, others as needed).
   Each page supplies its own .mobile-cards wrapper + .list-card content;
   these classes just give it consistent structure/spacing. */
.mobile-cards { display: none; }

@media (max-width: 600px) {
  .mobile-cards { display: flex; flex-direction: column; gap: 12px; }

  /* min-width:0 — same CSS Grid/Flexbox gotcha as .content above: flex items
     default to min-width:auto, so without this a card whose expanded detail
     contains a wide table (see Projects.razor's ProjectDetail fragment)
     refuses to shrink to the container's width, and its own overflow-x:auto
     wrappers have nothing bounded to actually clip against. */
  .list-card { padding: 14px 16px; min-width: 0; }

  .list-card-top {
    display: flex; justify-content: space-between; align-items: flex-start;
    gap: 10px; cursor: pointer;
  }
  .list-card-title {
    font-family: var(--font-display); font-weight: 800; font-size: 17px;
    letter-spacing: -0.01em; color: var(--fg-1);
  }
  .list-card-subtitle { font-size: 13px; color: var(--fg-2); margin-top: 2px; }

  .list-card-meta {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px;
    margin: 12px 0 0; padding: 0;
  }
  .list-card-meta dd { margin: 2px 0 0; font-size: 13px; color: var(--fg-1); }

  .list-card-actions {
    display: flex; align-items: center; gap: 4px;
    margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border);
  }

  .list-card-detail { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
}

/* ---------- Responsive tables — reflow rows into stacked cards on phones ----------
   Opt-in with `class="data stack"`. Each <tr> becomes a bordered card and each <td>
   a block labelled by its `data-label` attribute (set to the column's <th> text).
   Cheaper than a hand-built .mobile-cards view for the many small settings/list
   tables; the <div style="overflow-x:auto"> wrappers around these tables become
   harmless no-ops once nothing overflows. */
@media (max-width: 600px) {
  table.data.stack thead { display: none; }
  table.data.stack,
  table.data.stack tbody,
  table.data.stack tr,
  table.data.stack td { display: block; width: auto; }

  table.data.stack tr {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 10px 14px; margin-bottom: 10px;
  }
  table.data.stack td { border: none; padding: 4px 0; text-align: left; }

  table.data.stack td::before {
    content: attr(data-label);
    display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--fg-3); margin-bottom: 2px;
  }
  table.data.stack td:not([data-label])::before,
  table.data.stack td[data-label=""]::before { display: none; }
  table.data.stack td:empty { display: none; }
}

/* A section just jumped to from a Kanban card's "needed to move on" entry (focus-section.js). */
@keyframes focus-flash {
  0%, 60% { box-shadow: 0 0 0 3px var(--brand-500); }
  100%    { box-shadow: 0 0 0 3px transparent; }
}
.focus-flash { animation: focus-flash 2.4s ease-out; border-radius: 6px; }

/* Dashboard chart tooltips: each line's figure for the day, then the projects behind it
   (Dashboard.razor, PointTooltip). */
.dash-tip { min-width: 260px; max-width: 380px; padding: 2px 0 4px; }
.dash-tip + .dash-tip, .rz-chart-tooltip-item + .rz-chart-tooltip-item .dash-tip { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.dash-tip-head { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.dash-tip-swatch { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.dash-tip-row { display: flex; gap: 12px; padding-left: 16px; font-size: 12px; line-height: 1.5; }
.dash-tip-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dash-tip-amount { margin-left: auto; font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.dash-tip-more { color: var(--fg-3); }

/* Dashboard slicers and drill-down (DashboardPage): the filter bar under the title, the note saying
   what it's narrowed to, and a pointer over the charts whose points and bars open something. */
.dash-slicers { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin: 0 0 0.75rem; }
.dash-slice-note { margin: 0 0 1rem; padding: 0.5rem 0.75rem; border-radius: 6px; background: var(--bg-subtle); color: var(--fg-2); font-size: 0.875rem; }
.dash-clickable svg path, .dash-clickable svg rect, .dash-clickable svg circle { cursor: pointer; }

/* ── Project page Overview cards (ProjectTitleCard, ProjectPeopleCard, …) ───────────────
   Each card stacks its fields with an even gap; .ov-row puts two or three side by side and
   wraps them on a narrow screen. .ov-changed marks an unsaved change, as DraftField does. */
.ov-card { padding: 1rem 1rem 1rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.ov-card-title { margin: 0; }
.ov-row { display: flex; gap: 1rem; flex-wrap: wrap; align-items: flex-start; }
.ov-note { margin-top: 0.5rem; padding: 0.5rem 0.75rem; background: var(--info-50); border-radius: var(--radius-md); font-size: 0.8125rem; color: var(--fg-1); }
.ov-changed { color: var(--safety-600); font-weight: 600; text-transform: none; letter-spacing: 0; }

/* ---------- Settings pages ----------
   The cards on a /settings/* page (SettingsLayout supplies the grouped menu around them). A page
   that saves its fields together marks each changed card with .ov-changed and shows SettingsSaveBar. */
.settings-cards { display: flex; flex-direction: column; gap: 1rem; max-width: 760px; }
.settings-card { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.75rem; min-width: 0; }
.settings-card-head { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; align-items: center; justify-content: space-between; }
.settings-card-title { margin: 0; font-size: 0.9375rem; font-weight: 600; color: var(--fg-1); }
.settings-help { margin: 0; font-size: 0.8125rem; line-height: 1.5; color: var(--fg-2); }
.settings-list { margin: 0; padding-left: 1.1rem; display: flex; flex-direction: column; gap: 0.4rem; font-size: 0.8125rem; line-height: 1.5; color: var(--fg-2); }
.settings-check { display: flex; align-items: center; gap: 0.5rem; font-size: 0.875rem; color: var(--fg-1); cursor: pointer; }
.settings-facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem 1.5rem; }
.settings-facts dt { font-size: 0.75rem; color: var(--fg-2); }
.settings-facts dd { margin: 0; font-size: 0.8125rem; color: var(--fg-1); overflow-wrap: anywhere; }
.settings-row { display: flex; flex-wrap: wrap; gap: 0.75rem; }
.settings-row > * { flex: 1 1 220px; min-width: 0; }
@media (max-width: 600px) { .settings-facts { grid-template-columns: minmax(0, 1fr); } }

/* ---------- WebAssembly bundle download (#45, js/bundle-progress.js) ---------- */
.bundle-progress {
  position: fixed; top: 0; left: 0; height: 3px; z-index: 10000; pointer-events: none;
  width: var(--bundle-progress, 0%); background: var(--brand-500);
  opacity: 0; transition: width 200ms ease, opacity 300ms ease;
}
html[data-bundle-loading] .bundle-progress { opacity: 1; }
[data-theme="dark"] .bundle-progress { background: var(--brand-300); }

/* ── Financials tab (the project view's): the summary cards, list totals, jump bar and labor rows. ── */
/* Project Summary / WIP cards above the Budget card. */
.fin-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 22rem), 1fr));
    gap: 1.5rem;
    align-items: start;
}

.fin-card {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.fin-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding-bottom: 0.6rem;
    margin-bottom: 0.4rem;
    border-bottom: 1px solid var(--border);
}

.fin-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--fg-1);
}

.fin-row > span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fin-box {
    position: relative;
    border: 1px solid var(--border-strong);
    border-radius: 6px;
    padding: 0.6rem 0.9rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin: 0.5rem 0;
}

.fin-total {
    background: var(--bg-sunken);
    border-radius: 6px;
    padding: 0.75rem 0.9rem;
}

.fin-result {
    border-top: 1px dashed var(--border-strong);
    margin-top: 0.25rem;
    padding: 0.75rem 0.9rem 0;
    font-weight: var(--fw-semibold);
}

/* The +/−/= badges straddling a box's bottom (or top) edge. */
.fin-op {
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translate(-50%, 50%);
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: var(--surface);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    color: var(--fg-2);
}

.fin-op-top {
    top: 0;
    bottom: auto;
    transform: translate(-50%, -50%);
}

/* "Total $x" beside the Invoices / Expenses / Change Orders card titles. */
.list-total {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--fg-2);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.list-total .t-num {
    color: var(--fg-1);
    font-size: 1rem;
    margin-left: 0.35rem;
    text-transform: none;
    letter-spacing: 0;
}

/* The WIP card's profit/ROIC rows, set off from the billing rows above. */
.fin-divider {
    margin-top: 0.35rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* The jump bar over the tab's cards: sticky as it scrolls, below the page's Save bar when that's
   showing (--project-sticky-top, set by ProjectPage). */
.fin-jump {
    position: sticky;
    top: var(--project-sticky-top, 0px);
    z-index: 4;
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
    padding: 0.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-xs);
}

.fin-jump-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--fg-1);
    font: inherit;
    font-size: 0.8125rem;
    cursor: pointer;
}

.fin-jump-link:hover {
    border-color: var(--brand-400);
}

.fin-jump-link:focus-visible {
    outline: 2px solid var(--brand-500);
    outline-offset: 1px;
}

.fin-jump-count {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg-3);
}

/* Labor card: a person's name opens their punches underneath. */
.fin-link-btn {
    background: none; border: 0; padding: 4px 0; min-height: 32px;
    color: var(--fg-1); font: inherit; font-weight: 600; cursor: pointer; text-align: left;
}
.fin-link-btn:hover { color: var(--brand-400); }
.fin-link-btn:focus-visible { outline: 2px solid var(--brand-400); outline-offset: 2px; }
.fin-sub-row td { color: var(--fg-2); font-size: 13px; background: var(--bg-subtle); }

/* The Budget Builder (#52): the financial summary and the cost breakdown side by side across the
   dialog; one column on a narrow screen (and in the side drawer, always narrower than this). */
.budget-builder-top-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    align-items: start;
}

@media (max-width: 700px) {
    .budget-builder-top-row {
        grid-template-columns: 1fr;
    }
}

/* ── Project view: Draws tab (#53, Construction.Client/Components/ProjectView) ── */
.draws { display: flex; flex-direction: column; gap: 1.25rem; margin-top: 1rem; }
.draws-empty { display: flex; flex-direction: column; gap: 0.75rem; padding: 1.25rem; max-width: 760px; }
.draws-summary { display: flex; flex-direction: column; gap: 0.75rem; padding: 1rem; }
.draws-figs { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.draws-fig { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.draws-fig .t-label { color: var(--fg-3); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.draws-money { font-family: var(--font-mono); font-weight: 700; font-size: 20px; color: var(--fg-1); }
.draws-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: flex-end; }
.draws-loan-edit { display: flex; flex-direction: column; gap: 0.5rem; border-top: 1px solid var(--border); padding-top: 0.75rem; }
.draws-bar { display: inline-block; width: 72px; height: 6px; border-radius: 3px; background: var(--bg-sunken); vertical-align: middle; margin-right: 6px; overflow: hidden; }
.draws-bar > span { display: block; height: 100%; background: var(--brand-500); }
.loan-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; }
.draw { display: flex; flex-direction: column; gap: 1rem; }
.draw-head { display: flex; flex-wrap: wrap; gap: 1rem; align-items: flex-end; justify-content: space-between; }
.draw-head .t-label { margin-bottom: 4px; }
tr.draw-bad td { background: var(--fault-50); }
.draw-waivers { display: flex; flex-direction: column; gap: 0.5rem; }
.draw-waiver-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0.5rem; }
.draw-waiver { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; border: 1px solid var(--border); border-radius: 6px; padding: 0.6rem 0.75rem; background: var(--surface); }
.draw-waiver.missing { border-color: var(--safety-500); }
.draw-waiver.in { border-left: 3px solid var(--go-500); }
.draw-foot { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; border-top: 1px solid var(--border); padding-top: 0.75rem; }

/* ── Project page header (#54, Construction.Client/Components/ProjectView/ProjectHeader) ── */
.project-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ph-title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.ph-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.ph-title h1 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 1.75rem;
    line-height: 1.15;
    letter-spacing: .01em;
    color: var(--fg-1);
}

.ph-number {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--fg-3);
}

.ph-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-left: auto;
}

.ph-pill {
    display: inline-block;
    padding: 3px 12px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.5;
    white-space: nowrap;
}

.ph-track-wrap {
    overflow-x: auto;
}

.ph-track {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 3px;
    min-width: 640px;
}

.ph-step {
    flex: 1;
    padding-top: 7px;
    border-top: 4px solid var(--surface-3);
    font-size: 0.75rem;
    color: var(--fg-3);
    white-space: nowrap;
}

.ph-step.done {
    border-top-color: var(--go-500);
    color: var(--fg-2);
}

.ph-step.current {
    border-top-color: var(--brand-500);
    color: var(--fg-1);
    font-weight: 700;
}

.ph-facts {
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.75rem 1.5rem;
}

.ph-facts dt {
    font-size: 0.75rem;
    color: var(--fg-3);
}

.ph-facts dd {
    margin: 0;
    font-weight: 600;
    color: var(--fg-1);
    overflow-wrap: anywhere;
}

.ph-facts dd.num {
    font-family: var(--font-mono);
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.ph-needs {
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border-top: 4px solid var(--brand-500);
}

.ph-needs ul {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

.ph-needs li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding: 0.5rem 0;
}

.ph-needs li + li {
    border-top: 1px solid var(--border);
}

.ph-need-text {
    font-weight: 600;
    color: var(--fg-1);
}

/* ── Full-screen dialog title with Back and ✕ (DialogBackTitle, ProjectDetailDialog) ── */
.dialog-back-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
    width: 100%;
}

.dialog-back {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    flex: none;
    padding: 2px 10px 2px 6px;
    font-size: 0.85rem;
}

.dialog-back .rzi {
    font-size: 18px;
}

.dialog-back-title-text {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Stands in for Radzen's close button, which is off so closing can ask about unsaved changes. */
.dialog-close {
    display: inline-flex;
    align-items: center;
    flex: none;
    margin-left: auto;
    padding: 2px 6px;
}

.dialog-close .rzi {
    font-size: 20px;
}
