:root {
  /* porcelain ground, deep navy ink, one brass accent */
  --bg: #eceff3; --surface: #fbfcfd; --text: #101828; --dim: #54606f; --line: #dbe0e7;
  --brand: #1c3557; --brand-ink: #fff; --accent: #a8823f; --ink-bar: #0f1b30;
  --red: #c0392f; --red-bg: #fdecea; --amber: #946000; --amber-bg: #fff3dc;
  --green: #1b7a4b; --green-bg: #e6f5ec; --radius: 14px; --topbar: 56px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 10px 28px -14px rgba(16,24,40,.22);
  color-scheme: light; --serif: "Instrument Serif", "Iowan Old Style", Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 "Segoe UI", system-ui, -apple-system, Arial, Tahoma, sans-serif; -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.35rem; margin: .3rem 0 .8rem; } h2 { font-size: 1rem; margin: 0 0 .6rem; } h3 { font-size: .9rem; margin: 1rem 0 .4rem; color: var(--dim); }
main { padding: 14px; max-width: 1500px; margin: 0 auto; }
.dim { color: var(--dim); } .small { font-size: .82rem; } .ok-t { color: var(--green); } .amber-t { color: var(--amber); }
kbd { background: var(--bg); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 7px; font: inherit; font-size: .85rem; }

/* top bar */
.top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20; min-height: var(--topbar); }
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 6px 12px; border-radius: 8px; color: var(--dim); }
.top nav a.on, .top nav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.top .right { margin-inline-start: auto; display: flex; gap: 10px; align-items: center; }
.top form { margin: 0; } .top .ico { display: none; }
.lang { padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--text); }
button.link { background: none; border: 0; color: var(--dim); cursor: pointer; font: inherit; }
.btn { display: inline-block; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface);
  color: var(--text); font: inherit; cursor: pointer; }
.btn:hover { border-color: var(--brand); text-decoration: none; }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.danger { color: var(--red); border-color: var(--red); } .btn[disabled] { opacity: .45; cursor: not-allowed; }
input, select, textarea { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }
.notice { padding: 10px 14px; border-radius: 10px; margin-bottom: 10px; }
.notice.warn { background: var(--amber-bg); color: var(--amber); } .notice.err { background: var(--red-bg); color: var(--red); }

