/* =========================================================================
   ALPP Hub — Design System
   Tema claro, densidade de dashboard. Tokens primeiro, componentes depois.
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@300;400;500;600;700&display=swap');

:root {
  /* --- Superficies --- */
  --canvas:        #F4F5FA;
  --surface:       #FFFFFF;
  --surface-2:     #FAFBFE;
  --surface-3:     #F1F2F8;
  --line:          #E4E6F0;
  --line-strong:   #D0D4E4;

  /* --- Texto --- */
  --ink:           #141B34;
  --ink-2:         #4A5578;
  --ink-3:         #78829D;
  --ink-inv:       #FFFFFF;

  /* --- Marca --- */
  --brand:         #4F46E5;
  --brand-600:     #4338CA;
  --brand-700:     #3730A3;
  --brand-tint:    #EEF0FE;
  --brand-tint-2:  #E0E3FD;
  --violet:        #7C3AED;

  /* --- Semanticas --- */
  --pos:           #0B8A5B;
  --pos-tint:      #E4F6EE;
  --neg:           #C92A38;
  --neg-tint:      #FDECEE;
  --warn:          #B45309;
  --warn-tint:     #FEF3E2;
  --info:          #1D4ED8;
  --info-tint:     #E8EEFD;

  /* --- Marcas dos marketplaces (para os cards do hub) --- */
  --ml:            #FFE600;
  --ml-ink:        #2D3277;
  --shopee:        #EE4D2D;
  --amazon:        #FF9900;
  --amazon-ink:    #232F3E;
  --magalu:        #0086FF;
  --shein:         #1F1F1F;
  --tiktok:        #010101;
  --correios:      #FFD100;
  --correios-ink:  #003399;

  /* --- Espacamento (densidade 8/10: dashboard) --- */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px;
  --s5: 20px; --s6: 24px; --s8: 32px; --s10: 40px; --s12: 48px;

  /* --- Raios --- */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  /* --- Elevacao --- */
  --sh-1: 0 1px 2px rgba(20, 27, 52, .05);
  --sh-2: 0 2px 4px rgba(20, 27, 52, .06), 0 1px 2px rgba(20, 27, 52, .04);
  --sh-3: 0 8px 24px rgba(20, 27, 52, .09), 0 2px 6px rgba(20, 27, 52, .05);
  --sh-4: 0 20px 48px rgba(20, 27, 52, .16);

  /* --- Tipografia --- */
  --font-ui:   'Fira Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-data: 'Fira Code', ui-monospace, 'Cascadia Mono', Consolas, monospace;

  /* --- Movimento --- */
  --t-fast: 120ms cubic-bezier(.4, 0, .2, 1);
  --t-base: 200ms cubic-bezier(.4, 0, .2, 1);
  --t-slow: 320ms cubic-bezier(.16, 1, .3, 1);

  --sidebar-w: 252px;
  --topbar-h: 60px;
  --tabbar-h: 58px;

  /* Areas seguras do aparelho (notch, indicador de home).
     Fora do iOS os env() resolvem para 0px. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

/* =============================== Reset ================================= */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; background: var(--canvas); }

