/* =====================================================================
   InfoCell — sistema de loja de celular e assistência técnica

   Identidade: a bancada da assistência. Azul de tapete antiestático,
   dado sempre em mono tabular — é como o lojista lê IMEI e valor o dia
   inteiro.

   No celular a interface se comporta como aplicativo: barra de abas
   embaixo, folhas que sobem de baixo, cabeçalho enxuto e áreas de toque
   grandes. No computador, painel lateral e janelas centradas.
   ===================================================================== */

:root {
  /* superfícies */
  --ink:        #0B1220;
  --ink-2:      #1B2739;
  --surface:    #EFF2F7;
  --card:       #FFFFFF;
  --card-2:     #F8FAFC;
  --line:       #DEE4ED;
  --line-soft:  #EBEFF5;
  --muted:      #64748B;
  --muted-2:    #8A9AB0;

  /* marca */
  --esd:        #1E4FA3;
  --esd-600:    #17408A;
  --esd-soft:   #E7EEFA;
  --signal:     #00876A;
  --signal-soft:#E0F3EE;
  --amber:      #B36C00;
  --amber-soft: #FBF0DC;
  --danger:     #C22E26;
  --danger-soft:#FBE6E4;

  /* forma */
  --r-xs: 8px;
  --r-sm: 11px;
  --r:    15px;
  --r-lg: 22px;
  --r-pill: 999px;

  --shadow-xs: 0 1px 2px rgba(11,18,32,.05);
  --shadow:    0 1px 3px rgba(11,18,32,.06), 0 6px 18px rgba(11,18,32,.05);
  --shadow-md: 0 4px 12px rgba(11,18,32,.08), 0 14px 34px rgba(11,18,32,.07);
  --shadow-lg: 0 10px 24px rgba(11,18,32,.14), 0 30px 70px rgba(11,18,32,.18);

  /* estrutura */
  --rail: 244px;
  --topbar: 62px;
  --tabbar: 62px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);

  --sans: 'Archivo', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;

  --ease: cubic-bezier(.22,.72,.28,1);
}

/* ------------------------------ tema escuro ------------------------- */
:root[data-theme="escuro"] {
  --ink:        #E8EDF5;
  --ink-2:      #C6D0DF;
  --surface:    #090F1A;
  --card:       #111A2A;
  --card-2:     #16202F;
  --line:       #26334A;
  --line-soft:  #1C2739;
  --muted:      #8A9BB5;
  --muted-2:    #6D7E96;
  --esd:        #4C86E8;
  --esd-600:    #3E74D2;
  --esd-soft:   #17233A;
  --signal:     #22B894;
  --signal-soft:#102E27;
  --amber:      #E0A33C;
  --amber-soft: #2E240F;
  --danger:     #F0655B;
  --danger-soft:#33191A;
  --shadow-xs: 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 1px 3px rgba(0,0,0,.45), 0 6px 18px rgba(0,0,0,.35);
  --shadow-md: 0 4px 12px rgba(0,0,0,.5), 0 14px 34px rgba(0,0,0,.4);
  --shadow-lg: 0 10px 24px rgba(0,0,0,.55), 0 30px 70px rgba(0,0,0,.5);
  color-scheme: dark;
}
:root[data-theme="escuro"] .rail { background: #060B14; }
:root[data-theme="escuro"] th { background: var(--card-2); }

/* -------------------------------- base ------------------------------ */
* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.025em; line-height: 1.2; }
p { margin: 0; }
a { color: var(--esd); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--esd); outline-offset: 2px; border-radius: 6px; }

/* número, código e IMEI sempre em mono tabular: leitura de instrumento */
.num, .mono, td.num, th.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.02em;
}
.num { text-align: right; }

