/* App design system. Ported from the BluePatch launcher (Staging branch,
   bfcd23b, 2026-06-19) so it no longer depends on that repo: dark, dense,
   tool-like. Surfaces step up in 8-shade increments, borders are white at
   6/10/18%, one blue accent, small radii (2/4/6px). Type is Geist everywhere, figures included
   (--font-mono is Geist with tabular figures: one look for every digit, a 0 without a slash; Tanner 2026-09-27).
   Tailwind colour names in base.html map onto these variables, so every
   template follows the theme without per-class dark overrides. */

:root,
html[data-theme="dark"] {
  color-scheme: dark;

  --surface-base:    #1A1A1F;
  --surface-1:       #222228;
  --surface-2:       #2A2A32;
  --surface-3:       #32323C;
  --surface-overlay: #2E2E38;

  --text-primary:    #E8E8EE;
  --text-secondary:  #AEAEBE;
  --text-muted:      #78788C;

  --accent:          #4A8FE8;
  --accent-dim:      #2A5FA8;
  --accent-subtle:   rgba(74, 143, 232, 0.12);
  --accent-glow:     rgba(74, 143, 232, 0.25);
  --border-accent:   rgba(74, 143, 232, 0.50);
  --on-accent:       #222228;

  --status-ok:       #3DAA6E;
  --status-warn:     #C89B3C;
  --status-error:    #C04A4A;
  --status-offline:  #4A4A58;
  --error-text:      #E08080;
  --error-subtle:    rgba(192, 74, 74, 0.15);

  --border-subtle:   rgba(255, 255, 255, 0.06);
  --border-default:  rgba(255, 255, 255, 0.10);
  --border-strong:   rgba(255, 255, 255, 0.18);

  --card-shadow:
    0 2px 8px rgba(0, 0, 0, 0.55),
    0 1px 3px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --card-shadow-lift:
    0 12px 30px rgba(0, 0, 0, 0.65),
    0 4px 10px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.065);

  /* Same values as rgb triplets, for Tailwind opacity modifiers (bg-primary/10). */
  --rgb-accent:        74 143 232;
  --rgb-text-secondary: 174 174 190;

  --font-sans: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: var(--font-sans);  /* same face: no slashed 0; columns line up via tabular-nums */

  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;

  --nav-height: 48px;
  --sidebar-width: 240px;
  --transition-fast: 80ms ease;
  --transition-lift: 130ms cubic-bezier(0.2, 0, 0.2, 1);

  /* Kept for existing templates: the warm "attention" colour is status-warn. */
  --accent-amber: var(--status-warn);
}

/* Light theme: BluePatch has none; same structure inverted, for crew
   working outside in bright sun (per-user toggle). */
html[data-theme="light"] {
  color-scheme: light;

  /* Same ladder as dark: panels and cards (surface-2) sit above the page, so
     here they're white on a light grey page; surface-3 is tracks and hovers. */
  --surface-base:    #F1F1F4;
  --surface-1:       #F8F8FA;
  --surface-2:       #FFFFFF;
  --surface-3:       #EAEAEF;
  --surface-overlay: #FFFFFF;

  --text-primary:    #1A1A1F;
  --text-secondary:  #4A4A58;
  --text-muted:      #6E6E80;

  --accent:          #2F74D0;
  --accent-dim:      #2A5FA8;
  --accent-subtle:   rgba(47, 116, 208, 0.10);
  --accent-glow:     rgba(47, 116, 208, 0.20);
  --border-accent:   rgba(47, 116, 208, 0.50);
  --on-accent:       #FFFFFF;

  --status-warn:     #B0831F;
  --error-text:      #A83232;
  --error-subtle:    rgba(192, 74, 74, 0.10);

  --border-subtle:   rgba(0, 0, 0, 0.06);
  --border-default:  rgba(0, 0, 0, 0.10);
  --border-strong:   rgba(0, 0, 0, 0.18);

  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
  --card-shadow-lift: 0 10px 24px rgba(0, 0, 0, 0.12), 0 3px 8px rgba(0, 0, 0, 0.08);

  --rgb-accent:         47 116 208;
  --rgb-text-secondary: 74 74 88;
}
/* Light only: where dark leans on "darker = recessed" and the white panels would hide it. */
html[data-theme="light"] .btn { background: var(--surface-2); }
html[data-theme="light"] .sidebar-row:hover { background: var(--surface-3); }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface-base);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;  /* every figure the same width, so money columns line up without a mono font */
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: -0.003em;
  -webkit-font-smoothing: antialiased;
}

input, select, textarea {
  background-color: var(--surface-base);
  color: var(--text-primary);
  border-color: var(--border-default);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--border-accent) !important; box-shadow: none; }
option { background-color: var(--surface-1); color: var(--text-primary); }
/* iOS zooms into anything under 16px on focus. */
@media (max-width: 767px) {
  input, select, textarea { font-size: 16px !important; }
}

.font-mono,
input[type="number"],
input[inputmode="decimal"],
input[inputmode="numeric"] {
  font-variant-numeric: tabular-nums lining-nums;
}

/* Section eyebrow: tiny uppercase muted label above a title. */
.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ---- Shell: top bar + sidebar ------------------------------------------ */

.top-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  height: var(--nav-height);
  padding: 0 8px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
}
.nav-logo {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 6px;
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.nav-logo:hover { background: var(--surface-2); }
/* Job Kit 360 mark, templates/_logo_mark.html. */
.nav-logo-mark { display: block; width: 30px; height: 30px; flex-shrink: 0; }
.nav-logo img { display: block; height: 30px; width: auto; }
.nav-company {
  margin-left: 6px;
  padding-left: 14px;
  border-left: 1px solid var(--border-subtle);
  overflow: hidden;
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Phones: the top bar is just menu, logo and the clock button (Tanner 2026-09-28). */
@media (max-width: 767px) { .nav-company, .nav-clock-status { display: none; } }
/* Kept for page headers that use it as a subtitle. */
.nav-tagline {
  margin-left: 8px;
  padding-left: 12px;
  border-left: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.nav-icon-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
}
.nav-icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-icon-btn .material-symbols-outlined { font-size: 18px; }
/* Unread notifications: dot on the phone menu button. */
.nav-unread-dot {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--surface-1);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: var(--sidebar-width);
  padding: 8px;
  background: var(--surface-1);
  border-right: 1px solid var(--border-subtle);
  overflow-y: auto;
}
.sidebar-title {
  display: flex;
  align-items: center;
  height: 30px;
  margin: 4px 0 0;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.sidebar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  margin: 1px 0;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.sidebar-row:hover { background: var(--surface-2); color: var(--text-primary); }
.sidebar-row.active { background: var(--accent-subtle); color: var(--text-primary); }
.sidebar-row-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
}
.sidebar-row-icon .material-symbols-outlined { font-size: 17px; }
.sidebar-row-icon .nav-boxers-icon { width: 17px; height: 17px; }
.sidebar-row.active .sidebar-row-icon { background: var(--accent-subtle); color: var(--accent); }
.sidebar-count {
  margin-left: auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
/* Notifications: slides in from the right edge, full width on phones. */
.notif-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  overflow-y: auto;
  border-width: 0 0 0 1px;
  transition: transform 180ms ease;
}
.notif-panel-out { transform: translateX(100%); }
/* Phones: a popup card under the top bar, not a full-screen page (Tanner 2026-09-28). */
@media (max-width: 767px) {
  .notif-panel {
    top: calc(var(--nav-height) + env(safe-area-inset-top, 0px) + 8px);
    left: 12px;
    right: 12px;
    bottom: auto;
    width: auto;
    max-height: 70dvh;
    border-width: 1px;
    border-radius: var(--radius-md);
    transition: transform 180ms ease, opacity 180ms ease;
  }
  .notif-panel-out { transform: translateY(-8px); opacity: 0; }
}
.sidebar-divider { height: 1px; margin: 8px 0; background: var(--border-subtle); flex-shrink: 0; }
.sidebar-footer {
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 8px;
  min-width: 0;
}
.sidebar-user .avatar { width: 30px; height: 30px; font-size: 12px; }
.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--accent-dim);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
}

/* ---- Page header + buttons (BluePatch .main-header) --------------------- */

.page-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.search-box { position: relative; display: flex; align-items: center; flex: 0 1 320px; min-width: 200px; height: 32px; }
.search-box .material-symbols-outlined {
  position: absolute;
  left: 8px;
  font-size: 16px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input,
.select-input {
  width: 100%;
  height: 32px;
  padding: 0 8px 0 30px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13px;
}
.select-input { width: auto; padding: 0 8px; }
.btn-primary,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 32px;
  padding: 0 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--surface-base);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.btn:hover { border-color: var(--border-accent); color: var(--text-primary); }
.btn-primary {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { background: var(--accent); }
/* Every existing "bg-primary text-on-primary" button gets the same look. */
.bg-primary.text-on-primary { background: var(--accent-dim); border: 1px solid var(--accent); color: #fff; }
.bg-primary.text-on-primary:hover { background: var(--accent); opacity: 1; }
.btn .material-symbols-outlined,
.btn-primary .material-symbols-outlined { font-size: 16px; }

/* ---- Project launcher grid (BluePatch .project-card) -------------------- */

.project-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: 16px;
}
.project-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  overflow: hidden;
  color: inherit;
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-lift), box-shadow var(--transition-lift), border-color var(--transition-fast);
}
.project-card:hover {
  transform: translateY(-3px) scale(1.015);
  border-color: var(--border-strong);
  box-shadow: var(--card-shadow-lift);
  z-index: 2;
}
.project-card.is-paused { opacity: 0.6; }
.project-card-thumb {
  position: relative;
  height: 96px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(120% 140% at 0% 0%, color-mix(in srgb, var(--tone, var(--surface-3)) 34%, transparent) 0%, transparent 70%),
    linear-gradient(135deg, var(--surface-3) 0%, var(--surface-2) 100%);
  border-bottom: 1px solid var(--border-subtle);
  color: color-mix(in srgb, var(--tone, var(--text-muted)) 70%, var(--text-primary));
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  overflow: hidden;
}
.project-card-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.project-card-body { display: flex; flex-direction: column; gap: 2px; padding: 12px 12px 8px; min-width: 0; }
.project-card-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.project-card-meta {
  font-size: 12px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.project-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle);
}
.project-card-status {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-card-open {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-muted);
  font-size: 12px;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.project-card:hover .project-card-open { background: var(--accent-subtle); color: var(--accent); }
.project-card-flag {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 1;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--status-warn);
  color: #1A1A1F;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
/* One segment per work stage: done = accent, in progress = warn. */
.stage-segments { display: flex; gap: 2px; padding: 0 12px 10px; }
.stage-segments span { flex: 1; height: 3px; border-radius: 1px; background: var(--surface-3); }
.stage-segments .is-done { background: var(--accent); }
.stage-segments .is-in_progress { background: var(--status-warn); }

.new-project-card {
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 168px;
  border: 1px dashed var(--border-default);
  background: transparent;
  box-shadow: none;
  color: var(--text-muted);
}
.new-project-card:hover {
  border-color: var(--border-accent);
  background: var(--accent-subtle);
  color: var(--text-secondary);
  transform: none;
  box-shadow: none;
}
.new-project-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-default);
  font-size: 16px;
}

