/* =============================================================================
   LANCE — Cotação de compras · Drogaria São Jorge
   Folha de estilos principal (tokens, layout, componentes, quadro de lances)
   ============================================================================= */

/* ------------------------------------------------------------------ tokens */
:root {
  --font-display: "Sora", "Inter Display", "Inter", system-ui, sans-serif;
  --font-body: "IBM Plex Sans", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;

  --bg: #F3F6F4;
  --surface: #FFFFFF;
  --surface-2: #EAF0ED;
  --surface-3: #DFE8E4;
  --ink: #14201E;
  --ink-2: #3E514D;
  --muted: #6E807C;
  --line: #D9E2DE;
  --line-strong: #BFCDC8;

  --primary: #0F6E5B;
  --primary-ink: #0A4A3E;
  --primary-soft: #DDF0E9;
  --primary-contrast: #FFFFFF;

  --accent: #E89C1C;
  --accent-ink: #8A5A06;
  --accent-soft: #FFF1D6;

  --danger: #C8102E;
  --danger-soft: #FBE3E6;
  --indigo: #4A4FB5;
  --indigo-soft: #E4E5F7;
  --blue: #2457A6;
  --blue-soft: #DEE8F8;

  --sidebar: #0C1F1D;
  --sidebar-ink: #CFDCD8;
  --sidebar-muted: #7F9893;
  --sidebar-active: #163835;
  --sidebar-line: #1C3330;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(20, 32, 30, .06), 0 4px 16px rgba(20, 32, 30, .06);
  --shadow-lg: 0 12px 40px rgba(20, 32, 30, .18);
  --sidebar-w: 248px;
  --topbar-h: 58px;
  --fs: 13.5px;
}

:root[data-theme="dark"] {
  --bg: #0B1514;
  --surface: #122120;
  --surface-2: #182C2A;
  --surface-3: #1F3936;
  --ink: #E6EEEB;
  --ink-2: #B5C5C0;
  --muted: #8AA09A;
  --line: #22403C;
  --line-strong: #30534E;
  --primary: #2E9F85;
  --primary-ink: #8FD9C3;
  --primary-soft: #16352F;
  --accent: #F0B14A;
  --accent-ink: #FFD58A;
  --accent-soft: #3A2A0D;
  --danger: #F06A7A;
  --danger-soft: #3B1A20;
  --indigo: #9A9EF0;
  --indigo-soft: #23264D;
  --blue: #7FA8EE;
  --blue-soft: #1B2B47;
  --sidebar: #08100F;
  --sidebar-active: #122622;
  --sidebar-line: #142321;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,.6);
}

/* ------------------------------------------------------------------ base */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: var(--fs); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font-body); color: var(--ink); background: var(--bg);
  line-height: 1.45; -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; } h4 { font-size: .9rem; }
