/* MagicPhone admin — a care protocol you can edit. */

:root {
  --paper:      #eef2f0;
  --surface:    #ffffff;
  --surface-2:  #f7faf8;
  --ink:        #12201b;
  --ink-2:      #3d4d47;
  --muted:      #6b7d75;
  --line:       #dbe4df;
  --line-soft:  #e9efec;
  --pine:       #0e6b52;
  --pine-deep:  #0a4c3a;
  --pine-wash:  #e2f0ea;
  --amber:      #9c5a22;
  --amber-wash: #f8ecdf;
  --rust:       #8c3b2f;

  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Newsreader", Georgia, serif;

  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 32, 27, .05), 0 8px 24px -12px rgba(18, 32, 27, .16);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

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

.shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.rail {
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  padding: 26px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-right: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff 0%, #f6faf8 100%);
}

.rail__brand { display: flex; align-items: center; gap: 9px; }

.rail__mark {
  width: 11px; height: 11px; border-radius: 50%;
  background: var(--pine);
  box-shadow: 0 0 0 4px var(--pine-wash);
}

.rail__name {
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.rail__agent {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.rail__agent-name { font-weight: 600; font-size: 15px; }
.rail__agent-meta { color: var(--muted); font-size: 12.5px; margin-top: 1px; }

.rail__agent-line {
  margin-top: 9px; padding-top: 9px;
  border-top: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-size: 12px; color: var(--ink-2);
}

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); flex: none; }
.dot--live { background: var(--pine); box-shadow: 0 0 0 3px var(--pine-wash); }

.rail__nav { display: flex; flex-direction: column; gap: 2px; }

.rail__nav a {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 9px 11px;
  border-radius: 8px;
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 500;
  transition: background .13s ease, color .13s ease;
}

.rail__nav a:hover { background: var(--surface-2); color: var(--ink); }

.rail__nav a.is-on {
  background: var(--pine-wash);
  color: var(--pine-deep);
  font-weight: 600;
}

.rail__nav-count {
  font-family: var(--mono); font-size: 11.5px;
  color: var(--muted);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 20px; padding: 1px 7px;
}

.rail__nav a.is-on .rail__nav-count { background: #fff; border-color: #c6ded4; color: var(--pine-deep); }

.rail__foot { margin-top: auto; }
.rail__foot-link { font-size: 13px; color: var(--muted); text-decoration: none; }
.rail__foot-link:hover { color: var(--pine); }

.main { padding: 34px 40px 96px; max-width: 1180px; }

/* ---------- page header ---------- */

.head { margin-bottom: 26px; }

.head__title {
  font-family: var(--serif);
  font-size: 33px; font-weight: 600; letter-spacing: -0.02em;
  margin: 0;
}

.head__sub { color: var(--muted); margin: 6px 0 0; max-width: 62ch; }

.head__row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }

/* ---------- stats strip ---------- */

.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; margin-bottom: 26px;
}

.stat { background: var(--surface); padding: 13px 15px; }
.stat__n { font-family: var(--mono); font-size: 22px; font-weight: 600; letter-spacing: -0.02em; }
.stat__l { font-size: 11.5px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-top: 1px; }

/* ---------- playbook ---------- */

.book {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 16px;
  overflow: hidden;
}

.book--off { opacity: .58; }

.book__head {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: var(--surface-2);
}

.book__no {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  color: var(--pine); background: var(--pine-wash);
  border-radius: 6px; padding: 3px 7px; margin-top: 2px; flex: none;
}

.book__title { font-size: 17px; font-weight: 600; margin: 0; letter-spacing: -0.01em; }
.book__desc { color: var(--muted); font-size: 13.5px; margin: 2px 0 0; }
.book__tools { margin-left: auto; display: flex; align-items: center; gap: 6px; flex: none; }

.rules { list-style: none; margin: 0; padding: 0; counter-reset: rule; }

.rule {
  display: flex; gap: 13px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.rule:last-child { border-bottom: 0; }
.rule:hover { background: var(--surface-2); }
.rule--off .rule__text { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--line); }

.rule__no {
  counter-increment: rule;
  font-family: var(--mono); font-size: 12px; color: var(--muted);
  padding-top: 2px; flex: none; min-width: 22px;
}

.rule__no::before { content: counter(rule, decimal-leading-zero); }

.rule__text { flex: 1; min-width: 0; }

