/* ===================================================
   REPÚBLICA DO NARGA — PAINEL V3
   Mesmo sistema visual do catálogo · mobile-first
   =================================================== */

:root {
  --bg: #060807;
  --bg-2: #0a0d0c;
  --surface: #0e1211;
  --surface-2: #141918;
  --surface-3: #1a2120;
  --line: rgba(255, 255, 255, .07);
  --line-2: rgba(255, 255, 255, .12);
  --text: #f1f5f3;
  --muted: #9aa6a1;
  --dim: #66716c;

  --brand: #34f59a;
  --brand-2: #9dff6b;
  --brand-ink: #03140b;
  --brand-soft: rgba(52, 245, 154, .12);
  --amber: #ffbe5c;
  --blue: #4cc9ff;
  --violet: #b48cff;
  --danger: #ff6b86;
  --wa: #25d366;
  --pix: #32bcad;

  --font-display: 'Unbounded', 'Manrope', system-ui, sans-serif;
  --font-ui: 'Manrope', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
  --ease: cubic-bezier(.22, 1, .36, 1);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --gutter: 16px;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html.locked, html.locked body { overflow: hidden; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 8px; }

.ic { width: 1.15em; height: 1.15em; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: middle; }

/* ---------- BOTÕES / CAMPOS ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 16px; border-radius: 12px;
  font-weight: 700; font-size: .86rem; white-space: nowrap;
  transition: transform .2s var(--ease), background .2s, border-color .2s, opacity .2s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn .ic { width: 17px; height: 17px; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: var(--brand-ink); }
.btn-ghost { border: 1px solid var(--line-2); background: var(--surface); color: var(--text); }
.btn-ghost:hover { border-color: rgba(255, 255, 255, .22); }
.btn-danger { border: 1px solid rgba(255, 107, 134, .35); color: var(--danger); background: rgba(255, 107, 134, .06); }
.btn-wa { background: var(--wa); color: #04210f; }
.btn-sm { height: 34px; padding: 0 12px; font-size: .8rem; border-radius: 10px; }
.btn-block { width: 100%; }
.link { color: var(--brand); font-size: .78rem; font-weight: 700; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--muted);
  transition: color .2s, border-color .2s;
}
.icon-btn:hover { color: var(--text); border-color: rgba(255, 255, 255, .22); }
.icon-btn .ic { width: 18px; height: 18px; }
.icon-btn.spin .ic { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.field label em { color: var(--danger); font-style: normal; }
.field small { font-size: .72rem; color: var(--dim); }
.field input, .field select, .field textarea, .select {
  width: 100%; height: 44px; padding: 0 12px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--line-2); outline: 0;
  font-size: 16px; transition: border-color .2s, box-shadow .2s;
}
.field textarea { height: auto; min-height: 84px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
.field input:focus, .field select:focus, .field textarea:focus, .select:focus { border-color: rgba(52, 245, 154, .5); box-shadow: 0 0 0 4px rgba(52, 245, 154, .08); }
.select { font-size: .86rem; color: var(--text); color-scheme: dark; }
select.select, .field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239aa6a1' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m7 10 5 5 5-5'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 32px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.form-error { color: var(--danger); font-size: .82rem; font-weight: 600; }
.hint { color: var(--dim); font-size: .78rem; margin-bottom: 12px; }

.money-input { position: relative; }
.money-input::before { content: 'R$'; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--dim); font-size: .82rem; font-weight: 700; pointer-events: none; }
.money-input input { padding-left: 36px; }

.toggle { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: .84rem; font-weight: 600; user-select: none; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.toggle span { width: 40px; height: 24px; border-radius: 999px; background: var(--surface-3); border: 1px solid var(--line-2); position: relative; transition: background .25s; flex: none; }
.toggle span::after { content: ''; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transition: transform .3s var(--ease), background .25s; }
.toggle input:checked + span { background: var(--brand); border-color: var(--brand); }
.toggle input:checked + span::after { transform: translateX(16px); background: var(--brand-ink); }
.toggle input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* ---------- LOGIN ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: radial-gradient(60% 40% at 50% 0%, rgba(52, 245, 154, .1), transparent 70%); }
.login-card { width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; padding: 28px 22px; border-radius: 24px; background: var(--surface); border: 1px solid var(--line-2); }
.login-logo { border-radius: 50%; margin: 0 auto; box-shadow: 0 0 0 1px var(--line-2), 0 0 40px -6px rgba(52, 245, 154, .45); }
.login-card h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.2rem; text-align: center; }
.login-card > p { text-align: center; color: var(--muted); font-size: .84rem; margin-top: -8px; }

/* ---------- LAYOUT ---------- */
.app { min-height: 100dvh; }
.side {
  position: fixed; z-index: 50; left: 0; right: 0; bottom: 0;
  background: rgba(10, 13, 12, .94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line); padding-bottom: var(--safe-b);
}
.side-brand, .side-foot { display: none; }
.nav { display: grid; grid-template-columns: repeat(6, 1fr); }
.nav button {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 2px 8px; font-size: .62rem; font-weight: 700; color: var(--dim); transition: color .2s;
}
.nav button .ic { width: 21px; height: 21px; }
.nav button.active { color: var(--brand); }
.nav-badge { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 999px; background: var(--danger); color: #fff; font-size: .62rem; display: grid; place-items: center; }

.main { padding: 0 var(--gutter) calc(90px + var(--safe-b)); max-width: 1400px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 0 14px; position: sticky; top: 0; z-index: 30; background: rgba(6, 8, 7, .9); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.topbar h1 { font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; letter-spacing: -.02em; }
.topbar p { color: var(--dim); font-size: .8rem; }
.topbar-actions { display: flex; gap: 8px; }

.view { display: none; animation: fadeUp .4s var(--ease); }
.view.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } }

/* ---------- COMPONENTES ---------- */
.period { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 14px; }
.period::-webkit-scrollbar { display: none; }
.period button { flex: none; height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); font-size: .8rem; font-weight: 700; color: var(--muted); }
.period button.active { background: var(--brand-soft); border-color: rgba(52, 245, 154, .45); color: var(--brand); }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { padding: 14px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); min-width: 0; }
.kpi-top { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.kpi-top .ic { width: 17px; height: 17px; color: var(--k, var(--brand)); }
.kpi strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; letter-spacing: -.03em; margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi small { color: var(--dim); font-size: .72rem; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
.panel { padding: 16px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.panel-head h3 { font-size: .92rem; font-weight: 800; }
.chart-box { position: relative; height: 240px; }

.rank { display: flex; flex-direction: column; }
.rank-row { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rank-row:last-child { border-bottom: 0; }
.rank-row img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; background: #000; }
.rank-row b { display: block; font-size: .84rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-row small { color: var(--dim); font-size: .72rem; }
.rank-row .val { text-align: right; font-weight: 800; font-size: .84rem; white-space: nowrap; }
.rank-row .val small { display: block; font-weight: 600; }
.empty-sm { color: var(--dim); font-size: .82rem; padding: 14px 0; text-align: center; }

.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 32px; gap: 10px; align-items: center; font-size: .8rem; }
.bar-row span { color: var(--muted); }
.bar-track { height: 8px; border-radius: 8px; background: var(--surface-3); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 8px; background: var(--c, var(--brand)); transition: width .8s var(--ease); }
.bar-row b { text-align: right; }

.mixes { display: flex; flex-direction: column; gap: 14px; }
.mix h4 { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); margin-bottom: 6px; }
.mix-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.mix-chips span { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line); font-size: .78rem; font-weight: 600; }
.mix-chips b { color: var(--brand); }

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.search { flex: 1 1 220px; height: 42px; display: flex; align-items: center; gap: 8px; padding: 0 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); }
.search .ic { color: var(--dim); }
.search input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: 0; font-size: 16px; }
.toolbar .select { height: 42px; flex: 1 1 150px; width: auto; }
.dates { display: flex; gap: 6px; flex: 1 1 260px; }
.dates .select { flex: 1; min-width: 0; padding-right: 8px; }
.seg-switch { display: inline-flex; padding: 3px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); }
.seg-switch button { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 9px; font-size: .8rem; font-weight: 700; color: var(--muted); }
.seg-switch button.active { background: var(--surface-3); color: var(--text); }
.seg-switch .ic { width: 16px; height: 16px; }

