/* ==========================================================================
   HonestCall v2 — app.css
   TMDStats design system, token-driven. Every colour/size is an --hc-* custom
   property on :root (light) and overridden under :root[data-theme="dark"].
   Class prefix: hc-. No framework, no build step.

   Sections
     1. Tokens (light)          10. Pills & status badges
     2. Tokens (dark)           11. Banners
     3. Reset & base            12. Buttons
     4. Shell layout            13. Forms
     5. Sidebar                 14. Tabs
     6. Top bar                 15. KV list · details · chips
     7. Cards                   16. Empty state · pagination
     8. KPI tiles               17. Copy / tooltip · charts
     9. Tables                  18. Utilities · responsive
   ========================================================================== */

/* 1. Tokens (light) ------------------------------------------------------- */
:root {
  color-scheme: light;

  --hc-font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --hc-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --hc-bg: #f5f6f8;
  --hc-card: #ffffff;
  --hc-border: #e5e7eb;
  --hc-border-strong: #d1d5db;
  --hc-hover: #f9fafb;
  --hc-subtle: #f3f4f6;
  --hc-text: #111827;
  --hc-text-2: #374151;
  --hc-muted: #6b7280;
  --hc-input-bg: #ffffff;
  --hc-shadow: 0 1px 2px rgba(16, 24, 40, .04);
  --hc-shadow-lg: 0 12px 32px rgba(16, 24, 40, .14);

  /* Accents */
  --hc-blue: #1a56db;
  --hc-blue-hover: #1648b8;
  --hc-red: #c0392b;
  --hc-red-hover: #a93226;
  --hc-green: #0e9f6e;
  --hc-orange: #d97706;
  --hc-link: #1a56db;
  --hc-ring: rgba(26, 86, 219, .28);

  /* Pills & badges */
  --hc-pill-bg: #e8f0fe;
  --hc-pill-text: #1a56db;
  --hc-badge-green-bg: #def7ec;  --hc-badge-green-text: #03543f;
  --hc-badge-amber-bg: #fef3c7;  --hc-badge-amber-text: #92400e;
  --hc-badge-grey-bg: #f3f4f6;   --hc-badge-grey-text: #4b5563;
  --hc-badge-red-bg: #fde8e8;    --hc-badge-red-text: #9b1c1c;
  --hc-badge-blue-bg: #e1effe;   --hc-badge-blue-text: #1e429f;

  /* Banners */
  --hc-banner-warning-bg: #fffbeb; --hc-banner-warning-border: #fcd34d; --hc-banner-warning-text: #92400e;
  --hc-banner-alert-bg: #fef2f2;   --hc-banner-alert-border: #fca5a5;   --hc-banner-alert-text: #991b1b;
  --hc-banner-info-bg: #eff6ff;    --hc-banner-info-border: #93c5fd;    --hc-banner-info-text: #1e40af;
  --hc-banner-success-bg: #ecfdf5; --hc-banner-success-border: #6ee7b7; --hc-banner-success-text: #065f46;

  /* Charts — categorical slots in fixed order (validated CVD-safe, light surface #fff) */
  --hc-series-1: #1a56db;
  --hc-series-2: #d97706;
  --hc-series-3: #0e9f6e;
  --hc-series-4: #c0392b;
  --hc-series-5: #7c3aed;
  --hc-series-6: #0891b2;
  --hc-series-muted: #9ca3af;
  --hc-chart-grid: #eceff3;
  --hc-chart-axis: #d1d5db;
  --hc-tooltip-bg: #111827;
  --hc-tooltip-text: #ffffff;

  /* Geometry */
  --hc-radius: 12px;
  --hc-radius-sm: 8px;
  --hc-nav-radius: 8px;
  --hc-sidebar-w: 250px;
  --hc-topbar-h: 64px;
}

/* 2. Tokens (dark) -------------------------------------------------------- */
/* The shell's inline <script> stamps data-theme before first paint, so this
   selector is the single source of truth for dark mode. */