.status-dot { width: 6px; height: 6px; flex-shrink: 0; border-radius: 50%; background: var(--status-ok); }
.status-dot.is-warn { background: var(--status-warn); }
.status-dot.is-offline { background: var(--status-offline); }
.status-dot.is-done { background: var(--accent); }
.status-dot.is-idle { background: var(--text-muted); }

/* Status-bar style summary line (BluePatch .status-bar items). */
.stat-line { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; font-size: 12px; color: var(--text-secondary); }
.stat-line b { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-line .stat-divider { width: 1px; height: 12px; background: var(--border-subtle); }

/* ---- Schematic editor pieces (BluePatch SchematicPage) ------------------ */

/* Split view under a .page-header: optional library (left), canvas, inspector (right). */
.workspace { display: flex; min-height: calc(100dvh - var(--nav-height) - 57px); }
.workspace-main { flex: 1; min-width: 0; }
.library-panel,
.inspector-panel {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  width: 280px;
  background: var(--surface-1);
}
.library-panel { gap: 4px; padding: 8px; border-right: 1px solid var(--border-subtle); }
.inspector-panel { border-left: 1px solid var(--border-subtle); }
/* Laptop widths: the inspector drops under the main area so wide content (site tree) keeps the room. */
@media (min-width: 1024px) and (max-width: 1535px) {
  .workspace:has(> .inspector-panel:not(.is-rail)) { flex-direction: column; }
  .inspector-panel:not(.is-rail) { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); width: auto; border-left: 0; border-top: 1px solid var(--border-subtle); }
  .inspector-panel .inspector-section { border-right: 1px solid var(--border-subtle); }
}
@media (max-width: 1023px) {
  .workspace { flex-direction: column; min-height: 0; }
  .library-panel, .inspector-panel { width: auto; border: 0; border-bottom: 1px solid var(--border-subtle); }
  .inspector-panel { border-top: 1px solid var(--border-subtle); }
}
.library-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 26px;
  margin: 0;
  padding: 0 4px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.library-card {
  display: block;
  width: 100%;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  text-align: left;
  transition: border-color var(--transition-fast), background var(--transition-fast);
}
.library-card:hover { background: var(--surface-2); border-color: var(--border-default); }
.library-card[aria-pressed="true"] { background: var(--accent-subtle); border-color: var(--border-accent); }
.library-card-title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.library-card-meta { margin-top: 2px; font-size: 12px; font-variant-numeric: tabular-nums; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Inspector: stacked sections, each an uppercase header + key/value rows. */
.inspector-section { border-bottom: 1px solid var(--border-subtle); }
.inspector-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.kv { display: grid; grid-template-columns: 104px minmax(0, 1fr); gap: 8px; margin: 0; padding: 5px 12px; font-size: 13px; }
.kv dt { color: var(--text-muted); }
.kv dd { margin: 0; color: var(--text-primary); overflow-wrap: anywhere; }
.kv:last-child { padding-bottom: 12px; }
.metric-grid { display: grid; grid-template-columns: 1fr 1fr; }
.metric { padding: 10px 12px; border-top: 1px solid var(--border-subtle); }
.metric:nth-child(odd) { border-right: 1px solid var(--border-subtle); }
.metric b { display: block; font-family: var(--font-mono); font-size: 17px; font-weight: 500; letter-spacing: -0.02em; color: var(--text-primary); }
.metric span { font-size: 12px; color: var(--text-muted); }
/* Clickable count tiles (customer page): plain Geist figures, not mono. */
.metric-grid.is-tiles { grid-template-columns: repeat(3, 1fr); }
.metric-grid.is-tiles .metric { display: block; text-align: left; border-right: 1px solid var(--border-subtle); transition: background var(--transition-fast); }
.metric-grid.is-tiles .metric:last-child { border-right: 0; }
.metric-grid.is-tiles .metric:hover, .metric-grid.is-tiles .metric.is-on { background: var(--surface-3); }
.metric-grid.is-tiles .metric.is-on span { color: var(--accent); }
.metric-grid.is-tiles .metric b { font-family: inherit; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric-list { padding: 4px 0 8px; border-top: 1px solid var(--border-subtle); }

/* Canvas: the open work area under a page header. */
.canvas { position: relative; padding: 32px 20px; background: var(--surface-base); }
@media (max-width: 767px) { .canvas { padding: 16px; } }

.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 32px;
  padding: 0 8px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}
.tool-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition-fast), color var(--transition-fast);
}
.tool-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.tool-btn .material-symbols-outlined { font-size: 14px; }

