:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #12203a;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #0d2185;
  --brand-soft: #eef1fd;
  --ok: #067647;
  --ok-soft: #e7f6ee;
  --warn: #92500e;
  --warn-soft: #fdf3e3;
  --err: #b42318;
  --err-soft: #fdeceb;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.strong { font-weight: 600; }
.grow { flex: 1; min-width: 0; }

/* ----------------------------------------------------------- top bar */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px; height: 58px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; color: var(--ink); text-decoration: none; font-size: 15px;
}
.mark {
  display: grid; place-items: center; width: 28px; height: 28px;
  background: var(--brand); color: #fff; border-radius: 7px;
  font-size: 12px; font-weight: 700; letter-spacing: .02em;
}
.topnav { margin-left: auto; font-size: 13px; color: var(--brand);
          text-decoration: none; font-weight: 550; }
.topnav:hover { text-decoration: underline; }
/* the sign-out block sits at the far right; the nav link no longer
   needs to push itself there */
.topbar form.signout { margin-left: 0; }

main { max-width: 1240px; margin: 0 auto; padding: 22px 24px 60px; }

/* ------------------------------------------------------------- cards */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px;
}
.card h1 { font-size: 19px; margin: 0 0 4px; }
.card h2 { font-size: 14px; margin: 0 0 12px; letter-spacing: .01em; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.head p { margin: 0; font-size: 13px; }
.count {
  background: var(--brand-soft); color: var(--brand); border-radius: 20px;
  padding: 1px 8px; font-size: 12px; font-weight: 600; margin-left: 6px;
}
.crumb { margin-bottom: 12px; font-size: 13px; }
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--brand); }
.empty { color: var(--muted); padding: 10px 0; margin: 0; }

.split { display: grid; grid-template-columns: 1.05fr .95fr; gap: 16px; align-items: start; }
.col { min-width: 0; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------ upload */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 30px; margin-bottom: 12px; cursor: pointer;
  border: 1.5px dashed #c3cede; border-radius: var(--radius);
  background: #fafbfe; color: var(--muted); transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.dz-icon {
  display: grid; place-items: center; width: 30px; height: 30px;
  border-radius: 50%; background: var(--brand); color: #fff; font-size: 15px;
}
.dz-text { font-size: 13px; }

