/* ============================================================
   BENAVIE OS — painel admin
   Design system: DESIGN-hp.md (interpretação HP)
   Canvas branco, ink #1a1a1a, Electric Blue #024ad8 (máx 2/viewport)
   Cards 16px + Soft Lift · Botões 4px uppercase · Manrope/system
   ============================================================ */

:root {
  /* Cores — tokens do DESIGN-hp.md */
  --blue: #024ad8;
  --blue-bright: #296ef9;
  --blue-deep: #0e3191;
  --blue-soft: #c9e0fc;
  --ink: #1a1a1a;
  --ink-deep: #000000;
  --ink-soft: #292929;
  --on-ink: #ffffff;
  --canvas: #ffffff;
  --cloud: #f7f7f7;
  --fog: #e8e8e8;
  --steel: #c2c2c2;
  --graphite: #636363;
  --charcoal: #3d3d3d;
  --hairline: #e8e8e8;
  --hairline-strong: #c2c2c2;
  --rose: #f9d4d2;
  --red: #b3262b;
  --wine: #5a1313;
  --storm-mist: #8ebdce;
  --storm-sea: #7fadbe;
  --storm-deep: #356373;

  /* Raios — botões duros (4px) vs. cards macios (16px) */
  --r-sm: 3px;
  --r-md: 4px;
  --r-lg: 8px;
  --r-xl: 16px;
  --r-pill: 9999px;

  /* Sombras */
  --lift: 0 2px 8px rgba(26, 26, 26, .08);
  --float: 0 8px 24px rgba(26, 26, 26, .12);

  /* Espaço */
  --sp-xxs: 4px; --sp-xs: 8px; --sp-sm: 12px; --sp-md: 16px;
  --sp-lg: 20px; --sp-xl: 24px; --sp-xxl: 32px;

  --font: Manrope, Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --sidebar-w: 232px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ---------- Tipografia ---------- */
h1, h2, h3 { font-weight: 500; line-height: 1.1; }
.display-md { font-size: 32px; font-weight: 500; line-height: 1.0; }
.display-sm { font-size: 24px; font-weight: 500; line-height: 1.17; }
.display-xs { font-size: 20px; font-weight: 500; line-height: 1.2; }
.caption { font-size: 14px; color: var(--graphite); line-height: 1.5; }
.caption-sm { font-size: 12px; color: var(--graphite); line-height: 1.33; }
.muted { color: var(--charcoal); }
.price { font-size: 24px; font-weight: 500; line-height: 1.17; }

a { color: var(--blue); text-decoration: none; }
a:active { color: var(--blue-deep); }

/* Link discreto em ink (usado quando a cota de azul da tela já fechou) */
.link-ink { color: var(--ink); text-decoration: underline; text-underline-offset: 2px; }
.link-danger {
  color: var(--red); background: none; border: 0; cursor: pointer;
  font: 500 14px/1.4 var(--font); text-decoration: underline; text-underline-offset: 2px;
  padding: 10px 0;
}

/* ---------- Botões: 4px, uppercase, 14/600, tracking .7px ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 12px 24px;
  border: 0; border-radius: var(--r-md); cursor: pointer;
  font: 600 14px/1.4 var(--font); letter-spacing: .7px; text-transform: uppercase;
  background: var(--canvas); color: var(--ink);
  transition: background .12s ease;
}
.btn:disabled { cursor: not-allowed; }
.btn--primary { background: var(--blue); color: #fff; }
.btn--primary:active { background: var(--blue-deep); }
.btn--primary:disabled { background: var(--steel); color: #fff; }
.btn--ink { background: var(--ink); color: #fff; }
.btn--outline-ink { background: var(--canvas); color: var(--ink); border: 1px solid var(--ink); }
.btn--outline-ink:active { background: var(--cloud); }
.btn--danger { background: var(--red); color: #fff; }
.btn--sm { min-height: 36px; padding: 8px 16px; font-size: 12.6px; font-weight: 700; letter-spacing: .5px; }
.btn--block { width: 100%; }

/* ---------- Inputs: 44px, 4px, borda steel → ink no foco ---------- */
.input, .select, .textarea {
  width: 100%; min-height: 44px; padding: 12px 16px;
  border: 1px solid var(--steel); border-radius: var(--r-md);
  background: var(--canvas); color: var(--ink);
  font: 400 16px/1.4 var(--font);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--ink); }