body {
  margin: 0;
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  /* Sem realce cinza ao tocar e sem "puxar" a pagina alem do fim */
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

/* O navegador esconde [hidden] com `display:none`, mas qualquer regra nossa de
   `display` (em .field, .tile, .card…) vence a folha padrão dele. Sem isto,
   marcar um elemento como hidden pelo JS não teria efeito nenhum. */
[hidden] { display: none !important; }

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
img, svg { display: block; max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

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

/* ============================= Utilidades ============================== */

.stack       { display: flex; flex-direction: column; }
.row         { display: flex; align-items: center; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.wrap        { flex-wrap: wrap; }
.grow        { flex: 1 1 auto; min-width: 0; }
.gap-1 { gap: var(--s1); } .gap-2 { gap: var(--s2); } .gap-3 { gap: var(--s3); }
.gap-4 { gap: var(--s4); } .gap-5 { gap: var(--s5); } .gap-6 { gap: var(--s6); }
.mt-2 { margin-top: var(--s2); } .mt-3 { margin-top: var(--s3); }
.mt-4 { margin-top: var(--s4); } .mt-6 { margin-top: var(--s6); }
.mb-4 { margin-top: 0; margin-bottom: var(--s4); }
.text-center { text-align: center; }
.text-right  { text-align: right; }
.nowrap      { white-space: nowrap; }
.truncate    { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Corta em N linhas deixando o texto quebrar — nao trava a largura como o truncate */
.clamp-2     { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.hidden      { display: none !important; }

.t-xs { font-size: 11px; } .t-sm { font-size: 12px; } .t-md { font-size: 13px; }
.t-lg { font-size: 16px; } .t-xl { font-size: 20px; } .t-2xl { font-size: 26px; }
.t-muted  { color: var(--ink-2); }
.t-faint  { color: var(--ink-3); }
.t-strong { font-weight: 600; }
.t-bold   { font-weight: 700; }
.t-up     { text-transform: uppercase; letter-spacing: .06em; }
.t-pos { color: var(--pos); } .t-neg { color: var(--neg); } .t-warn { color: var(--warn); }
.num {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
  letter-spacing: -.01em;
}

/* ============================== Layout ================================= */

.app { display: flex; min-height: 100vh; }

/* ---- Barra lateral ---- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s5) var(--s5) var(--s4);
  border-bottom: 1px solid var(--line);
  min-height: var(--topbar-h);
}
.brand__mark {
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--violet) 100%);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 15px; letter-spacing: -.02em;
  box-shadow: var(--sh-2);
}
.brand__mark img { width: 100%; height: 100%; border-radius: 9px; object-fit: cover; }
/* Quando a marca escolhida ja traz o proprio fundo, o degrade sai de cena */
.brand__mark--img { background: none; }
.brand__name { font-weight: 700; font-size: 15px; letter-spacing: -.01em; line-height: 1.15; }
.brand__sub  { font-size: 11px; color: var(--ink-3); letter-spacing: .04em; text-transform: uppercase; }

.nav { padding: var(--s4) var(--s3); overflow-y: auto; flex: 1 1 auto; }
.nav__group + .nav__group { margin-top: var(--s5); }
.nav__title {
  font-size: 10px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3);
  padding: 0 var(--s3) var(--s2);
}
.nav__link {
  display: flex; align-items: center; gap: var(--s3);
  padding: 9px var(--s3);
  border-radius: var(--r-md);
  color: var(--ink-2);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  position: relative;
}
.nav__link:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.nav__link svg { width: 17px; height: 17px; flex: 0 0 17px; stroke-width: 1.8; }
.nav__link.is-active {
  background: var(--brand-tint);
  color: var(--brand-700);
  font-weight: 600;
}
.nav__link.is-active::before {
  content: '';
  position: absolute; left: -var(--s3); left: -12px; top: 50%;
  width: 3px; height: 18px; margin-top: -9px;
  border-radius: 0 3px 3px 0;
  background: var(--brand);
}
.nav__badge {
  margin-left: auto;
  font-size: 10px; font-weight: 600;
  padding: 1px 6px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--ink-3);
}

.sidebar__foot { border-top: 1px solid var(--line); padding: var(--s3); }
.userchip {
  display: flex; align-items: center; gap: var(--s3);
  padding: var(--s2) var(--s3);
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}
.userchip:hover { background: var(--surface-3); }
.avatar {
  width: 30px; height: 30px; flex: 0 0 30px;
  border-radius: var(--r-full);
  background: var(--brand-tint); color: var(--brand-700);
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
}

/* ---- Area principal ---- */
.main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  flex: 0 0 var(--topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s4);
  padding: 0 var(--s6);
  position: sticky; top: 0; z-index: 30;
}
.topbar__title { font-size: 17px; font-weight: 600; letter-spacing: -.01em; }
.topbar__sub { font-size: 12px; color: var(--ink-3); }

.content { padding: var(--s6); max-width: 1560px; width: 100%; }

.page-head { margin-bottom: var(--s5); }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.page-head p { color: var(--ink-2); font-size: 13px; margin-top: 2px; }

.section { margin-top: var(--s8); }
.section__head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--s4); margin-bottom: var(--s4); flex-wrap: wrap;
}
.section__title { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.section__hint { font-size: 12px; color: var(--ink-3); }

/* =============================== Cards ================================= */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
}
.card__head {
  padding: var(--s4) var(--s5);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
}
.card__title { font-size: 14px; font-weight: 600; }
.card__body { padding: var(--s5); }
.card__foot {
  padding: var(--s3) var(--s5);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
  font-size: 12px; color: var(--ink-3);
}

.grid { display: grid; gap: var(--s4); }
.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)); }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(232px, 1fr)); }

/* ---- Cartao de indicador ---- */
.stat { padding: var(--s5); }
.stat__label {
  font-size: 11px; font-weight: 600; letter-spacing: .07em; text-transform: uppercase;
  color: var(--ink-3);
  display: flex; align-items: center; gap: var(--s2);
}
.stat__label svg { width: 14px; height: 14px; flex: 0 0 14px; stroke-width: 2; }