/* Status */
.pill { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: .68rem; font-weight: 800; letter-spacing: .02em; white-space: nowrap; border: 1px solid; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.st-new { color: var(--brand); background: rgba(52, 245, 154, .08); border-color: rgba(52, 245, 154, .3); }
.st-preparing { color: var(--amber); background: rgba(255, 190, 92, .08); border-color: rgba(255, 190, 92, .3); }
.st-shipped { color: var(--blue); background: rgba(76, 201, 255, .08); border-color: rgba(76, 201, 255, .3); }
.st-completed { color: #8fd8b0; background: rgba(143, 216, 176, .06); border-color: rgba(143, 216, 176, .25); }
.st-cancelled { color: var(--danger); background: rgba(255, 107, 134, .06); border-color: rgba(255, 107, 134, .3); }
.st-paused { color: var(--muted); background: var(--surface-2); border-color: var(--line-2); }
.st-out_of_stock { color: var(--danger); background: rgba(255, 107, 134, .06); border-color: rgba(255, 107, 134, .3); }
.st-available { color: var(--brand); background: rgba(52, 245, 154, .08); border-color: rgba(52, 245, 154, .3); }
.st-low { color: var(--amber); background: rgba(255, 190, 92, .08); border-color: rgba(255, 190, 92, .3); }
.ship-free { color: var(--brand); }
.ship-priced { color: var(--blue); }
.ship-quote { color: var(--amber); }

/* Pedidos: histórico */
.orders-sum, .prod-sum { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--dim); font-size: .78rem; margin-bottom: 10px; }
.orders-sum b, .prod-sum b { color: var(--text); }
.orders-list { display: flex; flex-direction: column; gap: 8px; }
.order-row {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 12px; align-items: center;
  padding: 12px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line);
  text-align: left; width: 100%; transition: border-color .2s, background .2s;
}
.order-row:hover { border-color: var(--line-2); background: var(--surface-2); }
.or-main { min-width: 0; }
.or-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.or-num { font-family: var(--font-mono); font-size: .78rem; color: var(--brand); }
.or-name { font-weight: 800; font-size: .9rem; }
.or-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; color: var(--dim); font-size: .74rem; margin-top: 3px; }
.or-meta span { display: inline-flex; align-items: center; gap: 4px; }
.or-meta .ic { width: 13px; height: 13px; }
.or-side { text-align: right; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.or-total { font-family: var(--font-display); font-weight: 600; font-size: .95rem; letter-spacing: -.02em; white-space: nowrap; }
.or-items { grid-column: 1 / -1; color: var(--muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.day-sep { font-size: .7rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--dim); padding: 10px 2px 2px; }

/* Kanban */
.kanban { display: grid; grid-auto-flow: column; grid-auto-columns: 86%; gap: 10px; overflow-x: auto; scroll-snap-type: x mandatory; padding-bottom: 8px; margin: 0 calc(var(--gutter) * -1); padding-left: var(--gutter); padding-right: var(--gutter); scroll-padding: 0 var(--gutter); }
.kcol { scroll-snap-align: start; background: var(--bg-2); border: 1px solid var(--line); border-radius: 18px; padding: 10px; display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.kcol-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 4px 6px; font-size: .78rem; font-weight: 800; }
.kcol-head span { color: var(--dim); font-family: var(--font-mono); }
.kcard { padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 6px; text-align: left; width: 100%; }
.kcard:hover { border-color: var(--line-2); }
.kcard-top { display: flex; justify-content: space-between; align-items: center; gap: 6px; font-size: .74rem; color: var(--dim); }
.kcard b { font-size: .86rem; }
.kcard ul { list-style: none; font-size: .76rem; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px; margin-top: 2px; }
.kcard-foot strong { font-family: var(--font-display); font-weight: 600; font-size: .86rem; }
.kmove { display: flex; gap: 4px; }
.kmove button { height: 30px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); font-size: .74rem; font-weight: 700; display: inline-flex; align-items: center; gap: 4px; }
.kmove button.go { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.kmove .ic { width: 14px; height: 14px; }

/* Produtos */
.prod-list { display: flex; flex-direction: column; gap: 8px; }
.prod-row { display: grid; grid-template-columns: 56px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.prod-row.paused { opacity: .55; }
.prod-row img { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: #000; cursor: pointer; }
.pr-main { min-width: 0; cursor: pointer; }
.pr-main b { display: block; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-size: .74rem; color: var(--dim); margin-top: 3px; }
.pr-meta .sku { font-family: var(--font-mono); color: var(--muted); }
.pr-price { font-weight: 800; color: var(--text); }
.pr-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.stock-step { display: inline-flex; align-items: center; height: 32px; border-radius: 10px; border: 1px solid var(--line-2); background: var(--bg-2); }
.stock-step button { width: 30px; height: 100%; display: grid; place-items: center; color: var(--muted); }
.stock-step button:hover { color: var(--brand); }
.stock-step .ic { width: 14px; height: 14px; }
.stock-step output { min-width: 28px; text-align: center; font-weight: 800; font-size: .84rem; font-variant-numeric: tabular-nums; }
.stock-step.low output { color: var(--amber); }
.stock-step.zero output { color: var(--danger); }
.pr-btns { display: flex; gap: 4px; }
.pr-btns .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
.pr-btns .icon-btn .ic { width: 15px; height: 15px; }

/* Tabela desempenho */
.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); background: var(--surface); }
.table { width: 100%; border-collapse: collapse; font-size: .82rem; min-width: 820px; }
.table th { position: sticky; top: 0; background: var(--surface-2); text-align: left; padding: 11px 12px; font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); cursor: pointer; white-space: nowrap; user-select: none; }
.table th.sorted { color: var(--brand); }
.table th.sorted::after { content: ' ↓'; }
.table th.sorted.asc::after { content: ' ↑'; }
.table td { padding: 10px 12px; border-top: 1px solid var(--line); white-space: nowrap; }
.table tbody tr { cursor: pointer; transition: background .15s; }
.table tbody tr:hover { background: var(--surface-2); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .prod-cell { display: flex; align-items: center; gap: 10px; }
.table .prod-cell img { width: 34px; height: 34px; border-radius: 9px; object-fit: cover; background: #000; }
.table .prod-cell b { display: block; max-width: 220px; overflow: hidden; text-overflow: ellipsis; }
.table .prod-cell small { color: var(--dim); font-family: var(--font-mono); font-size: .7rem; }
.table .zero { color: var(--dim); }
.conv-hi { color: var(--brand); font-weight: 800; }

/* Frete */
.ship-info { flex-direction: row; align-items: flex-start; gap: 14px; }
.ship-info > .ic { width: 28px; height: 28px; color: var(--brand); margin-top: 2px; }
.ship-info p { color: var(--muted); font-size: .84rem; margin-top: 4px; }
.ship-info p b { color: var(--text); }
.rules { display: flex; flex-direction: column; gap: 8px; }
.rule { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; align-items: center; padding: 12px; border-radius: 14px; background: var(--bg-2); border: 1px solid var(--line); }
.rule.off { opacity: .5; }
.rule b { font-size: .88rem; }
.rule-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: .74rem; color: var(--dim); margin-top: 3px; }
.rule-meta .mono { font-family: var(--font-mono); color: var(--muted); }
.rule-price { font-family: var(--font-display); font-weight: 600; font-size: .95rem; text-align: right; }
.rule-price.free { color: var(--brand); }
.rule-actions { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; }
.rule-tag { font-size: .64rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 7px; border-radius: 6px; background: var(--surface-3); color: var(--muted); margin-right: 6px; }
.sim { display: flex; flex-direction: column; gap: 10px; }
.sim-result { padding: 14px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--bg-2); font-size: .84rem; display: flex; flex-direction: column; gap: 4px; }
.sim-result b { font-size: 1rem; }
.sim-result.free { border-color: rgba(52, 245, 154, .4); }
.sim-result.priced { border-color: rgba(76, 201, 255, .4); }
.sim-result.quote { border-color: rgba(255, 190, 92, .4); }

/* ---------- DRAWER ---------- */
.scrim { position: fixed; inset: 0; z-index: 90; background: rgba(2, 3, 3, .6); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); opacity: 0; visibility: hidden; transition: opacity .35s, visibility .35s; }
.scrim.on { opacity: 1; visibility: visible; }
.drawer {
  position: fixed; z-index: 100; inset: 0;
  display: flex; flex-direction: column; background: var(--bg-2);
  transform: translateY(100%); visibility: hidden; transition: transform .45s var(--ease), visibility .45s;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px var(--gutter) 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; letter-spacing: -.02em; }