:root[data-theme="dark"] {
  color-scheme: dark;

  --hc-bg: #0f1419;
  --hc-card: #161b22;
  --hc-border: #2a3441;
  --hc-border-strong: #3b4655;
  --hc-hover: #1c2330;
  --hc-subtle: #1c2330;
  --hc-text: #e6edf3;
  --hc-text-2: #c9d1d9;
  --hc-muted: #8b949e;
  --hc-input-bg: #0f1419;
  --hc-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  --hc-shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);

  --hc-blue-hover: #2f6fe8;
  --hc-link: #79a8ff;
  --hc-ring: rgba(88, 166, 255, .35);

  --hc-pill-bg: rgba(59, 130, 246, .18);
  --hc-pill-text: #93c5fd;
  --hc-badge-green-bg: rgba(14, 159, 110, .18);  --hc-badge-green-text: #6ee7b7;
  --hc-badge-amber-bg: rgba(217, 119, 6, .2);    --hc-badge-amber-text: #fcd34d;
  --hc-badge-grey-bg: rgba(139, 148, 158, .2);   --hc-badge-grey-text: #c9d1d9;
  --hc-badge-red-bg: rgba(192, 57, 43, .24);     --hc-badge-red-text: #fca5a5;
  --hc-badge-blue-bg: rgba(59, 130, 246, .2);    --hc-badge-blue-text: #93c5fd;

  --hc-banner-warning-bg: rgba(217, 119, 6, .12); --hc-banner-warning-border: rgba(217, 119, 6, .45); --hc-banner-warning-text: #fcd34d;
  --hc-banner-alert-bg: rgba(192, 57, 43, .14);   --hc-banner-alert-border: rgba(240, 82, 82, .45);   --hc-banner-alert-text: #fca5a5;
  --hc-banner-info-bg: rgba(59, 130, 246, .12);   --hc-banner-info-border: rgba(59, 130, 246, .45);   --hc-banner-info-text: #93c5fd;
  --hc-banner-success-bg: rgba(14, 159, 110, .12); --hc-banner-success-border: rgba(14, 159, 110, .45); --hc-banner-success-text: #6ee7b7;

  /* Same hues re-stepped for the dark surface (#161b22) and re-validated */
  --hc-series-1: #3b82f6;
  --hc-series-5: #8b5cf6;
  --hc-series-muted: #6b7280;
  --hc-chart-grid: #232b36;
  --hc-chart-axis: #3b4655;
  --hc-tooltip-bg: #e6edf3;
  --hc-tooltip-text: #0f1419;
}

/* 3. Reset & base --------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--hc-font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--hc-text);
  background: var(--hc-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; line-height: 1.3; color: var(--hc-text); }
h1 { font-size: 20px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
h4 { font-size: 14px; }
p { margin: 0 0 12px; }
a { color: var(--hc-link); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; }
code, kbd, .hc-mono { font-family: var(--hc-mono); font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
hr { border: 0; border-top: 1px solid var(--hc-border); margin: 20px 0; }
:focus-visible { outline: 2px solid var(--hc-blue); outline-offset: 2px; }
.hc-icon { display: inline-block; width: 18px; height: 18px; flex-shrink: 0; vertical-align: middle; }
.hc-icon--sm { width: 14px; height: 14px; }
.hc-icon--lg { width: 22px; height: 22px; }
.hc-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hc-skip-link { position: absolute; left: -999px; top: 8px; z-index: 100; padding: 8px 12px; background: var(--hc-card); color: var(--hc-text); border-radius: var(--hc-radius-sm); box-shadow: var(--hc-shadow-lg); }
.hc-skip-link:focus { left: 8px; }

/* 4. Shell layout --------------------------------------------------------- */
.hc-shell { display: flex; min-height: 100vh; }
.hc-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.hc-content { flex: 1 1 auto; min-width: 0; padding: 24px; }
.hc-banners { display: flex; flex-direction: column; gap: 10px; padding: 16px 24px 0; }
.hc-banners:empty { display: none; }
.hc-backdrop { display: none; }