p { margin: 0 0 .6rem; }
.mono, .ean, .price, .num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.xs { font-size: .78rem; }
.strong { font-weight: 600; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hide { display: none !important; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.flex { display: flex; align-items: center; gap: .5rem; }
.flex-wrap { flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* ------------------------------------------------------------------ app shell */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--sidebar); color: var(--sidebar-ink); position: fixed; inset: 0 auto 0 0;
  display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease;
}
.sidebar .brand { display: flex; align-items: center; gap: .7rem; padding: 1rem 1.1rem .8rem; border-bottom: 1px solid var(--sidebar-line); }
.sidebar .brand img { height: 36px; }
.sidebar .brand .store { font-size: .74rem; color: var(--sidebar-muted); letter-spacing: .08em; text-transform: uppercase; }
.sidebar .brand .wordmark { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: #fff; letter-spacing: -.02em; line-height: 1; }
.nav { padding: .6rem .6rem; overflow-y: auto; flex: 1; }
.nav .section { font-size: .68rem; text-transform: uppercase; letter-spacing: .12em; color: var(--sidebar-muted); padding: .9rem .6rem .35rem; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border-radius: 8px; color: var(--sidebar-ink); font-size: .92rem; font-weight: 500; }
.nav a:hover { background: var(--sidebar-active); text-decoration: none; color: #fff; }
.nav a.active { background: var(--sidebar-active); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav a svg { width: 17px; height: 17px; flex: none; opacity: .85; }
.nav a .count { margin-left: auto; font-size: .7rem; background: var(--accent); color: #1a1200; border-radius: 999px; padding: .05rem .45rem; font-weight: 700; }
.sidebar .foot { padding: .8rem 1rem; border-top: 1px solid var(--sidebar-line); font-size: .78rem; color: var(--sidebar-muted); }
.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: .8rem; padding: 0 1.4rem; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
}
.topbar .title { font-family: var(--font-display); font-weight: 600; font-size: 1.05rem; }
.topbar .spacer { flex: 1; }
.topbar .user { display: flex; align-items: center; gap: .5rem; font-size: .86rem; color: var(--ink-2); }
.content { padding: 1.4rem; max-width: 1360px; width: 100%; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: .15rem; }
.burger { display: none; }
@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); }
  body.nav-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
  .main { margin-left: 0; }
  .burger { display: inline-flex; }
  .content { padding: 1rem; }
}

/* ------------------------------------------------------------------ icon buttons & buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: .5rem .9rem; font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; background: var(--surface-2); color: var(--ink); line-height: 1.2;
  transition: background .15s, box-shadow .15s, transform .05s; white-space: nowrap; text-decoration: none;
}
.btn:hover { text-decoration: none; background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); color: var(--primary-contrast); }
.btn-primary:hover { background: var(--primary-ink); }
:root[data-theme="dark"] .btn-primary { color: #06201a; }
:root[data-theme="dark"] .btn-primary:hover { background: #3fb89a; }
.btn-accent { background: var(--accent); color: #1f1400; }
.btn-accent:hover { background: #d58d12; }
.btn-ghost { background: transparent; border-color: var(--line-strong); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: .32rem .6rem; font-size: .8rem; }
.btn-xs { padding: .18rem .45rem; font-size: .74rem; }
.btn-icon { padding: .45rem; border-radius: 8px; }
.btn-icon.btn-sm { padding: .3rem; }
.btn-wa { background: #25D366; color: #053b1c; }
.btn-wa:hover { background: #1ebe5a; }
.btn-group { display: inline-flex; gap: .4rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ cards / kpis */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1rem 1.1rem; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .8rem 1.1rem; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: .95rem; }
.kpi { padding: .9rem 1.1rem; position: relative; overflow: hidden; }
.kpi .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }
.kpi .value { font-family: var(--font-display); font-size: 1.55rem; font-weight: 700; margin-top: .2rem; letter-spacing: -.02em; }
.kpi .delta { font-size: .8rem; color: var(--muted); margin-top: .1rem; }
.kpi.good .value { color: var(--primary); }
.kpi.warn .value { color: var(--accent-ink); }
.kpi.bad .value { color: var(--danger); }
.kpi .mark { position: absolute; right: .8rem; top: .8rem; opacity: .14; width: 44px; height: 44px; }

