/* Layout: ferramenta com abas. Avaliações salvas, questionário com painel de resultado fixo, e plano de ação com acompanhamento. */
:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --sunk: #e8ecf2;
  --line: #d3dae4;
  --fg: #17202c;
  --muted: #5a6677;
  --accent: #1d5fbf;
  --accent-soft: #e2ebfa;
  --on-accent: #ffffff;
  --l1: #c2413a; --l2: #d98a1c; --l3: #96860c; --l4: #4a9a54; --l5: #1d7a6c;
  --warn-bg: #fff4dc; --warn-fg: #7a4d00;
  --bad-bg: #fde8e6; --bad-fg: #9b2620;
  --ok-bg: #e2f3e5; --ok-fg: #24652f;
  --font-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Source Sans 3", "Segoe UI", Roboto, sans-serif;
  --font-data: "JetBrains Mono", ui-monospace, Menlo, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141b; --surface: #171e28; --sunk: #202937; --line: #2d3848;
    --fg: #e6ebf2; --muted: #9aa6b8; --accent: #6ea3f2; --accent-soft: #1c2c45; --on-accent: #0b1220;
    --l1: #e8675f; --l2: #eba646; --l3: #d6c64a; --l4: #6cc07a; --l5: #4cbfae;
    --warn-bg: #3a2c10; --warn-fg: #f3cf85;
    --bad-bg: #3d1a18; --bad-fg: #f4a29c;
    --ok-bg: #173323; --ok-fg: #95d8a1;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f141b; --surface: #171e28; --sunk: #202937; --line: #2d3848;
  --fg: #e6ebf2; --muted: #9aa6b8; --accent: #6ea3f2; --accent-soft: #1c2c45; --on-accent: #0b1220;
  --l1: #e8675f; --l2: #eba646; --l3: #d6c64a; --l4: #6cc07a; --l5: #4cbfae;
  --warn-bg: #3a2c10; --warn-fg: #f3cf85;
  --bad-bg: #3d1a18; --bad-fg: #f4a29c;
  --ok-bg: #173323; --ok-fg: #95d8a1;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 16px; line-height: 1.5; }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 20px; padding-block: 28px 64px; display: grid; gap: 24px; }
