:root {
  color-scheme: light;
  --ink: #101820;
  --muted: #667085;
  --line: #d9e1e5;
  --surface: #ffffff;
  --canvas: #f4f7f5;
  --teal: #2ec4b6;
  --teal-dark: #127b71;
  --coral: #f45d48;
  --amber: #ffb703;
  --ok: #1f8a5f;
  --bad: #b42318;
  --shadow: 0 12px 30px rgba(16, 24, 32, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 84px;
  padding: 16px clamp(18px, 4vw, 44px);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.brand-mark {
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
}

.brand h1 {
  margin: 0;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.05;
  letter-spacing: 0;
}

.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.ghost-link,
button {
  min-height: 40px;
  border-radius: 8px;
  border: 1px solid var(--line);
  cursor: pointer;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: var(--ink);
  text-decoration: none;
  background: #f9fbfb;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(420px, 1fr);
  grid-template-areas:
    "control jobs"
    "detail detail";
  gap: 18px;
  padding: 18px clamp(18px, 4vw, 44px) 44px;
}

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

.control-panel {
  grid-area: control;
}

.jobs-panel {
  grid-area: jobs;
}

.detail-panel {
  grid-area: detail;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.panel-heading h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(46, 196, 182, 0.14);
  color: var(--teal-dark);
  font-weight: 700;
  font-size: 12px;
}

.pill.muted {
  background: #eef2f4;
  color: var(--muted);
}

.pill.failed {
  background: rgba(244, 93, 72, 0.14);
  color: var(--bad);
}

.pill.running {
  background: rgba(255, 183, 3, 0.18);
  color: #8a5f00;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 18px;
}

label {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label span,
.field-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
  color: var(--ink);
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus,
.ghost-link:focus {
  outline: 3px solid rgba(46, 196, 182, 0.22);
  outline-offset: 2px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding-top: 21px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  min-height: 18px;
  accent-color: var(--teal-dark);
}

.form-actions,
.detail-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.form-actions {
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.copy-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 104px;
  padding: 0 16px;
  font-weight: 800;
}

.primary-button {
  color: #ffffff;
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.secondary-button,
.copy-button {
  color: var(--ink);
  background: #fbfcfc;
}

.message {
  min-height: 24px;
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.message.error {
  color: var(--bad);
}

.setup-status {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 18px 18px;
}

.setup-status > div {
  display: grid;
  gap: 4px;
  min-height: 64px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.setup-status span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.setup-status strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}

.setup-status .ready {
  color: var(--ok);
}

.setup-status .missing {
  color: var(--bad);
}

.paperclip-box {
  display: grid;
  gap: 10px;
  padding: 0 18px 18px;
}

.paperclip-box > div {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfc;
}

.paperclip-box span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.paperclip-box strong {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

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

table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
}

th,
td {
  height: 52px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 14px;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.selected {
  background: #eef9f8;
}

.job-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  font-size: 12px;
}

.detail-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) 1fr 1fr;
  gap: 16px;
  padding: 18px;
}

.detail-grid > div {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.detail-grid strong,
.copy-button {
  min-height: 42px;
  justify-content: flex-start;
  overflow-wrap: anywhere;
}

.detail-actions {
  padding: 0 18px 18px;
}

.results {
  display: grid;
  gap: 12px;
  padding: 0 18px 18px;
}

.product-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfc;
}

.product-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
  letter-spacing: 0;
}

.score-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.score-line span {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #eef2f4;
  font-size: 12px;
  font-weight: 700;
}

.script-text {
  margin: 8px 0 0;
  padding: 10px 12px;
  border-left: 4px solid var(--coral);
  background: #ffffff;
  color: #26343d;
}

.warning-card {
  border-color: rgba(255, 183, 3, 0.65);
  background: #fffaf0;
}

.warning-card .script-text {
  border-left-color: var(--amber);
}

.code-line {
  margin: 8px 0 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.oauth-box {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.inline-link {
  width: fit-content;
  min-width: 0;
  color: var(--ink);
  text-decoration: none;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin: 12px 0;
}

.asset-card {
  display: grid;
  gap: 8px;
  min-height: 120px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
}

.asset-card img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border-radius: 6px;
  background: #eef2f4;
}

.asset-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  overflow-wrap: anywhere;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace {
    grid-template-columns: 1fr;
    grid-template-areas:
      "control"
      "jobs"
      "detail";
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }
}

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

  .toggle-row {
    padding-top: 0;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
