/* Site na Conversa · Produção. System fonts only; colours from the painel. No inline styles anywhere (CSP). */
:root {
  --brick: #8b3528; --brick-dark: #752b20; --honey: #f3c66a; --cream: #fff6e9; --paper: #fffcf7; --wash: #f5efe7;
  --ink: #2d2926; --muted: #665d55; --line: #e0d5c8; --focus: #244a58; --link: #8b3528;
  --ok-ink: #2f5a4a; --ok-bg: #e3efe8; --warn-ink: #5c4300; --warn-bg: #fff1cc; --bad-ink: #8b3528; --bad-bg: #fbe6e0;
  --info-ink: #244a58; --info-bg: #e5eef1; --neutral-bg: #efe8df;
  --radius: 10px; --gutter: 16px;
  color-scheme: light dark;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--cream);
}
@media (prefers-color-scheme: dark) {
  :root {
    --cream: #1c1917; --paper: #25211e; --wash: #2e2925; --ink: #f3ece4; --muted: #c2b6aa; --line: #463f39;
    --focus: #f3c66a; --link: #f5c97a; --brick: #a8473a; --brick-dark: #8f3a2e;
    --ok-ink: #b5e2cb; --ok-bg: #1f3a2f; --warn-ink: #ffe3a3; --warn-bg: #45360f; --bad-ink: #ffc4b5; --bad-bg: #4a2219;
    --info-ink: #bfdbe6; --info-bg: #1d3640; --neutral-bg: #36302b;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100dvh; background: var(--cream); color: var(--ink); }
h1, h2, h3, h4, h5, h6, p { margin: 0; }
h1 { font-size: 1.4rem; line-height: 1.2; }
h2 { font-size: 1.3rem; line-height: 1.25; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }
h5, h6 { font-size: .95rem; }
a { color: var(--link); }
button, input, textarea, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.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; }
.skip-link { position: absolute; left: 8px; top: -60px; z-index: 50; padding: 10px 14px; background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); }
.skip-link:focus { top: 8px; }
.muted { color: var(--muted); }
.mono, .file-name { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-size: .9em; overflow-wrap: anywhere; }
.noscript { padding: 24px var(--gutter); }

/* buttons */
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 16px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); font-weight: 600;
  text-decoration: none; cursor: pointer; touch-action: manipulation; text-align: center; }
.button:hover { border-color: var(--muted); }
.button.primary { background: var(--brick); border-color: var(--brick); color: #fff6e9; }
.button.primary:hover { background: var(--brick-dark); }
.button.quiet { background: transparent; }
.button.danger { background: var(--bad-bg); border-color: var(--bad-ink); color: var(--bad-ink); }
.button:disabled { cursor: not-allowed; background: var(--wash); border-style: dashed; border-color: var(--line); color: var(--muted); }
.button[aria-busy="true"]::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
@keyframes spin { to { transform: rotate(360deg); } }

/* notices */
.notice { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); overflow-wrap: anywhere; }
.notice.error { background: var(--bad-bg); border-color: var(--bad-ink); color: var(--bad-ink); }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-ink); color: var(--warn-ink); }
.notice.ok { background: var(--ok-bg); border-color: var(--ok-ink); color: var(--ok-ink); }
.banner { margin: 0; padding: 10px var(--gutter); background: var(--bad-bg); color: var(--bad-ink); border-bottom: 1px solid var(--bad-ink); }

/* opening and signed out */
.opening { min-height: 60dvh; display: grid; place-content: center; gap: 12px; padding: var(--gutter); text-align: center; }
.signed-out { min-height: 100dvh; display: grid; place-items: center; padding: var(--gutter); }
.signed-out-card { display: flex; flex-direction: column; align-items: center; gap: 18px; text-align: center; max-width: 420px; }

