/* ── TOKENS ─────────────────────────────────────────── */
:root {
  --navy:       #0b2d3e;
  --navy-light: #163d52;
  --teal:       #1a8fa8;
  --teal-light: #22b5d0;
  --teal-pale:  #e6f6fa;
  --ink:        #1a2f38;
  --muted:      #5a7a85;
  --line:       #cde7ee;
  --paper:      #f7fbfc;
  --white:      #ffffff;
  --danger:     #c0392b;
  --shadow-sm:  0 1px 4px rgba(11,45,62,.10);
  --shadow-md:  0 4px 16px rgba(11,45,62,.13);
  --radius:     10px;
  --touch:      48px; /* altura mínima para toque */
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: 'Segoe UI', Roboto, Arial, sans-serif;
  background: linear-gradient(145deg, var(--paper) 0%, #ddf0f5 100%);
  color: var(--ink);
  min-height: 100vh;
  font-size: 16px; /* base para mobile */
}

/* ── HEADER MOBILE-FIRST ──── */
.page-top {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #1a5a70 100%);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  overflow: hidden;
}
.page-top::after {
  content: ''; position: absolute; right: -40px; top: -40px;
  width: 160px; height: 160px; border-radius: 50%;
  background: rgba(34,181,208,.10); pointer-events: none;
}
.logo-img {
  width: 52px; height: 52px; min-width: 52px;
  border-radius: 8px; object-fit: cover;
  border: 2px solid rgba(255,255,255,.25);
  box-shadow: var(--shadow-md);
}
.header-text { flex: 1; min-width: 0; }
.page-top h1 {
  font-size: 1.1rem; margin: 0 0 2px;
  color: #fff; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-top p {
  margin: 0; font-size: .75rem;
  color: rgba(255,255,255,.70);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.badge {
  display: none; /* esconde no mobile */
}
@media (min-width: 600px) {
  .page-top { padding: 18px 24px; gap: 16px; }
  .logo-img  { width: 64px; height: 64px; min-width: 64px; }
  .page-top h1 { font-size: 1.35rem; }
  .page-top p  { font-size: .82rem; }
  .badge {
    display: inline-block;
    background: rgba(255,255,255,.10); border: 1px solid rgba(255,255,255,.20);
    color: rgba(255,255,255,.80); font-size: .72rem; padding: 4px 10px;
    border-radius: 20px; white-space: nowrap; margin-left: auto;
  }
}

/* ── WRAPPER ── */
.wrap { max-width: 820px; margin: 0 auto; padding: 16px 12px 60px; }

/* ── CARDS ── */
.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.card-title {
  font-size: .72rem; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--teal); font-weight: 700; margin: 0 0 14px;
  display: flex; align-items: center; gap: 7px;
}
.card-title::before {
  content: ''; width: 4px; height: 16px;
  background: var(--teal); border-radius: 2px; flex: 0 0 auto;
}

/* ── GRID CAMPOS ── */
.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 560px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ── INPUTS ── */
label {
  display: block; font-size: .78rem; color: var(--muted);
  font-weight: 600; margin-bottom: 5px; letter-spacing: .2px;
}
input, textarea, select {
  width: 100%;
  padding: 12px 12px; /* alto para fácil toque */
  border: 1.5px solid var(--line);
  border-radius: 8px; font-size: 1rem;
  background: var(--paper); color: var(--ink);
  font-family: inherit;
  min-height: var(--touch);
  transition: border-color .15s, box-shadow .15s;
}
input:focus, textarea:focus {
  outline: none; border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(26,143,168,.12); background: #fff;
}
textarea { resize: vertical; min-height: 72px; }

/* ── CARDS DE AMBIENTE ── */
#secoesContainer { display: flex; flex-direction: column; gap: 14px; }
.secao-card {
  border: 1.5px solid var(--line); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow-sm);
}
.secao-header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  display: flex; align-items: center; gap: 8px; padding: 10px 12px;
}
.secao-nome {
  text-transform: uppercase;
  flex: 1; background: rgba(255,255,255,.12);
  border: 1.5px solid rgba(255,255,255,.25);
  color: #fff; font-size: 1rem; font-weight: 600;
  padding: 9px 12px; border-radius: 6px;
  font-family: inherit; min-height: var(--touch);
  transition: background .15s;
}
.secao-nome:focus { outline: none; background: rgba(255,255,255,.22); border-color: rgba(255,255,255,.5); }
.secao-nome::placeholder { color: rgba(255,255,255,.45); font-weight: 400; }
.btn-rm-secao {
  background: rgba(192,57,43,.25); border: 1px solid rgba(192,57,43,.4);
  color: #ffb3ae; font-size: .78rem; padding: 8px 10px;
  border-radius: 6px; cursor: pointer; white-space: nowrap;
  min-height: var(--touch); transition: background .15s;
}
.btn-rm-secao:active { background: rgba(192,57,43,.50); }

