:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #667085;
  --line: #d7dde6;
  --accent: #1f6f78;
  --accent-strong: #174e55;
  --warn: #a86100;
  --good: #1d6b3a;
  --shadow: 0 12px 30px rgba(24, 33, 47, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  min-height: 40px;
  padding: 0 16px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

.nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 6px;
  border: 1px solid var(--line);
  padding: 0 16px;
  background: #fff;
  color: var(--accent);
  text-decoration: none;
}

.nav-button:hover {
  background: #f4f8f8;
  color: var(--accent-strong);
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
}

input:disabled {
  background: #eef2f6;
  color: #667085;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.login-body {
  display: grid;
  place-items: center;
  background: #eef3f4;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 30px;
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  margin-bottom: 18px;
}

.login-panel h1,
.topbar h1,
.panel h2,
.stage-card h3 {
  margin: 0;
  letter-spacing: 0;
}

.login-panel p {
  color: var(--muted);
  margin: 8px 0 22px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.form-error {
  min-height: 20px;
  color: #b42318;
  font-size: 14px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 22px 28px;
  background: #fff;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 13px;
}

.topbar h1 {
  font-size: 24px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-email {
  color: var(--muted);
  font-size: 14px;
}

.ghost-button {
  background: #fff;
  color: var(--accent);
  border: 1px solid var(--line);
}

.ghost-button:hover {
  background: #f4f8f8;
  color: var(--accent-strong);
}

.workspace {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 40px;
  display: grid;
  gap: 18px;
}

.status-strip,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.status-strip > div {
  padding: 16px 18px;
  border-right: 1px solid var(--line);
}

.status-strip > div:last-child {
  border-right: 0;
}

.status-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 5px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.panel-heading h2 {
  font-size: 20px;
}

.panel-heading p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.api-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}

.settings-form {
  display: grid;
  gap: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.token-settings {
  display: grid;
  gap: 12px;
}

.token-settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 0;
  background: #fbfcfd;
}

.token-settings-card legend {
  padding: 0 6px;
  font-weight: 700;
}

.clear-token-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

.clear-token-label input {
  width: auto;
  min-height: auto;
}

.clear-token-label span {
  margin: 0;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.seller-state {
  color: var(--muted);
  line-height: 1.4;
}

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

.token-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

.token-table th,
.token-table td {
  border: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: top;
}

.token-table th {
  background: #f2f5f8;
  font-size: 13px;
  color: #344054;
}

.token-note,
.api-message {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
}

.badge.ok {
  background: #e8f5ee;
  color: var(--good);
}

.badge.warn {
  background: #fff3d8;
  color: var(--warn);
}

.badge.bad {
  background: #fde8e8;
  color: #b42318;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.stage-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.optional-stage {
  border-color: #e5cc9b;
  background: #fffaf1;
}

.stage-number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: #e6f1f2;
  color: var(--accent-strong);
  font-weight: 700;
  margin-bottom: 12px;
}

.stage-card h3 {
  font-size: 18px;
}

.stage-card p {
  min-height: 42px;
  margin: 8px 0 16px;
  color: var(--muted);
  line-height: 1.45;
}

.stage-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stage-controls button {
  grid-column: 1 / -1;
}

.inline-controls {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.inline-controls button {
  grid-column: auto;
}

.log-list {
  display: grid;
  gap: 8px;
}

.log-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfd;
}

.run-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.run-links a {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 9px;
  color: var(--accent);
  background: #fff;
  text-decoration: none;
  font-size: 13px;
}

.run-links a:hover {
  color: var(--accent-strong);
  background: #f4f8f8;
}

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

@media (max-width: 760px) {
  .topbar,
  .panel-heading {
    display: grid;
  }

  .status-strip,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .status-strip > div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .status-strip > div:last-child {
    border-bottom: 0;
  }

  .stage-controls,
  .inline-controls,
  .settings-grid {
    grid-template-columns: 1fr;
  }
}
