:root {
  /* Hyra brand */
  --hyra-blue: #16314f;
  --hyra-teal: #0b9ed2;
  --hyra-light: #f5f7fa;
  --ink: #1f2d3d;
  --muted: #5a6b7b;
  --hint: #8a97a8;
  --line: #e6ebf1;
  --line-strong: #cdd9e6;

  /* Status / flag colours (from blueprint) */
  --flag-variance: #fff3cd;
  --flag-below: #f8d7da;
  --flag-replaced: #ffe5d0;
  --flag-unreadable: #e2d9f3;
  --flag-rollover: #d0f0fd;
  --approved: #d1e7dd;
  --estimated: #cfe2ff;
}

/* ── Base (compact, modern) ───────────────────────────────────────────── */
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 13.5px;
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Auth (login / first-run setup) */
.hmc-auth-body { background: var(--hyra-light); }
.hmc-auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.hmc-auth-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.75rem 1.75rem 2rem;
  box-shadow: 0 8px 28px rgba(22, 49, 79, 0.10);
}
.hmc-auth-brand { font-size: 1.25rem; font-weight: 700; color: var(--hyra-blue); }
.hmc-auth-sub { color: var(--muted); margin-bottom: 1.25rem; font-size: 0.85rem; }

/* App layout */
.hmc-app-body { background: var(--hyra-light); }
.hmc-layout { display: flex; min-height: 100vh; }

.hmc-sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: var(--hyra-blue);
  color: #cdd9e8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.hmc-sidebar-brand {
  font-weight: 600;
  font-size: 0.95rem;
  color: #fff;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  line-height: 1.2;
}
.hmc-nav { padding: 0.4rem 0; overflow-y: auto; }
.hmc-nav-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 1rem;
  color: #aebed2;
  text-decoration: none;
  font-size: 0.82rem;
  border-left: 3px solid transparent;
  white-space: nowrap;
}
.hmc-nav-link:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.hmc-nav-link.active {
  background: rgba(11, 158, 210, 0.18);
  border-left-color: var(--hyra-teal);
  color: #fff;
  font-weight: 600;
}
.hmc-nav-icon { width: 1.1rem; text-align: center; font-size: 0.85rem; opacity: 0.9; }

.hmc-content { flex: 1 1 auto; display: flex; flex-direction: column; min-width: 0; }
.hmc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fff;
  padding: 0.55rem 1.1rem;
  border-bottom: 1px solid var(--line);
}
.hmc-screen-title { font-size: 0.95rem; font-weight: 600; color: var(--hyra-blue); margin: 0; }
.hmc-user { display: flex; align-items: center; gap: 0.55rem; font-size: 0.82rem; }
.hmc-user-name { color: var(--ink); font-weight: 600; }
.hmc-logout { margin: 0; }
.hmc-main { padding: 1rem 1.1rem; flex: 1 1 auto; }

.hmc-placeholder { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1.25rem; }
.hmc-placeholder h2 { font-size: 0.95rem; margin: 0 0 0.25rem; color: var(--hyra-blue); }

