:root {
  --margin: 2cm;
  --pink-top: #f6b3cc;
  --pink: #e2639a;
  --berry: #a8215c;
  --ink: #3a1a2b;
  --muted: #7d5a6b;
  --line: #efc6d8;
  --paper: #fffafc;
  --green: #2e9e6a;
  --yellow: #e3a21a;
  --red: #d3424a;
  --gray: #9a8a93;
  --ease: cubic-bezier(.22, .9, .28, 1);
}
@media (max-width: 820px) { :root { --margin: .9rem; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; color: var(--ink);
  font-family: 'Figtree', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px; line-height: 1.45;
  background: linear-gradient(to bottom, var(--pink-top) 0%, #ffffff 100%) fixed no-repeat;
}
h1, h2, h3 { font-family: 'Fraunces', Georgia, serif; font-weight: 600; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--berry); outline-offset: 2px; }
[hidden] { display: none !important; }

/* ---------- faixa superior (~1/5 da tela) ---------- */
.band {
  height: 20vh; min-height: 150px;
  padding: var(--margin) var(--margin) 0;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 1rem;
}
.logo { height: min(72px, calc(20vh - var(--margin) - 8px)); min-height: 48px; width: auto; justify-self: start; }
.app-title { font-size: clamp(1.15rem, 2.6vw, 2.3rem); text-align: center; color: var(--berry); letter-spacing: .2px; }
.band-right { justify-self: end; }
@media (max-width: 820px) {
  .band { grid-template-columns: auto 1fr; grid-template-areas: "logo right" "title title"; height: auto; padding-bottom: .5rem; }
  .logo { grid-area: logo; } .band-right { grid-area: right; } .app-title { grid-area: title; }
}

/* ---------- login ---------- */
.login-stage {
  min-height: calc(80vh - var(--margin)); padding: 0 var(--margin) var(--margin);
  display: grid; place-items: center;
}
.login-card {
  width: min(420px, 100%); background: rgba(255, 255, 255, .88); border: 1px solid var(--line);
  border-radius: 24px; padding: 2rem; display: grid; gap: 1.1rem;
  box-shadow: 0 24px 60px rgba(168, 33, 92, .16);
  animation: card-in .5s var(--ease) both;
}
.login-card.leaving { opacity: 0; transform: translateY(-14px) scale(.98); transition: .28s ease; }
.login-card.shake { animation: shake .4s ease; }
@keyframes card-in { from { opacity: 0; transform: translateY(18px) scale(.98); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* ---------- campos e botões ---------- */
.field { display: grid; gap: .3rem; font-weight: 500; }
.field > span { font-size: .9rem; color: var(--muted); }
.field input, .field select, .field textarea, .search input {
  width: 100%; padding: .65rem .8rem; border: 1.5px solid var(--line); border-radius: 12px;
  background: #fff; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus, .search input:focus {
  outline: none; border-color: var(--pink); box-shadow: 0 0 0 4px rgba(226, 99, 154, .18);
}
.field input[readonly] { background: #fbeff4; color: var(--muted); }
.field input.hl { background: #fff1b8; border-color: var(--yellow); }
.field.invalid input, .field.invalid select { border-color: var(--red); }
.field .err { color: var(--red); font-size: .82rem; min-height: 1em; }
.inp { display: flex; align-items: center; gap: .5rem; }
.unit { font-style: normal; color: var(--muted); min-width: 3.2rem; font-size: .9rem; }
.form-error { color: var(--red); margin: 0; font-weight: 500; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .6rem 1.1rem; border-radius: 999px; border: 1.5px solid var(--pink);
  background: #fff; color: var(--berry); cursor: pointer; font-weight: 600;
  transition: transform .15s var(--ease), box-shadow .2s, background .2s, color .2s;
}
.btn:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(168, 33, 92, .18); background: #fff0f6; }
.btn:active:not(:disabled) { transform: translateY(0) scale(.97); }
.btn.primary { background: var(--berry); border-color: var(--berry); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #8f1a4d; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.danger:hover:not(:disabled) { background: #fdecec; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.big { padding: .85rem 1.4rem; font-size: 1.05rem; }
.btn.sm { padding: .35rem .8rem; font-size: .88rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.badge { background: var(--berry); color: #fff; border-radius: 999px; padding: 0 .55rem; font-size: .8rem; min-width: 1.4rem; text-align: center; }

/* ---------- tela principal ---------- */
.stage {
  padding: 0 var(--margin) var(--margin); min-height: calc(80vh - 1px);
  display: grid; grid-template-columns: 36vw 1fr; gap: 2rem; align-items: start;
}
.menu { display: grid; gap: 1.1rem; justify-items: center; }
.menu-btn {
  width: 33vw; min-height: 4.6rem; display: flex; align-items: center; gap: 1rem; padding: 0 1.6rem;
  border: 1.5px solid var(--line); border-radius: 22px; cursor: pointer; text-align: left;
  background: rgba(255, 255, 255, .9); color: var(--berry); font-size: 1.2rem; font-weight: 600;
  box-shadow: 0 10px 26px rgba(168, 33, 92, .12);
  transition: transform .2s var(--ease), box-shadow .25s, background .2s, color .2s;
}
.menu-btn svg { width: 1.7rem; height: 1.7rem; fill: currentColor; flex: none; transition: transform .3s var(--ease); }
.menu-btn:hover { transform: translateX(8px); background: var(--berry); color: #fff; box-shadow: 0 16px 34px rgba(168, 33, 92, .3); }
.menu-btn:hover svg { transform: scale(1.18) rotate(-6deg); }
.menu-btn:active { transform: translateX(8px) scale(.98); }
@media (max-width: 1000px) {
  .stage { grid-template-columns: 1fr; }
  .menu-btn { width: 100%; }
}
.dash { display: grid; gap: 1rem; align-content: start; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; }
.stat { background: rgba(255, 255, 255, .9); border: 1px solid var(--line); border-radius: 18px; padding: 1rem 1.2rem; }
.stat strong { display: block; font-family: 'Fraunces', Georgia, serif; font-size: 2.2rem; color: var(--berry); line-height: 1.1; }
.stat span { color: var(--muted); font-size: .9rem; }
.panel { background: rgba(255, 255, 255, .9); border: 1px solid var(--line); border-radius: 18px; padding: 1rem 1.2rem; }
.panel h3 { font-size: 1.1rem; margin-bottom: .6rem; color: var(--berry); }
.recent { list-style: none; margin: 0; padding: 0; display: grid; gap: .3rem; }
.recent button { width: 100%; text-align: left; background: none; border: 0; padding: .45rem .5rem; border-radius: 10px; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.recent button:hover { background: #fff0f6; }
.empty { color: var(--muted); padding: 1rem 0; }

/* ---------- janelas (expandem a partir do botão) ---------- */
.win-backdrop { position: fixed; inset: 0; background: rgba(58, 26, 43, .0); transition: background .35s ease; }
.win-backdrop.on { background: rgba(58, 26, 43, .38); backdrop-filter: blur(2px); }
.win {
  position: fixed; display: flex; flex-direction: column; overflow: hidden; opacity: 0;
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 80px rgba(120, 20, 70, .3);
  transition: top .5s var(--ease), left .5s var(--ease), width .5s var(--ease), height .5s var(--ease),
              opacity .3s ease, border-radius .5s var(--ease);
}
.win.open { border-radius: 26px; }
.win.no-anim { transition: none; }
.win-head {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex: none;
  padding: .9rem 1.3rem; background: linear-gradient(to right, #fde1ec, #fff);
  border-bottom: 1px solid var(--line);
}
.win-head h2 { font-size: 1.35rem; color: var(--berry); }
.win-body { flex: 1; overflow: auto; padding: 1.2rem 1.4rem; opacity: 0; transition: opacity .3s ease .22s; }
.win.open .win-body { opacity: 1; }
.win-foot { flex: none; display: flex; flex-wrap: wrap; gap: .7rem; align-items: center; justify-content: flex-end; padding: .8rem 1.3rem; border-top: 1px solid var(--line); background: #fff; }
.icon-btn { width: 2.3rem; height: 2.3rem; border-radius: 50%; border: 0; background: #fff; color: var(--berry); font-size: 1.5rem; line-height: 1; cursor: pointer; transition: transform .2s var(--ease), background .2s; }
.icon-btn:hover { background: var(--berry); color: #fff; transform: rotate(90deg); }

.toolbar { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; margin-bottom: 1rem; }
.search { display: flex; gap: .5rem; flex: 1 1 320px; max-width: 560px; }
.counter { margin-left: auto; color: var(--muted); }
.counter strong { color: var(--berry); font-size: 1.3rem; font-family: 'Fraunces', Georgia, serif; }

.rows { display: grid; gap: .6rem; }
.rows-head, .prow { display: grid; grid-template-columns: 1.6fr 1.6fr 1fr auto; gap: 1rem; align-items: center; padding: .75rem 1rem; }
.rows-head { color: var(--muted); font-size: .85rem; font-weight: 600; padding-bottom: 0; }
.prow { background: #fff; border: 1px solid var(--line); border-radius: 16px; transition: transform .2s var(--ease), box-shadow .2s; animation: row-in .35s var(--ease) both; }
.prow:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(168, 33, 92, .12); }
@keyframes row-in { from { opacity: 0; transform: translateY(8px); } }
.pact { display: flex; gap: .5rem; flex-wrap: wrap; justify-content: flex-end; }
.wrap-anywhere { overflow-wrap: anywhere; }
@media (max-width: 820px) { .rows-head { display: none; } .prow { grid-template-columns: 1fr; } .pact { justify-content: flex-start; } }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem 1.2rem; max-width: 900px; }
.form-grid .wide { grid-column: 1 / -1; }
.radios { display: flex; gap: 1rem; flex-wrap: wrap; padding: .5rem 0; }
.radios label { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font-weight: 500; }
fieldset { border: 1px solid var(--line); border-radius: 16px; padding: .8rem 1rem 1.1rem; margin: 0 0 1.2rem; background: #fff; }
legend { padding: 0 .5rem; font-weight: 700; color: var(--berry); }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: .8rem 1.4rem; background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: 1rem 1.2rem; margin-bottom: 1.2rem; }
.kv dt { color: var(--muted); font-size: .82rem; }
.kv dd { margin: 0; font-weight: 600; }
.kv div { min-width: 0; overflow-wrap: anywhere; }

.etable { width: 100%; border-collapse: separate; border-spacing: 0 .5rem; }
.etable th { text-align: left; color: var(--muted); font-size: .85rem; padding: 0 .7rem; }
.etable td { background: #fff; padding: .7rem; border-block: 1px solid var(--line); vertical-align: middle; }
.etable td:first-child { border-left: 1px solid var(--line); border-radius: 14px 0 0 14px; }
.etable td:last-child { border-right: 1px solid var(--line); border-radius: 0 14px 14px 0; }
.etable .acts { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.tbl-scroll { overflow-x: auto; }

.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .65rem; border-radius: 999px; font-weight: 600; font-size: .92rem; background: #eee; white-space: nowrap; }
.chip::before { content: ''; width: .6rem; height: .6rem; border-radius: 50%; background: currentColor; }
.chip.green { color: var(--green); background: #e5f5ed; }
.chip.yellow { color: #a87000; background: #fff3d1; }
.chip.red { color: var(--red); background: #fde8e9; }
.chip.gray { color: var(--gray); background: #f1ecef; }
.chip b { color: var(--ink); font-weight: 600; }
.tag-draft { background: #fff3d1; color: #a87000; border-radius: 999px; padding: .15rem .6rem; font-weight: 600; font-size: .85rem; }

/* nova avaliação (janela pequena) */
.pick { list-style: none; margin: .8rem 0 0; padding: 0; display: grid; gap: .4rem; max-height: 46vh; overflow: auto; }
.pick label { display: flex; align-items: center; gap: .6rem; padding: .6rem .8rem; border: 1.5px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; transition: border-color .15s, background .15s; }
.pick label:hover { background: #fff0f6; }
.pick input:checked + span { color: var(--berry); font-weight: 700; }
.pick label:has(input:checked) { border-color: var(--berry); background: #ffe6f0; }

/* ---------- avaliação: etapas ---------- */
.steps { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.step-tab { border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: .45rem .9rem; cursor: pointer; font-weight: 600; color: var(--muted); transition: all .2s var(--ease); }
.step-tab:hover { border-color: var(--pink); }
.step-tab.on { background: var(--berry); border-color: var(--berry); color: #fff; transform: translateY(-1px); }
.step-pane { display: none; }
.step-pane.on { display: block; animation: pane-in .35s var(--ease); }
@keyframes pane-in { from { opacity: 0; transform: translateX(14px); } }
.mode-row { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; }
.mode-row .radios { padding: 0; }
.missing { font-size: .9rem; color: var(--muted); margin-right: auto; max-width: 52ch; }
.missing summary { cursor: pointer; color: var(--red); font-weight: 600; }
.missing ul { margin: .3rem 0 0; padding-left: 1.2rem; }
.hint { color: var(--muted); font-size: .9rem; margin: .2rem 0 1rem; }

/* ---------- resultado ---------- */
.result h3.section { font-size: 1.25rem; color: var(--berry); margin: 1.8rem 0 .8rem; }
.result .method { font-size: 1.5rem; margin: 1.4rem 0 .2rem; color: var(--ink); }
.avatars { display: grid; grid-template-columns: repeat(8, minmax(84px, 1fr)); gap: .4rem; overflow-x: auto; padding: .3rem 0 .6rem; }
.avatar { margin: 0; text-align: center; font-weight: 600; color: #3a3a3a; border-radius: 18px; padding: .55rem .2rem .3rem; border: 3px solid transparent; transition: background .3s, border-color .3s, transform .3s var(--ease); }
.avatar figcaption { font-size: .92rem; margin-bottom: .35rem; }
.avatar img { width: 100%; height: auto; display: block; }
.avatar.on { background: #fff472; border-color: #fff212; box-shadow: 0 8px 22px rgba(190, 170, 0, .25); transform: translateY(-3px); }
.rtable { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.rtable th { background: #fde1ec; text-align: left; padding: .7rem .9rem; color: var(--berry); }
.rtable td { padding: .8rem .9rem; border-top: 1px solid var(--line); vertical-align: top; }
.rtable .ref { margin-top: 1.4em; text-align: center; color: var(--muted); font-size: .85rem; font-weight: 400; }
.rtable .ev { font-weight: 600; }
.rtable .ev.green { color: var(--green); } .rtable .ev.yellow { color: #a87000; } .rtable .ev.red { color: var(--red); } .rtable .ev.gray { color: var(--gray); }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1rem; }
.chart { background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: .6rem .8rem; }
.chart h4 { margin: 0 0 .2rem; font-size: .95rem; color: var(--berry); }
.chart svg { width: 100%; height: auto; display: block; }
.note-box { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: .8rem 1rem; white-space: pre-wrap; }
.note-box.pro { border-style: dashed; background: #fff8e1; }
.warn { background: #fff3d1; border-radius: 12px; padding: .5rem .9rem; margin: .5rem 0; color: #7a5200; }
.res-actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---------- diálogo de confirmação e avisos ---------- */
.dialog-backdrop { position: fixed; inset: 0; z-index: 9000; background: rgba(58, 26, 43, .45); display: grid; place-items: center; padding: 1rem; animation: fade .2s ease; }
.dialog { background: #fff; border-radius: 20px; padding: 1.5rem; width: min(420px, 100%); box-shadow: 0 30px 70px rgba(0, 0, 0, .3); animation: pop .3s var(--ease); }
.dialog p { margin: 0 0 1.2rem; }
.dialog .row { display: flex; gap: .6rem; justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.9) translateY(10px); } }
.toasts { position: fixed; bottom: 1.2rem; left: 50%; transform: translateX(-50%); z-index: 9500; display: grid; gap: .5rem; width: min(480px, calc(100% - 2rem)); }
.toast { background: var(--ink); color: #fff; padding: .8rem 1.1rem; border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .25); animation: pop .3s var(--ease); }
.toast.error { background: var(--red); } .toast.ok { background: var(--green); }

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

/* ---------- impressão ---------- */
@page { margin: 12mm; }
@media print {
  body { background: #fff !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body.printing > *:not(.win.print-target) { display: none !important; }
  body.printing .win.print-target { display: block !important; position: static !important; width: auto !important; height: auto !important; opacity: 1 !important; box-shadow: none; border: 0; overflow: visible; }
  body.printing .win.print-target .win-body { overflow: visible; opacity: 1; padding: 0; }
  .no-print, .win-head .icon-btn, .win-foot { display: none !important; }
  .avatars { overflow: visible; }
  .avatar.on { box-shadow: none; transform: none; }
  .chart, .rtable, .kv, .note-box { break-inside: avoid; }
}