/* header */
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; padding: 10px var(--gutter); background: var(--paper); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; flex: 1 1 100%; }
.status { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 auto; }
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 4px 10px; border-radius: 999px; background: var(--wash); font-size: .9rem; }
.pill .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.pill.on { background: var(--ok-bg); color: var(--ok-ink); }
.pill.on .dot { background: var(--ok-ink); }
.pill.off { background: var(--warn-bg); color: var(--warn-ink); }
.pill.off .dot { background: transparent; border: 2px solid var(--warn-ink); }
.pill.never .dot { background: transparent; border: 2px dashed var(--muted); }
.pill.alert { background: var(--bad-bg); color: var(--bad-ink); }
.top-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.switch { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px 6px 8px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); cursor: pointer; }
.switch-track { position: relative; width: 40px; height: 24px; border-radius: 999px; background: var(--neutral-bg); border: 1px solid var(--muted); flex-shrink: 0; }
.switch-thumb { position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch[aria-checked="true"] .switch-track { background: var(--brick); border-color: var(--brick); }
.switch[aria-checked="true"] .switch-thumb { transform: translateX(16px); background: #fff6e9; }
.switch-label { font-weight: 600; }
.switch:disabled { cursor: not-allowed; opacity: .7; }
.confirm { flex: 1 1 100%; display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--warn-ink); border-radius: var(--radius); background: var(--warn-bg); color: var(--ink); }
.confirm .button { flex: 1 1 140px; }
.topbar > .notice { flex: 1 1 100%; }

/* layout */
.layout { padding: var(--gutter); display: block; outline: none; }
.list-pane, .card-pane { min-width: 0; }
.app.card-open .list-pane { display: none; }
.section-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }

/* the list */
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.card-row { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; width: 100%; min-height: 64px; padding: 12px; text-align: left;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); cursor: pointer; }
.card-row:hover { border-color: var(--muted); }
.card-row[aria-current="true"] { border-color: var(--brick); box-shadow: inset 4px 0 0 var(--brick); }
.row-code { font-weight: 700; font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; }
.row-code.none { font-weight: 400; color: var(--muted); font-family: inherit; font-size: .9rem; }
.row-name { font-weight: 600; overflow-wrap: anywhere; }
.row-stage { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: .92rem; }
.stage { font-weight: 600; }
.stage.none { font-weight: 400; color: var(--muted); }
.clock-badge { padding: 1px 8px; border-radius: 999px; font-size: .82rem; font-weight: 700; white-space: nowrap; }
.clock-badge.ok { background: var(--ok-bg); color: var(--ok-ink); }
.clock-badge.late { background: var(--bad-bg); color: var(--bad-ink); }
.row-job { grid-column: 1 / -1; color: var(--muted); font-size: .92rem; }
.row-cost { grid-column: 1 / -1; font-size: .92rem; }

