/* One stylesheet, no framework.
   Saturated colour is reserved for the safety banner and destructive actions.
   If everything is coloured, the banner stops working. */

:root {
  --ink:        #16181d;
  --ink-soft:   #5b626e;
  --ink-faint:  #8b93a1;
  --line:       #e2e5ea;
  --line-soft:  #eef0f4;
  --page:       #f7f8fa;
  --card:       #ffffff;
  --go:         #1f6f43;
  --danger:     #a3231f;
  --amber-bg:   #fdf3e0;
  --amber-line: #d9a441;
  --red-bg:     #fbe9e7;
  --red-line:   #b3312c;
  --grey-bg:    #eef0f3;
  --blue:       #1f5488;
  --blue-bg:    #e6eef7;
  --green-bg:   #e7f1ea;
  --green-line: #bcd8c6;
  --green-soft: #f1f7f3;
  --amber-ink:  #8a5a12;
  --surface:    #fbfcfd;
  --surface-2:  #fcfcfd;
  --focus:      #2b6cb0;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
}

a { color: inherit; text-decoration: none; }
a:hover { text-decoration: underline; }

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

main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 96px;
}

h1 { font-size: 22px; margin: 0 0 2px; font-weight: 600; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
h3 { font-size: 12px; margin: 0 0 8px; font-weight: 600;
     text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); }

.muted { color: var(--ink-soft); }
.small { font-size: 13px; }
.mono  { font-family: var(--mono); font-size: 13px; }
.num   { font-family: var(--mono); font-size: 13px; white-space: nowrap; }

/* ---------- safety banner: the one loud thing ---------- */

.banner {
  border-bottom: 1px solid var(--line);
  padding: 12px 24px 10px;
  background: var(--grey-bg);
}
.banner-quiet  { background: var(--grey-bg);  border-bottom-color: var(--line); }
.banner-warn   { background: var(--amber-bg); border-bottom: 2px solid var(--amber-line); }
.banner-danger { background: var(--red-bg);   border-bottom: 3px solid var(--red-line); }

.banner-main {
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.banner-text strong { font-size: 15px; }
.banner-danger .banner-text strong { color: var(--red-line); }
.banner-text span { color: var(--ink-soft); margin-left: 10px; }
.banner-meta {
  max-width: 1180px; margin: 6px auto 0;
  font-size: 13px; color: var(--ink-soft);
}
.banner-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.pill {
  font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--card); white-space: nowrap;
}
.pill-going   { color: var(--go); border-color: var(--green-line); }
.pill-stopped { color: var(--ink-soft); }

/* ---------- nav ---------- */

.nav {
  border-bottom: 1px solid var(--line);
  background: var(--card);
}
/* Same column as `main` and the banner, so nothing sits off-grid. */
.nav-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  display: flex; align-items: stretch; gap: 4px;
}
.nav-group { display: flex; align-items: stretch; gap: 2px; }
/* What is waiting on you, and what is configured. Second rank, not second
   class: quieter until it has something to say or you are standing in it. */
.nav-aside { margin-left: auto; }

.nav a {
  display: flex; align-items: center; gap: 6px;
  padding: 11px 10px 9px; font-size: 14px;
  border-bottom: 2px solid transparent;
}
.nav a:hover { text-decoration: none; border-bottom-color: var(--line); }
.nav a.on { border-bottom-color: var(--ink); font-weight: 500; }
.nav-aside a { color: var(--ink-soft); }
.nav-aside a.on, .nav-aside a:hover { color: var(--ink); }

.nav .brand {
  font-weight: 600; padding-left: 0; padding-right: 16px; margin-right: 8px;
  border-bottom: none; position: relative;
}
.nav .brand::after {
  content: ""; position: absolute; right: 0; top: 50%;
  transform: translateY(-50%); height: 18px; width: 1px; background: var(--line);
}
.nav .brand:hover { border-bottom-color: transparent; }

@media (max-width: 900px) {
  .nav-inner { flex-wrap: wrap; gap: 0 4px; }
  .nav-aside { margin-left: 0; }
}

/* ---------- buttons ---------- */

.btn {
  font: inherit; font-size: 14px; padding: 6px 13px;
  border: 1px solid var(--line); border-radius: 6px;
  background: var(--card); color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: var(--ink-faint); text-decoration: none; }
.btn-go     { background: var(--go); border-color: var(--go); color: #fff; font-weight: 500; }
.btn-danger { background: var(--card); border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-flat   { border-color: transparent; background: transparent; color: var(--ink-soft); }
.btn-block  { display: block; width: 100%; margin-bottom: 6px; }
.btn.small  { padding: 2px 8px; font-size: 12px; }

/* ---------- page furniture ---------- */

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; margin-bottom: 18px;
}
.crumb { font-size: 13px; color: var(--ink-soft); margin: 0 0 12px; }
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin-top: 16px;
}
.pager-links { display: flex; gap: 8px; }
.section { margin: 24px 0 12px; }

