/* Handisly client portal — a quality-gate console.
   Cool paper, ink text, IBM Plex; the accent is the green of "Approved". */

:root {
  --paper: #f5f7f5;
  --surface: #ffffff;
  --ink: #1a2129;
  --muted: #5c6670;
  --line: #e1e5e0;
  --accent: #0f6b4f;
  --accent-ink: #0b5540;
  --bar: #161c22;
  --bar-text: #e8ebe9;
  --pending-fg: #8a5c00;  --pending-bg: #faf1d8;
  --planned-fg: #33557f;  --planned-bg: #e6edf7;
  --progress-fg: #64489c; --progress-bg: #eee9f8;
  --done-fg: #0f6b4f;     --done-bg: #e0f0e8;
  --danger-fg: #9a2020;   --danger-bg: #f6e1e1;
  --neutral-fg: #5c6670;  --neutral-bg: #ecefec;
  --sans: "IBM Plex Sans", -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--paper);
}
a { color: inherit; }
.mono { font-family: var(--mono); }
.small { font-size: 12.5px; }
.prewrap { white-space: pre-wrap; }

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

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 32px;
  height: 56px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.wordmark {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.brand-client {
  color: var(--muted);
  font-size: 13px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  white-space: nowrap;
}
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 500;
  font-size: 14px;
  padding: 6px 12px;
  border-radius: 6px;
}
.topnav a:hover { color: var(--ink); background: var(--paper); }
.topnav a.on { color: var(--ink); background: var(--paper); }
.badge {
  display: inline-block;
  margin-left: 6px;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  text-align: center;
  line-height: 18px;
}
.whoami { font-size: 12px; color: var(--muted); }

/* ---------- content pages ---------- */
.content { max-width: 880px; margin: 0 auto; padding: 40px 24px 80px; }
h1 { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; margin: 0 0 6px; }
h2 { font-size: 16px; font-weight: 600; margin: 32px 0 12px; }
.lede { color: var(--muted); margin: 0 0 28px; max-width: 60ch; }
.page-head { display: flex; align-items: center; justify-content: space-between; }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.crumbs a { color: var(--muted); }
.empty {
  padding: 40px 24px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  color: var(--muted);
  text-align: center;
  background: var(--surface);
}

/* ---------- pills & chips ---------- */
.pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}
.pill.pending { color: var(--pending-fg); background: var(--pending-bg); }
.pill.planned { color: var(--planned-fg); background: var(--planned-bg); }
.pill.in-progress { color: var(--progress-fg); background: var(--progress-bg); }
.pill.done { color: var(--done-fg); background: var(--done-bg); }
.idchip {
  font-size: 12.5px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  text-decoration: none;
}
a.idchip:hover { border-color: var(--accent); color: var(--accent-ink); }
.env {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 6px;
}
.ver { font-size: 12.5px; color: var(--muted); }