/* Device card: brand row, mono model row, port-style rows, identifier footer. */
.device-card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--card-shadow);
  transition: transform var(--transition-lift), box-shadow var(--transition-lift), border-color var(--transition-fast);
}
.device-card.is-lift:hover { transform: translateY(-3px); box-shadow: var(--card-shadow-lift); border-color: var(--border-strong); }
.device-card.is-selected { border-color: var(--border-accent); box-shadow: 0 0 0 1px var(--accent-glow), var(--card-shadow-lift); }
.device-media { position: relative; height: 160px; flex-shrink: 0; background: var(--surface-3); border-bottom: 1px solid var(--border-subtle); overflow: hidden; border-radius: var(--radius-md) var(--radius-md) 0 0; }
.device-media iframe, .device-media img { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; object-fit: cover; }
.device-brand { display: flex; align-items: center; gap: 8px; min-height: 36px; padding: 12px 12px 0; font-size: 15px; font-weight: 600; letter-spacing: -0.015em; color: var(--text-primary); }
.device-model {
  padding: 2px 12px 12px;
  font-size: 13px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-subtle);
}
.device-section { padding: 6px 0; border-bottom: 1px solid var(--border-subtle); }
.device-section:last-child { border-bottom: 0; }
.device-section-label { padding: 4px 12px 4px; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.port-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 30px;
  padding: 0 12px;
  font-size: 13px;
  color: var(--text-primary);
  text-align: left;
  transition: background var(--transition-fast);
}
a.port-row:hover, button.port-row:hover { background: var(--surface-3); }
.port-row .port-meta { margin-left: auto; padding-left: 8px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.port-row .port-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.port-dot { width: 7px; height: 7px; flex-shrink: 0; border-radius: 50%; border: 1.5px solid var(--border-default); background: var(--accent); }
.port-dot.is-warn { background: var(--status-warn); }
.port-dot.is-ok { background: var(--status-ok); }
.port-dot.is-idle { background: transparent; border-color: var(--text-muted); }
.avatar.is-sm { width: 18px; height: 18px; font-size: 8px; }
.device-identifier {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 36px;
  margin-top: auto;
  padding: 0 12px;
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.device-identifier a:hover { color: var(--accent); }

/* Zones (BluePatch canvas-zone): tinted box with an uppercase header strip. */
.zone { margin: 8px 12px; border: 1px solid; border-radius: var(--radius-md); font-size: 13px; overflow: hidden; }
.zone-header { display: flex; align-items: center; gap: 6px; height: 24px; padding: 0 8px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.zone-header .material-symbols-outlined { font-size: 13px; }
.zone-body { padding: 6px 8px 8px; white-space: pre-line; overflow-wrap: anywhere; color: var(--text-primary); }
.zone-warn { background: rgba(190, 120, 40, 0.06); border-color: rgba(190, 120, 40, 0.32); }
.zone-warn .zone-header { background: rgba(190, 120, 40, 0.16); color: var(--status-warn); }
.zone-room { background: rgba(52, 120, 200, 0.06); border-color: rgba(52, 120, 200, 0.32); }
.zone-room .zone-header { background: rgba(52, 120, 200, 0.16); color: var(--accent); }
.zone-error { background: var(--error-subtle); border-color: rgba(192, 74, 74, 0.4); }
.zone-error .zone-header { background: rgba(192, 74, 74, 0.2); color: var(--error-text); }

/* Wires: company node to site nodes, org-chart style, BluePatch wire colour.
   Every wire is 2px and centred on its point with calc(50% - 1px), ports are
   10px centred with -5px, so lines and dots line up at any display scaling. */
.wire-tree { --wire: #2E5F9E; }
.wire-stem { width: 2px; height: 40px; margin: 0 auto; background: var(--wire); }
.wire-branches { display: flex; justify-content: safe center; align-items: stretch; gap: 24px; overflow-x: auto; padding: 0 4px 8px; }
.wire-branch { position: relative; display: flex; flex: 1 1 0; min-width: 224px; max-width: 360px; padding-top: 40px; }
.wire-branch > .device-card { flex: 1; min-width: 0; }
.wire-branch::after { content: ""; position: absolute; top: 0; left: -12px; right: -12px; height: 2px; background: var(--wire); }
.wire-branch:first-child::after { left: calc(50% - 1px); }
.wire-branch:last-child::after { right: calc(50% - 1px); }
.wire-branch:only-child::after { display: none; }
/* The drop line and the port are both drawn on the card, so they round to
   the same pixel at any display scaling. */
.wire-branch > .device-card::after { content: ""; position: absolute; top: -41px; left: calc(50% - 1px); width: 2px; height: 41px; background: var(--wire); }
/* Port where each wire lands on a card. */
.wire-branch > .device-card::before,
.wire-root::after {
  content: "";
  position: absolute;
  left: calc(50% - 5px);
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface-base);
  z-index: 1;
}
.wire-branch > .device-card::before { top: -5px; }
.wire-root::after { bottom: -5px; }
@media (max-width: 767px) {
  /* Phone: one spine down the left, a short arm into each card. The spine is
     drawn per branch so it stops at the last arm instead of running on. */
  .wire-stem { margin: 0 0 0 23px; height: 24px; }
  .wire-branches { flex-direction: column; gap: 0; overflow: visible; margin-left: 24px; padding: 0; }
  .wire-branch { flex: none; min-width: 0; max-width: none; padding: 24px 0 0 24px; }
  .wire-branch > .device-card::after { top: 39px; left: -25px; width: 24px; height: 2px; }
  .wire-branch::after { top: 0; bottom: 0; left: -1px; right: auto; width: 2px; height: auto; }
  .wire-branch:first-child::after { left: -1px; }
  .wire-branch:last-child::after { right: auto; bottom: auto; height: 66px; }
  .wire-branch:only-child::after { display: block; }
  .wire-branch > .device-card::before { top: 35px; left: -5px; }
  .wire-root::after { left: 18px; }
  .wire-tree > .device-card.is-node { margin-left: 0; }
}

/* Person card (macros.person_card): one contact, same on every page. */
.person-card { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 10px; padding: 10px 12px; border-top: 1px solid var(--border-subtle); font-size: 13px; }
.device-section-label + .person-card { border-top: 0; }
.person-card[role="button"] { cursor: pointer; transition: background var(--transition-fast); }
.person-card[role="button"]:hover { background: var(--surface-3); }
.person-card[draggable="true"] { cursor: grab; }
.person-card > .avatar { margin-top: 2px; }
.person-card-body { flex: 1 1 150px; min-width: 0; }
.person-card-name { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text-primary); }
.person-card-main { display: inline-flex; align-items: center; gap: 2px; flex-shrink: 0; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }
.person-card-main .material-symbols-outlined { font-size: 13px; font-variation-settings: "FILL" 1; }
.person-card-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; line-height: 18px; color: var(--text-muted); }
.person-card-line.is-reach { color: var(--text-secondary); }
.person-card-line a:hover { color: var(--accent); }
.person-card-actions { display: flex; gap: 4px; flex-shrink: 0; margin-left: auto; }
.icon-action { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border: 1px solid var(--border-default); border-radius: var(--radius-sm); color: var(--text-secondary); transition: background var(--transition-fast), color var(--transition-fast); }
.icon-action:hover { background: var(--surface-3); color: var(--accent); border-color: var(--border-strong); }
.icon-action .material-symbols-outlined { font-size: 16px; }

/* Paper-preview tiles (sales orders, files) on project-card chrome. */
.thumb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; }
.thumb-card .project-card-thumb { height: 180px; }
.thumb-card .project-card-thumb.is-paper { background: #fff; }
.thumb-card .project-card-thumb img { object-position: top; }

/* ---- Panels: a device card used as a page section ----------------------- */

.panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--card-shadow);
}
.panel-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.panel-title { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.01em; color: var(--text-primary); }
.panel-title .material-symbols-outlined { font-size: 16px; color: var(--text-muted); }
.panel-header > .panel-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
/* Phones: header buttons that don't fit swipe sideways instead of running off the card. */
@media (max-width: 767px) {
  .panel-header > .panel-title { flex-shrink: 0; }
  .panel-header > .panel-actions { min-width: 0; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .panel-header > .panel-actions::-webkit-scrollbar { display: none; }
  .panel-header > .panel-actions > * { flex-shrink: 0; white-space: nowrap; }
}
.panel-body { padding: 14px; }
.panel-empty { padding: 20px 14px; font-size: 13px; color: var(--text-muted); text-align: center; }
.panel-grid { display: grid; gap: 16px; }

/* Job log (project page): underline tabs in a panel header, then an entry
   row of labelled inputs that wraps on phones. */
.log-tabs { display: flex; align-self: stretch; overflow-x: auto; }
.log-tabs > button { display: flex; align-items: center; gap: 6px; padding: 0 14px; border-bottom: 2px solid transparent; font-size: 13px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.log-tabs > button:hover { color: var(--text-primary); }
.log-tabs > button.is-on { border-bottom-color: var(--accent); color: var(--text-primary); }
.log-tab-count { font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.log-entry { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); background: var(--surface-1); }
.log-entry > .field { flex: 1 1 140px; }
.log-entry > .field.is-wide { flex: 3 1 200px; }
.log-entry > .field.is-narrow { flex: 0 1 110px; }
.log-entry > .btn, .log-entry > .btn-primary { height: 32px; }
.log-entry-readout { display: flex; align-items: center; height: 32px; margin: 0; font-size: 13px; }
.data-table tfoot td { height: 34px; padding: 4px 14px; border-top: 1px solid var(--border-default); font-weight: 500; }

/* Dense data table inside a panel. */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 30px;
  padding: 0 14px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-align: left;
}
.data-table td { height: 34px; padding: 4px 14px; border-bottom: 1px solid var(--border-subtle); font-variant-numeric: tabular-nums; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table .num { text-align: right; }

/* File tiles (scope, sales orders, attachments, notes). */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 12px; }
.tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-3);
  color: var(--text-muted);
  text-align: center;
  transition: border-color var(--transition-fast), transform var(--transition-lift);
}
.tile:hover { border-color: var(--border-accent); transform: translateY(-2px); }
.tile.is-empty { border-style: dashed; background: transparent; }
.tile.is-empty:hover { background: var(--accent-subtle); }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.tile .material-symbols-outlined { font-size: 28px; }
.tile-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 8px 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.72), transparent);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

/* Segmented control (BluePatch tool-btn group). */
.seg { display: inline-flex; padding: 2px; gap: 2px; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-1); }
.seg > button, .seg > a { height: 24px; padding: 0 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.seg > a { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.seg > button:hover, .seg > a:hover { color: var(--text-primary); }
/* Tickets filter: Urgent goes amber and pulses while any are open. */
.seg > a.is-alert { color: var(--status-warn); animation: alive-pulse 1.6s ease-in-out infinite; }
.seg > button.is-on, .seg > a.is-on { background: var(--accent-subtle); color: var(--accent); box-shadow: inset 0 0 0 1px var(--border-accent); }

/* Toolbar band under a page header (work stages, calendar controls). */
.band {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

/* Choice row: a port-row that holds a radio (main contact). */
.choice-row { cursor: pointer; border-left: 2px solid transparent; }
.choice-row:hover { background: var(--surface-3); }
.choice-row.is-on { border-left-color: var(--accent); background: var(--accent-subtle); }
.choice-row input[type="radio"] { accent-color: var(--accent); margin: 0; }

/* Rail: an inspector that holds a feed (activity) and stays in view. */
/* Phones: the contact page's Main office pane opens as a popup from the bottom (contacts/detail.html). */
@media (max-width: 767px) {
  .office-sheet { display: none; }
  .office-sheet.is-open {
    display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
    max-height: 85dvh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--surface-1); border-top: 1px solid var(--border-default); border-radius: var(--radius-md) var(--radius-md) 0 0;
  }
}
.inspector-panel.is-rail { width: 340px; }
@media (min-width: 1024px) {
  .inspector-panel.is-rail { position: sticky; top: 0; align-self: flex-start; height: calc(100dvh - var(--nav-height) - 57px); }
}
/* Activity feed (chat-style): one avatar + name per run of entries by a
   person; each change is a line with a coloured icon (jobs.tone) and its
   picture: file thumbnails, a date block + crew for visits, a note tile. */
.act-feed { padding: 0 12px 12px; }
.act-day { display: flex; align-items: center; gap: 8px; margin: 14px 0 6px; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.act-day::after { content: ""; flex: 1; height: 1px; background: var(--border-subtle); }
.act-group { display: flex; gap: 10px; padding: 8px 0; }
.act-avatar { flex-shrink: 0; }
.act-body { flex: 1; min-width: 0; }
.act-head { display: flex; align-items: baseline; gap: 8px; min-height: 28px; padding-top: 4px; }
.act-name { font-size: 14px; font-weight: 600; color: var(--text-primary); }
.act-time { margin-left: auto; font-size: 12px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.act-item { display: flex; gap: 8px; padding: 4px 0; }
.act-icon { flex-shrink: 0; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--surface-3); color: var(--text-secondary); }
.act-icon .material-symbols-outlined { font-size: 14px; }
.act-icon.tone-added { background: color-mix(in srgb, var(--status-ok) 22%, transparent); color: var(--status-ok); }
.act-icon.tone-removed { background: var(--error-subtle); color: var(--error-text); }
.act-icon.tone-warn { background: color-mix(in srgb, var(--status-warn) 22%, transparent); color: var(--status-warn); }
.act-icon.tone-stage, .act-icon.tone-schedule { background: var(--accent-subtle); color: var(--accent); }
.act-main { flex: 1; min-width: 0; padding-top: 1px; }
.act-text { font-size: 14px; line-height: 20px; color: var(--text-primary); }
.act-muted { font-size: 13px; line-height: 18px; color: var(--text-muted); }
.act-quote { margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--border-strong); font-size: 13px; color: var(--text-secondary); }
.act-thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.act-thumb { position: relative; display: flex; align-items: center; justify-content: center; width: 76px; height: 76px; overflow: hidden; border: 1px solid var(--border-default); border-radius: var(--radius-md); background: var(--surface-2); color: var(--text-secondary); }
.act-thumb:hover { border-color: var(--border-accent); }
.act-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; }
.act-thumb .material-symbols-outlined { font-size: 26px; }
.act-thumb-name { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 4px 3px; font-size: 10px; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: linear-gradient(transparent, rgba(0, 0, 0, 0.75)); }
.act-visit { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding: 6px 8px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-2); }
.act-visit.is-off { opacity: 0.6; }
.act-visit.is-off .act-cal b { text-decoration: line-through; }
.act-cal { flex-shrink: 0; display: flex; flex-direction: column; align-items: center; width: 38px; overflow: hidden; border: 1px solid var(--border-strong); border-radius: var(--radius-md); background: var(--surface-1); }
.act-cal span { width: 100%; padding: 1px 0; font-size: 9px; font-weight: 600; letter-spacing: 0.06em; text-align: center; text-transform: uppercase; color: var(--on-accent); background: var(--accent); }
.act-cal b { font-size: 16px; line-height: 22px; font-weight: 600; color: var(--text-primary); }
.act-crew { display: flex; align-items: center; gap: 3px; margin-top: 3px; min-width: 0; }
.act-crew .act-muted { margin-left: 4px; font-size: 12px; }
.act-note { display: flex; align-items: center; gap: 6px; max-width: 100%; margin-top: 6px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-2); font-size: 14px; color: var(--text-primary); text-align: left; }
button.act-note:hover { border-color: var(--border-accent); }
.act-note .material-symbols-outlined { font-size: 18px; color: var(--status-ok); }
.act-msg { margin: 2px 0 4px; padding: 8px 10px; border: 1px solid var(--border-default); border-radius: var(--radius-lg); background: var(--surface-2); font-size: 14px; }
.act-msg.is-note { background: var(--accent-subtle); border-color: var(--border-accent); }
.act-tag { margin-bottom: 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); }

