/* Ateliê das Graças: painel (PDV, estoque, CRM e financeiro). */
@font-face { font-family: "Extenda Trial"; src: local("Extenda Trial"), local("Extenda 40 Hecto Trial"), local("ExtendaTrial"); font-display: swap; }
:root {
  --navy: #1f3a68; --blue: #2f5597; --sky: #dfe8f5; --mist: #eef3fa;
  --ivory: #f3f5f8; --paper: #f5f6f8; --ink: #1b2537; --muted: #6b7489; --line: #e6e8ee;
  --ok: #2a7a4a; --warn: #b7791f; --bad: #b03a3a;
  --brand: Pacifico, cursive; --display: "Extenda Trial", Montserrat, system-ui, sans-serif; --sans: Montserrat, system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
}
* { box-sizing: border-box; }
html { touch-action: manipulation; } /* sem zoom de toque duplo */
body { margin: 0; display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; background: var(--paper); color: var(--ink); font: 400 14px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; }
h1, h2, h3 { margin: 0; font-family: var(--sans); font-weight: 700; letter-spacing: -.01em; color: var(--navy); }
table, .kpi b, .sum, .bars { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ---------- Lateral ---------- */
.side { position: sticky; top: 0; height: 100vh; background: var(--navy); color: #d6e0f0; display: flex; flex-direction: column; padding: 20px 14px; }
.side__brand { display: flex; align-items: center; gap: 10px; padding: 0 6px 22px; border-bottom: 1px solid rgba(255, 255, 255, .1); }
.side__brand img { width: 44px; height: 44px; border-radius: 50%; object-fit: contain; background: #fff; padding: 5px 0 3px; }
.side__brand span { font-family: var(--brand); font-size: 18px; color: #fff; line-height: 1.25; }
.side__brand small { display: block; font: 500 9.5px var(--sans); letter-spacing: .22em; text-transform: uppercase; color: #9fb3d4; margin-top: 4px; }
.side__nav { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; }
.side__nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; font-weight: 500; font-size: 13.5px; transition: background-color .25s; }
.side__nav a svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.side__nav a:hover { background: rgba(255, 255, 255, .07); }
.side__nav a[aria-current="page"] { background: #fff; color: var(--navy); }
.side__nav .badge { margin-left: auto; background: #f2b35b; color: #3a2a0a; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 0 7px; }
.side__foot { margin-top: auto; display: grid; gap: 8px; font-size: 12.5px; padding: 0 8px; }
.side__foot button { text-align: left; color: #9fb3d4; font-size: 12px; text-decoration: underline; }
.side__backdrop { display: none; }
.live { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: #9fb3d4; margin-bottom: 4px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; box-shadow: 0 0 0 0 rgba(74, 222, 128, .6); animation: live 2s infinite; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); } }

/* ---------- Topo ---------- */
.main { min-width: 0; }
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 16px; padding: 18px 28px; background: rgba(251, 250, 247, .9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.top h1 { font-size: 21px; line-height: 1.2; }
.top p { margin: 0; color: var(--muted); font-size: 12.5px; }
.top__actions { margin-left: auto; display: flex; gap: 8px; }
.top__menu { display: none; font-size: 22px; color: var(--navy); }
.view { padding: 24px 28px 60px; animation: viewIn .5s var(--ease); }
@keyframes viewIn { from { opacity: 0; translate: 0 10px; } }

/* ---------- Peças ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--navy); color: #fff; font-size: 12.5px; font-weight: 600; letter-spacing: .03em; border: 1px solid var(--navy); transition: background-color .25s, translate .3s var(--ease); white-space: nowrap; }
.btn:hover { background: var(--blue); translate: 0 -1px; }
.btn--ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn--ghost:hover { background: var(--mist); }
.btn--sm { height: 32px; padding: 0 12px; font-size: 12px; }
.btn--ok { background: var(--ok); border-color: var(--ok); }
.btn--bad { background: #fff; color: var(--bad); border-color: #f0d2d2; }
.btn--wa { background: #25d366; border-color: #25d366; }
.btn--block { width: 100%; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; min-width: 0; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
.panel h2 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.panel h2 small { font: 500 12px var(--sans); color: var(--muted); }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: 1.6fr 1fr; } .g2e { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); padding: 16px 18px; position: relative; overflow: hidden; }
.kpi span { font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.kpi b { display: block; font-family: var(--display); font-size: 26px; font-weight: 700; letter-spacing: -.02em; color: var(--navy); line-height: 1.15; margin-top: 4px; position: relative; z-index: 1; }
.kpi small { font-size: 12px; font-weight: 600; }
.up { color: var(--ok); } .down { color: var(--bad); }
.kpi--dark { background: var(--navy); border-color: var(--navy); }
.kpi--dark span, .kpi--dark small { color: #b9c8e2; } .kpi--dark b { color: #fff; }

/* Gráfico de barras em CSS */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 190px; padding-top: 10px; border-bottom: 1px solid var(--line); }
.bars > div { flex: 1; display: flex; align-items: flex-end; gap: 2px; height: 100%; }
.bars i { flex: 1; height: var(--h); min-height: 2px; background: var(--sky); border-radius: 4px 4px 0 0; transition: background-color .2s; animation: grow .9s var(--ease) both; animation-delay: var(--dl, 0s); transform-origin: bottom; }
.bars i.s2 { background: #f0c6c6; }
.bars > div:hover i { background: var(--blue); } .bars > div:hover i.s2 { background: var(--bad); }
.bars i.today { background: var(--navy); }
@keyframes grow { from { scale: 1 0; } }
.axis { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.hbar { display: grid; grid-template-columns: 130px 1fr auto; gap: 10px; align-items: center; font-size: 13px; margin-bottom: 10px; }
.hbar div { height: 10px; background: var(--mist); border-radius: 5px; overflow: hidden; }
.hbar div i { display: block; height: 100%; background: var(--blue); border-radius: 5px; animation: grow2 1s var(--ease) both; transform-origin: left; }
@keyframes grow2 { from { scale: 0 1; } }

/* Tabelas */
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid #f1eee8; vertical-align: middle; }
tr:hover td { background: #fcfbf8; }
td.num, th.num { text-align: right; white-space: nowrap; }
.thumb { width: 44px; height: 54px; border-radius: 6px; object-fit: cover; background: var(--ivory); }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--mist); color: var(--navy); white-space: nowrap; }
.pill--ok { background: #e3f3e9; color: var(--ok); } .pill--warn { background: #fbf0dc; color: var(--warn); } .pill--bad { background: #f8e3e3; color: var(--bad); }
.list { display: grid; gap: 2px; }
.list > div { display: flex; justify-content: space-between; gap: 10px; padding: 9px 0; border-bottom: 1px solid #f1eee8; font-size: 13.5px; }
.list > div:last-child { border: 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.empty { text-align: center; color: var(--muted); padding: 30px; font-size: 13.5px; }

/* Barra de ferramentas e formulários */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.field { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; font: inherit; font-size: 16px; background: #fff; min-width: 0; }
textarea.field { height: auto; padding: 10px 12px; resize: vertical; }
.field:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px var(--mist); }
.search { flex: 1; min-width: 200px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { height: 32px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: #fff; font-size: 12.5px; font-weight: 500; }
.chip[aria-pressed="true"] { background: var(--navy); color: #fff; border-color: var(--navy); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form label { display: grid; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.form .full { grid-column: 1 / -1; }
.check { display: flex !important; align-items: center; gap: 8px; grid-template-columns: none; color: var(--ink) !important; font-weight: 500 !important; }
.switch { position: relative; width: 38px; height: 22px; border-radius: 11px; background: #d9d5cd; transition: background-color .25s; flex: none; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: translate .3s var(--ease); }
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { translate: 16px 0; }
.drop { position: relative; aspect-ratio: 4 / 5; border: 1.5px dashed #c9d3e4; border-radius: 12px; background: var(--mist) center/cover no-repeat; display: grid; place-items: center; text-align: center; color: var(--navy); font-size: 12px; font-weight: 600; cursor: pointer; overflow: hidden; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.drop span { background: rgba(255, 255, 255, .88); padding: 6px 10px; border-radius: 8px; }

/* PDV */
.pdv { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
.prods { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.prod { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; transition: translate .3s var(--ease), box-shadow .3s; }
.prod:hover { translate: 0 -3px; box-shadow: 0 12px 24px -16px rgba(31, 58, 104, .5); }
.prod img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.prod div { padding: 8px 10px 10px; font-size: 12.5px; line-height: 1.3; }
.prod b { display: block; color: var(--navy); margin-top: 2px; }
.prod:disabled { opacity: .45; cursor: not-allowed; translate: none; box-shadow: none; }
.cart { position: sticky; top: 92px; }
.cart__line { display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid #f1eee8; font-size: 13px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 999px; }
.qty button { width: 26px; height: 26px; color: var(--navy); }
.qty span { min-width: 18px; text-align: center; }
.sum { display: flex; justify-content: space-between; font-size: 13.5px; padding: 3px 0; }
.sum--total { font-size: 20px; font-weight: 700; color: var(--navy); padding-top: 8px; border-top: 1px solid var(--line); margin-top: 6px; }
.pay { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay .chip { height: 38px; }

/* Pedidos */
.orders { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; }
.order { background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); padding: 16px; display: grid; gap: 10px; }
.order header { display: flex; justify-content: space-between; align-items: center; }
.order h3 { font-size: 15px; }
.order ul { margin: 0; padding-left: 18px; font-size: 13px; }
.order footer { display: flex; flex-wrap: wrap; gap: 6px; }

/* Modal e aviso */
.modal { width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); border: 0; border-radius: 18px; padding: 0; background: #fff; }
.modal::backdrop { background: rgba(15, 28, 52, .45); }
.modal[open] { animation: viewIn .45s var(--ease); }
.modal__head { display: flex; justify-content: space-between; align-items: center; padding: 18px 22px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; z-index: 1; }
.modal__head h2 { font-size: 18px; }
.modal__body { padding: 20px 22px; }
.modal__foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--line); position: sticky; bottom: 0; background: #fff; }
.x { font-size: 26px; line-height: 1; color: var(--navy); }
.toast { position: fixed; left: 50%; bottom: 24px; z-index: 99; translate: -50% 20px; opacity: 0; background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 999px; font-size: 13px; transition: opacity .35s, translate .45s var(--ease); pointer-events: none; }
.toast.on { opacity: 1; translate: -50% 0; }

@media (max-width: 1100px) {
  .g2, .g2e, .g3, .pdv { grid-template-columns: 1fr; }
  .cart { position: static; }
}
@media (max-width: 860px) {
  body { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 50; inset: 0 auto 0 0; width: 260px; translate: -100% 0; transition: translate .45s var(--ease); }
  .side[data-open="true"] { translate: 0 0; }
  .side[data-open="true"] + .side__backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(15, 28, 52, .4); }
  .top { padding: 14px 16px; }
  .top__menu { display: block; }
  .top h1 { font-size: 19px; }
  .top p { display: none; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi--dark { grid-column: 1 / -1; }
  .kpi { padding: 14px; }
  .kpi b { font-size: 21px; }
  .kpi span { font-size: 10px; }
  .kpi small { font-size: 11px; }
  .panel { padding: 16px; }
  .view { padding: 16px 16px 60px; }
  .form { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 100px 1fr auto; }
}

/* ---------- Celular: venda atual como gaveta e tabelas como cartões ---------- */
.cart__head { cursor: default; }
@media (max-width: 860px) {
  /* PDV: a caixa fica presa embaixo mostrando só o topo (itens e total) e sobe ao escolher um produto. */
  /* Aberta, ocupa só a metade de baixo: os produtos continuam visíveis e clicáveis em cima,
     e a página ganha espaço embaixo para rolar até o último produto. */
  .pdv { padding-bottom: 70px; }
  .pdv:has(.cart.aberto) { padding-bottom: 54vh; }
  .cart { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; top: auto; max-height: 50vh; overflow-y: auto; overscroll-behavior: contain;
    border-radius: 22px 22px 0 0; border-bottom: 0; padding-top: 0; box-shadow: 0 -16px 40px -18px rgba(15, 28, 52, .45);
    translate: 0 calc(100% - 54px); transition: translate .55s var(--ease); }
  .cart.aberto { translate: 0 0; }
  .cart__head { position: sticky; top: 0; z-index: 1; background: #fff; margin: 0 -16px 8px !important; padding: 20px 16px 10px; cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; }
  .cart__head::before { content: ""; position: absolute; top: 8px; left: 50%; width: 42px; height: 4px; margin-left: -21px; border-radius: 2px; background: #d5d9e1; }
  .cart__head small { color: var(--navy) !important; font-weight: 700 !important; font-size: 13px !important; }

  /* Tabelas: cada linha vira um cartão com "nome da coluna  valor", sem arrastar para o lado. */
  .panel.tbl-wrap { background: none; border: 0; box-shadow: none; padding: 0; overflow: visible; }
  .tbl-wrap table, .tbl-wrap tbody, .tbl-wrap tr, .tbl-wrap td { display: block; width: 100%; }
  .tbl-wrap thead { display: none; }
  .tbl-wrap tr { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px; margin-bottom: 10px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04); }
  .tbl-wrap tr:hover td { background: none; }
  .tbl-wrap td { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px dashed #eceef2; text-align: right; }
  .tbl-wrap td:last-child { border-bottom: 0; }
  .tbl-wrap td::before { content: attr(data-label); flex: none; font-size: 10.5px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); text-align: left; }
  .tbl-wrap td[data-label=""]::before { display: none; }
  .tbl-wrap td[data-label=""] { justify-content: flex-end; }
  .tbl-wrap td:first-child[data-label=""] { justify-content: center; }
  .tbl-wrap td .thumb { width: 72px; height: 88px; border-radius: 10px; }
}

/* ---------- Login do painel ---------- */
.login { position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 20px; background: radial-gradient(80% 60% at 50% 0%, #2f5597, #1f3a68 70%); }
.login__box { width: min(380px, 100%); background: #fff; border-radius: 22px; padding: 30px 26px; display: grid; gap: 14px; text-align: center; box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .5); }
.login__box img { width: 64px; margin: 0 auto; }
.login__box h1 { font-family: var(--brand); font-weight: 400; font-size: 26px; }
.login__box .muted { margin: -10px 0 4px; }
.login__box label { display: grid; gap: 6px; text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); }
.login__aviso { margin: 0; padding: 10px 12px; border-radius: 10px; background: #fbf0dc; color: var(--warn); font-size: 13px; }
.login__link { font-size: 12.5px; color: var(--blue); text-decoration: underline; }
.login__bio { width: 56px; height: 56px; margin: 0 auto; fill: none; stroke: var(--navy); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