/* 5. Sidebar -------------------------------------------------------------- */
.hc-sidebar {
  width: var(--hc-sidebar-w);
  flex: 0 0 var(--hc-sidebar-w);
  align-self: flex-start;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--hc-card);
  border-right: 1px solid var(--hc-border);
  overflow-y: auto;
  z-index: 30;
}
.hc-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px; border-bottom: 1px solid var(--hc-border); }
.hc-brand-logo {
  width: 38px; height: 38px; flex: 0 0 38px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--hc-blue); color: #fff;
}
.hc-brand-logo:hover { text-decoration: none; }
.hc-brand-logo img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
.hc-brand-text { min-width: 0; flex: 1 1 auto; }
.hc-brand-name { font-size: 15px; font-weight: 600; line-height: 1.2; color: var(--hc-text); }
.hc-brand-sub { font-size: 12px; color: var(--hc-muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-sidebar-close { margin-left: auto; } /* hidden ≥960px in the responsive section */

.hc-nav { flex: 1 1 auto; padding: 12px; }
.hc-nav-group { margin-bottom: 18px; }
.hc-nav-group:last-child { margin-bottom: 0; }
.hc-nav-label {
  display: block; margin: 0 0 6px; padding: 0 12px;
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--hc-muted);
}
.hc-nav-list { list-style: none; margin: 0; padding: 0; }
.hc-nav-item {
  display: flex; align-items: center; gap: 10px;
  margin: 2px 0; padding: 8px 12px;
  border-radius: var(--hc-nav-radius);
  font-size: 14px; font-weight: 500; color: var(--hc-text-2);
  transition: background .12s, color .12s;
}
.hc-nav-item .hc-icon { color: var(--hc-muted); }
.hc-nav-item:hover { background: var(--hc-hover); color: var(--hc-text); text-decoration: none; }
.hc-nav-item.is-active, .hc-nav-item.is-active:hover { background: var(--hc-blue); color: #fff; }
.hc-nav-item.is-active .hc-icon { color: #fff; }
.hc-nav-count { margin-left: auto; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--hc-pill-bg); color: var(--hc-pill-text); }
.hc-nav-item.is-active .hc-nav-count { background: rgba(255, 255, 255, .22); color: #fff; }
.hc-nav-footer { padding: 12px; border-top: 1px solid var(--hc-border); }
.hc-nav-item.hc-nav-signout, .hc-nav-item.hc-nav-signout .hc-icon { color: var(--hc-red); }
.hc-nav-item.hc-nav-signout:hover { background: rgba(192, 57, 43, .08); color: var(--hc-red); }

/* 6. Top bar -------------------------------------------------------------- */
.hc-topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; flex-wrap: wrap; gap: 12px;
  min-height: var(--hc-topbar-h); padding: 12px 24px;
  background: var(--hc-card); border-bottom: 1px solid var(--hc-border);
}
.hc-topbar-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 18px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-topbar-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.hc-search { position: relative; display: flex; align-items: center; }
.hc-search .hc-icon { position: absolute; left: 12px; color: var(--hc-muted); pointer-events: none; }
.hc-search-input {
  height: 36px; width: 240px; padding: 0 14px 0 36px;
  border-radius: 999px; border: 1px solid var(--hc-border-strong);
  background: var(--hc-input-bg); color: var(--hc-text); font-size: 14px;
}
.hc-search-input::placeholder { color: var(--hc-muted); }
.hc-search-input:focus { outline: none; border-color: var(--hc-blue); box-shadow: 0 0 0 3px var(--hc-ring); }
.hc-icon-btn {
  width: 36px; height: 36px; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--hc-radius-sm); border: 1px solid var(--hc-border-strong);
  background: var(--hc-card); color: var(--hc-text-2);
}
.hc-icon-btn:hover { background: var(--hc-hover); }
.hc-theme-toggle .hc-icon--sun { display: none; }
:root[data-theme="dark"] .hc-theme-toggle .hc-icon--sun { display: inline-block; }
:root[data-theme="dark"] .hc-theme-toggle .hc-icon--moon { display: none; }

/* 7. Cards ---------------------------------------------------------------- */
.hc-card {
  background: var(--hc-card);
  border: 1px solid var(--hc-border);
  border-radius: var(--hc-radius);
  box-shadow: var(--hc-shadow);
  padding: 20px;
}
.hc-card-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.hc-card-title { margin: 0; font-size: 15px; font-weight: 600; }
.hc-card-sub { margin: 2px 0 0; font-size: 13px; color: var(--hc-muted); }
.hc-card-actions { display: flex; align-items: center; gap: 8px; }
.hc-card--flush { padding: 0; overflow: hidden; }
.hc-card--flush .hc-card-header { margin: 0; padding: 16px 20px; border-bottom: 1px solid var(--hc-border); }
.hc-card--flush .hc-card-footer { padding: 12px 20px; border-top: 1px solid var(--hc-border); }
.hc-card--flush .hc-card-body { padding: 20px; }
.hc-stack > * + * { margin-top: var(--gap, 24px); } /* <div class="hc-stack" style="--gap: 10px"> to tighten */
.hc-grid { display: grid; gap: 16px; }
.hc-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.hc-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hc-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.hc-section-title { margin: 0 0 12px; font-size: 16px; font-weight: 600; }

/* 8. KPI tiles ------------------------------------------------------------ */
.hc-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }
.hc-kpi { position: relative; overflow: hidden; padding: 16px 20px; --kpi-accent: var(--hc-blue); }
.hc-kpi::before { content: ""; position: absolute; top: 0; bottom: 0; left: 0; width: 4px; background: var(--kpi-accent); }
.hc-kpi--red { --kpi-accent: var(--hc-red); }
.hc-kpi--blue { --kpi-accent: var(--hc-blue); }
.hc-kpi--green { --kpi-accent: var(--hc-green); }
.hc-kpi--orange { --kpi-accent: var(--hc-orange); }
.hc-kpi-label { font-size: 13px; color: var(--hc-muted); }
.hc-kpi-value { margin: 4px 0 2px; font-size: 28px; font-weight: 700; line-height: 1.2; color: var(--hc-text); } /* proportional figures on purpose */
.hc-kpi-sub { font-size: 12px; color: var(--hc-muted); }
.hc-kpi-sub.is-up { color: var(--hc-green); }
.hc-kpi-sub.is-down { color: var(--hc-red); }

