:root {
  --bg: #f6f3ef;
  --surface: #ffffff;
  --surface-2: #faf7f3;
  --border: #e8e1d8;
  --text: #22201d;
  --muted: #7a726a;
  --brand: #c8102e;
  --brand-2: #a00d24;
  --brand-soft: #fde8eb;
  --ok: #1f8a4c;
  --ok-soft: #e3f5ea;
  --warn: #b26b00;
  --warn-soft: #fff1d6;
  --info: #2457c5;
  --info-soft: #e6eeff;
  --wa: #e7ddd3;
  --bubble-in: #ffffff;
  --bubble-out: #dcf8c6;
  --bubble-human: #dbe8ff;
  --bubble-sys: #fff3c4;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font-size: 14px; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
.hidden { display: none !important; }

/* ── Login ─────────────────────────────── */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(circle at 20% 10%, #fde8eb, transparent 50%), var(--bg); }
.login-card { background: var(--surface); padding: 32px; border-radius: 18px; width: 100%; max-width: 360px; box-shadow: var(--shadow); text-align: center; }
.login-card .logo { font-size: 44px; }
.login-card h1 { margin: 8px 0 4px; font-size: 22px; }
.login-card p { margin: 0 0 20px; color: var(--muted); }
.login-card input { width: 100%; margin-bottom: 12px; }
.erro { color: var(--brand); min-height: 18px; font-size: 13px; }

/* ── Estrutura ─────────────────────────── */
.app { display: grid; grid-template-columns: 220px 1fr; height: 100vh; }
.sidebar { background: #1f1b18; color: #f3ece4; display: flex; flex-direction: column; padding: 16px 12px; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand .logo { font-size: 28px; }
.brand b { display: block; font-size: 15px; }
.brand small { color: #b8ab9d; }
.nav-btn { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: #d8cdc1; padding: 10px 12px; border-radius: 10px; text-align: left; position: relative; }
.nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-btn.ativo { background: var(--brand); color: #fff; }
.nav-btn .ic { width: 20px; text-align: center; }
.nav-btn .badge { margin-left: auto; }
.sidebar .rodape { margin-top: auto; font-size: 12px; color: #9c8f82; padding: 8px; }
.sidebar .rodape button { background: none; border: 0; color: #d8cdc1; text-decoration: underline; padding: 0; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar { display: flex; align-items: center; gap: 10px; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar h2 { margin: 0; font-size: 18px; margin-right: auto; }
.stat { display: flex; flex-direction: column; padding: 0 12px; border-left: 1px solid var(--border); }
.stat small { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }
.stat b { font-size: 15px; font-variant-numeric: tabular-nums; }
.conteudo { flex: 1; overflow: auto; padding: 20px; min-height: 0; }

/* ── Elementos comuns ──────────────────── */
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.pill.off { color: var(--brand); background: var(--brand-soft); border-color: transparent; }
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
.pill.info { color: var(--info); background: var(--info-soft); border-color: transparent; }
.badge { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 1px 7px; min-width: 20px; text-align: center; }
.btn { border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 10px; font-weight: 600; }
.btn:hover { background: var(--surface-2); }
.btn.prim { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.prim:hover { background: var(--brand-2); }
.btn.ok { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.ghost { background: none; border-color: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=number], input[type=time], textarea, select {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px; padding: 9px 12px; outline: none; }
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.vazio { color: var(--muted); text-align: center; padding: 30px 10px; font-size: 13px; }
.muted { color: var(--muted); }

/* Switch */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-weight: 600; font-size: 13px; }
.switch input { display: none; }
.switch .trilho { width: 38px; height: 22px; background: #cfc6bc; border-radius: 999px; position: relative; transition: .2s; }
.switch .trilho::after { content: ""; position: absolute; left: 3px; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: .2s; }
.switch input:checked + .trilho { background: var(--ok); }
.switch input:checked + .trilho::after { left: 19px; }

/* ── Pedidos (kanban) ──────────────────── */
.kanban { display: grid; grid-template-columns: repeat(4, minmax(240px, 1fr)); gap: 14px; align-items: start; min-height: 100%; }
.coluna { background: #efe9e2; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.coluna h3 { margin: 2px 4px 10px; font-size: 13px; display: flex; align-items: center; gap: 8px; text-transform: uppercase; letter-spacing: .04em; color: #5a524a; }
.pedido { background: var(--surface); border-radius: 10px; padding: 12px; margin-bottom: 10px; box-shadow: var(--shadow); border-left: 4px solid var(--border); }
.pedido.novo { border-left-color: var(--brand); animation: pulsar 1.6s ease-in-out 3; }
.pedido.preparo { border-left-color: var(--warn); }
.pedido.entrega, .pedido.pronto { border-left-color: var(--info); }
.pedido.concluido { border-left-color: var(--ok); opacity: .85; }
.pedido.cancelado { opacity: .55; }
@keyframes pulsar { 50% { box-shadow: 0 0 0 4px var(--brand-soft); } }
.pedido .topo { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.pedido .num { font-weight: 800; font-size: 16px; }
.pedido .hora { color: var(--muted); font-size: 12px; }
.pedido .cli { font-weight: 600; margin: 2px 0 6px; }
.pedido ul { margin: 6px 0; padding-left: 16px; font-size: 13px; }
.pedido ul li { margin-bottom: 3px; }
.pedido .sub { color: var(--muted); font-size: 12px; }
.pedido .linha { font-size: 12.5px; margin-top: 4px; }
.pedido .total { display: flex; justify-content: space-between; font-weight: 700; border-top: 1px dashed var(--border); margin-top: 8px; padding-top: 8px; }
.pedido .acoes { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.pedido .acoes .btn.prim { flex: 1; }

/* ── Conversas ─────────────────────────── */
.chat-layout { display: grid; grid-template-columns: 320px 1fr 280px; gap: 0; height: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.lista-conv { border-right: 1px solid var(--border); overflow: auto; }
.conv-item { display: flex; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); cursor: pointer; }
.conv-item:hover { background: var(--surface-2); }
.conv-item.sel { background: var(--brand-soft); }
.conv-item .av { width: 38px; height: 38px; border-radius: 50%; background: #e9dfd4; display: grid; place-items: center; font-weight: 700; color: #6b5d50; flex-shrink: 0; }
.conv-item .meio { min-width: 0; flex: 1; overflow: hidden; }
.conv-item .nome { font-weight: 600; display: flex; gap: 6px; align-items: center; }
.conv-item .prev { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-item .dir { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 11px; color: var(--muted); }
.conv-item .alerta { color: var(--brand); font-size: 12px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.chat-head .quem { margin-right: auto; }
.chat-head .quem b { display: block; }
.chat-head .quem small { color: var(--muted); }
.mensagens { flex: 1; overflow: auto; padding: 16px; background: var(--wa); background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.bolha { max-width: 75%; padding: 7px 10px 5px; border-radius: 10px; box-shadow: 0 1px 1px rgba(0,0,0,.08); white-space: pre-wrap; word-wrap: break-word; line-height: 1.4; font-size: 13.5px; }
.bolha .meta { font-size: 10.5px; color: #8a8178; text-align: right; margin-top: 2px; }
.bolha.cliente { background: var(--bubble-in); align-self: flex-start; border-top-left-radius: 2px; }
.bolha.ia { background: var(--bubble-out); align-self: flex-end; border-top-right-radius: 2px; }
.bolha.atendente { background: var(--bubble-human); align-self: flex-end; border-top-right-radius: 2px; }
.bolha.sistema { background: var(--bubble-sys); align-self: flex-end; border-top-right-radius: 2px; }
.digitando { align-self: flex-end; font-size: 12px; color: #5f5850; background: rgba(255,255,255,.7); padding: 4px 10px; border-radius: 999px; }
.aviso-humano { background: var(--warn-soft); color: var(--warn); padding: 8px 14px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); }
.envio { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface-2); }
.envio textarea { flex: 1; resize: none; height: 42px; }
.lateral { border-left: 1px solid var(--border); overflow: auto; padding: 14px; background: var(--surface-2); }
.lateral h4 { margin: 4px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.lateral .bloco { margin-bottom: 18px; font-size: 13px; }
.lateral .item-c { padding: 6px 0; border-bottom: 1px dashed var(--border); }

/* ── Simulador ─────────────────────────── */
.sim-layout { display: grid; grid-template-columns: 380px 1fr; gap: 24px; align-items: start; }
.celular { background: #111; border-radius: 34px; padding: 12px; box-shadow: 0 20px 40px rgba(0,0,0,.18); }
.tela { border-radius: 24px; overflow: hidden; display: flex; flex-direction: column; height: 680px; max-height: calc(100vh - 140px); }
.tela .wa-head { background: #075e54; color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
.tela .wa-head .av { width: 36px; height: 36px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-size: 20px; }
.tela .wa-head small { opacity: .8; display: block; font-size: 11.5px; }
.tela .mensagens { background-color: #e5ddd5; }
.tela .bolha.cliente { align-self: flex-end; background: var(--bubble-out); border-radius: 10px; border-top-right-radius: 2px; }
.tela .bolha.ia, .tela .bolha.sistema, .tela .bolha.atendente { align-self: flex-start; background: #fff; border-radius: 10px; border-top-left-radius: 2px; }
.tela .digitando { align-self: flex-start; }
.tela .envio { background: #f0f0f0; }
.tela .envio input { flex: 1; border-radius: 999px; }
.tela .envio .btn { border-radius: 50%; width: 42px; height: 42px; padding: 0; background: #075e54; border-color: #075e54; color: #fff; }
.dicas .card { padding: 18px; margin-bottom: 14px; }
.dicas h3 { margin: 0 0 10px; font-size: 15px; }
.dicas .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--border); background: var(--surface-2); padding: 7px 12px; border-radius: 999px; font-size: 13px; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* ── Cardápio / Ajustes ────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.secao { padding: 16px 18px; margin-bottom: 16px; }
.secao h3 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.tabela { width: 100%; border-collapse: collapse; }
.tabela td, .tabela th { padding: 7px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.tabela th { font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
.tabela input[type=number] { width: 100px; padding: 6px 8px; }
.tabela input[type=text] { width: 100%; padding: 6px 8px; }
.tabela tr.inativo td { opacity: .5; }
.tabela tr.inativo td:last-child { opacity: 1; }
.campo { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.campo label { font-size: 12px; font-weight: 600; color: var(--muted); }
.campo textarea { min-height: 90px; resize: vertical; }
.linha-flex { display: flex; gap: 12px; flex-wrap: wrap; }
.linha-flex .campo { flex: 1; min-width: 140px; }
.salvo { color: var(--ok); font-weight: 600; font-size: 12px; transition: opacity .3s; }

/* ── WhatsApp ──────────────────────────── */
.wa-box { max-width: 560px; margin: 0 auto; padding: 28px; text-align: center; }
.wa-box img { width: 280px; height: 280px; border-radius: 12px; border: 1px solid var(--border); }
.wa-box ol { text-align: left; color: var(--muted); line-height: 1.8; }

.toast { position: fixed; right: 20px; bottom: 20px; background: #1f1b18; color: #fff; padding: 12px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.2); z-index: 50; max-width: 340px; animation: entrar .25s ease; }
.toast.vermelho { background: var(--brand); }
@keyframes entrar { from { transform: translateY(20px); opacity: 0; } }

/* ── Responsivo ────────────────────────── */
@media (max-width: 1200px) {
  .chat-layout { grid-template-columns: 280px 1fr; }
  .lateral { display: none; }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { order: 2; flex-direction: row; padding: 6px; overflow-x: auto; gap: 2px; }
  .brand, .sidebar .rodape { display: none; }
  .nav-btn { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; align-items: center; min-width: 56px; }
  .nav-btn .badge { position: absolute; top: 2px; right: 4px; margin: 0; }
  .conteudo { padding: 12px; }
  .topbar { padding: 10px 12px; }
  .stat { display: none; }
  .kanban { grid-template-columns: repeat(4, 85vw); overflow-x: auto; scroll-snap-type: x mandatory; }
  .coluna { scroll-snap-align: start; }
  .chat-layout { grid-template-columns: 1fr; }
  .chat-layout.aberta .lista-conv { display: none; }
  .chat-layout:not(.aberta) .chat { display: none; }
  .sim-layout, .grid-2 { grid-template-columns: 1fr; }
  .celular { padding: 0; border-radius: 0; background: none; box-shadow: none; }
  .tela { border-radius: 12px; height: 70vh; }
}
@media (min-width: 901px) { .voltar { display: none; } }

/* Instrução interna para a IA (o cliente não vê) */
.bolha.nota { align-self: center; max-width: 85%; background: var(--warn-soft); border: 1px dashed var(--warn); color: #6b4a00; font-size: 12.5px; }
.envio.instrucao { border-top: 1px dashed var(--border); background: #fffaf0; }
.envio.instrucao textarea { height: 38px; font-size: 13px; }

/* InstaDelivery no card do pedido */
.pedido .insta { display: flex; flex-direction: column; gap: 6px; }
.pedido .insta .acoes { margin-top: 0; flex-wrap: wrap; }

/* aviso de vencimento do login do Claude (rodapé do menu) */
.aviso-login { margin-top: 4px; padding: 4px 6px; border-radius: 6px; background: #fde68a; color: #7c2d12; font-weight: 600; }
