/* Recepção TS — estilo "Modo" (claro, bordas finas, denso) com o roxo da Tereza (#52206F) como cor principal.
   SF Pro + Scholar itálico na palavra de destaque. Cartões sólidos, sem vidro. */
:root {
  /* Marca: escala do roxo TS */
  --brand-lowest: #f5eff9;
  --brand-low: #dcc8ea;
  --brand: #52206f;
  --brand-medium: #431a5b;
  --brand-high: #2b0f3d;
  /* Neutros */
  --bg: #f7f7f7;
  --surface: #ffffff;
  --low: #ebebeb;
  --base: #d1d1d1;
  --ink: #0d0d0d;
  --muted: #7b7b7b;
  /* Estados */
  --ok: #2e9e5b;
  --warn: #c77d12;
  --warn-low: #fdf3e2;
  --danger: #d5342b;
  --danger-low: #fdeceb;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Inter Tight", Inter, system-ui, sans-serif;
  --script: "TS Scholar", "Scholar", Georgia, serif;
  --r: 12px;
  --r-sm: 8px;
  --shadow: 0 1px 2px rgba(13, 13, 13, .04), 0 2px 8px -4px rgba(13, 13, 13, .06);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; }
body { min-height: 100dvh; overscroll-behavior-y: none; font-size: 15px; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
em { font-family: var(--script); font-style: italic; font-weight: 400; color: var(--brand); }
.boot { min-height: 100dvh; display: grid; place-items: center; color: var(--muted); }

/* ---------- Avatar ---------- */
.av { width: 40px; height: 40px; border-radius: 50%; display: inline-grid; place-items: center; font-weight: 600; font-size: 14px; flex: none; letter-spacing: .02em; }
.av.sm { width: 22px; height: 22px; font-size: 9px; }

/* ---------- Login ---------- */
.login { min-height: 100dvh; padding: calc(56px + var(--safe-t)) 16px calc(32px + var(--safe-b)); display: flex; flex-direction: column; align-items: center; }
.login-top { text-align: center; margin-bottom: 28px; }
.brand { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.login h1 { font-size: 34px; margin: 10px 0 6px; font-weight: 600; letter-spacing: -.03em; }
.login h1 em { font-size: 40px; }
.login p { margin: 0; color: var(--muted); font-size: 15px; }
.people { display: flex; flex-direction: column; width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--low); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.person { display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; border-top: 1px solid var(--low); transition: background .15s; }
.person:first-child { border-top: 0; }
.person:hover, .person:active { background: var(--brand-lowest); }
.person b { font-size: 15px; font-weight: 600; }
.person small { font-size: 13px; color: var(--muted); margin-left: auto; }
.pin-dots { display: flex; gap: 14px; margin: 4px 0 32px; }
.pin-dots span { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--base); transition: background .15s, border-color .15s; }
.pin-dots span.on { background: var(--brand); border-color: var(--brand); }
.pin-dots.shake { animation: shake .4s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
.keypad { display: grid; grid-template-columns: repeat(3, 84px); gap: 12px; }
.keypad button { height: 64px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--low); box-shadow: var(--shadow); font-size: 26px; font-weight: 500; display: grid; place-items: center; transition: background .1s, transform .1s, border-color .1s; }
.keypad button:active { background: var(--brand-lowest); border-color: var(--brand-low); transform: scale(.96); }
.keypad button.ghost { background: none; border: 0; box-shadow: none; }
.link { margin-top: 28px; color: var(--brand); font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; }

/* ---------- Topo ---------- */
.top { background: var(--surface); border-bottom: 1px solid var(--low); padding: calc(14px + var(--safe-t)) 16px 12px; position: sticky; top: 0; z-index: 5; }
.top-row { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "title actions" "day day" "stats stats" "seg seg"; align-items: center; gap: 10px 12px; }
.top-row .title { grid-area: title; } .top-row .top-actions { grid-area: actions; } .top-row .daynav { grid-area: day; } .top-row .stats { grid-area: stats; margin: 0; } .top-row .seg { grid-area: seg; }
.daynav { display: flex; gap: 6px; align-items: center; }
.daynav .icon-btn { width: 36px; height: 36px; }
.daynav .icon-btn:disabled { opacity: .35; cursor: default; }
.day-btn { flex: 1; height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--low); border-radius: var(--r-sm); background: var(--surface); font-weight: 600; font-size: 14px; padding: 0 14px; transition: border-color .15s; }
.day-btn:hover { border-color: var(--base); }
.day-btn svg { color: var(--brand); width: 16px; height: 16px; }
.top h1 { font-size: 24px; margin: 2px 0 0; font-weight: 600; letter-spacing: -.03em; }
.top h1 em { font-size: 28px; }
.top .brand { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; }
.top-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 40px; height: 40px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--low); display: grid; place-items: center; color: var(--ink); transition: background .15s; }
.icon-btn.on { background: var(--brand-lowest); border-color: var(--brand-low); color: var(--brand); }
.icon-btn.plain { width: 32px; height: 32px; }
.me { border-radius: 50%; box-shadow: 0 0 0 1px var(--low); }
.stats { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin: 0; }
.stats span { border: 1px solid var(--low); border-radius: 99px; padding: 4px 10px; background: var(--bg); display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.stats svg { width: 14px; height: 14px; }
.stats b { color: var(--ink); font-weight: 600; }
/* Grupo de botões (Minha vez | Quadro) */
.seg { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--low); border-radius: var(--r-sm); overflow: hidden; background: var(--surface); }
.seg button { padding: 9px; font-weight: 500; font-size: 14px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); transition: background .2s, color .2s; }
.seg button + button { border-left: 1px solid var(--low); }
.seg button.on { background: var(--brand-lowest); color: var(--brand); font-weight: 600; }
.badge { background: var(--brand); color: #fff; border-radius: 99px; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; }

.banner { display: flex; gap: 12px; align-items: flex-start; text-align: left; margin: 12px 16px 0; padding: 12px 14px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--brand-low); color: var(--ink); font-size: 14px; line-height: 1.4; width: calc(100% - 32px); box-shadow: var(--shadow); }
.banner b { display: block; font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.banner svg { margin-top: 1px; color: var(--brand); }

main { padding: 14px 16px calc(100px + var(--safe-b)); }

/* ---------- Card ---------- */
.card { position: relative; background: var(--surface); border: 1px solid var(--low); border-radius: var(--r); padding: 12px; box-shadow: var(--shadow); cursor: pointer; transition: border-color .3s, transform .15s, background-color .6s; }
.card.new { animation: pop .25s ease-out; }
.card:hover { border-color: var(--base); }
.card:active { transform: scale(.985); }
.card.mine { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lowest), var(--shadow); }
.card.dragging { opacity: .4; }
.card h3 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -.01em; padding-right: 72px; }
.card .proc { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card .note { margin: 8px 0 0; font-size: 13px; background: var(--bg); border: 1px solid var(--low); border-radius: var(--r-sm); padding: 6px 8px; color: #444; }
.card footer { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--low); font-size: 13px; }
.who { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; }
.muted { color: var(--muted); }
.time { display: inline-flex; gap: 4px; align-items: center; color: var(--muted); font-size: 12px; border: 1px solid var(--low); border-radius: 99px; padding: 2px 8px 2px 6px; white-space: nowrap; }
.time svg { width: 13px; height: 13px; }
.time.warn { color: var(--warn); background: var(--warn-low); border-color: transparent; font-weight: 600; }
.time.late { color: var(--danger); background: var(--danger-low); border-color: transparent; font-weight: 600; }
.your-turn { position: absolute; top: 10px; right: 10px; background: var(--brand-lowest); color: var(--brand); border: 1px solid var(--brand-low); font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.tag { display: inline-block; margin-top: 8px; font-size: 11px; background: var(--danger-low); color: var(--danger); padding: 2px 8px; border-radius: 99px; font-weight: 600; }
.stage-pill { display: inline-flex; align-items: center; gap: 6px; margin: 8px 0 0; font-size: 12px; font-weight: 500; color: var(--ink); background: var(--surface); border: 1px solid var(--low); padding: 3px 9px 3px 4px; border-radius: 99px; }
@keyframes pop { from { opacity: 0; transform: translateY(4px); } }

/* ---------- Minha vez ---------- */
.mine-list { display: flex; flex-direction: column; gap: 16px; max-width: 560px; margin: 0 auto; }
.mine-item { display: flex; flex-direction: column; gap: 8px; }
.primary { background: var(--brand); color: #fff; border-radius: var(--r-sm); padding: 13px 16px; font-weight: 600; font-size: 15px; display: flex; align-items: center; justify-content: center; gap: 8px; transition: transform .1s, background .15s; box-shadow: 0 1px 2px rgba(43, 15, 61, .25); }
.primary:hover { background: var(--brand-medium); }
.primary:active { transform: scale(.98); background: var(--brand-high); }
.primary:disabled { opacity: .45; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); max-width: 400px; margin: 24px auto 0; background: var(--surface); border: 1px dashed var(--base); border-radius: var(--r); }
.empty-ic { width: 52px; height: 52px; border-radius: var(--r); background: var(--brand-lowest); border: 1px solid var(--brand-low); color: var(--brand); display: grid; place-items: center; margin: 0 auto 14px; }
.empty-ic svg { width: 24px; height: 24px; }
.empty h2 { color: var(--ink); font-size: 18px; font-weight: 600; margin: 0 0 6px; }
.empty h2 em { font-size: 22px; }
.empty p { margin: 0; line-height: 1.45; font-size: 14px; }

/* ---------- Quadro ---------- */
main.quadro { padding-left: 0; padding-right: 0; }
.board { display: flex; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding: 0 16px 8px; scroll-padding: 0 16px; -webkit-overflow-scrolling: touch; }
.col { flex: 0 0 84%; max-width: 320px; scroll-snap-align: start; background: #f0f0f0; border: 1px solid var(--low); border-radius: var(--r); padding: 10px; min-height: 60vh; transition: background .15s, border-color .15s; }
.col.over { background: var(--brand-lowest); border-color: var(--brand); border-style: dashed; }
.col header { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; padding: 2px 2px 0; }
.count { margin-left: auto; background: var(--surface); border: 1px solid var(--low); border-radius: 99px; font-size: 12px; font-weight: 600; min-width: 24px; height: 22px; display: grid; place-items: center; padding: 0 7px; color: var(--muted); }
.col-hint { margin: 4px 0 10px 40px; font-size: 12px; color: var(--muted); }
.col-body { display: flex; flex-direction: column; gap: 8px; }
.col-empty { text-align: center; color: var(--muted); font-size: 12px; padding: 18px 0; margin: 0; border: 1px dashed var(--base); border-radius: var(--r); }
@media (min-width: 900px) {
  .top { padding: 12px 24px; }
  .top-row { grid-template-columns: auto auto auto 1fr auto; grid-template-areas: "title day seg stats actions"; gap: 16px; }
  .top-row .title { display: flex; align-items: baseline; gap: 12px; }
  .top-row .stats { justify-content: flex-end; }
  .daynav .day-btn { flex: none; min-width: 150px; }
  .seg { width: 240px; }
  .banner { margin: 12px 24px 0; width: calc(100% - 48px); }
  main { padding: 16px 24px 24px; }
  main.quadro { padding: 16px 0 0; }
  #app { display: flex; flex-direction: column; height: 100dvh; }
  main { flex: 1; min-height: 0; overflow-y: auto; }
  main.quadro { overflow: hidden; }
  .board { scroll-snap-type: none; padding: 0 24px 16px; height: 100%; align-items: stretch; }
  .col { flex: 1 0 210px; max-width: 340px; min-height: 0; display: flex; flex-direction: column; }
  .col-body { overflow-y: auto; flex: 1; padding: 2px; margin: -2px; }
  .mine-list { max-width: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); align-items: start; }
  .fab { right: 24px; bottom: 24px; }
}

/* ---------- Botão de novo paciente ---------- */
.fab { position: fixed; right: 16px; bottom: calc(20px + var(--safe-b)); background: var(--brand); color: #fff; border-radius: var(--r); padding: 13px 18px 13px 14px; font-weight: 600; font-size: 15px; display: flex; align-items: center; gap: 8px; box-shadow: 0 8px 24px -8px rgba(82, 32, 111, .55); z-index: 6; transition: transform .1s, background .15s; }
.fab:hover { background: var(--brand-medium); }
.fab:active { transform: scale(.96); }
.fab svg { width: 20px; height: 20px; stroke-width: 2.2; }

/* ---------- Folhas ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 20; pointer-events: none; }
#sheet-root:empty { display: none; }
.scrim { position: absolute; inset: 0; background: rgba(13, 13, 13, .35); opacity: 0; transition: opacity .25s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 88dvh; overflow-y: auto; background: var(--surface); border-radius: 16px 16px 0 0; padding: 8px 16px calc(20px + var(--safe-b)); transform: translateY(100%); transition: transform .28s cubic-bezier(.2, .8, .2, 1); }
.sheet.tall { min-height: 60dvh; }
#sheet-root.open { pointer-events: auto; }
#sheet-root.open .scrim { opacity: 1; }
#sheet-root.open .sheet { transform: none; }
@media (min-width: 700px) {
  .sheet { left: 50%; right: auto; width: 480px; bottom: 50%; border-radius: 16px; border: 1px solid var(--low); transform: translate(-50%, calc(50% + 30px)); opacity: 0; transition: transform .25s, opacity .2s; }
  #sheet-root.open .sheet { transform: translate(-50%, 50%); opacity: 1; }
  .sheet.tall { min-height: 0; }
}
.grab { width: 36px; height: 4px; border-radius: 9px; background: var(--low); margin: 0 auto 12px; }
.sh-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sh-head .stage-pill { margin: 0; }
.sh-title { font-size: 19px; font-weight: 600; margin: 0; letter-spacing: -.02em; }
.sh-title em { font-size: 22px; }
.sh-title.big { font-size: 24px; margin-top: 12px; }
.sh-proc { margin: 2px 0 0; font-size: 15px; color: var(--muted); }
.sh-note { background: var(--bg); border: 1px solid var(--low); padding: 10px 12px; border-radius: var(--r-sm); font-size: 14px; margin: 12px 0 0; }
.sh-meta { font-size: 13px; color: var(--muted); margin: 12px 0 14px; }
.sh-text { color: var(--muted); margin: 6px 0 16px; line-height: 1.4; }
.sh-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin: 22px 0 8px; }
.wide { width: 100%; }
.row-btns { display: flex; gap: 8px; margin-top: 8px; }
.row-btns > * { flex: 1; }
.ghost-btn { background: var(--surface); border: 1px solid var(--low); border-radius: var(--r-sm); padding: 12px; font-weight: 500; font-size: 14px; text-align: center; margin-top: 8px; transition: background .15s, border-color .15s; }
.ghost-btn:hover { background: var(--bg); border-color: var(--base); }
.row-btns .ghost-btn { margin-top: 0; }
.danger { background: var(--danger); color: #fff; border-radius: var(--r-sm); padding: 12px; font-weight: 600; }
.danger-text { color: var(--danger); }
.ghost-btn.danger-text { border-color: #f6cfcc; }
/* Histórico em lista com divisórias */
.hist { list-style: none; margin: 0; padding: 0; font-size: 13px; border: 1px solid var(--low); border-radius: var(--r); overflow: hidden; }
.hist li { display: flex; gap: 12px; padding: 9px 12px; border-top: 1px solid var(--low); }
.hist li:first-child { border-top: 0; }
.h-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; width: 40px; }

/* Passar adiante: lista de etapas numeradas (estilo step indicator) */
.stage-list { display: flex; flex-direction: column; border: 1px solid var(--low); border-radius: var(--r); overflow: hidden; margin-top: 12px; }
.stage-opt { border-top: 1px solid var(--low); background: var(--surface); transition: background .15s; }
.stage-opt:first-child { border-top: 0; }
.stage-opt.open { background: var(--brand-lowest); }
.stage-opt > button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; text-align: left; }
.stage-opt > button:hover { background: var(--bg); }
.stage-opt > button .st-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.stage-opt > button b { font-size: 14px; font-weight: 600; }
.stage-opt > button small { color: var(--muted); font-size: 12px; }
.stage-opt > button > svg { color: var(--base); }
.stage-opt.disabled > button { cursor: default; }
.stage-opt.disabled > button:hover { background: none; }
.step { width: 22px; height: 22px; border-radius: 50%; flex: none; display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--low); background: var(--surface); }
.step.done { background: var(--ok); border-color: var(--ok); color: #fff; }
.step.done svg { width: 13px; height: 13px; stroke-width: 2.6; }
.step.cur { background: var(--brand); border-color: var(--brand); color: #fff; }
.who-pick { padding: 0 12px 12px 44px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.who-pick p { width: 100%; margin: 0 0 2px; font-size: 12px; color: var(--muted); }
.who-pick button { background: var(--surface); border: 1px solid var(--low); border-radius: 99px; padding: 5px 12px 5px 5px; display: inline-flex; align-items: center; gap: 7px; font-weight: 500; font-size: 14px; }
.who-pick button:hover { border-color: var(--brand); }
.who-pick button:disabled { opacity: .4; }

/* Formulário */
.field { display: block; margin: 14px 0 0; }
.field span, .field-label { display: block; font-size: 13px; font-weight: 500; color: var(--ink); margin: 0 0 6px; }
.field small { font-weight: 400; color: var(--muted); }
.field input, .field textarea { width: 100%; border: 1px solid var(--low); background: var(--surface); border-radius: var(--r-sm); padding: 11px 12px; font-size: 16px; outline: none; resize: none; transition: border-color .15s, box-shadow .15s; }
.field input::placeholder, .field textarea::placeholder { color: #a8a8a8; }
.field input:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-lowest); }
.field-hint { font-size: 13px; color: var(--muted); background: var(--bg); border: 1px solid var(--low); border-radius: var(--r-sm); padding: 10px 12px; margin: 16px 0; line-height: 1.4; }
.field-hint b { color: var(--ink); font-weight: 600; }

/* Ícones das etapas: quadradinho com contorno, ícone na cor da etapa */
.st-ic { display: inline-grid; place-items: center; flex: none; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--low); color: var(--c); width: 30px; height: 30px; }
.st-ic svg { width: 16px; height: 16px; stroke-width: 1.8; }
.stage-pill .st-ic { width: 18px; height: 18px; border: 0; border-radius: 50%; background: color-mix(in srgb, var(--c) 14%, white); }
.stage-pill .st-ic svg { width: 12px; height: 12px; }
.stage-opt > button .st-ic { width: 32px; height: 32px; }

/* Aviso rápido */
#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 16px); background: var(--ink); color: #fff; padding: 10px 16px; border-radius: var(--r-sm); font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 30; max-width: calc(100% - 32px); text-align: center; box-shadow: 0 8px 24px -8px rgba(0, 0, 0, .35); }
#toast.on { opacity: 1; transform: translate(-50%, 0); }

/* Cronômetro e urgência: o card esquenta até o limite (5 min) e depois pisca */
.card[data-limit] { background-color: color-mix(in srgb, var(--danger) calc(var(--heat, 0) * 13%), var(--surface)); border-color: color-mix(in srgb, var(--danger) calc(var(--heat, 0) * 55%), var(--low)); }
.card[data-limit] .time { color: color-mix(in srgb, var(--danger) calc(var(--heat, 0) * 100%), var(--muted)); font-weight: 600; }
.time { font-variant-numeric: tabular-nums; }
.t-ic { display: inline-grid; }
.time.done { color: var(--ok); border-color: transparent; background: #e6f5ec; }
.card.urgent { border-color: var(--danger); animation: urgent 1.1s ease-in-out infinite; }
.card.urgent .time { background: var(--danger); border-color: var(--danger); color: #fff; }
.card.urgent .t-ic svg { animation: blink .55s steps(2, start) infinite; }
.card.urgent.mine { box-shadow: 0 0 0 3px var(--danger-low), var(--shadow); }
@keyframes urgent { 0%, 100% { background-color: var(--danger-low); box-shadow: 0 0 0 0 rgba(213, 52, 43, .35), var(--shadow); } 50% { background-color: #fbd5d2; box-shadow: 0 0 0 6px rgba(213, 52, 43, 0), var(--shadow); } }
@keyframes blink { to { visibility: hidden; } }
@media (prefers-reduced-motion: reduce) { .card.urgent, .card.urgent .t-ic svg { animation: none; } }

/* Média da etapa no topo da coluna */
.col-hint { display: flex; align-items: center; gap: 8px; }
.avg { margin-left: auto; display: inline-flex; align-items: center; gap: 3px; font-variant-numeric: tabular-nums; color: var(--muted); }
.avg svg { width: 12px; height: 12px; }

/* Outro dia (só consulta) */
.banner.past { align-items: center; border-color: var(--low); }
.banner.past > div { flex: 1; }
.ghost-btn.sm { margin: 0; padding: 8px 12px; font-size: 13px; white-space: nowrap; }

/* Tempo em cada etapa */
.durs { list-style: none; margin: 0; padding: 0; border: 1px solid var(--low); border-radius: var(--r); overflow: hidden; font-size: 14px; }
.durs li { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-top: 1px solid var(--low); }
.durs li:first-child { border-top: 0; }
.durs .st-ic { width: 26px; height: 26px; }
.durs .st-ic svg { width: 14px; height: 14px; }
.d-name { flex: 1; }
.d-name small { color: var(--brand); font-weight: 600; font-size: 11px; background: var(--brand-lowest); border-radius: 99px; padding: 1px 7px; margin-left: 4px; }
.d-time { font-variant-numeric: tabular-nums; font-weight: 600; display: inline-flex; align-items: center; gap: 4px; }
.durs li.over .d-time, .durs li.urgent .d-time { color: var(--danger); }
.d-time svg { width: 14px; height: 14px; }

/* Calendário */
.cal { border: 1px solid var(--low); border-radius: var(--r); padding: 12px; margin: 12px 0 4px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-head b { font-size: 15px; }
.cal-head .icon-btn:disabled { opacity: .3; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-grid.wk span { font-size: 11px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal-grid button { aspect-ratio: 1; border-radius: 50%; font-size: 14px; font-weight: 500; transition: background .15s; }
.cal-grid button:hover:not(:disabled) { background: var(--bg); }
.cal-grid button:disabled { color: #c8c8c8; cursor: default; }
.cal-grid button.today { box-shadow: inset 0 0 0 1px var(--brand-low); color: var(--brand); font-weight: 700; }
.cal-grid button.sel { background: var(--brand); color: #fff; }

/* Arrastar */
.card.ghost { position: fixed; left: 0; top: 0; z-index: 40; pointer-events: none; box-shadow: 0 18px 40px -12px rgba(13, 13, 13, .35); opacity: .95; animation: none !important; }
.card.dragging { opacity: .35; }
body.is-dragging, body.is-dragging * { user-select: none; -webkit-user-select: none; cursor: grabbing !important; }
.board .card { touch-action: pan-x pan-y; -webkit-touch-callout: none; user-select: none; -webkit-user-select: none; }
@media (pointer: fine) { .board .card { cursor: grab; } }

/* Logo TS (monograma do Manual de Marca: branco sobre o roxo esfumado) */
.logo { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; border-radius: 12px; color: #fff; font-weight: 700; letter-spacing: -.04em; font-size: 19px; line-height: 1;
  background: radial-gradient(120% 120% at 100% 100%, #6b3190 0%, #52206f 45%, #2b0f3d 100%); box-shadow: 0 4px 12px -6px rgba(82, 32, 111, .6); }
.logo.big { width: 76px; height: 76px; border-radius: 20px; font-size: 32px; margin-bottom: 14px; }
.logo.sm { width: 40px; height: 40px; border-radius: 50%; font-size: 15px; box-shadow: none; }
.top-row .title { display: flex; align-items: center; gap: 12px; }
.top-row .title h1 { margin: 0; }
.login .logo.big + h1 { margin-top: 0; }

/* Abas com 3 botões */
.seg.three { grid-template-columns: 1fr 1fr 1fr; }
.badge[hidden] { display: none; }

/* ---------- Chat ---------- */
main.chat { padding: 0; }
.chatbox { display: grid; grid-template-columns: 1fr; height: 100%; min-height: 0; }
.chat-side { padding: 14px 16px; overflow-y: auto; }
.chat-title { font-size: 13px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; margin: 0 0 8px; }
.rooms { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--low); border-radius: var(--r); overflow: hidden; }
.room { display: flex; align-items: center; gap: 12px; padding: 11px 12px; text-align: left; border-top: 1px solid var(--low); transition: background .15s; }
.room:first-child { border-top: 0; }
.room:hover { background: var(--bg); }
.room.on { background: var(--brand-lowest); }
.room-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.room-txt b { font-size: 15px; font-weight: 600; }
.room-txt small { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room.unread .room-txt small { color: var(--ink); font-weight: 500; }
.room-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.room-meta time { font-size: 12px; color: var(--muted); }
.room.unread .room-meta time { color: var(--brand); font-weight: 600; }
.thread { display: none; flex-direction: column; min-height: 0; background: var(--surface); }
.chatbox.in-room .chat-side { display: none; }
.chatbox.in-room .thread { display: flex; }
.thread-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--low); }
.thread-head div { display: flex; flex-direction: column; }
.thread-head b { font-size: 15px; }
.thread-head small { color: var(--muted); font-size: 12px; }
.msgs { flex: 1; overflow-y: auto; padding: 14px 12px; display: flex; flex-direction: column; gap: 3px; background: var(--bg); }
.msgs-empty { margin: auto; text-align: center; color: var(--muted); max-width: 260px; font-size: 14px; }
.msgs-empty svg { width: 28px; height: 28px; color: var(--brand); }
.msg-day { text-align: center; margin: 12px 0 6px; }
.msg-day span { font-size: 11px; color: var(--muted); background: var(--surface); border: 1px solid var(--low); border-radius: 99px; padding: 2px 10px; font-weight: 600; }
.msg { display: flex; align-items: flex-end; gap: 6px; max-width: 82%; margin-top: 6px; animation: pop .2s ease-out; }
.msg.cont { margin-top: 0; }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.av-gap { width: 22px; flex: none; }
.bubble { background: var(--surface); border: 1px solid var(--low); border-radius: 14px 14px 14px 4px; padding: 7px 10px 5px; font-size: 15px; line-height: 1.35; position: relative; word-wrap: break-word; min-width: 0; }
.msg.mine .bubble { background: var(--brand); border-color: var(--brand); color: #fff; border-radius: 14px 14px 4px 14px; }
.bubble .from { display: block; font-size: 12px; color: var(--brand); margin-bottom: 1px; }
.bubble time { display: block; text-align: right; font-size: 10px; color: var(--muted); margin-top: 2px; }
.msg.mine .bubble time { color: rgba(255, 255, 255, .7); }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--low); background: var(--surface); }
.composer textarea { flex: 1; border: 1px solid var(--low); border-radius: 20px; padding: 10px 14px; font-size: 16px; resize: none; outline: none; max-height: 140px; line-height: 1.3; background: var(--bg); transition: border-color .15s; }
.composer textarea:focus { border-color: var(--brand); background: var(--surface); }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; flex: none; transition: background .15s, transform .1s; }
.send:hover { background: var(--brand-medium); }
.send:active { transform: scale(.94); }
@media (min-width: 900px) {
  main.chat { padding: 16px 24px 24px; overflow: hidden; }
  .chatbox, .chatbox.in-room { height: 100%; min-height: 0; grid-template-columns: 320px 1fr; border: 1px solid var(--low); border-radius: var(--r); overflow: hidden; background: var(--surface); }
  .chatbox .chat-side, .chatbox.in-room .chat-side { display: block; border-right: 1px solid var(--low); background: var(--bg); }
  .chatbox .thread { display: flex; }
  .thread-head .back { display: none; }
  .seg.three { width: 330px; }
}

/* Chat ocupa a tela toda abaixo do topo */
#app.v-chat { display: flex; flex-direction: column; height: 100dvh; }
#app.v-chat main { flex: 1; min-height: 0; padding-bottom: 0; }
#app.v-chat .banner { display: none; }
@media (max-width: 899px) { #app.v-chat .daynav, #app.v-chat .stats { display: none; } }
.seg button { white-space: nowrap; }
@media (min-width: 900px) { .top-row .seg.three { width: 340px; } }
.composer textarea { scrollbar-width: none; } .composer textarea::-webkit-scrollbar { display: none; }

/* Login agrupado por setor */
.people-groups { width: 100%; max-width: 420px; display: flex; flex-direction: column; }
.group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; font-weight: 600; color: var(--muted); margin: 18px 4px 6px !important; }
.group-label:first-child { margin-top: 0 !important; }

/* Colunas coloridas: fundo clarinho e faixa no topo na cor da etapa */
.col { background: color-mix(in srgb, var(--c) 7%, #f4f4f4); border-color: color-mix(in srgb, var(--c) 18%, var(--low)); border-top: 3px solid var(--c); }
.col header .st-ic { background: var(--c); border-color: var(--c); color: #fff; }
.col header b { color: color-mix(in srgb, var(--c) 70%, var(--ink)); }
.col .count { background: color-mix(in srgb, var(--c) 14%, #fff); border-color: transparent; color: color-mix(in srgb, var(--c) 80%, var(--ink)); }
.col-empty { border-color: color-mix(in srgb, var(--c) 30%, var(--base)); color: color-mix(in srgb, var(--c) 60%, var(--muted)); }
.login p small { font-size: 13px; opacity: .8; }

/* =================== ANIMAÇÕES (02/12) =================== */
:root { --ease: cubic-bezier(.2, .8, .2, 1); --spring: cubic-bezier(.34, 1.56, .64, 1); }

/* Efeito de toque (onda) */
.primary, .person, .keypad button, .seg button, .ghost-btn, .room, .stage-opt > button, .fab, .icon-btn, .day-btn, .who-pick button, .send, .chip, .danger { position: relative; overflow: hidden; isolation: isolate; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .18; transform: scale(0); animation: ripple .6s var(--ease) forwards; z-index: -1; }
.primary .ripple, .fab .ripple, .send .ripple, .danger .ripple, .keypad button:active .ripple { background: #fff; opacity: .35; }
@keyframes ripple { to { transform: scale(1); opacity: 0; } }
button:not(:disabled):active { transform: scale(.97); }
button { transition: transform .12s var(--ease), background-color .2s, border-color .2s, color .2s, box-shadow .2s; }

/* ---------- Entrada (login) ---------- */
.login { padding: 0 0 calc(32px + var(--safe-b)); background: var(--bg); }
.hero { width: 100%; text-align: center; color: #fff; padding: calc(44px + var(--safe-t)) 20px 64px; margin-bottom: -36px;
  background: radial-gradient(130% 120% at 100% 0%, #7a3aa3 0%, #52206f 45%, #2b0f3d 100%); border-radius: 0 0 32px 32px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 80% at 0% 100%, rgba(255, 255, 255, .08), transparent 60%); pointer-events: none; }
.hero .logo.big { background: #fff; color: var(--brand); box-shadow: 0 10px 30px -10px rgba(0, 0, 0, .45); margin-bottom: 14px; animation: logoIn .7s var(--spring) both; }
.hero h1 { font-size: 30px; margin: 0 0 4px; font-weight: 600; letter-spacing: -.03em; animation: up .5s var(--ease) .1s both; }
.hero p { margin: 0; color: rgba(255, 255, 255, .75) !important; font-size: 15px; animation: up .5s var(--ease) .18s both; }
.hero-av { display: inline-block; margin-bottom: 14px; animation: logoIn .6s var(--spring) both; }
.hero-av .av { width: 76px; height: 76px; font-size: 26px; box-shadow: 0 0 0 4px rgba(255, 255, 255, .25), 0 10px 30px -10px rgba(0, 0, 0, .45); }
@keyframes logoIn { from { opacity: 0; transform: scale(.6) rotate(-8deg); } }
@keyframes up { from { opacity: 0; transform: translateY(12px); } }
.step-list .people-groups { padding: 0 16px; position: relative; z-index: 1; }
.people-groups .group-label { color: var(--muted); }
.people-groups .group-label:first-child { color: rgba(255, 255, 255, .8); }
.people-groups > * { animation: up .45s var(--ease) both; animation-delay: calc(.12s + var(--d, 0) * .045s); }
.person { gap: 12px; padding: 11px 12px; }
.person .p-txt { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.person .p-txt small { margin: 0; }
.person > svg { color: var(--base); transition: transform .2s var(--ease), color .2s; }
.person:hover > svg { transform: translateX(3px); color: var(--brand); }
.person.picked { background: var(--brand-lowest); }
.person.picked > svg { animation: spin .8s linear infinite; color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }
.login.busy { pointer-events: none; }
/* Código */
.code-box { position: relative; z-index: 1; background: var(--surface); border: 1px solid var(--low); border-radius: 24px; padding: 26px 20px 18px; margin: 0 16px; width: calc(100% - 32px); max-width: 380px; box-shadow: 0 20px 40px -24px rgba(43, 15, 61, .35); display: flex; flex-direction: column; align-items: center; animation: up .5s var(--ease) .12s both; }
.pin-dots { gap: 18px; margin: 0 0 8px; }
.pin-dots span { width: 16px; height: 16px; border: 2px solid var(--low); background: var(--surface); transition: background .2s, border-color .2s, transform .25s var(--spring); }
.pin-dots span.on { background: var(--brand); border-color: var(--brand); transform: scale(1.15); }
.pin-dots.loading span { animation: wave .8s ease-in-out infinite; }
.pin-dots.loading span:nth-child(2) { animation-delay: .1s; } .pin-dots.loading span:nth-child(3) { animation-delay: .2s; } .pin-dots.loading span:nth-child(4) { animation-delay: .3s; }
.pin-dots.success span { background: var(--ok); border-color: var(--ok); transform: scale(1.25); transition-delay: calc(var(--i, 0) * 40ms); }
.pin-dots.error { animation: shake .45s; }
.pin-dots.error span { background: var(--danger); border-color: var(--danger); }
@keyframes wave { 50% { transform: translateY(-7px) scale(1.1); } }
.code-hint { font-size: 12px; color: var(--muted); margin: 6px 0 18px !important; }
.keypad { grid-template-columns: repeat(3, 72px); gap: 14px 22px; }
.keypad button { width: 72px; height: 72px; border-radius: 50%; font-size: 28px; font-weight: 400; box-shadow: none; background: var(--bg); border: 1px solid var(--low); animation: keyIn .4s var(--spring) both; animation-delay: calc(.2s + var(--d, 0) * .025s); }
.keypad button:hover { border-color: var(--brand-low); }
.keypad button:active { background: var(--brand); color: #fff; border-color: var(--brand); transform: scale(.92); }
.keypad button.ghost { background: none; border-color: transparent; color: var(--muted); }
.keypad button.ghost.txt { font-size: 14px; font-weight: 500; }
.keypad button.ghost:active { background: var(--bg); color: var(--ink); }
@keyframes keyIn { from { opacity: 0; transform: scale(.7); } }

/* ---------- Abas: pílula que desliza ---------- */
.seg { position: relative; }
.seg-pill { position: absolute; top: 0; bottom: 0; left: 0; width: calc(100% / 3); background: var(--brand-lowest); box-shadow: inset 0 0 0 1px var(--brand-low); transform: translateX(calc(var(--i, 0) * 100%)); transition: transform .35s var(--spring); view-transition-name: seg-pill; z-index: 0; }
.seg button { position: relative; z-index: 1; background: none !important; }
.seg button + button { border-left: 0; }
.seg button.on { color: var(--brand); }

/* ---------- Trocas de tela (View Transitions) ---------- */
.top { view-transition-name: topo; }
.fab { view-transition-name: fab; }
::view-transition-group(*) { animation-duration: .38s; animation-timing-function: var(--ease); }
::view-transition-old(root) { animation: .22s var(--ease) both vtOut; }
::view-transition-new(root) { animation: .32s var(--ease) both vtIn; }
html[data-dir="fwd"]::view-transition-old(root) { animation-name: vtOutL; }
html[data-dir="fwd"]::view-transition-new(root) { animation-name: vtInR; }
html[data-dir="back"]::view-transition-old(root) { animation-name: vtOutR; }
html[data-dir="back"]::view-transition-new(root) { animation-name: vtInL; }
html[data-dir="move"]::view-transition-old(root), html[data-dir="move"]::view-transition-new(root) { animation: none; }
html[data-dir="enter"]::view-transition-new(root) { animation: .5s var(--ease) both vtEnter; }
::view-transition-old(topo), ::view-transition-new(topo) { animation: none; mix-blend-mode: normal; }
@keyframes vtOut { to { opacity: 0; } }
@keyframes vtIn { from { opacity: 0; transform: translateY(8px); } }
@keyframes vtOutL { to { opacity: 0; transform: translateX(-28px); } }
@keyframes vtInR { from { opacity: 0; transform: translateX(28px); } }
@keyframes vtOutR { to { opacity: 0; transform: translateX(28px); } }
@keyframes vtInL { from { opacity: 0; transform: translateX(-28px); } }
@keyframes vtEnter { from { opacity: 0; transform: scale(.98); } }
/* Navegador sem View Transitions: anima a entrada do conteúdo */
@supports not (view-transition-name: a) {
  main { animation: vtIn .3s var(--ease) both; }
}

/* Entrada no app: topo desce, colunas e cards em cascata */
body.entering .top { animation: down .45s var(--ease) both; }
body.entering .col { animation: up .45s var(--ease) both; }
body.entering .col:nth-child(2) { animation-delay: .04s; } body.entering .col:nth-child(3) { animation-delay: .08s; } body.entering .col:nth-child(4) { animation-delay: .12s; }
body.entering .col:nth-child(5) { animation-delay: .16s; } body.entering .col:nth-child(6) { animation-delay: .2s; } body.entering .col:nth-child(7) { animation-delay: .24s; } body.entering .col:nth-child(8) { animation-delay: .28s; }
body.entering .mine-item, body.entering .room { animation: up .4s var(--ease) both; }
@keyframes down { from { opacity: 0; transform: translateY(-14px); } }
.card.new { animation: cardIn .4s var(--spring) both; animation-delay: calc(var(--d, 0) * 40ms); }
@keyframes cardIn { from { opacity: 0; transform: translateY(10px) scale(.97); } }
.mine-item { animation: up .35s var(--ease) both; }

/* Folhas: conteúdo entra em cascata */
#sheet-root.open .sheet > * { animation: up .35s var(--ease) both; }
#sheet-root.open .sheet > *:nth-child(2) { animation-delay: .03s; } #sheet-root.open .sheet > *:nth-child(3) { animation-delay: .06s; }
#sheet-root.open .sheet > *:nth-child(4) { animation-delay: .09s; } #sheet-root.open .sheet > *:nth-child(5) { animation-delay: .12s; }
#sheet-root.open .sheet > *:nth-child(n+6) { animation-delay: .15s; }
.stage-opt { animation: up .3s var(--ease) both; }
.stage-opt:nth-child(2) { animation-delay: .03s; } .stage-opt:nth-child(3) { animation-delay: .06s; } .stage-opt:nth-child(4) { animation-delay: .09s; }
.stage-opt:nth-child(5) { animation-delay: .12s; } .stage-opt:nth-child(6) { animation-delay: .15s; } .stage-opt:nth-child(7) { animation-delay: .18s; } .stage-opt:nth-child(8) { animation-delay: .21s; }
.who-pick button { animation: keyIn .3s var(--spring) both; }

/* Badge pulsa quando aparece */
.badge:not([hidden]) { animation: pop2 .4s var(--spring); }
@keyframes pop2 { from { transform: scale(.4); } }
.fab { animation: fabIn .5s var(--spring) .2s both; }
@keyframes fabIn { from { transform: translateY(30px) scale(.8); opacity: 0; } }
.fab:hover { transform: translateY(-2px); box-shadow: 0 14px 30px -10px rgba(82, 32, 111, .6); }
.card:hover { transform: translateY(-1px); box-shadow: 0 6px 16px -8px rgba(13, 13, 13, .18); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-delay: 0s !important; transition-duration: .01ms !important; }
}
@media (min-width: 700px) { .hero { border-radius: 0 0 40px 40px; } }
.login > * { flex: none; }
#app:has(> .login) { display: block !important; height: auto !important; }
