:root {
  --bg: #0f121b;
  --panel: #171b27;
  --panel-2: #1e2333;
  --line: #2c3246;
  --text: #e6e9f2;
  --muted: #9aa3b8;
  --accent: #7c6cff;
  --green: #3ddc84;
  --blue: #4aa8ff;
  --amber: #ffb020;
  --red: #ff5c5c;
  --cyan: #38d6d6;
  --grey: #8a90a0;
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Liberation Mono", monospace;
  --sans: system-ui, "Segoe UI", Roboto, Arial, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); }
[hidden] { display: none !important; }
code, .mono { font-family: var(--mono); font-size: 0.92em; overflow-wrap: anywhere; }
.small { font-size: 12px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.h3 { font-size: 16px; margin: 4px 0 10px; }
.h4 { font-size: 13px; margin: 14px 0 6px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
button, select, input, textarea { font: inherit; color: var(--text); background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 6px 10px; }
button { cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
button.danger { background: #5a1f24; border-color: var(--red); color: #fff; font-weight: 600; }
button.link { background: none; border: none; color: var(--blue); padding: 0; text-decoration: underline; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.synthetic-banner { background: repeating-linear-gradient(135deg, #3b2f00 0 14px, #2c2400 14px 28px); color: #ffe08a; padding: 6px 16px; font-size: 12px; text-align: center; border-bottom: 1px solid #6b5600; }
.boot { padding: 40px; color: var(--muted); }

.login { display: grid; place-items: center; min-height: calc(100vh - 40px); padding: 16px; }
.login-card { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 24px; }
.login-card h1 { margin: 0 0 4px; font-size: 20px; }
.login-card form { display: grid; gap: 6px; margin: 16px 0; }
.login-card label { color: var(--muted); font-size: 12px; margin-top: 6px; }
.login-card button { margin-top: 12px; }
.error { color: var(--red); min-height: 1em; }
.warn { background: #3b2a00; border: 1px solid #7a5a00; color: #ffd27a; padding: 8px 12px; border-radius: 6px; margin: 8px 16px; }

.topbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { font-weight: 700; letter-spacing: 0.04em; display: flex; align-items: center; gap: 8px; }
.brand .sub { color: var(--muted); font-weight: 400; }
.logo { width: 14px; height: 14px; background: var(--accent); box-shadow: 4px 4px 0 var(--amber); display: inline-block; }
.session { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip { font-size: 12px; padding: 3px 8px; border-radius: 999px; background: var(--panel-2); border: 1px solid var(--line); }
.chip.green { border-color: var(--green); color: var(--green); }
.chip.red { border-color: var(--red); color: var(--red); }

.tabs { display: flex; gap: 4px; padding: 8px 16px 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border-radius: 6px 6px 0 0; border-bottom: none; background: transparent; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { background: var(--panel); color: var(--text); border-color: var(--line); }
.badge { background: var(--amber); color: #111; border-radius: 999px; padding: 0 7px; font-size: 11px; font-weight: 700; margin-left: 4px; }
.toast { position: fixed; right: 16px; bottom: 16px; max-width: min(520px, calc(100vw - 32px)); background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--blue); padding: 10px 14px; border-radius: 6px; z-index: 10; }
.toast.green { border-left-color: var(--green); }
.toast.red { border-left-color: var(--red); }
.toast.amber { border-left-color: var(--amber); }

main { padding: 16px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.office-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.office-canvas-wrap { min-width: 0; background: #0a0c12; border: 1px solid var(--line); border-radius: 10px; padding: 8px; display: flex; justify-content: center; }
#office-canvas { image-rendering: pixelated; image-rendering: crisp-edges; display: block; max-width: 100%; }
#agent-panel { max-height: 80vh; overflow: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 12px 0; }
.state { --c: var(--grey); display: inline-block; font: 700 11px var(--mono); color: #0b0d14; background: var(--c); padding: 2px 7px; border-radius: 3px; }
.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); }
.pill.green { color: var(--green); border-color: var(--green); }
.pill.blue { color: var(--blue); border-color: var(--blue); }
.pill.amber { color: var(--amber); border-color: var(--amber); }
.pill.red { color: var(--red); border-color: var(--red); }
.pill.cyan { color: var(--cyan); border-color: var(--cyan); }
.pill.grey { color: var(--grey); border-color: var(--grey); }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: 8px; padding: 12px; min-width: 0; }
.tile.green { border-left-color: var(--green); }
.tile.red { border-left-color: var(--red); }
.tile.amber { border-left-color: var(--amber); }
.tile-title { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }
.tile-value { font-size: 22px; font-weight: 700; margin: 4px 0; overflow-wrap: anywhere; }
.tile-sub { font-size: 12px; overflow-wrap: anywhere; }
.tile-src { font-size: 11px; color: var(--muted); margin-top: 6px; font-family: var(--mono); }

.table-wrap { overflow-x: auto; }
table.grid { border-collapse: collapse; width: 100%; font-size: 13px; }
table.grid th, table.grid td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.grid th { color: var(--muted); font-weight: 600; font-size: 12px; }
td.objective, .objective { max-width: 360px; overflow-wrap: anywhere; }

.two-col { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
#mission-form { display: grid; gap: 6px; }
#mission-form label { color: var(--muted); font-size: 12px; margin-top: 4px; display: block; }
#mission-form input, #mission-form textarea, #mission-form select { width: 100%; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
fieldset.fixed { border: 1px dashed var(--line); border-radius: 8px; margin: 8px 0; }
fieldset.fixed legend { color: var(--muted); font-size: 12px; }
dl, .kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 3px 12px; margin: 6px 0; font-size: 13px; }
dt { color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 10px 0; }
.ks-state { font-size: 18px; font-weight: 700; padding: 8px 12px; border-radius: 6px; }
.ks-state.red { background: #3a1418; color: #ff9a9a; }
.ks-state.green { background: #12301f; color: #8ff0b8; }
.approval { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 10px 0; background: var(--panel-2); }
ol.events { padding-left: 22px; }
ol.events li { margin: 4px 0; }
ol.events summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: 8px; }
.seq { color: var(--amber); }
pre { background: #0a0c12; border: 1px solid var(--line); border-radius: 6px; padding: 8px; overflow: auto; max-height: 320px; }
.foot { padding: 8px 16px 24px; }

/* increment 5: agents tab, orchestration tree, agent history */
ul.tree { list-style: none; padding-left: 18px; margin: 4px 0; border-left: 1px dashed var(--line); }
ul.tree > li { margin: 6px 0; }
#agents-tab h2 { margin-top: 18px; }
#agents-tab details { margin: 8px 0; }
.history details { margin: 4px 0; }
.history summary { cursor: pointer; color: var(--muted); font-size: 12px; }
ul.hist { padding-left: 18px; margin: 4px 0; }
ul.hist li { margin: 4px 0; }

dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 18px; width: min(560px, calc(100vw - 32px)); }
dialog.wide { width: min(860px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

@media (max-width: 980px) {
  .office-layout, .two-col { grid-template-columns: minmax(0, 1fr); }
  #agent-panel { max-height: none; }
}
@media (max-width: 560px) {
  main { padding: 10px; }
  .row { grid-template-columns: minmax(0, 1fr); }
  .topbar { padding: 8px 10px; }
  .tabs { padding: 6px 10px 0; }
}