/* --------------------------------- login ---------------------------- */
#login {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: calc(24px + var(--safe-top)) 20px calc(24px + var(--safe-bottom));
  background:
    radial-gradient(1200px 520px at 12% -10%, #1B3B72 0%, transparent 62%),
    linear-gradient(165deg, #0B1220 0%, #16294A 100%);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-card h1 { font-size: 21px; }
.login-card p.sub { color: var(--muted); font-size: 13.5px; margin: 4px 0 24px; }
.login-hint {
  margin-top: 22px; padding: 13px 14px; border-radius: var(--r-sm);
  background: var(--surface); font-size: 12.5px; color: var(--muted); line-height: 1.6;
}
.login-hint code { font-family: var(--mono); color: var(--ink); font-size: 12px; }

.logo {
  width: 38px; height: 38px; border-radius: 12px;
  background: var(--esd); color: #fff;
  display: grid; place-items: center; overflow: hidden;
  font-family: var(--mono); font-weight: 700; font-size: 15px;
  flex: none;
}
.logo img { width: 100%; height: 100%; object-fit: contain; }
.logo.has-img { background: transparent; }

/* --------------------------------- casca ---------------------------- */
#app { display: none; min-height: 100dvh; }
#app.on { display: block; }

.rail {
  position: fixed; inset: 0 auto 0 0; width: var(--rail);
  background: var(--ink); color: #A9B6CB;
  display: flex; flex-direction: column;
  z-index: 60;
  padding-top: var(--safe-top);
}
.rail-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.rail-brand strong { font-size: 15.5px; letter-spacing: -.02em; }
.rail-brand small { display: block; font-size: 11px; color: #7D8CA6; font-weight: 400; }
.rail-nav { flex: 1; overflow-y: auto; padding: 12px 10px 24px; -webkit-overflow-scrolling: touch; }
.rail-group {
  margin-top: 16px; padding: 0 10px 7px;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .1em;
  color: #5C6C87; font-weight: 600;
}
.rail a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 11px; border-radius: var(--r-sm);
  color: inherit; text-decoration: none; font-size: 14px;
  transition: background .14s var(--ease), color .14s var(--ease);
}
.rail a:hover { background: rgba(255,255,255,.07); color: #fff; }
.rail a.active { background: var(--esd); color: #fff; font-weight: 500; }
.rail a svg { width: 18px; height: 18px; flex: none; opacity: .92; }
.rail-user {
  border-top: 1px solid rgba(255,255,255,.08);
  padding: 13px 15px calc(13px + var(--safe-bottom));
  display: flex; align-items: center; gap: 11px;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--esd); color: #fff; display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600;
}
.rail-user .who { flex: 1; min-width: 0; }
.rail-user .who b {
  display: block; color: #fff; font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rail-user .who span { font-size: 11.5px; color: #7D8CA6; }

.topbar {
  position: fixed; top: 0; left: var(--rail); right: 0;
  height: calc(var(--topbar) + var(--safe-top));
  padding: var(--safe-top) 22px 0;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
  -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
  z-index: 50;
}
.topbar h2 { font-size: 16.5px; flex: none; }
.search { flex: 1; max-width: 440px; position: relative; }
.search input { width: 100%; padding-left: 36px; border-radius: var(--r-pill); }
.search svg {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted);
}

/* leitura permanente do caixa: o dado que o balcão mais precisa */
.cash-pill {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 14px 7px 11px; border-radius: var(--r-pill);
  border: 1px solid var(--line); background: var(--card);
  font-family: var(--mono); font-size: 12px; white-space: nowrap;
  cursor: pointer; transition: border-color .14s var(--ease);
}
.cash-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: #94A3B8; flex: none; }
.cash-pill.open { border-color: #BEDBD3; background: var(--signal-soft); color: var(--signal); }
.cash-pill.open .dot { background: var(--signal); box-shadow: 0 0 0 3px rgba(0,135,106,.2); }
.cash-pill .label {
  font-family: var(--sans); font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .08em; opacity: .72;
}

main {
  margin-left: var(--rail);
  padding: calc(var(--topbar) + var(--safe-top) + 22px) 22px 44px;
  min-height: 100dvh;
}

.page-head { display: flex; align-items: flex-end; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h3 { font-size: 21px; }
.page-head p { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; }
.page-head .spacer { flex: 1; }

/* no computador a barra de abas e a cortina não existem */
.tabbar { display: none; }
.sheet-backdrop { display: none; }

/* -------------------------------- controles -------------------------- */
input, select, textarea {
  width: 100%; padding: 10px 13px;
  border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--card);
  transition: border-color .14s var(--ease), box-shadow .14s var(--ease);
  font-size: 15px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--esd); box-shadow: 0 0 0 4px var(--esd-soft);
}
input[type=number], input.money { font-family: var(--mono); text-align: right; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--esd); }
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block; font-size: 12.5px; color: var(--muted);
  margin-bottom: 5px; font-weight: 500;
}
label.field > small { display: block; margin-top: 4px; }
.row { display: grid; gap: 13px; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 17px; border-radius: var(--r-sm);
  border: 1.5px solid var(--line); background: var(--card); color: var(--ink);
  font-weight: 500; font-size: 14.5px; cursor: pointer;
  transition: background .14s var(--ease), border-color .14s var(--ease), transform .08s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--card-2); }
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--esd); border-color: var(--esd); color: #fff; }
.btn.primary:hover { background: var(--esd-600); }
.btn.go { background: var(--signal); border-color: var(--signal); color: #fff; }
.btn.go:hover { filter: brightness(.94); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 32%, var(--line)); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.btn.sm { padding: 7px 12px; font-size: 13.5px; border-radius: var(--r-xs); }
.btn.block { width: 100%; }
.btn[data-busy] { opacity: .75; cursor: progress; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: var(--r-pill);
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
  background: var(--surface); color: var(--muted);
}
.badge.ok   { background: var(--signal-soft); color: var(--signal); }
.badge.warn { background: var(--amber-soft);  color: var(--amber); }
.badge.bad  { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--esd-soft);    color: var(--esd); }

kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px;
  border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px;
  background: var(--surface); color: var(--muted); white-space: nowrap;
}

/* --------------------------------- cards ----------------------------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--r); box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card > header {
  padding: 14px 17px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.card > header h4 { font-size: 14.5px; }
.card > header .spacer { flex: 1; }
.card .body { padding: 17px; }

.kpis {
  display: grid; gap: 13px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  margin-bottom: 17px;
}
.kpi {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  padding: 15px 17px; box-shadow: var(--shadow-xs);
  position: relative; overflow: hidden;
}
.kpi::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px; background: var(--esd);
}
.kpi.good::before { background: var(--signal); }
.kpi.warn::before { background: var(--amber); }
.kpi.bad::before  { background: var(--danger); }
.kpi .label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600;
}
.kpi .value {
  font-family: var(--mono); font-size: 23px; font-weight: 600;
  letter-spacing: -.035em; margin-top: 4px;
}
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 3px; }

.grid-2 { display: grid; gap: 17px; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 17px; grid-template-columns: 2fr 1fr; }

/* -------------------------------- tabelas ---------------------------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 600; padding: 10px 15px;
  border-bottom: 1px solid var(--line); background: var(--card-2); white-space: nowrap;
}
td { padding: 11px 15px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--card-2); }
td .sub { display: block; font-size: 12px; color: var(--muted); }

.pager {
  display: flex; align-items: center; gap: 10px; padding: 12px 15px;
  border-top: 1px solid var(--line-soft); font-size: 12.5px; color: var(--muted);
  flex-wrap: wrap;
}
.pager .spacer { flex: 1; }

.empty { padding: 48px 22px; text-align: center; color: var(--muted); }
.empty h4 { color: var(--ink); margin-bottom: 5px; font-size: 15.5px; }
.empty p { margin: 0 0 15px; font-size: 13.5px; }

.skeleton {
  background: linear-gradient(90deg, var(--line-soft) 25%, var(--card-2) 50%, var(--line-soft) 75%);
  background-size: 200% 100%; animation: shimmer 1.2s infinite;
  border-radius: var(--r-sm); height: 14px;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ------------------------- janelas e folhas -------------------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(11,18,32,.5);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  z-index: 80; animation: fade .14s var(--ease);
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--card); border-radius: var(--r-lg); width: 100%; max-width: 580px;
  max-height: 88dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: pop .18s var(--ease);
}
@keyframes pop { from { transform: translateY(12px) scale(.985); opacity: 0; } }
.modal.wide { max-width: 900px; }
.modal > header {
  padding: 17px 21px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 12px;
}
.modal > header h4 { font-size: 16.5px; flex: 1; }
.modal .content { padding: 21px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.modal > footer {
  padding: 15px 21px calc(15px + var(--safe-bottom));
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap;
}
.sheet-grab { display: none; }

.toasts {
  position: fixed; right: 16px; left: 16px; bottom: calc(18px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 9px; z-index: 95;
  align-items: flex-end; pointer-events: none;
}
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-sm);
  font-size: 13.5px; box-shadow: var(--shadow-lg); max-width: 400px;
  animation: slide .2s var(--ease); pointer-events: auto;
}
:root[data-theme="escuro"] .toast { background: #223149; }
.toast.bad { background: var(--danger); }
.toast.ok  { background: var(--signal); }
@keyframes slide { from { transform: translateY(10px); opacity: 0; } }

/* ---------------------------------- PDV ------------------------------ */
.pdv { display: grid; grid-template-columns: 1fr 384px; gap: 17px; align-items: start; }
.pdv-search { position: relative; margin-bottom: 13px; }
.pdv-search input {
  font-size: 16px; padding: 14px 15px 14px 44px; border-radius: var(--r);
  box-shadow: var(--shadow-xs);
}
.pdv-search svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 18px; height: 18px; color: var(--muted);
}
.results {
  position: absolute; top: calc(100% + 7px); left: 0; right: 0; z-index: 30;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); max-height: 360px; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.results div.hit {
  padding: 11px 15px; cursor: pointer; display: flex; gap: 12px; align-items: center;
  border-bottom: 1px solid var(--line-soft);
}
.results div.hit:last-child { border-bottom: none; }
.results div.hit:hover, .results div.hit.sel { background: var(--esd-soft); }
.results .hit-main { flex: 1; min-width: 0; }
.results .hit-main b { font-weight: 500; display: block; }
.results .hit-main span { font-size: 12px; color: var(--muted); font-family: var(--mono); }
.results .hit-price { font-family: var(--mono); font-weight: 600; }

