/* Outreach CRM. Mobile first; two panes at >= 900px. Every interactive target >= 44px. */

:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #eef0f3;
  --border: #dde1e6;
  --text: #1b1f24;
  --text-2: #4b535d;
  --muted: #5d6570;
  --accent: #2a62c9;
  --accent-ink: #ffffff;
  --accent-soft: #e6eefb;
  --good: #1d7a45;
  --good-soft: #e3f4ea;
  --warn: #8a5a00;
  --warn-soft: #fdf3dc;
  --bad: #b3261e;
  --bad-soft: #fbe7e5;
  --series-1: #2a78d6;
  --focus: #2a62c9;
  --radius: 12px;
  --tap: 44px;
  --gutter: 16px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #111418;
    --surface: #1a1e24;
    --surface-2: #232830;
    --border: #2f353e;
    --text: #e8eaed;
    --text-2: #c3c8cf;
    --muted: #a3abb5;
    --accent: #6d9eff;
    --accent-ink: #0b1220;
    --accent-soft: #1f2b44;
    --good: #5ccf8b;
    --good-soft: #17301f;
    --warn: #f1c25b;
    --warn-soft: #33290f;
    --bad: #ff8a80;
    --bad-soft: #3a1a18;
    --series-1: #3987e5;
    --focus: #8fb4ff;
    --shadow: none;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #111418;
  --surface: #1a1e24;
  --surface-2: #232830;
  --border: #2f353e;
  --text: #e8eaed;
  --text-2: #c3c8cf;
  --muted: #a3abb5;
  --accent: #6d9eff;
  --accent-ink: #0b1220;
  --accent-soft: #1f2b44;
  --good: #5ccf8b;
  --good-soft: #17301f;
  --warn: #f1c25b;
  --warn-soft: #33290f;
  --bad: #ff8a80;
  --bad-soft: #3a1a18;
  --series-1: #3987e5;
  --focus: #8fb4ff;
  --shadow: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  overflow-x: hidden;
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1 {
  font-size: 1.35rem;
  margin: 0;
  line-height: 1.2;
}
h2 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}
h1:focus {
  outline: none;
}

[hidden] {
  display: none !important;
}

.skip {
  position: absolute;
  left: -999px;
}
.skip:focus {
  left: 8px;
  top: 8px;
  z-index: 100;
  background: var(--surface);
  padding: 8px 12px;
}

/* ---------- Top bar & navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(env(safe-area-inset-top) + 4px) var(--gutter) 4px;
  min-height: 52px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.brand {
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}
.topnav {
  display: none;
  gap: 4px;
}
.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  align-items: center;
}
.topnav a,
.tabbar a {
  color: var(--text-2);
  text-decoration: none;
  border-radius: 8px;
}
.topnav a {
  padding: 0 12px;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
}
.topnav a[aria-current],
.tabbar a[aria-current] {
  color: var(--accent);
  font-weight: 600;
}

.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  font-size: 0.75rem;
  gap: 2px;
}
.tabbar a span {
  font-size: 1.2rem;
  line-height: 1;
}

body.logged-out .tabbar,
body.logged-out .topnav {
  display: none !important;
}

/* ---------- Layout ---------- */
main {
  display: block;
  outline: none;
}
.pane {
  padding: 12px var(--gutter) 24px;
  min-width: 0;
}
.pane-detail,
.pane-page {
  display: none;
}
body.has-detail .pane-list {
  display: none;
}
body.has-detail .pane-detail {
  display: block;
}
body.is-page .pane-list,
body.is-page .pane-detail {
  display: none;
}
body.is-page .pane-page {
  display: block;
  max-width: 820px;
  margin: 0 auto;
}
.pane-placeholder {
  display: none;
}