/* ---------- buttons ---------- */
.btn {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn:hover { border-color: var(--muted); }
.btn.primary, .btn.approve {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover, .btn.approve:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ---------- deployment cards ---------- */
.cardlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.card-main { flex: 1; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.card-title { font-weight: 600; font-size: 16px; text-decoration: none; }
.card-title:hover { color: var(--accent-ink); }
.card-sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.card-meta { display: flex; align-items: center; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.meta-note { font-size: 12.5px; color: var(--muted); }
.card-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---------- row lists (issues, notifications) ---------- */
.rowlist { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 18px;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row-title { flex: 1; min-width: 0; text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-title:hover { color: var(--accent-ink); }
.row-meta { font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.note .notedot { width: 7px; height: 7px; border-radius: 50%; background: transparent; flex-shrink: 0; }
.note.unread .notedot { background: var(--accent); }
.note .row-title { font-weight: 400; }
.note.unread .row-title { font-weight: 500; }

/* ---------- issue detail ---------- */
.issue-head { display: flex; align-items: center; gap: 16px; justify-content: space-between; flex-wrap: wrap; }
.facts { margin: 24px 0; display: grid; grid-template-columns: 130px 1fr; gap: 8px 16px; }
.facts dt { color: var(--muted); font-size: 13px; }
.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.status-select { font: inherit; padding: 6px 10px; border-radius: 7px; border: 1px solid var(--line); background: var(--surface); text-transform: capitalize; }
.context-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.reqs { width: 100%; border-collapse: collapse; margin-top: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.reqs th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 500; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.reqs td { padding: 7px 12px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.reqs tr:last-child td { border-bottom: none; }

/* ---------- deployment frame page ---------- */
body.framed { display: flex; flex-direction: column; overflow: hidden; }
body.framed .topbar { flex-shrink: 0; }
.framewrap { flex: 1; position: relative; display: flex; min-height: 0; }
#uat-frame { flex: 1; border: none; width: 100%; background: #fff; }
.frame-hint {
  position: absolute;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(20, 28, 25, 0.12);
  padding: 10px 16px;
  font-size: 13px;
  color: var(--muted);
  max-width: 90%;
}

/* the instrument bar — appears only inside a deployment */
.instrument {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bar);
  color: var(--bar-text);
  animation: rise 240ms ease-out;
}
@keyframes rise { from { transform: translateY(100%); } to { transform: translateY(0); } }
@media (prefers-reduced-motion: reduce) { .instrument { animation: none; } }
.inst-status { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 12.5px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #5c6670; flex-shrink: 0; }
.dot.live { background: #2fbf8f; box-shadow: 0 0 0 3px rgba(47, 191, 143, 0.25); }
.inst-path { color: #9aa4ad; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.inst-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.approved-note { font-size: 12.5px; color: #8fd9bd; }
.ibtn {
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.ibtn.ghost { background: transparent; border: none; color: #9aa4ad; }
.ibtn.ghost:hover { color: var(--bar-text); }
.ibtn.outline { background: transparent; border: 1px solid #3d564c; color: #8fd9bd; }
.ibtn.outline:hover { border-color: #2fbf8f; color: #b5ecd7; }
.ibtn.solid { background: var(--accent); border: 1px solid var(--accent); color: #fff; }
.ibtn.solid:hover { background: #12805e; }

/* issue panel above the instrument bar */
.issue-panel {
  position: fixed;
  right: 20px;
  bottom: 64px;
  width: min(440px, calc(100vw - 40px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(20, 28, 25, 0.18);
  padding: 20px;
  z-index: 10;
}
.issue-panel h2 { margin: 0 0 14px; }
.issue-panel label { display: block; font-size: 13px; font-weight: 500; margin: 12px 0 4px; }
.issue-panel .req { color: var(--muted); font-weight: 400; }
.issue-panel input, .issue-panel textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--paper);
  resize: vertical;
}
.capture-line { font-size: 11.5px; color: var(--muted); margin-top: 12px; }
.panel-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- platform status dashboard ---------- */
.status-windows { display: flex; gap: 6px; flex-shrink: 0; }
.asof { font-size: 12.5px; color: var(--muted); margin: 0 0 22px; }
.asof a { color: var(--accent-ink); }

/* status tones on pills (feeds/sections) + on big stat/paystat numbers */
.pill.st-ok { color: var(--done-fg); background: var(--done-bg); }
.pill.st-warn { color: var(--pending-fg); background: var(--pending-bg); }
.pill.st-bad { color: var(--danger-fg); background: var(--danger-bg); }
.pill.st-mut { color: var(--neutral-fg); background: var(--neutral-bg); }

/* summary tiles */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.stat-value { font-size: 25px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; overflow-wrap: anywhere; }
.stat-value.ok { color: var(--done-fg); }
.stat-value.warn { color: var(--pending-fg); }
.stat-value.bad { color: var(--danger-fg); }
.stat-value.mut { color: var(--ink); }
.stat-label { font-size: 13px; font-weight: 500; margin-top: 8px; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* sections */
.statsec { margin-top: 36px; }
.sec-head { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; }
.sec-head h2 { margin: 0; }
.sec-window { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.sec-note { font-size: 13px; color: var(--muted); margin: 0 0 12px; }

/* per-provider ingest block */
.provblock { margin-bottom: 20px; }
.provblock:last-child { margin-bottom: 0; }
.provblock-head { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; }
.provname { font-weight: 600; font-size: 14.5px; }
.muted-inline { color: var(--muted); }

/* tables: keep wide tables scrollable, right-align numeric cells */
.tablewrap { overflow-x: auto; }
.reqs td.num, .reqs th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* coverage cards */
.covgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.covcard { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; }
.covcard-head { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.covcounts { margin: 0; }
.covrow { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.covrow:first-child { border-top: none; }
.covrow dt { color: var(--muted); font-size: 13px; margin: 0; }
.covrow dd { margin: 0; font-weight: 600; font-variant-numeric: tabular-nums; }

/* success mini-bar */
.minibar { display: inline-block; vertical-align: middle; width: 64px; height: 6px; border-radius: 3px; background: var(--neutral-bg); overflow: hidden; }
.minibar > span { display: block; height: 100%; background: var(--accent); }
.minibar-label { font-size: 12px; color: var(--muted); margin-left: 8px; font-variant-numeric: tabular-nums; }

/* payment summary stats */
.paysum { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.paystat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; min-width: 170px; }
.paystat-label { display: block; font-size: 12px; color: var(--muted); }
.paystat-value { display: block; font-size: 18px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.paystat-value.ok { color: var(--done-fg); }
.paystat-value.bad { color: var(--danger-fg); }

/* ---------- users: access picker ---------- */
.invite { display: block; }
.invite-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.invite-row input[type=email] { flex: 1; min-width: 220px; }
.access-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.access-label { font-size: 13px; font-weight: 500; }
.preset-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.cap { font-size: 13px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.cap input { margin: 0; }
.userrow { flex-wrap: wrap; }
.caps-line { flex-basis: 100%; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.cap-pill { text-transform: none; }
.access-editor { flex-basis: 100%; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 10px 0 4px; }
.access-editor[hidden] { display: none; }
.access-editor .panel-actions { margin: 0 0 0 auto; }

/* ---------- customer inbox (Intercom) ---------- */
.chat-row.waiting .chat-who { font-weight: 600; }
.chat-who { flex: 0 0 170px; min-width: 0; text-decoration: none; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-snippet { font-weight: 400; color: var(--muted); }
.chat-row.waiting .chat-snippet { color: var(--ink); }

.chat-entries { display: flex; flex-direction: column; gap: 12px; margin: 8px 0 24px; }
.chat-msg { max-width: 82%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.chat-msg.agent, .chat-msg.bot { align-self: flex-end; background: var(--done-bg); border-color: transparent; }
.chat-msg.bot { background: var(--neutral-bg); }
.chat-msg.note { align-self: flex-end; background: var(--pending-bg); border-color: transparent; }
.chat-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; margin-bottom: 4px; font-size: 12.5px; color: var(--muted); }
.chat-author { font-weight: 600; color: var(--ink); }
.chat-at { margin-left: auto; white-space: nowrap; }
.chat-body { overflow-wrap: anywhere; }
.chat-body a, .chat-attachment { color: var(--accent-ink); }
.chat-attachment { display: block; margin-top: 6px; overflow-wrap: anywhere; }
.chat-event { align-self: center; font-size: 12.5px; color: var(--muted); }

.chat-reply { position: sticky; bottom: 0; padding: 14px 0 18px; background: var(--paper); border-top: 1px solid var(--line); }
.chat-reply textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  resize: vertical;
}
.chat-reply .panel-actions { align-items: center; justify-content: space-between; margin-top: 10px; }

/* ---------- responsive ---------- */
@media (max-width: 720px) {
  .topbar { gap: 14px; padding: 0 14px; }
  .brand-client, .whoami { display: none; }
  .content { padding: 24px 16px 60px; }
  .card { flex-direction: column; align-items: flex-start; }
  .row { flex-wrap: wrap; }
  .row-meta:nth-of-type(2) { display: none; }
  .facts { grid-template-columns: 1fr; gap: 2px 0; }
  .facts dt { margin-top: 10px; }
  .instrument { flex-wrap: wrap; }
  .inst-status { flex-basis: 100%; }
  .ibtn.ghost { display: none; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .status-windows { flex-wrap: wrap; }
  .chat-who { flex-basis: 100%; }
  .chat-msg { max-width: 100%; }
}

/* ---------- flash: a warning that stays until dismissed ---------- */
.flash { display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 0 0 16px; border-radius: 10px; font-size: 13.5px; }
.flash[hidden] { display: none; }
.flash.warn { color: var(--pending-fg); background: var(--pending-bg); }
.flash .flash-text { flex: 1; }
.cap input.locked-on { cursor: not-allowed; }