/* 9. Tables --------------------------------------------------------------- */
.hc-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.hc-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.hc-table th {
  padding: 10px 12px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--hc-muted);
  border-bottom: 1px solid var(--hc-border); background: var(--hc-card);
}
.hc-table td { padding: 12px; vertical-align: middle; border-bottom: 1px solid var(--hc-border); }
.hc-table tbody tr:hover { background: var(--hc-hover); }
.hc-table tbody tr:last-child td { border-bottom: 0; }
.hc-table .is-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hc-table .is-muted { color: var(--hc-muted); }
.hc-table .is-nowrap { white-space: nowrap; }
.hc-table a { font-weight: 500; }
.hc-table--compact th, .hc-table--compact td { padding: 8px 10px; }
.hc-card--flush .hc-table th:first-child, .hc-card--flush .hc-table td:first-child { padding-left: 20px; }
.hc-card--flush .hc-table th:last-child, .hc-card--flush .hc-table td:last-child { padding-right: 20px; }

/* 10. Pills & status badges ---------------------------------------------- */
.hc-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap;
  background: var(--hc-pill-bg); color: var(--hc-pill-text);
}
.hc-badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1.5; white-space: nowrap;
  background: var(--hc-badge-grey-bg); color: var(--hc-badge-grey-text);
}
.hc-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
/* Tones + v2 status aliases (the _badge.twig macro emits both) */
.hc-badge.is-green, .hc-badge.is-booked, .hc-badge.is-appointment-made, .hc-badge.is-active,
.hc-badge.is-delivered, .hc-badge.is-received, .hc-badge.is-success { background: var(--hc-badge-green-bg); color: var(--hc-badge-green-text); }
.hc-badge.is-amber, .hc-badge.is-review, .hc-badge.is-attempted, .hc-badge.is-call-back,
.hc-badge.is-pending, .hc-badge.is-queued, .hc-badge.is-scheduled, .hc-badge.is-warning { background: var(--hc-badge-amber-bg); color: var(--hc-badge-amber-text); }
.hc-badge.is-grey, .hc-badge.is-no-contact, .hc-badge.is-unknown, .hc-badge.is-expired,
.hc-badge.is-not-interested { background: var(--hc-badge-grey-bg); color: var(--hc-badge-grey-text); }
.hc-badge.is-red, .hc-badge.is-stopped, .hc-badge.is-failed, .hc-badge.is-capped,
.hc-badge.is-suspended, .hc-badge.is-invalid-code, .hc-badge.is-danger { background: var(--hc-badge-red-bg); color: var(--hc-badge-red-text); }
.hc-badge.is-blue, .hc-badge.is-quoted, .hc-badge.is-sent, .hc-badge.is-forwarded,
.hc-badge.is-info { background: var(--hc-badge-blue-bg); color: var(--hc-badge-blue-text); }

