/* claude-pool admin. One warm-neutral world, one accent for action and selection,
   status colors reserved for state. Light and dark are both designed, not inverted. */

:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #ffffff;
  --surface-2: #faf9f6;
  --surface-3: #f0eee9;
  --ink: #1c1b19;
  --ink-2: #57554f;
  --ink-3: #85827a;
  --line: #e7e4dd;
  --line-2: #d8d4cb;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fbeee6;
  --ok: #15803d;
  --ok-soft: #e7f4ec;
  --warn: #a16207;
  --warn-soft: #fbf3dc;
  --bad: #b91c1c;
  --bad-soft: #fbeaea;
  --series: #2a78d6;
  --track: #ebe8e2;
  --shadow: 0 1px 2px rgb(28 27 25 / 0.06), 0 4px 16px rgb(28 27 25 / 0.06);
  --radius: 10px;
  --radius-sm: 6px;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1918;
    --surface-2: #1f1e1c;
    --surface-3: #262522;
    --ink: #eeece7;
    --ink-2: #b4b1a9;
    --ink-3: #8b887f;
    --line: #2c2a27;
    --line-2: #3a3834;
    --accent: #f08a4b;
    --accent-ink: #1a1208;
    --accent-soft: #3a2518;
    --ok: #4ade80;
    --ok-soft: #16301f;
    --warn: #fbbf24;
    --warn-soft: #33290f;
    --bad: #f87171;
    --bad-soft: #3a1c1c;
    --series: #3987e5;
    --track: #2b2a27;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 6px 20px rgb(0 0 0 / 0.35);
  }
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 var(--font);
  font-variant-numeric: tabular-nums;
}

::selection {
  background: var(--accent-soft);
  color: var(--ink);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

* {
  scrollbar-color: var(--line-2) transparent;
}

a {
  color: inherit;
  text-underline-offset: 3px;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.mono {
  font-family: var(--mono);
  font-size: 12px;
}

.muted {
  color: var(--ink-2);
}

.faint {
  color: var(--ink-3);
}

.small {
  font-size: 12px;
}

.hidden {
  display: none !important;
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 28px;
}

.brand {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-mark {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: var(--accent);
  display: grid;
  place-items: center;
  color: var(--accent-ink);
}

.tabs {
  display: flex;
  gap: 2px;
  height: 100%;
}

.tab {
  background: none;
  border: 0;
  padding: 0 12px;
  color: var(--ink-2);
  cursor: pointer;
  position: relative;
  height: 100%;
  font-weight: 500;
}

.tab:hover {
  color: var(--ink);
}

.tab[aria-selected='true'] {
  color: var(--ink);
}

.tab[aria-selected='true']::after {
  content: '';
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -1px;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
}

.tab .count {
  margin-left: 6px;
  color: var(--ink-3);
  font-weight: 400;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.pulse {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-3);
}

.pulse i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ok);
}

.pulse.stale i {
  background: var(--bad);
}

/* ---------- layout ---------- */

main {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px 24px 64px;
  display: grid;
  gap: 28px;
}

/* Grid items default to their content width; let wide tables scroll inside instead. */
main > section {
  min-width: 0;
}

.section-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
  min-height: 32px;
}

.section-head h2 {
  font-size: 15px;
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.005em;
}

.section-head .hint {
  color: var(--ink-3);
  font-size: 12px;
}

