:root {
  color-scheme: light;
  --background: hsl(0 0% 100%);
  --foreground: hsl(240 10% 3.9%);
  --card: hsl(0 0% 100%);
  --card-foreground: hsl(240 10% 3.9%);
  --primary: hsl(240 5.9% 10%);
  --primary-foreground: hsl(0 0% 98%);
  --secondary: hsl(240 4.8% 95.9%);
  --secondary-foreground: hsl(240 5.9% 10%);
  --muted: hsl(240 4.8% 95.9%);
  --muted-foreground: hsl(240 3.8% 46.1%);
  --accent: hsl(240 4.8% 95.9%);
  --accent-foreground: hsl(240 5.9% 10%);
  --border: hsl(240 5.9% 90%);
  --input: hsl(240 5.9% 90%);
  --ring: hsl(240 10% 3.9%);
  --ok: hsl(142 60% 30%);
  --bad: hsl(0 72% 45%);
  --live: hsl(212 90% 42%);
  --ok-bg: hsl(142 60% 96%);
  --bad-bg: hsl(0 80% 97%);
  --live-bg: hsl(212 90% 97%);
  --radius: .6rem;
  --radius-card: calc(var(--radius) + 4px);
  --shadow-xs: 0 1px 2px rgb(24 24 27 / .04);
  --shadow-card: 0 1px 2px rgb(24 24 27 / .04), 0 8px 24px rgb(24 24 27 / .055);
  --font-display: "DM Serif Display", ui-serif, Georgia, serif;
  --font-sans: "Space Grotesk", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "Roboto Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.dark {
  color-scheme: dark;
  --background: hsl(50 2% 9%);
  --foreground: hsl(0 0% 98%);
  --card: hsl(240 6% 11%);
  --card-foreground: hsl(0 0% 98%);
  --primary: hsl(0 0% 98%);
  --primary-foreground: hsl(240 5.9% 10%);
  --secondary: hsl(240 3.7% 15.9%);
  --secondary-foreground: hsl(0 0% 98%);
  --muted: hsl(240 3.7% 15.9%);
  --muted-foreground: hsl(240 5% 64.9%);
  --accent: hsl(240 3.7% 15.9%);
  --accent-foreground: hsl(0 0% 98%);
  --border: hsl(240 3.7% 20%);
  --input: hsl(240 3.7% 22%);
  --ring: hsl(240 4.9% 83.9%);
  --ok: hsl(142 55% 60%);
  --bad: hsl(0 75% 68%);
  --live: hsl(212 90% 68%);
  --ok-bg: hsl(142 30% 14%);
  --bad-bg: hsl(0 40% 15%);
  --live-bg: hsl(212 45% 15%);
  --shadow-card: 0 1px 2px rgb(0 0 0 / .25), 0 8px 24px rgb(0 0 0 / .22);
}

* { box-sizing: border-box; margin: 0; }
html { background: var(--background); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
body { min-height: 100dvh; background: var(--background); color: var(--foreground); font: 15px/1.5 var(--font-sans); }
button, input { color: inherit; font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid color-mix(in oklab, var(--ring) 18%, transparent); outline-offset: 2px; }

.page-shell { width: 100%; }
.masthead {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  height: 4.25rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--background) 94%, transparent);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: baseline; gap: .65rem; min-width: 0; color: inherit; text-decoration: none; }
.brand h1 { font: 400 1.55rem/1 var(--font-display); letter-spacing: .01em; }
.brand > span { color: var(--muted-foreground); font-size: .75rem; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: .65rem; }
.system-state { display: flex; align-items: center; gap: .42rem; color: var(--muted-foreground); font: 500 .72rem var(--font-mono); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.icon-btn { width: 2.1rem; height: 2.1rem; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--muted-foreground); }
.icon-btn:hover { background: var(--accent); color: var(--foreground); }

main { display: grid; gap: 1rem; width: min(1180px, 100%); margin: 0 auto; padding: 1.25rem; }
.intake-grid { display: grid; grid-template-columns: minmax(0, .82fr) minmax(360px, 1.18fr); gap: 1rem; align-items: stretch; }
.card { padding: 1rem 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--card); color: var(--card-foreground); box-shadow: var(--shadow-xs); }
.card.hero { box-shadow: var(--shadow-card); }
.eyebrow, .card-kicker { margin: 0; color: var(--muted-foreground); font-size: .68rem; font-weight: 600; letter-spacing: .11em; text-transform: uppercase; }
.intro h2, .card-heading h2, .section-heading h2, dialog h2 { margin: .18rem 0 .3rem; font-size: 1rem; letter-spacing: -.02em; }
.lede { max-width: 62ch; margin-top: .2rem; color: var(--muted-foreground); font-size: .84rem; }

