/* Dashboard styling.
 *
 * Every colour comes from callalo-tokens.css, which defines the light palette on :root and
 * redefines it under both `prefers-color-scheme: dark` and `[data-theme="dark"]`. Nothing here
 * hardcodes a hex value: a colour written here would be right in one theme and wrong in the
 * other, and would drift from the brand the first time a token changed.
 *
 * D-049 scoped this as "minimal, functional, not polished". It is meant to look considered and
 * to stop there.
 */

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

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--cl-bg);
  color: var(--cl-text);
  font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

a { color: var(--cl-accent-text); text-underline-offset: 2px; }

:is(a, button, input, select, textarea):focus-visible {
  outline: 2px solid var(--cl-focus);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
  padding: 12px 20px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--cl-surface);
  border-bottom: 1px solid var(--cl-border);
}

.wordmark {
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  color: var(--cl-text);
  text-decoration: none;
}
.wordmark span { color: var(--cl-accent-text); }

.topnav { display: flex; gap: 4px; flex-wrap: wrap; }
.topnav a {
  padding: 5px 11px;
  border-radius: 6px;
  color: var(--cl-text-muted);
  text-decoration: none;
  font-size: 14px;
}
.topnav a:hover { background: var(--cl-surface-sunken); color: var(--cl-text); }
.topnav a[aria-current="page"] {
  background: var(--cl-surface-sunken);
  color: var(--cl-text);
  font-weight: 600;
}

.topnav-soon {
  padding: 5px 11px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--cl-text-subtle);
  opacity: 0.55;
  cursor: not-allowed;
  user-select: none;
}

.whoami {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--cl-text-muted);
}
.whoami .email { max-width: 22ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.whoami form { margin: 0; }

.role {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--cl-surface-sunken);
  color: var(--cl-text-subtle);
}
.role-owner {
  background: var(--cl-status-wants-human-bg);
  color: var(--cl-status-wants-human-fg);
}

.linkish {
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--cl-accent-text);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ---------- page shell ---------- */

.page {
  flex: 1;
  width: 100%;
  max-width: 940px;
  margin: 0 auto;
  padding: 28px 20px 48px;
}

.centred {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

h1 { font-size: 24px; font-weight: 600; margin: 0 0 6px; letter-spacing: -0.015em; }
h2 { font-size: 17px; font-weight: 600; margin: 32px 0 10px; }
.lede { color: var(--cl-text-muted); margin: 0 0 26px; max-width: 62ch; }

.pagefoot {
  padding: 14px 20px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--cl-border);
  color: var(--cl-text-subtle);
  font-size: 12px;
}

/* ---------- cards and tiles ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin: 0 0 8px;
}

.tile {
  background: var(--cl-surface);
  border: 1px solid var(--cl-border);
  border-radius: 10px;
  padding: 14px 16px;
}
.tile .label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cl-text-subtle);
}
.tile .value {
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}
.tile .note { font-size: 12.5px; color: var(--cl-text-muted); }

.card {
  background: var(--cl-surface);
  border: 1px solid var(--cl-border);
  border-radius: 12px;
  padding: 22px;
}

/* ---------- login ---------- */

.signin { width: 100%; max-width: 380px; }
.signin .wordmark { font-size: 26px; display: block; margin-bottom: 4px; }
.signin .tagline { color: var(--cl-text-muted); font-size: 14px; margin: 0 0 22px; }

.field { display: block; margin-bottom: 14px; }
.field span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 5px;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  color: var(--cl-text);
  background: var(--cl-bg);
  border: 1px solid var(--cl-border-strong);
  border-radius: 7px;
}

.btn {
  appearance: none;
  width: 100%;
  padding: 10px 14px;
  font: inherit;
  font-weight: 600;
  color: var(--cl-on-primary);
  background: var(--cl-primary);
  border: 1px solid var(--cl-primary);
  border-radius: 7px;
  cursor: pointer;
}
.btn:hover { background: var(--cl-primary-hover); border-color: var(--cl-primary-hover); }
.btn.secondary {
  width: auto;
  background: var(--cl-surface);
  color: var(--cl-text);
  border-color: var(--cl-border-strong);
}

.alert {
  border-radius: 8px;
  padding: 10px 13px;
  margin: 0 0 16px;
  font-size: 14px;
  border: 1px solid var(--cl-border-strong);
  background: var(--cl-surface-sunken);
}
/* The brand defines an outcome palette; "rejected" is its red, and reusing it keeps the
   dashboard and the results report speaking the same visual language in both themes. */
.alert.bad {
  border-color: var(--cl-status-rejected-dot);
  background: var(--cl-status-rejected-bg);
  color: var(--cl-status-rejected-fg);
}

/* ---------- tables ---------- */

.tablewrap {
  overflow-x: auto;
  border: 1px solid var(--cl-border);
  border-radius: 10px;
  background: var(--cl-surface);
}
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--cl-border); }
thead th {
  background: var(--cl-surface-sunken);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cl-text-subtle);
  white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td.mono, .mono {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.empty {
  padding: 30px 20px;
  text-align: center;
  color: var(--cl-text-muted);
}

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--cl-surface-sunken);
  color: var(--cl-text-subtle);
}
.pill.verified {
  background: var(--cl-status-verified-bg);
  color: var(--cl-status-verified-fg);
}
.pill.failed {
  background: var(--cl-status-rejected-bg);
  color: var(--cl-status-rejected-fg);
}
.pill.unverified {
  background: var(--cl-status-no-answer-bg);
  color: var(--cl-status-no-answer-fg);
}

/* ---------- agents ---------- */

.pagehead { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.btn.inline { display: inline-block; width: auto; text-decoration: none; white-space: nowrap; }
.crumbs { margin: 0 0 4px; font-size: 13px; color: var(--cl-text-muted); }
.crumbs a { color: inherit; }

.agentgrid { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 18px; align-items: start; }
@media (max-width: 820px) { .agentgrid { grid-template-columns: 1fr; } }

.field textarea { resize: vertical; line-height: 1.5; }
.field small { display: block; margin-top: 5px; font-size: 12.5px; color: var(--cl-text-muted); }
.field em { display: block; margin-top: 5px; font-size: 12.5px; font-style: normal; font-weight: 600;
  color: var(--cl-status-rejected-fg); }
.field.invalid input, .field.invalid textarea, .field.invalid select {
  border-color: var(--cl-status-rejected-fg);
}
.field span i { font-style: normal; font-weight: 400; color: var(--cl-text-muted); }
.field .req { font-size: 11px; font-weight: 600; margin-left: 6px; color: var(--cl-text-subtle); }
.fieldrow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .fieldrow { grid-template-columns: 1fr; } }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }

.history h2 { margin-top: 0; font-size: 15px; }
.history ol { list-style: none; margin: 0 0 12px; padding: 0; }
.history li { display: flex; gap: 8px; align-items: center; padding: 6px 0;
  border-bottom: 1px solid var(--cl-border); font-size: 13px; }
.history li:last-child { border-bottom: 0; }
.muted { color: var(--cl-text-muted); font-size: 12.5px; }

/* ---------- place a call ---------- */

.dialcard { margin-bottom: 18px; }
.dialcard h2 { margin-top: 0; font-size: 15px; }
.dialcard .safety { margin: 12px 0 0; }
