:root {
  --bg: #0f1115;
  --surface: #1a1d24;
  --border: #2a2f3a;
  --fg: #e6e6e6;
  --muted: #8b919a;
  --accent: #2a5ea8;
  --ok: #3d9970;
  --warn: #c9a227;
  --err: #b03a2e;
}

* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--fg);
  margin: 0;
  line-height: 1.5;
}

.layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 12px;
}

.sidebar h1 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0 0 20px 8px;
}

.nav-btn {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.875rem;
}

.nav-btn.active,
.nav-btn:hover {
  background: #252932;
  color: var(--fg);
}

.main {
  padding: 0 28px 24px;
  max-width: 1100px;
}

.main-header {
  position: sticky;
  top: 0;
  z-index: 90;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin: 0 -28px 12px;
  padding: 12px 28px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.wallet-bar-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.8125rem;
  min-width: 132px;
}

.wallet-bar-btn:hover {
  border-color: #4a5568;
}

.wallet-bar-btn.connected {
  border-color: #3d9970;
}

.wallet-bar-text {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  line-height: 1.25;
  text-align: right;
}

.wallet-bar-sub {
  font-size: 0.7rem;
  color: var(--muted);
}

.wallet-modal-panel {
  max-width: 420px;
}

.wallet-modal-desc {
  margin: 0 16px 12px;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.wallet-modal-list {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.wallet-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  cursor: pointer;
  font-size: 0.875rem;
}

.wallet-option.selected {
  border-color: var(--accent);
}

.wallet-option input {
  margin: 0;
}

.wallet-modal-error {
  min-height: 1.25rem;
  margin: 8px 16px 0;
  color: #f1948a;
  font-size: 0.8125rem;
}

.wallet-modal-actions {
  display: flex;
  gap: 8px;
  padding: 16px;
  margin-top: 8px;
}

button.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.view { display: none; }
.view.active { display: block; }

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.card h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.muted { color: var(--muted); font-size: 0.8rem; }

.status-pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 500;
}

.status-pill.ok { background: #1e3d2f; color: #7dcea0; }
.status-pill.warn { background: #3d3618; color: #f9e79f; }
.status-pill.err { background: #3d1e1e; color: #f1948a; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th { color: var(--muted); font-weight: 500; }

button.btn {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8125rem;
  margin-right: 8px;
  margin-top: 4px;
}

button.btn.secondary {
  background: #333842;
}

button.btn.danger {
  background: var(--err);
}

input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--fg);
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.8125rem;
  margin-right: 8px;
  margin-bottom: 8px;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.form-row label {
  min-width: 80px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.log-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  max-height: 200px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.step-list { list-style: none; padding: 0; margin: 0; }
.step-list li {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.step-list li.done { border-color: var(--ok); }
.step-list li.current { border-color: var(--accent); }

.mono { font-family: ui-monospace, monospace; font-size: 0.75rem; word-break: break-all; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.card-wide {
  width: 100%;
}

.card-scheduler {
  margin-top: 4px;
}

.table-relaxed th,
.table-relaxed td {
  padding: 10px 14px;
}

.table-relaxed td:nth-child(2),
.table-relaxed td:nth-child(3) {
  white-space: nowrap;
}

.table-relaxed td:last-child {
  max-width: 480px;
  word-break: break-word;
}

.pipeline-step {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 0.8125rem;
}

.pipeline-step.done { border-color: var(--ok); }

.blocker-list {
  margin: 4px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.8125rem;
}

button.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.deploy-form-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}

.deploy-form-main h2,
.deploy-form-log h2 {
  font-size: 0.95rem;
  margin: 0 0 12px;
  font-weight: 600;
}

.deploy-form-log {
  border-left: 1px solid var(--border);
  padding-left: 24px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.deploy-status {
  font-size: 0.8125rem;
  margin-bottom: 10px;
  padding: 10px 12px;
  background: var(--surface-2, #1a1d24);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: grid;
  gap: 6px;
}

.deploy-status-label {
  display: inline-block;
  width: 72px;
  color: var(--muted);
}

.deploy-status .mono {
  word-break: break-all;
}

.log-box-tall {
  flex: 1;
  min-height: 320px;
  max-height: 520px;
  font-size: 0.8125rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
#jobs-unified-detail:empty {
  display: none;
}

#jobs-unified-table tbody tr.active-row {
  background: #252932;
}

/* Token picker */
.token-picker-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 420px;
  min-height: 52px;
  padding: 8px 12px;
  background: var(--surface-2, #1a1d24);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.token-picker-trigger:hover {
  border-color: #4a5568;
}

.token-picker-selected {
  display: flex;
  align-items: center;
  gap: 12px;
}

.token-picker-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  line-height: 1.3;
}

.token-picker-text strong {
  font-size: 0.9375rem;
}

.token-picker-chevron {
  color: var(--muted);
  font-size: 0.75rem;
}

.token-logo,
.token-logo-fallback {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.token-logo-fallback {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #2d3748;
  color: #e2e8f0;
  font-weight: 600;
  font-size: 0.875rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal.hidden {
  display: none;
}

body.modal-open {
  overflow: hidden;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 520px;
  max-height: min(80vh, 640px);
  background: var(--surface, #12151a);
  border: 1px solid var(--border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 8px;
}

.modal-header h2 {
  margin: 0;
  font-size: 1rem;
}

.modal-search {
  margin: 0 16px 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}

.token-picker-list {
  overflow-y: auto;
  padding: 0 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.token-picker-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2, #1a1d24);
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.token-picker-item:hover {
  border-color: #4a5568;
}

.token-picker-item.selected {
  border-color: #63b3ed;
  background: #1e2936;
}

.token-picker-item .token-logo,
.token-picker-item .token-logo-fallback {
  width: 44px;
  height: 44px;
}

.token-picker-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.token-picker-item-title {
  font-weight: 600;
  font-size: 0.9375rem;
}

.token-picker-item-sub,
.token-picker-item-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--border); }
  .grid-2 { grid-template-columns: 1fr; }
  .deploy-form-layout { grid-template-columns: 1fr; }
  .deploy-form-log {
    border-left: none;
    padding-left: 0;
    padding-top: 16px;
    border-top: 1px solid var(--border);
  }
}