.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters input, .filters select {
  font: inherit; font-size: 14px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card);
}
.filters input[type=search] { min-width: 260px; }

.empty {
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 44px; text-align: center;
}
.empty-lead { font-size: 17px; margin: 0 0 4px; }
.empty p { color: var(--ink-soft); margin: 0 0 18px; }

.callout {
  border: 1px solid var(--amber-line); background: var(--amber-bg);
  border-radius: 8px; padding: 10px 14px; margin-bottom: 16px; font-size: 14px;
}
.callout-bad { border-color: var(--red-line); background: var(--red-bg); }

/* ---------- table ---------- */

.grid {
  width: 100%; border-collapse: collapse; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
}
.grid th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: .05em;
  padding: 9px 12px; border-bottom: 1px solid var(--line);
}
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr[onclick]:hover { background: var(--surface); cursor: pointer; }

.status {
  font-family: var(--mono); font-size: 12px; padding: 2px 7px;
  border-radius: 4px; background: var(--line-soft); color: var(--ink-soft);
}
.status-active    { background: var(--green-bg); color: var(--go); }
.status-replied   { background: var(--blue-bg); color: var(--blue); }
.status-bounced,
.status-halted    { background: var(--red-bg); color: var(--danger); }

.tag {
  font-size: 11px; padding: 1px 6px; border-radius: 4px;
  background: var(--line-soft); color: var(--ink-soft);
}
.tag-warn { background: var(--amber-bg); color: var(--amber-ink); }
.tag-interested     { background: var(--green-bg); color: var(--go); }
.tag-not_interested { background: var(--line-soft); }
.tag-stop           { background: var(--red-bg); color: var(--red-line); }
.tag-auto_reply     { background: var(--grey-bg); color: var(--ink-soft); }
.tag-unclear        { background: var(--amber-bg); color: var(--amber-ink); }

/* ---------- detail layout ---------- */

.detail { display: grid; grid-template-columns: minmax(0,1fr) 300px; gap: 24px; }
@media (max-width: 940px) { .detail { grid-template-columns: 1fr; } }

/* Wide tables scroll inside their own box rather than being clipped by the
   overflow:hidden that rounds their corners. */
@media (max-width: 760px) {
  .grid { display: block; overflow-x: auto; white-space: nowrap; }
}

.rail { display: flex; flex-direction: column; gap: 14px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px;
}
.card dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0 0 12px; }
.card dt { font-size: 13px; color: var(--ink-faint); }
.card dd { font-size: 13px; margin: 0; }