/* ------------------------------------------------------------ inputs */
input[type=text], input[type=tel], input[type=password],
input:not([type]), textarea, select {
  width: 100%; padding: 8px 10px; font: inherit; color: var(--ink);
  background: #fff; border: 1px solid #cbd5e1; border-radius: 7px;
}
textarea { resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.row.files { gap: 18px; font-size: 12.5px; color: var(--muted); }
.row.files input { width: auto; border: none; padding: 0; }
label.grow { font-size: 12.5px; color: var(--muted); }

/* ----------------------------------------------------------- buttons */
.btn {
  display: inline-block; padding: 8px 14px; font: inherit; font-weight: 550;
  color: var(--ink); background: #fff; border: 1px solid #cbd5e1;
  border-radius: 7px; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { border-color: #94a3b8; background: #f8fafc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0a1a6b; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--err); border-color: #f2c4c0; background: #fff; }
.btn.danger:hover { background: var(--err-soft); }
.btn.tiny { padding: 4px 9px; font-size: 12px; font-weight: 500; }
.btn.big { width: 100%; padding: 11px; font-size: 14.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.tabs { display: flex; gap: 6px; }

/* ------------------------------------------------------------ tables */
/* The claims table has a fixed minimum width, so it scrolls inside its card
   rather than pushing the page sideways on a narrow window. */
.table-wrap { overflow-x: auto; margin: 0 -4px; padding: 0 4px; }
table.claims { width: 100%; min-width: 660px; border-collapse: collapse; font-size: 13.5px; }
.claims th {
  text-align: left; padding: 8px 10px; color: var(--muted);
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em;
  border-bottom: 1px solid var(--line); font-weight: 600;
}
.claims td { padding: 10px; border-bottom: 1px solid #f1f5f9; white-space: nowrap; }
.claims td:first-child { white-space: normal; }
.claims tr:last-child td { border-bottom: none; }
.claims tr:hover td { background: #fafbfe; }
.claims a.strong { color: var(--ink); text-decoration: none; }
.claims a.strong:hover { color: var(--brand); text-decoration: underline; }

dl.kv { display: grid; grid-template-columns: 150px 1fr; gap: 2px 14px; margin: 0; font-size: 13px; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; }

/* ------------------------------------------------------------- pills */
.pill {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; white-space: nowrap;
  background: #eef2f7; color: var(--muted);
}
.pill-replied, .pill-ready { background: var(--ok-soft); color: var(--ok); }
.pill-awaiting, .pill-partly { background: var(--warn-soft); color: var(--warn); }
.pill-no { background: var(--err-soft); color: var(--err); }
.tag {
  font-size: 11.5px; color: var(--warn); background: var(--warn-soft);
  padding: 2px 9px; border-radius: 20px; font-weight: 600;
}

/* ------------------------------------------------------------ flashes */
.flashes { margin-bottom: 14px; }
.flash {
  padding: 10px 14px; border-radius: 8px; margin-bottom: 8px;
  font-size: 13px; border: 1px solid transparent;
}
.flash-ok { background: var(--ok-soft); color: var(--ok); border-color: #b7e3cc; }
.flash-warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d9b0; }
.flash-error { background: var(--err-soft); color: var(--err); border-color: #f2c4c0; }

/* ----------------------------------------------------------- preview */
.preview {
  width: 100%; height: 620px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff;
}

/* --------------------------------------------------------- query/answer */
.qa { padding: 12px 0; border-bottom: 1px solid #f1f5f9; }
.qa:last-of-type { border-bottom: none; }
.qa .q { display: flex; gap: 9px; font-size: 13.5px; margin-bottom: 8px; line-height: 1.45; }
.num {
  flex: none; display: grid; place-items: center; width: 20px; height: 20px;
  border-radius: 50%; background: #eef2f7; color: var(--muted);
  font-size: 11.5px; font-weight: 700;
}
.qa.done .num { background: var(--ok-soft); color: var(--ok); }

/* --------------------------------------------------------- whatsapp */
.whatsapp .msg { margin-top: 10px; }
.whatsapp summary { cursor: pointer; font-size: 12.5px; color: var(--brand); }
.whatsapp pre {
  margin: 8px 0 0; padding: 12px; background: #f8fafc; border: 1px solid var(--line);
  border-radius: 8px; font-size: 12px; line-height: 1.55; white-space: pre-wrap;
  max-height: 260px; overflow: auto;
}
ul.log { list-style: none; margin: 10px 0 0; padding: 0; font-size: 12.5px; }
ul.log li { padding: 4px 0; border-bottom: 1px solid #f1f5f9; color: var(--muted); }
ul.log li:last-child { border-bottom: none; }

.actions form { margin: 0 0 8px; }
.actions form:last-child { margin: 12px 0 0; }

/* ----------------------------------------------------- whatsapp thread */
.thread { margin-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.bubble {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
  background: #fafbfe; font-size: 12.5px;
}
.bubble.in { background: var(--ok-soft); border-color: #c9e7d8; }
.bubble-head {
  display: flex; justify-content: space-between; gap: 10px;
  color: var(--muted); font-size: 11.5px; margin-bottom: 5px;
}
.bubble-body { white-space: pre-wrap; line-height: 1.5; color: var(--ink); }
.bubble-foot { margin-top: 6px; display: flex; gap: 8px; align-items: center; }
.simulate { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--line); }
.simulate textarea { margin: 5px 0 8px; }

/* ------------------------------------------------------- whatsapp link */
.qr {
  display: block; width: 260px; height: 260px; margin: 14px 0;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 8px;
}
pre.cmd {
  background: #0f172a; color: #e2e8f0; padding: 10px 12px; border-radius: 8px;
  font-size: 12.5px; overflow-x: auto;
}
ul.plain { list-style: none; margin: 0; padding: 0; font-size: 13.5px; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid #f1f5f9; }
ul.plain li:last-child { border-bottom: none; }
ul.plain a { color: var(--ink); text-decoration: none; font-weight: 550; }
ul.plain a:hover { color: var(--brand); }

/* messages that carried no answer: kept, but out of the way */
details.chatter { margin-top: 10px; }
details.chatter summary {
  cursor: pointer; font-size: 12.5px; color: var(--muted);
}
details.chatter summary:hover { color: var(--brand); }
.chatter-line {
  display: flex; gap: 10px; padding: 5px 0 5px 4px;
  font-size: 12.5px; color: var(--muted); border-bottom: 1px solid #f1f5f9;
}
.chatter-line:last-child { border-bottom: none; }

/* ------------------------------------------------------------- sign in */
.signin { max-width: 380px; margin: 48px auto; }
.signin h1 { margin-bottom: 6px; }
.field { display: block; margin: 14px 0; }
.field span {
  display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 5px;
}
.signout { display: flex; align-items: center; gap: 10px; margin: 0; }
.who { font-size: 12.5px; color: var(--muted); }
.topnav + .signout { margin-left: 14px; }