/* chips and badges */
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .85rem; font-weight: 600; background: var(--neutral-bg); color: var(--ink); white-space: nowrap; }
.st { font-weight: 600; }
.st.s-queued { color: var(--ink); }
.chip.s-queued { background: var(--neutral-bg); }
.chip.s-running { background: var(--info-bg); color: var(--info-ink); }
.chip.s-waiting { background: var(--honey); color: #2d2926; }
.chip.s-done { background: var(--ok-bg); color: var(--ok-ink); }
.chip.s-failed { background: var(--bad-bg); color: var(--bad-ink); }
.chip.s-cancelled, .chip.s-other { background: var(--neutral-bg); color: var(--muted); }
.row-job .s-running { color: var(--info-ink); }
.row-job .s-waiting, .row-job .s-failed { color: var(--bad-ink); }
.row-job .s-done { color: var(--ok-ink); }
.badge-paid { padding: 1px 7px; border-radius: 5px; background: var(--honey); color: #2d2926; font-size: .8rem; font-weight: 700; }
.button:disabled .badge-paid { background: var(--neutral-bg); color: var(--muted); }
.verdict { display: inline-block; padding: 2px 8px; border-radius: 6px; font-weight: 700; font-size: .85rem; white-space: nowrap; }
.verdict.v-apoia { background: var(--ok-bg); color: var(--ok-ink); }
.verdict.v-nao_menciona { background: var(--neutral-bg); color: var(--ink); }
.verdict.v-contradiz { background: var(--bad-bg); color: var(--bad-ink); }
.flag { display: inline-block; margin-top: 4px; padding: 1px 7px; border-radius: 5px; font-size: .82rem; font-weight: 600; background: var(--warn-bg); color: var(--warn-ink); border: 1px solid var(--warn-ink); }
.flags { display: flex; flex-wrap: wrap; gap: 6px; }

/* the card */
.card-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 14px; }
.card-top h2 { flex: 1 1 200px; overflow-wrap: anywhere; outline: none; }
.code-chip { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-weight: 700; padding: 3px 10px; border-radius: 6px; background: var(--neutral-bg); }
.code-chip.none { font-family: inherit; font-weight: 400; color: var(--muted); }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.job-actions { display: flex; flex-direction: column; gap: 12px; }
.job-action { display: flex; flex-direction: column; gap: 4px; }
.job-action .button { width: 100%; }
.reason { font-size: .9rem; color: var(--muted); }
.tool-out { display: flex; flex-direction: column; gap: 8px; }
.tool-out textarea { width: 100%; min-height: 160px; }

/* jobs */
.jobs { display: flex; flex-direction: column; gap: 12px; }
.job { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.job.s-waiting { border-color: var(--warn-ink); }
.job-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.job-meta { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.code-note { font-size: .85em; }
.events { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.event { display: grid; grid-template-columns: auto 1fr; gap: 0 10px; padding: 6px 8px; border-radius: 6px; min-width: 0; }
.event-time { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.event-kind { font-weight: 700; font-size: .85rem; }
.event-text, .event > .answer { grid-column: 1 / -1; white-space: pre-wrap; overflow-wrap: anywhere; }
.event.k-warning { background: var(--warn-bg); color: var(--warn-ink); }
.event.k-question { background: var(--warn-bg); border: 2px solid var(--warn-ink); padding: 10px; }
.event.k-answer { background: var(--info-bg); color: var(--info-ink); margin-left: 12px; }
.event.k-cost { color: var(--muted); }
.answer { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; white-space: normal; }
.answer label { font-weight: 600; }

/* results */
.result { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.alternative { border: 1px dashed var(--muted); border-radius: var(--radius); padding: 10px; display: flex; flex-direction: column; gap: 10px; }
.kv { display: grid; grid-template-columns: minmax(0, max-content) minmax(0, 1fr); gap: 4px 12px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.plain { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }
.file-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.file-list li { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; padding: 6px 0; border-bottom: 1px solid var(--line); }
.file-meta { color: var(--muted); font-size: .9rem; }
.table-wrap { overflow-x: auto; }
table.lines { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.lines th, table.lines td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
table.lines thead th { color: var(--muted); font-weight: 600; }
table.lines q { quotes: "«" "»"; }

/* the timeline and its clocks */
.clocks { display: flex; flex-direction: column; gap: 6px; }
.clock { padding: 8px 10px; border-radius: 8px; border-left: 4px solid var(--line); background: var(--wash); font-weight: 600; overflow-wrap: anywhere; }
.clock.ok { background: var(--ok-bg); color: var(--ok-ink); border-left-color: var(--ok-ink); }
.clock.late { background: var(--bad-bg); color: var(--bad-ink); border-left-color: var(--bad-ink); }
.clock.running { background: var(--info-bg); color: var(--info-ink); border-left-color: var(--info-ink); }
.clock.idle { color: var(--muted); font-weight: 400; }
.marks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.mark { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 12px; min-width: 0; }
.mark > .button { width: 100%; justify-content: flex-start; }
.mark.set { padding: 4px 4px 4px 12px; border: 1px solid var(--line); border-left: 4px solid var(--ok-ink); border-radius: 8px; }
.mark-label { font-weight: 600; }
.mark-time { font-variant-numeric: tabular-nums; }
.mark-tools { display: flex; flex-wrap: wrap; margin-left: auto; }
.link-button { min-height: 44px; min-width: 44px; padding: 0 8px; border: 0; background: none; color: var(--link); text-decoration: underline; cursor: pointer; }
.mark-edit { flex: 1 1 100%; display: flex; flex-direction: column; gap: 6px; padding: 6px 8px 8px 0; }
.mark-edit label { font-weight: 600; }
.delivery-info { display: flex; flex-direction: column; gap: 4px; overflow-wrap: anywhere; }

/* «Ajustes» */
.settings { margin-top: 18px; padding-top: 6px; border-top: 1px solid var(--line); }
.settings > summary { min-height: 44px; padding: 10px 0; cursor: pointer; font-weight: 600; }
.settings-form { display: flex; flex-direction: column; gap: 8px; padding-bottom: 8px; }
.settings-form label { font-weight: 600; }
.prefixed { display: flex; align-items: center; gap: 6px; }
.prefix { font-family: ui-monospace, "Cascadia Mono", Consolas, Menlo, monospace; font-weight: 700; }
.settings-form .prefixed input { width: 7em; }

/* costs */
.cost-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.cost-row { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.cost-amount { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.cost-detail { grid-column: 1 / -1; color: var(--muted); font-size: .88rem; overflow-wrap: anywhere; }

/* the card form */
details.form-box > summary { min-height: 44px; padding: 10px 0; cursor: pointer; list-style-position: inside; }
details.form-box > summary h3 { display: inline; }
.card-form { display: flex; flex-direction: column; gap: 16px; margin-top: 8px; }
.card-form fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.card-form legend { font-weight: 700; font-size: 1.05rem; padding: 0; margin-bottom: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field label { font-weight: 600; }
.field .req { font-weight: 400; color: var(--muted); }
.field input, .field textarea, .answer textarea, .confirm input, .tool-out textarea, .mark-edit input, .prefixed input {
  width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--muted); border-radius: 8px; background: var(--paper); color: var(--ink); font-size: 16px; }
.field textarea { min-height: 88px; resize: vertical; }
.field textarea.large { min-height: 260px; }
.hint { font-size: .9rem; color: var(--muted); overflow-wrap: anywhere; }
.warn { font-size: .9rem; color: var(--warn-ink); background: var(--warn-bg); border-left: 4px solid var(--warn-ink); padding: 6px 10px; border-radius: 4px; }
.form-actions { display: flex; flex-direction: column; gap: 10px; position: sticky; bottom: 0; padding: 10px 0; background: var(--paper); border-top: 1px solid var(--line); }
.form-actions .button { width: 100%; }

/* toast */
.toast { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  width: min(480px, calc(100vw - 32px)); padding: 12px 16px; border-radius: var(--radius); background: var(--ink); color: var(--cream);
  pointer-events: none; /* it may sit over a button on a phone: taps go through (review T3-9) */ }
/* an empty toast stays in the accessibility tree (a live region), only out of sight */
.toast:empty { width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); }

/* phones: tables become stacked rows */
@media (max-width: 599px) {
  table.lines thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.lines, table.lines tbody, table.lines tr, table.lines th, table.lines td { display: block; width: 100%; }
  table.lines tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; padding: 4px 0; }
  table.lines th, table.lines td { border-bottom: 0; padding: 4px 10px; }
  table.lines [data-label]::before { content: attr(data-label); display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
  .kv { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .kv dd { margin-bottom: 6px; }
}

/* wider screens */
@media (min-width: 600px) {
  .brand { flex: 0 1 auto; }
  .job-actions { flex-direction: row; flex-wrap: wrap; }
  .job-action { flex: 1 1 200px; }
  .form-actions { flex-direction: row; align-items: center; }
  .form-actions .button { width: auto; }
  .card-row { grid-template-columns: 5.5em minmax(0, 1fr) auto; align-items: center; }
  .row-stage, .row-job { grid-column: 2; }
  .row-cost { grid-column: 3; grid-row: 1 / span 2; text-align: right; }
}
@media (min-width: 960px) {
  :root { --gutter: 24px; }
  .layout { display: grid; grid-template-columns: minmax(300px, 380px) minmax(0, 1fr); gap: 24px; align-items: start; }
  .app.card-open .list-pane { display: block; }
  .list-pane { position: sticky; top: 16px; max-height: calc(100dvh - 32px); overflow-y: auto; }
  .card-row { grid-template-columns: 4.8em minmax(0, 1fr); }
  .row-stage, .row-job, .row-cost { grid-column: 2; grid-row: auto; text-align: left; }
  .card-pane { max-width: 920px; }
  .back-to-list { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