/* ------------------------------------------------------------------ badges / chips */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .14rem .5rem; border-radius: 999px; font-size: .72rem; font-weight: 700; letter-spacing: .02em; text-transform: uppercase; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-green { background: var(--primary-soft); color: var(--primary-ink); }
.badge-amber { background: var(--accent-soft); color: var(--accent-ink); }
.badge-red { background: var(--danger-soft); color: var(--danger); }
.badge-indigo { background: var(--indigo-soft); color: var(--indigo); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-ink { background: var(--ink); color: var(--bg); }
.badge-muted { background: var(--surface-2); color: var(--muted); }
.badge.plain::before { display: none; }
.chip { display: inline-flex; align-items: center; gap: .35rem; padding: .18rem .55rem; border-radius: 6px; font-size: .76rem; background: var(--surface-2); color: var(--ink-2); font-weight: 500; border: 1px solid var(--line); }
.chip.ok { background: var(--primary-soft); color: var(--primary-ink); border-color: transparent; }
.chip.warn { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.chip.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.chip .mono { font-size: .74rem; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .72rem; flex: none; }
.avatar.dist { background: var(--indigo-soft); color: var(--indigo); border-radius: 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--muted); }
.dot.ok { background: var(--primary); } .dot.bad { background: var(--danger); } .dot.warn { background: var(--accent); }

/* ------------------------------------------------------------------ forms */
label, .label { font-size: .8rem; font-weight: 600; color: var(--ink-2); display: block; margin-bottom: .25rem; }
.input, .select, textarea.input {
  width: 100%; font: inherit; font-size: .9rem; padding: .48rem .65rem; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.mono { font-family: var(--font-mono); }
.input-sm { padding: .3rem .5rem; font-size: .84rem; }
.input-xs { padding: .2rem .4rem; font-size: .8rem; width: 72px; }
textarea.input { min-height: 72px; resize: vertical; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 1.8rem; }
.form-grid { display: grid; gap: .8rem 1rem; grid-template-columns: repeat(12, 1fr); }
.form-grid > * { grid-column: span 12; }
.col-2 { grid-column: span 2 !important; } .col-3 { grid-column: span 3 !important; } .col-4 { grid-column: span 4 !important; } .col-6 { grid-column: span 6 !important; } .col-8 { grid-column: span 8 !important; } .col-9 { grid-column: span 9 !important; }
@media (max-width: 720px) { .form-grid > * { grid-column: span 12 !important; } }
.help { font-size: .76rem; color: var(--muted); margin-top: .2rem; }
.switch { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 500; font-size: .88rem; color: var(--ink); }
.switch input { appearance: none; width: 34px; height: 20px; border-radius: 999px; background: var(--line-strong); position: relative; transition: background .15s; cursor: pointer; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(14px); }
.check { display: inline-flex; align-items: center; gap: .45rem; font-size: .88rem; font-weight: 500; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); margin: 0; }
.inline-form { display: flex; gap: .5rem; align-items: flex-end; flex-wrap: wrap; }
.inline-form > div { min-width: 140px; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.qty button { border: 0; background: var(--surface-2); width: 26px; height: 28px; cursor: pointer; font-weight: 700; color: var(--ink-2); }
.qty input { width: 48px; border: 0; text-align: center; font: inherit; font-family: var(--font-mono); font-size: .85rem; background: var(--surface); color: var(--ink); }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th { text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; padding: .55rem .7rem; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 1; }
.table td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table .r { text-align: right; }
.table .c { text-align: center; }
.table-dense td { padding: .35rem .6rem; }
.table .sub { color: var(--muted); font-size: .76rem; display: block; }
.table a.row-link { color: inherit; font-weight: 600; }
.toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .9rem; }
.toolbar .input, .toolbar .select { width: auto; min-width: 160px; }
.search { position: relative; }
.search svg { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--muted); }
.search .input { padding-left: 1.9rem; }
.pager { display: flex; gap: .3rem; align-items: center; justify-content: flex-end; padding: .6rem 1rem; font-size: .82rem; color: var(--muted); }
.pager a, .pager span.cur { padding: .25rem .55rem; border-radius: 6px; border: 1px solid var(--line); }
.pager span.cur { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.empty { text-align: center; padding: 2.4rem 1rem; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: .35; margin-bottom: .6rem; }
.empty h3 { color: var(--ink-2); margin-bottom: .3rem; }

/* ------------------------------------------------------------------ tabs (abas da cotação) */
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1rem; overflow-x: auto; }
.tabs a { padding: .6rem .9rem; font-weight: 600; font-size: .88rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; display: flex; gap: .4rem; align-items: center; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--accent); }
.tabs a .count { font-size: .7rem; background: var(--surface-2); border-radius: 999px; padding: 0 .4rem; color: var(--ink-2); }
.cot-head { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: .6rem 1rem; padding: .9rem 1.1rem; }
.cot-head .k { font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 700; }
.cot-head .v { font-weight: 600; font-size: .95rem; margin-top: .1rem; }