/* ==== Forms, settings, people, cost report, login =========================== */
/* Admin pages (Settings, People, Cost Report, Report a Bug, Log in).
   Token-only, built on app.css; to be folded into app.css. */

/* ---- Form fields ------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.field-help { margin: 0; font-size: 12px; line-height: 1.45; color: var(--text-muted); }
.field-input {
  width: 100%;
  height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-1);
  color: var(--text-primary);
  font-size: 13px;
}
textarea.field-input { height: auto; padding: 8px 10px; line-height: 1.5; resize: vertical; }
.field-input.is-sm { height: 28px; padding: 0 8px; }
.field-input.is-num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
/* Borderless until touched: inline-edit cells in a list. */
.field-input.is-quiet { border-color: transparent; background: transparent; }
.field-input.is-quiet:hover { border-color: var(--border-default); }
.field-input.is-quiet:focus { background: var(--surface-1); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-secondary); white-space: nowrap; cursor: pointer; }
.check input { width: 14px; height: 14px; margin: 0; accent-color: var(--accent); }
.btn.is-danger { color: var(--error-text); }
.btn.is-danger:hover { border-color: var(--status-error); background: var(--error-subtle); }
.tool-btn.is-danger:hover { color: var(--error-text); background: var(--error-subtle); }
.tool-btn:disabled { opacity: 0.3; pointer-events: none; }
.tool-btn.is-icon { width: 26px; padding: 0; justify-content: center; }

/* Flash line under a page header. */
.flash { margin: 0; padding: 8px 20px; font-size: 13px; border-bottom: 1px solid var(--border-subtle); }
.flash.is-ok { background: var(--accent-subtle); color: var(--text-primary); }
.flash.is-error { background: var(--error-subtle); color: var(--error-text); }

/* ---- Preferences layout: section nav (left) + stacked panels ----------- */
.pref-nav .library-card { display: flex; align-items: center; gap: 8px; }
.pref-nav .library-card .material-symbols-outlined { font-size: 16px; color: var(--text-muted); }
.pref-nav .library-card[aria-pressed="true"] .material-symbols-outlined { color: var(--accent); }
@media (min-width: 1024px) {
  .pref-nav { position: sticky; top: 0; align-self: flex-start; width: 240px; height: calc(100dvh - var(--nav-height) - 57px); }
}
@media (max-width: 1023px) {
  .pref-nav { flex-direction: row; overflow-x: auto; padding: 6px 12px; }
  .pref-nav .library-title { display: none; }
  .pref-nav .library-card { width: auto; flex-shrink: 0; }
}
.pref-stack { display: flex; flex-direction: column; gap: 16px; padding: 20px; }
.pref-stack > .panel { scroll-margin-top: 16px; }
@media (max-width: 767px) { .pref-stack { padding: 12px; } }

/* A settings row: what it is (left) and the control (right). */
.setting-row {
  display: grid;
  grid-template-columns: minmax(180px, 280px) minmax(0, 1fr);
  gap: 16px 32px;
  padding: 16px 14px;
  border-bottom: 1px solid var(--border-subtle);
}
.setting-row:last-child { border-bottom: 0; }
.setting-row-title { margin: 0 0 2px; font-size: 13px; font-weight: 600; color: var(--text-primary); }
.setting-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: 12px; align-items: end; max-width: 720px; }
.setting-actions { display: flex; align-items: center; gap: 12px; grid-column: 1 / -1; }
@media (max-width: 767px) { .setting-row { grid-template-columns: 1fr; gap: 10px; } }

/* Ordered list rows joined by a thin wire through their dots (work stages). */
.seq-list { position: relative; }
.seq-row { position: relative; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 8px 0 14px; border-bottom: 1px solid var(--border-subtle); }
.seq-row:hover { background: var(--surface-3); }
.seq-row::before { content: ""; position: absolute; left: 43px; top: 0; bottom: 0; width: 1px; background: var(--border-strong); }
.seq-row:first-child::before { top: 50%; }
.seq-row:last-child::before { bottom: 50%; }
.seq-row:only-child::before { display: none; }
.seq-num { width: 14px; flex-shrink: 0; font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); text-align: right; }
.seq-row .port-dot { position: relative; z-index: 1; margin: 0 4px; border-color: var(--surface-2); background: var(--surface-3); box-shadow: 0 0 0 1px var(--border-strong); }
.seq-row .port-dot.is-ok { background: var(--status-ok); box-shadow: none; }
.seq-row form { display: contents; }
.seq-tools { display: flex; align-items: center; gap: 2px; margin-left: auto; }

/* Permission matrix: dense, first column pinned, ticks centred. */
.matrix { width: 100%; border-collapse: collapse; font-size: 13px; }
.matrix th, .matrix td { height: 32px; padding: 0 12px; border-bottom: 1px solid var(--border-subtle); text-align: center; white-space: nowrap; }
.matrix thead th { background: var(--surface-1); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); vertical-align: bottom; padding-top: 8px; padding-bottom: 6px; }
.matrix thead th small { display: block; font-size: 11px; font-weight: 400; letter-spacing: 0; text-transform: none; font-variant-numeric: tabular-nums; }
.matrix th:first-child, .matrix td:first-child { position: sticky; left: 0; z-index: 1; text-align: left; background: var(--surface-2); border-right: 1px solid var(--border-subtle); }
.matrix thead th:first-child { background: var(--surface-1); }
.matrix tbody tr:hover td { background: var(--surface-3); }
.matrix td + td, .matrix th + th { border-left: 1px solid var(--border-subtle); }
.matrix input[type="checkbox"] { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); vertical-align: middle; }
.matrix tr.matrix-group td { height: 28px; padding-top: 8px; background: var(--surface-1); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); text-align: left; }
.matrix tfoot td { height: 40px; background: var(--surface-1); border-bottom: 0; }

/* Row with an avatar, name over a muted line (people, trash). */
.ident { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ident .avatar { width: 28px; height: 28px; font-size: 11px; }
.ident-name { display: block; font-size: 13px; font-weight: 500; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ident-meta { display: block; font-size: 12px; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar.is-off { background: var(--surface-3); color: var(--text-muted); }
.data-table tr.is-link { cursor: pointer; }
.data-table tr.is-link:hover td { background: var(--surface-3); }
.data-table tr.is-dim td { color: var(--text-muted); }

/* ---- Cost Report ------------------------------------------------------- */
.cost-summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 16px 40px;
  align-items: center;
  padding: 16px 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
}
.cost-key b { display: block; font-family: var(--font-mono); font-size: 30px; font-weight: 500; line-height: 1.15; letter-spacing: -0.03em; color: var(--status-ok); font-variant-numeric: tabular-nums; }
.cost-key b.is-loss { color: var(--error-text); }
.cost-key span { font-size: 12px; color: var(--text-muted); }
.cost-key span b { display: inline; font-size: 12px; letter-spacing: 0; color: var(--text-secondary); }
/* Contract split: where each contract dollar went. */
.cost-bar { display: flex; height: 8px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-3); }
.cost-bar > span { height: 100%; }
.cost-bar > span + span { border-left: 1px solid var(--surface-1); }
.cost-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 8px; font-size: 12px; color: var(--text-muted); }
.cost-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.cost-legend b { font-family: var(--font-mono); font-weight: 500; color: var(--text-primary); }
.swatch { width: 8px; height: 8px; flex-shrink: 0; border-radius: 1px; }
.is-labor { background: var(--accent); }
.is-expense { background: var(--status-warn); }
.is-profit { background: var(--status-ok); }
.is-over { background: var(--status-error); }
.cost-contract { display: flex; align-items: end; gap: 8px; }
.cost-contract .field-input { width: 140px; }
@media (max-width: 1023px) {
  .cost-summary { grid-template-columns: 1fr; gap: 14px; padding: 14px 16px; }
}