.section-head .spacer {
  flex: 1;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- summary strip ---------- */

.summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 36px;
  padding: 16px 20px;
  align-items: baseline;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.stat b {
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
}

.stat span {
  font-size: 12px;
  color: var(--ink-3);
}

.stat.accent b {
  color: var(--accent);
}

.stat .sub {
  font-size: 17px;
  color: var(--ink);
  font-weight: 650;
  letter-spacing: -0.01em;
}

/* ---------- attention ---------- */

.attention {
  display: grid;
  gap: 0;
}

.issue {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.issue:first-child {
  border-top: 0;
}

.issue .icon {
  flex: none;
}

.issue.bad .icon {
  color: var(--bad);
}

.issue.warn .icon {
  color: var(--warn);
}

.issue .text {
  flex: 1;
  min-width: 0;
}

.issue .text b {
  font-weight: 600;
}

/* ---------- controls ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  transition:
    background 150ms ease-out,
    border-color 150ms ease-out;
}

.btn:hover {
  background: var(--surface-3);
}

.btn:active {
  transform: translateY(0.5px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: default;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.primary:hover {
  background: color-mix(in srgb, var(--accent) 88%, black);
}

.btn.danger {
  color: var(--bad);
}

.btn.danger.armed {
  background: var(--bad);
  border-color: var(--bad);
  color: #fff;
}

.btn.ghost {
  border-color: transparent;
  background: none;
  color: var(--ink-2);
}

.btn.ghost:hover {
  background: var(--surface-3);
  color: var(--ink);
}

.btn.small {
  height: 26px;
  padding: 0 9px;
  font-size: 12px;
}

.btn.busy {
  opacity: 0.6;
  pointer-events: none;
}

.input,
.select {
  height: 30px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  min-width: 0;
}

.input::placeholder {
  color: var(--ink-3);
}

.input:hover,
.select:hover {
  border-color: var(--ink-3);
}

.input.wide {
  width: 360px;
  max-width: 100%;
}

.input.narrow {
  width: 84px;
}

.segmented {
  display: inline-flex;
  padding: 2px;
  border-radius: 8px;
  background: var(--surface-3);
  gap: 2px;
}

.segmented button {
  border: 0;
  background: none;
  height: 26px;
  padding: 0 10px;
  border-radius: 6px;
  color: var(--ink-2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
}

.segmented button[aria-pressed='true'] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.08);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.check {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  color: var(--ink-2);
  cursor: pointer;
}

.check input {
  accent-color: var(--accent);
}

/* ---------- pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  background: var(--surface-3);
  color: var(--ink-2);
}

.pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill.ok {
  background: var(--ok-soft);
  color: var(--ok);
}

.pill.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

.pill.bad {
  background: var(--bad-soft);
  color: var(--bad);
}

.pill.off {
  color: var(--ink-3);
}

.tag {
  display: inline-block;
  padding: 0 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 18px;
  background: var(--surface-3);
  color: var(--ink-2);
  vertical-align: 1px;
}

/* ---------- data table ---------- */

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.table tr:last-child > td {
  border-bottom: 0;
}

.table .num {
  text-align: right;
}

.table.rows tbody tr.row {
  cursor: pointer;
  transition: background 120ms ease-out;
}

.table.rows tbody tr.row:hover {
  background: var(--surface-2);
}

.table.rows tbody tr.row.open {
  background: var(--surface-2);
}

.table.rows tbody tr.row.open > td {
  border-bottom-color: transparent;
}

.table.dense td {
  padding: 7px 12px;
  font-size: 13px;
}

.table-wrap {
  overflow-x: auto;
}

.name {
  font-weight: 600;
}

.name-line {
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.chevron {
  color: var(--ink-3);
  transition: transform 180ms ease-out;
  display: inline-flex;
}

tr.open .chevron,
.open > .chevron,
.session.open .chevron {
  transform: rotate(90deg);
}

.detail > td {
  padding: 0 12px 16px !important;
  background: var(--surface-2);
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(320px, 1.4fr) minmax(260px, 1fr);
  gap: 24px;
  padding: 8px 4px 4px;
}

.detail-grid.two {
  grid-template-columns: minmax(320px, 1.5fr) minmax(260px, 1fr);
}

.detail-block h4 {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-3);
}

.detail-block + .detail-block {
  min-width: 0;
}

.detail-sessions {
  margin-top: 16px;
}

.kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
}

.kv dt {
  color: var(--ink-3);
}

.kv dd {
  margin: 0;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.inline-form {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.field-hint {
  font-size: 12px;
  color: var(--ink-3);
  margin-top: 6px;
  max-width: 44ch;
}

.error-text {
  color: var(--bad);
  font-size: 12px;
  margin-top: 8px;
  overflow-wrap: anywhere;
}

/* ---------- meters ---------- */

.meters {
  display: grid;
  gap: 6px;
  min-width: 150px;
}

.meter {
  display: grid;
  grid-template-columns: 34px 1fr 38px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.meter .label {
  color: var(--ink-3);
}

.meter .value {
  text-align: right;
  color: var(--ink-2);
}

.bar {
  height: 6px;
  border-radius: 3px;
  background: var(--track);
  overflow: hidden;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--ok);
  min-width: 2px;
}

.bar.warn > i {
  background: var(--warn);
}

.bar.bad > i {
  background: var(--bad);
}

.quota-window {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
}

.quota-window .top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.quota-window .bar {
  height: 8px;
  border-radius: 4px;
}

/* ---------- charts ---------- */

.spark {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  width: 96px;
  height: 22px;
}

.spark i {
  flex: 1;
  background: var(--series);
  border-radius: 1px 1px 0 0;
  min-height: 1px;
  opacity: 0.9;
}

.spark i.zero {
  background: var(--track);
}

.usage-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.usage-cell .total {
  min-width: 48px;
  text-align: right;
}

.chart {
  display: grid;
  gap: 6px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--ink-3);
}

.chart-head b {
  color: var(--ink);
  font-weight: 600;
}

.columns {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 96px;
  border-bottom: 1px solid var(--line-2);
}

.columns .col {
  flex: 1;
  display: flex;
  align-items: flex-end;
  cursor: default;
  min-width: 0;
}

.columns .col i {
  display: block;
  width: 100%;
  max-width: 18px;
  margin: 0 auto;
  background: var(--series);
  border-radius: 3px 3px 0 0;
  transition: opacity 120ms ease-out;
}

.columns .col:hover i,
.columns .col:focus-visible i {
  opacity: 0.7;
}

.columns .col:hover,
.columns .col:focus-visible {
  background: color-mix(in srgb, var(--series) 8%, transparent);
  border-radius: 3px;
}

.chart-axis {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--ink-3);
}

.chart-empty {
  height: 96px;
  display: grid;
  place-items: center;
  font-size: 12px;
  color: var(--ink-3);
  border: 1px dashed var(--line-2);
  border-radius: var(--radius-sm);
}

.tooltip {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12px;
  box-shadow: var(--shadow);
  max-width: 280px;
}

.tooltip b {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.tooltip .row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--ink-2);
}

