/* ------------------------------------------------------------------
   Componentes: cartoes, campos, botoes, tabelas, graficos e feedback.
   ------------------------------------------------------------------ */

/* ----------------------------------------------------------------- Card */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) 0;
}

.card__title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.card__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.card__body { padding: var(--space-4); display: flex; flex-direction: column; gap: var(--space-4); }

/* ---------------------------------------------------------------- Campos */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-3);
}

.form-inline { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; }

.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--wide { grid-column: 1 / -1; }

.field__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field__hint {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--surface-hover);
  color: var(--text-faint);
  font-size: 10px;
  cursor: help;
}

.field__help { color: var(--text-faint); font-size: 11px; line-height: 1.4; }

.input {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 14px;
  transition: border-color .15s, background .15s;
}
.input:hover { border-color: var(--border-strong); }
.input:focus { outline: none; border-color: var(--accent); background: var(--bg-elevated); }
.input::placeholder { color: var(--text-faint); }
textarea.input { resize: vertical; min-height: 68px; }

.select { cursor: pointer; appearance: none; padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-right: 46px; }
.input-group.is-bare .input { padding-right: 11px; }

.input--mini { max-width: 110px; padding: 5px 8px; font-size: 12.5px; }

.input__suffix {
  position: absolute;
  right: 10px;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 600;
  pointer-events: none;
}

/* Toggle */

.toggle { display: inline-flex; align-items: center; gap: var(--space-2); cursor: pointer; user-select: none; }
.toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.toggle__track {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 999px;
  background: var(--border);
  transition: background .18s;
}

.toggle__thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--bg-elevated);
  box-shadow: var(--shadow-sm);
  transition: transform .18s;
}

.toggle input:checked + .toggle__track { background: var(--accent); }
.toggle input:checked + .toggle__track .toggle__thumb { transform: translateX(17px); }
.toggle__label { font-size: 13px; color: var(--text-muted); }

/* Segmented */

.segmented {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  gap: 3px;
}

.segmented__item {
  flex: 1;
  padding: 6px 12px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.segmented__item:hover { color: var(--text); }
.segmented__item.is-active { background: var(--accent); color: var(--accent-text); }

/* -------------------------------------------------------------- Botoes */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }

.btn--primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn--primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }

.btn--ghost { background: transparent; }
.btn--ghost:hover { background: var(--surface-hover); }

.btn--danger { background: var(--negative); border-color: var(--negative); color: #fff; }
.btn--ghost-danger { background: transparent; border-color: transparent; color: var(--negative); }
.btn--ghost-danger:hover { background: var(--negative-soft); }

/* Fonte de simbolos explicita: sem ela, alguns glifos de icone caem em tofu. */
.btn--icon {
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1;
  font-family: "Segoe UI Symbol", "Segoe UI Emoji", var(--font);
}
.btn--icon-danger:hover { background: var(--negative-soft); border-color: var(--negative); color: var(--negative); }

.actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.actions .btn { flex: 1 1 auto; }

.data-actions { display: flex; flex-direction: column; gap: var(--space-2); }

/* --------------------------------------------------------- Preco e stats */

.price-card {
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: linear-gradient(145deg, var(--accent), var(--accent-strong));
  color: var(--accent-text);
  box-shadow: var(--shadow-md);
}

.price-card__label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .75; }
.price-card__value { font-size: 42px; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; margin: 6px 0 2px; }
.price-card__sub { font-size: 13px; font-weight: 600; opacity: .85; }

.price-card__foot {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  margin-top: var(--space-4);
  padding-top: var(--space-3);
  border-top: 1px solid rgba(0, 0, 0, .18);
  font-size: 11px;
  font-weight: 600;
  opacity: .8;
}

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }

.stat {
  padding: var(--space-4);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius);
}

.stat--positive { border-left-color: var(--positive); }
.stat--negative { border-left-color: var(--negative); }
.stat--accent { border-left-color: var(--accent); }

