:root {
  --ink: #17202e;        /* texto e rail */
  --ink-2: #4a5568;      /* texto secundário */
  --canvas: #eef1f5;     /* fundo */
  --surface: #ffffff;
  --line: #d9dee6;
  --amber: #d98e04;      /* abaixo da meta */
  --amber-bg: #fff4dc;
  --teal: #0d7a6a;       /* ações */
  --teal-bg: #e3f3f0;
  --red: #b42318;
  --sans: "IBM Plex Sans", "Segoe UI Variable", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", Consolas, "Cascadia Mono", monospace;
  --r-lg: 14px; --r-md: 8px; --r-sm: 5px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.55 var(--sans); color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
.hidden { display: none !important; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

/* ---------- rail ---------- */
.rail { background: var(--ink); color: #c9d1dd; padding: 22px 16px; display: flex; flex-direction: column; gap: 28px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: conic-gradient(from 200deg, var(--amber) 0 25%, #f5c04a 25% 50%, #3b4a60 50%); }
nav { display: flex; flex-direction: column; gap: 4px; }
.tool { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-md); color: inherit; text-decoration: none; font-size: 14px; }
.tool.active { background: rgba(255,255,255,.08); color: #fff; }
.tool .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(217,142,4,.25); }
.tool.soon { color: #6f7c8f; font-size: 13px; padding-left: 27px; }
.rail-foot { margin-top: auto; font-size: 12px; color: #8995a8; display: flex; flex-direction: column; gap: 10px; }
.file-btn { cursor: pointer; color: #c9d1dd; border: 1px dashed #3b4a60; border-radius: var(--r-md); padding: 8px 10px; text-align: center; }
.file-btn:hover { border-color: #8995a8; }
.file-btn input { display: none; }

/* ---------- incident header ---------- */
main { min-width: 0; padding: 28px 32px 48px; }
.incident { margin-bottom: 24px; }
.inc-empty h1 { font-size: 30px; line-height: 1.15; margin: 0 0 6px; letter-spacing: -.02em; font-weight: 700; }
.inc-empty p { margin: 0; color: var(--ink-2); max-width: 60ch; }
.inc-full { display: flex; gap: 32px; align-items: flex-end; justify-content: space-between; flex-wrap: wrap; }
.inc-main { min-width: 0; }
.inc-meta { color: var(--ink-2); font-size: 14px; display: flex; gap: 14px; flex-wrap: wrap; }
.inc-meta b { color: var(--ink); font-weight: 600; }
.inc-route { font-family: var(--mono); font-size: clamp(22px, 2.6vw, 32px); font-weight: 600; letter-spacing: -.02em; margin: 4px 0 2px; word-break: break-all; }
.inc-path { font-family: var(--mono); font-size: 14px; color: var(--teal); }

/* meter: o elemento de destaque — distância até a meta */
.meter { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 14px 18px; min-width: 300px; }
.meter-nums { display: flex; align-items: baseline; gap: 10px; }
.meter-val { font-family: var(--mono); font-size: 28px; font-weight: 600; color: var(--amber); letter-spacing: -.02em; }
.meter-val.ok { color: var(--teal); }
.meter-meta { font-size: 13px; color: var(--ink-2); }
.meter-track { position: relative; height: 8px; background: #edf0f4; border-radius: 4px; margin: 10px 0 6px; overflow: visible; }
.meter-fill { position: absolute; inset: 0 auto 0 0; background: var(--amber); border-radius: 4px; }
.meter-fill.ok { background: var(--teal); }
.meter-goal { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); }
.meter-delta { font-size: 13px; color: var(--ink-2); }
.meter-delta b { color: var(--amber); }

/* ---------- work area ---------- */
.work { display: grid; grid-template-columns: minmax(380px, 5fr) 7fr; gap: 20px; align-items: start; }
.flow { display: flex; flex-direction: column; gap: 14px; }
.step { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 18px; }
.step-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-head h2 { font-size: 16px; margin: 0; font-weight: 600; flex: 1; }
.step-n { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 600; background: var(--canvas); color: var(--ink-2); }
.step.done .step-n { background: var(--teal); color: #fff; }

label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 4px; font-weight: 500; }
input, textarea { width: 100%; font: inherit; font-size: 14px; color: var(--ink); background: #fbfcfd; border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; }
input:focus, textarea:focus { outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-bg); background: #fff; }
textarea { resize: vertical; }
.mono, #rid { font-family: var(--mono); font-size: 13px; }
.fields { display: grid; grid-template-columns: 1fr 170px; gap: 12px; }
.muted { color: var(--ink-2); }

/* combobox de rotas */
.combo { position: relative; }
.combo-list { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: 0 12px 32px -8px rgba(23,32,46,.22), 0 2px 6px rgba(23,32,46,.06); max-height: 360px; overflow: auto; }
.combo-list li[data-i] { padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer; }
.combo-list li.active { background: var(--teal-bg); }
.opt-id { font: 500 13px/1.35 var(--mono); color: var(--ink); word-break: break-all; }
.opt-sub { display: flex; gap: 8px; justify-content: space-between; margin-top: 2px; font-size: 12px; color: var(--ink-2); }
.opt-path { font-family: var(--mono); word-break: break-all; }
.opt-team { flex: none; color: var(--teal); }
.combo-list mark { background: #fde7b0; color: inherit; border-radius: 2px; }
.opt-more { padding: 6px 10px; font-size: 12px; color: var(--ink-2); }
.hint { margin: 0 0 8px; font-size: 13.5px; color: var(--ink-2); }

.facts { display: grid; grid-template-columns: 88px 1fr; gap: 4px 12px; margin: 0 0 12px; font-size: 13.5px; }
.facts:empty { display: none; }
.facts dt { color: var(--ink-2); }
.facts dd { margin: 0; min-width: 0; }
.facts .p { font-family: var(--mono); color: var(--teal); font-weight: 500; word-break: break-all; }

pre.code { margin: 0; background: #f6f8fa; border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px 14px; font: 12.5px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; color: #2b3445; max-height: 340px; overflow: auto; }

.cmp { margin-top: 10px; }
.cmp summary { cursor: pointer; font-size: 13.5px; color: var(--ink-2); margin-bottom: 8px; }

.msg { font-size: 13px; margin-top: 8px; }
.msg:empty { display: none; }
.msg.err { color: var(--red); } .msg.warn { color: #8a5a00; background: var(--amber-bg); padding: 6px 10px; border-radius: var(--r-sm); }
.msg.ok { color: var(--teal); }
.sugg { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.sugg button { font: 12px var(--mono); background: var(--canvas); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 8px; cursor: pointer; color: var(--ink); }
.sugg button:hover { border-color: var(--teal); }

.btn { font: inherit; font-size: 13.5px; font-weight: 500; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: var(--r-md); padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.btn:hover:not(:disabled) { border-color: var(--ink-2); }
.btn.primary { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #0a6658; }
.btn:disabled { opacity: .45; cursor: default; }

/* ---------- report ---------- */
.report { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); position: sticky; top: 20px; display: flex; flex-direction: column; max-height: calc(100vh - 40px); }
.report-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; background: var(--canvas); padding: 3px; border-radius: var(--r-md); }
.tab { font: inherit; font-size: 13.5px; border: 0; background: transparent; padding: 5px 12px; border-radius: var(--r-sm); cursor: pointer; color: var(--ink-2); }
.tab.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(23,32,46,.12); }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.report-body { overflow: auto; padding: 24px 32px 32px; flex: 1; }
.pane[data-pane="md"], .pane[data-pane="md"] .md-edit { height: 100%; }
.md-edit { min-height: 60vh; font-size: 12.5px; line-height: 1.5; }
.cons-edit { font-size: 14.5px; line-height: 1.6; margin-bottom: 10px; }
.empty { color: var(--ink-2); padding: 48px 0; text-align: center; }
.empty p { margin: 4px 0; }

/* documento renderizado */
.doc { max-width: 76ch; font-size: 14.5px; }
.doc h1 { font-size: 22px; line-height: 1.25; margin: 0 0 14px; letter-spacing: -.015em; }
.doc h2 { font-size: 18px; margin: 30px 0 10px; padding-top: 18px; border-top: 1px solid var(--line); }
.doc h3 { font-size: 15px; margin: 22px 0 8px; }
.doc p { margin: 0 0 10px; }
.doc ul { margin: 0 0 12px; padding-left: 20px; }
.doc li { margin: 2px 0; }
.doc code { font-family: var(--mono); font-size: .88em; background: #f1f3f6; padding: 1px 5px; border-radius: 4px; }
.doc blockquote { margin: 0 0 16px; padding: 10px 14px; border-left: 3px solid var(--amber); background: #fbf8f0; border-radius: 0 var(--r-md) var(--r-md) 0; font-size: 14px; line-height: 1.7; }
.doc table { border-collapse: collapse; margin: 6px 0 14px; font-size: 13.5px; min-width: 60%; }
.doc th { background: #f3f5f8; font-weight: 600; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 10px; }
.doc td { font-variant-numeric: tabular-nums; }
.doc pre { background: #f6f8fa; border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; font: 12px/1.5 var(--mono); white-space: pre-wrap; word-break: break-word; margin: 0 0 12px; }
.doc pre code { background: none; padding: 0; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 9px 16px; border-radius: var(--r-md); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1100px) {
  .work { grid-template-columns: 1fr; }
  .report { position: static; max-height: none; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; align-items: center; flex-wrap: wrap; gap: 12px; }
  .rail-foot { margin: 0; }
  main { padding: 20px 16px; }
  .fields { grid-template-columns: 1fr; }
  .report-body { padding: 18px; }
}
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
