:root {
  --bg-page: #f6f6f4;
  --bg-surface: #ffffff;
  --bg-inset: #ececea;
  --ink: #1f2328;
  --ink-subtle: #656d76;
  --line: #d9dbdf;
  --accent: #2f5fd0;
  --success: #1a7f4b;
  --error: #b42318;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg-page, #f6f6f4);
  color: var(--ink, #1f2328);
  font: 15px/1.5 var(--sans, system-ui, sans-serif);
}
a { color: var(--accent, #2f5fd0); }
h1, h2, h3 { margin: 0 0 8px; line-height: 1.25; }
h1, .page-title, .auth-title { font-size: 26px; font-weight: 650; }
h2, .section-title, .panel-title { font-size: 17px; font-weight: 600; }
p { margin: 0 0 8px; }
img { max-width: 100%; height: auto; display: block; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.context, .meta, .hint, .muted, .feed-when, .account-email, .run-activity-note, .input-help { color: var(--ink-subtle, #656d76); }
.context, .hint, .feed-when, .input-help, .run-activity-note { font-size: 13px; }
.strong { font-weight: 600; }
.empty { color: var(--ink-subtle, #656d76); font-style: italic; }
.linklike { background: none; border: 0; padding: 0; color: var(--accent, #2f5fd0); font: inherit; text-decoration: underline; cursor: pointer; }

.shell { width: 100%; max-width: 1080px; margin: 0 auto; padding: 0 24px; }
.page-app { max-width: 880px; padding: 32px 24px 64px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.actions, .entitlement-actions, .brand-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-action { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.masthead { margin-bottom: 24px; }
.home-grid { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; }
.home-side { display: flex; flex-direction: column; gap: 16px; }
.aside { color: var(--ink-subtle, #656d76); font-size: 13px; }
@media (max-width: 720px) { .home-grid { grid-template-columns: 1fr; } }

.nav { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 24px; border-bottom: 1px solid var(--line, #d9dbdf); }
.nav a.active { font-weight: 600; }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-weight: 650; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; background: var(--ink, #1f2328); color: #fff; font-size: 12px; font-weight: 700; }
.brand-mark-img { display: block; width: 28px; height: 28px; border-radius: 7px; object-fit: cover; }
.auth-wrap { max-width: 440px; padding-top: 64px; }
.auth-card { padding: 24px; }

.panel, .setup-connection, .conn-row, .attachment, .result-section { background: var(--bg-surface, #fff); border: 1px solid var(--line, #d9dbdf); border-radius: 10px; padding: 16px; }
.panel { margin-bottom: 16px; }
.panel.flush { padding: 0; overflow: hidden; }
.conn-row, .setup-connection { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.conn-row-credential { flex-direction: column; align-items: stretch; justify-content: flex-start; }
.setup-connection-status { font-size: 13px; color: var(--ink-subtle, #656d76); }
.plan-facts { display: flex; flex-wrap: wrap; gap: 16px; margin: 8px 0; font-size: 13px; }
.banner { padding: 10px 14px; border-radius: 8px; background: var(--bg-inset, #ececea); margin-bottom: 16px; }
.banner.warning { background: #fdf3dc; }
.banner.success { background: #e3f4ea; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 9px; border-radius: 999px; background: var(--bg-inset, #ececea); font-size: 12px; font-weight: 600; }
.chip.success { background: #e3f4ea; color: var(--success, #1a7f4b); }
.chip.pending, .chip.warning { background: #fdf3dc; }
.chip.live { color: var(--accent, #2f5fd0); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent, #2f5fd0); display: inline-block; }

.button, .run-submit, .setup-submit, .entitlement-run, .entitlement-configure, .entitlement-billing, .setup-connect {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 14px;
  border: 1px solid var(--accent, #2f5fd0); border-radius: 7px; background: var(--accent, #2f5fd0); color: #fff;
  font: 600 14px/1 var(--sans, system-ui, sans-serif); text-decoration: none; cursor: pointer;
}
.button.outline, .entitlement-configure, .entitlement-billing, .setup-connect { background: transparent; color: var(--ink, #1f2328); border-color: var(--line, #d9dbdf); }
.button.compact { min-height: 30px; padding: 0 10px; font-size: 13px; }
.button.large { min-height: 42px; width: 100%; }
.button:disabled { opacity: 0.5; cursor: default; }
.setup-form, .config-form, .run-form { display: flex; flex-direction: column; gap: 14px; }
.form-section { display: flex; flex-direction: column; gap: 12px; }
.form-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 8px; }
.input-field { display: flex; flex-direction: column; gap: 6px; }
.input-field label { font-size: 13px; font-weight: 600; }
.input-field input, .input-field select, .input-field textarea, .auth-card input {
  width: 100%; min-height: 38px; padding: 8px 10px; border: 1px solid var(--line, #d9dbdf); border-radius: 7px;
  background: var(--bg-surface, #fff); color: inherit; font: inherit;
}
.input-check { display: flex; align-items: center; gap: 8px; }
.input-check input { width: 16px; height: 16px; }

.setup-steps { display: grid; gap: 0; margin: 12px 0 0; padding: 0; list-style: none; counter-reset: step; }
.setup-step { display: grid; grid-template-columns: 28px 1fr; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line, #d9dbdf); }
.setup-step-mark { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--line, #d9dbdf); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; }
.setup-step.done .setup-step-mark { background: var(--success, #1a7f4b); border-color: var(--success, #1a7f4b); color: #fff; }
.setup-step.current .setup-step-mark { border-color: var(--accent, #2f5fd0); color: var(--accent, #2f5fd0); }
.setup-step-head { font-weight: 600; }
.setup-step-body { color: var(--ink-subtle, #656d76); font-size: 13px; }

.run-summary { margin-bottom: 16px; }
.run-live { color: var(--accent, #2f5fd0); font-weight: 600; }
.run-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.run-thread-item { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: start; }
.run-thread-item .run-activity-icon { display: inline-flex; align-items: center; gap: 4px; width: 40px; height: 18px; color: var(--ink-subtle, #656d76); background: transparent; }
.run-thread-item .run-activity-icon .icon { flex: none; width: 18px; height: 18px; }
.run-activity-state { display: inline-block; flex: none; position: relative; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--line, #d9dbdf); }
.is-done .run-activity-state { border-color: var(--success, #1a7f4b); }
.is-done .run-activity-state::after { content: ""; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px; border: solid var(--success, #1a7f4b); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.is-running .run-activity-state { border-color: var(--accent, #2f5fd0); border-top-color: transparent; }
.is-failed .run-activity-state { border-color: var(--error, #b42318); }
.run-thread-item.pending { color: var(--ink-subtle, #656d76); }

.result-output { line-height: 1.6; }
.result-output img, .result-attachments img { max-width: 100%; }
.result-section { margin-bottom: 16px; }
.result-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.result-metrics .large { font-size: 24px; font-weight: 650; }
.result-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.result-table th, .result-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line, #d9dbdf); }
.result-attachments { display: flex; flex-direction: column; gap: 8px; }
.result-permalink { font-size: 13px; }
.result-activity { list-style: none; margin: 0; padding: 0; }
.result-activity li { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.result-activity li .icon { width: 14px; height: 14px; }
.result-activity li.is-running .icon { color: var(--accent, #2f5fd0); }
.dataset-pagination { display: flex; gap: 12px; justify-content: flex-end; font-size: 13px; }

.modal { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; z-index: 10; }
.modal:target { display: flex; }
.modal-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 0.35); }
.modal-card { position: relative; width: min(520px, calc(100% - 32px)); max-height: 90vh; overflow: auto; padding: 20px; border-radius: 12px; background: var(--bg-surface, #fff); }
.modal-title { margin-bottom: 12px; }
.modal-close { position: absolute; top: 12px; right: 12px; color: var(--ink-subtle, #656d76); text-decoration: none; font-size: 18px; }