.cart-line {
  display: flex; align-items: center; gap: 12px; padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft);
}
.cart-line:last-child { border-bottom: none; }
.cart-line .name { flex: 1; min-width: 0; }
.cart-line .name b { font-weight: 500; }
.cart-line .name span { display: block; font-size: 12px; color: var(--muted); font-family: var(--mono); }
.qty {
  display: flex; align-items: center; border: 1.5px solid var(--line);
  border-radius: var(--r-sm); overflow: hidden;
}
.qty button {
  border: none; background: none; width: 32px; height: 34px; cursor: pointer;
  color: var(--muted); font-size: 17px; -webkit-tap-highlight-color: transparent;
}
.qty button:hover { background: var(--surface); color: var(--ink); }
.qty input {
  width: 48px; border: none; text-align: center; padding: 0; height: 34px;
  font-family: var(--mono); border-radius: 0;
  border-left: 1.5px solid var(--line); border-right: 1.5px solid var(--line);
}

.totals { padding: 15px 17px; }
.totals .line {
  display: flex; justify-content: space-between; padding: 5px 0;
  font-size: 13.5px; color: var(--muted);
}
.totals .line b { font-family: var(--mono); color: var(--ink); font-weight: 500; }
.totals .grand {
  display: flex; justify-content: space-between; align-items: baseline;
  border-top: 1.5px dashed var(--line); margin-top: 11px; padding-top: 13px;
}
.totals .grand span {
  font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted);
}
.totals .grand b {
  font-family: var(--mono); font-size: 29px; font-weight: 700; letter-spacing: -.04em;
}

.pay-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.pay-methods button {
  padding: 14px 10px; border: 1.5px solid var(--line); border-radius: var(--r-sm);
  background: var(--card); cursor: pointer; font-size: 13.5px; font-weight: 500;
  text-align: center; transition: border-color .14s var(--ease), background .14s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.pay-methods button:hover { border-color: var(--esd); background: var(--esd-soft); }
.pay-methods button:active { transform: scale(.97); }
.pay-list { margin-top: 13px; }
.pay-list .p {
  display: flex; align-items: center; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line-soft); font-size: 13.5px;
}
.pay-list .p b { font-family: var(--mono); margin-left: auto; }