.drawer-head p { color: var(--dim); font-size: .78rem; margin-top: 2px; }
.drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 16px var(--gutter) 24px; display: flex; flex-direction: column; gap: 16px; overscroll-behavior: contain; }
.drawer-foot { display: flex; gap: 8px; flex-wrap: wrap; padding: 12px var(--gutter) calc(12px + var(--safe-b)); border-top: 1px solid var(--line); background: var(--bg-2); }
.drawer-foot:empty { display: none; }
.drawer-foot .grow { flex: 1; }

.sec { display: flex; flex-direction: column; gap: 10px; }
.sec-title { font-size: .7rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--dim); display: flex; align-items: center; gap: 6px; }
.sec-title .ic { width: 15px; height: 15px; color: var(--brand); }
.box { padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); display: flex; flex-direction: column; gap: 4px; font-size: .86rem; }
.box .muted { color: var(--muted); }
.kv { display: flex; justify-content: space-between; gap: 10px; font-size: .84rem; }
.kv span:first-child { color: var(--muted); }
.kv.total { padding-top: 8px; margin-top: 4px; border-top: 1px dashed var(--line-2); font-weight: 800; font-size: .95rem; }
.items-tbl { display: flex; flex-direction: column; }
.items-tbl .it { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: .84rem; align-items: center; }
.items-tbl .it:last-child { border-bottom: 0; }
.it-q { font-weight: 800; color: var(--brand); font-family: var(--font-mono); }
.it small { display: block; color: var(--muted); font-size: .74rem; }
.msg-pre { white-space: pre-wrap; font-family: var(--font-mono); font-size: .74rem; line-height: 1.55; color: var(--muted); padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); max-height: 280px; overflow-y: auto; }
.timeline { display: flex; flex-direction: column; gap: 8px; padding-left: 4px; }
.tl-item { display: grid; grid-template-columns: 12px 1fr auto; gap: 10px; align-items: center; font-size: .8rem; }
.tl-item i { width: 9px; height: 9px; border-radius: 50%; background: var(--c, var(--brand)); box-shadow: 0 0 0 3px var(--bg-2), 0 0 0 4px var(--line-2); }
.tl-item time { color: var(--dim); font-family: var(--font-mono); font-size: .72rem; }
.status-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 6px; }
.status-pick button { height: 38px; border-radius: 11px; border: 1px solid var(--line-2); font-size: .78rem; font-weight: 700; color: var(--muted); }
.status-pick button.current { color: var(--text); border-color: var(--brand); background: var(--brand-soft); }
.quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* Editor de produto */
.img-drop { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; }
.img-drop img { width: 96px; height: 96px; border-radius: 16px; object-fit: cover; background: #000; border: 1px solid var(--line-2); }
.img-drop label.btn { cursor: pointer; }
.img-drop input[type=file] { display: none; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px; min-height: 48px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line-2); cursor: text; }
.tags:focus-within { border-color: rgba(52, 245, 154, .5); }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 6px 0 10px; border-radius: 9px; background: var(--surface-3); font-size: .8rem; font-weight: 600; }
.tag button { width: 20px; height: 20px; border-radius: 6px; display: grid; place-items: center; color: var(--dim); }
.tag button:hover { color: var(--danger); }
.tag button .ic { width: 12px; height: 12px; }
.tags input { flex: 1; min-width: 120px; height: 30px; background: none; border: 0; outline: 0; font-size: 16px; }
.margin-note { font-size: .76rem; color: var(--muted); }
.margin-note b { color: var(--brand); }
.seg-pick { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-pick label { position: relative; }
.seg-pick input { position: absolute; opacity: 0; pointer-events: none; }
.seg-pick span { display: grid; place-items: center; height: 40px; border-radius: 11px; border: 1px solid var(--line-2); font-size: .8rem; font-weight: 700; color: var(--muted); cursor: pointer; text-align: center; }
.seg-pick input:checked + span { color: var(--text); border-color: var(--brand); background: var(--brand-soft); }
.flav-bars { display: flex; flex-direction: column; gap: 8px; }

/* ---------- TOASTS ---------- */
.toasts { position: fixed; z-index: 300; top: 12px; left: 50%; transform: translateX(-50%); width: min(380px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 14px; background: rgba(20, 25, 24, .96); border: 1px solid var(--line-2); box-shadow: 0 20px 40px -16px rgba(0, 0, 0, .8); font-size: .84rem; font-weight: 600; animation: toastIn .4s var(--ease); }
.toast .ic { width: 18px; height: 18px; color: var(--brand); }
.toast.err .ic { color: var(--danger); }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-12px); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-8px); } }