/* Job health (R1): expected profit in dollars, where the price goes, what needs doing. */
.health { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px 48px; align-items: center; padding: 20px; background: var(--surface-1); border-bottom: 1px solid var(--border-subtle); --tone: var(--status-ok); }
.health.is-amber { --tone: var(--status-warn); }
.health.is-red { --tone: var(--status-error); }
.health.is-none { --tone: var(--text-muted); }
.health-key .eyebrow { display: flex; align-items: center; gap: 6px; color: var(--tone); }
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.health-label { display: block; margin-top: 6px; font-size: 13px; color: var(--text-secondary); }
.health-key > b { display: block; font-family: var(--font-mono); font-size: 34px; font-weight: 500; line-height: 1.15; letter-spacing: -0.03em; color: var(--tone); font-variant-numeric: tabular-nums; }
.health-vs { display: block; font-size: 13px; color: var(--text-muted); }
.health-vs em { font-style: normal; color: var(--status-warn); }
.health-vs em.is-up { color: var(--status-ok); }
.cost-bar.is-tall { height: 14px; }
.health .cost-legend { font-size: 13px; }
.is-spent { background: var(--accent); }
.is-tax { background: var(--border-strong); }
/* Budget with actual spend filled in over it (one bar). */
.plan-bar { position: relative; }
.plan-fill { position: absolute; top: 0; left: 0; height: 100%; border-radius: var(--radius-sm) 0 0 var(--radius-sm); }
.plan-fill.is-over { border-radius: 0; }
.plan-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; font-size: 12px; color: var(--text-muted); }
.plan-head b { font-family: var(--font-mono); font-size: 15px; font-weight: 500; color: var(--text-primary); }
.plan-labels { display: flex; margin-top: 6px; }
.plan-labels > span { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; padding-right: 8px; }
.plan-labels > span.is-end { align-items: flex-end; padding-right: 0; }
.plan-labels em { font-size: 11px; font-style: normal; color: var(--text-muted); }
.plan-labels b { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-primary); }
/* Hovering the bar pops up the amount spent, above where the fill ends. */
.plan-pop { position: absolute; bottom: calc(100% + 8px); transform: translateX(-50%); display: none; padding: 6px 10px; white-space: nowrap; font-size: 12px; color: var(--text-secondary); background: var(--surface-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); z-index: 5; }
.plan-pop b { font-family: var(--font-mono); font-weight: 500; color: var(--text-primary); }
.plan-pop em { display: block; font-style: normal; font-size: 11px; color: var(--text-muted); }
.plan-bar:hover .plan-pop { display: block; }
.plan-bar { cursor: default; }
.cost-bar > .is-spent.is-plan { background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--border-accent); }
.is-over-text { color: var(--error-text) !important; }
.is-under-text { color: var(--status-ok); }
.health-how { border-top: 1px solid var(--border-subtle); padding: 10px 14px; font-size: 12px; color: var(--text-muted); }
.health-how summary { cursor: pointer; color: var(--text-secondary); }
.health-how ul { margin-top: 8px; display: grid; gap: 4px; }
.health-how b { color: var(--text-secondary); font-weight: 600; }
/* Hours used per labor row: fills to 100%, amber from 90%, red past budget. */
.burn { display: flex; align-items: center; gap: 10px; --tone: var(--accent); }
.burn.is-close { --tone: var(--status-warn); }
.burn.is-overrun { --tone: var(--status-error); }
.burn-track { flex: 1; min-width: 80px; height: 8px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-3); }
.burn-track > span { display: block; height: 100%; background: var(--tone); }
.burn em { flex-shrink: 0; min-width: 60px; font-size: 12px; font-style: normal; text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.health-reasons { padding: 10px 14px; border-top: 1px solid var(--border-subtle); }
.health-reasons ul { display: flex; flex-wrap: wrap; gap: 6px 24px; margin-top: 6px; font-size: 13px; color: var(--text-secondary); }
.health-reasons li { display: inline-flex; gap: 8px; }
.health-reasons b { color: var(--text-primary); font-weight: 500; }
@media (max-width: 1023px) { .health { grid-template-columns: 1fr; gap: 14px; padding: 16px; } }

/* Metric strip across the page (metric-grid in a row). */
.metric-grid.is-row { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); border-bottom: 1px solid var(--border-subtle); }
.metric-grid.is-row .metric { border-top: 0; border-right: 1px solid var(--border-subtle); padding: 10px 20px; }
.metric-grid.is-row .metric:last-child { border-right: 0; }
.metric small { display: block; font-size: 11px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
@media (max-width: 767px) {
  .metric-grid.is-row { grid-template-columns: 1fr 1fr; }
  .metric-grid.is-row .metric { padding: 10px 16px; border-bottom: 1px solid var(--border-subtle); }
  .metric-grid.is-row .metric:nth-child(even) { border-right: 0; }
}
.money { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Add-a-line strip at the top of a ledger panel. */
.ledger-add { display: grid; grid-template-columns: 150px minmax(140px, 1fr) 96px 110px minmax(140px, 2fr) auto; gap: 8px; padding: 10px 14px; background: var(--surface-1); border-bottom: 1px solid var(--border-subtle); }
@media (max-width: 1023px) { .ledger-add { grid-template-columns: 1fr 1fr; } .ledger-add > .is-wide { grid-column: 1 / -1; } }
.data-table td.is-actions { width: 1%; white-space: nowrap; text-align: right; }
.data-table td.is-actions > * { display: inline-flex; vertical-align: middle; }
.data-table .field-input.is-sm { min-width: 64px; }

/* Login */
.login-shell { display: flex; min-height: 100dvh; align-items: center; justify-content: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); background: var(--surface-base); }
.login-card { width: 100%; max-width: 360px; }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }

/* Phone fixes for the preferences layout. */
@media (max-width: 767px) {
  .setting-row { grid-template-columns: minmax(0, 1fr); }
  .matrix td:first-child { white-space: normal; min-width: 150px; line-height: 1.3; padding-top: 6px; padding-bottom: 6px; }
  .seq-num { display: none; }
  .seq-row::before { left: 21px; }
  /* Stage name gets its own full line; Done / Save / arrows wrap under it instead of cutting the name off. */
  .seq-row { flex-wrap: wrap; row-gap: 0; padding-top: 4px; padding-bottom: 4px; }
  .seq-row .field-input { flex: 1 1 calc(100% - 32px); }
  .seq-row .check { margin-left: 24px; }
}
.field-input.is-num::placeholder { font-family: var(--font-sans); text-align: left; }
/* The activity rail spans the width once it drops under the page (phone/tablet). */
@media (max-width: 1023px) { .inspector-panel.is-rail { width: auto; } }

/* ==== Contacts: directory, customer profile ================================= */
/* Contacts (FEAT-051): initials tones, the A-Z directory, site-tree extras
   and plain form fields. Token-based so it can fold into app.css. */

/* Initials avatars: six tones picked by id, all from the palette. */
.avatar.tone-0 { background: var(--accent-dim); }
.avatar.tone-1 { background: color-mix(in srgb, var(--status-ok) 80%, var(--surface-base)); }
.avatar.tone-2 { background: color-mix(in srgb, var(--status-warn) 85%, var(--surface-base)); }
.avatar.tone-3 { background: color-mix(in srgb, var(--status-error) 85%, var(--surface-base)); }
.avatar.tone-4 { background: color-mix(in srgb, var(--accent) 55%, var(--status-error)); }
.avatar.tone-5 { background: color-mix(in srgb, var(--status-ok) 55%, var(--accent)); }
.avatar.is-md { width: 28px; height: 28px; font-size: 11px; }
.avatar.is-lg { width: 40px; height: 40px; font-size: 14px; }
.avatar.is-square { border-radius: var(--radius-md); }

/* A-Z directory: sticky letter strips over dense rows. */
.az-rail { display: flex; flex-wrap: wrap; gap: 2px; }
.az-rail a { display: flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 600; color: var(--text-muted); }
.az-rail a:hover { background: var(--surface-2); color: var(--accent); }
.dir-letter {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  height: 28px;
  padding: 0 20px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  scroll-margin-top: 0;
}
.dir-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 2fr) minmax(0, 1.2fr) 80px 80px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 16px;
  min-height: 56px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  color: var(--text-secondary);
  transition: background var(--transition-fast);
}
.dir-row:hover { background: var(--surface-1); }
.dir-row:hover .dir-go { color: var(--accent); }
.dir-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; color: var(--text-primary); }
.dir-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-muted); }
.dir-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dir-cell b { font-weight: 600; color: var(--text-primary); }
.dir-go { font-size: 16px; color: var(--text-muted); }
.dir-head { min-height: 30px; padding-top: 0; padding-bottom: 0; background: var(--surface-1); font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.dir-head:hover { background: var(--surface-1); }
@media (max-width: 767px) {
  .dir-row { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 12px; padding: 8px 16px; }
  .dir-row .dir-wide { display: none; }
  .dir-letter { padding: 0 16px; }
}

/* Site tree extras. */
.device-card.is-node { max-width: 560px; margin: 0 auto; }
.wire-tree .device-model { overflow-wrap: anywhere; }
.device-media.is-empty { display: flex; align-items: center; justify-content: center; height: 96px; color: var(--text-muted); }
.device-brand .tool-btn { margin-left: auto; margin-right: -8px; }
.drop-hint { padding: 4px 12px 6px; font-size: 12px; color: var(--text-muted); }
.section-strip { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 36px; padding: 0 12px 0 20px; background: var(--surface-1); border-top: 1px solid var(--border-subtle); border-bottom: 1px solid var(--border-subtle); }
.section-body { padding: 16px 20px 24px; }
@media (max-width: 767px) { .section-strip { padding-left: 16px; } .section-body { padding: 16px; } }
.thumb-drop { min-height: 220px; }
.thumb-drop.is-over { border-color: var(--border-accent); background: var(--accent-subtle); color: var(--accent); }
.thumb-card .project-card-footer { font-size: 12px; color: var(--text-muted); }
.thumb-card .project-card-footer a:hover { color: var(--accent); }
.link-danger { font-size: 12px; color: var(--text-muted); }
.link-danger:hover { color: var(--error-text); }
.field > span { font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.form-card { width: 100%; max-width: 640px; }
.form-card .panel-body { display: grid; gap: 16px; }
.form-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--border-subtle); }

/* ==== Daily Brief =========================================================== */
/* Daily Brief (FEAT-051): library of today's jobs + one device-card on the canvas. */

.brief-header { flex-wrap: wrap; row-gap: 4px; padding-top: 8px; padding-bottom: 8px; }