/* 11. Banners ------------------------------------------------------------- */
.hc-banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: 10px; border: 1px solid;
  font-size: 14px; line-height: 1.45;
  transition: opacity .25s, transform .25s;
}
.hc-banner > .hc-icon { flex: 0 0 18px; margin-top: 2px; }
.hc-banner-body { flex: 1 1 auto; min-width: 0; }
.hc-banner-title { font-weight: 600; }
.hc-banner-action { margin-left: auto; align-self: center; font-weight: 600; white-space: nowrap; color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.hc-banner-close { margin-left: 4px; align-self: center; width: 28px; height: 28px; padding: 0; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: transparent; color: inherit; opacity: .7; }
.hc-banner-close:hover { opacity: 1; background: rgba(0, 0, 0, .06); }
.hc-banner.is-leaving { opacity: 0; transform: translateY(-4px); }
.hc-banner--warning { background: var(--hc-banner-warning-bg); border-color: var(--hc-banner-warning-border); color: var(--hc-banner-warning-text); }
.hc-banner--alert   { background: var(--hc-banner-alert-bg);   border-color: var(--hc-banner-alert-border);   color: var(--hc-banner-alert-text); }
.hc-banner--info    { background: var(--hc-banner-info-bg);    border-color: var(--hc-banner-info-border);    color: var(--hc-banner-info-text); }
.hc-banner--success { background: var(--hc-banner-success-bg); border-color: var(--hc-banner-success-border); color: var(--hc-banner-success-text); }

/* 12. Buttons ------------------------------------------------------------- */
.hc-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px;
  font-size: 14px; font-weight: 500; line-height: 1; white-space: nowrap;
  border: 1px solid transparent; border-radius: var(--hc-radius-sm);
  background: var(--hc-subtle); color: var(--hc-text);
  cursor: pointer; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.hc-btn:hover { text-decoration: none; background: var(--hc-border); }
.hc-btn .hc-icon { width: 16px; height: 16px; }
.hc-btn--primary { background: var(--hc-blue); color: #fff; }
.hc-btn--primary:hover { background: var(--hc-blue-hover); }
.hc-btn--secondary { background: var(--hc-card); color: var(--hc-text); border-color: var(--hc-border-strong); }
.hc-btn--secondary:hover { background: var(--hc-hover); }
.hc-btn--danger { background: var(--hc-red); color: #fff; }
.hc-btn--danger:hover { background: var(--hc-red-hover); }
.hc-btn--danger-outline { background: transparent; color: var(--hc-red); border-color: var(--hc-red); }
.hc-btn--danger-outline:hover { background: rgba(192, 57, 43, .08); }
.hc-btn--ghost { background: transparent; color: var(--hc-text-2); }
.hc-btn--ghost:hover { background: var(--hc-hover); }
.hc-btn--sm { height: 30px; padding: 0 10px; font-size: 13px; }
.hc-btn--sm .hc-icon { width: 14px; height: 14px; }
.hc-btn--block { width: 100%; }
.hc-btn--icon { width: 36px; padding: 0; }
.hc-btn--sm.hc-btn--icon { width: 30px; }
.hc-btn:disabled, .hc-btn[aria-disabled="true"] { opacity: .55; cursor: not-allowed; pointer-events: none; }
.hc-btn-group { display: inline-flex; flex-wrap: wrap; gap: 8px; }

/* 13. Forms --------------------------------------------------------------- */
.hc-form { display: flex; flex-direction: column; gap: 16px; }
.hc-form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.hc-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hc-label { font-size: 13px; font-weight: 500; color: var(--hc-text); }
.hc-label .is-required { color: var(--hc-red); }
.hc-input, .hc-select, .hc-textarea {
  width: 100%; height: 38px; padding: 0 12px;
  font-size: 14px; color: var(--hc-text); background: var(--hc-input-bg);
  border: 1px solid var(--hc-border-strong); border-radius: var(--hc-radius-sm);
  transition: border-color .12s, box-shadow .12s;
}
.hc-input::placeholder, .hc-textarea::placeholder { color: var(--hc-muted); }
.hc-input:focus, .hc-select:focus, .hc-textarea:focus { outline: none; border-color: var(--hc-blue); box-shadow: 0 0 0 3px var(--hc-ring); }
.hc-input:disabled, .hc-select:disabled, .hc-textarea:disabled { background: var(--hc-subtle); color: var(--hc-muted); cursor: not-allowed; }
.hc-input[readonly] { background: var(--hc-subtle); }
.hc-textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.hc-select {
  appearance: none; -webkit-appearance: none; padding-right: 36px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.hc-input--sm, .hc-select--sm { height: 32px; font-size: 13px; }
.hc-input-group { display: flex; align-items: stretch; }
.hc-input-group .hc-input { border-radius: var(--hc-radius-sm) 0 0 var(--hc-radius-sm); }
.hc-input-group .hc-btn { border-radius: 0 var(--hc-radius-sm) var(--hc-radius-sm) 0; height: 38px; }
.hc-help { font-size: 12px; color: var(--hc-muted); }
.hc-error { font-size: 12px; color: var(--hc-red); }
.hc-field.is-invalid .hc-input, .hc-field.is-invalid .hc-select, .hc-field.is-invalid .hc-textarea { border-color: var(--hc-red); }
.hc-field.is-invalid .hc-input:focus, .hc-field.is-invalid .hc-select:focus, .hc-field.is-invalid .hc-textarea:focus { box-shadow: 0 0 0 3px rgba(192, 57, 43, .22); }
.hc-check { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; cursor: pointer; }
.hc-check input { width: 16px; height: 16px; flex: 0 0 16px; margin: 2px 0 0; accent-color: var(--hc-blue); cursor: pointer; }
.hc-check .hc-help { display: block; }
.hc-toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; }
.hc-toggle input { position: absolute; width: 1px; height: 1px; margin: 0; opacity: 0; }
.hc-toggle-track { position: relative; width: 38px; height: 22px; flex: 0 0 38px; border-radius: 999px; background: var(--hc-border-strong); transition: background .15s; }
.hc-toggle-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.hc-toggle input:checked + .hc-toggle-track { background: var(--hc-blue); }
.hc-toggle input:checked + .hc-toggle-track::after { transform: translateX(16px); }
.hc-toggle input:focus-visible + .hc-toggle-track { outline: 2px solid var(--hc-blue); outline-offset: 2px; }
.hc-toggle input:disabled + .hc-toggle-track { opacity: .5; }
.hc-form-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.hc-form-actions.is-start { justify-content: flex-start; }
.hc-fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.hc-legend { padding: 0; margin-bottom: 10px; font-size: 14px; font-weight: 600; }

/* 14. Tabs ---------------------------------------------------------------- */
.hc-tabs { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; border-bottom: 1px solid var(--hc-border); overflow-x: auto; }
.hc-tab {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 10px 14px; margin-bottom: -1px;
  font-size: 14px; font-weight: 500; white-space: nowrap; color: var(--hc-muted);
  border: 0; border-bottom: 2px solid transparent; background: none; text-decoration: none;
  transition: color .12s, border-color .12s;
}
.hc-tab:hover { color: var(--hc-text); text-decoration: none; }
.hc-tab.is-active { color: var(--hc-blue); border-bottom-color: var(--hc-blue); }
.hc-tab-count { font-size: 11px; font-weight: 600; padding: 0 6px; border-radius: 999px; background: var(--hc-subtle); color: var(--hc-muted); }
.hc-tab.is-active .hc-tab-count { background: var(--hc-pill-bg); color: var(--hc-pill-text); }
.hc-tab-panel { padding-top: 16px; }
.hc-tab-panel[hidden] { display: none; }

/* 15. KV list · details · chips ------------------------------------------ */
.hc-kv { display: grid; grid-template-columns: minmax(120px, 180px) 1fr; gap: 10px 24px; margin: 0; font-size: 14px; }
.hc-kv dt { font-weight: 500; color: var(--hc-muted); }
.hc-kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.hc-kv--tight { gap: 6px 16px; }

.hc-details { border: 1px solid var(--hc-border); border-radius: 10px; background: var(--hc-card); }
.hc-details summary { display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-weight: 500; cursor: pointer; list-style: none; border-radius: 10px; }
.hc-details summary::-webkit-details-marker { display: none; }
.hc-details summary::before {
  content: ""; width: 16px; height: 16px; flex: 0 0 16px; transition: transform .15s;
  background: no-repeat center / 16px url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/svg%3E");
}
.hc-details[open] summary::before { transform: rotate(90deg); }
.hc-details[open] summary { border-bottom: 1px solid var(--hc-border); border-radius: 10px 10px 0 0; }
.hc-details-body { padding: 14px; font-size: 14px; }

.hc-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.hc-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 30px; padding: 0 12px; border-radius: 999px;
  font-size: 13px; font-weight: 500; white-space: nowrap;
  background: var(--hc-card); color: var(--hc-text-2); border: 1px solid var(--hc-border-strong);
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s, color .12s;
}
.hc-chip:hover { background: var(--hc-hover); text-decoration: none; }
.hc-chip.is-active { background: var(--hc-pill-bg); border-color: var(--hc-blue); color: var(--hc-pill-text); }
.hc-chip .hc-icon { width: 14px; height: 14px; }
.hc-chip-count { font-size: 11px; font-weight: 600; opacity: .8; }
.hc-chips-label { font-size: 13px; color: var(--hc-muted); margin-right: 4px; }

/* Meter — a ratio against a cap (SMS sends, code attempts). The track is a
   lighter step of the fill's own hue so state reads across the whole bar. */
.hc-meter { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--hc-muted); }
.hc-meter-track { flex: 1 1 auto; height: 8px; border-radius: 999px; background: var(--hc-pill-bg); overflow: hidden; }
.hc-meter-fill { height: 100%; border-radius: inherit; background: var(--hc-blue); transition: width .2s; }
.hc-meter--warning .hc-meter-track { background: var(--hc-badge-amber-bg); }
.hc-meter--warning .hc-meter-fill { background: var(--hc-orange); }
.hc-meter--danger .hc-meter-track { background: var(--hc-badge-red-bg); }
.hc-meter--danger .hc-meter-fill { background: var(--hc-red); }
.hc-meter-value { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Avatar — initials circle for users / team lists */
.hc-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 12px; font-weight: 600; letter-spacing: .02em;
  background: var(--hc-pill-bg); color: var(--hc-pill-text);
}
.hc-avatar--sm { width: 24px; height: 24px; font-size: 10px; }
.hc-avatar-group { display: inline-flex; }
.hc-avatar-group .hc-avatar { border: 2px solid var(--hc-card); margin-left: -8px; }
.hc-avatar-group .hc-avatar:first-child { margin-left: 0; }

/* 16. Empty state · pagination ------------------------------------------- */
.hc-empty { padding: 40px 20px; text-align: center; color: var(--hc-muted); }
.hc-empty-icon { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin-bottom: 12px; border-radius: 12px; background: var(--hc-subtle); color: var(--hc-muted); }
.hc-empty-title { margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--hc-text); }
.hc-empty-text { margin: 0 auto 16px; max-width: 420px; font-size: 13px; }

