:root {
  --tinta: #1A1E40;
  --cobre: #C98672;
  --cobre-forte: #D99A85;
  --creme: #F5F1EA;

  --fundo: #0E1128;
  --fundo-2: #141836;
  --superficie: rgba(255, 255, 255, 0.045);
  --superficie-2: rgba(255, 255, 255, 0.075);
  --linha: rgba(245, 241, 234, 0.09);
  --texto: #F5F1EA;
  --texto-2: rgba(245, 241, 234, 0.72);
  --texto-3: rgba(245, 241, 234, 0.5);
  --sombra: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 18px 40px -24px rgba(0, 0, 0, 0.7);

  --urgente: #F06A5E;
  --importante: #D99A85;
  --info: #8FA3D9;
  --ok: #5CC995;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --raio: 20px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --fundo: #F5F1EA;
    --fundo-2: #EDE6DA;
    --superficie: rgba(255, 255, 255, 0.72);
    --superficie-2: #FFFFFF;
    --linha: rgba(26, 30, 64, 0.1);
    --texto: #1A1E40;
    --texto-2: rgba(26, 30, 64, 0.74);
    --texto-3: rgba(26, 30, 64, 0.52);
    --sombra: 0 1px 0 rgba(255, 255, 255, 0.8) inset, 0 16px 36px -22px rgba(26, 30, 64, 0.35);
    --urgente: #C8372C;
    --importante: #A8604B;
    --info: #42579A;
    --ok: #1F8A57;
    --cobre-forte: #A8604B;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh; background: var(--fundo); color: var(--texto);
  font: 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.fundo {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(120% 60% at 100% -10%, rgba(201, 134, 114, 0.16), transparent 60%),
    radial-gradient(90% 50% at -10% 10%, rgba(76, 88, 170, 0.18), transparent 60%),
    linear-gradient(var(--fundo), var(--fundo-2));
}
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* topo */
.topo {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; max-width: 640px; margin: 0 auto;
  backdrop-filter: blur(16px) saturate(140%); -webkit-backdrop-filter: blur(16px) saturate(140%);
  background: color-mix(in srgb, var(--fundo) 72%, transparent);
  border-bottom: 1px solid transparent; transition: border-color .3s;
}
.topo.com-linha { border-bottom-color: var(--linha); }
.emblema { border-radius: 50%; }
.marca { display: flex; flex-direction: column; line-height: 1.1; }
.marca-nome { font: 600 19px/1.1 var(--serif); letter-spacing: .01em; }
.marca-sub { font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--cobre-forte); margin-top: 3px; }
.estado-pill {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px; min-height: 36px;
  padding: 0 14px; border-radius: 999px; border: 1px solid var(--linha); background: var(--superficie);
  color: var(--texto-2); font: 500 13px var(--sans); cursor: pointer;
}
.ponto { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 0 currentColor; }
.estado-pill.alerta .ponto { background: var(--urgente); animation: pulsar 1.8s infinite; color: var(--urgente); }
@keyframes pulsar { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 60%, transparent); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

main { max-width: 640px; margin: 0 auto; padding: 6px 18px 48px; }

/* boas vindas */
.cartao-boas-vindas { text-align: center; padding: 48px 8px 24px; }
.emblema-grande { border-radius: 50%; box-shadow: 0 20px 50px -18px rgba(201, 134, 114, .55); }
.cartao-boas-vindas h1 { font: 500 30px/1.15 var(--serif); margin: 26px 0 12px; letter-spacing: -.01em; }
.cartao-boas-vindas p { color: var(--texto-2); margin: 0 auto 26px; max-width: 34ch; }
#form-emparelhar { display: flex; flex-direction: column; gap: 12px; max-width: 320px; margin: 0 auto; }
#codigo {
  font: 600 24px/1 ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .32em; text-align: center;
  padding: 16px 12px; border-radius: 16px; border: 1px solid var(--linha); background: var(--superficie); color: var(--texto);
}
#codigo:focus { outline: 2px solid var(--cobre); outline-offset: 2px; }

/* resumo */
.resumo { padding: 22px 2px 8px; }
.resumo-sobre { margin: 0; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; color: var(--cobre-forte); }
.resumo-titulo { font: 500 34px/1.1 var(--serif); margin: 8px 0 6px; letter-spacing: -.015em; }
.resumo-sub { margin: 0; color: var(--texto-3); font-size: 14px; }

.faixa-notif {
  display: flex; gap: 14px; align-items: center; justify-content: space-between; margin: 18px 0 4px; padding: 16px;
  border-radius: var(--raio); background: linear-gradient(135deg, rgba(201, 134, 114, .22), rgba(201, 134, 114, .06));
  border: 1px solid rgba(201, 134, 114, .35);
}
.faixa-notif strong { display: block; font-size: 15px; }
.faixa-notif span { display: block; font-size: 13px; color: var(--texto-2); }

.seccao {
  display: flex; align-items: center; gap: 8px; margin: 30px 2px 12px; font: 600 12px var(--sans);
  letter-spacing: .16em; text-transform: uppercase; color: var(--texto-3);
}
.contador { color: var(--cobre-forte); letter-spacing: 0; }

