/* Agency Hub dashboard. Layout: sticky top bar, summary tiles, platform list beside a latest-leads panel. */
:root {
  --bg: #ECF0F2; --surface: #FFFFFF; --surface-2: #F5F7F8; --fg: #15212A; --muted: #5A6873; --line: #D7DEE3;
  --bar: #16232C; --bar-fg: #E3EAEE;
  --accent: #0C7A70; --accent-soft: #DCF0ED; --accent-fg: #FFFFFF;
  --ok: #1B7742; --ok-soft: #DCF1E3; --warn: #9A5B00; --warn-soft: #FBEBD3;
  --bad: #A12A2A; --bad-soft: #F6DADA; --idle: #5A6873; --idle-soft: #ECEFF1;
  --g-dir: #7656A3; --g-market: #3D6DAE; --g-vetted: #2B867A; --g-local: #B15F28; --g-saas: #A2436A; --g-store: #5B772B;
  --shadow: 0 1px 2px rgba(16,30,40,.06), 0 10px 30px rgba(16,30,40,.10);
  --f: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --f-mono: ui-monospace, SFMono-Regular, Consolas, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0D1317; --surface: #151E24; --surface-2: #1A252C; --fg: #E4EBEF; --muted: #93A3AE; --line: #26333C;
    --bar: #0A1014; --bar-fg: #E3EAEE;
    --accent: #3AB3A6; --accent-soft: #163A37; --accent-fg: #06201D;
    --ok: #5CC98A; --ok-soft: #15301F; --warn: #F0B04B; --warn-soft: #35280F;
    --bad: #F08080; --bad-soft: #3A1A1A; --idle: #93A3AE; --idle-soft: #1F2B33;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 14px/1.5 var(--f); }
[hidden] { display: none !important; }
h1, h2 { margin: 0; text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.spacer { flex: 1; }
.error { color: var(--bad); background: var(--bad-soft); border-radius: 8px; padding: 8px 10px; margin: 0; font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px 13px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: var(--surface-2); }
a.btn { color: var(--fg); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.wide { width: 100%; padding: 10px; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.danger-btn { color: var(--bad); }
.btn.danger-solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.icon-btn { border: 0; background: none; font-size: 22px; line-height: 1; padding: 4px 8px; cursor: pointer; color: var(--muted); border-radius: 6px; }
.icon-btn:hover { background: var(--surface-2); }

input, select, textarea { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 7px 10px; min-width: 0; }
textarea { resize: vertical; width: 100%; }

.logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--accent-fg); display: inline-grid; place-items: center; font-weight: 700; font-size: 12px; letter-spacing: .02em; flex: none; }
.brand, .brand-lg { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 28px; display: flex; flex-direction: column; gap: 12px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 22px; margin-top: 8px; }
.login-card p { margin: 0; }
.login-card label { font-weight: 600; font-size: 13px; }

/* app */
.top { position: sticky; top: 0; z-index: 10; background: var(--bar); color: var(--bar-fg); padding-top: env(safe-area-inset-top); }
.top-in { max-width: 1280px; margin: 0 auto; display: flex; align-items: center; gap: 10px; padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left)); flex-wrap: wrap; }
.top .btn { background: transparent; color: var(--bar-fg); border-color: #2F404B; }
.top .btn:hover { background: #22323C; }
.top .muted { color: #93A3AE; }
.mode { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: #22323C; color: #B9C7CF; }
.mode.live { background: #12443F; color: #8BE0D5; }
.main { max-width: 1280px; margin: 0 auto; padding: 20px max(16px, env(safe-area-inset-right)) 48px max(16px, env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.stat b { font-size: 24px; font-weight: 650; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.on { border-color: var(--ok); }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-width: 0; }
.toolbar { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toolbar input[type=search] { flex: 1 1 200px; }
.chips { display: flex; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.chip { flex: none; padding: 4px 11px; border-radius: 20px; border: 1px solid var(--line); background: none; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.chip[aria-selected=true] { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.chip .n { font-variant-numeric: tabular-nums; opacity: .8; margin-left: 4px; }

.group-h { display: flex; align-items: center; gap: 8px; padding: 14px 14px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); }
.group-h .dot { width: 8px; height: 8px; border-radius: 2px; }
.row { display: grid; grid-template-columns: auto minmax(0, 1fr) 128px 128px 64px auto; gap: 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.row.removed .name { text-decoration: line-through; color: var(--muted); }
.pchip { width: 32px; height: 32px; border-radius: 8px; color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 11.5px; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.sub { font-size: 12px; color: var(--muted); font-family: var(--f-mono); overflow-wrap: anywhere; }
.row select { width: 100%; font-size: 12.5px; padding: 5px 8px; }
.row select.s-active { background: var(--ok-soft); color: var(--ok); border-color: transparent; font-weight: 600; }
.row select.s-paused { background: var(--warn-soft); color: var(--warn); border-color: transparent; font-weight: 600; }
.row select.s-notstarted { background: var(--idle-soft); color: var(--idle); border-color: transparent; }
.row select.s-removed { background: var(--bad-soft); color: var(--bad); border-color: transparent; }
.leads30 { font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.leads30 small { display: block; color: var(--muted); font-size: 11px; }
.acts { display: flex; gap: 6px; }
.acts .btn { padding: 5px 10px; }
.empty { padding: 32px 16px; color: var(--muted); text-align: center; }

.cat-directories { background: var(--g-dir); } .cat-marketplaces { background: var(--g-market); }
.cat-vettednetworks { background: var(--g-vetted); } .cat-localleads { background: var(--g-local); }
.cat-saaspartners { background: var(--g-saas); } .cat-storefronts { background: var(--g-store); }

.leads { padding: 14px; position: sticky; top: 72px; }
.leads h2 { font-size: 15px; }
.leads p { margin: 2px 0 10px; }
.lead-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.lead-list li { padding: 10px 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.lead-list .lt { display: flex; gap: 8px; font-size: 12px; color: var(--muted); }
.lead-list .lt .d { margin-left: auto; font-family: var(--f-mono); font-size: 11px; }
.lead-list .ls { font-size: 13px; overflow-wrap: anywhere; }
.stage { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; border-radius: 4px; background: var(--accent-soft); color: var(--accent); }

/* editor */
.editor { border: 1px solid var(--line); border-radius: 14px; padding: 0; width: min(620px, calc(100% - 24px)); max-height: calc(100% - 24px); background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }
.editor::backdrop { background: rgba(10, 18, 24, .45); }
.editor form { display: flex; flex-direction: column; max-height: calc(100vh - 24px); }
.ed-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ed-head h2 { font-size: 17px; }
.ed-body { padding: 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label, .checks legend { font-weight: 600; font-size: 12.5px; }
.field small { font-size: 11.5px; }
.checks { border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px 10px; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.checks label { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.ed-foot { display: flex; gap: 8px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.danger { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.confirm { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 12.5px; background: var(--bad-soft); color: var(--bad); padding: 6px 8px; border-radius: 8px; }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; font-weight: 500; box-shadow: var(--shadow); z-index: 100; max-width: calc(100% - 32px); }
.toast.bad { background: var(--bad); color: #fff; }

@media (max-width: 1020px) {
  .layout { grid-template-columns: 1fr; }
  .leads { position: static; }
}
@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats .stat:last-child { grid-column: span 2; }
  .row { grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "chip name leads" "status status status" "alert alert alert" "acts acts acts"; }
  .row .pchip { grid-area: chip; } .row .who { grid-area: name; } .row .leads30 { grid-area: leads; }
  .row .st { grid-area: status; } .row .am { grid-area: alert; } .row .acts { grid-area: acts; }
  .row .acts .btn { flex: 1; }
  .grid2, .checks { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  #updated { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: rise .2s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
}
