/* Trustera "The Map" identity: graphite ground, gold policy, green allowed, red blocked. */
:root {
  color-scheme: dark;
  --bg: #0B0C0F;
  --panel: #121419;
  --panel-2: #181B22;
  --line: #262A33;
  --ink: #F2F2F0;
  --muted: #A3A7B3;
  --gold: #F5B83D;
  --gold-soft: #2E2614;
  --green: #3DDBB4;
  --green-soft: #12302A;
  --red: #FF5D5D;
  --red-soft: #351819;
  --amber: #FFCB7E;
  --sans: "IBM Plex Sans Arabic", "Segoe UI", Tahoma, system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.6 var(--sans); }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px max(16px, 3vw); background: rgba(11,12,15,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand b { display: block; font: 600 22px/1 "IBM Plex Sans", var(--sans); letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 12px; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.tab { border: 0; background: none; padding: 8px 16px; border-radius: 9px; cursor: pointer; color: var(--muted); font-weight: 600; }
.tab.active { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.top-actions { display: flex; align-items: center; gap: 14px; }
.live { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.dot { width: 9px; height: 9px; border-radius: 99px; background: var(--green); box-shadow: 0 0 0 4px rgba(61,219,180,.15); }
.live.busy .dot { background: var(--gold); animation: pulse 1s infinite; }
.ghost { font-size: 13px; color: var(--muted); text-decoration: none; border: 1px solid var(--line); padding: 6px 12px; border-radius: 9px; }
.ghost:hover { color: var(--ink); }
.lang { border: 1px solid var(--gold); background: none; color: var(--gold); padding: 6px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; font-size: 13px; }
.lang:hover { background: var(--gold-soft); }
.reset { border: 1px solid var(--line); background: none; color: var(--muted); padding: 6px 12px; border-radius: 9px; cursor: pointer; font-size: 13px; font-weight: 600; }
.reset:hover { color: var(--ink); border-color: var(--muted); }
.reset.armed { color: var(--red); border-color: var(--red); background: var(--red-soft); }
html[lang="en"] body { font-family: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif; }
html[dir="ltr"] .drawer { left: auto; right: 0; border-right: 0; border-left: 1px solid var(--line); }

main { max-width: 1440px; margin: 0 auto; padding: 24px max(16px, 3vw) 40px; display: flex; flex-direction: column; gap: 18px; }

/* hero */
.hero { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: 13px; font-weight: 600; }
h1 { margin: 0; font-size: clamp(26px, 3.2vw, 40px); line-height: 1.25; text-wrap: balance; }
h1 em { font-style: normal; color: var(--gold); }
.lead { margin: 8px 0 10px; color: var(--muted); max-width: 62ch; }
.policy-line { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { font-family: var(--mono); font-size: 12.5px; padding: 2px 10px; border-radius: 99px; direction: ltr; }
.chip.ok { background: var(--green-soft); color: var(--green); }
.chip.bad { background: var(--red-soft); color: var(--red); }
.modes { display: flex; gap: 8px; flex-wrap: wrap; }
.mode { display: inline-flex; align-items: center; gap: 10px; border: 1px solid var(--line); background: var(--panel); padding: 11px 16px;
  border-radius: 12px; cursor: pointer; font-weight: 600; transition: transform .15s, border-color .15s; }
.mode:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-1px); }
.mode:disabled { opacity: .4; cursor: default; }
.mode .k { width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; background: var(--panel-2); color: var(--gold); font-size: 13px; }
.mode.primary { background: var(--gold); color: #17130A; border-color: var(--gold); }
.mode.primary .k { background: rgba(0,0,0,.15); color: #17130A; }
.mode.try { border-color: rgba(61,219,180,.5); }
.mode.wide { width: 100%; justify-content: center; margin-top: 16px; }
.mode.spin { opacity: .7; pointer-events: none; }

.banner { border-radius: 14px; padding: 14px 18px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; font-weight: 600;
  background: var(--green-soft); color: var(--green); border: 1px solid rgba(61,219,180,.35); }
.banner.bad { background: var(--red-soft); color: var(--red); border-color: rgba(255,93,93,.35); }
.banner .big { font: 600 26px/1 "IBM Plex Sans", var(--sans); }
.error { margin: 0; color: var(--red); background: var(--red-soft); padding: 10px 14px; border-radius: 10px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.stat .l { color: var(--muted); font-size: 13px; }
.stat .n { font: 600 30px/1.2 "IBM Plex Sans", var(--sans); font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat .n.ok { color: var(--green); } .stat .n.bad { color: var(--red); } .stat .n.gold { color: var(--gold); }

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px 18px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.card-head h2 { margin: 0; font-size: 18px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.lg { display: inline-block; width: 22px; height: 0; border-top: 3px solid; margin-inline-end: 6px; vertical-align: middle; }
.lg.ok { border-color: var(--green); } .lg.bad { border-color: var(--red); border-top-style: dashed; } .lg.stop { border-color: #555B66; }
.map-scroll { overflow-x: auto; }
#map { display: block; width: 100%; min-width: 760px; height: auto; direction: ltr; }
.map-cols { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; padding: 4px 6% 0; direction: ltr; }

/* svg map */
.node rect { fill: var(--panel-2); stroke: #3A3F4A; stroke-width: 1.3; }
.node .t { fill: var(--ink); font: 600 14px var(--sans); }
.node .s { fill: var(--muted); font: 11px var(--mono); }
.node.allowed rect { stroke: rgba(61,219,180,.55); }
.node.leak rect { stroke: var(--red); stroke-dasharray: 5 4; fill: #1E1214; }
.node.leak .t { fill: #FFD9D9; }
.node.partner rect { stroke: #5DA9FF; stroke-width: 1.6; }
.node.partner.hit rect { stroke: var(--red); }
.node.code rect { stroke: #3A3F4A; }
.node.code.hit rect { stroke: var(--red); stroke-dasharray: 5 4; fill: #1E1214; }
.gate rect.box { fill: #19160D; stroke: var(--gold); stroke-width: 2; }
.gate .t { fill: var(--gold); font: 700 16px var(--sans); }
.gate .s { fill: var(--muted); font: 11.5px var(--mono); }
.gate.busy rect.box { animation: glow 1s ease-in-out infinite alternate; }
.pill-ok { fill: var(--green); } .pill-bad { fill: var(--red); }
.edge { fill: none; stroke-width: 2.2; stroke-linecap: round; }
.edge.idle { stroke: #2C3039; }
.edge.ok { stroke: var(--green); opacity: .9; }
.edge.bad { stroke: var(--red); stroke-dasharray: 7 7; animation: dash 1.1s linear infinite; }
.edge.stop { stroke: #4A505C; stroke-dasharray: 2 6; }
.flow { fill: none; stroke: #E9FFF8; stroke-width: 4; stroke-linecap: round; stroke-dasharray: .1 22; animation: dash 1.4s linear infinite; opacity: .85; }
.xmark { stroke: var(--red); stroke-width: 2.4; stroke-linecap: round; }
.badge-t { font: 600 11px var(--sans); }
@keyframes dash { to { stroke-dashoffset: -28; } }
@keyframes glow { from { filter: drop-shadow(0 0 0 rgba(245,184,61,0)); } to { filter: drop-shadow(0 0 10px rgba(245,184,61,.7)); } }
@keyframes pulse { 50% { opacity: .35; } }

/* alerts */
.count { min-width: 26px; height: 26px; border-radius: 99px; display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--red-soft); color: var(--red); padding: 0 8px; }
.count.zero { background: var(--green-soft); color: var(--green); }
.alert { width: 100%; text-align: start; border: 1px solid rgba(255,93,93,.35); background: #1A1112; border-radius: 12px; padding: 12px 14px;
  margin-bottom: 10px; cursor: pointer; display: block; }
.alert:hover { border-color: var(--red); }
.alert.sus { border-color: rgba(255,203,126,.35); background: #1B1710; }
.alert .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.alert .t { font-weight: 600; }
.alert .m { color: var(--muted); font-size: 12.5px; }
.sev { font-size: 11.5px; font-weight: 700; padding: 1px 9px; border-radius: 99px; }
.sev.critical { background: var(--red); color: #1A0909; } .sev.high { background: var(--red-soft); color: var(--red); }
.sev.medium { color: var(--amber); border: 1px dashed var(--amber); }
.ok-box { border-radius: 12px; padding: 14px; background: var(--green-soft); color: var(--green); font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; }
.report-btn { display: block; text-align: center; margin-top: 8px; padding: 10px; border-radius: 10px; border: 1px solid var(--line);
  color: var(--ink); text-decoration: none; font-weight: 600; }
.report-btn:hover { border-color: var(--gold); }

/* feed */
.table-scroll { overflow-x: auto; }
.feed { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
.feed th { text-align: start; color: var(--muted); font-weight: 500; font-size: 12.5px; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.feed td { padding: 9px 10px; border-bottom: 1px solid #1D2028; vertical-align: middle; }
.feed tr.new { animation: rowin .45s ease-out; }
.feed td .mono { font-size: 12.5px; }
.dec { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 99px; }
.dec.ok { background: var(--green-soft); color: var(--green); } .dec.bad { background: var(--red-soft); color: var(--red); }
@keyframes rowin { from { opacity: 0; transform: translateY(-6px); background: rgba(245,184,61,.08); } }

/* detail */
.d-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: flex-start; }
.d-head h2 { margin: 0 0 4px; font-size: 22px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.panel { border-radius: 12px; overflow: hidden; border: 1px solid var(--line); min-width: 0; }
.panel h4 { margin: 0; padding: 8px 12px; font-size: 13px; }
.panel.ok h4 { background: var(--green-soft); color: var(--green); } .panel.bad h4 { background: var(--red-soft); color: var(--red); }
pre { margin: 0; padding: 12px; font: 12.5px/1.6 var(--mono); white-space: pre-wrap; word-break: break-word; background: #0E1014; direction: ltr; text-align: left; }
.hl { background: rgba(255,93,93,.22); color: #FFB3B3; border-radius: 3px; }
.d-sec { margin-top: 18px; } .d-sec h3 { font-size: 15px; margin: 0 0 8px; }
.rules { width: 100%; border-collapse: collapse; font-size: 13px; direction: ltr; text-align: left; }
.rules td { padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.ev { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; direction: ltr; }
.ai { margin-top: 18px; background: var(--gold-soft); border: 1px solid rgba(245,184,61,.3); border-radius: 12px; padding: 14px 16px; }
.ai .btn { border: 1px solid var(--gold); background: none; color: var(--gold); padding: 6px 14px; border-radius: 9px; cursor: pointer; font-weight: 600; }
.ai-body { direction: ltr; text-align: left; margin-top: 10px; font-size: 14px; }
.ai-body ol { margin: 6px 0; padding-left: 20px; }

/* drawer */
.drawer-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 30; }
.drawer { position: fixed; top: 0; bottom: 0; left: 0; width: min(440px, 100%); z-index: 31; background: var(--panel); border-right: 1px solid var(--line);
  padding: 20px; overflow-y: auto; animation: slidein .25s ease-out; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; }
.drawer-head h2 { margin: 0; }
.drawer h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); }
.x { border: 1px solid var(--line); background: none; border-radius: 9px; width: 34px; height: 34px; cursor: pointer; }
.toggles { display: flex; flex-direction: column; gap: 8px; }
.tg { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; }
.tg:has(input:checked) { border-color: var(--red); background: var(--red-soft); }
.tg input { accent-color: var(--red); margin-top: 5px; }
.tg small { color: var(--muted); display: block; }
.code { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; }
.code summary { cursor: pointer; padding: 8px 12px; font-weight: 600; }
@keyframes slidein { from { transform: translateX(-30px); opacity: 0; } }

.limit { color: var(--muted); font-size: 12.5px; border-inline-start: 3px solid var(--line); padding-inline-start: 10px; margin: 0; }

@media (max-width: 1100px) { .layout { grid-template-columns: 1fr; } .stats { grid-template-columns: repeat(3, minmax(0,1fr)); } }
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; } .top-actions .ghost { display: none; }
  .stats { grid-template-columns: repeat(2, minmax(0,1fr)); } .cols { grid-template-columns: 1fr; }
  .mode { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Shield, contract -> policy, ledger */
.mode.shield { border-color: rgba(245,184,61,.6); }
.tabs { flex-wrap: wrap; }
.tag-soft { font-size: 12.5px; color: var(--muted); border: 1px solid var(--line); padding: 3px 10px; border-radius: 99px; }
.samples { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.chip-btn { border: 1px dashed var(--line); background: none; color: var(--ink); padding: 4px 12px; border-radius: 99px; cursor: pointer; font-size: 13px; }
.chip-btn:hover { border-color: var(--gold); }
textarea#clause { width: 100%; background: var(--panel-2); color: var(--ink); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; font: 15px/1.7 var(--sans); resize: vertical; }
textarea#clause:focus { outline: 2px solid var(--gold); outline-offset: 2px; }
.actions-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.draft { margin-top: 16px; display: grid; gap: 12px; }
.draft .row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.draft .lbl { min-width: 150px; color: var(--muted); font-size: 13.5px; }
.chip.neutral { background: var(--panel-2); color: var(--muted); }
.match { font-size: 13px; color: var(--muted); }
.match q { color: var(--ink); }
.diff { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--panel-2); }
.ledger-ok, .ledger-bad { border-radius: 14px; padding: 16px 18px; margin: 12px 0; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ledger-ok { background: var(--green-soft); color: var(--green); border: 1px solid rgba(61,219,180,.35); }
.ledger-bad { background: var(--red-soft); color: var(--red); border: 1px solid rgba(255,93,93,.4); }
.ledger-ok .big, .ledger-bad .big { font: 600 28px/1 "IBM Plex Sans", var(--sans); }
.ledger td.bad-row { color: var(--red); }
.ledger tr.broken td { background: rgba(255,93,93,.08); }
.gate .shield-t { fill: var(--gold); font: 700 13px var(--sans); }
.tag-soft:empty { display: none; }