h1, h2, h3 { font-family: var(--font-display); text-wrap: balance; margin: 0; }
h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); font-weight: 800; font-stretch: 112%; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; font-weight: 700; font-stretch: 105%; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0; }
.eyebrow { font-family: var(--font-data); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.lede { color: var(--muted); max-width: 70ch; }
header { display: grid; gap: 8px; }
.savebar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 0.9rem; color: var(--muted); }
.savebar .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--l4); display: inline-block; margin-right: 6px; }
.savebar .dot.off { background: var(--l2); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; border-bottom: 1px solid var(--line); }
.tab { font: inherit; font-weight: 600; background: none; border: none; border-bottom: 3px solid transparent; padding: 10px 14px; color: var(--muted); cursor: pointer; }
.tab[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.tab:disabled { opacity: .45; cursor: default; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.setup { display: flex; flex-wrap: wrap; gap: 16px; align-items: end; }
.field { display: grid; gap: 4px; min-width: 0; flex: 1 1 200px; }
.field label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
input[type=text], input[type=date], select, textarea { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }
.setup .hint { flex: 1 1 100%; font-size: 0.9rem; color: var(--muted); }
.btn { font: inherit; font-weight: 600; border-radius: 6px; padding: 8px 14px; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--fg); }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.btn.small { padding: 4px 10px; font-size: 0.88rem; }
.btn.danger { color: var(--bad-fg); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn:disabled:hover { border-color: var(--line); }
.btn.primary:disabled:hover { border-color: var(--accent); }
.lock { background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 12px; font-size: 0.92rem; }
.tab:disabled { opacity: .5; cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.banner { background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 10px 14px; font-size: 0.95rem; }

/* Avaliações */
.list-head { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: end; }
.tbl-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.95rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
td.code { font-family: var(--font-data); white-space: nowrap; color: var(--muted); }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--sunk); }
.empty { color: var(--muted); padding: 16px 0; }
.confirm { display: inline-flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Questionário */
.main { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
@media (max-width: 920px) { .main { grid-template-columns: minmax(0, 1fr); } .panel { position: static !important; order: -1; } }
.scale { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 0.85rem; color: var(--muted); }
.scale b { font-family: var(--font-data); color: var(--fg); }
.dim { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.dim + .dim { margin-top: 16px; }
.dim-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: var(--sunk); }
.dim-head .meta { font-family: var(--font-data); font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.q { display: grid; grid-template-columns: 2.6rem minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; padding: 12px 16px; }
.q + .q { border-top: 1px solid var(--line); }
.q .code { font-family: var(--font-data); font-size: 0.8rem; color: var(--muted); }
.q .text { min-width: 0; }
@media (max-width: 640px) { .q { grid-template-columns: 2.4rem minmax(0, 1fr); } .opts { grid-column: 1 / -1; } }
.opts { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.opts input { position: absolute; opacity: 0; pointer-events: none; }
.opts label { font-family: var(--font-data); font-size: 0.85rem; min-width: 2.3rem; text-align: center; padding: 6px 4px; cursor: pointer; color: var(--muted); background: var(--surface); }
.opts input + label ~ label { border-left: 1px solid var(--line); }
.opts input:checked + label { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.opts input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: -2px; }
.opts label:hover { color: var(--fg); }
fieldset[disabled] .opts label { cursor: default; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }

.panel { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); display: grid; gap: 16px; }
.score { display: flex; align-items: center; gap: 16px; }
.score .num { font-family: var(--font-display); font-weight: 800; font-stretch: 120%; font-size: 3.4rem; line-height: 1; font-variant-numeric: tabular-nums; }
.score .of { font-family: var(--font-data); color: var(--muted); font-size: 0.85rem; }
.pill { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 0.95rem; padding: 4px 10px; border-radius: 999px; border: 1.5px solid currentColor; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.note { font-size: 0.9rem; color: var(--muted); }
.note.warn { background: var(--warn-bg); color: var(--warn-fg); border-radius: 6px; padding: 8px 10px; }
.progress { height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); }
svg text { font-family: var(--font-body); }
.bars { display: grid; gap: 8px; }
.bar { display: grid; grid-template-columns: minmax(0, 1fr) 2.6rem; gap: 2px 10px; align-items: center; font-size: 0.88rem; }
.bar .track { grid-column: 1 / -1; height: 8px; background: var(--sunk); border-radius: 4px; overflow: hidden; }
.bar .track i { display: block; height: 100%; border-radius: 4px; }
.bar .v { font-family: var(--font-data); text-align: right; font-variant-numeric: tabular-nums; }
.bar .name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Plano */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; display: grid; gap: 2px; }
.kpi b { font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; font-stretch: 115%; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi span { font-size: 0.85rem; color: var(--muted); }
.kpi.alert b { color: var(--bad-fg); }
.kpi { min-width: 0; }
.kpi.data b { font-size: 1.35rem; font-stretch: 100%; white-space: nowrap; }
input[type=date] { min-width: 150px; }
.sug { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }
.sug.alt { color: var(--warn-fg, var(--muted)); }
.waves { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.wave { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); display: grid; gap: 4px; }
.wave .when { font-family: var(--font-data); font-size: 0.78rem; color: var(--muted); }
.plan-tools { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.plan-tools .field { flex: 0 1 220px; }
.act td { border-bottom: none; }
.act-detail td { padding-top: 0; }
.act-title { font-weight: 600; }
.act-meta { font-size: 0.85rem; color: var(--muted); }
details summary { cursor: pointer; color: var(--accent); font-size: 0.9rem; font-weight: 600; }
details ol { margin: 6px 0 4px; padding-left: 1.3rem; }
details .ev { font-size: 0.9rem; }
.tag { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 8px; border-radius: 4px; white-space: nowrap; }
.tag.open { background: var(--warn-bg); color: var(--warn-fg); }
.tag.galta { background: var(--bad-bg); color: var(--bad-fg); }
.tag.gmedia { background: var(--warn-bg); color: var(--warn-fg); }
.tag.gbaixa { border: 1px solid var(--line); color: var(--muted); }
.gut { display: grid; grid-template-columns: repeat(3, 58px); gap: 4px; }
.gut label { display: grid; gap: 2px; font-size: 0.72rem; color: var(--muted); font-weight: 600; text-align: center; }
.gut select { padding: 5px 4px; text-align: center; }
.form-acao { display: grid; gap: 14px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.form-grid .wide { grid-column: 1 / -1; }
.row-btns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.tag.quick { background: var(--accent-soft); color: var(--accent); }
.tag.struct { background: var(--sunk); color: var(--fg); }
.tag.estr { background: var(--accent); color: var(--on-accent); font-size: 0.9rem; }
.tag.oper { background: var(--accent-soft); color: var(--accent); font-size: 0.9rem; }
.tag.late { background: var(--bad-bg); color: var(--bad-fg); }
.tag.done { background: var(--ok-bg); color: var(--ok-fg); }
.cell-in { min-width: 140px; }
select.st { min-width: 140px; }
.timeline { display: block; width: 100%; min-width: 640px; height: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.85rem; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
.copied { font-size: 0.9rem; color: var(--muted); }
@media (prefers-reduced-motion: no-preference) { .bar .track i, .progress > i { transition: width .3s ease; } }

.login { max-width: 420px; margin: 40px auto; display: grid; gap: 14px; }
.login h1 { font-size: 1.8rem; }
input[type=password] { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; width: 100%; }

/* Tabela do plano: cabe na largura da página; em telas estreitas vira cartões. */
.acoes-tbl .act-cell { min-width: 180px; }
.acoes-tbl .cell-in { min-width: 110px; }
.acoes-tbl select.st, .acoes-tbl select[data-cl] { min-width: 132px; }
.acoes-tbl input[type=date] { min-width: 132px; }
.acoes-tbl td { padding: 10px 6px; }
.acoes-tbl .gut { grid-template-columns: repeat(3, 50px); }
@media (max-width: 1100px) {
  .acoes-tbl thead { display: none; }
  .acoes-tbl, .acoes-tbl tbody { display: block; }
  .acoes-tbl tr.act { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .acoes-tbl tr.act td { display: block; border: 0; padding: 0; }
  .acoes-tbl tr.act td.act-cell { grid-column: 1 / -1; min-width: 0; }
  .acoes-tbl tr.act td[data-label]::before { content: attr(data-label); display: block; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; margin-bottom: 4px; }
  .acoes-tbl input[type=date], .acoes-tbl .cell-in, .acoes-tbl select.st, .acoes-tbl select[data-cl] { min-width: 0; }
}