/* Card head: job name + time on the left, actions on the right (wrap under on phones). */
.brief-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 0 12px; padding-right: 12px; border-bottom: 1px solid var(--border-subtle); }
.brief-card-title { font-size: 16px; }
.brief-card-title a { min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.brief-card-actions { display: flex; align-items: center; gap: 8px; padding-top: 12px; }

/* Body: details column + map; stacks under 1024px with the map below. */
.brief-card-grid { display: grid; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) {
  .brief-card-grid:has(> .brief-map) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .brief-card-grid:has(> .brief-map) > :first-child { border-right: 1px solid var(--border-subtle); }
}
.brief-map { min-width: 0; background: var(--surface-3); border-radius: 0 0 var(--radius-md) var(--radius-md); overflow: hidden; }
.brief-map iframe { display: block; width: 100%; height: 100%; min-height: 320px; border: 0; }
@media (min-width: 1024px) { .brief-map { border-radius: 0 0 var(--radius-md) 0; } }

.brief-wrap { min-width: 0; padding: 4px 0; line-height: 1.4; overflow-wrap: anywhere; }
.brief-directions { flex-wrap: wrap; gap: 4px; padding-left: 4px; }

/* Documents: 3-up thumbnail strip, pages sideways when it overflows. */
.doc-strip {
  --doc-gap: 8px;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: calc((100% - 2 * var(--doc-gap)) / 3);
  gap: var(--doc-gap);
  -webkit-overflow-scrolling: touch;
  /* Vertical page scroll wins until JS sees the strip can actually page. */
  touch-action: auto;
  overflow: visible;
}
.doc-strip.is-paged,
.doc-strip.is-paged .doc-tile {
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
  -webkit-user-select: none;
  user-select: none;
}
.doc-strip.is-paged { overflow-x: auto; overflow-y: hidden; }
.doc-strip .doc-tile { width: 100%; aspect-ratio: 1 / 1; height: auto; }

/* The job list is a sideways row above the card (the pre-FEAT-051 layout). */
.brief-workspace { flex-direction: column; }
.brief-library { width: auto; flex-direction: row; align-items: stretch; overflow-x: auto; padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--border-subtle); scrollbar-width: none; }
.brief-library::-webkit-scrollbar { display: none; }
.brief-library .library-title { display: none; }
.brief-library .library-card { flex: 0 0 auto; width: 280px; border-color: var(--border-subtle); }
/* Long job names and crew lists wrap to two lines instead of cutting off. */
.brief-library .library-card-title,
.brief-library .library-card-meta { white-space: normal; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.brief-go-bottom { display: none; }
@media (max-width: 1023px) {
  .brief-library .library-card:only-of-type { width: 100%; }
  .brief-map iframe { min-height: 240px; }
}
/* Phone: two cards across, free sideways scroll (no snapping); Add note stays
   up top, Go to Project moves to the bottom of the card. */
@media (max-width: 767px) {
  .brief-library { -webkit-overflow-scrolling: touch; }
  .brief-library .library-card { width: calc((100% - 4px) / 2); }
  .brief-card-actions { width: 100%; padding: 0 0 12px 12px; }
  .brief-card-actions > * { flex: 1; justify-content: center; }
  .brief-card-actions .brief-go { display: none; }
  .brief-go-bottom { display: flex; justify-content: center; margin: 12px; }
}

/* ==== Tickets: lanes and cards ============================================== */
/* Tickets (FEAT-051): kanban lanes, ticket cards, flag marks, scrolling rail.
   Token-based so it can fold into app.css. */

/* Lanes: one column per stage, thin uppercase header, dense cards. */
.lane-board { display: flex; align-items: stretch; min-height: calc(100dvh - var(--nav-height) - 57px); overflow-x: auto; }
.lane { display: flex; flex-direction: column; flex: 1 0 256px; min-width: 256px; border-right: 1px solid var(--border-subtle); }
.lane:last-child { border-right: 0; }
.lane-header {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  background: var(--surface-1);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lane-header .lane-name { color: var(--text-secondary); }
.lane-count { margin-left: auto; font-family: var(--font-mono); letter-spacing: 0; color: var(--text-muted); }
.lane-body { display: flex; flex-direction: column; gap: 8px; flex: 1; padding: 8px; }
.lane-body.drag-over { background: var(--accent-subtle); box-shadow: inset 0 0 0 1px var(--border-accent); }
.lane-empty { padding: 24px 0; font-size: 12px; color: var(--text-muted); text-align: center; }

/* Ticket card: device-card chrome, number row, summary, customer/site lines. */
.ticket-card {
  position: relative;
  display: block;
  padding: 8px 12px 10px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  box-shadow: var(--card-shadow);
  color: inherit;
  cursor: pointer;
  transition: border-color var(--transition-fast), box-shadow var(--transition-lift), transform var(--transition-lift);
}
.ticket-card:hover { border-color: var(--border-strong); box-shadow: var(--card-shadow-lift); transform: translateY(-1px); }
.ticket-card.is-urgent { box-shadow: inset 2px 0 0 var(--status-warn), var(--card-shadow); }
.ticket-card.dragging { opacity: 0.4; }
.kanban-card[draggable="true"] { cursor: grab; }
.kanban-card[draggable="true"]:active { cursor: grabbing; }
.ticket-card-top { display: flex; align-items: center; gap: 8px; min-height: 20px; }
.ticket-card-number { font-family: var(--font-mono); font-size: 11px; color: var(--text-muted); }
.ticket-card-title { margin-top: 2px; font-size: 13px; font-weight: 500; line-height: 1.35; color: var(--text-primary); overflow-wrap: anywhere; }
.ticket-card-meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--text-secondary); min-width: 0; }
.ticket-card-meta span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ticket-card-meta .material-symbols-outlined { font-size: 13px; color: var(--text-muted); }

/* Flag: status dot + tiny uppercase word (urgent = warn, warranty = accent). */
.flag-mark { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); white-space: nowrap; }
.flag-mark.is-warn { color: var(--status-warn); }
.flag-mark.is-accent { color: var(--accent); }

/* A rail whose content can outgrow the viewport (consumables list). */
.inspector-panel.is-rail.is-scroll { overflow-y: auto; }

/* ==== Project page ========================================================== */
/* Project page. quill.snow.css loads after base.html's `.ql-container { height: auto }`,
   so its height: 100% wins and the editor spills out of a stretched grid cell. */
.panel .ql-container { height: auto; }

/* Customer page: a button pinned right in a section label, the People list, the Main office pane. */
.device-section-label:has(> .tool-btn) { display: flex; align-items: center; justify-content: space-between; padding-right: 4px; }
.device-section-label .tool-btn, .inspector-heading .tool-btn { text-transform: none; letter-spacing: 0; }
.inspector-heading .tool-btn { margin-right: -8px; }
.people-list-row { display: flex; align-items: center; gap: 16px; border-top: 1px solid var(--border-subtle); }
.people-list-row > .person-card { flex: 1; min-width: 0; border-top: 0; }
.people-list-sites { flex: 0 0 30%; padding-right: 12px; font-size: 13px; color: var(--text-secondary); }
@media (max-width: 639px) {
  .people-list-row { flex-direction: column; align-items: stretch; gap: 0; }
  .people-list-sites { padding: 0 12px 10px 56px; }
}
.office-fields { display: grid; gap: 10px; padding: 4px 12px 12px; }
/* Customer page: open projects / tickets, a list that slides over the page
   from the right. Closed unless .is-open, so it never slides on page load. */
.jobs-panel { position: fixed; top: 0; right: 0; bottom: 0; z-index: 45; width: min(560px, 100vw); overflow-y: auto; border-width: 0 0 0 1px;
  transform: translateX(100%); visibility: hidden; transition: transform 200ms ease, visibility 0s linear 200ms; }
