:root {
  --bg: #f7f7f5; --card: #ffffff; --text: #1d1d1b; --muted: #6b6b66; --line: #e3e2dd;
  --accent: #2f5bea; --ok: #1c8a4a; --warn: #b26b00; --bad: #c0362c;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141413; --card: #1e1e1c; --text: #ecebe6; --muted: #9b9a93; --line: #33322e;
    --accent: #7b9bff; --ok: #4cc27f; --warn: #e3a440; --bad: #ef6b60; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
a { color: var(--accent); }
main { max-width: 1280px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 8px 0 12px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: .95rem; margin: 14px 0 6px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--bad); }

.top { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.top .brand { font-weight: 700; color: var(--text); text-decoration: none; }
.top nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.top nav a { padding: 4px 10px; border-radius: 6px; text-decoration: none; color: var(--muted); }
.top nav a[aria-current] { background: var(--bg); color: var(--text); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 14px; min-width: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.lanes { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.columns { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; overflow-x: auto; }
.column { background: transparent; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; }
.stack label.choice { flex-direction: row; align-items: baseline; gap: 6px; }
.inline { display: inline; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 14px; }
.quick input[name=title], .quick input[name=name] { flex: 1; min-width: 200px; }

input, select, textarea, button, .button { font: inherit; color: inherit; }
input, select, textarea { background: var(--card); border: 1px solid var(--line); border-radius: 6px; padding: 7px 9px; }
textarea { width: 100%; resize: vertical; }
button, .button { background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 12px; cursor: pointer; text-decoration: none; display: inline-block; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.small { padding: 2px 8px; font-size: .85rem; }
button.link { background: none; border: none; color: var(--muted); padding: 4px; }

.flash { background: var(--card); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; }
.pill { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.proposed { border-color: var(--accent); color: var(--accent); }
.pill.applied { border-color: var(--ok); color: var(--ok); }
.pill.failed { border-color: var(--bad); color: var(--bad); }
.pill.running, .pill.queued { border-color: var(--warn); color: var(--warn); }

.status { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; border: 1px solid var(--line); background: var(--card); }
.status.up { border-left: 5px solid var(--ok); }
.status.down { border-left: 5px solid var(--bad); }
.status.paused { border-left: 5px solid var(--warn); }
.meters { display: flex; flex-wrap: wrap; gap: 16px; font-size: .9rem; }
meter { width: 90px; vertical-align: middle; }

.task { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; margin-bottom: 8px; }
.task.high { border-left: 4px solid var(--bad); }
.task.low { opacity: .85; }
.task p { margin: 2px 0 6px; }
.move { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }

.run { border-top: 1px solid var(--line); padding: 10px 0; }
.run header { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; }
.run .ask { margin: 6px 0; }
.output { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 10px; font: 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; max-height: 480px; overflow: auto; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.reply { display: flex; gap: 6px; flex: 1; min-width: 260px; }
.reply input { flex: 1; }

.stats { display: flex; flex-wrap: wrap; gap: 18px; margin: 0 0 14px; }
.stats div { min-width: 80px; }
.stats dt { color: var(--muted); font-size: .8rem; }
.stats dd { margin: 0; font-size: 1.3rem; font-weight: 600; }
.facts dt { color: var(--muted); font-size: .85rem; }
.facts dd { margin: 0 0 8px; }

table { width: 100%; border-collapse: collapse; background: var(--card); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.lane.off { opacity: .6; }
.login { max-width: 360px; margin: 18vh auto; text-align: center; }

@media (max-width: 720px) {
  .columns { grid-template-columns: 1fr; }
  .two { grid-template-columns: 1fr; }
  table { display: block; overflow-x: auto; }
  /* On a phone: the brand and sign-out share the first row, and the pages
     are one row under them that scrolls sideways, instead of a column that
     fills a third of the screen. */
  .top { gap: 6px 12px; padding: 8px 12px; }
  .top .brand { flex: 1; }
  .top nav { order: 3; flex: 0 0 100%; flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .top nav a { white-space: nowrap; padding: 10px 12px; }
  /* Thumb-sized targets, and 16px text in fields so iOS does not zoom the
     page in when one is tapped. */
  button, .button, input, select { min-height: 44px; }
  input, select, textarea { font-size: 16px; }
  button.small { min-height: 36px; }
  .quick input[name=title], .quick input[name=name] { min-width: 0; }
  .shot img { max-width: 100%; height: auto; }
  /* An agent choice reads as one sentence beside its radio, not three
     squeezed columns. */
  .stack label.choice { display: block; padding: 6px 0; }
  .stack label.choice input { margin-right: 8px; }
}
form + h2, form + h3 { margin-top: 18px; }
.shot { display: inline-block; margin: 6px 8px 0 0; }
.shot img { max-width: 260px; max-height: 180px; border: 1px solid var(--line); border-radius: 6px; display: block; }
.shot figcaption { font-size: .8rem; color: var(--muted); }
code.token { font: 13px ui-monospace, Menlo, monospace; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; overflow-wrap: anywhere; display: inline-block; }