.textarea { min-height: 96px; resize: vertical; }
.input--search { min-height: 40px; max-width: 420px; }
.field { margin-bottom: var(--sp-md); }
.field > label {
  display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--ink);
}
.field .hint { font-size: 12px; color: var(--graphite); margin-top: 4px; }
.field .error-text { font-size: 12px; color: var(--red); margin-top: 4px; }
.input.invalid { border-color: var(--red); }

/* Toggle (switch) */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; min-height: 44px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track {
  width: 44px; height: 24px; border-radius: var(--r-pill);
  background: var(--steel); transition: background .15s ease; flex: none; position: relative;
}
.switch .track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px;
  border-radius: 50%; background: #fff; transition: transform .15s ease;
}
.switch input:checked + .track { background: var(--ink); }
.switch input:checked + .track::after { transform: translateX(20px); }
.switch .switch-label { font-size: 15px; font-weight: 500; }

/* Stepper de estoque */
.stepper { display: inline-flex; align-items: center; gap: 2px; }
.stepper button {
  width: 36px; height: 36px; border: 1px solid var(--steel); background: var(--canvas);
  border-radius: var(--r-md); font: 600 18px/1 var(--font); color: var(--ink); cursor: pointer;
}
.stepper button:active { background: var(--cloud); }
.stepper button:disabled { color: var(--steel); cursor: not-allowed; }
.stepper .stepper-value {
  min-width: 44px; text-align: center; font-weight: 600; font-size: 16px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--canvas); border-radius: var(--r-xl);
  box-shadow: var(--lift); padding: var(--sp-xl);
}
.card--cloud { background: var(--cloud); box-shadow: none; }
.card + .card, .card + .slab, .slab + .card { margin-top: var(--sp-md); }
.card h2 { margin-bottom: var(--sp-md); }
.card-label {
  font-size: 12px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase;
  color: var(--graphite); margin-bottom: var(--sp-sm);
}

/* Dark slab (promo-strip-dark) — fecha o dashboard */
.slab {
  background: var(--ink); color: var(--on-ink);
  border-radius: var(--r-xl); padding: 48px var(--sp-xxl);
}
.slab h2 { color: #fff; }
.slab .caption { color: var(--steel); }

/* Grid de métricas */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--sp-md); margin: var(--sp-md) 0; }
.metric .metric-value { font-size: 32px; font-weight: 500; line-height: 1.1; margin: 6px 0 2px; }

/* ---------- Tabs pill (category-tab) ---------- */
.tabs { display: flex; flex-wrap: wrap; gap: var(--sp-xs); margin: var(--sp-md) 0; }
.tab {
  border: 1px solid var(--hairline); background: var(--canvas); color: var(--ink);
  border-radius: var(--r-pill); padding: 8px 20px; min-height: 40px;
  font: 500 15px/1.4 var(--font); cursor: pointer;
}
.tab.active { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ---------- Tabela ---------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 700; letter-spacing: .6px;
  text-transform: uppercase; color: var(--graphite);
  padding: 10px 12px; border-bottom: 1px solid var(--hairline);
  white-space: nowrap;
}
.table td { padding: 14px 12px; border-bottom: 1px solid var(--hairline); font-size: 15px; }
.table tr:last-child td { border-bottom: 0; }
.table tr.row-click { cursor: pointer; }
.table tr.row-click:hover { background: var(--cloud); }
.td-num { font-weight: 600; white-space: nowrap; }
.td-money { white-space: nowrap; font-weight: 500; }
.td-when { white-space: nowrap; color: var(--graphite); font-size: 14px; }