.stat__label { font-size: 11px; font-weight: 650; letter-spacing: .05em; text-transform: uppercase; color: var(--text-faint); }
.stat__value { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.stat--positive .stat__value { color: var(--positive); }
.stat--negative .stat__value { color: var(--negative); }
.stat__sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

/* ---------------------------------------------------------------- Linhas */

.rows { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }

.row--strong { font-weight: 700; border-top: 1px solid var(--border-strong); margin-top: 4px; }
.row--strong .row__value { font-size: 16px; }

.row__label { color: var(--text-muted); display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.row__hint { color: var(--text-faint); font-size: 11px; }
.row__value { font-variant-numeric: tabular-nums; font-weight: 600; text-align: right; }

/* ---------------------------------------------------- Grafico de custos */

.cost-chart { display: flex; flex-direction: column; gap: var(--space-3); }

.bar {
  display: flex;
  gap: 2px;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--bg-sunken);
}
.bar__slice { height: 100%; min-width: 2px; transition: flex .25s ease; }
.bar__slice:hover { filter: brightness(1.15); }

.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }

.legend__item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto auto 44px;
  align-items: baseline;
  gap: var(--space-2);
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.legend__item:last-child { border-bottom: 0; }

.legend__dot { width: 10px; height: 10px; border-radius: 3px; }
.legend__label { color: var(--text); }
.legend__hint { color: var(--text-faint); font-size: 11px; }
.legend__value { font-variant-numeric: tabular-nums; font-weight: 600; }
.legend__share { color: var(--text-muted); font-variant-numeric: tabular-nums; text-align: right; font-size: 12px; }

/* -------------------------------------------------------------- Tabelas */

.table-wrap { overflow-x: auto; margin: 0 calc(var(--space-4) * -1); padding: 0 var(--space-4); }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
  padding: 0 var(--space-3) var(--space-2);
  text-align: left;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--text-faint);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 10px var(--space-3);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-variant-numeric: tabular-nums;
}

/* Precisa vencer a especificidade de `.table th` / `.table td`. */
.table th.is-right,
.table td.is-right { text-align: right; }

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-hover); }
.table tr.is-highlight { background: var(--accent-soft); }
.table tr.is-highlight td { font-weight: 650; }

.cell-title { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; font-weight: 600; font-variant-numeric: normal; }
.cell-sub { color: var(--text-faint); font-size: 11px; font-weight: 400; }

.table-actions { display: flex; gap: 4px; justify-content: flex-end; }

.status-select {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-size: 11px;
  font-weight: 650;
  cursor: pointer;
}
.status-select.is-positive { border-color: var(--positive); color: var(--positive); }
.status-select.is-negative { border-color: var(--negative); color: var(--negative); }
.status-select.is-accent { border-color: var(--accent); color: var(--accent); }

/* --------------------------------------------------------------- Extras */

.extras { display: flex; flex-direction: column; gap: var(--space-3); }
.extras__list { display: flex; flex-direction: column; gap: var(--space-2); }

.extras__item {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) 130px 200px auto;
  gap: var(--space-2);
  align-items: end;
  padding: var(--space-3);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

@media (max-width: 720px) {
  .extras__item { grid-template-columns: minmax(0, 1fr) auto; }
}

/* ------------------------------------------------------------ Diversos */

.badge {
  display: inline-flex;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-hover);
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.badge--accent { background: var(--accent-soft); color: var(--accent); }
.badge--positive { background: var(--positive-soft); color: var(--positive); }
.badge--negative { background: var(--negative-soft); color: var(--negative); }

.empty, .empty-state {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
}
.empty-state { display: flex; flex-direction: column; align-items: center; gap: var(--space-4); }

.alerts { display: flex; flex-direction: column; gap: 6px; }

.alert {
  padding: 10px 13px;
  border-radius: var(--radius);
  border-left: 3px solid var(--info);
  background: var(--bg-sunken);
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
}
.alert--ok { border-left-color: var(--good); }
.alert--warn { border-left-color: var(--warn); }
.alert--bad { border-left-color: var(--crit); }

/* ------------------------------------------------- Veredito e regua ---- */

.veredito {
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  border-left: 4px solid var(--info);
  background: var(--bg-sunken);
}
.veredito--ok { border-left-color: var(--good); }
.veredito--warn { border-left-color: var(--warn); }
.veredito--bad { border-left-color: var(--crit); }