/* sistemas */
.grelha { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tile {
  padding: 14px 14px 13px; border-radius: 18px; background: var(--superficie); border: 1px solid var(--linha);
  box-shadow: var(--sombra); min-height: 86px; display: flex; flex-direction: column; gap: 6px;
}
.tile-topo { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--texto-2); }
.tile-topo .ponto { flex: none; }
.tile.mal .ponto { background: var(--urgente); color: var(--urgente); animation: pulsar 1.8s infinite; }
.tile.aviso .ponto { background: var(--importante); }
.tile.neutro .ponto { background: var(--texto-3); }
.tile-valor { font: 500 17px/1.2 var(--serif); }
.tile-det { font-size: 12px; color: var(--texto-3); }

/* avisos */
.lista { display: flex; flex-direction: column; gap: 12px; }
.lista.compacta { gap: 8px; }
.vazio {
  padding: 22px 18px; border-radius: var(--raio); border: 1px dashed var(--linha); color: var(--texto-3);
  text-align: center; font-size: 14px;
}
.aviso {
  position: relative; padding: 18px 18px 16px 20px; border-radius: var(--raio); background: var(--superficie);
  border: 1px solid var(--linha); box-shadow: var(--sombra); overflow: hidden;
}
.aviso::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--cor); }
.aviso.urgente { --cor: var(--urgente); background: linear-gradient(160deg, color-mix(in srgb, var(--urgente) 12%, transparent), var(--superficie) 55%); }
.aviso.importante { --cor: var(--importante); }
.aviso.info { --cor: var(--info); }
.aviso.realce { animation: realce 1.6s ease; }
@keyframes realce { 0%, 40% { box-shadow: 0 0 0 2px var(--cobre); } 100% { box-shadow: var(--sombra); } }
.aviso-cab { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--texto-3); }
.etiqueta { font-weight: 600; letter-spacing: .08em; text-transform: uppercase; font-size: 11px; color: var(--cor); }
.aviso h3 { margin: 6px 0 4px; font: 500 19px/1.25 var(--serif); }
.aviso p { margin: 0; color: var(--texto-2); font-size: 14px; }
.acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

/* botões */
.botao {
  -webkit-tap-highlight-color: transparent; appearance: none; border: 1px solid var(--linha); background: var(--superficie-2);
  color: var(--texto); min-height: 44px; padding: 0 16px; border-radius: 14px; font: 600 14px var(--sans); cursor: pointer;
  transition: transform .12s ease, background .2s, opacity .2s;
}
.botao:active { transform: scale(.97); }
.botao:focus-visible { outline: 2px solid var(--cobre); outline-offset: 2px; }
.botao.primario { background: linear-gradient(180deg, #D49480, #B9725E); border-color: transparent; color: #1A1E40; }
.botao.discreto { background: transparent; color: var(--texto-2); }
.botao[disabled] { opacity: .55; pointer-events: none; }
.botao.ocupado::after { content: ""; display: inline-block; width: 12px; height: 12px; margin-left: 8px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: rodar .7s linear infinite; vertical-align: -2px; }
@keyframes rodar { to { transform: rotate(360deg); } }

/* pedidos */
.pedido { display: flex; gap: 10px; align-items: flex-end; padding: 10px; border-radius: var(--raio); background: var(--superficie); border: 1px solid var(--linha); box-shadow: var(--sombra); }
.pedido textarea {
  flex: 1; resize: none; border: 0; background: transparent; color: var(--texto); font: 15px/1.45 var(--sans);
  padding: 10px 8px; min-height: 44px; max-height: 160px;
}
.pedido textarea:focus { outline: none; }
.pedido textarea::placeholder { color: var(--texto-3); }
#pedidos { margin-top: 10px; }
.linha-pedido { padding: 12px 14px; border-radius: 14px; background: var(--superficie); border: 1px solid var(--linha); font-size: 14px; }
.linha-pedido .cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.linha-pedido .titulo { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.linha-pedido .res { margin: 6px 0 0; color: var(--texto-2); font-size: 13px; white-space: pre-wrap; }
.chip { flex: none; font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; padding: 4px 9px; border-radius: 999px; background: var(--superficie-2); color: var(--texto-2); }
.chip.feito { color: var(--ok); }
.chip.falhou { color: var(--urgente); }
.chip.atratar { color: var(--cobre-forte); }
.chip.atratar::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: currentColor; margin-right: 6px; animation: pulsar 1.4s infinite; vertical-align: 1px; }

.historico summary { cursor: pointer; list-style: none; }
.historico summary::-webkit-details-marker { display: none; }
.historico summary::after { content: "+"; margin-left: auto; font-size: 16px; color: var(--texto-3); }
.historico[open] summary::after { content: "−"; }
.resolvido { padding: 12px 14px; border-radius: 14px; border: 1px solid var(--linha); font-size: 14px; color: var(--texto-2); }
.resolvido small { display: block; color: var(--texto-3); font-size: 12px; }

.rodape { margin-top: 36px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.nota { color: var(--texto-3); font-size: 12px; text-align: center; margin: 8px 0 0; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translate(-50%, 30px); opacity: 0;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px; background: var(--creme); color: var(--tinta);
  font: 600 14px var(--sans); box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .6); transition: transform .35s cubic-bezier(.2, .9, .3, 1.2), opacity .25s; pointer-events: none; z-index: 20;
}
.toast.ver { transform: translate(-50%, 0); opacity: 1; }

/* entrada */
.entra { animation: entrar .6s cubic-bezier(.2, .8, .2, 1) both; animation-delay: var(--atraso, 0ms); }
@keyframes entrar { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

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