/* ---------- Botões ---------- */
.icon-btn {
  position: relative;
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: 0; border-radius: 999px;
  background: transparent;
  cursor: pointer;
}
.icon-btn:hover { background: var(--brand-soft); color: var(--brand-text); }

.badge-dot {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; padding: 0 4px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--brand); color: var(--on-brand);
  font-size: 9px; font-weight: 700;
}

.avatar {
  width: 36px; height: 36px; margin-left: 4px;
  display: grid; place-items: center;
  border-radius: 999px;
  background: var(--brand); color: var(--on-brand);
  font-family: var(--font-display);
  font-size: 12px; font-weight: 600;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px;
  border: 1px solid transparent; border-radius: var(--radius-md);
  background: var(--surface-2);
  font-weight: 600; font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--brand); color: var(--on-brand); }
.btn-primary:hover { background: var(--brand-strong); filter: none; }
.btn-ghost { background: transparent; border-color: var(--border); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.95); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); color: var(--brand-text); filter: none; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: var(--radius-sm); }
.btn-lg { height: 48px; font-size: 15px; }
.btn-primary kbd { background: rgba(0, 0, 0, .1); }

/* ---------- Cards ---------- */
.card {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 9px; }
/* "Faixa de corrida" laranja antes de cada título */
.card-title::before {
  content: "";
  flex: none;
  width: 4px; height: 16px;
  border-radius: 2px;
  background: var(--brand);
}

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Formulários ---------- */
.input {
  height: 38px; width: 100%;
  padding: 0 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: var(--focus); }
.input.is-invalid { border-color: var(--red); }
.input-sm { height: 32px; border-radius: var(--radius-sm); }

.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.input-icon .input { padding-left: 38px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-2); font-weight: 500; }
.field-error { color: var(--red); font-size: 12px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters .input-icon { flex: 1 1 260px; }
.filters select.input { width: auto; min-width: 170px; }
.filters .spacer { flex: 1; }

/* ---------- Chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  height: 32px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface);
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.chip:hover { background: var(--surface-2); }
.chip.active { background: var(--brand); border-color: var(--brand); color: var(--on-brand); font-weight: 600; }

/* ---------- Tabelas ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  padding: 10px 12px;
  text-align: left; font-weight: 500; color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table tbody tr:hover { background: color-mix(in srgb, var(--brand) 5%, var(--surface)); }
.table th.num, .table td.num { text-align: right; }
.table td.wrap { white-space: normal; min-width: 150px; }

.cell-product { display: flex; align-items: center; gap: 10px; }

.thumb {
  flex: none;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--c) 18%, transparent);
  color: var(--c);
  font-size: 11px; font-weight: 700;
}
.thumb-lg { width: 44px; height: 44px; font-size: 14px; border-radius: 10px; }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; font-size: 13px; color: var(--text-2); }
.pagination .pages { display: flex; gap: 6px; }

/* ---------- Status ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px; font-weight: 600;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge--success { color: var(--green); background: color-mix(in srgb, var(--green) 14%, transparent); }
.badge--warning { color: var(--warning); background: color-mix(in srgb, var(--warning) 15%, transparent); }
.badge--danger  { color: var(--red); background: color-mix(in srgb, var(--red) 13%, transparent); }
.badge--info    { color: var(--info); background: color-mix(in srgb, var(--info) 13%, transparent); }

/* ---------- Estados ---------- */
.skeleton {
  border-radius: var(--radius-lg);
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.state {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  padding: 40px 16px;
  text-align: center; color: var(--text-2);
}
.state svg { color: var(--text-3); }

/* ---------- Modal e formulários ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(11, 9, 10, .5);
  animation: toast-in .15s ease;
}
.modal {
  width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow-y: auto;
  padding: 22px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .3);
}
.modal--wide { max-width: 820px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.form-section {
  font-family: var(--font-display); font-size: 13px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .06em; color: var(--brand-text);
  margin: 4px 0 -4px;
}
.form-grid.form-grid-3 { grid-template-columns: repeat(3, 1fr); }
.form-grid-3 .span-3 { grid-column: span 3; }
.margin-box {
  height: 38px; display: flex; align-items: center; padding: 0 12px;
  border-radius: var(--radius-md); background: var(--surface-2);
  font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums;
}
.margin-box.is-pos { color: var(--green); }
.margin-box.is-neg { color: var(--red); }
.mono, .mono-cell { font-family: Consolas, "Cascadia Mono", monospace; letter-spacing: .02em; }
.mono-cell { font-size: 12px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span {
  display: flex; align-items: center; justify-content: center; height: 40px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-weight: 600; font-size: 13px;
}
.segmented input:checked + span { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand); }
.segmented input:focus-visible + span { box-shadow: var(--focus); }
.move-head { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--radius-md); background: var(--surface-2); }
.move-head > div:nth-child(2) { flex: 1; min-width: 0; }
.move-stock { text-align: right; }
.move-stock span { display: block; font-size: 11px; color: var(--text-2); }
.move-stock strong { font-family: var(--font-display); font-size: 24px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-grid .span-2 { grid-column: span 2; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }
.check {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-md);
  cursor: pointer;
}
.check input { width: 18px; height: 18px; margin: 1px 0 0; accent-color: var(--brand); flex: none; }
.check strong { display: block; font-size: 13px; }
.check small { display: block; font-size: 12px; color: var(--text-2); }
.inline-field { display: flex; gap: 8px; }
.inline-field .input { flex: 1; min-width: 0; }
.inline-field .btn { flex: none; width: 40px; padding: 0; }
@media (max-width: 720px) {
  .form-grid.form-grid-3 { grid-template-columns: 1fr 1fr; }
  .form-grid-3 .span-3 { grid-column: span 2; }
}
@media (max-width: 520px) {
  .form-grid, .form-grid.form-grid-3 { grid-template-columns: 1fr; }
  .form-grid .span-2, .form-grid-3 .span-2, .form-grid-3 .span-3 { grid-column: auto; }
}

/* ---------- POP (procedimento) ---------- */
.pop-block { border: 1px solid var(--border); border-left: 4px solid var(--brand); border-radius: var(--radius-md); padding: 10px 12px; background: var(--surface); }
.pop-head { display: flex; align-items: center; gap: 10px; }
.pop-head > svg { color: var(--brand); flex: none; }
.pop-title { flex: 1; min-width: 0; }
.pop-title small { display: block; font-size: 12px; color: var(--text-2); }
.pop-equip { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); }
.pop-equip > span { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--brand-text); }
.pop-equip ul { margin: 4px 0 0; padding-left: 18px; font-size: 12.5px; display: grid; gap: 3px; }
.tag.tag-pop { background: var(--brand-soft); border-color: var(--brand-soft-2); color: var(--brand-text); }