/* ------------------------------------------------------------------ alerts / toasts / modal / drawer */
.alert { padding: .7rem .9rem; border-radius: var(--radius-sm); font-size: .88rem; border: 1px solid transparent; margin-bottom: 1rem; }
.alert svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: .3rem; }
.alert-ok { background: var(--primary-soft); color: var(--primary-ink); }
.alert-erro { background: var(--danger-soft); color: var(--danger); }
.alert-info { background: var(--blue-soft); color: var(--blue); }
.alert-warn { background: var(--accent-soft); color: var(--accent-ink); }
.toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 100; }
.toast { background: var(--ink); color: var(--bg); padding: .65rem .9rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); font-size: .88rem; max-width: 380px; animation: toast-in .2s ease; }
.toast.erro { background: var(--danger); color: #fff; }
.toast.ok { background: var(--primary); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.modal-bg { position: fixed; inset: 0; background: rgba(8, 16, 15, .55); z-index: 80; display: flex; align-items: center; justify-content: center; padding: 1rem; animation: fade .15s; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 620px; max-height: 92vh; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.modal.lg { max-width: 920px; }
.modal-head { padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-body { padding: 1rem 1.1rem; overflow-y: auto; }
.modal-foot { padding: .8rem 1.1rem; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: .5rem; }
.drawer-bg { position: fixed; inset: 0; background: rgba(8, 16, 15, .5); z-index: 80; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(520px, 100%); background: var(--surface); z-index: 81; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: slide .2s ease; }
@keyframes fade { from { opacity: 0; } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.close { border: 0; background: transparent; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; padding: .2rem .4rem; }
.popover { position: absolute; z-index: 60; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); padding: .6rem .7rem; min-width: 240px; font-size: .8rem; }

/* ------------------------------------------------------------------ notifications */
.notif-btn { position: relative; }
.notif-btn .n { position: absolute; top: -4px; right: -4px; background: var(--danger); color: #fff; font-size: .62rem; font-weight: 700; border-radius: 999px; padding: 0 .3rem; min-width: 16px; text-align: center; }
.notif-list { position: absolute; right: 0; top: 44px; width: 340px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 50; overflow: hidden; }
.notif-list a { display: block; padding: .6rem .8rem; border-bottom: 1px solid var(--line); color: var(--ink); font-size: .84rem; }
.notif-list a:hover { background: var(--surface-2); text-decoration: none; }
.notif-list .t { font-weight: 600; }
.notif-list .m { color: var(--muted); font-size: .78rem; }

/* ------------------------------------------------------------------ progress */
.progress { height: 6px; background: var(--surface-3); border-radius: 999px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.progress.amber > i { background: var(--accent); }
.progress.red > i { background: var(--danger); }

/* ------------------------------------------------------------------ QUADRO DE LANCES (ofertas) */
.board-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; margin-bottom: 1rem; }
.board-summary .kpi { padding: .7rem .9rem; }
.board-summary .kpi .value { font-size: 1.3rem; }
.forn-chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .9rem; }
.forn-chip { display: inline-flex; align-items: center; gap: .45rem; padding: .3rem .6rem; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); font-size: .8rem; }
.forn-chip .name { font-weight: 600; }
.forn-chip .tot { font-family: var(--font-mono); }
.forn-chip.below { border-color: var(--accent); background: var(--accent-soft); }
.forn-chip .min { color: var(--accent-ink); font-size: .72rem; }
.board-wrap { overflow: auto; max-height: calc(100vh - 230px); border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.board { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .84rem; min-width: 720px; }
.board th { position: sticky; top: 0; z-index: 3; background: var(--surface); border-bottom: 1px solid var(--line); padding: .5rem .6rem; text-align: left; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.board th.forn { text-align: center; min-width: 118px; }
.board th.forn .fn { color: var(--ink); text-transform: none; letter-spacing: 0; font-size: .82rem; display: block; }
.board th.forn .fe { font-weight: 500; color: var(--muted); text-transform: none; letter-spacing: 0; font-size: .7rem; }
.board th.forn.dist .fn::before { content: "⚡ "; }
.board td { padding: .35rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.board td.prod { position: sticky; left: 0; background: var(--surface); z-index: 2; min-width: 260px; max-width: 340px; border-right: 1px solid var(--line); }
.board th.prod { position: sticky; left: 0; z-index: 4; border-right: 1px solid var(--line); }
.board td.prod .d { font-weight: 600; line-height: 1.25; }
.board td.prod .meta { display: flex; gap: .5rem; align-items: center; color: var(--muted); font-size: .74rem; margin-top: .15rem; flex-wrap: wrap; }
.board td.prod .meta .ean { letter-spacing: .02em; }
.board td.qtd { text-align: center; }
.board td.qtd input { width: 56px; text-align: center; }
.board tr.sel-none td.prod { box-shadow: inset 3px 0 0 var(--danger); }
.board td.off { text-align: center; padding: .25rem .35rem; }
.lance { display: inline-flex; flex-direction: column; align-items: center; gap: .05rem; padding: .3rem .55rem; border-radius: 8px; border: 1px solid transparent; cursor: pointer; min-width: 92px; background: transparent; font: inherit; color: var(--ink); line-height: 1.15; position: relative; transition: background .12s, border-color .12s; }
.lance:hover { background: var(--surface-2); border-color: var(--line-strong); }
.lance .p { font-family: var(--font-mono); font-weight: 600; font-size: .9rem; }
.lance .s { font-size: .68rem; color: var(--muted); display: flex; gap: .3rem; align-items: center; }
.lance.best { background: var(--primary-soft); border-color: transparent; }
.lance.best .p { color: var(--primary-ink); }
.lance.best::before { content: ""; position: absolute; left: -2px; top: 50%; width: 0; height: 0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid var(--accent); transform: translateY(-50%); }
.lance.selected { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-soft); }
.lance.selected .p::after { content: " ✓"; color: var(--primary); font-weight: 700; }
.lance.above .p { color: var(--danger); }
.lance.sub { border-style: dashed; border-color: var(--accent); }
.lance.none { color: var(--line-strong); cursor: default; min-width: 60px; }
.lance.none:hover { background: transparent; border-color: transparent; }
.lance .cond { font-family: var(--font-mono); font-size: .62rem; background: var(--indigo-soft); color: var(--indigo); border-radius: 4px; padding: 0 .25rem; }
.lance .vme { color: var(--primary-ink); font-weight: 600; }
.board td.tot { text-align: right; font-family: var(--font-mono); white-space: nowrap; }
.board td.tot .eco { display: block; font-size: .72rem; color: var(--primary-ink); }
.board tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 700; border-top: 2px solid var(--line-strong); z-index: 2; }
.board .ref { font-size: .7rem; color: var(--muted); }
.board .ref input { width: 70px; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .76rem; color: var(--muted); margin-top: .6rem; align-items: center; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.legend .best i { background: var(--primary-soft); border-left: 3px solid var(--accent); }
.legend .selected i { border: 2px solid var(--primary); }
.legend .above i { background: var(--danger-soft); }
.legend .sub i { border: 1px dashed var(--accent); }

/* offer detail popover */
.off-detail { display: grid; grid-template-columns: auto 1fr; gap: .15rem .6rem; }
.off-detail dt { color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.off-detail dd { margin: 0; font-family: var(--font-mono); }

/* ------------------------------------------------------------------ nova cotação (builder) */
.builder-add { display: grid; grid-template-columns: 1fr 110px 150px auto; gap: .6rem; align-items: end; }
@media (max-width: 800px) { .builder-add { grid-template-columns: 1fr 1fr; } }
.ac { position: relative; }
.ac-list { position: absolute; left: 0; right: 0; top: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 50; max-height: 320px; overflow-y: auto; }
.ac-list div { padding: .45rem .7rem; cursor: pointer; font-size: .86rem; border-bottom: 1px solid var(--line); }
.ac-list div:hover, .ac-list div.active { background: var(--surface-2); }
.ac-list .ean { color: var(--muted); font-size: .74rem; margin-left: .4rem; }
.ac-list .stk { float: right; color: var(--muted); font-size: .74rem; }
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--radius); padding: 1.4rem; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--primary); background: var(--primary-soft); }

/* ------------------------------------------------------------------ fornecedores (ajustes da cotação) */
.forn-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .5rem; }
.forn-item { display: flex; align-items: center; gap: .6rem; padding: .5rem .65rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; background: var(--surface); }
.forn-item:hover { border-color: var(--line-strong); }
.forn-item.on { border-color: var(--primary); background: var(--primary-soft); }
.forn-item .nm { font-weight: 600; font-size: .86rem; line-height: 1.2; }
.forn-item .em { font-size: .74rem; color: var(--muted); }
.forn-item input { accent-color: var(--primary); width: 16px; height: 16px; margin: 0; }

/* ------------------------------------------------------------------ timeline / status */
.steps { display: flex; gap: 0; counter-reset: s; margin-bottom: 1rem; }
.steps span { flex: 1; text-align: center; font-size: .72rem; font-weight: 600; color: var(--muted); padding: .4rem .2rem; border-bottom: 3px solid var(--line); }
.steps span.done { color: var(--primary-ink); border-color: var(--primary); }
.steps span.cur { color: var(--ink); border-color: var(--accent); }

/* ------------------------------------------------------------------ consulta de preços (cards) */
.price-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .7rem; }
.price-card { border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .85rem; background: var(--surface); display: flex; flex-direction: column; gap: .35rem; }
.price-card .top { display: flex; justify-content: space-between; align-items: center; font-size: .74rem; color: var(--muted); }
.price-card .d { font-weight: 600; line-height: 1.25; min-height: 2.4em; }
.price-card .pl { font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--primary-ink); }
.price-card .det { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .2rem .4rem; font-size: .72rem; color: var(--muted); }
.price-card .det b { color: var(--ink-2); font-family: var(--font-mono); font-weight: 500; }
.price-card .act { display: flex; gap: .4rem; align-items: center; margin-top: .2rem; }
.price-card.sem { opacity: .6; }
.upn-list { display: flex; flex-direction: column; gap: .4rem; }
.upn-item { display: flex; justify-content: space-between; gap: .6rem; font-size: .8rem; padding: .45rem .6rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }

/* ------------------------------------------------------------------ dashboard */
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 1rem; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }
.rank { list-style: none; margin: 0; padding: 0; }
.rank li { display: grid; grid-template-columns: 1fr auto; gap: .4rem; align-items: center; padding: .35rem 0; font-size: .84rem; border-bottom: 1px solid var(--line); }
.rank li:last-child { border-bottom: 0; }
.rank .bar { height: 4px; border-radius: 999px; background: var(--primary); grid-column: 1 / -1; }
.rank .v { font-family: var(--font-mono); }
.curva-row { display: grid; grid-template-columns: 56px 1fr; gap: .8rem; align-items: center; padding: .55rem 0; border-bottom: 1px solid var(--line); }
.curva-row:last-child { border-bottom: 0; }
.curva-row .letter { font-family: var(--font-display); font-size: 1.6rem; font-weight: 700; color: var(--surface-3); }
.curva-row .metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: .3rem; font-size: .74rem; color: var(--muted); }
.curva-row .metrics b { display: block; color: var(--ink); font-family: var(--font-mono); font-weight: 500; }
.event { display: flex; gap: .7rem; padding: .5rem 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.event:last-child { border-bottom: 0; }
.event .date { text-align: center; min-width: 42px; font-family: var(--font-display); line-height: 1; }
.event .date b { font-size: 1.2rem; display: block; }
.event .date span { font-size: .66rem; text-transform: uppercase; color: var(--muted); letter-spacing: .08em; }
.event .t { font-weight: 600; font-size: .86rem; }
.event .s { color: var(--muted); font-size: .76rem; }

/* ------------------------------------------------------------------ calendário */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 3px; }
.cal .dow { font-size: .68rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); text-align: center; padding: .3rem 0; }
.cal .day { min-height: 92px; border: 1px solid var(--line); border-radius: 8px; padding: .3rem .4rem; font-size: .74rem; background: var(--surface); }
.cal .day.other { opacity: .4; }
.cal .day.today { border-color: var(--accent); }
.cal .day .n { font-weight: 700; color: var(--muted); font-size: .72rem; }
.cal .ev { display: block; margin-top: .2rem; padding: .12rem .3rem; border-radius: 4px; background: var(--primary-soft); color: var(--primary-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.entrega { background: var(--blue-soft); color: var(--blue); }
.cal .ev.reposicao { background: var(--accent-soft); color: var(--accent-ink); }
.cal .ev.lembrete { background: var(--indigo-soft); color: var(--indigo); }
.cal .ev.done { text-decoration: line-through; opacity: .55; }

/* ------------------------------------------------------------------ login / blank */
.blank { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; background: radial-gradient(1200px 600px at 10% -10%, var(--primary-soft), transparent), var(--bg); }
.login { width: 100%; max-width: 400px; }
.login .card-body { padding: 1.6rem; }
.login .logo { display: flex; justify-content: center; margin-bottom: 1.2rem; }
.login .logo img { height: 110px; }

/* ------------------------------------------------------------------ portal do fornecedor (mobile first) */
.portal { max-width: 760px; margin: 0 auto; padding: .8rem; }
.portal-head { display: flex; align-items: center; gap: .7rem; padding: .6rem .2rem 1rem; }
.portal-head img { height: 36px; }
.portal-head .s { color: var(--muted); font-size: .8rem; }
.portal .item { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: .7rem .8rem; margin-bottom: .55rem; display: grid; grid-template-columns: 1fr; gap: .45rem; }
.portal .item .d { font-weight: 600; line-height: 1.25; }
.portal .item .meta { font-size: .74rem; color: var(--muted); display: flex; gap: .6rem; flex-wrap: wrap; }
.portal .item .fields { display: grid; grid-template-columns: 1.2fr 1fr 1.6fr; gap: .45rem; }
@media (max-width: 480px) { .portal .item .fields { grid-template-columns: 1fr 1fr; } .portal .item .fields .wide { grid-column: span 2; } }
.portal .item .fields label { font-size: .68rem; }
.portal .item .fields .input { font-size: 1rem; padding: .55rem .6rem; }
.portal .item.filled { border-color: var(--primary); }
.portal .item .rank { font-size: .72rem; font-weight: 700; }
.portal .item .rank.melhor { color: var(--primary-ink); }
.portal .item .rank.acima { color: var(--accent-ink); }
.portal-bar { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--line); padding: .7rem .8rem; display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin: 0 -.8rem; }
.portal-bar .sum { font-size: .8rem; color: var(--muted); }
.portal-bar .sum b { color: var(--ink); font-family: var(--font-mono); }
.portal .done { text-align: center; padding: 2rem 1rem; }
.portal .done .big { font-size: 3rem; }

/* ------------------------------------------------------------------ print */
@media print {
  .sidebar, .topbar, .toolbar, .btn, .tabs, .no-print, .toasts { display: none !important; }
  .main { margin: 0; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; }
  body { background: #fff; color: #000; font-size: 11px; }
  .print-head { display: flex !important; justify-content: space-between; align-items: center; border-bottom: 1px solid #999; padding-bottom: .5rem; margin-bottom: .8rem; }
}
.print-head { display: none; }

/* filtro ativo em grupo de botões ghost */
.btn-ghost.btn-primary { background: var(--primary); color: var(--primary-contrast); border-color: transparent; }
:root[data-theme="dark"] .btn-ghost.btn-primary { color: #06201a; }

/* ------------------------------------------------------------------ responsivo: nada estoura a largura */
.grid > *, .dash-grid > *, .card, .content, .toolbar > * { min-width: 0; }
.toolbar > * { max-width: 100%; }
.main { overflow-x: clip; }
@media (max-width: 720px) {
  .topbar { gap: .35rem; padding: 0 .8rem; }
  .topbar .user span.nowrap, .topbar .btn-accent .lbl { display: none; }
  .cot-head { grid-template-columns: repeat(2, 1fr); }
}

/* ---------------------------------------------------------------- multiempresa (1.1) */
.multi-empresa .sidebar { box-shadow: inset 0 4px 0 var(--empresa-cor, var(--primary)); }
.multi-empresa .sidebar .store { color: #fff; font-weight: 600; }
.empresa-troca { display: flex; align-items: center; gap: .4rem; padding: .15rem .25rem .15rem .55rem; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); }
.empresa-troca .dot, .empresa-opcao .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--empresa-cor, var(--primary)); flex: none; }
.empresa-troca select { border: 0; background-color: transparent; font-weight: 600; padding-left: 0; min-width: 0; max-width: 190px; }
.empresa-troca select:focus { box-shadow: none; }
.empresa-escolha { display: grid; gap: .45rem; }
.empresa-opcao { display: flex; align-items: center; gap: .6rem; padding: .6rem .75rem; border: 1px solid var(--line); border-radius: var(--radius-sm); cursor: pointer; font-weight: 600; color: var(--ink); background: var(--surface); }
.empresa-opcao input { position: absolute; opacity: 0; pointer-events: none; }
.empresa-opcao:hover { border-color: var(--line-strong); }
.empresa-opcao:has(input:checked) { border-color: var(--empresa-cor); box-shadow: 0 0 0 3px color-mix(in srgb, var(--empresa-cor) 18%, transparent); }
.empresa-opcao:has(input:focus-visible) { outline: 2px solid var(--empresa-cor); outline-offset: 2px; }
@media (max-width: 720px) { .empresa-troca select { max-width: 120px; } }

/* ---------------------------------------------------------------- colar do Excel (1.2) */
.colar textarea { min-height: 96px; font-size: .82rem; line-height: 1.35; white-space: pre; }
.colar-cols { display: flex; gap: .5rem; flex-wrap: wrap; margin: .2rem 0 .7rem; padding: .55rem .6rem; background: var(--surface-2); border-radius: var(--radius-sm); }
.colar-col { display: flex; flex-direction: column; gap: .2rem; min-width: 150px; flex: 1 1 150px; max-width: 220px; }
.colar-col .select { width: 100%; }
.colar-amostra { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.colar-tabela { max-height: 46vh; overflow: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.colar-tabela .table th { position: sticky; top: 0; }
.colar-tabela tr.colar-off td { opacity: .45; }
.colar-tabela td .sub { max-width: 420px; }
.modal-foot .colar-subst { margin-right: auto; gap: .4rem; color: var(--ink-2); }
.modal-foot .colar-subst .select { width: auto; }
@media (max-width: 720px) { .modal-foot { flex-wrap: wrap; } .modal-foot .colar-subst { width: 100%; } }

/* ---- 1.3: WhatsApp do Lance ---- */
[hidden] { display: none !important; }
.wa-linha { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wa-qr { display: flex; gap: 20px; align-items: flex-start; flex-wrap: wrap; }
.wa-qr img { width: 232px; height: 232px; background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); image-rendering: pixelated; flex: none; }
.wa-qr > div:last-child { flex: 1 1 260px; min-width: 0; }
.wa-passos { margin: 8px 0 8px 18px; padding: 0; font-size: 13px; line-height: 1.6; }
.wa-codigo { font-size: 28px; font-weight: 700; letter-spacing: .12em; padding: 14px 18px; border: 1px dashed var(--line-strong); border-radius: 10px; background: var(--bg); flex: none; }
.wa-acoes .input { max-width: 190px; }
.wa-sub { display: flex; align-items: center; gap: 4px; margin-top: 3px; }
.wa-sub svg { width: 13px; height: 13px; color: #25D366; }
@media (max-width: 640px) { .wa-qr img { width: 100%; max-width: 280px; height: auto; } .wa-acoes .input { max-width: none; flex: 1 1 100%; } }
#wa-card .card-head h3 { display: flex; align-items: center; gap: 8px; }
#wa-card .card-head h3 svg { width: 18px; height: 18px; color: #25D366; flex: none; }

/* ---- 1.4: Conferência de NF e reabertura ---- */
.seg { display: inline-flex; gap: .25rem; flex-wrap: wrap; }
a.chip { text-decoration: none; cursor: pointer; }
a.chip.on { background: var(--primary); color: var(--primary-contrast); border-color: transparent; }
.row-alerta td { background: color-mix(in srgb, var(--danger-soft) 55%, transparent); }
.msg-whats { white-space: pre-wrap; font-family: var(--font-body); font-size: .86rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .8rem 1rem; margin: 0; max-height: 360px; overflow: auto; }
.reab-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .35rem .9rem; max-height: 260px; overflow: auto; padding: .5rem; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.reab-lista .check { font-weight: 400; }
.reab-lista .check .muted { font-size: .74rem; }
.prazo-ind { color: var(--accent-ink); }
.reab-form > div > .check { display: flex; margin: .3rem 0; }

/* ---- 1.5: painel de permissões ---- */
.perm-grid th.c { font-size: .66rem; letter-spacing: .04em; white-space: nowrap; }
.perm-grid td.c input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.perm-grid td.c input:disabled { cursor: not-allowed; opacity: .55; }
.perm-check .check { padding: .25rem .55rem; border: 1px solid var(--line); border-radius: 6px; }

/* 1.7 — encomenda (giro lento) */
.table tr.row-encomenda td { background: color-mix(in srgb, var(--danger-soft) 35%, transparent); }
.table td .enc-motivo { white-space: nowrap; font-size: .68rem; }
.enc-lista td .sub { display: block; }
.enc-resumo { display: flex; gap: .6rem; flex-wrap: wrap; margin: .4rem 0; }
.enc-resumo .chip.bad { background: var(--danger-soft); color: var(--danger); }

/* 1.7.1 — campo só de letras (nome do caderno) */
.sem-numeros-aviso { color: var(--danger); font-size: .74rem; margin-top: .25rem; width: 100%; flex-basis: 100%; }
.input.input-erro { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }

/* 1.9 — Estoque das lojas (balcão) */
.estq-campo { width: 100%; }
.estq-campo .input { width: 100%; height: 52px; font-size: 1.15rem; padding-left: 2.6rem; }
.estq-campo svg { width: 20px; height: 20px; }
.estq-lojas { display: flex; flex-wrap: wrap; gap: .5rem 1.2rem; margin-top: .7rem; font-size: .8rem; color: var(--muted); }
.estq-st.warn b { color: var(--accent-ink); }
.estq-vazio { padding: 2.2rem 1rem; text-align: center; }
#estq-res.carregando { opacity: .55; transition: opacity .15s; }
.estq-tab td, .estq-tab th { vertical-align: middle; }
.estq-tab th.c { min-width: 150px; }
.estq-tab th .sub { display: block; font-weight: 500; text-transform: none; letter-spacing: 0; }
.estq-cel { text-align: center; }
.estq-qtd { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; line-height: 1.1; }
.estq-qtd .u { font-size: .75rem; font-weight: 500; color: var(--muted); }
.estq-cel.tem .estq-qtd { color: var(--primary-ink); }
.estq-cel.zero .estq-qtd { color: var(--danger); }
.estq-cel.sem .estq-qtd, .estq-cel.nao { color: var(--muted); }
.estq-tab tr.estq-outra td { background: color-mix(in srgb, var(--primary-soft) 70%, transparent); }
.estq-tab tr.estq-outra .estq-cel.tem { box-shadow: inset 0 0 0 2px var(--primary); }
.estq-aviso { display: inline-block; margin-top: .35rem; font-size: .68rem; letter-spacing: .03em; }
@media (max-width: 720px) { .estq-qtd { font-size: 1.15rem; } .estq-tab th.c { min-width: 96px; } }
.estq-st .dot { margin-right: .3rem; }
.estq-aviso { font-size: .74rem; padding: .22rem .55rem; }
@media (max-width: 720px) {
  .estq-tab { table-layout: fixed; width: 100%; min-width: 0 !important; }
  .estq-tab th:first-child, .estq-tab td:first-child { width: 46%; }
  .estq-tab th.c { min-width: 0; font-size: .6rem; letter-spacing: .02em; padding-left: .2rem; padding-right: .2rem; white-space: normal; }
  .estq-tab td { padding-left: .45rem; padding-right: .3rem; }
  .estq-tab td:first-child b { font-size: .8rem; }
  .estq-aviso { font-size: .62rem; white-space: normal; }
  .estq-qtd .u { display: none; }
}