/* ---------- Badges de status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--r-lg);
  font: 700 13px/1.3 var(--font); white-space: nowrap;
}
.badge--aguardando { color: var(--graphite); border: 1px solid var(--steel); background: var(--canvas); }
.badge--pago { background: var(--blue-soft); color: var(--blue); }
.badge--embalado { background: var(--fog); color: var(--ink); }
.badge--enviado { background: rgba(142, 189, 206, .3); color: var(--storm-deep); }
.badge--entregue { background: var(--storm-deep); color: #fff; }
.badge--cancelado { background: var(--rose); color: var(--red); }

/* ---------- Layout: sidebar ink + conteúdo ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w); flex: none;
  background: var(--ink); color: var(--on-ink);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar .wordmark {
  font-size: 20px; font-weight: 500; letter-spacing: 1px; color: #fff;
  padding: var(--sp-xl) var(--sp-xl) var(--sp-lg);
}
.side-nav { flex: 1; display: flex; flex-direction: column; padding-top: var(--sp-xs); }
.side-link {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 12px var(--sp-xl);
  color: #fff; font-size: 16px;
  border-left: 3px solid transparent;
}
.side-link svg { width: 20px; height: 20px; flex: none; stroke: currentColor; }
.side-link:hover { background: var(--ink-soft); }
.side-link.active { border-left-color: var(--blue); background: var(--ink-soft); }
.side-cta { padding: var(--sp-md) var(--sp-xl); }
.side-foot {
  padding: var(--sp-md) var(--sp-xl) var(--sp-xl);
  border-top: 1px solid var(--ink-soft);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.side-foot .who { font-size: 14px; color: var(--steel); }
.side-foot .logout {
  background: none; border: 0; color: #fff; cursor: pointer;
  font: 600 12px/1 var(--font); letter-spacing: .6px; text-transform: uppercase;
  padding: 10px 0;
}
.side-foot .logout:hover { text-decoration: underline; }

.main {
  flex: 1; min-width: 0;
  padding: var(--sp-xxl) var(--sp-xl) 96px;
  max-width: 1100px; margin: 0 auto; width: 100%;
}
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-md); margin-bottom: var(--sp-lg); flex-wrap: wrap; }
.page-head .sub { margin-top: 6px; }
.back-link { display: inline-block; margin-bottom: var(--sp-md); font-weight: 500; }

/* ---------- Bottom nav (mobile) + FAB ---------- */
.bottomnav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  background: var(--ink); color: #fff;
  justify-content: space-around; padding: 6px 0 max(6px, env(safe-area-inset-bottom));
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  color: var(--steel); font-size: 11px; min-width: 56px; min-height: 44px; justify-content: center;
}
.bottomnav a svg { width: 22px; height: 22px; stroke: currentColor; }
.bottomnav a.active { color: #fff; }
.fab {
  display: none; position: fixed; right: 16px; bottom: 76px; z-index: 41;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--blue); color: #fff; box-shadow: var(--float);
  align-items: center; justify-content: center; font-size: 28px; font-weight: 500; line-height: 1;
}
.fab:active { background: var(--blue-deep); }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: var(--canvas); position: relative; overflow: hidden; padding: var(--sp-xl);
}
.login-card {
  background: var(--canvas); border-radius: var(--r-xl); box-shadow: var(--lift);
  padding: 40px var(--sp-xxl); width: 100%; max-width: 400px; position: relative; z-index: 1;
}
.login-card .wordmark { font-size: 24px; font-weight: 500; letter-spacing: 1.5px; margin-bottom: 6px; }
.login-card .caption { margin-bottom: var(--sp-xl); }
.login-error { color: var(--red); font-size: 14px; margin-top: var(--sp-sm); min-height: 20px; }
/* Chevrons azuis — eco do wordmark HP; só no login (e herói do dashboard) */
.chevron {
  position: absolute; top: 50%; width: 72px; height: 320px;
  background: var(--blue); transform: translateY(-50%) skewX(-24deg);
}
.chevron--l { left: -20px; }
.chevron--l2 { left: 84px; opacity: .35; }
.chevron--r { right: -20px; }
.chevron--r2 { right: 84px; opacity: .35; }

/* ---------- Timeline do pedido ---------- */
.timeline { list-style: none; }
.timeline li { display: flex; gap: 14px; position: relative; padding-bottom: 22px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline .dot {
  width: 14px; height: 14px; border-radius: 50%; flex: none; margin-top: 3px;
  border: 2px solid var(--steel); background: var(--canvas); position: relative; z-index: 1;
}
.timeline li.done .dot { background: var(--ink); border-color: var(--ink); }
.timeline li.cancel .dot { background: var(--red); border-color: var(--red); }
.timeline li:not(:last-child)::before {
  content: ""; position: absolute; left: 6px; top: 18px; bottom: 0;
  width: 2px; background: var(--hairline);
}
.timeline .tl-label { font-weight: 500; }
.timeline li:not(.done):not(.cancel) .tl-label { color: var(--graphite); font-weight: 400; }
.timeline .tl-when { font-size: 13px; color: var(--graphite); }

/* ---------- Toasts ---------- */
#toasts {
  position: fixed; right: 16px; bottom: 16px; z-index: 100;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  background: var(--ink); color: #fff; border-radius: var(--r-lg);
  padding: 14px 18px; font-size: 14px; box-shadow: var(--float);
  animation: toast-in .18s ease;
}
.toast--error { background: var(--red); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(26, 26, 26, .45);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-xl);
}
.modal {
  background: var(--canvas); border-radius: var(--r-xl); box-shadow: var(--float);
  padding: var(--sp-xxl); width: 100%; max-width: 480px;
}
.modal h3 { font-size: 24px; font-weight: 500; margin-bottom: var(--sp-sm); }
.modal .modal-body { color: var(--charcoal); margin-bottom: var(--sp-xl); font-size: 15px; }
.modal .modal-actions { display: flex; gap: var(--sp-sm); justify-content: flex-end; flex-wrap: wrap; }

