:root {
  --bg: #faf9fa;
  --surface: #fff;
  --text: #593f52;
  --muted: #715e6b;
  --border: #ede8eb;
  --primary: #63455b;
  --primary-hover: #593f52;
  --radius: 16px;
  --sombra: 0 2px 8px rgb(99 69 91 / 7%);
}
body { font-family: "Bahnschrift", "Trebuchet MS", sans-serif; }
input, textarea, select, button { font-family: inherit; }
h1, h2, h3 { letter-spacing: -.02em; }
.auth-wrapper { background: radial-gradient(ellipse at top left, #fceae9, transparent 58%), var(--bg); }
.auth-card, .card, .operacao-table, .board-col, .modal-card { border-radius: 16px; }
.card, .operacao-table, .topbar { box-shadow: var(--sombra); }
.auth-card { box-shadow: 0 12px 36px rgb(99 69 91 / 10%); }
.auth-links { margin-top: 14px; }
.brand-badge { background: #fceae9; color: #593f52; border-radius: 8px; padding: 5px 10px; }
.btn, .tab-btn, input, textarea, select { border-radius: 10px; }
select, select.ticket-menu {
  border-radius: 16px;
  appearance: none;
  cursor: pointer;
  padding-right: 31px;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m3 5 4 4 4-4' fill='none' stroke='%2363455b' stroke-width='1.7' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 10px center;
}
select.ticket-menu { background-color: #f0edef; border-color: #b6a5b1; min-height: 30px; }
@supports (appearance: base-select) and selector(::picker(select)) {
  select, select.ticket-menu, ::picker(select) { appearance: base-select; }
  select, select.ticket-menu { background-image: none; padding-inline-end: 12px; align-items: center; }
  select::picker-icon { color: var(--primary); }
  ::picker(select) {
    margin-block: 4px;
    padding: 5px;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    color: var(--text);
    box-shadow: 0 8px 24px rgb(99 69 91 / 14%);
    overflow: auto;
  }
  select option { padding: 7px 12px; border-radius: 11px; }
  select option:checked { background: #fceae9; color: #593f52; }
  select option:enabled:is(:hover, :focus-visible) { background: #f0edef; }
}
select:hover, .btn-outline:hover { border-color: #b6a5b1; }
:is(button, a, input, select, textarea):focus-visible { outline: 3px solid #826a7c; outline-offset: 2px; }
.ticket-card, .operacao-sala-opcao { border-radius: 12px; }
.board-col { background: #f0edef; }
.col-abertura, [data-estado="ABERTURA_FICHA"] { --tom: #f0edef; --tinta: #63455b; }
.col-aguardando, [data-estado="AGUARDANDO_ATENDIMENTO"] { --tom: #f7e2da; --tinta: #754f42; }
.col-medico, [data-estado="EM_ATENDIMENTO"] { --tom: #e7dce5; --tinta: #684b60; }
.col-enfermagem, [data-estado="FINALIZADO"], [data-estado="DISPONIVEL"] { --tom: #f0edef; --tinta: #63455b; }
[data-estado="DEVOLVIDA_RECEPCAO"] { --tom: #fceae9; --tinta: #834327; }
[data-estado="CANCELADO"] { --tom: #fae2e4; --tinta: #873f4b; }
[data-estado="LIVRE"] { --tom: #f0edef; --tinta: #715e6b; }
.board-col-header, .estado { background-color: var(--tom); color: var(--tinta); }
.estado { display: inline-block; border-radius: 8px; padding: 3px 9px; font-size: .83rem; font-weight: 600; }
.estado + .small { margin-top: 4px; }
.operacao-card-sala { border-top: 3px solid var(--tinta); }
.operacao-card-sala .estado { margin-top: 6px; }
.operacao-table thead th { background: #f0edef; color: #593f52; }
.operacao-table tbody th { background: transparent; }
.operacao-table tbody tr:hover { background: #faf9fa; }
.operacao-vazio { background: transparent; border: 1px dashed var(--border); box-shadow: none; }
.modal-card { padding: clamp(16px, 3vw, 26px); box-shadow: 0 24px 72px rgb(99 69 91 / 24%); }
.modal-backdrop, .operacao-dialogo::backdrop { background: rgb(99 69 91 / 45%); backdrop-filter: blur(3px); }
.modal-header { padding-bottom: 12px; border-bottom: 1px solid var(--border); }
.modal-footer { flex-wrap: wrap; padding-top: 14px; border-top: 1px solid var(--border); margin-top: 18px; }
.operacao-sala-opcao:has(input:checked) { background: #fceae9; box-shadow: inset 0 0 0 1px var(--primary); }
@media (forced-colors: active) { select, select.ticket-menu { appearance: auto; } }
.operacao-topbar { background: #63455b; color: #fff; }
.operacao-topbar .brand-badge { background: transparent; color: #fff; letter-spacing: .08em; }
#visao-geral h1 { font-size: clamp(1.5rem, 3vw, 2rem); }
#visao-geral h2 { font-size: .92rem; color: var(--muted); font-weight: 500; }
#cards-salas .operacao-card-sala { padding: 18px; border-top: 1px solid var(--border); }
#cards-salas .operacao-card-sala h3 { font-size: 1.1rem; }
.fila-resumo summary { cursor: pointer; font-weight: 600; }
.fila-resumo summary:focus-visible { outline: 3px solid #826a7c; outline-offset: 3px; }
.fila-resumo[open] summary { margin-bottom: 14px; }
.total-fichas { background: #fceae9; color: #593f52; border-radius: 8px; padding: 2px 8px; }
#lista-encerradas table { table-layout: fixed; min-width: 740px; }
#lista-encerradas th:first-child { width: 28%; }
#lista-encerradas tbody th { overflow: hidden; text-overflow: ellipsis; }
#lista-encerradas :is(th, td) { white-space: nowrap; vertical-align: middle; padding-block: 6px; }
.estado-com-obs { border: 0; cursor: help; }
#obs-encerramento { position: fixed; z-index: 45; width: min(280px, calc(100vw - 16px)); max-height: 42vh; overflow: auto; padding: 10px 12px; border-radius: 10px; background: #593f52; color: white; box-shadow: var(--sombra); white-space: pre-wrap; overflow-wrap: anywhere; }

/* A hierarquia permanece legível mesmo quando as animações estão desligadas. */
.auth-card { border-top: 4px solid #826a7c; }
.auth-form .btn-primary { margin-top: 4px; }
.tab-btn.active { box-shadow: inset 0 -3px 0 #f5b8b4; }
.modal-footer { background: linear-gradient(180deg, transparent, #faf9fa); }
.operacao-historico li::marker { color: #63455b; font-weight: 600; }
.operacao-historico li { border-inline-start: 2px solid #ede8eb; padding-inline-start: 10px; }
.toast { box-shadow: 0 8px 24px rgb(99 69 91 / 18%); border-radius: 12px; }
.toast.toast-error { background: #813f4a; }
.toast.toast-success { background: #63455b; }

@keyframes aparecer-painel {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes abrir-modal {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes revelar-fundo { from { opacity: 0; } to { opacity: 1; } }
@keyframes realcar-ficha { from { background-color: #fceae9; } }
@media (prefers-reduced-motion: no-preference) {
  .auth-card, #operacao:not([hidden]), #tab-admin:not(.hidden), #tab-painel:not(.hidden),
  .fila-resumo[open] > :not(summary), .toast { animation: aparecer-painel 200ms ease-out; }
  dialog[open].modal-card, .modal-backdrop:not(.hidden) .modal-card { animation: abrir-modal 180ms ease-out; }
  dialog[open]::backdrop, .modal-backdrop:not(.hidden) { animation: revelar-fundo 150ms ease-out; }
  .ficha-movimentada.operacao-card-sala, tr.ficha-movimentada > * { animation: realcar-ficha 1.1s ease-out; }
  .btn, .tab-btn, select, .operacao-sala-opcao {
    transition: background-color 140ms, border-color 140ms, box-shadow 140ms, transform 140ms;
  }
  .btn:active:not(:disabled), .tab-btn:active { transform: translateY(1px); }
  @media (hover: hover) {
    .btn-primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 3px 8px rgb(99 69 91 / 18%); }
    .operacao-sala-opcao:hover:has(input:enabled) { transform: translateY(-2px); border-color: #b6a5b1; }
  }
}
@media (prefers-reduced-motion: reduce) {
  .btn, .tab-btn, select, .operacao-sala-opcao { transition: none; }
}

.topbar { background: var(--primary); color: white; }
.topbar .topbar-sub, .topbar .topbar-center label { color: #f0edef; }
.topbar .btn-ghost { color: white; }
.topbar .btn-ghost:hover { background: #593f52; }
input[type="radio"], input[type="checkbox"] { accent-color: var(--primary); }
a:not([class]), .btn-link { color: var(--primary); }
.topbar .tab-btn.active { background: #fceae9; color: #593f52; }
::selection { background: #ead4df; color: #493043; }
