/* KHOORK Agents — operations console. Ink-and-thread palette: deep indigo ink, a
   print-screen magenta accent, warm neutral paper. */
:root {
  --bg: #f4f3f7; --surface: #ffffff; --surface-2: #f0eef5; --fg: #1c1a26; --muted: #5d5970;
  --line: #e1dee9; --accent: #b0247a; --accent-ink: #ffffff; --accent-soft: #fbe7f3;
  --ok: #157a4a; --ok-soft: #e3f5ec; --warn: #9a5b00; --warn-soft: #fff3dc; --err: #b42318; --err-soft: #fde8e7;
  --ask: #2f55c9; --ask-soft: #e8eeff;
  --radius: 10px; --font: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #121019; --surface: #1b1824; --surface-2: #231f2f; --fg: #ece9f4; --muted: #a8a3b8;
  --line: #2f2a3d; --accent: #e65fb2; --accent-ink: #1b0b14; --accent-soft: #3a1830;
  --ok: #5fd39b; --ok-soft: #12301f; --warn: #f2b84b; --warn-soft: #33260c; --err: #ff8a80; --err-soft: #3a1414;
  --ask: #8fa9ff; --ask-soft: #1b2442; color-scheme: dark } }
:root[data-theme="dark"] {
  --bg: #121019; --surface: #1b1824; --surface-2: #231f2f; --fg: #ece9f4; --muted: #a8a3b8;
  --line: #2f2a3d; --accent: #e65fb2; --accent-ink: #1b0b14; --accent-soft: #3a1830;
  --ok: #5fd39b; --ok-soft: #12301f; --warn: #f2b84b; --warn-soft: #33260c; --err: #ff8a80; --err-soft: #3a1414;
  --ask: #8fa9ff; --ask-soft: #1b2442; color-scheme: dark }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; text-wrap: balance; margin: 0; }
h1 { font-size: 1.5rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { font-weight: 800; letter-spacing: 0.08em; font-size: 0.95rem; }
.brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 0.9rem; }
.topbar nav a[aria-current="page"] { background: var(--accent-soft); color: var(--fg); }
.topbar .who { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 0.88rem; color: var(--muted); }

.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 60px; display: flex; flex-direction: column; gap: 22px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; min-width: 0; }
.panel > h2 { margin-bottom: 4px; }
.panel > p.muted { margin: 0 0 14px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn { font: inherit; font-weight: 600; font-size: 0.9rem; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); cursor: pointer; }
.btn:hover:not(:disabled) { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--err); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

label.field { display: flex; flex-direction: column; gap: 5px; font-weight: 600; font-size: 0.88rem; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
input[type=text], input[type=email], input[type=password], input[type=url], input[type=number], select, textarea {
  font: inherit; font-weight: 400; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); width: 100%; min-width: 0; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 0.9rem; }
.form { display: grid; gap: 12px; }
.form.cols { grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); }

.pill { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.pill.succeeded, .pill.set { background: var(--ok-soft); color: var(--ok); }
.pill.failed, .pill.missing { background: var(--err-soft); color: var(--err); }
.pill.running, .pill.queued { background: var(--accent-soft); color: var(--accent); }
.pill.waiting { background: var(--ask-soft); color: var(--ask); }
.pill.cancelled { background: var(--warn-soft); color: var(--warn); }

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em; }
.table-wrap { overflow-x: auto; }
td.num { font-variant-numeric: tabular-nums; }

.agent-card { display: flex; flex-direction: column; gap: 10px; }
.agent-card.planned { opacity: 0.75; border-style: dashed; }
.notice { padding: 10px 14px; border-radius: 8px; font-size: 0.9rem; }
.notice.err { background: var(--err-soft); color: var(--err); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }
.notice.warn { background: var(--warn-soft); color: var(--warn); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.tabs button { font: inherit; font-weight: 600; font-size: 0.9rem; background: none; border: none; padding: 9px 14px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }

/* Run page */
.run-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(280px, 360px); gap: 18px; align-items: start; }
@media (max-width: 900px) { .run-layout { grid-template-columns: 1fr; } }
.screen { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; aspect-ratio: 1280 / 800; max-width: 100%; }
.screen img { width: 100%; height: 100%; object-fit: contain; display: block; cursor: crosshair; }
.screen .idle { position: absolute; inset: 0; display: grid; place-items: center; color: #c9c5d6; font-size: 0.95rem; text-align: center; padding: 20px; }
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; max-height: 520px; overflow-y: auto; font-size: 0.86rem; }
.log li { padding: 6px 8px; border-radius: 6px; background: var(--surface-2); }
.log li.error { background: var(--err-soft); color: var(--err); }
.log li.success { background: var(--ok-soft); color: var(--ok); }
.log li.warn { background: var(--warn-soft); color: var(--warn); }
.log li.ask { background: var(--ask-soft); color: var(--ask); }
.log time { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); margin-right: 6px; }
.log a { font-size: 0.8rem; }
.question { border: 2px solid var(--ask); background: var(--ask-soft); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.question strong { color: var(--ask); }

/* Dialog (in-page; never native alert/confirm) */
.overlay { position: fixed; inset: 0; background: rgba(10, 8, 18, 0.5); display: grid; place-items: center; padding: 16px; z-index: 50; }
.dialog { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; width: 100%; max-width: 440px; display: flex; flex-direction: column; gap: 14px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.dialog .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-size: 0.9rem; z-index: 60; }

.center-card { max-width: 400px; margin: 10vh auto 0; padding: 0 16px; }
.blanks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.blanks figure { margin: 0; display: flex; flex-direction: column; gap: 6px; background: var(--surface-2); border-radius: 8px; padding: 6px; font-size: 0.75rem; word-break: break-all; }
.blanks img { width: 100%; aspect-ratio: 1; object-fit: contain; display: block; border-radius: 6px; background: var(--surface); }
code { font-family: var(--mono); font-size: 0.85em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