/* ---------- sessions ---------- */

.sessions {
  display: grid;
}

.session {
  border-top: 1px solid var(--line);
}

.session:first-child {
  border-top: 0;
}

.session-row {
  display: grid;
  grid-template-columns: 14px minmax(160px, 220px) minmax(150px, 220px) 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 120ms ease-out;
}

.session-row:hover {
  background: var(--surface-2);
}

.session.open .session-row {
  background: var(--surface-2);
}

.state-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-3);
  justify-self: center;
}

.state-dot.running {
  background: var(--accent);
  animation: pulse 1.4s ease-in-out infinite;
}

.state-dot.queued {
  background: var(--warn);
}

.state-dot.tools {
  background: var(--series);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

@media (prefers-reduced-motion: reduce) {
  .state-dot.running {
    animation: none;
  }
  * {
    transition: none !important;
  }
}

.state-text {
  font-weight: 550;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.state-text.running {
  color: var(--accent);
}

.state-text.queued {
  color: var(--warn);
}

.who {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.who .arrow {
  color: var(--ink-3);
  margin: 0 4px;
}

.prompt {
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.session-detail {
  padding: 4px 16px 14px 44px;
  background: var(--surface-2);
  display: grid;
  gap: 10px;
}

.session-detail .full-prompt {
  color: var(--ink);
  overflow-wrap: anywhere;
}

.steps {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
}

.steps li {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.steps li::before {
  content: '›';
  color: var(--ink-3);
  margin-right: 8px;
}

.agents {
  display: grid;
  gap: 4px;
}

.agent {
  display: flex;
  gap: 10px;
  align-items: baseline;
  font-size: 12px;
  padding-left: 10px;
  border-left: 1px solid var(--line-2);
}

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--ink-3);
}

.empty b {
  display: block;
  color: var(--ink-2);
  font-weight: 600;
  margin-bottom: 4px;
}

/* ---------- add panels ---------- */

.add-panel {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: var(--radius) var(--radius) 0 0;
  display: grid;
  gap: 10px;
}

.add-panel .row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.secret-box {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-sm);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line));
  background: var(--accent-soft);
}

.secret-box pre {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ink);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 60;
  max-width: calc(100vw - 32px);
}

.toast.bad {
  background: var(--bad);
  color: #fff;
}

/* ---------- login ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  padding: 28px;
  display: grid;
  gap: 16px;
}

.login-card h1 {
  margin: 0;
  font-size: 18px;
  letter-spacing: -0.01em;
}

.login-card .input {
  height: 38px;
  width: 100%;
}

.login-card .btn {
  height: 38px;
  justify-content: center;
}

/* ---------- responsive ---------- */

@media (max-width: 1100px) {
  .detail-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 760px) {
  .topbar-inner {
    padding: 0 16px;
    gap: 12px;
  }
  .brand > span:not(.brand-mark) {
    display: none;
  }
  .pulse > span {
    display: none;
  }
  .section-head {
    flex-wrap: wrap;
  }
  .section-head .spacer {
    display: none;
  }
  .section-head .toolbar {
    width: 100%;
  }
  .section-head .toolbar .input {
    flex: 1;
  }
  .tab {
    padding: 0 8px;
  }
  main {
    padding: 16px 16px 48px;
  }
  .detail-grid {
    grid-template-columns: 1fr;
  }
  .session-row {
    grid-template-columns: 14px 1fr auto;
    row-gap: 4px;
  }
  .session-row .chevron {
    grid-row: 1;
    grid-column: 3;
  }
  .session-row .who,
  .session-row .prompt {
    grid-column: 2 / -1;
  }
  .detail-grid.two {
    grid-template-columns: 1fr;
  }
  .hide-sm {
    display: none;
  }
  .summary {
    gap: 12px 24px;
  }
}

@media (max-width: 420px) {
  .tab .count {
    display: none;
  }
  .topbar-right {
    gap: 8px;
  }
}