/* home: glance + agent */
body.home main { padding: 12px; }
.layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; height: calc(100vh - var(--topbar) - 24px); }
.glance { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; overflow-y: auto; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat { text-align: start; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 10px; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; color: var(--text); font: inherit; }
.stat b { font-size: 1.5rem; line-height: 1; } .stat span { font-size: .76rem; color: var(--dim); }
.stat.red b { color: var(--red); } .stat.amber b { color: var(--amber); }
.stat:hover, .stagebar:hover { border-color: var(--brand); }
.stages { display: flex; flex-direction: column; gap: 6px; }
.stagebar { display: flex; justify-content: space-between; border: 1px solid var(--line); background: var(--bg); border-radius: 8px;
  padding: 7px 10px; cursor: pointer; color: var(--text); font: inherit; }
.agent { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 4px 2px 10px; }
.msg { max-width: min(760px, 92%); }
.msg.user { align-self: flex-end; } .msg.assistant, .msg.sys { align-self: flex-start; }
.bubble { padding: 9px 13px; border-radius: 14px; background: var(--bg); white-space: pre-wrap; word-break: break-word; }
.msg.user .bubble { background: var(--brand); color: var(--brand-ink); border-end-end-radius: 4px; }
.msg.assistant .bubble { border-end-start-radius: 4px; }
.msg.thinking .bubble { color: var(--dim); font-style: italic; }
.replay { background: none; border: 0; cursor: pointer; opacity: .55; padding: 0 4px; font-size: .9rem; } .replay:hover { opacity: 1; }
.caselist { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); }
.crow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 12px; color: var(--text);
  border-bottom: 1px solid var(--line); border-inline-start: 5px solid var(--dc, var(--line)); background: color-mix(in srgb, var(--dc, #9aa5b1) 7%, var(--surface)); }
.crow:last-child { border-bottom: 0; } .crow:hover { text-decoration: none; background: color-mix(in srgb, var(--dc, #9aa5b1) 15%, var(--surface)); }
.cname { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.csub { grid-column: 1; font-size: .8rem; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cright { grid-column: 2; grid-row: 1 / span 2; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: .82rem; }
.cmiss { grid-column: 1 / -1; font-size: .78rem; color: var(--amber); }
.stagepill, .stage { padding: 1px 9px; border-radius: 99px; background: var(--bg); font-size: .78rem; border: 1px solid var(--line); }
.s-ready { color: var(--green); } .late, .cdue.late { color: var(--red); font-weight: 600; } .cdue.soon { color: var(--amber); font-weight: 600; }
.more { padding: 6px 12px; font-size: .8rem; color: var(--dim); }
.pendingcard { margin-top: 8px; border: 1px solid var(--amber); background: var(--amber-bg); border-radius: 10px; padding: 10px 12px; }
.pendingcard .q { margin-bottom: 8px; color: var(--text); font-weight: 600; }
.pendingcard .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pendingcard.done { border-color: var(--green); background: var(--green-bg); } .pendingcard.cancelled { opacity: .6; border-color: var(--line); background: var(--bg); }
.quickbar { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 0; }
.chip { padding: 5px 12px; border-radius: 99px; border: 1px solid var(--line); background: var(--bg); color: var(--text); cursor: pointer; font: inherit; font-size: .85rem; }
.chip:hover { border-color: var(--brand); }
.composer { display: flex; gap: 8px; align-items: center; } .composer input { flex: 1; min-width: 0; padding: 11px 14px; border-radius: 99px; }
.mic { width: 46px; height: 46px; border-radius: 50%; border: 1px solid var(--line); background: var(--bg); font-size: 1.3rem; cursor: pointer; flex: 0 0 auto; }
.mic:hover { border-color: var(--brand); } .mic[disabled] { opacity: .4; cursor: not-allowed; }
.mic.on { background: var(--red); border-color: var(--red); color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--red) 55%, transparent); } 100% { box-shadow: 0 0 0 14px transparent; } }
.hint { font-size: .8rem; color: var(--dim); min-height: 1.2em; padding: 4px 6px 0; }
.voicebox { margin-top: 6px; font-size: .9rem; } .voicebox summary { cursor: pointer; color: var(--dim); }
.voicerow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 8px 0; } .voicerow select { max-width: 280px; }
.check { display: inline-flex; align-items: center; gap: 6px; }

/* cases / settings pages */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; } .filters input[type=search] { flex: 1; min-width: 200px; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { border-collapse: collapse; width: 100%; } table.list th, table.list td { padding: 9px 12px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list th { font-size: .75rem; text-transform: uppercase; color: var(--dim); } table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr td:first-child { border-inline-start: 5px solid var(--dc); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--dc); margin-inline-end: 6px; } .dot.big { width: 14px; height: 14px; }
.empty { color: var(--dim); text-align: center; padding: 24px; }
.info { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px; }
.info dl { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; } .info dt { color: var(--dim); } .info dd { margin: 0; }
.history { list-style: none; padding: 0; } .history li { padding: 7px 0; border-bottom: 1px solid var(--line); } .history time { color: var(--dim); font-size: .8rem; margin-inline-end: 6px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 6px 16px 14px; margin-bottom: 14px; max-width: 700px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; } .actions form { margin: 0; }
.login { max-width: 340px; margin: 12vh auto; background: var(--surface); padding: 24px; border: 1px solid var(--line); border-radius: var(--radius); }
.login form { display: flex; flex-direction: column; gap: 12px; } .login label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; color: var(--dim); }
.login .langs { text-align: center; color: var(--dim); }

/* phones: glance becomes a strip, the agent fills the screen */
@media (max-width: 900px) {
  html, body { overflow-x: hidden; }
  .top { gap: 6px; padding: 6px 10px; flex-wrap: nowrap; } .top .lbl { display: none; } .top .ico { display: inline; font-size: 1.1rem; }
  .brand { font-size: 1.3rem; } .top nav { flex: 1; min-width: 0; overflow-x: auto; gap: 0; } .top nav a { padding: 6px 8px; font-size: .86rem; white-space: nowrap; }
  body.home main { padding: 8px; }
  .layout { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); height: calc(100dvh - 46px - 16px); gap: 8px; }
  .glance { padding: 8px; overflow-x: auto; overflow-y: hidden; }
  .glance h2, .glance h3, .stages { display: none; }
  .stats { display: flex; gap: 6px; } .stat { flex: 0 0 auto; min-width: 92px; padding: 6px 10px; }
  .stat b { font-size: 1.25rem; } .stat span { white-space: nowrap; }
  .agent { padding: 8px; } .msg { max-width: 100%; }
  .quickbar { flex-wrap: nowrap; overflow-x: auto; } .chip { flex: 0 0 auto; white-space: nowrap; }
  .composer input { padding: 10px 12px; } .mic { width: 50px; height: 50px; }
  .info dl { grid-template-columns: 1fr; } .info dt { margin-top: 6px; }
}

/* never let a child force the page wider than the screen */
.layout > *, .agent > *, .chat, .msg, .caselist { min-width: 0; }
.cmiss { white-space: normal; }
.notice { overflow-wrap: anywhere; }
@media (max-width: 900px) {
  .notice { padding: 8px 10px; font-size: .85rem; margin-bottom: 6px; }
  .composer { gap: 6px; } .composer .btn { padding: 10px 12px; }
}

/* ---- mixed Arabic / English text ---- */
bdi { unicode-bidi: isolate; }
kbd { direction: ltr; unicode-bidi: isolate; }
.bubble { unicode-bidi: plaintext; text-align: start; }
.csub { display: flex; gap: 0; overflow: hidden; white-space: nowrap; }
.csub .tok { unicode-bidi: isolate; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }
.cname { unicode-bidi: plaintext; text-align: start; }
.pendingcard .q { unicode-bidi: plaintext; text-align: start; }
input#msg { unicode-bidi: plaintext; text-align: start; }
.meta-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0; }
.val { unicode-bidi: isolate; }
.val.ltr { direction: ltr; display: inline-block; }
.history li .chg { direction: ltr; unicode-bidi: isolate; display: inline-block; }