/* ── CABEÇALHO DOS ITENS (só desktop) ── */
.itens-cabecalho {
  display: none; /* esconde no mobile */
  grid-template-columns: 1fr 130px 100px 36px;
  gap: 8px; padding: 6px 14px 4px;
  background: #f0f8fb; border-bottom: 1px solid var(--line);
}
.itens-cabecalho span {
  font-size: .66rem; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: .6px;
}
@media (min-width: 600px) {
  .itens-cabecalho { display: grid; }
}

/* ── ITEM ROW — mobile: 2 linhas / desktop: 1 linha ── */
.item-row {
  display: grid;
  /* mobile: desc ocupa tudo, abaixo medidas+valor+botão */
  grid-template-columns: 1fr 1fr 36px;
  grid-template-rows: auto auto;
  grid-template-areas:
    "desc  desc   rm"
    "med   preco  preco";
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid #f0f7f9;
  background: #fff;
}
.item-desc    { grid-area: desc; }
.item-medidas { grid-area: med; }
.item-preco   { grid-area: preco; text-align: right; }
.btn-rm-item  { grid-area: rm; align-self: center; }

.item-row input {
  background: #fff; border-color: var(--line);
  font-size: .92rem; padding: 9px 10px;
  min-height: 42px;
}

.btn-rm-item {
  background: none; border: none; color: #c0c8cc;
  font-size: 1.2rem; cursor: pointer; padding: 6px;
  border-radius: 6px; line-height: 1;
  min-height: 42px; min-width: 36px;
  display: flex; align-items: center; justify-content: center;
  transition: color .15s, background .15s;
}
.btn-rm-item:active { color: var(--danger); background: #fdf0ef; }

/* Desktop: volta para 1 linha */
@media (min-width: 600px) {
  .item-row {
    grid-template-columns: 1fr 130px 100px 36px;
    grid-template-rows: auto;
    grid-template-areas: "desc med preco rm";
    padding: 8px 14px;
    gap: 8px;
  }
  .btn-rm-item:hover { color: var(--danger); background: #fdf0ef; }
}

/* ── FOOTER DOS AMBIENTES ── */
.secao-footer {
  background: var(--paper); padding: 10px 12px;
  display: flex; align-items: center; justify-content: space-between;
  border-top: 1px solid var(--line); gap: 10px;
}
.btn-add-item {
  background: none; border: 1.5px dashed var(--teal);
  color: var(--teal); font-size: .88rem; padding: 8px 14px;
  border-radius: 8px; cursor: pointer; font-family: inherit;
  min-height: var(--touch); transition: background .15s;
}
.btn-add-item:active { background: var(--teal-pale); }
@media (min-width: 600px) {
  .btn-add-item:hover { background: var(--teal-pale); }
}
.secao-subtotal {
  font-size: .92rem; font-weight: 700; color: var(--navy);
  white-space: nowrap;
}

/* ── BTN ADICIONAR AMBIENTE ── */
.btn-add-secao {
  width: 100%; margin-top: 6px; padding: 14px;
  background: var(--teal-pale); border: 2px dashed var(--teal);
  border-radius: var(--radius); color: var(--teal);
  font-size: 1rem; font-weight: 600; cursor: pointer;
  font-family: inherit; min-height: var(--touch);
  transition: background .15s; letter-spacing: .2px;
}
.btn-add-secao:active { background: #d2eef5; }

/* ── BARRA TOTAL ── */
.total-bar {
  background: linear-gradient(135deg, var(--navy) 0%, #1a5a70 100%);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 14px; box-shadow: var(--shadow-md); gap: 12px;
}
.total-bar .label {
  color: rgba(255,255,255,.70); font-size: .85rem;
  font-weight: 600; letter-spacing: .8px; text-transform: uppercase;
}
.total-bar .valor {
  color: #ffd97a; font-size: 1.4rem; font-weight: 700;
  letter-spacing: .5px; white-space: nowrap;
}

/* ── AÇÕES ── */
.actions { display: flex; flex-direction: column; gap: 10px; }
@media (min-width: 560px) {
  .actions { flex-direction: row; justify-content: flex-end; }
}
.btn-primary {
  background: linear-gradient(135deg, var(--teal) 0%, #136e85 100%);
  color: #fff; border: none; padding: 15px 24px;
  border-radius: 10px; font-size: 1rem; font-weight: 700;
  cursor: pointer; box-shadow: 0 4px 14px rgba(26,143,168,.35);
  font-family: inherit; letter-spacing: .3px;
  min-height: var(--touch); width: 100%;
  transition: filter .15s;
}
@media (min-width: 560px) { .btn-primary { width: auto; } }
.btn-primary:active { filter: brightness(1.08); }

.btn-secondary {
  background: #fff; color: var(--teal);
  border: 1.5px solid var(--teal);
  padding: 15px 22px; border-radius: 10px;
  font-size: 1rem; cursor: pointer;
  font-family: inherit; min-height: var(--touch); width: 100%;
  transition: background .15s;
}
@media (min-width: 560px) { .btn-secondary { width: auto; } }
.btn-secondary:active { background: var(--teal-pale); }

/* ── BOTÃO WHATSAPP ─── */
.btn-whatsapp {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff; border: none; padding: 15px 22px;
  border-radius: 10px; font-size: 1rem; font-weight: 700;
  cursor: pointer; font-family: inherit;
  min-height: var(--touch); width: 100%;
  box-shadow: 0 4px 14px rgba(37,211,102,.30);
  transition: filter .15s;
}
@media (min-width: 560px) { .btn-whatsapp { width: auto; } }
.btn-whatsapp:active { filter: brightness(1.08); }

/* ── BOTÃO HISTÓRICO ─── */
.btn-historico {
  display: block; width: 100%; margin-top: 14px;
  background: transparent; border: 1.5px solid var(--line);
  color: var(--muted); font-size: .9rem; padding: 12px;
  border-radius: 10px; cursor: pointer; font-family: inherit;
  transition: background .15s, color .15s, border-color .15s;
  min-height: var(--touch);
}
.btn-historico:hover, .btn-historico:active {
  background: var(--teal-pale); color: var(--teal); border-color: var(--teal);
}

/* ── PAINEL HISTÓRICO ─── */
.historico-card {
  display: none; margin-top: 12px;
  animation: slideDown .2s ease;
}
.historico-card.aberto { display: block; }
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.hist-header {
  display: flex; align-items: center;
  justify-content: space-between; margin-bottom: 12px; gap: 10px;
}
.hist-header .card-title { margin: 0; }
.btn-limpar-hist {
  background: none; border: 1px solid #e0b0b0; color: var(--danger);
  font-size: .78rem; padding: 5px 10px; border-radius: 6px;
  cursor: pointer; white-space: nowrap; font-family: inherit;
}
.btn-limpar-hist:hover { background: #fdf0ef; }

.hist-vazio {
  text-align: center; color: var(--muted); font-size: .88rem;
  padding: 20px; line-height: 1.6;
}

.hist-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.hist-item:last-child { border-bottom: none; }

.hist-info {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  flex: 1; min-width: 0;
}
.hist-num {
  font-weight: 700; color: var(--teal); font-size: .85rem;
  white-space: nowrap;
}
.hist-cliente {
  font-weight: 600; color: var(--ink); font-size: .9rem;
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.hist-data { color: var(--muted); font-size: .8rem; white-space: nowrap; }
.hist-total {
  font-weight: 700; color: var(--navy); font-size: .9rem;
  white-space: nowrap;
}
.btn-restaurar {
  background: var(--teal-pale); border: 1.5px solid var(--teal);
  color: var(--teal); font-size: .82rem; padding: 7px 12px;
  border-radius: 7px; cursor: pointer; white-space: nowrap;
  font-family: inherit; min-height: 38px; flex-shrink: 0;
  transition: background .15s;
}
.btn-restaurar:active { background: #c8e8f0; }
@media (min-width: 560px) { .btn-restaurar:hover { background: #c8e8f0; } }