.schedule { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.schedule li {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0;
  border-bottom: 1px solid var(--line-soft);
}
.schedule li:last-child { border-bottom: none; }
.sched-when { font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
              flex-shrink: 0; min-width: 96px; }
.sched-sent    { color: var(--ink); }
.sched-skipped { color: var(--ink-faint); text-decoration: line-through; }
.sched-failed  { color: var(--danger); }
.sched-why     { flex-basis: 100%; padding-left: 104px; color: var(--ink-faint); }

.halt-form { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.halt-form label { display: block; font-size: 12px; color: var(--ink-faint); margin-bottom: 4px; }
.halt-form input {
  font: inherit; font-size: 13px; width: 100%; padding: 6px 8px; margin-bottom: 8px;
  border: 1px solid var(--line); border-radius: 6px;
}

/* ---------- timeline entries ---------- */

.entry {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 0; margin-bottom: 12px; overflow: hidden;
}
.mail-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 14px; background: var(--surface); border-bottom: 1px solid var(--line-soft);
  font-size: 13px;
}
.mail-head time { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; }
.mail-dir {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
  padding: 2px 7px; border-radius: 4px; background: var(--line-soft); color: var(--ink-soft);
}
.mail-dir-in      { background: var(--blue-bg); color: var(--blue); }
.mail-dir-preview { background: var(--amber-bg); color: var(--amber-ink); }
.mail-to { color: var(--ink-soft); margin-left: 8px; }

.mail-subject { padding: 10px 14px 0; font-weight: 600; }
.mail-body {
  padding: 8px 14px 12px; white-space: pre-wrap; font-size: 14px;
  line-height: 1.55; overflow-wrap: anywhere;
}
.mail-in { border-left: 3px solid var(--blue); }
.preview { border-left: 3px solid var(--amber-line); }

.entry-foot {
  padding: 7px 14px; border-top: 1px solid var(--line-soft);
  background: var(--surface-2); font-family: var(--mono);
  font-size: 11.5px; color: var(--ink-faint);
}
.quoted { padding: 0 14px 10px; }
.quoted summary { font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.quoted .mail-body { padding: 6px 0 0; border-left: 2px solid var(--line); padding-left: 10px; }

.verdict {
  padding: 9px 14px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; align-items: center; font-size: 13px;
}

.entry.note, .entry.denied { padding: 9px 14px; }
.entry.denied { border-left: 3px solid var(--amber-line); }
.entry-line {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 14px; gap: 12px;
}
.entry-line time { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; }
.entry.note .muted, .entry.denied .muted { font-size: 13px; }

/* HTMX indicator */
.htmx-indicator { display: none; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { display: block; }

/* ---------- phase 3 ---------- */

/* An unapproved campaign must look obviously unfinished. */
.unfinished {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border: 2px dashed var(--amber-line); background: var(--amber-bg);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 20px;
}
.unfinished p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
.approved-strip {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--green-line); background: var(--green-soft); border-radius: 8px;
  padding: 9px 14px; margin-bottom: 20px; font-size: 14px;
}

.stack { display: flex; flex-direction: column; gap: 14px; max-width: 620px; }
.stack-tight { display: flex; flex-direction: column; gap: 8px; }
.stack label, .stack-tight label { display: flex; flex-direction: column; gap: 4px;
  font-size: 13px; color: var(--ink-soft); }
.stack input, .stack select, .stack textarea,
.stack-tight input, .stack-tight select, .stack-tight textarea {
  font: inherit; font-size: 14px; padding: 7px 10px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; background: var(--card);
}
.stack textarea, .stack-tight textarea { font-family: var(--mono); font-size: 13px; }
.row { display: flex; gap: 12px; }
.row label { flex: 1; }
fieldset {
  border: 1px solid var(--line); border-radius: 8px; padding: 14px;
  background: var(--card); display: flex; flex-direction: column; gap: 12px;
}
legend { font-size: 12px; font-weight: 600; text-transform: uppercase;
         letter-spacing: .05em; color: var(--ink-faint); padding: 0 6px; }

ul.tight { margin: 0 0 10px; padding-left: 20px; font-size: 14px; }
ul.tight li { margin-bottom: 3px; }
ul.forbidden li { color: var(--danger); }

.card h3 { margin-top: 12px; }
.card h3:first-child { margin-top: 0; }
.card p { margin: 0 0 8px; font-size: 14px; }

.grid.quiet { font-size: 13px; }
.grid.quiet tbody tr:hover { background: transparent; cursor: default; }

.entry.reco { padding: 14px; }
.entry.reco p { margin: 6px 0; font-size: 14px; }
.reco-actions { display: flex; gap: 8px; margin-top: 10px; }
.reco-actions form { margin: 0; }

.handoff { margin-bottom: 20px; }
.handoff-body {
  background: var(--card); border: 1px solid var(--line); border-left: 3px solid var(--amber-line);
  border-radius: 8px; padding: 12px 14px; font-family: var(--mono);
  font-size: 12px; line-height: 1.5; white-space: pre-wrap; overflow-x: auto;
  margin: 0;
}

tr.bad-row { background: var(--red-bg); }
tr.bad-row td { color: var(--ink-soft); }

.status-conversing { background: var(--blue-bg); color: var(--blue); }
.status-escalated  { background: var(--amber-bg); color: var(--amber-ink); }

.tag-positive       { background: var(--green-bg); color: var(--go); }
.tag-question       { background: var(--blue-bg); color: var(--blue); }
.tag-soft_objection { background: var(--amber-bg); color: var(--amber-ink); }
.tag-not_now        { background: var(--amber-bg); color: var(--amber-ink); }

/* --- notifications ------------------------------------------------------ */

.badge {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--grey-bg);
  color: var(--ink-soft);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  line-height: 18px;
  text-align: center;
}

.notif-list { list-style: none; margin: 16px 0 0; padding: 0; }

.notif {
  background: var(--card);
  border: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 4px;
  margin-bottom: 10px;
  padding: 11px 14px;
}

.notif.unread { border-left-color: var(--danger); }

.notif-head { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }

.notif-body {
  margin: 8px 0 0;
  padding: 8px 10px;
  background: var(--line-soft);
  border-radius: 3px;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  overflow-x: auto;
}

.notif-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  font-size: 13px;
}

.notif-foot form, .row-gap form { margin: 0; }
.row-gap { display: flex; align-items: center; gap: 10px; margin-top: 12px; }

/* ---------- phase 4 ---------- */

/* Nothing below here is allowed to compete with the safety banner. Colour is
   a second signal only: every tag and pill also carries its own words, so the
   page still reads correctly in greyscale. */

/* Dashboard: what needs a person, then what the machine is doing. */

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 16px 18px; margin-bottom: 14px;
}
.panel h3 { color: var(--ink); font-size: 14px; text-transform: none;
            letter-spacing: 0; margin-bottom: 8px; }
