:root {
  --fundo: #140d1b;
  --fundo-2: #1b1224;
  --superficie: #22172e;
  --superficie-2: #2c1f3a;
  --borda: #3d2c50;
  --texto: #f3ecf9;
  --texto-2: #bfaed2;
  --texto-3: #8f7ca5;
  --lilas: #c9a9e8;
  --lilas-forte: #b48ae0;
  --roxo: #7a4bb3;
  --roxo-escuro: #401e50;
  --ok: #86d9ae;
  --alerta: #f2c97d;
  --erro: #f3909f;
  --raio: 16px;
  --sombra: 0 10px 30px rgba(0, 0, 0, .35);
  --seguro-baixo: env(safe-area-inset-bottom, 0px);
  --seguro-topo: env(safe-area-inset-top, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100dvh;
  background: radial-gradient(1200px 600px at 50% -200px, #2b1a3b 0%, var(--fundo) 60%) fixed, var(--fundo);
  color: var(--texto);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--lilas); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; color: var(--texto-2); font-weight: 600; }
.mudo { color: var(--texto-2); }
.fraco { color: var(--texto-3); font-size: .875rem; }
.num { font-variant-numeric: tabular-nums; }
[hidden] { display: none !important; }

.carregando { min-height: 100dvh; display: grid; place-items: center; }
.carregando img { opacity: .9; animation: pulsa 1.6s ease-in-out infinite; }
@keyframes pulsa { 50% { opacity: .45; } }

/* ---------- estrutura ---------- */
.casca { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
.lateral { display: none; }
.principal { padding: calc(var(--seguro-topo) + 12px) 16px calc(96px + var(--seguro-baixo)); max-width: 760px; width: 100%; margin: 0 auto; }
.topo { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.topo .marca { height: 44px; width: auto; }
.topo .usuario { font-size: .8rem; color: var(--texto-3); text-align: right; }

.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(20, 13, 27, .92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--borda);
  padding: 6px 4px calc(6px + var(--seguro-baixo));
}
.abas a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  text-decoration: none; color: var(--texto-3); font-size: .7rem; padding: 6px 0; border-radius: 12px;
}
.abas a svg { width: 24px; height: 24px; }
.abas a.ativa { color: var(--lilas); }

@media (min-width: 900px) {
  .casca { grid-template-columns: 240px 1fr; }
  .abas { display: none; }
  .lateral {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh;
    padding: 24px 16px; border-right: 1px solid var(--borda); background: rgba(27, 18, 36, .6);
  }
  .lateral img { width: 150px; margin: 0 auto 24px; display: block; }
  .lateral a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--texto-2); text-decoration: none; }
  .lateral a svg { width: 20px; height: 20px; }
  .lateral a:hover { background: var(--superficie); }
  .lateral a.ativa { background: var(--superficie-2); color: var(--lilas); }
  .lateral .rodape { margin-top: auto; font-size: .8rem; color: var(--texto-3); }
  .principal { padding: 32px 32px 48px; }
  .topo .marca { display: none; }
}

