/* ============================================================
   gtm panel skin: matches the hq client portal (gncyai/hq src/components/portal/*)
   on top of the AIGNCY design kit (static/aigncy/tokens.css + fonts.css).
   Values are the portal's RENDERED values (hq globals.css overrides applied).
   The legacy class names (.card, .btn, .pill, ...) and CSS variables (--bg,
   --accent, ...) used across templates/ are kept and re-pointed here.
   ============================================================ */

/* ---------- Accent + display face ---------- */
:root {
  /* Client portal accent (PortalClientHome: #E11D48). One place to change it. */
  --ag-accent: #e11d48;
  --ag-accent-text: #fb7185;
  --ag-accent-soft: rgb(225 29 72 / 0.16);
  --ag-accent-ink: #ffffff;
  /* hq owner's call 2026-09-26: display face is Chaney, default letterforms. */
  --ag-font-display: 'Chaney', 'Arial Black', system-ui, sans-serif;
  --ag-display-tracking: 0.01em;

  /* Portal's rendered neutrals */
  --p-line: rgb(255 255 255 / 0.14);
  --p-line-soft: rgb(255 255 255 / 0.06);
  --p-fill: rgb(255 255 255 / 0.035);
  --p-fill-2: rgb(255 255 255 / 0.045);
  --p-fill-3: rgb(255 255 255 / 0.06);
  --p-fg: #ffffff;
  --p-fg-2: rgb(255 255 255 / 0.86);
  --p-fg-3: rgb(255 255 255 / 0.74);
  --p-fg-4: rgb(255 255 255 / 0.55);
  --p-sidebar-w: 240px;

  /* ---- Legacy aliases used by inline styles in templates/ ---- */
  --bg: var(--ag-bg);
  --bg-elev: var(--p-fill);
  --bg-elev-2: var(--p-fill-3);
  --border: var(--p-line);
  --border-bright: rgb(255 255 255 / 0.25);
  --text: var(--p-fg);
  --text-dim: var(--p-fg-3);
  --text-faint: var(--p-fg-4);
  --accent: var(--ag-accent-text);
  --accent-bright: #fda4af;
  --accent-dim: var(--ag-accent);
  --good: #6ee7b7;
  --warn: #fcd34d;
  --bad: #fda4af;
  --orange: #fdba74;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body {
  font-family: var(--ag-font-body);
  font-feature-settings: normal;
  font-size: 15px;
  line-height: 1.5;
  color: var(--p-fg-2);
  background: #000;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: var(--ag-accent-text); text-decoration: none; transition: color var(--ag-dur-1) var(--ag-ease-out); }
a:hover { color: var(--accent-bright); }
::selection { background: var(--ag-accent-soft); color: #fff; }

/* ---------- Ground: accent glow + dot grid (PortalHome) ---------- */
.p-ground { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.p-ground .glow {
  position: absolute; top: -160px; left: 50%; transform: translateX(-50%);
  width: 900px; height: 480px; border-radius: 50%;
  background: var(--ag-accent); opacity: 0.14; filter: blur(120px);
}
.p-ground .dots {
  position: absolute; inset: 0; opacity: 0.3;
  background-image: radial-gradient(rgb(255 255 255 / 0.05) 1px, transparent 1px);
  background-size: 26px 26px;
}

/* ---------- Sidebar (≥1024px) ---------- */
.p-sidebar {
  position: fixed; top: 0; bottom: 0; left: 0; z-index: 20;
  width: var(--p-sidebar-w);
  display: flex; flex-direction: column;
  padding: 28px 16px 20px;
  background: rgb(0 0 0 / 0.4);
  -webkit-backdrop-filter: blur(24px); backdrop-filter: blur(24px);
  border-right: 1px solid var(--p-line);
  overflow-y: auto;
}
.p-brand { display: flex; align-items: center; gap: 10px; padding: 0 12px 24px; color: #fff; }
.p-brand img { height: 22px; width: auto; display: block; }
.p-brand span {
  font-family: var(--ag-font-display); text-transform: uppercase;
  letter-spacing: var(--ag-display-tracking); font-size: 14px; line-height: 1; color: #fff;
}
.p-brand small {
  display: block; margin-top: 4px;
  font-family: var(--ag-font-mono); font-size: 10.5px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--p-fg-4);
}
.p-nav-group { margin-top: 18px; }
.p-nav-label {
  padding: 0 12px 6px;
  font-family: var(--ag-font-mono); font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--p-fg-4);
}
.p-nav a {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 14px;
  font-size: 14px; font-weight: 500; color: var(--p-fg-3);
  transition: background var(--ag-dur-1) var(--ag-ease-out), color var(--ag-dur-1) var(--ag-ease-out);
}
.p-nav a:hover { color: #fff; background: rgb(255 255 255 / 0.04); }
.p-nav a.active { color: #fff; background: var(--p-fill-3); }
.p-nav a.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--ag-accent);
}
.p-nav a .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.35; flex: none; }
.p-nav a.active .dot { background: var(--ag-accent); opacity: 1; }
.p-sidebar-foot { margin-top: auto; padding-top: 20px; }
.p-signout {
  display: block; text-align: center; padding: 8px 12px; border-radius: 14px;
  border: 1px solid rgb(255 255 255 / 0.15); color: var(--p-fg-3); font-size: 13px; font-weight: 600;
}
.p-signout:hover { border-color: rgb(255 255 255 / 0.35); color: #fff; }

/* ---------- Content column ---------- */
.p-main { position: relative; z-index: 1; min-height: 100vh; }
.container { max-width: 1120px; margin: 0 auto; padding: 40px 32px 72px; }
body.p-authed .p-main { padding-left: var(--p-sidebar-w); }
body:not(.p-authed) .container { max-width: 440px; padding-top: 12vh; }

/* Page title: Chaney uppercase (portal h1) */
h1 {
  font-family: var(--ag-font-display); font-weight: 400;
  text-transform: uppercase; letter-spacing: var(--ag-display-tracking);
  line-height: 1.05; font-size: 30px; color: #fff; margin-bottom: 10px;
}
/* Section header: mono eyebrow */
h2 {
  font-family: var(--ag-font-mono); font-weight: 500;
  font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase;
  color: rgb(255 255 255 / 0.82); margin: 32px 0 12px;
}
h3 { font-size: 15px; font-weight: 600; color: #fff; }
p { color: var(--p-fg-2); }

/* ---------- Cards ---------- */
.card {
  background: var(--p-fill);
  border: 1px solid var(--p-line);
  border-radius: 24px;
  padding: 20px 24px;
  margin-bottom: 16px;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.07), 0 10px 36px -16px rgb(0 0 0 / 0.8);
  transition: border-color var(--ag-dur-3) var(--ag-ease-out), transform var(--ag-dur-3) var(--ag-ease-out);
}
.card:hover { border-color: rgb(255 255 255 / 0.18); }
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.cards .card { margin-bottom: 0; padding: 20px; }
/* Stat numbers: Satoshi 600, tabular (portal does not use Chaney for numbers) */
.stat-value {
  font-family: var(--ag-font-body); font-weight: 600;
  font-size: 34px; line-height: 40px; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; color: #fff;
}
.stat-label {
  margin-top: 6px;
  font-family: var(--ag-font-mono); font-size: 11.5px; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--p-fg-3);
}

/* ---------- Forms ---------- */
label {
  display: block; margin: 16px 0 6px;
  font-family: var(--ag-font-mono); font-size: 11.5px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--p-fg-3); font-weight: 500;
}
label:first-child, label:first-of-type { margin-top: 0; }
input[type="text"], input[type="password"], input[type="number"],
input[type="email"], input[type="search"], input[type="url"], input[type="date"],
input[type="datetime-local"], input[type="time"], textarea, select {
  width: 100%;
  padding: 10px 14px;
  background: var(--p-fill-2);
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 14px;
  color: #fff;
  font-size: 15px; font-family: inherit;
  transition: border-color var(--ag-dur-1) var(--ag-ease-out);
}
textarea { border-radius: 16px; resize: vertical; min-height: 100px; line-height: 1.5; }
input[type="date"], input[type="datetime-local"], input[type="time"] { color-scheme: dark; font-family: var(--ag-font-mono); font-size: 13px; }
input::placeholder, textarea::placeholder { color: rgb(255 255 255 / 0.3); }
input:focus, textarea:focus, select:focus { outline: none; border-color: rgb(255 255 255 / 0.25); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--p-fg-3) 50%), linear-gradient(135deg, var(--p-fg-3) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
select option { background: #0c0c0f; color: #fff; }
/* Compact selects/inputs inside tables and inline forms (status pickers etc.) */
td select, td input[type="text"], td input[type="number"] {
  width: auto; min-width: 0; padding: 4px 28px 4px 10px; font-size: 12.5px; border-radius: 999px;
  background-position: calc(100% - 15px) 50%, calc(100% - 10px) 50%;
}
td input[type="text"], td input[type="number"] { padding: 4px 10px; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--ag-accent); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px;
  background: var(--ag-accent); color: var(--ag-accent-ink);
  border: 1px solid transparent; border-radius: 14px;
  cursor: pointer; font-family: inherit; font-size: 13.5px; font-weight: 600;
  transition: filter var(--ag-dur-1) var(--ag-ease-out), transform var(--ag-dur-1) var(--ag-ease-out), background var(--ag-dur-1);
}
.btn:hover { filter: brightness(1.12); color: var(--ag-accent-ink); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .p-nav a:focus-visible { outline: 2px solid var(--ag-accent-text); outline-offset: 2px; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 12px; }
.btn-secondary { background: transparent; color: var(--p-fg-2); border-color: var(--p-line); }
.btn-secondary:hover { filter: none; background: rgb(255 255 255 / 0.04); color: #fff; border-color: rgb(255 255 255 / 0.25); }
.btn-danger { background: var(--ag-error-soft); color: #fda4af; border-color: rgb(251 113 133 / 0.3); }
.btn-danger:hover { color: #fff; background: rgb(251 113 133 / 0.25); filter: none; }
.btn-warn { background: var(--ag-pending); color: #000; }
.btn-warn:hover { color: #000; }

/* ---------- Flash (kit toast look, inline) ---------- */
.flash {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin-bottom: 16px; border-radius: 16px;
  font-size: 14px; color: #fff;
  background: var(--ag-glass); -webkit-backdrop-filter: blur(var(--ag-glass-blur)); backdrop-filter: blur(var(--ag-glass-blur));
  border: 1px solid var(--p-line);
}
.flash::before { content: ""; width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--p-fg-3); }
.flash-success::before { background: var(--ag-live); box-shadow: 0 0 10px var(--ag-live); }
.flash-error::before { background: var(--ag-error); box-shadow: 0 0 10px var(--ag-error); }
.flash-success { border-color: rgb(46 230 111 / 0.25); }
.flash-error { border-color: rgb(255 90 90 / 0.3); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; padding: 10px 16px;
  font-family: var(--ag-font-mono); font-weight: 500;
  font-size: 11.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--p-fg-3); background: transparent;
  border-bottom: 1px solid var(--p-line);
}
td { padding: 12px 16px; border-bottom: 1px solid var(--p-line-soft); vertical-align: top; color: var(--p-fg-2); }
tr:last-child td { border-bottom: none; }
tbody tr { transition: background var(--ag-dur-1) var(--ag-ease-out); }
tr:hover td { background: rgb(255 255 255 / 0.03); }
td a { color: #fff; font-weight: 500; }
td a:hover { color: var(--ag-accent-text); }

/* Lead score cells (leads.html): tabular, colour by band */
.score-cell { font-weight: 700; font-variant-numeric: tabular-nums; }
.score-hot { color: var(--good); }
.score-warm { color: var(--warn); }
.score-cold { color: var(--text-dim); }

/* ---------- Status pills (portal invoice pills) ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; border: 1px solid transparent;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.025em; text-transform: uppercase;
  line-height: 1.6; white-space: nowrap;
}
.pill-good  { color: #6ee7b7; background: rgb(52 211 153 / 0.10); border-color: rgb(52 211 153 / 0.20); }
.pill-warn  { color: #fcd34d; background: rgb(251 191 36 / 0.10); border-color: rgb(251 191 36 / 0.20); }
.pill-bad   { color: #fda4af; background: rgb(251 113 133 / 0.10); border-color: rgb(251 113 133 / 0.20); }
.pill-info  { color: var(--ag-accent-text); background: var(--p-fill-3); border-color: rgb(255 255 255 / 0.08); }
.pill-muted { color: rgb(255 255 255 / 0.70); background: rgb(255 255 255 / 0.04); border-color: rgb(255 255 255 / 0.08); }

/* ---------- Toggle ---------- */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0; border-radius: 999px;
  background: rgb(255 255 255 / 0.14); transition: background var(--ag-dur-2) var(--ag-ease-out);
}
.toggle-slider:before {
  position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: transform var(--ag-dur-2) var(--ag-ease-spring);
}
.toggle input:checked + .toggle-slider { background: var(--ag-accent); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }
.toggle input:focus-visible + .toggle-slider { outline: 2px solid var(--ag-accent-text); outline-offset: 2px; }

/* ---------- Utilities ---------- */
.muted { color: var(--p-fg-3); }
.faint { color: var(--p-fg-4); }
.mono, code, pre { font-family: var(--ag-font-mono); }
.mono { font-size: 12.5px; }
code { font-size: 12.5px; background: var(--p-fill-3); padding: 1px 6px; border-radius: 6px; color: var(--p-fg-2); }
hr { border: 0; border-top: 1px solid var(--p-line-soft); margin: 16px 0; }

.pagination { display: flex; gap: 6px; margin-top: 20px; justify-content: center; }
.pagination a, .pagination span {
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600;
  border: 1px solid var(--p-line); background: var(--p-fill-2); color: var(--p-fg-2);
}
.pagination a:hover { color: #fff; border-color: rgb(255 255 255 / 0.25); }

/* ---------- Top bar (phones/tablets) ---------- */
.p-topbar { display: none; }
@media (max-width: 1023px) {
  .p-sidebar { display: none; }
  body.p-authed .p-main { padding-left: 0; }
  .p-topbar {
    display: block; position: sticky; top: 0; z-index: 20;
    background: rgb(0 0 0 / 0.72); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--p-line);
  }
  .p-topbar .p-brand { padding: 14px 16px 8px; }
  .p-topbar .p-nav { display: flex; gap: 4px; overflow-x: auto; padding: 0 12px 10px; scrollbar-width: none; }
  .p-topbar .p-nav::-webkit-scrollbar { display: none; }
  .p-topbar .p-nav .p-nav-group, .p-topbar .p-nav .p-nav { display: contents; }
  .p-topbar .p-nav-label { display: none; }
  .p-topbar .p-nav a { flex: none; padding: 6px 12px; font-size: 13px; }
  .p-topbar .p-nav a.active::before { display: none; }
  .p-topbar .p-nav a .dot { display: none; }
  .container { padding: 24px 16px 64px; }
}
@media (max-width: 680px) {
  h1 { font-size: 24px; }
  .cards { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .stat-value { font-size: 28px; line-height: 32px; }
  table { font-size: 13px; }
  th, td { padding: 9px 10px; }
  [style*="grid-template-columns: 2fr 1fr"],
  [style*="grid-template-columns: 1fr 1fr"] { grid-template-columns: 1fr !important; }
  .card { border-radius: 20px; padding: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