/* Marcador numerado das etapas do roteiro */
.step-dot {
  flex: 0 0 26px; width: 26px; height: 26px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 700; font-size: 11px;
  background: var(--surface-3); color: var(--ink-3);
}
.step-dot svg { width: 13px; height: 13px; stroke-width: 2.6; }
.step-dot--done { background: var(--pos-tint); color: var(--pos); }
.step-dot--next { background: var(--warn-tint); color: var(--warn); }

/* Icone dentro de um quadrado (listas, tabelas) */
.ic-box {
  flex: 0 0 30px; width: 30px; height: 30px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--brand-tint); color: var(--brand-700);
}
.ic-box svg { width: 15px; height: 15px; }

/* Icone inline em listas de texto */
.ic-inline { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 2px; color: var(--brand); }
.stat__value {
  font-family: var(--font-data);
  font-variant-numeric: tabular-nums;
  font-size: 25px; font-weight: 600; letter-spacing: -.03em;
  margin-top: var(--s2); line-height: 1.1;
}
.stat__foot { margin-top: var(--s3); font-size: 12px; color: var(--ink-2); display: flex; align-items: center; gap: var(--s2); }

.delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-family: var(--font-data); font-size: 11px; font-weight: 600;
  padding: 2px 6px; border-radius: var(--r-sm);
}
.delta--pos { background: var(--pos-tint); color: var(--pos); }
.delta--neg { background: var(--neg-tint); color: var(--neg); }
.delta--flat { background: var(--surface-3); color: var(--ink-3); }
.delta svg { width: 12px; height: 12px; }

/* ============================== Botoes ================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  padding: 8px 14px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), box-shadow var(--t-fast), color var(--t-fast), transform var(--t-fast);
}
.btn:hover { text-decoration: none; }
.btn:active { transform: translateY(.5px); }
.btn svg { width: 15px; height: 15px; flex: 0 0 15px; stroke-width: 1.9; }

.btn--primary { background: var(--brand); color: #fff; box-shadow: var(--sh-2); }
.btn--primary:hover { background: var(--brand-600); }

.btn--ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.btn--ghost:hover { background: var(--surface-3); color: var(--ink); border-color: var(--line-strong); }

.btn--subtle { background: var(--surface-3); color: var(--ink-2); }
.btn--subtle:hover { background: var(--brand-tint); color: var(--brand-700); }

.btn--danger { background: var(--neg-tint); color: var(--neg); }
.btn--danger:hover { background: var(--neg); color: #fff; }

.btn--sm { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn--sm svg { width: 13px; height: 13px; flex: 0 0 13px; }
.btn--lg { padding: 11px 20px; font-size: 14px; }
.btn--block { width: 100%; }
.btn--icon { padding: 7px; }
.btn--icon svg { width: 16px; height: 16px; flex: 0 0 16px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* =============================== Badges ================================ */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: 11px; font-weight: 600;
  background: var(--surface-3); color: var(--ink-2);
  white-space: nowrap;
}
.badge svg { width: 11px; height: 11px; }
.badge--pos  { background: var(--pos-tint);  color: var(--pos); }
.badge--neg  { background: var(--neg-tint);  color: var(--neg); }
.badge--warn { background: var(--warn-tint); color: var(--warn); }
.badge--info { background: var(--info-tint); color: var(--info); }
.badge--brand{ background: var(--brand-tint);color: var(--brand-700); }
/* o ponto reforca o significado sem depender so da cor */
.badge__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ============================== Tabelas ================================ */

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--ink-3);
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky; top: 0;
}
table.data td {
  padding: var(--s3) var(--s4);
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.data tbody tr { transition: background var(--t-fast); }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .col-num { text-align: right; font-family: var(--font-data); font-variant-numeric: tabular-nums; }
/* Ícone que acompanha um texto dentro da tabela precisa ficar do tamanho da letra */
table.data td a svg {
  display: inline-block;
  width: 13px; height: 13px;
  vertical-align: -2px;
  margin-left: 3px;
}

/* =============================== Forms ================================= */

.field { display: flex; flex-direction: column; gap: 5px; }
.field > label {
  font-size: 12px; font-weight: 600; color: var(--ink-2);
  display: flex; align-items: center; gap: var(--s2);
}
.field__hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.45; }
.field__error { font-size: 12px; color: var(--neg); font-weight: 500; }

.input, .select, .textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--surface);
  font-size: 13.5px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--ink-3); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-tint-2);
}
.input::placeholder, .textarea::placeholder { color: var(--ink-3); }
.input[aria-invalid='true'] { border-color: var(--neg); }
.textarea { resize: vertical; min-height: 76px; line-height: 1.5; }
.select { cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2378829D' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px;
}
.input--mono { font-family: var(--font-data); }