.panel > p:last-child { margin-bottom: 0; }
/* The one place on the dashboard that earns a border weight of its own. */
.panel-loud { border-left: 3px solid var(--amber-line); }

.linklist { list-style: none; margin: 8px 0 12px; padding: 0;
            display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.linklist li { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.linklist a { font-weight: 500; text-decoration: underline;
              text-decoration-color: var(--line); text-underline-offset: 3px; }

.tiles {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px; margin-bottom: 12px;
}
.tile {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px 16px;
}
.tile-value { font-size: 24px; font-weight: 600; line-height: 1.15; }
.tile-of    { font-size: 15px; font-weight: 400; color: var(--ink-faint); }
.tile-label { font-size: 13px; margin-top: 2px; }
.tile-note  { font-size: 12px; color: var(--ink-faint); margin-top: 6px; }

/* Mail frame: a message, not a database row. */

.mail-meta {
  padding: 8px 14px 0; font-size: 13px; color: var(--ink-soft);
  display: flex; flex-wrap: wrap; gap: 4px 20px;
}
.mail-label {
  display: inline-block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint);
  min-width: 46px;
}
.quoted .mail-label, .callcard .mail-label {
  display: block; padding: 8px 0 0; min-width: 0;
}
.callcard > .mail-label { padding: 10px 14px 0; }

/* Call card: the summary is the headline, the transcript is out of the way. */

.callcard { border-left: 3px solid var(--ink-faint); }
.call-facts {
  padding: 10px 14px 0; font-size: 13px;
  display: flex; flex-wrap: wrap; gap: 4px 24px;
}
.call-summary { padding: 10px 14px 2px; }
.call-summary p { margin: 0 0 6px; font-size: 14px; }
.call-headline { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }

/* Call outcome tags. Each also spells its own name, so hue is never the signal. */
.tag-callback_requested { background: var(--green-bg); color: var(--go); }
.tag-opt_out            { background: var(--red-bg); color: var(--red-line); }
.tag-wrong_number       { background: var(--amber-bg); color: var(--amber-ink); }
.tag-no_engagement      { background: var(--line-soft); color: var(--ink-soft); }
.tag-hostile_or_legal   { background: var(--red-bg); color: var(--red-line); }
.tag-wrong_person       { background: var(--amber-bg); color: var(--amber-ink); }
.status-dormant   { background: var(--line-soft); color: var(--ink-soft); }
.status-closed    { background: var(--line-soft); color: var(--ink-faint); }
.status-completed { background: var(--green-bg); color: var(--go); }

/* System events sit in a quieter register than actual messages. */
.entry.note {
  background: transparent; border-color: transparent;
  border-left: 2px solid var(--line); border-radius: 0;
  padding: 6px 0 6px 12px; margin-bottom: 6px;
}
.entry.note .entry-line { font-size: 13px; color: var(--ink-soft); }

/* Copy review */

.seq-head { margin-bottom: 14px; }
.flagline {
  padding: 6px 14px; font-size: 13px; color: var(--amber-ink);
  background: var(--amber-bg); border-top: 1px solid var(--line-soft);
}
.flagline::before { content: "Flagged: "; font-weight: 600; }
.btn-quiet { padding: 2px 9px; font-size: 12px; color: var(--ink-soft); }

/* Settings */

.inline-form {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin: 10px 0 6px;
}
.inline-form label { font-size: 13px; color: var(--ink-soft); }
.inline-form input, .inline-form select {
  font: inherit; font-size: 14px; padding: 6px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: var(--card);
}
.inline-form input[type=tel] { min-width: 200px; font-family: var(--mono); }
.settings-dump {
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  background: var(--surface); border: 1px solid var(--line-soft);
  border-radius: 8px; padding: 12px; overflow-x: auto; margin: 0;
}

/* A sub-row carrying a disclosure under its table row. */
.grid-sub td { padding: 0 12px 8px; border-bottom: 1px solid var(--line-soft); }
.grid tbody tr.grid-sub:hover { background: transparent; cursor: default; }
.grid-sub summary { font-size: 13px; color: var(--ink-soft); cursor: pointer; }
.grid-sub .mail-body { padding: 6px 0 0; }

/* An indicator inside a row of buttons must not force a line break. */
span.htmx-indicator { display: none; }
.htmx-request span.htmx-indicator,
span.htmx-request.htmx-indicator { display: inline; }
.btn.is-busy { color: var(--ink-faint); cursor: progress; }

/* A stopped campaign, in the same register as an unfinished one: this is a
   state you are meant to notice and act on, not a failure. */
.stopped-strip {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  border: 1px solid var(--line); border-left: 3px solid var(--ink-faint);
  background: var(--grey-bg); border-radius: 10px;
  padding: 16px 18px; margin-bottom: 8px;
}
.stopped-strip p { margin: 4px 0 0; color: var(--ink-soft); font-size: 14px; }