.only-m { display: grid; }

/* ===================================================
   BREAKPOINTS
   =================================================== */
@media (max-width: 360px) {
  :root { --gutter: 12px; }
  .nav button { font-size: .56rem; }
  .field-row-3 { grid-template-columns: 1fr 1fr; }
  .bar-row { grid-template-columns: 96px 1fr 28px; }
}

@media (min-width: 640px) {
  :root { --gutter: 24px; }
  .kpis { grid-template-columns: repeat(3, 1fr); }
  .kanban { grid-auto-columns: 300px; }
  .drawer { inset: 0 0 0 auto; width: 540px; border-left: 1px solid var(--line-2); transform: translateX(100%); }
  .drawer.open { transform: none; }
  .order-row { grid-template-columns: 1fr auto; }
}

@media (min-width: 1024px) {
  .side {
    top: 0; right: auto; width: 232px; bottom: 0;
    border-top: 0; border-right: 1px solid var(--line);
    display: flex; flex-direction: column; padding: 20px 14px;
  }
  .side-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
  .side-brand img { border-radius: 50%; box-shadow: 0 0 0 1px rgba(52, 245, 154, .5); }
  .side-brand strong { display: block; font-family: var(--font-display); font-weight: 600; font-size: .95rem; }
  .side-brand small { color: var(--brand); font-size: .66rem; letter-spacing: .3em; text-transform: uppercase; font-weight: 700; }
  .nav { display: flex; flex-direction: column; gap: 2px; }
  .nav button { flex-direction: row; gap: 12px; padding: 0 12px; height: 42px; border-radius: 12px; font-size: .86rem; color: var(--muted); }
  .nav button:hover { color: var(--text); background: rgba(255, 255, 255, .03); }
  .nav button.active { background: var(--brand-soft); color: var(--brand); }
  .nav button .ic { width: 19px; height: 19px; }
  .nav-badge { position: static; margin-left: auto; }
  .side-foot { display: flex; flex-direction: column; gap: 2px; margin-top: auto; }
  .side-link { display: flex; align-items: center; gap: 12px; height: 40px; padding: 0 12px; border-radius: 12px; color: var(--dim); font-size: .84rem; font-weight: 600; }
  .side-link:hover { color: var(--text); }
  .main { margin-left: 232px; padding: 0 32px 40px; }
  .topbar { padding: 24px 0 18px; }
  .topbar h1 { font-size: 1.45rem; }
  .only-m { display: none; }
  .kpis { grid-template-columns: repeat(6, 1fr); }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .span-2 { grid-column: span 2; }
  .chart-box { height: 280px; }
  .kanban { grid-auto-flow: row; grid-template-columns: repeat(4, 1fr); overflow: visible; margin: 0; padding: 0; }
  .prod-list { display: grid; grid-template-columns: 1fr 1fr; }
}

