:root {
  --bg: oklch(1 0 0);
  --surface: oklch(0.975 0.004 261.2);
  --surface-strong: oklch(0.94 0.009 261.2);
  --ink: oklch(0.18 0.018 261.2);
  --muted: oklch(0.43 0.018 261.2);
  --primary: oklch(0.476 0.207 261.2);
  --primary-hover: oklch(0.42 0.2 261.2);
  --accent: oklch(0.62 0.145 183);
  --success: oklch(0.54 0.14 148);
  --warning: oklch(0.72 0.145 76);
  --danger: oklch(0.58 0.19 28);
  --border: oklch(0.87 0.012 261.2);
  --console-bg: oklch(0.12 0 0);
  --console-ink: oklch(0.92 0.006 261.2);
  --focus: oklch(0.7 0.15 183);
  --radius: 8px;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, oklch(0.96 0.008 261.2), transparent 36%),
    var(--bg);
}

.login-panel {
  width: min(100%, 390px);
  display: grid;
  gap: 18px;
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.login-panel h1,
.brand-row h1,
.target-header h2,
.empty-state h2,
.history-head h2 {
  margin: 0;
  line-height: 1.16;
}

.login-panel h1 {
  font-size: 1.55rem;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--primary);
  font-size: 0.76rem;
  font-weight: 700;
}

label {
  display: grid;
  gap: 6px;
  color: var(--ink);
  font-weight: 600;
}

label span,
.label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 11px;
  font-family: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: oklch(0.48 0.014 261.2);
}

.primary-button,
.ghost-button,
.link-button {
  min-height: 38px;
  border-radius: var(--radius);
  border: 0;
  font-weight: 700;
}

.primary-button {
  padding: 0 16px;
  background: var(--primary);
  color: white;
}

.primary-button:hover {
  background: var(--primary-hover);
}

.ghost-button {
  padding: 0 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
}

.ghost-button:hover {
  background: var(--surface);
}

.download-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  text-decoration: none;
}

.link-button {
  min-height: 0;
  padding: 0;
  background: transparent;
  color: var(--primary);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  background: var(--surface);
}

.sidebar {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
  padding: 22px;
  border-right: 1px solid var(--border);
  background: var(--bg);
}

.brand-row,
.sidebar-meta,
.target-header,
.history-head,
.command-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand-row h1 {
  font-size: 1.35rem;
}

.sidebar-meta {
  min-height: 42px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.agent-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 8px;
}

.agent-button {
  width: 100%;
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--ink);
  text-align: left;
}

.agent-button:hover,
.agent-button.selected {
  border-color: var(--primary);
  background: oklch(0.97 0.016 261.2);
}

.agent-title-row,
.agent-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.agent-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 760;
}

.agent-meta-row {
  color: var(--muted);
  font-size: 0.84rem;
}

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 22px;
  gap: 18px;
}

.target-header {
  min-height: 82px;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.target-header h2 {
  font-size: 1.35rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: white;
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill.online {
  background: var(--success);
}

.status-pill.offline,
.status-pill.failed {
  background: var(--danger);
}

.status-pill.running,
.status-pill.queued {
  background: var(--accent);
}

.status-pill.neutral,
.status-pill.timed_out {
  background: var(--muted);
}

.status-pill.succeeded {
  background: var(--success);
}

.empty-state {
  display: grid;
  align-content: center;
  justify-items: start;
  min-height: 420px;
  max-width: 560px;
  padding: 20px;
}

.empty-state h2 {
  font-size: 1.55rem;
}

.empty-state p {
  margin: 8px 0 0;
  color: var(--muted);
}

.console-panel {
  min-width: 0;
  display: grid;
  gap: 18px;
}

.run-as-bar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--border);
}

.run-as-bar > div {
  min-width: 0;
  display: grid;
  gap: 3px;
  padding: 13px 14px;
  background: var(--bg);
}

.run-as-bar strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.command-form {
  display: grid;
  gap: 14px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.control-grid {
  display: grid;
  grid-template-columns: 170px minmax(220px, 1fr) 150px;
  gap: 12px;
}

.error-line {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-weight: 650;
}

.history-head {
  padding-top: 4px;
}

.command-history {
  display: grid;
  gap: 12px;
}

.command-card {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  overflow: hidden;
}

.command-card-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--border);
}

.command-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  font-size: 0.91rem;
  font-weight: 700;
}

.command-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.82rem;
}

.console-output {
  margin: 0;
  padding: 14px;
  overflow: auto;
  max-height: 520px;
  background: var(--console-bg);
  color: var(--console-ink);
  font-family: "Cascadia Code", "Consolas", "SFMono-Regular", monospace;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.empty-list {
  padding: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  background: var(--bg);
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }

  .agent-list {
    max-height: 290px;
  }

  .control-grid,
  .run-as-bar {
    grid-template-columns: 1fr;
  }

  .brand-row,
  .target-header,
  .history-head,
  .command-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .target-header {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .primary-button,
  .ghost-button,
  .agent-button {
    transition: background 150ms ease-out, border-color 150ms ease-out;
  }
}