@media (min-width: 900px) {
  body {
    padding-bottom: 0;
  }
  .tabbar {
    display: none;
  }
  .topnav {
    display: flex;
  }
  body:not(.is-page):not(.logged-out) main {
    display: grid;
    grid-template-columns: minmax(320px, 400px) 1fr;
    height: calc(100dvh - 53px);
  }
  .pane-list,
  .pane-detail {
    overflow-y: auto;
  }
  .pane-list {
    border-right: 1px solid var(--border);
  }
  body.has-detail .pane-list,
  body:not(.is-page) .pane-list {
    display: block;
  }
  body:not(.is-page) .pane-detail {
    display: block;
  }
  .pane-detail > .pane-host {
    max-width: 760px;
  }
  .pane-placeholder {
    display: block;
  }
  .back {
    display: none !important;
  }
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}
.pane-head h1 {
  flex: 1;
}
.back {
  min-width: var(--tap);
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  text-decoration: none;
  color: var(--text);
  margin-left: -10px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.row.wrap {
  flex-wrap: wrap;
}
.row.end {
  justify-content: flex-end;
}
.pane-host > * + * {
  margin-top: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}
.card > summary,
details > summary {
  cursor: pointer;
  min-height: var(--tap);
  display: flex;
  align-items: center;
  font-weight: 600;
  color: var(--text-2);
}

/* ---------- Text ---------- */
.muted {
  color: var(--muted);
}
.small {
  font-size: 0.875rem;
}
.pad {
  padding: 8px 4px;
}
.text-bad {
  color: var(--bad);
}
.text-warn {
  color: var(--warn);
}
.error {
  color: var(--bad);
  margin: 0;
}
p {
  margin: 0;
}

/* ---------- Controls ---------- */
.btn,
.icon-btn,
.link-btn {
  font: inherit;
  cursor: pointer;
}
.btn {
  min-height: var(--tap);
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  font-weight: 500;
  white-space: nowrap;
}
.btn:hover {
  background: var(--surface-2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
}
.btn-danger {
  color: var(--bad);
  border-color: color-mix(in srgb, var(--bad) 40%, var(--border));
}
.btn-block {
  width: 100%;
}
.btn-small {
  min-height: var(--tap);
  padding: 0 12px;
  font-size: 0.875rem;
}
.icon-btn {
  min-width: var(--tap);
  min-height: var(--tap);
  border: none;
  background: transparent;
  color: var(--text-2);
  border-radius: 10px;
  font-size: 1.1rem;
}
.icon-btn:hover {
  background: var(--surface-2);
}
.link-btn {
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  padding: 0;
}

input,
select,
textarea {
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  min-height: var(--tap);
  padding: 8px 12px;
  width: 100%;
  min-width: 0;
}
textarea {
  resize: vertical;
}
input[type='checkbox'] {
  width: 24px;
  height: 24px;
  min-height: 0;
  accent-color: var(--accent);
  flex: none;
}
input[type='file'] {
  padding: 10px;
}
.input-short {
  width: 110px;
  flex: none;
}
.row > input,
.row > select {
  flex: 1;
}
.row > .input-short {
  flex: none;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 140px;
}
.field-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
}
.hint {
  color: var(--muted);
}
.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  cursor: pointer;
}

.search {
  margin-bottom: 8px;
}

/* ---------- Lists ---------- */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.list-row:last-child {
  border-bottom: none;
}
.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  color: inherit;
  text-decoration: none;
  min-height: var(--tap);
  justify-content: center;
  overflow-wrap: anywhere;
}
a.row-main:hover strong {
  color: var(--accent);
}
.check {
  margin: 0 4px;
}
.section {
  margin-bottom: 20px;
}
.section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 12px 0 4px;
}
.section .list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
}

.call-btn {
  flex: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--good-soft);
  color: var(--good);
  font-size: 1.3rem;
  text-decoration: none;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.loading {
  color: var(--muted);
  padding: 24px 4px;
}

/* ---------- Banners, pills, badges ---------- */
.banner {
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.925rem;
}
.banner-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.banner-bad {
  background: var(--bad-soft);
  color: var(--bad);
}
.banner-info {
  background: var(--accent-soft);
  color: var(--text);
}
.pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--surface-2);
  color: var(--text-2);
  margin-left: 6px;
  white-space: nowrap;
}
.pill-good,
.pill-delivered,
.pill-sent {
  background: var(--good-soft);
  color: var(--good);
}
.pill-bounced,
.pill-complained,
.pill-failed {
  background: var(--bad-soft);
  color: var(--bad);
}
.pill-delayed,
.pill-queued {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge {
  font: inherit;
  font-size: 0.8rem;
  min-height: 32px;
  padding: 0 10px;
  border-radius: 999px;
  border: none;
  cursor: default;
}
.badge-info {
  background: var(--accent-soft);
  color: var(--accent);
}
.badge-warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge-bad {
  background: var(--bad-soft);
  color: var(--bad);
  cursor: pointer;
  min-height: var(--tap);
}

/* ---------- Org detail ---------- */
.org-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.org-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-wrap: anywhere;
}
.phone-link {
  font-size: 1.15rem;
  font-weight: 600;
  min-height: var(--tap);
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}
.stage-select {
  width: auto;
  flex: 1 1 160px;
  font-weight: 600;
}