/* ---------- componentes ---------- */
.cartao { background: var(--superficie); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; margin-bottom: 14px; }
.cartao.destaque { background: linear-gradient(160deg, #3a2150 0%, #24172f 70%); border-color: #563a73; }
.cartao > h2, .cartao > h3 { margin-bottom: 10px; }
.linha { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pilha > * + * { margin-top: 10px; }
.grade-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grade-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 380px) { .grade-3 { grid-template-columns: 1fr 1fr; } }

.metrica { background: var(--fundo-2); border: 1px solid var(--borda); border-radius: 14px; padding: 12px; }
.metrica .rotulo { font-size: .75rem; color: var(--texto-3); text-transform: uppercase; letter-spacing: .04em; }
.metrica .valor { font-size: 1.35rem; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metrica .sub { font-size: .8rem; color: var(--texto-2); }

.barra { height: 10px; border-radius: 99px; background: var(--fundo-2); border: 1px solid var(--borda); overflow: hidden; }
.barra > i { display: block; height: 100%; background: linear-gradient(90deg, var(--roxo), var(--lilas)); border-radius: 99px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--borda);
  background: var(--superficie-2); color: var(--texto); cursor: pointer; text-decoration: none; font-weight: 600;
  -webkit-tap-highlight-color: transparent; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: #352648; }
.btn.primario { background: linear-gradient(180deg, #9a6bd4, var(--roxo)); border-color: #9a6bd4; color: #fff; }
.btn.primario:hover { background: linear-gradient(180deg, #a77ade, #8352c0); }
.btn.perigo { color: var(--erro); }
.btn.fantasma { background: transparent; }
.btn.pequeno { min-height: 34px; padding: 6px 12px; font-size: .875rem; border-radius: 10px; }
.btn.largo { width: 100%; }
.btn.grande { min-height: 64px; font-size: 1.15rem; border-radius: 18px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.botoes { display: flex; flex-wrap: wrap; gap: 8px; }

.ponto { text-align: center; }
.ponto .relogio { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.ponto .estado { color: var(--texto-2); margin-bottom: 14px; }
.ponto .botoes { justify-content: center; }
.ponto .botoes .btn { flex: 1 1 140px; }

label.campo { display: block; }
label.campo > span { display: block; font-size: .8rem; color: var(--texto-2); margin-bottom: 4px; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--borda); background: var(--fundo-2); outline: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--lilas-forte); box-shadow: 0 0 0 3px rgba(180, 138, 224, .2); }
input[type="date"], input[type="time"] { -webkit-appearance: none; appearance: none; min-width: 0; }
textarea { min-height: 90px; resize: vertical; }
.segmento { display: grid; grid-template-columns: 1fr 1fr; background: var(--fundo-2); border: 1px solid var(--borda); border-radius: 12px; padding: 3px; }
.segmento label { text-align: center; padding: 8px; border-radius: 9px; cursor: pointer; color: var(--texto-2); font-size: .9rem; }
.segmento input { display: none; }
.segmento label:has(input:checked) { background: var(--superficie-2); color: var(--lilas); }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 4px; border-bottom: 1px solid var(--borda); }
.lista li:last-child { border-bottom: 0; }
.lista .dia { width: 48px; text-align: center; background: var(--fundo-2); border: 1px solid var(--borda); border-radius: 12px; padding: 6px 0; line-height: 1.1; }
.lista .dia b { display: block; font-size: 1.15rem; }
.lista .dia small { font-size: .65rem; color: var(--texto-3); text-transform: uppercase; }
.lista .det { min-width: 0; }
.lista .det .h { font-variant-numeric: tabular-nums; }
.lista .det .o { font-size: .8rem; color: var(--texto-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lista .tot { font-weight: 650; font-variant-numeric: tabular-nums; text-align: right; }
.lista li.clicavel { cursor: pointer; }
.lista li.clicavel:hover { background: rgba(255, 255, 255, .02); }

.selo { display: inline-block; font-size: .72rem; padding: 2px 8px; border-radius: 99px; border: 1px solid var(--borda); color: var(--texto-2); white-space: nowrap; }
.selo.ok { color: var(--ok); border-color: rgba(134, 217, 174, .4); }
.selo.alerta { color: var(--alerta); border-color: rgba(242, 201, 125, .4); }
.selo.lilas { color: var(--lilas); border-color: rgba(201, 169, 232, .4); }

.faixa { border-radius: 12px; padding: 10px 12px; font-size: .875rem; margin-bottom: 14px; border: 1px solid; }
.faixa.alerta { background: rgba(242, 201, 125, .08); border-color: rgba(242, 201, 125, .35); color: #f6dcaa; }
.faixa.info { background: rgba(201, 169, 232, .08); border-color: rgba(201, 169, 232, .3); color: var(--texto-2); }

.seletor-periodo { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.seletor-periodo select { flex: 1; }

.tabela-dados { width: 100%; border-collapse: collapse; font-size: .9rem; }
.tabela-dados td { padding: 7px 0; border-bottom: 1px solid var(--borda); vertical-align: top; }
.tabela-dados td:last-child { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.tabela-dados tr.total td { border-bottom: 0; font-size: 1.05rem; color: var(--lilas); padding-top: 10px; }

.copiavel { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--borda); }
.copiavel:last-child { border-bottom: 0; }
.copiavel .r { font-size: .75rem; color: var(--texto-3); text-transform: uppercase; letter-spacing: .03em; }
.copiavel .v { word-break: break-word; white-space: pre-wrap; }
.texto-modelo { white-space: pre-wrap; background: var(--fundo-2); border: 1px solid var(--borda); border-radius: 12px; padding: 12px; font-size: .9rem; max-height: 360px; overflow: auto; }
ol.passos { padding-left: 20px; margin: 0; }
ol.passos li { margin-bottom: 8px; color: var(--texto-2); }
ol.passos li b { color: var(--texto); }
.etapas { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

.fab {
  position: fixed; right: 18px; bottom: calc(84px + var(--seguro-baixo)); z-index: 15;
  width: 58px; height: 58px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: linear-gradient(180deg, #9a6bd4, var(--roxo)); color: #fff; box-shadow: var(--sombra); cursor: pointer;
}
.fab svg { width: 28px; height: 28px; }
@media (min-width: 900px) { .fab { bottom: 32px; right: 32px; } }

dialog {
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); overflow: auto;
  background: var(--superficie); color: var(--texto); border: 1px solid var(--borda); border-radius: 20px; padding: 20px; box-shadow: var(--sombra);
}
dialog::backdrop { background: rgba(8, 4, 12, .7); backdrop-filter: blur(3px); }
dialog h2 { margin-bottom: 14px; }
dialog .acoes { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
dialog .acoes .esq { margin-right: auto; }

#aviso {
  position: fixed; left: 50%; bottom: calc(90px + var(--seguro-baixo)); transform: translate(-50%, 20px);
  background: #3a2650; color: var(--texto); border: 1px solid #5a3f78; padding: 10px 16px; border-radius: 12px;
  box-shadow: var(--sombra); opacity: 0; pointer-events: none; transition: all .2s; z-index: 50; max-width: calc(100vw - 32px); text-align: center;
}
#aviso.visivel { opacity: 1; transform: translate(-50%, 0); }
#aviso.erro { background: #4a2230; border-color: #7a3a4d; }

.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.login .caixa { width: 100%; max-width: 380px; }
.login img { width: 220px; display: block; margin: 0 auto 28px; }
.vazio { text-align: center; padding: 28px 8px; color: var(--texto-3); }
hr.sep { border: 0; border-top: 1px solid var(--borda); margin: 16px 0; }
details > summary { cursor: pointer; color: var(--texto-2); }