/* ---------- Skeleton ---------- */
.skeleton { border-radius: var(--r-lg); background: var(--fog); position: relative; overflow: hidden; }
.skeleton::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.6), transparent);
  animation: shimmer 1.2s infinite;
}
@keyframes shimmer { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.skel-line { height: 16px; margin: 10px 0; }
.skel-card { height: 96px; margin: 12px 0; border-radius: var(--r-xl); }

/* ---------- Estado vazio ---------- */
.empty { text-align: center; padding: 56px var(--sp-xl); color: var(--charcoal); }
.empty .empty-title { font-size: 20px; font-weight: 500; color: var(--ink); margin-bottom: 8px; }
.empty .empty-hint { font-size: 15px; max-width: 420px; margin: 0 auto 20px; }
.empty svg { width: 48px; height: 48px; stroke: var(--steel); margin-bottom: 12px; }

/* ---------- Blocos utilitários ---------- */
.row { display: flex; gap: var(--sp-md); flex-wrap: wrap; align-items: center; }
.row--between { justify-content: space-between; }
.stack > * + * { margin-top: var(--sp-md); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-md); }
.divider { border: 0; border-top: 1px solid var(--hairline); margin: var(--sp-md) 0; }
.kv { display: flex; justify-content: space-between; gap: var(--sp-md); padding: 6px 0; font-size: 15px; }
.kv .k { color: var(--graphite); }
.kv--total { font-weight: 600; font-size: 17px; border-top: 1px solid var(--hairline); margin-top: 6px; padding-top: 12px; }

/* Barra de estoque (produtos) */
.stockbar { height: 6px; border-radius: var(--r-pill); background: var(--fog); overflow: hidden; margin-top: 8px; }
.stockbar > i { display: block; height: 100%; background: var(--ink); }

/* Lista de variantes */
.variant-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md);
  padding: 12px 0; border-bottom: 1px solid var(--hairline); flex-wrap: wrap;
}
.variant-row:last-child { border-bottom: 0; }
.variant-name { font-weight: 500; min-width: 120px; }

/* Radios do pedido manual */
.radio-list { display: flex; flex-direction: column; gap: 2px; }
.radio-item {
  display: flex; align-items: center; gap: 10px; min-height: 44px;
  padding: 4px 8px; border-radius: var(--r-lg); cursor: pointer; font-size: 15px;
}
.radio-item:hover { background: var(--cloud); }
.radio-item input { width: 18px; height: 18px; accent-color: var(--ink); }

/* Config: linha de status de integração */
.integ-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-md); padding: 10px 0; }
.integ-ok { color: var(--storm-deep); font-weight: 600; font-size: 14px; }
.integ-pending { color: var(--graphite); font-weight: 600; font-size: 14px; }

/* ---------- Responsivo ---------- */
@media (max-width: 1023px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 767px) {
  .sidebar { display: none; }
  .bottomnav { display: flex; }
  .fab { display: flex; }
  .main { padding: var(--sp-lg) var(--sp-md) 132px; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .slab { padding: var(--sp-xxl) var(--sp-xl); }
  .chevron { display: none; }
  .display-md { font-size: 26px; }
  /* Tabela de pedidos vira lista de cards no celular */
  .table--cards thead { display: none; }
  .table--cards tr { display: block; border: 1px solid var(--hairline); border-radius: var(--r-lg); margin-bottom: 10px; padding: 10px 12px; }
  .table--cards td { display: inline-block; border: 0; padding: 2px 6px 2px 0; }
  .table--cards td.td-full { display: block; }
}