/* ---------- Pré-visualização de etiqueta ---------- */
.label-preview {
  display: flex; justify-content: center; align-items: center;
  padding: 16px; min-height: 120px; overflow: auto;
  background: repeating-conic-gradient(#ececec 0 25%, #f7f7f7 0 50%) 0 0 / 16px 16px;
  border-radius: var(--radius-md); border: 1px solid var(--border);
}
.label-preview .lbl { box-shadow: 0 2px 10px rgba(0, 0, 0, .18); flex: none; }

/* ---------- Toasts ---------- */
.toasts {
  position: fixed; z-index: 50; right: 20px; bottom: 20px;
  display: flex; flex-direction: column; gap: 10px;
  max-width: min(380px, calc(100vw - 40px));
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px;
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-md);
  border-left: 4px solid var(--green);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
  animation: toast-in .2s ease;
}
.toast--warning { border-left-color: var(--warning); }
.toast--danger { border-left-color: var(--red); }
.toast--info { border-left-color: var(--brand); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ---------- Gráficos ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; overflow: visible; }
.chart-tip {
  position: absolute; z-index: 2;
  transform: translate(-50%, -100%);
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--text); color: var(--surface);
  font-size: 12px; font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}
.chart-tip small { display: block; font-weight: 500; opacity: .75; }

/* Gráfico de barras empilhadas */
.chart-tip .tip-row { display: flex; align-items: center; gap: 6px; font-weight: 600; white-space: nowrap; }
.chart-tip .tip-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 13px; pointer-events: none; }
.tech-totals { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.tech-totals span { display: inline-flex; align-items: center; gap: 6px; }
.tech-totals i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.tech-totals strong { color: var(--text); }

/* Perfil técnico: sem botões de alteração (o banco também bloqueia) */
.only-atendente { display: none; }
.role-atendente .only-atendente { display: inline; }
.role-atendente [data-admin-only] { display: none !important; }
.role-atendente:not(.can-stock) [data-stock-only] { display: none !important; }

.thumb-img { object-fit: contain; padding: 2px; background: #fff; border: 1px solid var(--border); }