.rule__tools { display: flex; gap: 5px; align-items: flex-start; flex: none; opacity: 0; transition: opacity .12s ease; }
.rule:hover .rule__tools, .rule__tools:focus-within { opacity: 1; }

.rule__add { padding: 11px 18px 15px; background: var(--surface-2); border-top: 1px solid var(--line-soft); }

/* ---------- forms ---------- */

textarea, input[type="text"], input[type="number"], select {
  width: 100%; font-family: var(--sans); font-size: 14.5px; line-height: 1.5;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px;
}

textarea { resize: vertical; min-height: 68px; }

textarea:focus, input:focus, select:focus {
  outline: none; border-color: var(--pine);
  box-shadow: 0 0 0 3px var(--pine-wash);
}

label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 5px; }

.field { margin-bottom: 17px; }
.field__hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 17px; }

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

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  padding: 7px 13px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  cursor: pointer; text-decoration: none;
  transition: background .13s ease, border-color .13s ease, color .13s ease;
}

.btn:hover { background: var(--surface-2); border-color: #c9d6d0; color: var(--ink); }

.btn--go { background: var(--pine); border-color: var(--pine); color: #fff; }
.btn--go:hover { background: var(--pine-deep); border-color: var(--pine-deep); color: #fff; }

.btn--quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 5px 8px; }
.btn--quiet:hover { background: var(--line-soft); color: var(--ink); }

.btn--danger:hover { background: #fbecea; border-color: #e8c4bd; color: var(--rust); }

.btn--sm { font-size: 12.5px; padding: 4px 9px; }

.actions { display: flex; gap: 9px; align-items: center; margin-top: 20px; }

/* ---------- tags ---------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 11.5px; font-weight: 500;
  padding: 2px 8px; border-radius: 20px;
  border: 1px solid var(--line); color: var(--muted); background: var(--surface);
  white-space: nowrap;
}

.tag--on { border-color: #bfdcd0; background: var(--pine-wash); color: var(--pine-deep); }
.tag--warn { border-color: #e6cdae; background: var(--amber-wash); color: var(--amber); }

/* ---------- prompt preview ---------- */

.prompt {
  background: #10231d; color: #d6e4de;
  border-radius: var(--radius); padding: 20px 22px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.72;
  white-space: pre-wrap; word-break: break-word;
  max-height: 420px; overflow: auto;
}

.prompt__head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; flex-wrap: wrap; margin-bottom: 11px;
}

/* ---------- transcripts ---------- */

.calls { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--surface); }

.call-row {
  display: grid; grid-template-columns: 1fr auto auto auto;
  gap: 16px; align-items: center;
  padding: 13px 17px; border-bottom: 1px solid var(--line-soft);
  text-decoration: none;
}

.call-row:last-child { border-bottom: 0; }
.call-row:hover { background: var(--surface-2); }
.call-row__who { font-family: var(--mono); font-weight: 500; }
.call-row__meta { color: var(--muted); font-size: 13px; }

.turns { display: flex; flex-direction: column; gap: 13px; }

.turn { display: flex; gap: 13px; align-items: flex-start; }
.turn--agent { flex-direction: row-reverse; }

.turn__body {
  max-width: 66%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface);
}

.turn--agent .turn__body { background: var(--pine-wash); border-color: #c9e2d7; }

.turn__who { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 3px; }
.turn__lat { font-family: var(--mono); font-size: 11px; color: var(--muted); padding-top: 13px; flex: none; }

/* ---------- try a call ---------- */

.try { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 26px; align-items: start; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.panel__title { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
.panel__note { color: var(--muted); font-size: 13px; margin: 0 0 15px; }

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

.flash {
  padding: 10px 15px; border-radius: 8px; margin-bottom: 20px;
  background: var(--pine-wash); border: 1px solid #bfdcd0; color: var(--pine-deep);
  font-weight: 500; font-size: 14px;
}

.flash--alert { background: var(--amber-wash); border-color: #e6cdae; color: var(--amber); }

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; }
  .main { padding: 24px 20px 70px; }
  .try { grid-template-columns: 1fr; }
}

/* A checkbox that sits on the same line as a save button without fighting it. */
.check {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.check input {
  width: 15px;
  height: 15px;
  accent-color: var(--pine);
}

.btn--quiet {
  color: var(--muted);
  border-color: var(--line);
  background: transparent;
}

.btn--quiet:hover { color: var(--ink); }
