/* ==========================================================================
   JVFarm Call Console — MOBILE ONLY.
   Designed for one-handed use on a phone, all day. There is no desktop
   layout: on wider screens the app stays phone-width and centers itself.
   Aesthetic: field-dispatch terminal. Dark cockpit, signal-green for "dial",
   monospace tabular figures so agent counts and phone numbers scan instantly.
   ========================================================================== */

:root {
  --bg: #0a0e16;
  --bg-glow: #121a2b;
  --surface: #131b2a;
  --surface-2: #1a2436;
  --surface-3: #212d43;
  --line: #26334c;
  --line-soft: #1c2739;

  --text: #eef3fb;
  --text-dim: #97a6c2;
  --text-faint: #64748f;

  --accent: #4f8cff;      /* structural / links */
  --dial: #23c268;        /* the call action — "go" */
  --dial-press: #1ba158;
  --warn: #f0a742;
  --bad: #f2635f;
  --info: #4fb6e8;
  --muted: #6b7a99;

  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;            /* minimum touch target */

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --shadow: 0 6px 20px rgba(0, 0, 0, .45);

  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  background:
    radial-gradient(120% 60% at 50% 0%, var(--bg-glow) 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 16px/1.45 ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}

/* Phone-shaped everywhere. On a desktop browser this simply centers a
   phone-width column — the layout is never anything but mobile. */
.app {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  position: relative;
  background: linear-gradient(180deg, rgba(19,27,42,.55) 0%, transparent 220px);
}

a { color: var(--accent); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
button { touch-action: manipulation; cursor: pointer; }

.mono {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- top bar ---------- */
.bar {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: calc(var(--safe-top) + 12px) 16px 12px;
  background: rgba(10, 14, 22, .88);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: center;
  gap: 12px;
}
.bar h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.2px;
  display: flex;
  align-items: baseline;
  gap: 7px;
}
.bar h1 span { color: var(--dial); }
.bar .push { flex: 1; }

.counts {
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: .6px;
  text-transform: uppercase;
  white-space: nowrap;
}
.counts b { color: var(--text-dim); }
.counts .ready { color: var(--dial); }

.iconbtn {
  height: 38px;
  min-width: 38px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.iconbtn:active { background: var(--surface-3); }
.iconbtn.alert {
  background: rgba(240,167,66,.16);
  border-color: rgba(240,167,66,.45);
  color: var(--warn);
}

/* ---------- search + filters ---------- */
.search {
  padding: 12px 16px 4px;
}
.search input {
  width: 100%;
  height: var(--tap);
  padding: 0 16px;
  font-size: 16px;              /* >=16px stops iOS zoom-on-focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
}
.search input::placeholder { color: var(--text-faint); }
.search input:focus { outline: none; border-color: var(--accent); }

/* horizontal chip rails — the only place sideways scrolling is allowed */
.rail {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.rail::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}
.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.chip.on-dial { background: var(--dial); border-color: var(--dial); color: #04240f; }

/* ---------- prospect cards ---------- */
.list { padding: 6px 12px calc(var(--safe-bottom) + 90px); }

.card {
  position: relative;
  display: block;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 14px 14px 16px;
  margin-bottom: 10px;
  overflow: hidden;
  color: inherit;
}
.card:active { background: var(--surface-2); }
/* status accent rail down the left edge */
.card::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--line);
}
.card.s-good::before  { background: var(--dial); }
.card.s-warn::before  { background: var(--warn); }
.card.s-bad::before   { background: var(--bad); }
.card.s-info::before  { background: var(--info); }
.card.s-muted::before { background: var(--muted); }

.card-top { display: flex; gap: 12px; align-items: flex-start; color: inherit; }
.card-main { flex: 1; min-width: 0; }

.name {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -.2px;
  /* keep cards uniform: two lines max */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.meta {
  margin-top: 4px;
  font-size: 13px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* agent count — the primary scan signal */
.agents {
  flex: 0 0 auto;
  text-align: right;
  line-height: 1;
}
.agents .n {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.5px;
}
.agents .lbl {
  display: block;
  margin-top: 3px;
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.agents .growth { color: var(--dial); font-size: 11px; font-weight: 600; }

.card-bottom {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* tap-to-call, right inside the card */
.call {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  background: var(--dial);
  color: #052b12;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
}
.call:active { background: var(--dial-press); }
.call.ghost {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--text-faint);
  font-weight: 600;
}

.tag {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.t-good  { background: rgba(35,194,104,.14);  color: var(--dial); border-color: rgba(35,194,104,.3); }
.t-warn  { background: rgba(240,167,66,.14);  color: var(--warn); border-color: rgba(240,167,66,.3); }
.t-bad   { background: rgba(242,99,95,.14);   color: var(--bad);  border-color: rgba(242,99,95,.3); }
.t-info  { background: rgba(79,182,232,.14);  color: var(--info); border-color: rgba(79,182,232,.3); }
.t-muted { background: rgba(107,122,153,.14); color: var(--muted); border-color: rgba(107,122,153,.3); }
.t-neutral { background: var(--surface-2); color: var(--text-faint); border-color: var(--line); }

.src { font-size: 10px; letter-spacing: .5px; text-transform: uppercase; }
.src-high, .src-state { color: var(--dial); }
.src-medium { color: var(--warn); }
.src-low { color: var(--bad); }

.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-faint);
}

/* ---------- pagination ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 4px 0;
}
.pager a, .pager span {
  flex: 1;
  height: var(--tap);
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pager span.pos { background: transparent; border: none; color: var(--text-faint); font-size: 13px; }

/* ---------- detail page ---------- */
.detail { padding: 16px 16px calc(var(--safe-bottom) + 190px); }

.back {
  display: inline-flex;
  align-items: center;
  height: 40px;
  color: var(--text-faint);
  font-size: 14px;
  font-weight: 600;
}

.hero { margin-top: 4px; }
.hero h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -.5px;
}
.hero .sub { margin-top: 6px; color: var(--text-faint); font-size: 14px; }
.hero .tags { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
}
.stat .n { font-size: 26px; font-weight: 700; letter-spacing: -.6px; line-height: 1; }
.stat .n.sm { font-size: 17px; }
.stat .lbl {
  display: block;
  margin-top: 7px;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.rows {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.row {
  display: flex;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 15px;
  align-items: baseline;
}
.row:last-child { border-bottom: none; }
.row dt {
  flex: 0 0 108px;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
}
.row dd { margin: 0; flex: 1; min-width: 0; word-break: break-word; }

.section-label {
  margin: 22px 0 10px;
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* one-tap disposition grid */
.dispo {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.dispo button {
  min-height: 52px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.2;
}
.dispo button:active { background: var(--surface-3); }
.dispo button.cur {
  border-color: currentColor;
  background: var(--surface-2);
}
.dispo button.d-good  { color: var(--dial); }
.dispo button.d-warn  { color: var(--warn); }
.dispo button.d-bad   { color: var(--bad); }
.dispo button.d-info  { color: var(--info); }
.dispo button.d-muted,
.dispo button.d-neutral { color: var(--text-dim); }

textarea {
  width: 100%;
  min-height: 110px;
  padding: 13px 14px;
  font-size: 16px;
  line-height: 1.45;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); }

/* sticky thumb-zone call bar on the detail screen */
.dock {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 40;
  padding: 10px 16px calc(var(--safe-bottom) + 10px);
  background: linear-gradient(180deg, rgba(10,14,22,0) 0%, rgba(10,14,22,.94) 22%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.dock-inner { max-width: 520px; margin: 0 auto; display: flex; gap: 10px; }
.dock .call { height: 56px; font-size: 17px; }
.dock .save {
  flex: 0 0 auto;
  min-width: 104px;
  height: 56px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.dock .save:active { background: var(--surface-3); }

/* ---------- flash messages ---------- */
.flash {
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
}
.flash.ok  { background: rgba(35,194,104,.13); color: var(--dial); border: 1px solid rgba(35,194,104,.3); }
.flash.err { background: rgba(242,99,95,.13); color: var(--bad); border: 1px solid rgba(242,99,95,.3); }

/* ---------- auth screens ---------- */
.auth {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--safe-top) + 32px) 22px calc(var(--safe-bottom) + 32px);
}
.auth .logo {
  font-size: 34px;
  font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 6px;
}
.auth .logo span { color: var(--dial); }
.auth .tagline { color: var(--text-faint); font-size: 15px; margin-bottom: 28px; line-height: 1.4; }
.auth label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 16px 0 7px;
}
.auth input {
  width: 100%;
  height: 52px;
  padding: 0 15px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.auth input:focus { outline: none; border-color: var(--accent); }
.auth .primary {
  width: 100%;
  height: 54px;
  margin-top: 26px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--dial);
  color: #052b12;
  font-size: 16px;
  font-weight: 700;
}
.auth .primary:active { background: var(--dial-press); }
.auth .alt {
  margin-top: 22px;
  text-align: center;
  font-size: 14px;
  color: var(--text-faint);
}
.auth .alt a { font-weight: 650; }

/* ---------- users admin (still phone-shaped) ---------- */
.u-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 8px;
}
.u-row .who { flex: 1; min-width: 0; }
.u-row .who b { display: block; font-size: 15px; }
.u-row .who small { color: var(--text-faint); font-size: 12px; }
.u-row button {
  height: 40px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(242,99,95,.35);
  background: rgba(242,99,95,.1);
  color: var(--bad);
  font-size: 13px;
  font-weight: 650;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 6px;
}
.form-card label {
  display: block;
  font-size: 11px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 14px 0 6px;
}
.form-card label:first-child { margin-top: 0; }
.form-card input, .form-card select {
  width: 100%;
  height: 48px;
  padding: 0 13px;
  font-size: 16px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.form-card .primary {
  width: 100%;
  height: 50px;
  margin-top: 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

/* ---------- dialer: bottom tab bar ---------- */
.tabs {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  background: rgba(10, 14, 22, .96);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding-bottom: var(--safe-bottom);
}
.tabs a {
  flex: 1;
  min-height: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .3px;
}
.tabs a .ico { font-size: 19px; line-height: 1; }
.tabs a.on { color: var(--dial); }
.tabs a.on .ico { transform: translateY(-1px); }

/* dialer screens sit above the tab bar */
.screen { padding: 16px 16px calc(var(--safe-bottom) + 86px); }
.screen.with-dock { padding-bottom: calc(var(--safe-bottom) + 152px); }

/* the assigned-prospect hero */
.assigned {
  background: linear-gradient(160deg, var(--surface-2) 0%, var(--surface) 70%);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 20px 18px;
  position: relative;
  overflow: hidden;
}
.assigned::after {
  content: "";
  position: absolute;
  inset: -60% -30% auto auto;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(35,194,104,.16) 0%, transparent 70%);
  pointer-events: none;
}
.assigned .eyebrow {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--dial);
  font-weight: 700;
}
.assigned h2 {
  margin: 8px 0 0;
  font-size: 25px;
  line-height: 1.18;
  letter-spacing: -.6px;
}
.assigned .where { margin-top: 7px; color: var(--text-dim); font-size: 14.5px; }

.dialcount {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 14px;
  padding: 7px 13px;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-dim);
}
.dialcount b { color: var(--text); }
.dialcount.zero { color: var(--text-faint); }

.queue-note {
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-faint);
  text-align: center;
}

.nextbtn {
  width: 100%;
  min-height: 52px;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 700;
}
.nextbtn:active { background: var(--surface-3); }

.savebtn {
  width: 100%;
  min-height: 50px;
  margin-top: 12px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
}

/* history list */
.hitem {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 9px;
  color: inherit;
  position: relative;
  overflow: hidden;
}
.hitem::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--line);
}
.hitem.s-good::before  { background: var(--dial); }
.hitem.s-warn::before  { background: var(--warn); }
.hitem.s-bad::before   { background: var(--bad); }
.hitem.s-info::before  { background: var(--info); }
.hitem.s-muted::before { background: var(--muted); }
.hitem .top { display: flex; gap: 10px; align-items: baseline; }
.hitem .top b { flex: 1; font-size: 15.5px; font-weight: 650; }
.hitem .dials {
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-dim);
}
.hitem .line { margin-top: 5px; font-size: 13px; color: var(--text-faint); }
.hitem .note {
  margin-top: 9px;
  padding: 9px 11px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (prefers-reduced-motion: no-preference) {
  .card { transition: background .12s ease; }
  .call, .dispo button, .chip { transition: background .12s ease, color .12s ease; }
}