.jobs-panel.is-open { transform: none; visibility: visible; transition: transform 200ms ease; }
.job-line { display: grid; grid-template-columns: minmax(0, 1fr) 120px 118px; align-items: center; gap: 16px; padding: 12px 16px; border-top: 1px solid var(--border-subtle); color: inherit; }
.job-line:hover { background: var(--surface-2); }
.job-line.is-urgent { box-shadow: inset 3px 0 0 var(--status-warn); }
.job-line-main, .job-line-stage { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.job-line-title { overflow: hidden; font-size: 14px; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.job-line-meta { display: flex; align-items: center; gap: 4px; min-width: 0; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.job-line-meta .material-symbols-outlined { font-size: 14px; }
.job-line-flag { margin-right: 4px; padding: 0 6px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--status-warn) 22%, transparent); color: var(--status-warn); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; }
.job-line-stage .stage-segments { padding: 0; }
.job-line-next { display: flex; align-items: center; justify-content: flex-end; gap: 6px; font-size: 12px; white-space: nowrap; }
@media (max-width: 480px) { .job-line { grid-template-columns: minmax(0, 1fr) auto; } .job-line-stage { grid-column: 1; grid-row: 2; } .job-line-next { grid-row: 1 / span 2; grid-column: 2; } }
/* Files page: each site is a drop target. */
.file-group.is-over { background: var(--accent-subtle); }
/* Files / Sales orders pages: List = the same tiles laid out as rows. */
.thumb-grid.is-list { grid-template-columns: minmax(0, 1fr); gap: 0; border: 1px solid var(--border-default); border-radius: var(--radius-md); overflow: hidden; }
.thumb-grid.is-list .thumb-card { flex-direction: row; align-items: center; border: 0; border-top: 1px solid var(--border-subtle); border-radius: 0; background: var(--surface-1); }
.thumb-grid.is-list .thumb-card:first-child { border-top: 0; }
.thumb-grid.is-list .thumb-card:hover { background: var(--surface-2); }
.thumb-grid.is-list .project-card-thumb { width: 36px; height: 44px; margin: 6px 0 6px 12px; border-radius: var(--radius-sm); }
.thumb-grid.is-list .project-card-thumb .material-symbols-outlined { font-size: 20px !important; }
.thumb-grid.is-list .project-card-body { flex: 1; flex-direction: row; align-items: center; gap: 16px; padding: 8px 12px; }
.thumb-grid.is-list .project-card-name { -webkit-line-clamp: 1; flex: 1; }
.thumb-grid.is-list .project-card-footer { flex: 0 0 auto; gap: 24px; min-width: 220px; border-top: 0; padding: 0 16px; }
.thumb-grid.is-list > .drop-hint { padding: 12px 16px; }
@media (max-width: 639px) { .thumb-grid.is-list .project-card-footer { min-width: 0; gap: 12px; } .thumb-grid.is-list .project-card-meta { display: none; } }
/* Customer page: the site invoices go to. */
.billing-tag { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: var(--radius-sm); background: var(--accent-subtle); color: var(--accent); font-size: 10px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 1px; }

/* Budget vs actual grid (Cost Report): a row per cost type that opens to its editable lines. */
.ledger-add.is-flex { display: flex; flex-wrap: wrap; align-items: center; }
.ledger-add.is-flex > .is-wide { flex: 1 1 200px; }
.bva-title { font-size: 15px; font-weight: 600; }
.bva-head { display: flex; align-items: center; gap: 12px; min-width: 0; }
.bva-name { display: flex; flex-direction: column; width: 200px; flex-shrink: 0; }
.bva-hint { font-size: 11px; color: var(--text-muted); }
.bva-meter { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 80px; --tone: var(--accent); }
.bva-meter.is-overspent { --tone: var(--status-error); }
.bva-meter-track { flex: 1; height: 10px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-3); }
.bva-meter-track > span { display: block; height: 100%; background: var(--tone); }
.bva-meter em { width: 40px; font-size: 12px; font-style: normal; text-align: right; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.bva-meter.is-overspent em { color: var(--error-text); }
/* Something to fix: the calendar's conflict triangle; hover lists it, click jumps to it. */
.bva-warn { position: relative; display: inline-flex; margin-left: -4px; padding: 2px; color: var(--status-warn); border-radius: var(--radius-sm); }
.bva-warn .material-symbols-outlined { font-size: 16px; }
.bva-warn-slot { width: 20px; margin-left: -4px; flex-shrink: 0; }  /* same width as the triangle button (16px icon + 2px padding each side) */
.bva-warn:hover { background: var(--surface-3); }
.bva-warn-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 5; display: none; flex-direction: column; gap: 4px; padding: 8px 10px; white-space: nowrap; font-size: 12px; text-align: left; color: var(--text-primary); background: var(--surface-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); }
.bva-warn-pop em { font-style: normal; color: var(--status-warn); }
.bva-warn:hover .bva-warn-pop, .bva-warn:focus-visible .bva-warn-pop { display: flex; }
.bva .bva-row td:first-child { overflow: visible; }
.bva-chev { font-size: 18px; color: var(--text-muted); transition: transform 0.15s; }
.is-open .bva-chev { transform: rotate(180deg); }
.is-open .bva-row td { background: var(--surface-2); }
.data-table .bva-detail > td { padding: 0; background: var(--surface-1); }
.bva-label { padding: 12px 14px 4px; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.bva-lines td, .bva-lines th { background: transparent; }
.bva-bar { display: flex; align-items: center; gap: 12px; padding: 8px 14px; }
.bva-co { flex-shrink: 0; padding: 0 6px; font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.bva-spent { display: grid; padding: 0 14px 8px; font-size: 13px; }
.bva-spent li { display: flex; gap: 12px; padding: 5px 0; border-bottom: 1px solid var(--border-subtle); color: var(--text-secondary); }
.bva-spent em { font-style: normal; color: var(--text-muted); }
.bva-spent b { margin-left: auto; font-family: var(--font-mono); font-weight: 500; color: var(--text-primary); }
.bva-date { width: 44px; flex-shrink: 0; color: var(--text-muted); }
.bva-spent-note { padding: 0 14px 10px; font-size: 13px; color: var(--text-secondary); }
.bva-spent-note a { color: var(--accent); }
.field-input.is-missing { border-color: var(--status-warn); }
.ledger-add.is-flex > .field-input { width: auto; }
.data-table.bva { table-layout: fixed; }
.bva > thead > tr > th:nth-child(n+2):nth-child(-n+4) { width: 13%; }
.bva-row td { height: 48px; }
.bva-lines { min-width: 720px; }
.bva-lines select.field-input.is-sm { min-width: 150px; }
.bva-add td { border-bottom: 0; }
.bva > thead > tr > th:last-child { width: 40px; }
.bva-scroll { overflow-x: auto; }
/* Phones: the Budget table keeps its desktop width and swipes sideways as one sheet (Google Sheets style);
   the page scrolls up and down. The inner grids stop scrolling on their own so there's one scroller. */
@media (max-width: 767px) {
  .bva-sheet { overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain; }
  .bva-sheet > .data-table.bva { min-width: 860px; }
  .bva-sheet .bva-scroll { overflow-x: visible; }
}
/* Ruled grid for budget lines: every cell boxed, header band, inputs fill their cell, read-only columns shaded. */
.bva-grid { border-collapse: collapse; border-top: 1px solid var(--border-default); }
.bva-grid th { height: 34px; white-space: nowrap; font-size: 13px; font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-primary); background: var(--surface-3); border: 1px solid var(--border-default); border-top: 0; }
/* The Budget / Spent / Left column heads over the three folds: white and bold, the page's main headers. */
.bva > thead > tr > th { font-size: 12px; font-weight: 700; color: var(--text-primary); }
.bva-grid td { height: 34px; padding: 0 8px; border: 1px solid var(--border-subtle); }
.bva-grid tr > :first-child { border-left: 0; }
.bva-grid tr > :last-child { border-right: 0; }
.bva-grid tbody tr:hover td, .bva-grid tbody tr:focus-within td { background: var(--accent-subtle); }
.bva-grid tbody tr:hover td.bva-calc, .bva-grid tbody tr:focus-within td.bva-calc { color: var(--text-primary); }
.bva-grid td:has(> .bva-cell), .bva-grid td:has(> div > .bva-cell) { padding: 0; }
.bva-grid td > div:has(> .bva-cell) { padding-left: 8px; }
.bva-cell { width: 100%; height: 34px; padding: 0 8px; font-size: 13px; color: var(--text-primary); background: transparent; border: 0; outline: 0; font-variant-numeric: tabular-nums; }
.bva-cell.is-num { text-align: right; }
.bva-cell::placeholder { color: var(--text-muted); }
.bva-cell:focus { background: var(--surface-1); box-shadow: inset 0 0 0 1px var(--accent); }
.bva-grid .bva-calc { background: var(--surface-2); color: var(--text-secondary); }
.bva-grid td.is-missing .bva-cell::placeholder { color: var(--status-warn); }  /* just the word, no box (Tanner 2026-10-01) */
.bva-grid .is-low { color: var(--status-warn); }
.bva-grid .is-gain { color: var(--status-ok); }
.bva-grid .is-loss { color: var(--error-text); }
.bva-grid tfoot td { height: 36px; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border-default); }
.bva-grid .bva-add td { border-bottom: 1px solid var(--border-subtle); }
/* Remove sits far left, muted until hovered, and always confirms; the add row puts "+" in the same spot. */
.bva-grid td.bva-del { width: 36px; padding: 0; text-align: center; }
.bva-del-btn { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; color: var(--text-muted); opacity: 0.45; border-radius: var(--radius-sm); }
.bva-del-btn .material-symbols-outlined { font-size: 16px; }
tr:hover .bva-del-btn, .bva-del-btn:focus-visible { opacity: 1; }
.bva-del-btn:hover { color: var(--error-text); background: var(--error-subtle); }
.bva-del-btn.is-add { opacity: 1; color: var(--accent); }
.bva-del-btn.is-add:hover { color: var(--accent); background: var(--accent-subtle); }
/* Margin column: click flips % margin <-> dollars made. */
.bva-toggle { cursor: pointer; }
.bva-toggle-head { font: inherit; letter-spacing: inherit; text-transform: inherit; color: var(--accent); cursor: pointer; }
.bva-toggle-head:hover { text-decoration: underline; }
/* Desktop fits without a sideways scroll from a ~800px panel up (Tanner 2026-10-01); the Item column takes what's
   left. A figure cell never pushes the table wider (clipped, not scrolled; not the Labor hours cell, its "why" popup must show). Phones: .bva-sheet above. */
.bva-grid.is-fixed { table-layout: fixed; min-width: 800px; }
.bva-grid.is-fixed td.num { overflow: hidden; }
/* Budget folds: one open at a time, sliding open/closed (grid-rows 0fr -> 1fr); no slide when the panel is swapped in after a save. */
.data-table .bva-detail > td { height: auto; border-bottom: 0; }
/* An open fold is boxed off: a strong line above its header row and below its contents, and a blue edge down
   the left, so it's clear where Products ends and Labor begins (Tanner 2026-09-27). */
.bva > tbody.is-open > tr.bva-row > td { border-top: 2px solid var(--border-strong); }
.bva > tbody.is-open > tr.bva-row > td:first-child { border-left: 3px solid var(--accent); }
.bva > tbody.is-open > tr.bva-detail > td { border-bottom: 2px solid var(--border-strong); border-left: 3px solid var(--accent); }
.bva-fold { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.25s ease; }
.is-open .bva-fold { grid-template-rows: 1fr; }
.bva-fold-inner { min-height: 0; overflow: hidden; }
.is-settling .bva-fold, .is-settling .bva-chev { transition: none; }
.bva-bar .btn .material-symbols-outlined { font-size: 16px; }
/* With a fold open, the other two fold lines dim (full again on hover) so the open one stands out. */
.bva > tbody > tr.bva-row { transition: opacity 0.2s ease; }
.bva.has-open > tbody:not(.is-open) > tr.bva-row { opacity: 0.4; }
.bva.has-open > tbody:not(.is-open) > tr.bva-row:hover { opacity: 1; }
/* Labor fold: one hours bar per phase. Length = budget (or hours used once over), fill = used, tick = the budget
   once passed, red past it = the overrun; "18 hrs" inside, "12 left" / "2 over" at the end, budget typed in after. */