.veredito__titulo { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.veredito--ok .veredito__titulo { color: var(--good); }
.veredito--warn .veredito__titulo { color: var(--warn); }
.veredito--bad .veredito__titulo { color: var(--crit); }
.veredito__texto { color: var(--text-muted); font-size: 13px; }

.regua { position: relative; height: 34px; margin: 22px 4px 48px; }
.regua__trilho {
  position: absolute; top: 14px; left: 0; right: 0;
  height: 6px; border-radius: 3px; background: var(--border-strong);
}
.regua__zona {
  position: absolute; top: 14px; height: 6px;
  border-radius: 3px; background: var(--s3);
}
.regua__mk {
  position: absolute; top: 6px; width: 2px; height: 22px;
  background: var(--text-faint);
}
.regua__mk.is-eu { width: 3px; height: 30px; top: 2px; background: var(--accent); }
.regua__lb {
  position: absolute; top: 32px; font-size: 10.5px; color: var(--text-faint);
  transform: translateX(-50%); white-space: nowrap;
}
.regua__lb.is-eu { top: 48px; color: var(--accent); font-weight: 700; }

/* ------------------------------------------------------ Complementos ---- */

.legend-title {
  font-size: 11px; font-weight: 700; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-faint);
  margin-bottom: 2px;
}

.table td.is-empty {
  text-align: center; color: var(--text-faint);
  padding: var(--space-5) 0;
}

.chk { display: flex; align-items: center; gap: 8px; }
.chk input[type="checkbox"], .chk input[type="radio"] {
  width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer;
}

.thumb {
  width: 46px; height: 46px; border-radius: var(--radius-sm);
  object-fit: cover; border: 1px solid var(--border); background: var(--bg-sunken);
}

.hint-inline { font-size: 11px; color: var(--text-faint); }

/* ------------------------------------------------------------ Feedback */

.toast-host {
  position: fixed;
  right: var(--space-4);
  bottom: var(--space-4);
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 380px;
  padding: 11px 15px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .2s, transform .2s;
}
.toast.is-visible { opacity: 1; transform: translateY(0); }

.toast__icon { font-weight: 700; }
.toast--success .toast__icon { color: var(--positive); }
.toast--error .toast__icon { color: var(--negative); }
.toast--warning .toast__icon { color: var(--warning); }
.toast--info .toast__icon { color: var(--info); }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: var(--space-4);
  background: rgba(4, 7, 11, .6);
  backdrop-filter: blur(3px);
  opacity: 0;
  transition: opacity .18s;
  overflow-y: auto;
}
.overlay.is-visible { opacity: 1; }

.modal {
  width: min(460px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  padding: var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  transform: translateY(8px);
  transition: transform .18s;
}
.overlay.is-visible .modal { transform: translateY(0); }
.modal--wide { width: min(720px, 100%); }

.modal__title { font-size: 17px; margin-bottom: var(--space-2); }
.modal__text { color: var(--text-muted); font-size: 13px; margin-bottom: var(--space-4); }
.modal__form { display: flex; flex-direction: column; gap: var(--space-4); }
.modal__actions { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-4); }

/* ------------------------------------------------------------ Impressao */

@media print {
  .header, .actions, .toast-host, .overlay { display: none !important; }
  body { background: #fff; color: #000; }
  .card { border-color: #ccc; box-shadow: none; }
}

/* ------------------------------------------------------ Layout de pagina */

.page-head { margin-bottom: var(--space-2); }
.page-title { font-size: 22px; letter-spacing: -.02em; }
.page-sub { color: var(--text-muted); font-size: 13px; margin: 2px 0 0; }

.divider {
  border: 0;
  border-top: 1px solid var(--border);
  margin: var(--space-3) 0;
}

.canais-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

@media (max-width: 900px) {
  .canais-grid { grid-template-columns: minmax(0, 1fr); }
}

.canais-lista .table td { padding: 6px var(--space-3); }
.canais-lista .table .chk { justify-content: center; }

.legend__dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }

a { color: var(--accent); }

/* --------------------------------------------------------------- Produtos */

.sku {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .02em;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--accent);
}

.badge--warn { background: var(--warning-soft); color: var(--warn); }
.badge--neutral { background: var(--surface-hover); color: var(--text-muted); }

.stat--warn { border-left-color: var(--warn); }
.stat--warn .stat__value { color: var(--warn); }

/* ----------------------------------------------------------- Integrações */

.cap-list { display: flex; flex-wrap: wrap; gap: 6px; }

.instrucoes {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-3);
  background: var(--bg-sunken);
}
.instrucoes summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  color: var(--text-muted);
}
.instrucoes summary:hover { color: var(--text); }
.instrucoes__lista { margin: var(--space-3) 0; padding-left: 20px; font-size: 13px; line-height: 1.7; }
.instrucoes__lista li { margin-bottom: 4px; }
.instrucoes code { word-break: break-all; }
