:root {
  --bg: #f6f7f9; --panel: #fff; --ink: #1d2330; --muted: #667085; --line: #e3e6ec;
  --accent: #2f5bd3; --accent-ink: #fff; --ok: #1f7a4d; --warn: #a15c00; --bad: #b42318; --mock: #7a3fbf;
  --chip: #eef1f6; --radius: 10px;
  font-family: "Sarabun", "Noto Sans Thai", "Leelawadee UI", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #12151b; --panel: #1a1f28; --ink: #e6e9ef; --muted: #98a2b3; --line: #2b3240; --chip: #252c38; --accent: #6d8ff0; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.55; }
a { color: var(--accent); }
.pad { padding: 16px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.topbar { display: flex; gap: 16px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { padding: 6px 10px; border-radius: 8px; text-decoration: none; color: var(--ink); }
.topbar nav a.active { background: var(--chip); font-weight: 600; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); }
main { padding: 16px; max-width: 1500px; margin: 0 auto; }
h1 { font-size: 22px; margin: 4px 0 12px; } h2 { font-size: 18px; margin: 16px 0 8px; } h3 { font-size: 16px; margin: 12px 0 6px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.card h3 { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 6px 12px; border-radius: 8px; cursor: pointer; font: inherit; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.ghost { border-color: transparent; }
.btn.sm { padding: 2px 8px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; width: 100%; }
textarea { min-height: 70px; resize: vertical; }
label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 2px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-size: 14px; margin: 0 12px 0 0; }
label.inline input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 10px 0; }
legend { padding: 0 6px; font-weight: 600; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 760px) { .form2 { grid-template-columns: 1fr; } }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--chip); font-size: 12px; white-space: nowrap; }
.chip.ok, .st-complete, .st-succeeded, .st-done, .st-ready, .st-authenticated { color: var(--ok); }
.chip.warn, .st-queued, .st-paused, .st-awaiting_input, .st-configured, .st-partial { color: var(--warn); }
.chip.bad, .st-failed, .st-blocked, .st-cancelled, .st-not_configured, .st-not_authenticated, .st-not_implemented, .st-error { color: var(--bad); }
.st-running { color: var(--accent); font-weight: 600; }
.chip.mock, .mock-badge { background: var(--mock); color: #fff; font-weight: 700; }
.mock-banner { background: var(--mock); color: #fff; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-weight: 600; }
.partial-banner { background: var(--warn); color: #fff; padding: 8px 12px; border-radius: 8px; margin-bottom: 10px; font-weight: 600; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: #fff; flex: none; }
.av-owner { background: #c2410c; } .av-manager { background: #0f766e; } .av-employee { background: #4f46e5; } .av-human { background: #475467; }
.agent-card { display: flex; gap: 8px; align-items: flex-start; padding: 8px; border: 1px solid var(--line); border-radius: 8px; margin: 6px 0; background: var(--panel); }
.agent-card.disabled { opacity: .55; }
.agent-card .meta { flex: 1; min-width: 0; }
.agent-card .meta div { overflow-wrap: anywhere; }
/* meeting 3-pane */
.meeting { display: grid; grid-template-columns: 240px minmax(0, 1fr) 340px; gap: 12px; align-items: start; }
.meeting .left, .meeting .right { position: sticky; top: 64px; max-height: calc(100vh - 80px); overflow: auto; }
.room-nav button { display: flex; width: 100%; text-align: left; gap: 6px; align-items: center; padding: 8px; border: 0; background: transparent; border-radius: 8px; cursor: pointer; color: var(--ink); font: inherit; }
.room-nav button[aria-current="true"] { background: var(--chip); font-weight: 600; }
.tabs { display: none; }
@media (max-width: 1100px) {
  .meeting { grid-template-columns: 1fr; }
  .meeting .left, .meeting .right { position: static; max-height: none; }
  .tabs { display: flex; gap: 6px; margin-bottom: 8px; }
  .meeting[data-tab="rooms"] .center, .meeting[data-tab="rooms"] .right { display: none; }
  .meeting[data-tab="talk"] .left, .meeting[data-tab="talk"] .right { display: none; }
  .meeting[data-tab="context"] .left, .meeting[data-tab="context"] .center { display: none; }
}
.stage-h { margin: 18px 0 6px; padding-bottom: 4px; border-bottom: 1px solid var(--line); font-size: 15px; color: var(--muted); }
.msg { display: flex; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin: 8px 0; }
.msg:target, .msg.flash { outline: 2px solid var(--accent); }
.msg .body { flex: 1; min-width: 0; }
.msg .head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 13px; }
.msg .summary { font-weight: 600; margin: 4px 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.kv { margin: 4px 0; }
.kv > .k { font-size: 12px; color: var(--muted); }
.kv > .v { white-space: pre-wrap; overflow-wrap: anywhere; }
.kv ul { margin: 2px 0; padding-left: 20px; }
.ref { cursor: pointer; border: 0; background: var(--chip); color: var(--accent); border-radius: 6px; padding: 0 6px; font: inherit; font-size: 12px; }
details.prov { font-size: 12px; color: var(--muted); margin-top: 6px; }
.pending { padding: 8px 10px; border: 1px dashed var(--line); border-radius: 8px; margin: 6px 0; font-size: 14px; }
.bar { height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); }
#toast { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 8px; display: none; z-index: 20; max-width: 90vw; }
#toast.show { display: block; }
#toast.err { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); color: var(--ink); max-width: 640px; width: 92vw; }
dialog::backdrop { background: rgba(0,0,0,.35); }
.login { max-width: 380px; margin: 10vh auto; }
.warnbox { border-left: 4px solid var(--warn); background: var(--chip); padding: 8px 10px; border-radius: 6px; margin: 6px 0; }
.errbox { border-left: 4px solid var(--bad); background: var(--chip); padding: 8px 10px; border-radius: 6px; margin: 6px 0; }
.orgchart { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.orgchart .lvl { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.orgchart .node { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 10px; font-size: 13px; text-align: center; min-width: 140px; }
code, .mono { font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