/* -------------------------------- gráficos --------------------------- */
.chart { width: 100%; height: 210px; display: block; }
.chart .grid-line { stroke: var(--line-soft); stroke-width: 1; }
.chart .area { fill: url(#areaFill); }
.chart .line { fill: none; stroke: var(--esd); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart .bar { fill: var(--esd); }
.chart text { font-size: 10px; fill: var(--muted); font-family: var(--mono); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); padding: 0 17px 15px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.bar-row { display: flex; align-items: center; gap: 11px; padding: 7px 0; font-size: 13.5px; }
.bar-row .n { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .track {
  width: 100px; height: 7px; border-radius: 4px; background: var(--surface);
  overflow: hidden; flex: none;
}
.bar-row .track i { display: block; height: 100%; background: var(--esd); border-radius: 4px; }
.bar-row .v { font-family: var(--mono); font-size: 12.5px; width: 96px; text-align: right; flex: none; }

/* --------------------------- abas e filtros -------------------------- */
.tabs {
  display: flex; gap: 4px; border-bottom: 1px solid var(--line);
  margin-bottom: 18px; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: none; background: none; padding: 10px 14px; cursor: pointer; font-size: 14px;
  color: var(--muted); border-bottom: 2.5px solid transparent; margin-bottom: -1px;
  white-space: nowrap; -webkit-tap-highlight-color: transparent;
}
.tabs button.on { color: var(--esd); border-bottom-color: var(--esd); font-weight: 600; }

.filters { display: flex; gap: 9px; flex-wrap: wrap; margin-bottom: 15px; align-items: center; }
.filters input, .filters select { width: auto; min-width: 140px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chips button {
  padding: 6px 13px; border: 1.5px solid var(--line); background: var(--card);
  border-radius: var(--r-pill); cursor: pointer; font-size: 12.5px; color: var(--muted);
  -webkit-tap-highlight-color: transparent;
}
.chips button.on { background: var(--ink); border-color: var(--ink); color: var(--card); }

/* -------------------------------- alertas ---------------------------- */
.bell { position: relative; padding: 8px; flex: none; }
.bell svg { width: 20px; height: 20px; }
.bell-count {
  position: absolute; top: 2px; right: 1px;
  min-width: 17px; height: 17px; padding: 0 4px;
  border-radius: var(--r-pill); background: var(--danger); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 600;
  display: grid; place-items: center; line-height: 1;
}
.bell-count.calm { background: var(--esd); }

.panel {
  position: fixed; top: calc(var(--topbar) + var(--safe-top) - 4px); right: 16px;
  width: 400px; max-width: calc(100vw - 24px);
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); z-index: 85; overflow: hidden;
  animation: pop .16s var(--ease);
}
.panel header {
  padding: 13px 15px; border-bottom: 1px solid var(--line-soft);
  display: flex; align-items: center; gap: 8px;
}
.panel header h4 { font-size: 14.5px; flex: 1; }
.panel .list { max-height: min(62dvh, 480px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
.alert {
  display: flex; gap: 11px; padding: 12px 15px;
  border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.alert:last-child { border-bottom: none; }
.alert:hover { background: var(--card-2); }
.alert.unread { background: var(--esd-soft); }
.alert .mark { width: 5px; border-radius: 3px; flex: none; background: var(--esd); }
.alert .mark.aviso { background: var(--amber); }
.alert .mark.urgente { background: var(--danger); }
.alert .txt { flex: 1; min-width: 0; }
.alert .txt b { display: block; font-weight: 500; font-size: 13.5px; }
.alert .txt span { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.alert .when { font-size: 11px; color: var(--muted); font-family: var(--mono); flex: none; }

/* ---------------------- paleta de comandos --------------------------- */
.cmd-overlay {
  position: fixed; inset: 0; background: rgba(11,18,32,.52);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  z-index: 90; display: flex; justify-content: center;
  padding: 11vh 16px 16px; animation: fade .12s var(--ease);
}
.cmd {
  width: 100%; max-width: 640px; align-self: flex-start;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .14s var(--ease);
  display: flex; flex-direction: column; max-height: 72dvh;
}
.cmd-head {
  display: flex; align-items: center; gap: 11px; padding: 15px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.cmd-head svg { color: var(--muted); flex: none; }
.cmd-head input { border: none; padding: 0; font-size: 16.5px; background: transparent; }
.cmd-head input:focus { box-shadow: none; }
.cmd-list { overflow-y: auto; flex: 1; padding: 7px 0; -webkit-overflow-scrolling: touch; }
.cmd-group {
  padding: 9px 18px 5px; font-size: 10.5px; text-transform: uppercase;
  letter-spacing: .09em; color: var(--muted); font-weight: 600;
}
.cmd-item { display: flex; align-items: center; gap: 12px; padding: 10px 18px; cursor: pointer; }
.cmd-item.sel { background: var(--esd-soft); }
.cmd-txt { flex: 1; min-width: 0; }
.cmd-txt b { display: block; font-weight: 500; font-size: 14.5px; }
.cmd-txt span {
  display: block; font-size: 12.5px; color: var(--muted); font-family: var(--mono);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cmd-empty { padding: 30px 18px; text-align: center; color: var(--muted); font-size: 13.5px; }
.cmd-foot {
  display: flex; gap: 16px; padding: 11px 18px calc(11px + var(--safe-bottom));
  border-top: 1px solid var(--line-soft); font-size: 11.5px; color: var(--muted);
  background: var(--surface);
}
.cmd-foot kbd { margin-right: 4px; }

/* ------------------------------- faixas ------------------------------ */
.support-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 99;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  background: var(--danger); color: #fff; font-size: 12.5px;
  box-shadow: 0 2px 12px rgba(0,0,0,.24);
}
.support-banner span:first-child { flex: 1; min-width: 220px; }
body.has-support-banner .rail,
body.has-support-banner .topbar { top: 36px; }
body.has-support-banner main { padding-top: calc(var(--topbar) + var(--safe-top) + 58px); }

.sub-banner {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 11px 15px; border-radius: var(--r); margin-bottom: 17px;
  font-size: 13.5px; border: 1px solid var(--line);
}
.sub-banner.warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 28%, var(--line)); color: var(--amber); }
.sub-banner.bad  { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 28%, var(--line)); color: var(--danger); }
.sub-banner span { flex: 1; min-width: 200px; }

/* =====================================================================
   CELULAR — a interface passa a se comportar como aplicativo
   ===================================================================== */
@media (max-width: 1100px) {
  .pdv { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  body { font-size: 15.5px; }

  /* o painel lateral vira gaveta, acionada pela aba "Mais" */
  .rail {
    width: min(86vw, 320px);
    transform: translateX(-100%);
    transition: transform .26s var(--ease);
    box-shadow: var(--shadow-lg);
    will-change: transform;
  }
  body.nav-open .rail { transform: none; }

  .sheet-backdrop {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(11,18,32,.45);
    opacity: 0; pointer-events: none; transition: opacity .26s var(--ease);
  }
  body.nav-open .sheet-backdrop { opacity: 1; pointer-events: auto; }

  /* cabeçalho enxuto, como app: título à esquerda, ações à direita */
  .topbar {
    left: 0; padding: var(--safe-top) 14px 0; gap: 8px;
    height: calc(56px + var(--safe-top));
  }
  .topbar h2 { font-size: 18px; font-weight: 600; letter-spacing: -.03em; }
  .search { display: none; }
  .cash-pill { padding: 6px 11px; }
  .cash-pill .label, .cash-pill .amount { display: none; }

  main {
    margin-left: 0;
    padding: calc(56px + var(--safe-top) + 16px) 14px calc(var(--tabbar) + var(--safe-bottom) + 24px);
  }

  /* barra de abas inferior */
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 70;
    background: color-mix(in srgb, var(--card) 92%, transparent);
    backdrop-filter: saturate(1.6) blur(14px);
    -webkit-backdrop-filter: saturate(1.6) blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-bottom);
  }
  .tabbar button {
    flex: 1; border: none; background: none; cursor: pointer; position: relative;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px; padding: 9px 4px 7px; min-height: var(--tabbar);
    color: var(--muted); font-size: 10.5px; font-weight: 500;
    -webkit-tap-highlight-color: transparent;
    transition: color .14s var(--ease), transform .08s var(--ease);
  }
  .tabbar button svg { width: 22px; height: 22px; stroke-width: 1.8; }
  .tabbar button.on { color: var(--esd); }
  .tabbar button.on svg { stroke-width: 2.3; }
  .tabbar button:active { transform: scale(.94); }
  .tabbar .tab-badge {
    position: absolute; top: 7px; left: 50%; margin-left: 5px;
    min-width: 9px; height: 9px; border-radius: var(--r-pill);
    background: var(--danger); border: 2px solid var(--card);
  }

  /* janela vira folha que sobe de baixo */
  .overlay { place-items: end center; padding: 0; }
  .modal, .modal.wide {
    max-width: 100%; width: 100%;
    max-height: 92dvh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    animation: sobe .3s var(--ease);
  }
  @keyframes sobe { from { transform: translateY(100%); } }
  .sheet-grab {
    display: block; width: 42px; height: 4.5px; border-radius: 3px;
    background: var(--line); margin: 9px auto 0; flex: none;
  }
  .modal > header { padding: 12px 18px 14px; }
  .modal > header h4 { font-size: 17px; }
  .modal .content { padding: 18px; }
  .modal > footer {
    padding: 13px 18px calc(13px + var(--safe-bottom));
    gap: 9px;
  }
  .modal > footer .btn { flex: 1; min-width: 42%; padding: 13px 14px; }

  /* alertas ocupam a largura toda, como notificação de app */
  .panel {
    top: auto; bottom: calc(var(--tabbar) + var(--safe-bottom));
    left: 0; right: 0; width: auto; max-width: none;
    border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: none;
    animation: sobe .26s var(--ease);
  }
  .panel .list { max-height: 60dvh; }

  .cmd-overlay { padding: 0; align-items: flex-end; }
  .cmd { max-width: 100%; border-radius: var(--r-lg) var(--r-lg) 0 0; max-height: 82dvh; }

  .toasts { bottom: calc(var(--tabbar) + var(--safe-bottom) + 14px); align-items: stretch; }
  .toast { max-width: none; }

  /* alvos de toque maiores e controles confortáveis */
  .btn { padding: 12px 18px; font-size: 15px; }
  .btn.sm { padding: 9px 13px; font-size: 13.5px; }
  input, select, textarea { padding: 13px 14px; font-size: 16px; }  /* 16px evita o zoom do iOS */
  .qty button { width: 42px; height: 44px; font-size: 19px; }
  .qty input { height: 44px; width: 54px; }
  .pay-methods button { padding: 17px 10px; font-size: 14.5px; }
  .rail a { padding: 13px 12px; font-size: 15px; }
  .tabs button { padding: 12px 15px; font-size: 14.5px; }
  .chips button { padding: 8px 15px; font-size: 13px; }

  .page-head { margin-bottom: 16px; }
  .page-head h3 { font-size: 22px; }
  .kpis { gap: 11px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .kpi { padding: 13px 15px; }
  .kpi .value { font-size: 20px; }

  body.has-support-banner .rail,
  body.has-support-banner .topbar { top: 40px; }
  body.has-support-banner main { padding-top: calc(56px + var(--safe-top) + 56px); }
}

/* tabela larga vira cartão: cada linha é um bloco legível */
@media (max-width: 640px) {
  .table-wrap table, .table-wrap thead, .table-wrap tbody,
  .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap thead { display: none; }
  .table-wrap tbody tr {
    border: 1px solid var(--line); border-radius: var(--r);
    margin: 11px 13px; padding: 5px 0; background: var(--card);
    box-shadow: var(--shadow-xs);
  }
  .table-wrap tbody tr:first-child { margin-top: 13px; }
  .table-wrap td {
    display: flex; align-items: center; gap: 12px;
    padding: 8px 15px; border: none; text-align: left;
  }
  .table-wrap td::before {
    content: attr(data-label);
    flex: none; width: 38%; max-width: 130px;
    font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em;
    color: var(--muted); font-weight: 600;
  }
  .table-wrap td:empty { display: none; }
  .table-wrap td[data-label=""] { justify-content: flex-end; }
  .table-wrap td[data-label=""]::before { display: none; }
  .table-wrap td.num { justify-content: space-between; }
  .table-wrap tbody td:first-child { padding-top: 12px; font-size: 16px; }
  .table-wrap tbody td:first-child::before { display: none; }

  .row { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { gap: 13px; }
  .totals .grand b { font-size: 26px; }
}

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

/* -------------------------------- impressão --------------------------- */
#print-area { display: none; }
@media print {
  body > *:not(#print-area) { display: none !important; }
  #print-area {
    display: block; font-family: var(--mono); font-size: 12px; color: #000;
    width: 80mm; margin: 0 auto;
  }
  #print-area h1 { font-size: 14px; text-align: center; margin-bottom: 2px; }
  #print-area .center { text-align: center; }
  #print-area hr { border: none; border-top: 1px dashed #000; margin: 6px 0; }
  #print-area table { width: 100%; font-size: 11px; }
  #print-area td { padding: 1px 0; border: none; }
  #print-area .r { text-align: right; }
  @page { margin: 4mm; }
}
