:root {
  --mar: #0b6e8a;
  --mar-esc: #074e63;
  --agua: #19a7c2;
  --areia: #f6ecd9;
  --areia-esc: #e8d6b3;
  --coral: #f06b4f;
  --sol: #f7b733;
  --verde: #22a06b;
  --texto: #17313b;
  --muted: #6b8089;
  --bg: #f7f9fa;
  --card: #ffffff;
  --borda: #e3e9ec;
  --raio: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* Topo */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(120deg, var(--mar-esc), var(--mar) 60%, var(--agua));
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 26px; }
.brand small { display: block; opacity: .8; font-size: 12px; }
.roles { display: flex; gap: 4px; background: rgba(255,255,255,.12); padding: 4px; border-radius: 999px; overflow-x: auto; }
.roles button {
  border: 0; background: transparent; color: #fff; padding: 7px 14px; border-radius: 999px; white-space: nowrap; font-size: 14px;
}
.roles button.active { background: #fff; color: var(--mar-esc); font-weight: 600; }

/* Faixa de cobrança */
.banner { padding: 10px 16px; font-weight: 600; text-align: center; }
.banner.aviso { background: #fff4d6; color: #8a5a00; }
.banner.carencia { background: #ffe1da; color: #a12d14; }

/* Layout */
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.card { background: var(--card); border: 1px solid var(--borda); border-radius: var(--raio); padding: 16px; }
.card h3 { margin: 0 0 12px; font-size: 16px; }
.row { display: flex; align-items: center; gap: 8px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
h2 { margin: 4px 0 14px; }

.kpi .label { color: var(--muted); font-size: 13px; }
.kpi .valor { font-size: 26px; font-weight: 700; margin-top: 4px; }

.btn {
  border: 0; border-radius: 10px; padding: 10px 14px; background: var(--mar); color: #fff; font-weight: 600;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.sec { background: #eaf3f6; color: var(--mar-esc); }
.btn.coral { background: var(--coral); }
.btn.verde { background: var(--verde); }
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.lg { padding: 14px 18px; font-size: 17px; width: 100%; }

.input, select.input, textarea.input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--borda); border-radius: 10px; background: #fff;
}
label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.b-ok { background: #dcf5e8; color: #146c45; }
.b-aviso { background: #fff1cc; color: #8a5a00; }
.b-carencia { background: #ffe1da; color: #a12d14; }
.b-bloq { background: #2d2d2d; color: #fff; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--borda); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.tright { text-align: right; }

/* Garçom (mobile-first) */
.garcom { max-width: 560px; margin: 0 auto; }
.mesa-input { font-size: 32px; font-weight: 700; text-align: center; letter-spacing: .05em; }
.cats { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; margin-bottom: 8px; }
.cats button { border: 1px solid var(--borda); background: #fff; border-radius: 999px; padding: 7px 13px; white-space: nowrap; }
.cats button.active { background: var(--mar); color: #fff; border-color: var(--mar); }
.prod { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 0; border-bottom: 1px solid var(--borda); }
.prod .nome { font-weight: 600; }
.prod .preco { color: var(--mar); font-weight: 700; font-size: 14px; }
.qtd { display: flex; align-items: center; gap: 8px; }
.qtd button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: #eaf3f6; color: var(--mar-esc); font-size: 20px; font-weight: 700; }
.qtd button.mais { background: var(--mar); color: #fff; }
.qtd span { min-width: 18px; text-align: center; font-weight: 700; }
.carrinho {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--borda);
  margin: 12px -16px -16px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  box-shadow: 0 -6px 20px rgba(0,0,0,.06);
}
.bt-status { font-size: 13px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #c3cdd1; margin-right: 6px; }
.dot.on { background: var(--verde); }

/* Cozinha */
.kanban { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 800px) { .kanban { grid-template-columns: 1fr; } }
.col { background: var(--areia); border-radius: var(--raio); padding: 12px; min-height: 200px; }
.col h3 { margin: 0 0 10px; display: flex; justify-content: space-between; }
.ticket { background: #fff; border-radius: 12px; padding: 12px; margin-bottom: 10px; border-left: 5px solid var(--sol); }
.ticket.preparando { border-left-color: var(--agua); }
.ticket.pronto { border-left-color: var(--verde); }
.ticket .mesa { font-size: 20px; font-weight: 800; }
.ticket ul { margin: 8px 0; padding-left: 18px; }
.ticket .obs { color: var(--coral); font-size: 13px; }

/* Caixa */
.mesas { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.mesa-card { background: #fff; border: 2px solid var(--borda); border-radius: 12px; padding: 12px; text-align: left; }
.mesa-card.sel { border-color: var(--mar); background: #eef8fb; }
.mesa-card .n { font-size: 22px; font-weight: 800; }

/* Ranking */
.rank { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--borda); }
.rank .pos { font-size: 24px; width: 34px; text-align: center; }
.rank .bar { height: 8px; background: #eaf3f6; border-radius: 999px; overflow: hidden; margin-top: 5px; }
.rank .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--agua), var(--mar)); }
.seg { display: inline-flex; background: #eaf3f6; border-radius: 999px; padding: 3px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 999px; font-size: 13px; color: var(--mar-esc); }
.seg button.active { background: #fff; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.1); }

/* Scan IA */
.scan {
  border: 2px dashed var(--agua); border-radius: var(--raio); padding: 22px; text-align: center; background: #f1fafc;
}
.scan .big { font-size: 40px; }

/* Bloqueio / modal / toast */
.blocked { position: fixed; inset: 0; background: rgba(7,30,40,.85); display: grid; place-items: center; z-index: 50; padding: 20px; }
.blocked .card { max-width: 420px; text-align: center; }
.blocked .big { font-size: 48px; }
.modal { position: fixed; inset: 0; background: rgba(7,30,40,.5); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal-card { background: #fff; border-radius: var(--raio); padding: 20px; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60;
  background: var(--texto); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600; max-width: 90vw;
}
.recibo {
  font-family: "Courier New", monospace; font-size: 13px; background: #fffef8; border: 1px dashed #bbb;
  padding: 12px; white-space: pre; width: 32ch; margin: 10px auto; overflow: hidden;
}

/* ---- Telas de entrada (login / cadastro) ---- */
.entrada { min-height: calc(100vh - 60px); display: grid; place-items: center; padding: 20px; }
.entrada .card { width: 100%; max-width: 420px; }
.entrada h2 { margin-top: 0; }
.erro { color: #b42318; font-size: 14px; margin-top: 8px; }
.ok-box { background: #dcf5e8; color: #146c45; border-radius: 10px; padding: 12px; }
.aviso-box { background: #fff4d6; color: #8a5a00; border-radius: 10px; padding: 12px; }

/* ---- Abas internas de cada painel ---- */
.abas { display: flex; gap: 4px; overflow-x: auto; margin-bottom: 14px; border-bottom: 1px solid var(--borda); }
.abas button { border: 0; background: transparent; padding: 10px 14px; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.abas button.active { color: var(--mar); border-bottom-color: var(--mar); }
.sair { background: rgba(255,255,255,.15); color: #fff; border: 0; border-radius: 999px; padding: 7px 14px; }

/* ---- Caixa de link para copiar ---- */
.link-box { display: flex; gap: 6px; align-items: center; background: #f1fafc; border: 1px solid #cfe8ef; border-radius: 10px; padding: 6px 6px 6px 10px; }
.link-box code { flex: 1; font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Gráfico de barras simples ---- */
.barras { display: flex; align-items: flex-end; gap: 4px; height: 140px; padding-top: 10px; }
.barras div { flex: 1; background: linear-gradient(180deg, var(--agua), var(--mar)); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.barras-leg { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.barras-leg span { flex: 1; text-align: center; overflow: hidden; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--borda); background: #fff; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
.chips button.active { background: var(--mar); color: #fff; border-color: var(--mar); }

/* =====================================================================
   v3 — números alinhados, mapa de mesas, caixa
   ===================================================================== */
body { font-variant-numeric: tabular-nums; }
.g4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.kpi { display: flex; flex-direction: column; justify-content: space-between; min-height: 92px; }
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.kpi .valor { font-size: clamp(20px, 2.2vw, 26px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.kpi .det { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kpi.destaque { background: linear-gradient(135deg, var(--mar-esc), var(--mar)); color: #fff; border: 0; }
.kpi.destaque .label, .kpi.destaque .det { color: rgba(255,255,255,.8); }
td.tright, th.tright { white-space: nowrap; }

/* Lista "rótulo ........ valor" */
.linhas-valor { display: grid; gap: 0; }
.linhas-valor > div { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--borda); }
.linhas-valor > div:last-child { border-bottom: 0; }
.linhas-valor .v { font-weight: 700; white-space: nowrap; }
.linhas-valor .total { font-size: 18px; border-top: 2px solid var(--texto); border-bottom: 0; margin-top: 4px; }
.forma-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; vertical-align: middle; }

/* Mapa de mesas */
.mapa { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.mesa {
  border-radius: 12px; padding: 10px 8px; text-align: center; border: 2px solid; background: #fff; cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; min-height: 84px; justify-content: center;
}
.mesa .n { font-size: 22px; font-weight: 800; line-height: 1; }
.mesa .s { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.mesa .t { font-size: 13px; font-weight: 700; }
.mesa .m { font-size: 11px; color: var(--muted); }
.mesa.livre { border-color: #bfe8d3; color: #146c45; background: #f3fbf7; }
.mesa.uso { border-color: #f5b88a; color: #9a3d0c; background: #fff6ef; }
.legenda { display: flex; gap: 14px; font-size: 13px; flex-wrap: wrap; }
.legenda span::before { content: ""; display: inline-block; width: 12px; height: 12px; border-radius: 4px; margin-right: 6px; vertical-align: -1px; }
.legenda .l::before { background: #bfe8d3; } .legenda .u::before { background: #f5b88a; }

/* Garçom: escolha de mesa */
.mapa.compacto { grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); }
.mapa.compacto .mesa { min-height: 56px; padding: 6px 4px; }
.mapa.compacto .mesa .n { font-size: 18px; }

/* Impressora */
.impressora { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.impressora .st { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 14px; }
.resultado-ok { text-align: center; padding: 10px 0; }
.resultado-ok .big { font-size: 46px; }
.recibo b { font-weight: 800; }

/* Campo de senha do garçom: grande, visível e com botão "Mostrar" */
.campo-senha { position: relative; }
.campo-senha .input { font-size: 22px; text-align: center; padding: 14px 92px; color: #10202a; caret-color: #0b6e8a; border-width: 2px; }
.campo-senha .input:focus { border-color: #0b6e8a; outline: 3px solid rgba(11,110,138,.18); }
.campo-senha .input[type="password"]:not(:placeholder-shown) { letter-spacing: .25em; }
.campo-senha .input::placeholder { font-size: 17px; letter-spacing: 0; }
.ver-senha { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: #eef8fb; color: #0b6e8a; border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; cursor: pointer; }
