/* Choice WMS — design system (layout administrativo, sem dependências externas) */
:root {
  color-scheme: light;
  --navy-900: #0b1f33;
  --navy-800: #102a43;
  --navy-700: #163d61;
  --blue-600: #1769aa;
  --blue-500: #2684d6;
  --blue-50: #eaf4fd;
  --ink: #1f3247;
  --ink-soft: #3d5168;
  --muted: #64788f;
  --line: #dde5ee;
  --line-strong: #c7d3e0;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --canvas: #f2f5f9;
  --success: #12795f;
  --success-bg: #e4f6ef;
  --warning: #9a5b00;
  --warning-bg: #fff4dc;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --violet: #6b4fb3;
  --violet-bg: #f1ecfb;
  --teal: #0f7c74;
  --teal-bg: #e1f4f2;
  --shadow-sm: 0 1px 2px rgba(16, 42, 67, .06);
  --shadow: 0 6px 20px rgba(16, 42, 67, .08);
  --shadow-lg: 0 24px 60px rgba(11, 31, 51, .22);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 248px;
  --sidebar-collapsed: 72px;
  /* Ícones: tamanhos por categoria (SVG 24×24, traço 2). */
  --icon-size: 18px;
  --icon-size-sm: 15px;
  --icon-size-lg: 22px;
  --icon-stroke: 2;
  /* Cards de indicador (.metric): contêiner do ícone e grade interna. */
  --metric-icon-box: 34px;
  --metric-icon-radius: 10px;
  --metric-label-h: 48px;
  --metric-value-h: 34px;
  --metric-foot-h: 32px;
  --metric-min-h: 154px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body { margin: 0; color: var(--ink); background: var(--canvas); -webkit-font-smoothing: antialiased; }
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid #f5b700; outline-offset: 2px; border-radius: 4px; }
code, .mono { font-family: "JetBrains Mono", "Cascadia Code", Consolas, monospace; font-size: .92em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* vertical-align só age em ícones dentro de texto (tabelas, parágrafos); em flex/grid é ignorado. */
.icon { width: var(--icon-size); height: var(--icon-size); flex: none; vertical-align: middle; stroke: currentColor; fill: none; stroke-width: var(--icon-stroke); stroke-linecap: round; stroke-linejoin: round; overflow: visible; }
.icon-sm { width: var(--icon-size-sm); height: var(--icon-size-sm); }
.icon-lg { width: var(--icon-size-lg); height: var(--icon-size-lg); }

/* ---------------- Shell ---------------- */
.app { display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s ease; }
.app.collapsed { grid-template-columns: var(--sidebar-collapsed) minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 6px; padding: 16px 12px; color: #d9e2ec; background: linear-gradient(180deg, var(--navy-800), var(--navy-900)); z-index: 40; overflow-y: auto; overflow-x: hidden; }
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 16px; color: #fff; text-decoration: none !important; }
.brand-mark { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 11px; background: linear-gradient(135deg, var(--blue-500), var(--blue-600)); color: #fff; font-weight: 900; font-size: 13px; letter-spacing: .06em; box-shadow: 0 6px 16px rgba(38, 132, 214, .35); }
.brand strong { display: block; font-size: 15px; }
.brand small { display: block; color: #9fb3c8; font-size: 11.5px; margin-top: 2px; }
.nav-section { margin: 14px 10px 4px; color: #7f97b0; font-size: 10.5px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; white-space: nowrap; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 1px 0; border-radius: 9px; color: #c9d6e3; font-size: 14px; font-weight: 600; white-space: nowrap; text-decoration: none !important; position: relative; }
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a[aria-current="page"] { background: rgba(38, 132, 214, .22); color: #fff; box-shadow: inset 3px 0 0 var(--blue-500); }
.nav .nav-count { margin-left: auto; min-width: 20px; padding: 1px 7px; border-radius: 99px; background: #f5b700; color: var(--navy-900); font-size: 11px; font-weight: 800; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 14px 8px 4px; border-top: 1px solid rgba(255, 255, 255, .12); font-size: 13px; }
.sidebar-footer .who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avatar { display: grid; place-items: center; width: 34px; height: 34px; flex: none; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 800; font-size: 12px; }
.who-text { min-width: 0; }
.who-text strong { display: block; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-text small { display: block; color: #9fb3c8; }
.sidebar-actions { display: flex; gap: 6px; margin-top: 10px; }
.sidebar-actions button { flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 7px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 8px; background: transparent; color: #c9d6e3; font-size: 12px; font-weight: 700; cursor: pointer; }
.sidebar-actions button:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.app.collapsed .brand > span:last-child, .app.collapsed .nav-section, .app.collapsed .nav a span, .app.collapsed .who-text, .app.collapsed .sidebar-actions span, .app.collapsed .nav .nav-count { display: none; }
.app.collapsed .nav a { justify-content: center; }
.app.collapsed .sidebar-actions { flex-direction: column; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 14px; padding: 12px clamp(16px, 3vw, 32px); background: rgba(242, 245, 249, .86); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink-soft); cursor: pointer; position: relative; }
.icon-button:hover { border-color: var(--line-strong); color: var(--ink); }
.icon-button .dot { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 99px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 800; display: grid; place-items: center; border: 2px solid var(--canvas); }
.search { position: relative; flex: 1; max-width: 560px; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { width: 100%; height: 40px; padding: 0 74px 0 40px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.search input:focus { border-color: var(--blue-500); outline: none; box-shadow: 0 0 0 4px rgba(38, 132, 214, .14); }
.search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); padding: 2px 7px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface-2); color: var(--muted); font-size: 11px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.env-badge { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.env-badge.local { background: var(--warning-bg); color: var(--warning); border: 1px solid #f0d49a; }
.env-badge.auth { background: var(--success-bg); color: var(--success); border: 1px solid #a7dcc9; }
.env-badge.anon { background: var(--danger-bg); color: var(--danger); border: 1px solid #f3b7b1; }
.menu-toggle { display: none; }

.content { padding: 24px clamp(16px, 3vw, 32px) 48px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.eyebrow { margin: 0 0 4px; color: var(--blue-600); font-size: 11.5px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.page-head h1 { margin: 0; color: var(--navy-800); font-size: clamp(22px, 2.6vw, 28px); letter-spacing: -.01em; }
.page-head p.lead { margin: 6px 0 0; color: var(--muted); max-width: 760px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------- Grid & cards ---------------- */
.grid { display: grid; gap: 16px; }
.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)); }
.span-2 { grid-column: span 2; }
.span-all { grid-column: 1 / -1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.card-head h2, .card-head h3 { margin: 0; font-size: 15.5px; color: var(--navy-800); display: flex; align-items: center; gap: 8px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }
.card.accent-wms { border-top: 3px solid var(--blue-500); }
.card.accent-bi { border-top: 3px solid var(--violet); }
.card.accent-woo { border-top: 3px solid var(--teal); }
.card.accent-warn { border-top: 3px solid #e0a100; }

/* ---------------- Cards de indicador (componente único para todas as páginas) ----------------
   Marcação: <article|a class="metric [green|amber|red|violet]">
               <span class="metric-icon">svg</span><span>Título</span><strong>Valor</strong><small>Descrição</small>
   Grade fixa: linha 1 = título (até 3 linhas) + ícone; linha 2 = valor; linha 3 = descrição/badge.
   Um título longo nunca desloca o valor ou o ícone em relação aos outros cards. */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); grid-auto-rows: 1fr; align-items: stretch; gap: 14px; margin-bottom: 18px; }
.metric {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--metric-icon-box);
  grid-template-rows: var(--metric-label-h) var(--metric-value-h) minmax(var(--metric-foot-h), 1fr);
  column-gap: 8px;
  row-gap: 4px;
  min-height: var(--metric-min-h);
  padding: 16px 16px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.metric > .metric-icon {
  grid-column: 2; grid-row: 1; align-self: start; justify-self: end;
  display: flex; align-items: center; justify-content: center;
  width: var(--metric-icon-box); height: var(--metric-icon-box); padding: 0;
  border-radius: var(--metric-icon-radius);
  background: var(--blue-50); color: var(--blue-600);
}
.metric > .metric-icon .icon { display: block; width: var(--icon-size); height: var(--icon-size); margin: 0; }
.metric.green > .metric-icon { background: var(--success-bg); color: var(--success); }
.metric.amber > .metric-icon { background: var(--warning-bg); color: var(--warning); }
.metric.red > .metric-icon { background: var(--danger-bg); color: var(--danger); }
.metric.violet > .metric-icon { background: var(--violet-bg); color: var(--violet); }
.metric > span:not(.metric-icon):not(.skeleton) { grid-column: 1; grid-row: 1; align-self: start; min-width: 0; color: var(--muted); font-size: 12.5px; font-weight: 600; line-height: 16px; overflow-wrap: anywhere; }
.metric > strong { grid-column: 1 / -1; grid-row: 2; align-self: center; margin: 0; color: var(--navy-800); font-size: 28px; line-height: 1.1; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.metric > small { grid-column: 1 / -1; grid-row: 3; align-self: start; color: var(--muted); font-size: 12px; line-height: 16px; }
.metric > .skeleton { grid-column: 1 / -1; align-self: center; }
.metric > .skeleton:first-child { grid-row: 1; }
.metric > .skeleton:nth-child(2) { grid-row: 2; }
/* Seções com seis indicadores (Dashboard, Ficha do produto): 3 colunas, 6 em telas largas. */
.metrics.metrics-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (min-width: 1600px) { .metrics.metrics-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 900px) { .metrics.metrics-6 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
a.metric { color: inherit; text-decoration: none !important; transition: transform .12s ease, box-shadow .12s ease; }
a.metric:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

/* ---------------- Buttons & forms ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px; border: 1px solid transparent; border-radius: 10px; background: var(--blue-600); color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; text-decoration: none !important; transition: background .12s ease, box-shadow .12s ease; }
.btn:hover { background: #135c94; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--blue-600); }
.btn.ghost:hover { background: var(--blue-50); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #941c13; }
.btn.success { background: var(--success); }
.btn.success:hover { background: #0d5f4a; }
.btn.sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn.lg { height: 48px; padding: 0 22px; font-size: 15px; }
.btn .spinner { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255, 255, 255, .45); border-top-color: #fff; }
.btn.secondary .spinner { border-color: var(--line-strong); border-top-color: var(--blue-600); }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12.5px; font-weight: 700; color: var(--ink-soft); }
.field .hint { font-size: 12px; color: var(--muted); }
.input, .field input, .field select, .field textarea { width: 100%; min-height: 40px; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: 9px; background: var(--surface); }
.field textarea { min-height: 76px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { border-color: var(--blue-500); outline: none; box-shadow: 0 0 0 4px rgba(38, 132, 214, .14); }
.field input[aria-invalid="true"] { border-color: var(--danger); }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }

.scan-box { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px dashed var(--line-strong); border-radius: 12px; background: var(--surface-2); }
.scan-box:focus-within { border-color: var(--blue-500); border-style: solid; background: var(--blue-50); }
.scan-box .icon { color: var(--blue-600); width: 26px; height: 26px; }
.scan-box input { flex: 1; min-width: 0; height: 46px; border: 0; background: transparent; font-size: 20px; font-weight: 700; letter-spacing: .03em; font-family: "JetBrains Mono", Consolas, monospace; }
.scan-box input:focus { outline: none; }
.scan-box.flash-ok { animation: flash-ok .6s ease; }
.scan-box.flash-err { animation: flash-err .6s ease; }
@keyframes flash-ok { 0% { background: #c9f0de; border-color: var(--success); } 100% { } }
@keyframes flash-err { 0%, 40% { background: #fbd5d1; border-color: var(--danger); transform: translateX(-4px); } 20%, 60% { transform: translateX(4px); } 100% { } }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar .input { max-width: 340px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: 99px; background: var(--surface); color: var(--ink-soft); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip:hover { border-color: var(--blue-500); }
.chip[aria-pressed="true"] { background: var(--navy-700); border-color: var(--navy-700); color: #fff; }
.chip .count { padding: 0 6px; border-radius: 99px; background: rgba(0, 0, 0, .08); font-size: 11.5px; }
.chip[aria-pressed="true"] .count { background: rgba(255, 255, 255, .2); }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; padding: 11px 14px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--blue-600); border-bottom-color: var(--blue-600); }
.tab-panel[hidden] { display: none; }

/* ---------------- Tables ---------------- */
.table-wrap { width: 100%; overflow: auto; }
.table-wrap.tall { max-height: 560px; }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; }
.table th { position: sticky; top: 0; z-index: 1; padding: 10px 14px; background: var(--surface-2); color: var(--muted); font-size: 11.5px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tbody tr:hover td { background: #f8fbff; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table .nowrap { white-space: nowrap; }
.table tr.selected td { background: var(--blue-50); }
.table tr.clickable { cursor: pointer; }
.thumb { width: 44px; height: 44px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface-2) center / contain no-repeat; display: grid; place-items: center; color: var(--muted); overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.product-cell { display: flex; align-items: center; gap: 12px; min-width: 220px; }
.product-cell strong { display: block; color: var(--ink); line-height: 1.3; }
.product-cell small { color: var(--muted); }
.qty-strong { font-weight: 800; font-size: 15px; }
.empty { padding: 40px 18px; text-align: center; color: var(--muted); }
.empty > .icon { width: 34px; height: 34px; color: var(--line-strong); margin-bottom: 8px; display: block; margin-left: auto; margin-right: auto; }
.empty strong { display: block; color: var(--ink-soft); margin-bottom: 4px; }

/* ---------------- Badges ---------------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; font-size: 12px; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--ink-soft); border: 1px solid var(--line); }
.badge.blue { background: var(--blue-50); color: var(--blue-600); border-color: #c2dcf3; }
.badge.green { background: var(--success-bg); color: var(--success); border-color: #a7dcc9; }
.badge.amber { background: var(--warning-bg); color: var(--warning); border-color: #f0d49a; }
.badge.red { background: var(--danger-bg); color: var(--danger); border-color: #f3b7b1; }
.badge.violet { background: var(--violet-bg); color: var(--violet); border-color: #d7cbf1; }
.badge.teal { background: var(--teal-bg); color: var(--teal); border-color: #a8dcd6; }
.badge.dark { background: var(--navy-700); color: #fff; border-color: var(--navy-700); }
.source { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 6px; font-size: 10.5px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
.source.wms { background: var(--blue-50); color: var(--blue-600); }
.source.bi { background: var(--violet-bg); color: var(--violet); }
.source.woo { background: var(--teal-bg); color: var(--teal); }
.source.test { background: var(--warning-bg); color: var(--warning); }

/* ---------------- Feedback ---------------- */
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 13px 16px; margin-bottom: 16px; border-radius: 10px; border: 1px solid #c2dcf3; background: var(--blue-50); color: var(--ink-soft); font-size: 13.5px; }
.notice .icon { color: var(--blue-600); margin-top: 1px; }
.notice.warn { border-color: #f0d49a; background: var(--warning-bg); }
.notice.warn .icon { color: var(--warning); }
.notice.danger { border-color: #f3b7b1; background: var(--danger-bg); }
.notice.danger .icon { color: var(--danger); }
.notice.success { border-color: #a7dcc9; background: var(--success-bg); }
.notice.success .icon { color: var(--success); }
.notice strong { color: var(--ink); }

.spinner { display: inline-block; width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--blue-600); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row td { padding: 0 !important; }
.skeleton { display: block; height: 14px; margin: 14px; border-radius: 6px; background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 50%, #eef2f7 75%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 10px; width: min(400px, calc(100vw - 40px)); }
.toast { display: flex; gap: 12px; align-items: flex-start; padding: 13px 14px; border-radius: 12px; background: var(--navy-800); color: #fff; box-shadow: var(--shadow-lg); animation: toast-in .2s ease; font-size: 14px; }
.toast .icon { margin-top: 1px; }
.toast.success { background: #0d5f4a; }
.toast.error { background: #8f1d14; }
.toast.warn { background: #7a4a00; }
.toast button { margin-left: auto; border: 0; background: none; color: rgba(255, 255, 255, .7); cursor: pointer; padding: 0; }
@keyframes toast-in { from { transform: translateY(10px); opacity: 0; } }

.modal-backdrop { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px; background: rgba(11, 31, 51, .55); backdrop-filter: blur(2px); animation: fade .15s ease; }
.modal { width: min(560px, 100%); max-height: calc(100vh - 40px); display: flex; flex-direction: column; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); animation: pop .18s ease; }
.modal.wide { width: min(820px, 100%); }
.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 6px; }
.modal-head .modal-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px; background: var(--blue-50); color: var(--blue-600); }
.modal-head.danger .modal-icon { background: var(--danger-bg); color: var(--danger); }
.modal-head.warn .modal-icon { background: var(--warning-bg); color: var(--warning); }
.modal-head h2 { margin: 0; font-size: 18px; color: var(--navy-800); }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.modal-body { padding: 14px 22px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 22px 20px; border-top: 1px solid var(--line); }
.summary-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 700; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: scale(.97); opacity: 0; } }

.dropdown { position: absolute; right: 0; top: calc(100% + 8px); width: 360px; max-height: 460px; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 50; }
.dropdown-head { padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 800; color: var(--navy-800); }
.dropdown-item { display: flex; gap: 10px; padding: 11px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; color: var(--ink); text-decoration: none !important; }
.dropdown-item:hover { background: var(--surface-2); }
.dropdown-item small { display: block; color: var(--muted); }

.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 16px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; word-break: break-word; }
.kv dd .badge { white-space: normal; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.stat { padding: 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.stat span { display: block; color: var(--muted); font-size: 12px; font-weight: 600; }
.stat strong { display: block; margin-top: 4px; font-size: 22px; color: var(--navy-800); font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.list li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .grow strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list small { color: var(--muted); }
.list.wrap .grow strong { white-space: normal; }
.list li.order-note { align-items: flex-start; }
.list li.order-note.released { box-shadow: inset 4px 0 0 #f5b700; }
.list li.order-note.divergence { box-shadow: inset 4px 0 0 var(--danger); }
.list li.order-note .grow strong { display: inline; }
.list li.order-note .grow small { display: block; margin-top: 3px; overflow-wrap: anywhere; }
.shortcuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.shortcut { display: flex; flex-direction: column; gap: 10px; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); color: var(--ink); font-weight: 700; text-decoration: none !important; transition: border-color .12s, transform .12s; }
.shortcut:hover { border-color: var(--blue-500); transform: translateY(-2px); }
.shortcut .icon { width: 24px; height: 24px; color: var(--blue-600); }
.shortcut small { color: var(--muted); font-weight: 500; }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--success); transition: width .25s ease; }
.product-hero { display: flex; gap: 18px; align-items: center; }
.product-hero .thumb { width: 96px; height: 96px; border-radius: 12px; }
.product-hero h2 { margin: 4px 0; font-size: 18px; color: var(--navy-800); }
.muted { color: var(--muted); }
.text-right { text-align: right; }
.mt-0 { margin-top: 0; } .mt-16 { margin-top: 16px; } .mb-16 { margin-bottom: 16px; }
.hstack { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------------- Labels / print ---------------- */
#printArea { display: none; }
.label-print { display: inline-flex; flex-direction: column; align-items: center; gap: 2px; width: var(--label-width, 62mm); padding: 3mm; margin: 2mm; border: 1px dashed #bbb; page-break-inside: avoid; font-family: Arial, sans-serif; }
.label-print b { font-size: 8pt; letter-spacing: .05em; }
.label-print img { width: calc(var(--label-width, 62mm) - 6mm); height: 16mm; object-fit: contain; }
.label-print strong { font-size: 13pt; letter-spacing: .06em; }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block !important; }
  .label-print { border: 0; }
  @page { margin: 5mm; }
}

/* ---------------- Responsive ---------------- */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app, .app.collapsed { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar); transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .app.mobile-open .sidebar { transform: none; }
  .app.collapsed .brand > span:last-child, .app.collapsed .nav-section, .app.collapsed .nav a span, .app.collapsed .who-text, .app.collapsed .sidebar-actions span { display: initial; }
  .menu-toggle { display: inline-grid; }
  .scrim { position: fixed; inset: 0; background: rgba(11, 31, 51, .45); z-index: 35; }
  .grid-2, .grid-3, .grid-4, .form-grid { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .search kbd, .env-badge .env-text { display: none; }
  .dropdown { position: fixed; left: 12px; right: 12px; top: 64px; width: auto; }
}
@media (max-width: 560px) {
  .content { padding: 16px 12px 40px; }
  .topbar { gap: 8px; padding: 10px 12px; }
  .metric strong { font-size: 24px; }
  .page-actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------------- Ajustes de tabela/cards ---------------- */
.metric small .source, .metric span.source { display: inline-flex; padding: 2px 8px; }
.table td.prod { min-width: 240px; }
.table td.loc { white-space: nowrap; }
.search { min-width: 0; }
.search input { min-width: 0; }
.topbar-right { flex: none; }
@media (max-width: 560px) {
  .search input { padding-right: 12px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .shortcuts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ------------------------------------------------------------------ login */
.login-page { min-height: 100vh; background: var(--canvas); }
.login-shell { display: grid; grid-template-columns: minmax(320px, 44%) 1fr; min-height: 100vh; }
.login-brand { display: flex; flex-direction: column; justify-content: space-between; padding: 36px 40px; color: #fff;
  background: radial-gradient(120% 80% at 0% 100%, rgba(38, 132, 214, .35), transparent 60%), linear-gradient(160deg, var(--navy-800), var(--navy-900)); }
.login-pitch { max-width: 420px; margin-bottom: 8vh; }
.login-pitch h2 { margin: 0 0 12px; font-size: 26px; line-height: 1.25; }
.login-pitch p { margin: 0; color: #9fb3c8; }
.login-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 20px; gap: 14px; }
.login-card { width: 100%; max-width: 420px; padding: 28px; }
.login-card h1 { margin: 0 0 4px; font-size: 24px; color: var(--navy-800); }
.login-card .muted { margin: 0 0 18px; font-size: 13.5px; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form .notice { margin: 0; }
.login-mobile-brand { display: none; align-items: center; gap: 10px; margin-bottom: 18px; color: var(--navy-800); }
.password-field { position: relative; }
.password-field input { padding-right: 84px; }
.password-field .btn { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.btn.block { width: 100%; }
.form-error { margin: 0; padding: 10px 12px; border-radius: 9px; background: var(--danger-bg); color: var(--danger); font-size: 13.5px; font-weight: 600; }
.login-alt { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line); }
.login-alt summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.login-alt details[open] summary { margin-bottom: 12px; }
.login-foot { max-width: 420px; text-align: center; font-size: 12.5px; }
.login-page .field input { min-height: 46px; font-size: 16px; }
@media (max-width: 860px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-mobile-brand { display: flex; }
  .login-panel { justify-content: flex-start; padding: max(24px, env(safe-area-inset-top)) 16px 24px; }
  .login-card { padding: 22px 18px; }
}

/* ------------------------------------------------------------------ usuários */
.role-badge.admin { background: var(--violet-bg); color: var(--violet); }
.temp-password { display: block; margin: 12px 0; padding: 14px; border-radius: 10px; background: var(--surface-2); border: 1px dashed var(--line-strong);
  font: 700 20px/1.2 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .04em; text-align: center; user-select: all; overflow-wrap: anywhere; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Identidade WMS: barra compacta inspirada na referência PRM. */
.brand-mark { font-family: "Arial Narrow", Impact, sans-serif; font-size: 22px; font-style: italic; letter-spacing: -.12em; padding-right: 3px; background: linear-gradient(140deg,#398fe4,#0e58a4); }
.brand strong { font-size: 21px; font-weight: 900; letter-spacing: -.07em; line-height: 1; }
.brand small { font-size: 10px; letter-spacing: .08em; text-transform: uppercase; }
.sidebar-partner { display: flex; align-items: center; height: 33px; margin: 0 0 10px 3px; opacity: .72; }
.sidebar-partner img { width: 94px; max-height: 27px; object-fit: contain; object-position: left center; }
.app.collapsed .sidebar-partner img { width: 35px; object-fit: cover; object-position: left; }
.topbar { min-height: 68px; background: rgba(12,19,30,.97); border-bottom-color: #293748; color: #e8eef8; }
.partner-strip { flex: none; width: 186px; height: 33px; overflow: hidden; display: flex; align-items: center; }
.partner-strip img { display: block; width: 186px; height: 33px; object-fit: cover; object-position: center; filter: invert(1); mix-blend-mode: screen; opacity: .75; }
.topbar .search { max-width: 480px; }
.topbar .search input { background: #182332; border-color: #344256; color: #e8eef8; }
.topbar .search input::placeholder { color: #a4b2c4; }
.topbar .search .icon { color: #a4b2c4; }
.topbar .search kbd { background: #233044; border-color: #344256; color: #a4b2c4; }
.topbar .icon-button { background: transparent; border-color: transparent; color: #bdcad9; }
.topbar .icon-button:hover { background: #243248; color: #fff; }
.topbar .icon-button:focus-visible { outline-color: #63b1ff; }
.live-clock { display: flex; align-items: center; gap: 8px; white-space: nowrap; padding-right: 12px; margin-right: 2px; border-right: 1px solid #344256; font-variant-numeric: tabular-nums; }
.live-clock time { font-size: 13px; font-weight: 800; letter-spacing: -.02em; color: #f1f5fb; }
.live-clock > span { display: flex; flex-direction: column; gap: 1px; font-size: 10px; color: #b9c7d7; }
.live-clock b { font-weight: 600; }
.live-clock small { color: #8393a8; font-size: 9px; }
.page-head h1 { font-weight: 800; letter-spacing: -.035em; }
.eyebrow { letter-spacing: .13em; }
.card, .metric, .modal, .dropdown { box-shadow: var(--shadow); }
.login-partners { display: flex; align-items: center; gap: 14px; margin-top: 22px; }
.login-partners img { display: block; object-fit: contain; }
.login-partners .industrial-logos { width: min(100%, 360px); height: 74px; object-fit: cover; object-position: center; filter: invert(1); mix-blend-mode: screen; opacity: .77; }
.login-mobile-brand .choice-logo { width: 76px; height: 26px; object-fit: contain; margin-left: auto; padding: 4px; border-radius: 6px; background: #0d1725; }
.login-affiliates { display: flex; align-items: center; justify-content: center; gap: 12px; opacity: .82; }
.login-affiliates img:first-child { width: 77px; height: 28px; object-fit: contain; padding: 4px; border-radius: 5px; background: #0d1725; }
.login-affiliates img:last-child { width: 27px; height: 28px; object-fit: contain; }
.login-theme-toggle { position: fixed; z-index: 5; top: max(16px, env(safe-area-inset-top)); right: max(16px, env(safe-area-inset-right)); height: 34px; padding: 0 12px; font-size: 12px; box-shadow: var(--shadow-sm); }

:root[data-theme="dark"] {
  color-scheme: dark;
  --blue-600: #72b8ff; --blue-500: #3a95ee; --blue-50: #1a334b;
  --ink: #e8eef7; --ink-soft: #ccd6e5; --muted: #a1afc2;
  --line: #334155; --line-strong: #46576c;
  --surface: #172334; --surface-2: #1d2b3d; --canvas: #0e1724;
  --success: #83dbb2; --success-bg: #183e36;
  --warning: #f0c879; --warning-bg: #443922;
  --danger: #ff9891; --danger-bg: #442c30;
  --violet: #c4aeff; --violet-bg: #342c4b;
  --teal: #80dfd0; --teal-bg: #193d41;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow: 0 8px 24px rgba(0,0,0,.19);
  --shadow-lg: 0 24px 60px rgba(0,0,0,.45);
}
:root[data-theme="dark"] .page-head h1,
:root[data-theme="dark"] .card-head h2,
:root[data-theme="dark"] .card-head h3,
:root[data-theme="dark"] .metric strong,
:root[data-theme="dark"] .modal-head h2,
:root[data-theme="dark"] .dropdown-head,
:root[data-theme="dark"] .stat strong,
:root[data-theme="dark"] .product-hero h2,
:root[data-theme="dark"] .login-card h1,
:root[data-theme="dark"] .login-mobile-brand,
:root[data-theme="dark"] .sku-big,
:root[data-theme="dark"] .pair-code { color: var(--ink); }
:root[data-theme="dark"] .table tbody tr:hover td { background: #233349; }
:root[data-theme="dark"] .skeleton { background: linear-gradient(90deg,#27384d 25%,#354960 50%,#27384d 75%); background-size: 200% 100%; }
:root[data-theme="dark"] .badge.blue { border-color: #315f84; }
:root[data-theme="dark"] .badge.green { border-color: #2d7160; }
:root[data-theme="dark"] .badge.amber { border-color: #76643f; }
:root[data-theme="dark"] .badge.red { border-color: #79505a; }
:root[data-theme="dark"] .badge.violet { border-color: #6c558f; }
:root[data-theme="dark"] .badge.teal { border-color: #326b6b; }
:root[data-theme="dark"] .notice { border-color: #315f84; }
:root[data-theme="dark"] .notice.warn { border-color: #76643f; }
:root[data-theme="dark"] .notice.danger { border-color: #79505a; }
:root[data-theme="dark"] .notice.success { border-color: #2d7160; }
:root[data-theme="dark"] .scan-box:focus-within { background: var(--blue-50); }
:root[data-theme="dark"] .modal { border: 1px solid var(--line); }
:root[data-theme="dark"] .btn:not(.secondary):not(.ghost):not(.danger):not(.success) { background: #286fac; color: #fff; }
:root[data-theme="dark"] .btn:not(.secondary):not(.ghost):not(.danger):not(.success):hover { background: #3481c3; }
:root[data-theme="dark"] .login-affiliates img:last-child { filter: brightness(1.8); }
@media (max-width: 1180px) { .partner-strip { width: 130px; } .partner-strip img { width: 130px; } .live-clock > span { display: none; } }
@media (max-width: 900px) { .partner-strip { display: none; } .app.collapsed .sidebar-partner img { width: 94px; object-fit: contain; } }
@media (max-width: 560px) { .topbar { min-height: 58px; } .live-clock { padding-right: 6px; gap: 0; } .live-clock time { font-size: 11px; } .topbar-right { gap: 2px; } .topbar .search input { font-size: 12px; } .topbar .search input::placeholder { color: transparent; } .topbar .icon-button { width: 34px; height: 34px; } }
@media (max-width: 420px) { .topbar .env-badge { display: none; } .live-clock time { font-size: 10px; } }


/* Celular estreito: indicadores em uma coluna (vale para todas as seções .metrics). */
@media (max-width: 380px) { .metrics, .metrics.metrics-6 { grid-template-columns: minmax(0, 1fr); } }