.sep { color: var(--dim); margin-inline: .45em; flex: 0 0 auto; }

/* two talk buttons: EN / Arabic */
.mic { position: relative; }
.mic small { position: absolute; bottom: -3px; inset-inline-end: -3px; font-size: .62rem; line-height: 1; font-weight: 700; padding: 2px 4px;
  border-radius: 8px; background: var(--brand); color: var(--brand-ink); }
.mic.on small { background: #fff; color: var(--red); }
@media (max-width: 900px) { .mic { width: 44px; height: 44px; font-size: 1.15rem; } .composer { gap: 5px; } }

.wacard { margin-top: 8px; border: 1px solid #25d366; background: color-mix(in srgb, #25d366 9%, var(--surface)); border-radius: 10px; padding: 10px 12px; }
.wacard .q { font-weight: 600; margin-bottom: 6px; unicode-bidi: plaintext; text-align: start; }
.wacard .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0; }
.wacard .row input { flex: 1; min-width: 140px; }
.wamsg { white-space: pre-wrap; background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 6px 0; unicode-bidi: plaintext; text-align: start; }
.docrow { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.docrow .docname { flex: 1 1 140px; } .docrow input[type=tel] { width: 170px; }

/* ---------- views: canvas panel, cards, table, charts ---------- */
.chip.view { border-style: dashed; }
.canvas { display: none; }
@media (min-width: 1180px) {
  .layout.with-canvas { grid-template-columns: 250px minmax(300px, .8fr) minmax(0, 1.5fr); }
  .layout.with-canvas .canvas { display: flex; }
}
.canvas { position: relative; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; overflow: hidden; }
.canvas[hidden] { display: none !important; }
.canvas-close { position: absolute; top: 8px; inset-inline-end: 8px; z-index: 2; background: var(--bg); border: 1px solid var(--line); border-radius: 50%; width: 28px; height: 28px; cursor: pointer; color: var(--dim); }
.canvas-body { flex: 1; overflow: auto; min-height: 0; }
.vwrap { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.viewbox { margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: var(--surface); }
.vbar { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; padding-inline-end: 34px; }
.vtitle { font-weight: 700; font-size: 1rem; flex: 1 1 200px; unicode-bidi: plaintext; text-align: start; }
.vseg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.vseg button { background: var(--bg); border: 0; padding: 4px 10px; cursor: pointer; font: inherit; font-size: .82rem; color: var(--text); }
.vseg button.on { background: var(--brand); color: var(--brand-ink); }
.vbar select { padding: 3px 8px; font-size: .82rem; border-radius: 8px; width: auto; }
.vnote { font-size: .78rem; color: var(--dim); }
.vscroll { overflow-x: auto; }
table.vtable { border-collapse: collapse; width: 100%; font-size: .86rem; }
table.vtable th, table.vtable td { padding: 6px 9px; border-bottom: 1px solid var(--line); text-align: start; white-space: nowrap; }
table.vtable th { position: sticky; top: 0; background: var(--surface); font-size: .72rem; text-transform: uppercase; color: var(--dim); z-index: 1; }
table.vtable td:first-child { border-inline-start: 5px solid var(--dc, var(--line)); }
table.vtable tr.grp td { background: var(--bg); font-weight: 700; border-inline-start: 0; }
table.vtable tr.tot td { font-weight: 700; border-top: 2px solid var(--line); }
table.vtable td.late { color: var(--red); font-weight: 600; }
table.vtable td .ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.vcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.vcard { display: block; color: var(--text); border: 1px solid var(--line); border-inline-start: 5px solid var(--dc, var(--line)); border-radius: 10px; padding: 8px 10px;
  background: color-mix(in srgb, var(--dc, #9aa5b1) 7%, var(--surface)); min-width: 0; }
.vcard:hover { text-decoration: none; background: color-mix(in srgb, var(--dc, #9aa5b1) 15%, var(--surface)); }
.vcard .t { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; unicode-bidi: plaintext; }
.vcard .s { font-size: .78rem; color: var(--dim); display: flex; flex-wrap: wrap; }
.vcard .r { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 4px; font-size: .8rem; }
.vcard .m { margin-top: 3px; font-size: .75rem; color: var(--amber); }
.vgroup { font-weight: 700; margin: 8px 0 4px; display: flex; gap: 8px; align-items: baseline; }
.vgroup .n { background: var(--bg); border-radius: 99px; padding: 0 8px; font-size: .78rem; font-weight: 600; }
.vchart { direction: ltr; }
.vchart svg { width: 100%; height: auto; display: block; }
.vchart text { fill: var(--text); font-size: 12px; font-family: inherit; }
.vchart .dim { fill: var(--dim); }
.vlegend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: .78rem; direction: ltr; }
.vlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-inline-end: 5px; vertical-align: -1px; }
@media (max-width: 900px) { .vcards { grid-template-columns: 1fr 1fr; } .vtitle { flex-basis: 100%; } }
@media (max-width: 480px) { .vcards { grid-template-columns: 1fr; } }

.newcase { display: flex; flex-direction: column; gap: 12px; max-width: 520px; } .newcase label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--dim); }
.newcase .err { color: var(--red); font-size: .82rem; } h1 .btn { font-size: .85rem; vertical-align: middle; text-decoration: none; }
.newcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; margin-top: 8px; background: var(--surface); }

/* ================= premium finish ================= */
body { font-family: "Hanken Grotesk", "Segoe UI", system-ui, -apple-system, Arial, Tahoma, sans-serif; letter-spacing: .005em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
h1 { font-family: var(--serif); font-weight: 400; font-size: 2rem; letter-spacing: 0; margin: .4rem 0 1rem; line-height: 1.15; }
h2 { font-size: .74rem; text-transform: uppercase; letter-spacing: .12em; color: var(--dim); font-weight: 700; }
h3 { font-size: .74rem; text-transform: uppercase; letter-spacing: .1em; }
html[dir=rtl] h1, html[dir=rtl] h2, html[dir=rtl] h3 { letter-spacing: 0; text-transform: none; }

/* top bar: a dark band that frames the whole app */
.top { background: var(--ink-bar); border-bottom: 1px solid rgba(255,255,255,.06); color: #e9edf3; padding: 8px 22px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; font-family: var(--serif); font-size: 1.45rem; font-weight: 400; letter-spacing: .01em; }
.brand svg { width: 24px; height: 24px; flex: 0 0 auto; } .brand:hover { text-decoration: none; }
.top nav { gap: 2px; margin-inline-start: 14px; }
.top nav a { color: #aab6c6; padding: 8px 14px; border-radius: 0; border-bottom: 2px solid transparent; font-weight: 500; }
.top nav a:hover { background: none; color: #fff; text-decoration: none; }
.top nav a.on { background: none; color: #fff; border-bottom-color: var(--accent); }
.lang { border-color: rgba(255,255,255,.22); color: #e9edf3; border-radius: 99px; padding: 3px 12px; font-size: .85rem; }
.lang:hover { border-color: var(--accent); text-decoration: none; }
.top button.link { color: #aab6c6; } .top button.link:hover { color: #fff; }

/* surfaces */
.glance, .agent, .canvas, .info, .panel, .tablewrap, .login { box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--line) 80%, transparent); }
.btn { border-radius: 10px; padding: 9px 16px; font-weight: 600; transition: transform .12s, box-shadow .12s, border-color .12s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgba(16,24,40,.35); }
.btn.primary { background: var(--brand); border-color: var(--brand); }
input, select, textarea { border-radius: 10px; padding: 9px 12px; transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }

/* the glance column */
.glance { padding: 18px; }
.stats { gap: 10px; }
.stat { background: var(--bg); border-color: transparent; border-radius: 12px; padding: 12px 14px; gap: 6px; transition: border-color .12s; }
.stat b { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.stat span { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
html[dir=rtl] .stat span { letter-spacing: 0; text-transform: none; font-size: .8rem; }
.stat:hover, .stagebar:hover { border-color: var(--accent); }
.stagebar { border-color: transparent; border-radius: 10px; padding: 9px 12px; font-variant-numeric: tabular-nums; }

/* the conversation */
.agent { padding: 16px 18px; }
.bubble { border-radius: 16px; padding: 11px 15px; line-height: 1.5; }
.msg.assistant .bubble { background: var(--surface); border: 1px solid var(--line); }
.msg.user .bubble { background: var(--brand); color: var(--brand-ink); }
.chip { background: var(--surface); border-radius: 99px; padding: 6px 14px; font-weight: 500; }
.chip:hover { border-color: var(--accent); }
.composer { padding-top: 10px; border-top: 1px solid var(--line); }
.composer input { background: var(--bg); border-color: transparent; padding: 13px 18px; }
.composer input:focus { background: var(--surface); }
.mic { background: var(--bg); border-color: transparent; }
.mic:hover { border-color: var(--accent); }

/* case rows, tables */
.caselist, .viewbox, .newcard { border-radius: 12px; }
.crow { padding: 10px 14px; }
.stagepill, .stage { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); border-color: transparent; font-weight: 600; font-size: .74rem; letter-spacing: .02em; padding: 2px 10px; }
.s-ready { background: var(--green-bg); }
table.list th, table.vtable th { font-size: .68rem; letter-spacing: .1em; font-weight: 700; background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
html[dir=rtl] table.list th, html[dir=rtl] table.vtable th { letter-spacing: 0; text-transform: none; font-size: .78rem; }
table.list tbody tr:hover td, table.vtable tbody tr:hover td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
table.list td, table.list th { padding: 11px 14px; }
.vtitle { font-family: var(--serif); font-weight: 400; font-size: 1.35rem; }
.vseg { border-radius: 10px; } .vseg button.on { background: var(--brand); }
.vgroup { font-size: .95rem; }
.info { padding: 10px 22px; } .info dl { gap: 10px 20px; }
.info dt { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 600; align-self: center; }
html[dir=rtl] .info dt { letter-spacing: 0; text-transform: none; font-size: .85rem; }
.login { padding: 34px 30px; border-radius: 18px; }
main { padding: 20px 22px; } body.home main { padding: 16px 22px; }
.layout { height: calc(100vh - var(--topbar) - 32px); gap: 18px; }
@media (max-width: 900px) {
  .top { padding: 6px 12px; } .top nav { margin-inline-start: 0; } .top nav a { padding: 8px 8px; }
  main, body.home main { padding: 10px; } h1 { font-size: 1.6rem; }
  .layout { height: calc(100dvh - 50px - 20px); gap: 10px; } .glance, .agent { padding: 10px; }
  .stat b { font-size: 1.5rem; }
}
@media (prefers-reduced-motion: reduce) { .btn, .stat, input, select { transition: none; } .btn:hover { transform: none; } }
.stat b, h1, .vtitle { font-variant-numeric: lining-nums tabular-nums; }

.msg.old { opacity: .72; } .pwbox { font: 600 1.3rem/1.4 ui-monospace, Consolas, monospace; background: var(--bg); padding: 12px 16px; border-radius: 10px; user-select: all; display: inline-block; }
fieldset.perms { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; }
fieldset.perms legend { padding: 0 8px; color: var(--dim); font-size: .8rem; }
.newcase select { width: 100%; }
.newcase label.check, fieldset.perms label.check { flex-direction: row; align-items: center; gap: 10px; color: var(--text); font-size: .95rem; }
h1 .btn.small { font-size: .8rem; padding: 6px 12px; }

.contactrow { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.contactrow:last-child { border-bottom: 0; } .contactrow input { min-width: 0; width: 100%; }
.docrow input[type=email] { width: 230px; max-width: 100%; }

/* reports */
.repbar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin-bottom: 14px; }
.repsum { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-bottom: 18px; }
.repsum .tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.repsum .tile b { font-family: var(--serif); font-weight: 400; font-size: 2.2rem; line-height: 1; font-variant-numeric: lining-nums tabular-nums; }
.repsum .tile.red b { color: var(--red); } .repsum .tile.amber b { color: var(--amber); }
.repsum .tile span { display: block; font-size: .78rem; color: var(--dim); margin-top: 6px; }
table.rep td .pill { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: .74rem; font-weight: 600; margin: 1px 4px 1px 0; background: var(--amber-bg); color: var(--amber); }
table.rep td .pill.red { background: var(--red-bg); color: var(--red); } table.rep td .pill.stage { background: color-mix(in srgb, var(--brand) 9%, var(--surface)); color: var(--text); }
table.rep td { white-space: normal; } table.rep tbody tr td:first-child { border-inline-start: 5px solid var(--dc); }
@media print {
  .top, .repbar .btn, #toasts, .repbar form { display: none !important; } body { background: #fff; } main { padding: 0; }
  .tablewrap, .tile { box-shadow: none !important; }
}
table.rep td .pill.ok { background: var(--green-bg); color: var(--green); }

/* intake */
.dropzone { background: var(--surface); border: 2px dashed var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 12px; margin-bottom: 20px; }
.dropzone.drag { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 8%, var(--surface)); }
.dropzone .row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.dropzone select, .dropzone input[type=text] { min-width: 180px; }
.intakecard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); margin-bottom: 12px; }
.intakecard.dup { border-color: var(--amber); }
.intakecard .fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin: 10px 0; }
.intakecard label { display: flex; flex-direction: column; gap: 3px; font-size: .74rem; color: var(--dim); text-transform: uppercase; letter-spacing: .06em; }
html[dir=rtl] .intakecard label { text-transform: none; letter-spacing: 0; font-size: .8rem; }
.intakecard input { min-width: 0; padding: 7px 10px; text-transform: none; letter-spacing: 0; }
.intakecard .meta { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; font-size: .82rem; color: var(--dim); }
.intakecard .evidence { font-size: .82rem; color: var(--dim); font-style: italic; unicode-bidi: plaintext; margin-bottom: 6px; }
.intakecard .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.conf { padding: 1px 9px; border-radius: 99px; font-size: .72rem; font-weight: 700; background: var(--green-bg); color: var(--green); }
.conf.medium { background: var(--amber-bg); color: var(--amber); } .conf.low { background: var(--red-bg); color: var(--red); }
#intake-status { min-height: 1.4em; font-weight: 600; }

/* browser tasks */
.jobcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 16px; box-shadow: var(--shadow); margin-bottom: 10px; }
.jobcard .top2 { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.jobcard pre { margin: 8px 0 0; padding: 8px 10px; background: var(--bg); border-radius: 8px; font: .78rem/1.4 ui-monospace, Consolas, monospace; white-space: pre-wrap; max-height: 9em; overflow: auto; direction: ltr; text-align: left; }
.dotstate { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--red); margin-inline-end: 6px; } .dotstate.on { background: var(--green); }
.tokenbox { font: 600 1.05rem/1.5 ui-monospace, Consolas, monospace; background: var(--bg); padding: 12px 14px; border-radius: 10px; user-select: all; word-break: break-all; direction: ltr; text-align: left; }
.st-running { color: var(--brand); font-weight: 700; } .st-failed { color: var(--red); font-weight: 700; } .st-done { color: var(--green); font-weight: 700; }

#stopspeak { padding: 8px 12px; } #stopspeak[hidden] { display: none; }

/* hands-free */
.mic.hf.on { background: var(--red); border-color: var(--red); color: #fff; }
.hfstatus { font-size: .85rem; font-weight: 600; padding: 4px 6px 0; color: var(--brand); } .hfstatus[hidden] { display: none; }
.hfstatus.live::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--red); margin-inline-end: 8px; animation: pulse 1.4s infinite; }
.hfrow { display: flex; align-items: center; gap: 10px; } .hfrow .hfstatus { flex: 1 1 auto; } #hflang { min-width: 42px; font-weight: 700; } #hflang[hidden] { display: none; }

.lbar { display: grid; grid-template-columns: 9em 1fr 3.4em auto; gap: 10px; align-items: center; padding: 5px 0; } .lbar .bar { height: 10px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.lbar .bar i { display: block; height: 100%; background: var(--brand); border-radius: 99px; } .lbar b { font-variant-numeric: tabular-nums; text-align: end; }

/* installed app (PWA): keep clear of the notch and the home bar */
.top { padding-top: max(8px, env(safe-area-inset-top)); padding-inline-start: max(22px, env(safe-area-inset-left)); padding-inline-end: max(22px, env(safe-area-inset-right)); }
body { padding-bottom: env(safe-area-inset-bottom); }
@media (max-width: 900px) { .top { padding-inline-start: max(12px, env(safe-area-inset-left)); padding-inline-end: max(12px, env(safe-area-inset-right)); } }
.standalone .layout { height: calc(100dvh - var(--topbar) - 32px - env(safe-area-inset-bottom)); }
.ioshint { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--ink-bar); color: #fff; padding: 10px 16px; font-size: .9rem; } .ioshint[hidden] { display: none; }
.ioshint button { background: none; border: 0; color: #cdd5df; font-size: 1.3rem; cursor: pointer; }
#install-app[hidden] { display: none; }