.hc-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.hc-pagination-info { font-size: 13px; color: var(--hc-muted); }
.hc-pagination-list { display: flex; align-items: center; gap: 4px; margin: 0; padding: 0; list-style: none; }
.hc-page-link {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  font-size: 13px; font-weight: 500; color: var(--hc-text);
  border: 1px solid var(--hc-border); border-radius: var(--hc-radius-sm); background: var(--hc-card);
  text-decoration: none;
}
.hc-page-link:hover { background: var(--hc-hover); text-decoration: none; }
.hc-page-link.is-active { background: var(--hc-blue); border-color: var(--hc-blue); color: #fff; }
.hc-page-link.is-disabled { opacity: .45; pointer-events: none; }
.hc-page-link .hc-icon { width: 16px; height: 16px; }
.hc-page-gap { display: inline-flex; align-items: center; justify-content: center; min-width: 24px; height: 32px; color: var(--hc-muted); }

/* 17. Copy / tooltip · charts -------------------------------------------- */
[data-copy] { position: relative; }
.hc-copy {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px; border-radius: 6px;
  background: var(--hc-subtle); border: 1px solid var(--hc-border); color: var(--hc-text);
  cursor: pointer; transition: border-color .12s, background .12s;
}
.hc-copy:hover { border-color: var(--hc-border-strong); }
.hc-copy .hc-icon { width: 14px; height: 14px; color: var(--hc-muted); }
.hc-code { font-family: var(--hc-mono); font-size: 13px; font-weight: 600; letter-spacing: .06em; }
.hc-tip {
  position: absolute; left: 50%; bottom: calc(100% + 6px); z-index: 5;
  transform: translate(-50%, 4px);
  padding: 5px 8px; border-radius: 6px;
  font-size: 11px; font-weight: 500; line-height: 1; white-space: nowrap;
  background: var(--hc-tooltip-bg); color: var(--hc-tooltip-text);
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s;
}
.hc-tip.is-visible { opacity: 1; transform: translate(-50%, 0); }

.hc-chart { position: relative; width: 100%; height: 280px; } /* height includes the x-axis band */
.hc-chart--sm { height: 200px; }
.hc-chart--lg { height: 360px; }
.hc-chart.is-loading::after { content: "Loading chart…"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--hc-muted); }
.hc-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 8px 0 0; padding: 0; list-style: none; font-size: 12px; color: var(--hc-muted); }
.hc-legend li { display: inline-flex; align-items: center; gap: 6px; }
.hc-legend-swatch { width: 10px; height: 10px; border-radius: 3px; }