/* Data tables (Excel-like: scroll within, sticky header) */
.hmc-table-wrap { background: #fff; border: 1px solid var(--line); border-radius: 10px; max-height: calc(100vh - 190px); overflow: auto; }
.hmc-table { width: 100%; margin: 0; font-size: 12.5px; border-collapse: collapse; }
.hmc-table th, .hmc-table td { padding: 6px 10px; border-bottom: 1px solid var(--line); text-align: left; }
.hmc-table tbody tr:hover { background: #f7fafc; }
.hmc-table thead th {
  position: sticky; top: 0;
  background: #eef3f8; color: var(--hyra-blue); font-weight: 600;
  border-bottom: 1px solid var(--line-strong); white-space: nowrap; z-index: 1;
}
.hmc-num { text-align: right; }

.hmc-badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.hmc-badge.is-active, .hmc-badge.is-ok { background: #def3e6; color: #1b7a45; }
.hmc-badge.is-inactive, .hmc-badge.is-muted { background: #eceff3; color: #5a6b7b; }
.hmc-badge.is-warn { background: #fff1d6; color: #8a5a08; }
.hmc-badge.is-info { background: #e2effb; color: #185fa5; }
.hmc-badge.is-block, .hmc-badge.is-danger { background: #fbe0e0; color: #a32020; }

/* Sortable headers */
.hmc-table th.hmc-sortable { cursor: pointer; user-select: none; }
.hmc-table th.hmc-sortable:hover { background: #e3ebf4; }
.hmc-caret { display: inline-block; width: 0.7em; margin-left: 2px; color: var(--hyra-teal); }
.hmc-table th.hmc-sortable[data-dir="asc"] .hmc-caret::after { content: "▲"; font-size: 9px; }
.hmc-table th.hmc-sortable[data-dir="desc"] .hmc-caret::after { content: "▼"; font-size: 9px; }

/* ── Form system (compact, modern) ───────────────────────────────────── */
.hf-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 0.75rem; }
.hf-toolbar-left { display: flex; align-items: center; gap: 8px; }
.hf-count { color: var(--muted); font-size: 0.82rem; margin: 0.6rem 0 0; }
.hmc-table tr.is-inactive td { opacity: 0.5; }

/* Bulk Setup (A14) */
.hf-lead { font-size: 0.85rem; color: var(--muted); max-width: 880px; margin: 0 0 1rem; }
.hf-file { display: block; font-size: 0.82rem; margin-bottom: 0.75rem; }
.hmc-bulk-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1rem; max-width: 1000px; }
.hmc-bulk-grid .hf-card { max-width: none; }
.hmc-bulk-results { margin-top: 1rem; }
.hmc-bulk-summary { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 0.5rem; }

/* Dashboard (A1) cards */
.hmc-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; max-width: 1100px; }
.hmc-card { position: relative; background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.hmc-card-value { font-size: 1.6rem; font-weight: 700; color: var(--hyra-blue); }
.hmc-card-label { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.hmc-card-dot { position: absolute; top: 14px; right: 14px; width: 10px; height: 10px; border-radius: 50%; }
.hmc-card-dot.is-active, .hmc-card-dot.is-ok { background: #1b7a45; }
.hmc-card-dot.is-warn { background: #e0a008; }
.hmc-card-dot.is-block, .hmc-card-dot.is-danger { background: #a32020; }
.hmc-card-dot.is-info { background: var(--hyra-teal); }
.hmc-card-dot.is-muted { background: var(--line-strong); }

/* Approve Readings (A4) */
.hf-cycle-banner { background: var(--hyra-light); border-radius: 8px; padding: 8px 12px; font-size: 0.84rem; margin: 0.5rem 0; }
.hf-cycle-banner.billing { background: #e6f6ec; color: #1b7a45; }
.hmc-row-flagged td { background: #fff3cd; }
.hmc-row-unreadable td { background: #e2d9f3; }
.hmc-row-rollover td { background: #d0f0fd; }
.hmc-row-approved td { background: #d1e7dd; }
.hmc-approve-form { display: flex; align-items: center; gap: 5px; margin: 2px 0; flex-wrap: wrap; }
.hmc-approve-form + .hmc-approve-form { border-top: 1px dashed var(--line); padding-top: 4px; }

/* Worker → PID roster checklist */
.hf-pidgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 4px 14px; max-width: 1000px; }
.hf-pidcheck { display: flex; align-items: center; gap: 7px; font-size: 0.84rem; padding: 3px 0; }
.hf-pidcheck input { width: 16px; height: 16px; }

/* FDC device-preview harness */
.fdc-device-shell { width: max-content; margin: 1.2rem auto; border: 12px solid #1c1c1e; border-radius: 32px; background: #000; box-shadow: 0 10px 40px rgba(0,0,0,0.25); overflow: hidden; }
#fdc-frame { display: block; width: 390px; height: 844px; border: 0; background: #fff; }

/* Customer-edit unit context panel */
.hmc-ctx { background: var(--hyra-light); border: 1px solid var(--line); border-radius: 8px; padding: 0.6rem 0.8rem; }
.hmc-ctx-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.5rem 1.2rem; }
.hmc-ctx-grid > div { display: flex; flex-direction: column; }
.hmc-ctx-k { font-size: 11px; color: var(--muted); }
.hmc-ctx-v { font-size: 0.85rem; color: var(--ink); font-weight: 500; }
.hmc-ctx-sib { margin-top: 0.5rem; border-top: 1px solid var(--line); padding-top: 0.5rem; }

/* QB upload coverage suggestions */
.hmc-cov-row { padding: 0.5rem 0.7rem; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 0.5rem; }
.hmc-cov-row .hmc-unit-title { margin-right: 6px; }
.hmc-sugg { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.82rem; color: var(--ink); }
.hmc-sugg li { margin-bottom: 0.2rem; }

.hf-card { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 1rem 1.25rem 1.25rem; max-width: 1000px; }
.hf-title { font-size: 0.95rem; font-weight: 700; color: var(--hyra-blue); margin: 0 0 0.25rem; }
.hf-sec { font-size: 0.78rem; font-weight: 700; color: var(--hyra-teal); text-transform: none; margin: 1rem 0 0.6rem; padding-bottom: 0.35rem; border-bottom: 1px solid var(--line); }
.hf-sec .hf-sec-note { color: var(--hint); font-weight: 400; }

.hf-row { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.hf-row + .hf-row { margin-top: 10px; }
.hf-field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.hf-grow { flex: 1 1 220px; }
.hf-label { font-size: 12px; color: var(--muted); }
.hf-input, .hf-select {
  height: 32px; width: 100%; box-sizing: border-box;
  border: 1px solid var(--line-strong); border-radius: 7px; padding: 0 9px;
  font-size: 13px; color: var(--ink); background: #fff;
}
.hf-select { padding-right: 6px; }
.hf-input:focus, .hf-select:focus { outline: none; border-color: var(--hyra-teal); box-shadow: 0 0 0 3px rgba(11, 158, 210, 0.15); }
.hf-input:read-only { background: #f3f6f9; color: var(--muted); }
.hf-input.num { text-align: right; }
.hf-input.err, .hf-select.err { border-color: #dc3545; }
.hf-hint { font-size: 11px; color: var(--hint); margin: 4px 0 0; }
.hf-err { font-size: 11px; color: #dc3545; margin: 3px 0 0; }

.hf-w-pid { width: 84px; }
.hf-w-pct { width: 92px; }
.hf-w-rate { width: 120px; }
.hf-w-charge { width: 140px; }
.hf-w-invoice { width: 120px; }
.hf-w-cycle { width: 148px; }
.hf-w-months { width: 210px; }
.hf-w-account { width: 160px; }
.hf-w-type { width: 180px; }
.hf-w-terms { width: 180px; }

.hf-checkrow { display: flex; align-items: center; gap: 8px; height: 32px; }
.hf-toggle { appearance: none; -webkit-appearance: none; width: 36px; height: 20px; border-radius: 10px; background: var(--line-strong); position: relative; cursor: pointer; border: none; flex: none; }
.hf-toggle:checked { background: var(--hyra-teal); }
.hf-toggle::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 0.15s; }
.hf-toggle:checked::after { left: 18px; }
.hf-toggle-label { font-size: 12px; color: var(--ink); }
.hf-info { display: inline-flex; align-items: center; justify-content: center; margin-left: 5px; width: 15px; height: 15px; font-size: 12px; line-height: 1; color: var(--hyra-teal, #2d8fa4); cursor: help; user-select: none; }
.hf-info:hover, .hf-info:focus { color: var(--hyra-blue, #1a3d6b); outline: none; }
.hf-readonly { padding: 7px 10px; border: 1px solid var(--border, #d0d7de); border-radius: 6px; background: #f6f8fa; color: var(--ink, #24292f); font-size: 13px; min-height: 34px; }
.hf-name-edit { margin-top: 6px; }
.hf-name-edit > summary { cursor: pointer; font-size: 12px; color: var(--hyra-teal, #2d8fa4); width: max-content; list-style: revert; }
.hf-name-edit > summary:hover { color: var(--hyra-blue, #1a3d6b); }
.hf-name-edit[open] > summary { margin-bottom: 4px; font-weight: 600; }

.hf-actions { display: flex; gap: 8px; margin-top: 1.25rem; }
.hf-btn {
  height: 32px; padding: 0 14px; border-radius: 7px; font-size: 13px; font-weight: 500;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink);
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.hf-btn:hover { background: #f3f6f9; }
.hf-btn-primary { background: var(--hyra-teal); border-color: var(--hyra-teal); color: #fff; }
.hf-btn-primary:hover { background: #0a8cba; }
.hf-btn-sm { height: 26px; padding: 0 10px; font-size: 12px; }
.hf-btn-danger { border-color: #d99; color: #a32020; }
.hf-btn-danger:hover { background: #fbe0e0; }
.hf-inline-form { display: inline; }
.hf-alert-sm { padding: 5px 10px; font-size: 12px; margin: 4px 0; }

/* QB customer unit cards */
.hmc-unit-card { padding: 0.75rem 0.85rem; margin-bottom: 0.7rem; }
.hmc-unit-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 0.4rem; flex-wrap: wrap; }
.hmc-unit-title { font-size: 0.9rem; font-weight: 700; color: var(--hyra-blue); }
.hmc-unit-cov { display: inline-flex; gap: 5px; flex-wrap: wrap; }
.hmc-table-tight td, .hmc-table-tight th { padding: 4px 8px; }
.hmc-row-muted { opacity: 0.6; }
.hmc-actions-cell { white-space: nowrap; }

/* Screen sub-tabs (Properties | Meters) */
.hmc-tabs { display: flex; gap: 0; margin-bottom: 0.85rem; border-bottom: 2px solid var(--line); }
.hmc-tab {
  padding: 0.45rem 1.1rem; font-size: 0.82rem; font-weight: 500; color: var(--muted);
  text-decoration: none; border: 1px solid transparent; border-bottom: none;
  border-radius: 6px 6px 0 0; margin-bottom: -2px; display: inline-flex; align-items: center; gap: 4px;
}
.hmc-tab:hover { color: var(--ink); background: var(--hyra-light); }
.hmc-tab.active {
  color: var(--hyra-blue); background: #fff;
  border-color: var(--line-strong) var(--line-strong) #fff; font-weight: 600;
}

/* Alerts */
.alert { font-size: 0.85rem; padding: 0.6rem 0.85rem; border-radius: 8px; margin-bottom: 0.85rem; border: 1px solid transparent; }
.alert-danger { background: #fdecec; border-color: #f5c2c2; color: #a12626; }
.alert-success { background: #e7f6ec; border-color: #b8e4c6; color: #1b7a45; }
.alert-warning { background: #fff6e0; border-color: #f3dca0; color: #8a5a08; }

/* Collapsible "all clean / approved" group on the Approve screen */
.hmc-collapse { margin-top: 12px; border: 1px solid var(--hmc-border, #d8dee6); border-radius: 6px; }
.hmc-collapse > summary { cursor: pointer; padding: 8px 12px; font-size: 13px; font-weight: 600; color: var(--hmc-ink, #2a3340); user-select: none; }
.hmc-collapse > summary:hover { background: var(--hmc-hover, #f4f7fa); }
.hmc-collapse[open] > summary { border-bottom: 1px solid var(--hmc-border, #d8dee6); }
.hmc-collapse .hmc-table-wrap { margin: 0; }
