/* Rules page additions + desk extras (P3, 24 Sep 2026). Colour tokens only (app.css :root); no new colours. */

/* auto-send: its own amber box, because it is the one switch that lets the desk speak without a tap */
.rx-box { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 10px; background: var(--card); }
.rx-box.amber { border-color: var(--amber); background: var(--amber-soft); }
.rx-box .rules-row:last-child { border-bottom: 0; }

/* confirm sheet (auto-send on, restore) */
/* veil: the same ink as --shadow; app.css (frozen tonight) has no overlay token to reuse */
.rx-veil { position: fixed; inset: 0; background: rgba(23, 23, 26, .35); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.rx-sheet { width: min(520px, 100%); background: var(--card); color: var(--ink); border-radius: 16px 16px 0 0; box-shadow: var(--sheet); padding: 18px 18px calc(18px + env(safe-area-inset-bottom)); }
.rx-sheet h3 { margin: 0 0 6px; font-size: 16px; }
.rx-sheet p { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.rx-sheet .rules-actions { justify-content: flex-end; }
@media (min-width: 700px) { .rx-veil { align-items: center; } .rx-sheet { border-radius: 16px; padding-bottom: 18px; } }

/* earlier versions: one line each */
.rx-hist { list-style: none; margin: 6px 0 0; padding: 0; }
.rx-hist li { display: flex; align-items: center; gap: 10px; min-height: 36px; border-bottom: 1px solid var(--line); font-size: 14px; }
.rx-hist .rx-when { color: var(--muted); font-size: 12px; min-width: 120px; font-variant-numeric: tabular-nums; }
.rx-hist .rx-what { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rx-hist .rx-by { color: var(--muted); font-size: 12px; }
.rx-hist .btn { visibility: hidden; }
.rx-hist li:hover .btn, .rx-hist li:focus-within .btn { visibility: visible; }
@media (hover: none) { .rx-hist .btn { visibility: visible; } }

/* canned replies editor: one line per reply */
.rx-canned { display: grid; grid-template-columns: 180px 1fr auto; gap: 8px; align-items: center; min-height: 40px; border-bottom: 1px solid var(--line); }
.rx-canned input, .rx-canned textarea, .rx-in { border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--card); color: var(--ink); font: inherit; }
.rx-canned textarea { resize: vertical; min-height: 34px; }
.rx-canned input:focus, .rx-canned textarea:focus, .rx-in:focus { border-color: var(--acc); outline: none; }

/* customers & routing table */
.rx-dir { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 14px; }
.rx-dir th { text-align: left; font-size: 12px; font-weight: 500; color: var(--muted); padding: 6px 8px 6px 0; border-bottom: 1px solid var(--line); }
.rx-dir td { padding: 4px 8px 4px 0; border-bottom: 1px solid var(--line); height: 40px; white-space: nowrap; }
.rx-dir td.grow { white-space: normal; }
.rx-dir select, .rx-dir input { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: var(--card); color: var(--ink); font: inherit; max-width: 100%; }
.rx-dir .pill { margin-left: 6px; }
.rx-dir .rules-actions { flex-wrap: nowrap; margin-top: 0; gap: 6px; }
.rx-dir .btn { visibility: hidden; }
.rx-dir tr:hover .btn, .rx-dir tr:focus-within .btn { visibility: visible; }
@media (hover: none) { .rx-dir .btn { visibility: visible; } }
.rx-import { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
.rx-import textarea { width: 100%; }
.rx-errs { margin: 4px 0 0; padding: 0; list-style: none; font-size: 13px; }
.rx-errs li { color: var(--red); min-height: 24px; }
.rx-errs li code { color: var(--ink); background: var(--fill); border-radius: 6px; padding: 0 4px; }

/* desk extras: window timer, health line, quick replies (mounted by wa.js) */
.dx-window { font-size: 12px; white-space: nowrap; }
.dx-health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.dx-health.amber { color: var(--amber); }
.dx-health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dx-health .dot.green { background: var(--green); }
.dx-health .dot.amber { background: var(--amber); }
.dx-health .dot.red { background: var(--red); }
.dx-canned { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0; }
.dx-canned .chip { cursor: pointer; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 700px) {
  .rx-canned { grid-template-columns: 1fr; }
  .rx-dir thead { display: none; }
  .rx-dir, .rx-dir tbody, .rx-dir tr, .rx-dir td { display: block; width: 100%; }
  .rx-dir tr { border-bottom: 1px solid var(--line); padding: 6px 0; }
  .rx-dir td { border: 0; height: auto; padding: 2px 0; white-space: normal; }
}

/* ---- Rules & pricing layout (restored 24 Sep after the redesign; new look: filled fields, hairlines) ---- */
.page.rules { max-width: 980px; }
.rules-sec { margin-top: 26px; }
.rules-sec textarea { width: 100%; min-height: 110px; border: 0; border-radius: 12px; padding: 12px 14px; resize: vertical; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-size: 15px; line-height: 1.5; }
.rules-sec textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--acc); }
.rules-actions { display: flex; align-items: center; gap: 12px; margin-top: 10px; flex-wrap: wrap; }
.rules-err { display: inline-block; margin-top: 8px; }
.rules-row { display: grid; grid-template-columns: minmax(220px, 1fr) 150px minmax(220px, 1.3fr); align-items: center; gap: 14px; min-height: 44px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rules-row label { font-weight: 500; }
.rules-in { display: flex; align-items: center; gap: 6px; }
.rules-in input[type="number"] { width: 96px; } .rules-in input:not([type]) { width: 130px; } .rules-in input[type="number"], .rules-in input:not([type]) { height: 34px; border: 0; border-radius: 8px; padding: 0 10px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); font-variant-numeric: tabular-nums; }
.rules-in input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--acc); }
.rules-in input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--acc); }
.rules-in textarea { width: 100%; }
.rules-hint { line-height: 1.35; }
.rules-parsed { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--card); box-shadow: inset 0 0 0 1px var(--line); }
.rules-table { max-width: 420px; margin-bottom: 8px; }
.rules-line { padding: 2px 0; }
.rules-unclear { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.admin-body .page { overflow-y: auto; }
@media (max-width: 760px) {
  .rules-row { grid-template-columns: 1fr; gap: 4px; padding: 8px 0; }
}
