/* Dashboard and graph views. Colours come from the variables in style.css so light and dark themes both work. */
.tabs { display: flex; gap: 4px; padding: 3px; background: var(--code); border-radius: 10px; }
.tab { background: transparent; color: var(--muted); border: 0; padding: 6px 14px; font-weight: 600; border-radius: 8px; }
.tab[aria-current="page"] { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.tab:not([aria-current="page"]):hover { color: var(--ink); }

/* one view at a time: the body attribute decides */
.view { display: none; flex: 1; overflow-y: auto; padding: 16px; width: 100%; max-width: 1280px; margin: 0 auto; }
body[data-view="dash"] #dash, body[data-view="graph"] #graphview, body[data-view="cases"] #casesview, body[data-view="rules"] #rulesview { display: block; }
body[data-view="dash"] #log, body[data-view="graph"] #log, body[data-view="cases"] #log, body[data-view="rules"] #log,
body[data-view="dash"] #form, body[data-view="graph"] #form, body[data-view="cases"] #form, body[data-view="rules"] #form,
body[data-view="dash"] .foot, body[data-view="graph"] .foot, body[data-view="cases"] .foot, body[data-view="rules"] .foot,
body[data-view="dash"] #new, body[data-view="graph"] #new, body[data-view="cases"] #new, body[data-view="rules"] #new { display: none; }
body[data-view="graph"] #graphview { display: flex; flex-direction: column; overflow: hidden; }

.status { min-height: 20px; margin: 0 0 10px; color: var(--muted); font-size: 13.5px; }
.status.err { color: var(--err-ink); background: var(--err-bg); padding: 8px 12px; border-radius: 8px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .v { font-size: 22px; font-weight: 700; line-height: 1.2; }
.kpi .l { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.kpi.alert .v { color: var(--err-ink); }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 12px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.card h3 { margin: 0 0 8px; font-size: 14.5px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; margin-inline-start: 6px; }
.chart { height: 300px; width: 100%; }
.card.wide .chart { height: 320px; }

.alerts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.alertrow { text-align: start; display: flex; align-items: center; gap: 10px; background: var(--bg); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-weight: 500; }
.alertrow:hover, .alertrow[aria-expanded="true"] { border-color: var(--accent); }
.alertrow .cnt { min-width: 30px; text-align: center; border-radius: 999px; padding: 2px 8px; font-weight: 700; font-size: 13px; background: var(--code); }
.alertrow .cnt.hit { background: var(--warn-bg); color: var(--warn-ink); }
.alertrow .cnt.zero { opacity: .6; }
.alertrow .t { min-width: 0; }
.alertrow .t b { display: block; font-size: 13px; }
.alertrow .t small { color: var(--muted); font-size: 11.5px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.alert-detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.alert-detail h4 { margin: 0 0 4px; font-size: 14px; }
.alert-detail p { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.alert-detail table { border-collapse: collapse; font-size: 12.5px; width: 100%; }
.alert-detail th, .alert-detail td { border: 1px solid var(--line); padding: 4px 8px; text-align: start; vertical-align: top; overflow-wrap: anywhere; }
.alert-detail th { background: var(--code); }
.tablewrap2 { overflow-x: auto; }
a.idlink { color: var(--accent); text-decoration: underline dotted; cursor: pointer; font-weight: 600; }
a.idlink:hover { text-decoration: underline; }

/* graph explorer */
.gbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.gbar input { flex: 1; min-width: 200px; max-width: 420px; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
.gbar select { padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; }
.gbar label { color: var(--muted); font-size: 13px; }
.gwrap { display: flex; gap: 12px; flex: 1; min-height: 0; }
.gcanvas { flex: 1; min-width: 0; min-height: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.gside { width: 320px; max-width: 38%; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-size: 13px; }
.glegend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 10px; }
.glegend span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 12px; }
.glegend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; }
.ginfo h4 { margin: 0 0 4px; font-size: 14.5px; overflow-wrap: anywhere; }
.ginfo table { border-collapse: collapse; width: 100%; margin: 6px 0; }
.ginfo td { border-bottom: 1px solid var(--line); padding: 3px 4px; vertical-align: top; overflow-wrap: anywhere; }
.ginfo td:first-child { color: var(--muted); width: 38%; }
.ginfo .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ginfo .btns button { padding: 5px 10px; font-size: 12.5px; }
.muted { color: var(--muted); }

/* filters */
.filters { display: flex; flex-wrap: wrap; align-items: end; gap: 8px 12px; margin-bottom: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.filters label { display: flex; flex-direction: column; gap: 3px; color: var(--muted); font-size: 12px; }
.filters input, .filters select { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 13px; max-width: 220px; }
.filters button { padding: 7px 14px; }

/* sankey, trends, risk */
.chart.tall { height: 460px; }
.chart.small { height: 190px; }
.seg { display: inline-flex; margin-inline-start: 10px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; vertical-align: middle; }
.segbtn { background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: 3px 10px; font-size: 12px; font-weight: 600; }
.segbtn.on { background: var(--accent); color: var(--accent-ink); }
.spikes { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 12px; margin-top: 10px; }
.spikes table, .risk table { border-collapse: collapse; width: 100%; font-size: 12.5px; }
.spikes th, .spikes td, .risk th, .risk td { border-bottom: 1px solid var(--line); padding: 5px 6px; text-align: start; vertical-align: top; }
.spikes h4 { margin: 0 0 4px; font-size: 13px; }
.spikes .note { color: var(--muted); font-size: 12px; margin: 0 0 4px; }
.risk tr.row { cursor: pointer; }
.risk tr.row:hover td, .risk tr.row.on td { background: var(--code); }
.bar { display: inline-block; height: 9px; border-radius: 5px; background: var(--accent); vertical-align: middle; }
.tier { font-size: 11.5px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.tier.High { background: var(--err-bg); color: var(--err-ink); } .tier.Medium { background: var(--warn-bg); color: var(--warn-ink); } .tier.Low { background: var(--code); color: var(--muted); }
.chip2 { display: inline-block; font-size: 11px; background: var(--code); border-radius: 6px; padding: 1px 6px; margin: 1px 3px 1px 0; }
.risk-detail { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.risk-detail h4 { margin: 0 0 6px; font-size: 14px; }
.btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.btns button { padding: 5px 12px; font-size: 12.5px; }

/* cases */
.casegrid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 14px; }
.caselist, .casedetail { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.newcase { display: flex; gap: 6px; margin-bottom: 10px; }
.newcase input, .casedetail textarea, .casepick input, .casepick select, .casedetail select { padding: 7px 9px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; font-size: 13px; }
.newcase input { flex: 1; min-width: 0; }
.caseitem { display: block; width: 100%; text-align: start; background: var(--bg); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; margin-bottom: 6px; font-weight: 500; }
.caseitem.on, .caseitem:hover { border-color: var(--accent); }
.caseitem b { display: block; font-size: 13px; overflow-wrap: anywhere; }
.caseitem small { color: var(--muted); font-size: 11.5px; }
.badge2 { font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: var(--code); color: var(--muted); margin-inline-end: 6px; }
.badge2.reviewing { background: var(--warn-bg); color: var(--warn-ink); } .badge2.escalated { background: var(--err-bg); color: var(--err-ink); } .badge2.cleared { background: var(--user); color: var(--accent); }
.casedetail h3 { margin: 0 0 6px; font-size: 17px; overflow-wrap: anywhere; }
.casedetail h4 { margin: 14px 0 6px; font-size: 13.5px; }
.casedetail .rowline { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 6px 0; }
.citem { border: 1px solid var(--line); border-radius: 10px; padding: 7px 10px; margin: 6px 0; font-size: 13px; overflow-wrap: anywhere; }
.citem pre { margin: 6px 0 0; white-space: pre-wrap; font-size: 12px; background: var(--code); padding: 6px 8px; border-radius: 8px; max-height: 180px; overflow: auto; }
.citem .x, .cnote .x { float: inline-end; background: transparent; color: var(--muted); border: 0; padding: 0 4px; font-size: 16px; font-weight: 400; }
.cnote { border-inline-start: 3px solid var(--accent); padding: 4px 10px; margin: 6px 0; font-size: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.cnote small { display: block; color: var(--muted); font-size: 11.5px; }
.casedetail textarea { width: 100%; min-height: 70px; resize: vertical; }
.casepick { position: fixed; inset: 0; background: rgba(0, 0, 0, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.casepick[hidden] { display: none; }
.casepick .panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px; width: min(420px, 92vw); display: flex; flex-direction: column; gap: 8px; }
.casepick h4 { margin: 0; }
.addcase { background: transparent; color: var(--accent); border: 1px solid var(--accent); padding: 3px 10px; font-size: 12px; font-weight: 600; margin-top: 6px; }

@media (max-width: 860px) {
  .casegrid { grid-template-columns: minmax(0, 1fr); }
  .filters input, .filters select { max-width: none; width: 100%; }
  .filters label { flex: 1 1 140px; }
  .top { flex-wrap: wrap; }
  .tabs { order: 3; width: 100%; justify-content: center; overflow-x: auto; }
  .grid { grid-template-columns: minmax(0, 1fr); }
  .gwrap { flex-direction: column; }
  .gside { width: auto; max-width: none; }
  .gcanvas { min-height: 360px; }
  body[data-view="graph"] #graphview { overflow-y: auto; }
}

/* progress steps, cached-answer note, report bar, rules catalogue, investigate button */
.typinghead { display: flex; align-items: center; gap: 8px; }
.steps { list-style: none; margin: 6px 0 0; padding: 0; font-size: 12.5px; color: var(--muted); }
.steps li { padding: 1px 0; } .steps li.now { color: var(--ink); font-weight: 600; } .steps li.now::before { content: "\2192 "; }
.cachenote { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.cachenote button { margin-inline-start: 6px; padding: 2px 10px; font-size: 12px; }
.reportbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: flex-end; margin-bottom: 8px; }
.rulesintro { margin: 0 0 12px; max-width: 900px; }
.rulelist { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(380px, 100%), 1fr)); gap: 12px; align-items: start; }
.rulecard { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.rulecard h4 { margin: 0 0 4px; font-size: 14.5px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.rulecard .rid { font-size: 11.5px; background: var(--code); border-radius: 6px; padding: 1px 7px; }
.rulecard .hits { margin-inline-start: auto; font-size: 11.5px; font-weight: 700; padding: 1px 9px; border-radius: 999px; background: var(--code); color: var(--muted); }
.rulecard .hits.some { background: var(--warn-bg); color: var(--warn-ink); }
.rulecard p { margin: 4px 0; font-size: 13px; } .rulecard ul { margin: 2px 0 4px 18px; padding: 0; font-size: 13px; }
.rulecard h5 { margin: 8px 0 2px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.rulecard .btns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.rulecard pre { max-height: 220px; overflow: auto; font-size: 11.5px; background: var(--code); padding: 8px; border-radius: 8px; white-space: pre-wrap; }
.rulecard .ruleout { margin-top: 8px; overflow-x: auto; }
.rulecard .ruleout table { font-size: 12px; }
.invbtn { padding: 2px 9px; font-size: 12px; }

/* language switch and right-to-left details */
.langbtn { padding: 5px 12px; font-size: 13px; font-weight: 600; }
.reportbar button { white-space: nowrap; }
[dir="rtl"] .steps li.now::before { content: "\2190 "; }
[dir="rtl"] .bubble pre, [dir="rtl"] .q pre, [dir="rtl"] .rulecard pre { direction: ltr; text-align: left; }
[dir="rtl"] .chart, [dir="rtl"] .gcanvas { direction: ltr; }
[dir="rtl"] .idlink, [dir="rtl"] code { unicode-bidi: isolate; }
[dir="rtl"] td, [dir="rtl"] th { unicode-bidi: plaintext; }
@media (max-width: 520px) {
  .tab { padding: 6px 9px; font-size: 13px; white-space: nowrap; }
  .tabs { gap: 2px; }
  .actions { flex-wrap: wrap; }
}

/* money flow summary, trend chart and unusual-day list */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; margin: 4px 0 10px; }
.tile { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; background: var(--bg); }
.tile .l { font-size: 12px; color: var(--muted); font-weight: 600; } .tile .v { font-size: 24px; font-weight: 700; line-height: 1.25; } .tile .s { font-size: 12px; color: var(--muted); }
.tile.in .v { color: var(--accent); } .tile.left .v { color: #c2412d; }
.stackbar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: var(--code); margin: 2px 0 6px; }
.stackbar .paid { background: #2f5fb3; } .stackbar .left { background: #c2412d; }
.story { margin: 4px 0 10px; font-size: 14.5px; font-weight: 600; }
.flow-lists { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; margin-top: 8px; }
.rank h4 { margin: 0 0 6px; font-size: 13px; }
.rank ul { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: minmax(70px, 38%) 1fr auto; gap: 8px; align-items: center; padding: 3px 0; font-size: 12.5px; }
.rank .lab { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank .track { height: 10px; background: var(--code); border-radius: 999px; overflow: hidden; display: block; }
.rank .fill { display: block; height: 100%; border-radius: 999px; }
.rank .val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.flow-detail { margin-top: 12px; } .flow-detail summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--accent); }
.note { color: var(--muted); font-size: 12px; margin: 4px 0; }
.trendctl { display: flex; flex-wrap: wrap; gap: 10px; margin: 0 0 6px; } .trendctl .seg { margin-inline-start: 0; }
.tsegbtn { background: transparent; color: var(--muted); border: 0; border-radius: 0; padding: 4px 12px; font-size: 12.5px; font-weight: 600; }
.tsegbtn.on { background: var(--accent); color: var(--accent-ink); }
.spikelist h4 { margin: 10px 0 4px; font-size: 13px; }
.spikeul { list-style: none; margin: 0; padding: 0; }
.spikeul li { display: flex; gap: 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.spikeul .ratio { flex: none; min-width: 74px; text-align: center; font-weight: 700; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--err-bg); color: var(--err-ink); }
.spikeul .txt { flex: 1; } .spikeul .pid { flex: none; }
.card.wide .chart.tall { height: 460px; }

/* graph search: type filter, searchable suggestions, starting points */
.combo { position: relative; flex: 1 1 280px; min-width: 220px; max-width: 560px; }
.gbar .combo input { width: 100%; max-width: none; box-sizing: border-box; }
.suggest { position: absolute; inset-inline: 0; top: 100%; z-index: 40; margin: 4px 0 0; padding: 4px; list-style: none; max-height: 360px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); }
.suggest li { display: flex; gap: 10px; align-items: flex-start; padding: 7px 9px; border-radius: 8px; cursor: pointer; }
.suggest li[aria-selected="true"] { background: var(--code); }
.suggest li.hd, .suggest li.empty { cursor: default; color: var(--muted); font-size: 12px; padding: 5px 9px; }
.suggest .dot { flex: none; width: 10px; height: 10px; border-radius: 50%; margin-top: 6px; }
.suggest .txt { min-width: 0; flex: 1; }
.suggest .top { display: flex; gap: 8px; align-items: baseline; justify-content: space-between; }
.suggest .n { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .tp { flex: none; font-size: 11px; color: var(--muted); }
.suggest .alt { font-size: 12.5px; color: var(--ink); opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest .m { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gstarts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; font-size: 12.5px; }
.gstarts:empty { display: none; }
.ghostchip { opacity: .8; }