@media (min-width: 1500px) {
  .prod-list { grid-template-columns: 1fr 1fr 1fr; }
}

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

/* Frete flexível */
.fee-box { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.fee-box.pending { border-color: rgba(255, 190, 92, .45); background: rgba(255, 190, 92, .05); }
.fee-box > label { font-size: .7rem; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fee-box.pending > label { color: var(--amber); }
.fee-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.fee-row input { width: 100%; height: 44px; padding: 0 12px 0 36px; border-radius: 12px; background: var(--bg-2); border: 1px solid var(--line-2); outline: 0; font-size: 16px; }
.fee-row input:focus { border-color: rgba(52, 245, 154, .5); }
.fee-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: .74rem; color: var(--dim); }
.fee-chips button { height: 30px; padding: 0 10px; border-radius: 9px; border: 1px solid var(--line-2); font-size: .78rem; font-weight: 700; color: var(--text); }
.fee-chips button:hover { border-color: var(--brand); }
.rule-est { display: block; font-family: var(--font-ui); font-size: .64rem; font-weight: 700; color: var(--amber); text-transform: uppercase; letter-spacing: .06em; }

/* Aviso de configuração do servidor */
.health-bar { display: flex; gap: 10px; align-items: flex-start; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: rgba(255, 190, 92, .08); border: 1px solid rgba(255, 190, 92, .4); color: var(--amber); font-size: .82rem; font-weight: 600; }
.health-bar .ic { width: 18px; height: 18px; margin-top: 1px; }