.timeline {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
}
.tl-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 8px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.tl-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.tl-call .tl-icon {
  background: var(--good-soft);
  color: var(--good);
}
.tl-email .tl-icon {
  background: var(--accent-soft);
  color: var(--accent);
}
.tl-notes {
  white-space: pre-wrap;
  margin: 4px 0;
  overflow-wrap: anywhere;
}

/* ---------- Log call ---------- */
.call-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 16px;
}
.dial {
  min-height: 56px;
  font-size: 1.15rem;
  flex: 1 1 200px;
}
.timer-box {
  display: flex;
  align-items: center;
  gap: 8px;
}
.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.6rem;
  font-weight: 600;
  min-width: 4ch;
  text-align: right;
}
.outcome-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}
@media (min-width: 560px) {
  .outcome-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
.outcome {
  font: inherit;
  font-weight: 600;
  min-height: 64px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  padding: 8px;
}
.outcome-good {
  border-color: color-mix(in srgb, var(--good) 45%, var(--border));
}
.outcome-bad {
  border-color: color-mix(in srgb, var(--bad) 45%, var(--border));
}
.outcome[aria-pressed='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.outcome-good[aria-pressed='true'] {
  background: var(--good);
  border-color: var(--good);
  color: var(--surface);
}
.outcome-bad[aria-pressed='true'] {
  background: var(--bad);
  border-color: var(--bad);
  color: var(--surface);
}

/* ---------- Dashboard ---------- */
.tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}
@media (min-width: 700px) {
  .tiles {
    grid-template-columns: repeat(3, 1fr);
  }
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.tile-label {
  font-size: 0.8rem;
  color: var(--muted);
}
.tile-value {
  font-size: 1.6rem;
  font-variant-numeric: tabular-nums;
}
.tile-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.bars {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 30%) 1fr;
  align-items: center;
  gap: 10px;
  min-height: var(--tap);
  border-radius: 6px;
  position: relative;
}
.bar-row:hover,
.bar-row:focus-visible {
  background: var(--surface-2);
}
.bar-label {
  font-size: 0.875rem;
  color: var(--text-2);
}
.bar-track {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding-right: 64px;
}
.bar {
  height: 20px;
  background: var(--series-1);
  border-radius: 0 4px 4px 0; /* square at the baseline, rounded data-end */
}
.bar-value {
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}
.bar-tip {
  display: none;
  position: absolute;
  right: 4px;
  top: -30px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.8rem;
  padding: 4px 8px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}
.bar-row:hover .bar-tip,
.bar-row:focus-visible .bar-tip {
  display: block;
}

/* ---------- Email ---------- */
.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  margin-bottom: 12px;
  scrollbar-width: none;
}
.tab {
  font: inherit;
  min-height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-2);
  cursor: pointer;
  white-space: nowrap;
}
.tab[aria-selected='true'] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chips {
  border: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chips legend {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  margin-bottom: 4px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: var(--tap);
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}
.chip input {
  width: 20px;
  height: 20px;
}
.email-preview {
  width: 100%;
  height: 360px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}
.steps {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---------- Import ---------- */
.table-wrap {
  overflow-x: auto;
  max-width: 100%;
}
.table {
  border-collapse: collapse;
  width: 100%;
}
.table th,
.table td {
  border-bottom: 1px solid var(--border);
  padding: 6px 8px;
  text-align: left;
  white-space: nowrap;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.progress {
  width: 100%;
  height: 12px;
}

/* ---------- Login ---------- */
.pane-login {
  display: grid;
  place-items: center;
  min-height: 70dvh;
}
.login-card {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Dialog & toasts ---------- */
.dialog {
  border: none;
  border-radius: 16px;
  padding: 20px;
  width: min(440px, calc(100vw - 32px));
  background: var(--surface);
  color: var(--text);
}
.dialog::backdrop {
  background: rgb(0 0 0 / 0.45);
}
.dialog form,
.dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.dialog:not([open]) {
  display: none;
}
.toasts {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(440px, calc(100vw - 32px));
  pointer-events: none;
}
@media (min-width: 900px) {
  .toasts {
    bottom: 24px;
  }
}
.toast {
  background: var(--text);
  color: var(--bg);
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgb(0 0 0 / 0.2);
}
.toast-good {
  background: var(--good);
  color: var(--surface);
}
.toast-error {
  background: var(--bad);
  color: #fff;
}

@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}
@media (forced-colors: active) {
  .bar {
    background: CanvasText;
  }
}

body.logged-out .pane:not(.pane-login) {
  display: none !important;
}