/* 18. Utilities · responsive --------------------------------------------- */
.hc-muted { color: var(--hc-muted); }
.hc-small { font-size: 12px; }
.hc-strong { font-weight: 600; }
.hc-num { font-variant-numeric: tabular-nums; }
.hc-text-right { text-align: right; }
.hc-text-center { text-align: center; }
.hc-truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hc-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.hc-row--between { justify-content: space-between; }
.hc-mt-1 { margin-top: 8px; }  .hc-mt-2 { margin-top: 16px; }  .hc-mt-3 { margin-top: 24px; }
.hc-mb-1 { margin-bottom: 8px; } .hc-mb-2 { margin-bottom: 16px; } .hc-mb-3 { margin-bottom: 24px; }
.hc-hide { display: none !important; }
.hc-swatch { width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--hc-border); }

@media (min-width: 960px) {
  .hc-menu-btn, .hc-sidebar-close { display: none; } /* after .hc-icon-btn so it wins */
}
@media (max-width: 959px) {
  .hc-sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; height: 100%; z-index: 50;
    transform: translateX(-100%); transition: transform .2s ease;
  }
  .hc-shell.is-nav-open .hc-sidebar { transform: none; box-shadow: var(--hc-shadow-lg); }
  .hc-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 20, 25, .5); opacity: 0; pointer-events: none; transition: opacity .2s; }
  .hc-shell.is-nav-open .hc-backdrop { opacity: 1; pointer-events: auto; }
  .hc-topbar { position: static; padding: 10px 16px; }
  .hc-content { padding: 16px; }
  .hc-banners { padding: 12px 16px 0; }
  .hc-grid--2, .hc-grid--3, .hc-grid--4 { grid-template-columns: 1fr; }
}
@media (max-width: 639px) {
  .hc-search { flex: 1 1 100%; order: 10; }
  .hc-search-input { width: 100%; }
  .hc-card { padding: 16px; }
  .hc-card--flush { padding: 0; }
  .hc-card--flush .hc-card-header, .hc-card--flush .hc-card-body { padding: 14px 16px; }
  .hc-card--flush .hc-table th:first-child, .hc-card--flush .hc-table td:first-child { padding-left: 16px; }
  .hc-card--flush .hc-table th:last-child, .hc-card--flush .hc-table td:last-child { padding-right: 16px; }
  .hc-kpi-value { font-size: 24px; }
  .hc-kv { grid-template-columns: 1fr; gap: 2px 0; }
  .hc-kv dd { margin-bottom: 10px; }
  .hc-form-actions { flex-direction: column; align-items: stretch; }
  .hc-form-actions .hc-btn { width: 100%; }
  .hc-pagination { justify-content: center; }
  .hc-banner { flex-wrap: wrap; }
  .hc-banner-action { margin-left: 30px; flex-basis: 100%; }
  .hc-chart { height: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media print {
  .hc-sidebar, .hc-topbar, .hc-backdrop, .hc-banner-close { display: none !important; }
  .hc-content { padding: 0; }
  .hc-card { box-shadow: none; break-inside: avoid; }
}