.pipeline { display: grid; margin-top: 1rem; padding: 0; list-style: none; }
.pipeline li { position: relative; display: grid; grid-template-columns: 18px 1fr; gap: .65rem; min-height: 3.05rem; }
.pipeline li:not(:last-child)::after { position: absolute; top: 19px; bottom: 0; left: 8px; width: 1px; background: var(--border); content: ""; }
.stage-index { position: relative; z-index: 1; display: grid; place-items: center; width: 17px; height: 17px; overflow: hidden; border: 1px solid var(--border); border-radius: 50%; background: var(--background); color: transparent; font-size: 0; }
.stage-index::after { width: 5px; height: 5px; border-radius: 50%; background: var(--muted-foreground); content: ""; }
.pipeline strong { display: block; font-size: .82rem; }
.pipeline small { display: block; margin-top: .05rem; color: var(--muted-foreground); font-size: .72rem; }

.intake-card { display: grid; align-content: start; gap: .8rem; }
.card-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: .1rem; }
.file-stamp { padding: .22rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--secondary); color: var(--muted-foreground); font: 500 .69rem var(--font-mono); }
label { display: grid; gap: .32rem; }
label > span:first-child { color: var(--muted-foreground); font-size: .7rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
input:not([type="file"]) { width: 100%; height: 2.45rem; padding: 0 .7rem; border: 1px solid var(--input); border-radius: var(--radius); outline: 0; background: var(--background); }
input:not([type="file"]):focus { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 18%, transparent); }
input::placeholder { color: var(--muted-foreground); }
.file-field input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.file-drop { display: grid; place-items: center; min-height: 7.5rem; padding: 1.1rem; border: 1px dashed var(--input); border-radius: var(--radius-card); background: var(--secondary); text-align: center; transition: border-color .15s, background .15s; }
.file-drop strong { display: block; font-size: .9rem; text-transform: none; letter-spacing: 0; }
.file-drop small { display: block; margin-top: .25rem; color: var(--muted-foreground); font-size: .76rem; }
.file-field:hover .file-drop, .file-field input:focus + .file-drop { border-color: var(--ring); background: var(--accent); }
.primary-action { display: flex; align-items: center; justify-content: space-between; min-height: 2.4rem; margin-top: .1rem; padding: 0 .9rem; border: 1px solid var(--primary); border-radius: var(--radius); background: var(--primary); color: var(--primary-foreground); font-weight: 600; }
.primary-action:hover { opacity: .9; }
.form-message { min-height: 1.4em; color: var(--ok); font-size: .76rem; }
.form-message[data-error="true"] { color: var(--bad); }

.sessions-section { display: grid; gap: .8rem; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.quiet-action { height: 2.1rem; padding: 0 .75rem; border: 1px solid var(--border); border-radius: var(--radius); background: transparent; color: var(--muted-foreground); font-size: .78rem; font-weight: 500; }
.quiet-action:hover { background: var(--accent); color: var(--foreground); }
.sessions-list { display: grid; gap: .45rem; }
.session-row { display: grid; grid-template-columns: 1.25fr .8fr .65fr auto; gap: 1rem; align-items: center; padding: .65rem .7rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--background); }
.session-row:hover { background: var(--accent); }
.session-main strong, .session-main small { display: block; }
.session-main strong { font-size: .82rem; }
.session-main small, .session-time, .session-count { margin-top: .05rem; color: var(--muted-foreground); font: 400 .7rem/1.4 var(--font-mono); }
.status-pill { justify-self: start; padding: .22rem .55rem; border: 1px solid var(--border); border-radius: 999px; background: var(--secondary); color: var(--muted-foreground); font: 500 .69rem var(--font-mono); }
.status-pill[data-status="concluida"] { border-color: color-mix(in oklab, var(--ok) 30%, transparent); background: var(--ok-bg); color: var(--ok); }
.status-pill[data-status="falha"] { border-color: color-mix(in oklab, var(--bad) 30%, transparent); background: var(--bad-bg); color: var(--bad); }
.artifact-action { border: 0; background: transparent; color: var(--foreground); font-size: .76rem; font-weight: 600; }
.empty-state { padding: .7rem; color: var(--muted-foreground); font-size: .8rem; }

dialog { width: min(420px, calc(100% - 2rem)); padding: 1.1rem; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--card); color: var(--foreground); box-shadow: var(--shadow-card); }
dialog::backdrop { background: rgb(0 0 0 / .55); backdrop-filter: blur(4px); }
dialog form { display: grid; gap: .8rem; }
dialog p:not(.eyebrow) { color: var(--muted-foreground); font-size: .84rem; }

@media (max-width: 840px) {
  .intake-grid { grid-template-columns: 1fr; }
  .session-row { grid-template-columns: 1fr auto; }
  .session-time, .session-count { display: none; }
}
@media (max-width: 600px) {
  .masthead { padding: 0 .9rem; }
  .brand > span, .system-state { display: none; }
  main { padding: .85rem; }
  .card { padding: .9rem; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