.input-group { display: flex; align-items: stretch; gap: 0; }
.input-group .input { border-radius: var(--r-md) 0 0 var(--r-md); }
.input-group .btn { border-radius: 0 var(--r-md) var(--r-md) 0; border: 1px solid var(--line-strong); border-left: 0; }

.form-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }

/* ============================ Estado vazio ============================= */

.empty {
  padding: var(--s10) var(--s6);
  text-align: center;
  color: var(--ink-2);
}
.empty__icon {
  width: 42px; height: 42px; margin: 0 auto var(--s4);
  border-radius: var(--r-lg);
  background: var(--surface-3); color: var(--ink-3);
  display: grid; place-items: center;
}
.empty__icon svg { width: 21px; height: 21px; }
.empty h3 { font-size: 14px; font-weight: 600; color: var(--ink); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto; }

/* =========================== Cards do hub ============================== */

.hub-grid { display: grid; gap: var(--s4); grid-template-columns: repeat(auto-fill, minmax(214px, 1fr)); }

.tile {
  position: relative;
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--sh-1);
  transition: transform var(--t-base), box-shadow var(--t-base), border-color var(--t-base);
}
.tile:hover { transform: translateY(-2px); box-shadow: var(--sh-3); border-color: var(--line-strong); }
.tile__banner {
  height: 78px;
  display: grid; place-items: center;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.tile__banner .mk-logo { height: 30px; width: auto; }
.tile__body { padding: var(--s4); flex: 1 1 auto; }
.tile__name { font-size: 13.5px; font-weight: 600; letter-spacing: -.01em; }
.tile__note { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.tile__foot {
  padding: var(--s3) var(--s4);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  display: flex; align-items: center; gap: var(--s2);
}
.tile__link {
  position: absolute; inset: 0;
  z-index: 1;
}
.tile__foot .btn { position: relative; z-index: 2; }

/* fundos das marcas — tons claros para o logo respirar */
.bg-mercadolivre { background: linear-gradient(160deg, #FFF7B8 0%, #FFE600 100%); }
.bg-shopee       { background: linear-gradient(160deg, #FFE7E0 0%, #FFCDBE 100%); }
.bg-amazon       { background: linear-gradient(160deg, #FFF0D6 0%, #FFDEA8 100%); }
.bg-magalu       { background: linear-gradient(160deg, #DCEEFF 0%, #B4DCFF 100%); }
.bg-shein        { background: linear-gradient(160deg, #F1F1F4 0%, #DEDEE4 100%); }
.bg-tiktokshop   { background: linear-gradient(160deg, #E6FCFB 0%, #FFE3EC 100%); }
.bg-correios     { background: linear-gradient(160deg, #FFF6CC 0%, #FFE680 100%); }
.bg-generico     { background: linear-gradient(160deg, var(--brand-tint) 0%, var(--brand-tint-2) 100%); }

/* =============================== Modal ================================= */

.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(20, 27, 52, .38);
  backdrop-filter: blur(2px);
  display: grid; place-items: center;
  padding: var(--s4);
  z-index: 100;
  animation: fade var(--t-base) both;
}
.modal {
  background: var(--surface);
  border-radius: var(--r-xl);
  box-shadow: var(--sh-4);
  width: 100%; max-width: 560px;
  max-height: calc(100vh - 48px);
  display: flex; flex-direction: column;
  animation: pop var(--t-slow) both;
}
.modal--wide { max-width: 760px; }
.modal__head {
  padding: var(--s5) var(--s6) var(--s4);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s4);
}
.modal__title { font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.modal__sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.modal__body { padding: var(--s5) var(--s6); overflow-y: auto; }
.modal__foot {
  padding: var(--s4) var(--s6);
  border-top: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-xl) var(--r-xl);
  display: flex; align-items: center; justify-content: flex-end; gap: var(--s3);
}

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop  { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* ================================ Toast ================================ */

.toast-host {
  position: fixed; bottom: var(--s6); right: var(--s6);
  display: flex; flex-direction: column; gap: var(--s2);
  z-index: 200;
}
.toast {
  display: flex; align-items: center; gap: var(--s3);
  background: var(--ink);
  color: #fff;
  padding: 10px var(--s4);
  border-radius: var(--r-md);
  box-shadow: var(--sh-4);
  font-size: 13px;
  animation: pop var(--t-base) both;
  max-width: 380px;
}
.toast svg { width: 16px; height: 16px; flex: 0 0 16px; }
.toast--pos svg { color: #6EE7B7; }
.toast--neg svg { color: #FCA5A5; }

/* =============================== Alerta ================================ */

.note {
  display: flex; gap: var(--s3);
  padding: var(--s4);
  border-radius: var(--r-md);
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid transparent;
}
.note svg { width: 16px; height: 16px; flex: 0 0 16px; margin-top: 1px; }
.note--info  { background: var(--info-tint);  color: #16357A; border-color: #C7D7FA; }
.note--warn  { background: var(--warn-tint);  color: #7C3D06; border-color: #F5D9A8; }
.note--pos   { background: var(--pos-tint);   color: #04543A; border-color: #B4E5CE; }
.note--neg   { background: var(--neg-tint);   color: #8A1A25; border-color: #F5C2C7; }
.note strong { font-weight: 600; }

/* ============================ Tela de login ============================ */

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--surface);
}
.auth__aside {
  background: linear-gradient(150deg, var(--brand-700) 0%, var(--brand) 45%, var(--violet) 100%);
  color: #fff;
  padding: var(--s12);
  display: flex; flex-direction: column; justify-content: space-between;
  position: relative; overflow: hidden;
}
.auth__aside::after {
  content: '';
  position: absolute; right: -140px; bottom: -160px;
  width: 460px; height: 460px; border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.auth__aside::before {
  content: '';
  position: absolute; right: 40px; top: -120px;
  width: 300px; height: 300px; border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.auth__aside > * { position: relative; z-index: 1; }
.auth__pitch h2 { font-size: 30px; font-weight: 700; letter-spacing: -.03em; line-height: 1.15; }
.auth__pitch p { margin-top: var(--s4); font-size: 14.5px; color: rgba(255, 255, 255, .82); max-width: 400px; line-height: 1.6; }
.auth__points { margin-top: var(--s8); display: flex; flex-direction: column; gap: var(--s3); }
.auth__points li { display: flex; align-items: center; gap: var(--s3); font-size: 13.5px; color: rgba(255, 255, 255, .92); }
.auth__points svg { width: 16px; height: 16px; flex: 0 0 16px; color: #A5F3D0; }

.auth__panel { display: grid; place-items: center; padding: var(--s6); }
.auth__form { width: 100%; max-width: 348px; }
.auth__brand { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s8); }
.auth__form h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.auth__form > p { color: var(--ink-2); font-size: 13px; margin-top: 4px; margin-bottom: var(--s6); }

/* ===================== Componentes do catálogo ========================= */

/* Miniatura do produto (ou caixa cinza quando ainda não tem foto) */
.thumb {
  flex: 0 0 40px; width: 40px; height: 40px;
  border-radius: var(--r-md);
  overflow: hidden;
  display: grid; place-items: center;
  background: var(--surface-3);
  color: var(--ink-3);
  border: 1px solid var(--line);
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb svg { width: 19px; height: 19px; }
.thumb--lg {
  flex: 0 0 68px; width: 68px; height: 68px;
  border-radius: var(--r-lg);
}
.thumb--lg svg { width: 28px; height: 28px; }

/* Filtros rápidos */
.chips { display: flex; gap: var(--s2); flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center;
  padding: 6px 12px;
  border-radius: var(--r-full);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-2);
  font-size: 12.5px; font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.chip:hover { background: var(--surface-3); color: var(--ink); text-decoration: none; }
.chip.is-on {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.chip.is-on:hover { background: var(--brand-600); color: #fff; }

/* Linha divisória dentro de cartões */
.rule { border: 0; border-top: 1px solid var(--line); margin: var(--s2) 0; width: 100%; }

/* Ícone dentro do campo de busca */
.input-icon {
  position: absolute; left: 11px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-3); pointer-events: none;
}
.input-icon svg { width: 16px; height: 16px; }

/* Campo de dinheiro com o "R$" grudado na frente */
.input-prefix { display: flex; align-items: stretch; }
.input-prefix > span {
  display: grid; place-items: center;
  padding: 0 10px;
  border: 1px solid var(--line-strong); border-right: 0;
  border-radius: var(--r-md) 0 0 var(--r-md);
  background: var(--surface-3);
  color: var(--ink-3);
  font-size: 12.5px; font-weight: 600;
  white-space: nowrap;
}
.input-prefix .input { border-radius: 0 var(--r-md) var(--r-md) 0; }
.input-prefix:focus-within > span { border-color: var(--brand); color: var(--brand-700); }

/* Seletor segmentado (tipo de movimento) */
.segmented {
  display: flex; flex-wrap: wrap; gap: 3px;
  padding: 3px;
  background: var(--surface-3);
  border-radius: var(--r-md);
}
.segmented__opt { flex: 1 1 auto; }
.segmented__opt input {
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
}
.segmented__opt span {
  display: block;
  padding: 7px 10px;
  border-radius: 7px;
  text-align: center;
  font-size: 12.5px; font-weight: 500;
  color: var(--ink-2);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.segmented__opt span:hover { color: var(--ink); }
.segmented__opt input:checked + span {
  background: var(--surface);
  color: var(--brand-700);
  font-weight: 600;
  box-shadow: var(--sh-2);
}
.segmented__opt input:focus-visible + span {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

/* Indicador clicável no painel */
.stat--link { display: block; color: inherit; transition: border-color var(--t-fast), box-shadow var(--t-fast); }
.stat--link:hover { text-decoration: none; border-color: var(--line-strong); box-shadow: var(--sh-2); }

/* ===================== Componentes do financeiro ======================= */

/* Barra de proporção (para onde foi o dinheiro) */
.bar {
  height: 7px;
  border-radius: var(--r-full);
  background: var(--surface-3);
  overflow: hidden;
}
.bar__fill {
  display: block; height: 100%;
  border-radius: var(--r-full);
  background: var(--ink-3);
  transition: width var(--t-slow);
}
.bar__fill--brand { background: var(--brand); }
.bar__fill--pos   { background: var(--pos); }
.bar__fill--neg   { background: var(--neg); }
.bar__fill--warn  { background: var(--warn); }

/* Miniatura do comprovante */
.receipt-preview {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface-3);
  max-height: 260px;
}
.receipt-preview img { width: 100%; height: auto; object-fit: contain; max-height: 260px; }
.receipt-preview:hover { border-color: var(--brand); }

/* Uma linha do rateio */
.split-row {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) auto;
  gap: var(--s3);
  align-items: start;
  padding: var(--s3);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}
.split-row--locked { background: var(--brand-tint); border-color: var(--brand-tint-2); }
.split-row__estoque {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
  gap: var(--s3);
  padding-top: var(--s3);
  border-top: 1px dashed var(--line-strong);
}
.split-row__rm { align-self: center; }

.split-total {
  border-top: 1px solid var(--line);
  padding-top: var(--s4);
}

/* Aviso de fechamento do rateio */
.split-check {
  display: flex; align-items: center; gap: var(--s2);
  padding: 9px var(--s4);
  border-radius: var(--r-md);
  font-size: 13px; font-weight: 500;
}
.split-check svg { width: 16px; height: 16px; flex: 0 0 16px; }
.split-check--ok  { background: var(--pos-tint); color: var(--pos); }
.split-check--off { background: var(--warn-tint); color: var(--warn); }

/* Caixa de marcação com explicação ao lado */
.check {
  display: flex; align-items: flex-start; gap: var(--s3);
  cursor: pointer;
}
.check input[type='checkbox'] {
  flex: 0 0 18px; width: 18px; height: 18px;
  margin: 2px 0 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.check:hover .t-strong { color: var(--brand-700); }

/* Linha de acerto entre os sócios */
.acerto-linha {
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
}

/* Resultado da leitura do comprovante */
.ia-result {
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  padding: var(--s4);
  background: var(--surface-2);
}
.ia-result dl { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s4); margin: 0; }
.ia-result dt { font-size: 11.5px; font-weight: 600; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.ia-result dd { margin: 0; font-size: 13px; }

@media (max-width: 640px) {
  .split-row { grid-template-columns: minmax(0, 1fr) auto; }
  .split-row__estoque { grid-template-columns: minmax(0, 1fr); }
}

/* ========================= Barra inferior (celular) ==================== */

.tabbar { display: none; }
.topbar__mark { display: none; }

.hide-sm, .hide-xs { display: inline-flex; }

/* ============================ Responsivo =============================== */

@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Faixa intermediária: a barra lateral ainda ocupa espaço e a tabela não virou
   cartão ainda. Escondemos as colunas secundárias em vez de rolar de lado. */
@media (min-width: 701px) and (max-width: 1100px) {
  .hide-md { display: none !important; }
}

@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .auth { grid-template-columns: 1fr; }
  .auth__aside { display: none; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Com a lateral ocupando 220px, duas colunas aqui deixariam os formulários
     estreitos demais — melhor empilhar antes disso. */
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 860px) {
  /* --- A lateral vira gaveta, aberta pelo botao "Mais" --- */
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: min(300px, 86vw); flex-basis: auto;
    transform: translateX(-100%);
    transition: transform var(--t-base);
    box-shadow: var(--sh-4);
    height: 100dvh;
    padding-top: var(--safe-t);
    padding-left: var(--safe-l);
  }
  .sidebar.is-open { transform: none; }
  .scrim {
    position: fixed; inset: 0; background: rgba(20, 27, 52, .4);
    z-index: 35; animation: fade var(--t-fast) both;
  }

  /* --- Barra inferior fixa --- */
  .tabbar {
    display: flex;
    position: fixed; left: 0; right: 0; bottom: 0;
    z-index: 45;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(14px);
    border-top: 1px solid var(--line);
    padding-bottom: var(--safe-b);
    padding-left: var(--safe-l);
    padding-right: var(--safe-r);
  }
  .tabbar__item {
    flex: 1 1 0;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 3px;
    min-height: var(--tabbar-h);
    padding: 8px 4px;
    border: 0; background: none;
    font-size: 10.5px; font-weight: 600; letter-spacing: .01em;
    color: var(--ink-3);
    cursor: pointer;
    transition: color var(--t-fast);
  }
  .tabbar__item:hover { text-decoration: none; }
  .tabbar__item svg { width: 21px; height: 21px; flex: 0 0 21px; stroke-width: 1.9; }
  .tabbar__item.is-active { color: var(--brand); }
  .tabbar__item:focus-visible { outline-offset: -3px; }

  /* --- Cabecalho e conteudo --- */
  .topbar {
    padding: 0 var(--s4);
    padding-top: var(--safe-t);
    height: calc(var(--topbar-h) + var(--safe-t));
    flex-basis: calc(var(--topbar-h) + var(--safe-t));
    gap: var(--s3);
  }
  .topbar__mark {
    display: grid; place-items: center;
    width: 30px; height: 30px; flex: 0 0 30px;
    border-radius: 8px; overflow: hidden;
    background: linear-gradient(135deg, var(--brand) 0%, var(--violet) 100%);
    color: #fff; font-weight: 700; font-size: 13px;
  }
  .topbar__mark img { width: 100%; height: 100%; object-fit: cover; }
  .topbar__mark--img { background: none; }
  .topbar__title { font-size: 16px; }

  .content {
    padding: var(--s4);
    padding-left: max(var(--s4), var(--safe-l));
    padding-right: max(var(--s4), var(--safe-r));
    /* espaco para a barra inferior nao cobrir o fim da pagina */
    padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s6));
  }

  .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  /* Indicadores continuam em dupla: sao curtos e cabem lado a lado */
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .hub-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .page-head h1 { font-size: 20px; }
  .section { margin-top: var(--s6); }

  .stat { padding: var(--s4); }
  .stat__label { font-size: 10px; letter-spacing: .05em; }
  .stat__value { font-size: 21px; }
  .stat__foot { margin-top: var(--s2); }

  .hide-sm { display: none !important; }

  /* iOS aumenta o zoom sozinho quando o campo tem menos de 16px */
  .input, .select, .textarea { font-size: 16px; padding: 11px 12px; }

  .toast-host { bottom: calc(var(--tabbar-h) + var(--safe-b) + var(--s3)); }
}

/* --------- Modal vira folha inferior no celular --------- */
@media (max-width: 640px) {
  .modal-backdrop { padding: 0; align-items: flex-end; }
  .modal {
    max-width: none;
    max-height: 92dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    animation: sheet var(--t-slow) both;
  }
  .modal__head, .modal__body, .modal__foot { padding-left: var(--s5); padding-right: var(--s5); }
  .modal__foot {
    border-radius: 0;
    padding-bottom: calc(var(--s4) + var(--safe-b));
    flex-wrap: wrap;
  }
  .modal__foot .btn { flex: 1 1 auto; }
  /* alca visual da folha */
  .modal__head::before {
    content: '';
    position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 36px; height: 4px; border-radius: 2px; background: var(--line-strong);
  }
  .modal__head { position: relative; padding-top: var(--s6); }
}

@keyframes sheet { from { transform: translateY(100%); } to { transform: none; } }

/* --------- Tabela vira lista de cartoes no celular --------- */
@media (max-width: 700px) {
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr {
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    padding: var(--s2) var(--s2) var(--s3);
    margin-bottom: var(--s3);
    background: var(--surface);
  }
  table.data tr:last-child { margin-bottom: 0; }
  table.data td {
    border: 0;
    padding: 6px var(--s3);
    display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
    text-align: left;
  }
  table.data td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    color: var(--ink-3);
  }
  table.data td:not([data-label])::before { display: none; }
  table.data td[data-block] { display: block; }
  table.data td[data-block]::before { display: none; }
  table.data td.col-num { text-align: right; }
  table.data tbody tr:hover { background: var(--surface); }
}

@media (max-width: 420px) {
  .toast-host { left: var(--s4); right: var(--s4); }
  .toast { max-width: none; }
  .hide-xs { display: none !important; }
  .topbar__actions .btn { padding: 8px 10px; }
  .hub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile__banner { height: 66px; }
  .tile__banner .mk-logo { height: 24px; }
}

/* Area de toque minima em controles compactos */
@media (pointer: coarse) {
  .btn, .nav__link { min-height: 44px; }
  .btn--sm { min-height: 38px; }
  .btn--icon { min-width: 44px; }
}

/* --------- Rodando como app instalado na tela de inicio --------- */
@media (display-mode: standalone) {
  /* Sem barra de endereco, a pagina inteira e nossa: nada de selecao acidental
     de texto ao arrastar, e a rolagem fica so onde deve. */
  body { user-select: none; }
  .input, .textarea, .num, [data-secret-slot], p, td { user-select: text; }
}

/* ============================ Simulador (Etapa 5) ========================= */

/* Formulario a esquerda, resultado grudado a direita: mudou um numero,
   o resultado muda no campo de visao, sem rolar a pagina. */
.sim-grid {
  display: grid;
  gap: var(--s6);
  grid-template-columns: minmax(0, 1fr) 372px;
  align-items: start;
}
.sim-out { position: sticky; top: var(--s4); }

.sim-hero { text-align: center; padding: var(--s5) var(--s4) var(--s4); }
.sim-hero__label { font-size: 12px; color: var(--ink-3); letter-spacing: .02em; }
.sim-hero__value {
  font-family: 'Fira Code', monospace;
  font-size: 32px; font-weight: 600; line-height: 1.1;
  letter-spacing: -.02em; margin: var(--s1) 0 var(--s2);
}
.sim-hero__foot { display: flex; justify-content: center; gap: var(--s2); flex-wrap: wrap; }

/* Uma linha da cascata: de onde saiu o dinheiro do preco */
.wf { display: grid; gap: 10px; }
.wf__row { display: grid; grid-template-columns: 1fr auto; gap: 2px var(--s3); align-items: baseline; }
.wf__name { font-size: 12px; color: var(--ink-2); }
.wf__val { font-family: 'Fira Code', monospace; font-size: 12.5px; font-weight: 500; }
.wf__bar { grid-column: 1 / -1; height: 4px; border-radius: var(--r-full); background: var(--surface-3); overflow: hidden; }
.wf__bar > i { display: block; height: 100%; border-radius: var(--r-full); background: var(--ink-3); transition: width .18s ease; }
.wf__bar > i.is-neg { background: var(--neg); }
.wf__bar > i.is-pos { background: var(--pos); }
.wf__bar > i.is-brand { background: var(--brand); }
.wf__row--total { border-top: 1px dashed var(--line-strong); padding-top: var(--s3); margin-top: var(--s1); }
.wf__row--total .wf__name { color: var(--ink); font-weight: 600; font-size: 13px; }
.wf__row--total .wf__val { font-size: 14px; }

/* Par rotulo/valor usado nos blocos de preco de referencia e do lote */
.kv { display: grid; grid-template-columns: 1fr auto; gap: var(--s2) var(--s3); align-items: baseline; }
.kv dt { font-size: 12px; color: var(--ink-2); }
.kv dd { font-family: 'Fira Code', monospace; font-size: 13px; font-weight: 500; text-align: right; }

/* Botao discreto que joga um valor sugerido para dentro do campo */
.hint-fill {
  background: none; border: 0; padding: 0; cursor: pointer;
  font: inherit; font-size: 11px; color: var(--brand); text-decoration: underline;
  text-underline-offset: 2px;
}
.hint-fill:hover { color: var(--brand-700); }

/* Comparacao entre simulacoes */
.sim-rank { display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: var(--r-full);
  background: var(--surface-3); color: var(--ink-2);
  font-size: 11px; font-weight: 700; }
.sim-rank--top { background: var(--brand); color: #fff; }

@media (max-width: 1180px) {
  .sim-grid { grid-template-columns: minmax(0, 1fr); }
  .sim-out { position: static; }
}

/* No celular o resultado fica no fim da pagina — longe demais de quem esta
   digitando o preco. Esta faixa gruda no topo e responde a cada tecla. */
.sim-bar { display: none; }
@media (max-width: 1180px) {
  .sim-bar {
    display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap;
    position: sticky; top: var(--topbar-h); z-index: 20;
    margin-bottom: var(--s4);
    padding: var(--s3) var(--s4);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--sh-1);
  }
  .sim-bar__label { font-size: 12px; color: var(--ink-3); }
  .sim-bar__value { font-family: 'Fira Code', monospace; font-size: 18px; font-weight: 600; }
}