.bva-th-note { margin-left: 6px; font-weight: 400; color: var(--text-muted); }
.bva-grid td.bva-hours-cell { padding: 0 0 0 10px; }
.bva-hours { display: flex; align-items: center; gap: 10px; }
.bva-hbar { position: relative; flex: 1; height: 22px; overflow: hidden; border-radius: var(--radius-sm); background: var(--surface-3); }
.bva-hbar-fill, .bva-hbar-over { position: absolute; top: 0; bottom: 0; left: 0; background: var(--accent); opacity: 0.85; }
.bva-hbar-over { background: var(--status-error); }
.bva-hbar-tick { position: absolute; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: var(--text-primary); }
.bva-hbar-used, .bva-hbar-left { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; font-size: 12px; font-weight: 600; color: var(--text-primary); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.bva-hbar-used { left: 8px; }
.bva-hbar-left { right: 8px; }
.bva-hbar.is-over .bva-hbar-left { color: #fff; }
.bva-hbar.is-empty .bva-hbar-used { font-weight: 400; color: var(--text-muted); text-shadow: none; }
.bva-hours-budget { display: flex; align-items: center; gap: 2px; width: 92px; flex-shrink: 0; font-size: 12px; color: var(--text-muted); }
.bva-hours-budget .bva-cell { width: 64px; padding: 0 6px; text-align: right; color: var(--text-primary); }
.bva-hours-budget b { margin-left: 4px; font-weight: 500; color: var(--text-primary); }
/* Labor fold: the job's total hours strip, and finished / in-progress phases. */
.bva-total { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; padding: 8px 14px; font-size: 13px; color: var(--text-secondary); }
.bva-total b { font-weight: 600; color: var(--text-primary); }
.bva-total .is-todo, .bva-total .is-todo b { color: var(--status-warn); }
.bva-total-main { display: flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-primary); }
.bva-total-main .bva-cell { width: 72px; height: 30px; font-size: 14px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border-default); border-radius: var(--radius-sm); }
.bva-phase { display: inline-flex; align-items: center; gap: 6px; }
.bva-phase .material-symbols-outlined { font-size: 16px; color: var(--status-ok); }
.bva-phase em { padding: 0 6px; font-size: 11px; font-style: normal; font-weight: 500; color: var(--accent); border: 1px solid var(--border-accent); border-radius: var(--radius-sm); }
/* Hovering an over-budget hours bar: why it went over. The open fold stops clipping once it has slid open so
   the popup can sit above the bar. */
@keyframes bva-unclip { to { overflow: visible; } }
.is-open .bva-fold-inner { animation: bva-unclip 0s 0.26s forwards; }
.bva-hours { position: relative; }
.bva-why { position: absolute; bottom: calc(100% + 6px); left: 0; z-index: 6; display: none; min-width: 260px; padding: 8px 10px; font-size: 12px; color: var(--text-secondary); background: var(--surface-3); border: 1px solid var(--border-default); border-radius: var(--radius-md); box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35); }
.bva-why p { display: flex; justify-content: space-between; gap: 16px; padding: 2px 0; white-space: nowrap; }
.bva-why p:first-child { margin-bottom: 4px; color: var(--error-text); }
.bva-why b { font-weight: 600; color: var(--text-primary); }
.bva-why p:first-child b { color: var(--error-text); }
.bva-why .is-none { color: var(--text-muted); }
.bva-hours.has-why:hover .bva-why { display: block; }
.bva-hours.has-why .bva-hbar { cursor: help; }
.bva-count { margin-left: 6px; padding: 0 6px; font-size: 11px; font-weight: 600; color: var(--status-warn); border: 1px solid var(--status-warn); border-radius: var(--radius-sm); }
/* Linked items sidecar (admin/_cost_inventory.html): takes the Activity rail's place, sliding in */
.workspace.show-linked > #activity, .workspace:not(.show-linked) > #linked { display: none; }
.workspace.show-linked > #linked { animation: side-in 0.2s ease-out; }
@keyframes side-in { from { transform: translateX(24px); opacity: 0; } }
#linked.is-drop { background: var(--accent-subtle); }
.bva-side-list { display: flex; flex-direction: column; gap: 6px; padding: 10px; max-height: 70vh; overflow-y: auto; }
.bva-card { display: flex; align-items: flex-start; gap: 6px; padding: 8px; font-size: 13px; background: var(--surface-2); border: 1px solid var(--border-default); border-radius: var(--radius-md); cursor: grab; }
.bva-card:hover { border-color: var(--border-strong, var(--accent)); }
.bva-card.is-dragging { opacity: 0.4; }
.bva-card-grip { font-size: 18px; color: var(--text-muted); }
.bva-card-sub { font-size: 12px; color: var(--text-secondary); }
.bva-card-on { font-size: 12px; color: var(--accent); }
.bva-card-check { display: flex; align-items: center; gap: 4px; margin-top: 2px; font-size: 12px; color: var(--status-warn); }
.bva-card-check > .material-symbols-outlined { font-size: 16px; }
/* Linked items: a line placed from inventory (icon + count), a qty > 1 line opening to its units, cards flying onto a line */
.bva-linked { display: inline-flex; align-items: center; gap: 1px; margin-right: 8px; font-size: 12px; color: var(--accent); white-space: nowrap; }
.bva-linked .material-symbols-outlined { font-size: 15px; }
.bva-units-btn { display: inline-flex; flex: none; width: 18px; height: 18px; align-items: center; justify-content: center; margin-left: -4px; border-radius: var(--radius-sm, 2px); color: var(--text-muted); }
.bva-units-btn:hover { color: var(--text-primary); background: var(--surface-3, var(--surface-2)); }
.bva-units-btn .material-symbols-outlined { font-size: 16px; transition: transform var(--transition-fast); }
.bva-units-btn.is-open .material-symbols-outlined { transform: rotate(90deg); }
.bva-units-n { width: 16px; color: var(--text-muted); text-align: right; }
/* A unit row (app/line_units.py): inset under its line, a rail down the left, smaller text */
.bva-grid tr.bva-units > td { background: var(--surface-1); font-size: 12px; }
.bva-grid tr.bva-units > td:nth-child(2) { box-shadow: inset 2px 0 0 var(--border-strong, var(--border-default)); }
.bva-unit-name { display: flex; align-items: center; gap: 6px; min-width: 0; padding-left: 14px; }
.bva-unit-link { font-size: 14px; color: var(--accent); }
.bva-fly { position: fixed; z-index: 100; margin: 0; pointer-events: none; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
@keyframes bva-landed { from { background: color-mix(in srgb, var(--accent) 28%, transparent); } to { background: transparent; } }
tr.is-landed > td { animation: bva-landed 1s ease-out; }
.bva-card.is-landed, .sidebar-row.is-landed { animation: bva-landed 1s ease-out; }
.bva-grid tr.is-drop td { background: var(--accent-subtle); box-shadow: inset 0 1px 0 var(--accent), inset 0 -1px 0 var(--accent); }
.bva-icon-link { display: inline-flex; color: var(--text-secondary); }
.bva-icon-link .material-symbols-outlined, .bva-icon-link.material-symbols-outlined { font-size: 18px; }
a.bva-icon-link:hover { color: var(--accent); }
.bva-grid td.is-estimated { opacity: 0.6; }  /* profit on the expected cost, until the actual is filled in */

/* Platform console (/platform): stat tiles with a 30-day trend, daily column charts (inline SVG, one series and one
   axis each), inline bars in tables, and the status side panel. Accent = the data; text stays in text tokens. */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { padding: 12px 14px; border: 1px solid var(--border-subtle); border-radius: var(--radius-md); background: var(--surface-2); }
.kpi-label { margin: 0; font-size: 11px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.kpi-value { margin: 4px 0 0; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; color: var(--text-primary); font-variant-numeric: normal; }
.kpi-sub { margin: 2px 0 0; font-size: 12px; color: var(--text-secondary); }
.kpi-spark { display: block; width: 100%; height: 28px; margin-top: 8px; overflow: visible; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.chart { padding: 8px 12px 4px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid-line { stroke: var(--border-subtle); stroke-width: 1; }
.chart-axis { stroke: var(--border-default); stroke-width: 1; }
.chart-tick { font-size: 11px; fill: var(--text-muted); font-variant-numeric: tabular-nums; }
.chart-bar { fill: var(--accent); }
.chart-hit:hover .chart-bar { fill: color-mix(in srgb, var(--accent) 80%, var(--text-primary)); }
.chart-hit:hover rect { fill: var(--surface-3); fill-opacity: 0.5; }
.inline-bar { display: flex; align-items: center; gap: 10px; }
.inline-bar .num { flex-shrink: 0; min-width: 64px; font-size: 12px; color: var(--text-secondary); }
.inline-bar-track { position: relative; display: block; flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.inline-bar-track > span { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: color-mix(in srgb, var(--accent) 35%, transparent); }
.inline-bar-track > span.is-strong { background: var(--accent); }
.inline-bar-track > span.is-warn { background: var(--status-warn); }
.hbar-row { display: grid; grid-template-columns: minmax(120px, 200px) 1fr 80px; align-items: center; gap: 12px; padding: 4px 0; font-size: 13px; }
.hbar-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-secondary); }
.hbar-value { text-align: right; font-size: 12px; color: var(--text-secondary); }
.side-server { display: flex; align-items: center; gap: 10px; padding: 6px 12px; }
.side-name { margin: 0; font-size: 13px; font-weight: 500; color: var(--text-primary); }
.side-meta { margin: 0; font-size: 12px; color: var(--text-muted); }
.side-num { margin-left: auto; font-size: 12px; color: var(--text-secondary); font-variant-numeric: tabular-nums; white-space: nowrap; }
.side-meter { padding: 6px 12px; }
.side-meter-head { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 12px; color: var(--text-secondary); }
.side-links { display: flex; flex-direction: column; gap: 6px; padding: 4px 12px 12px; font-size: 13px; }
.plan-note { margin: 4px 0 0; font-size: 12px; color: var(--text-muted); }
.plan-note.is-warn { color: var(--status-warn); }
.sort-btn { display: inline-flex; align-items: center; gap: 2px; font: inherit; letter-spacing: inherit; text-transform: inherit; color: inherit; }
.sort-btn .material-symbols-outlined { font-size: 14px; opacity: 0.5; }
.sort-btn:hover, .sort-btn.is-on { color: var(--text-primary); }
.sort-btn.is-on .material-symbols-outlined { opacity: 1; color: var(--accent); }
