:root {
  color-scheme: dark;
  --bg: #0b1120;
  --panel: #111827;
  --panel-2: #1e293b;
  --border: #273449;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--muted);
}
.dot.live { background: var(--ok); }
.dot.err { background: var(--danger); }

.host-pill {
  font-family: var(--mono);
  font-size: 0.75rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  min-width: 0;
  overflow-wrap: anywhere;
}

.center-card {
  max-width: 480px;
  margin: 3rem auto;
  text-align: center;
}

.push-card {
  margin-bottom: 1rem;
}

.card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.sidebar,
.detail-pane {
  min-width: 0;
}

@media (max-width: 840px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
}

.section-head h2 {
  margin: 0;
  font-size: 0.95rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.request-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-width: 0;
}

.req-item {
  width: 100%;
  min-width: 0;
  overflow: hidden;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.7rem 0.85rem;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.req-item:hover { background: var(--panel-2); }
.req-item.active { border-color: var(--primary); background: #162238; }
.req-item.pending { border-left: 3px solid var(--warn); }

.req-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
  min-width: 0;
}

.req-cmd {
  flex: 1;
  min-width: 0;
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.req-meta {
  font-size: 0.78rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  display: inline-block;
  flex-shrink: 0;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  text-transform: uppercase;
}

.badge-pending { background: rgba(245, 158, 11, 0.2); color: #fbbf24; }
.badge-approved, .badge-running { background: rgba(59, 130, 246, 0.2); color: #60a5fa; }
.badge-completed { background: rgba(34, 197, 94, 0.2); color: #4ade80; }
.badge-rejected, .badge-failed, .badge-killed { background: rgba(239, 68, 68, 0.2); color: #f87171; }
.badge-expired, .badge-canceled { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }

.banner {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}
.banner.error { background: rgba(239, 68, 68, 0.16); border: 1px solid rgba(239, 68, 68, 0.45); color: #fecaca; }
.banner.ok { background: rgba(34, 197, 94, 0.16); border: 1px solid rgba(34, 197, 94, 0.45); color: #bbf7d0; }

.btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 0.5rem 0.9rem;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
  background: var(--panel-2);
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-sm { padding: 0.25rem 0.6rem; font-size: 0.78rem; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--panel-2); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { border-color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-ghost:hover:not(:disabled) { background: var(--panel-2); }

.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
  min-width: 0;
}

.detail-title {
  font-family: var(--mono);
  font-size: 1rem;
  margin: 0;
  min-width: 0;
  flex: 1;
  overflow-wrap: anywhere;
}

.kv-grid {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 0.45rem 0.8rem;
  font-size: 0.86rem;
  margin-bottom: 1rem;
}

.kv-grid > * {
  min-width: 0;
}

@media (max-width: 600px) {
  .kv-grid { grid-template-columns: minmax(0, 1fr); }
}

.kv-label { color: var(--muted); }
.kv-val {
  font-family: var(--mono);
  overflow-wrap: anywhere;
  word-break: break-word;
}

.cmd-preview {
  margin: 0.35rem 0 0.85rem;
  padding: 0.7rem 0.8rem;
  background: #060a13;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.83rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
  color: #e2e8f0;
}

.argv-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: #090e1a;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  margin: 0.35rem 0 1rem;
}

.argv-row {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr);
  gap: 0.5rem;
  align-items: baseline;
  font-family: var(--mono);
  font-size: 0.82rem;
  padding: 0.25rem 0.45rem;
  border-radius: 5px;
  background: var(--panel-2);
  border: 1px solid var(--border);
}

.argv-row.cmd {
  border-color: var(--primary);
}

.argv-idx {
  color: var(--muted);
  font-size: 0.74rem;
  text-align: right;
  user-select: none;
}

.argv-val {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: normal;
}

.argv-row.cmd .argv-val {
  color: #93c5fd;
  font-weight: 600;
}

.risk-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.risk-item {
  font-size: 0.84rem;
  padding: 0.5rem 0.75rem;
  border-radius: 7px;
  border: 1px solid transparent;
}
.risk-high { background: rgba(239, 68, 68, 0.14); border-color: rgba(239, 68, 68, 0.4); color: #fecaca; }
.risk-medium { background: rgba(245, 158, 11, 0.14); border-color: rgba(245, 158, 11, 0.4); color: #fde68a; }
.risk-info { background: rgba(59, 130, 246, 0.14); border-color: rgba(59, 130, 246, 0.35); color: #bfdbfe; }

.action-box {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  padding: 0.85rem;
  border-radius: 8px;
  background: #0d1526;
  border: 1px solid var(--border);
  margin-bottom: 1rem;
}

.reject-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input {
  flex: 1;
  min-width: 180px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.45rem 0.7rem;
  font-size: 0.86rem;
}

.terminal {
  background: #060a13;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  font-family: var(--mono);
  font-size: 0.8rem;
  max-height: 360px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.term-stderr { color: #fca5a5; }
.term-stdout { color: #e2e8f0; }

.muted { color: var(--muted); }
.small { font-size: 0.84rem; }
.tiny { font-size: 0.76rem; margin-top: 0.4rem; }
