:root {
  --ink: #1F2937;
  --muted: #526176;
  --line: #D0D5DD;
  --soft-line: #E7E9ED;
  --page: #F3F4F6;
  --panel: #FFFFFF;
  --portal-accent: var(--blue);
  --portal-accent-dark: var(--blue-dark);
  --portal-soft: var(--blue-soft);
  --success: #18864B;
  --danger: #B42318;
  --shadow: 0 16px 44px rgba(16, 24, 40, 0.10);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { min-width: 320px; margin: 0; font-family: Arial, Helvetica, sans-serif; background: var(--page); color: var(--ink); }
button, input, select { font: inherit; }
button, a, input, select { outline-offset: 3px; }

.site-header { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 20px 0; display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.brand, .back-link { text-decoration: none; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--portfolio-navy); font-weight: 700; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 8px; background: var(--portfolio-navy); color: var(--portfolio-ivory); font-size: 12px; letter-spacing: .06em; }
.back-link { color: var(--muted); font-size: 14px; }
.back-link:hover { color: var(--ink); }

main { width: min(1440px, calc(100% - 48px)); margin: 0 auto; padding: 54px 0 88px; }
.intro { max-width: 820px; margin-bottom: 42px; }
.eyebrow, .step-label { margin: 0; color: var(--portal-accent); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h1 { margin: 10px 0 16px; color: var(--portfolio-navy); font-size: clamp(48px, 7vw, 76px); line-height: 1; letter-spacing: -.045em; }
.intro-copy { max-width: 760px; margin: 0; color: #475467; font-size: 19px; line-height: 1.6; }
.privacy-note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

.automation-workspace { display: grid; gap: 28px; }
.input-panel, .portal-panel, .recording { border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
.input-panel { border-radius: 12px; overflow: hidden; }
.panel-heading { padding: 22px 24px; display: flex; align-items: center; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--soft-line); }
.panel-heading h2, .portal-progress h2, .recording h2 { margin: 5px 0 0; color: var(--portfolio-navy); font-size: 22px; }
.panel-heading p:last-child, .recording > div > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 14px; }

.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 1100px; border-collapse: collapse; }
th { padding: 10px 12px; border-bottom: 1px solid var(--line); background: #F8F9FA; color: #475467; font-size: 11px; letter-spacing: .04em; text-align: left; text-transform: uppercase; }
td { padding: 8px 6px; border-bottom: 1px solid var(--soft-line); }
td:first-child { width: 102px; padding-left: 12px; }
td:last-child { width: 42px; padding-right: 12px; }
td input { width: 100%; min-width: 118px; height: 38px; padding: 0 9px; border: 1px solid transparent; border-radius: 4px; background: transparent; color: var(--ink); }
td input:hover { border-color: var(--line); }
td input:focus { border-color: var(--portal-accent); box-shadow: 0 0 0 2px var(--blue-ring); }
.row-status { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
.row-status::before { width: 7px; height: 7px; border-radius: 50%; background: #98A2B3; content: ""; }
tr.processing .row-status { color: var(--portal-accent); }
tr.processing .row-status::before { background: var(--portal-accent); box-shadow: 0 0 0 4px var(--portal-soft); }
tr.complete .row-status { color: var(--success); }
tr.complete .row-status::before { background: var(--success); }
.remove-row { width: 30px; height: 30px; border: 0; border-radius: 5px; background: transparent; color: #98A2B3; cursor: pointer; font-size: 18px; }
.remove-row:hover { background: #FEF3F2; color: var(--danger); }

.input-actions { padding: 16px 24px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #F8F9FA; }
.input-actions p { margin: 0; color: var(--muted); font-size: 13px; }
.input-actions > div { display: flex; gap: 10px; }
.button { min-height: 40px; padding: 0 15px; border: 1px solid transparent; border-radius: 6px; cursor: pointer; font-weight: 700; }
.button:disabled { cursor: wait; opacity: .58; }
.button-primary { background: var(--portal-accent); color: white; }
.button-primary:hover:not(:disabled) { background: var(--portal-accent-dark); }
.button-secondary { border-color: var(--line); background: white; color: #344054; }
.button-secondary:hover:not(:disabled) { background: #F8F9FA; }

.portal-panel { overflow: hidden; border-radius: 4px; }
.portal-topbar { min-height: 64px; padding: 0 24px; display: flex; align-items: center; justify-content: space-between; background: #FFF; border-bottom: 4px solid var(--portal-accent); }
.portal-product { display: flex; align-items: center; gap: 12px; }
.portal-product div { display: grid; gap: 2px; }
.portal-product strong { color: #1D2939; font-size: 15px; }
.portal-product span:not(.portal-symbol) { color: var(--muted); font-size: 12px; }
.portal-symbol { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 3px; background: var(--portal-accent); color: white; font-size: 12px; font-weight: 700; }
.environment {
  padding: 4px 8px;
  border: 1px solid var(--blue-border);
  border-radius: 3px;
  background: var(--portal-soft);
  color: var(--portal-accent-dark);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .1em;
}
.portal-progress { padding: 20px 24px 14px; display: flex; align-items: end; justify-content: space-between; gap: 20px; background: #FAFAFA; }
.run-status { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; font-weight: 700; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #98A2B3; }
.status-dot.running { background: var(--portal-accent); box-shadow: 0 0 0 4px var(--portal-soft); }
.status-dot.complete { background: var(--success); }
.progress-track { height: 4px; background: #E4E7EC; }
.progress-fill { width: 0; height: 100%; background: var(--portal-accent); transition: width 180ms ease; }

#portal-form { padding: 12px 24px 0; background: white; }
fieldset { margin: 0; padding: 18px 0 22px; border: 0; border-bottom: 1px solid var(--soft-line); }
legend { padding: 0; color: #344054; font-size: 13px; font-weight: 700; }
.form-grid { margin-top: 14px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field-wide { grid-column: 1 / -1; }
label { display: block; margin-bottom: 5px; color: #475467; font-size: 11px; font-weight: 700; }
.field input, .field select, .attachment-display { width: 100%; height: 38px; padding: 0 10px; border: 1px solid #BFC5CE; border-radius: 3px; background: #F9FAFB; color: var(--ink); }
.field select { pointer-events: none; appearance: none; }
.field input { pointer-events: none; }
.attachment-display { display: flex; align-items: center; color: var(--muted); font-size: 12px; }
.automation-file { position: absolute; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; }
.field.active input,
.field.active select,
.field.active .attachment-display {
  border-color: var(--portal-accent);
  background: #FFF;
  box-shadow: 0 0 0 2px var(--blue-ring);
}
.field.complete input, .field.complete select, .field.complete .attachment-display { background: #FFF; }
.portal-footer { padding: 16px 0; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.portal-footer p { margin: 0; color: var(--muted); font-size: 12px; }
.portal-footer p.success { color: var(--success); font-weight: 700; }
.portal-submit { min-height: 38px; padding: 0 16px; border: 0; border-radius: 3px; background: var(--portal-accent); color: white; font-weight: 700; }
.portal-submit:not(.ready) {
  background: #64748B;
}
.results-panel { padding: 18px 24px 22px; border-top: 1px solid var(--soft-line); background: #F8F9FA; }
.results-panel h3 { margin: 0 0 10px; color: #344054; font-size: 13px; }
.results-panel ol { margin: 0; padding: 0; display: grid; gap: 6px; list-style: none; }
.results-panel li { color: var(--success); font-size: 12px; }
.results-panel .empty-result { color: var(--muted); }

.recording { margin-top: 28px; padding: 24px; display: grid; grid-template-columns: minmax(240px, .45fr) minmax(0, 1fr); align-items: center; gap: 30px; border-radius: 12px; }
.demo-video { display: block; width: 100%; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 6px; background: #111; }
footer { padding: 0 24px 40px; color: var(--muted); font-size: 12px; text-align: center; }
footer p { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

@media (max-width: 800px) {
  .site-header, main { width: min(100% - 28px, 1440px); }
  main { padding: 38px 0 64px; }
  .panel-heading, .input-actions, .portal-progress, .portal-footer { align-items: stretch; flex-direction: column; }
  .input-actions > div { display: grid; grid-template-columns: 1fr 1fr; }
  .three-columns, .form-grid { grid-template-columns: 1fr; }
  .recording { grid-template-columns: 1fr; padding: 18px; }
  .portal-topbar, .portal-progress, #portal-form, .results-panel { padding-left: 16px; padding-right: 16px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; } }
