:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-soft: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f8fbff;
  --surface-3: #edf4fb;
  --border: #d9e3ee;
  --border-soft: #c6d4e3;
  --text: #102033;
  --text-soft: #40566f;
  --muted: #6b7f96;
  --muted-2: #8a9aae;
  --accent: #12846f;
  --accent-2: #0f9f7f;
  --accent-dark: #0b6f5d;
  --accent-soft: rgba(18, 132, 111, 0.10);
  --accent-border: rgba(18, 132, 111, 0.28);
  --blue: #315fbd;
  --blue-soft: rgba(49, 95, 189, 0.09);
  --danger: #c7364d;
  --danger-soft: rgba(199, 54, 77, 0.09);
  --danger-border: rgba(199, 54, 77, 0.25);
  --warn: #9a6500;
  --warn-soft: rgba(217, 151, 35, 0.12);
  --warn-border: rgba(217, 151, 35, 0.30);
  --warn-bg: var(--warn-soft);
  --warn-text: #7a4f00;
  --green: #12846f;
  --shadow: 0 18px 45px rgba(39, 63, 89, 0.12);
  --shadow-sm: 0 8px 22px rgba(39, 63, 89, 0.08);
  --radius: 8px;
  --radius-sm: 6px;
  --r: var(--radius);
  --r-sm: var(--radius-sm);
}

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

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  background: linear-gradient(180deg, #eef5f9 0%, #f7f9fc 280px, #f5f7fb 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 15px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 750;
  transition: background 0.14s ease, border-color 0.14s ease, box-shadow 0.14s ease, transform 0.10s ease, opacity 0.14s ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  box-shadow: none;
}

button.ghost {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-soft);
}

button.ghost:hover {
  background: var(--surface-3);
  border-color: var(--border-soft);
  color: var(--text);
  box-shadow: none;
}

button.danger,
button.ghost.danger {
  color: var(--danger);
  border-color: var(--danger-border);
  background: var(--danger-soft);
}

button.btn-warning,
button.ghost.btn-warning {
  color: var(--warn);
  border-color: var(--warn-border);
  background: var(--warn-soft);
}

input,
textarea,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
}

textarea {
  min-height: 102px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
  background: #fff;
}

input::placeholder,
textarea::placeholder {
  color: var(--muted-2);
}

input[type="checkbox"] {
  width: 16px;
  min-width: 16px;
  height: 16px;
  min-height: 16px;
  padding: 0;
  accent-color: var(--accent);
}

select option {
  background: #fff;
  color: var(--text);
}

label {
  display: grid;
  gap: 7px;
  color: var(--text-soft);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.12;
}

h2 {
  font-size: 18px;
  line-height: 1.2;
}

h3 {
  font-size: 14px;
  line-height: 1.25;
}

p,
.muted {
  color: var(--muted);
}

code,
pre {
  font-family: "Cascadia Code", "SF Mono", Consolas, monospace;
}

pre {
  max-width: 100%;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #f3f7fb;
  color: #29425f;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: min(100% - 32px, 1180px);
  margin: 0 auto;
  padding: 22px 0 34px;
}

.embed-shell {
  width: min(100% - 20px, 1040px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 78px;
  margin-bottom: 18px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow-sm);
}

.topbar-brand {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 13px;
}

.topbar-logo {
  display: grid;
  width: 42px;
  height: 42px;
  min-width: 42px;
  place-items: center;
  border: 1px solid var(--accent-border);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 21px;
  font-weight: 850;
}

.topbar p {
  margin-top: 4px;
  font-size: 12px;
}

.account-banner,
.error-box {
  margin-bottom: 16px;
  border-radius: var(--radius);
  padding: 13px 17px;
}

.account-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border: 1px solid var(--accent-border);
  background: #eefaf6;
}

.account-banner strong {
  display: block;
  margin-bottom: 2px;
  color: var(--text);
}

.account-banner > div > span {
  color: var(--text-soft);
  font-size: 12px;
}

.account-metrics {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 7px;
}

.profile-alert {
  flex-basis: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--warn-border);
  border-radius: var(--radius-sm);
  background: var(--warn-bg);
  color: var(--warn-text);
  font-size: 13px;
}

.account-metrics span,
.pill,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  background: #fff;
  color: var(--text-soft);
  font-size: 12px;
  white-space: nowrap;
}

.status-ok {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.account-active {
  border-color: var(--accent-border);
}

.account-limited {
  border-color: var(--warn-border);
  background: #fff8e9;
}

.account-disabled {
  border-color: var(--danger-border);
  background: #fff0f3;
}

.error-box {
  border: 1px solid var(--danger-border);
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 750;
}

.grid {
  display: grid;
  gap: 16px;
}

.auth-grid,
.dashboard-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.auth-screen {
  display: grid;
  min-height: 62vh;
  place-items: center;
  padding: 28px 0;
}

.auth-card {
  width: min(100%, 520px);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  margin: 0 auto 4px;
  border-radius: 16px;
  background: var(--accent);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
}

.auth-card h2,
.auth-card > p {
  margin: 0;
  text-align: center;
}

.auth-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.auth-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.link-btn {
  border: 0;
  padding: 6px 8px;
  background: transparent;
  color: var(--accent);
  box-shadow: none;
  font-weight: 700;
}

.link-btn:hover {
  background: var(--accent-soft);
}

#inboxView > .dashboard-grid {
  align-items: start;
}

.view-pane {
  display: grid;
  gap: 16px;
}

.panel,
.info-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.panel {
  display: grid;
  gap: 15px;
  padding: 20px;
}

#inboxView > .dashboard-grid > .panel {
  align-self: start;
  min-height: 0;
}

#inboxView > .dashboard-grid > .panel:first-child {
  max-height: 760px;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}

#inboxView > .dashboard-grid > .panel:nth-child(2) {
  max-height: 760px;
  overflow: auto;
}

.panel form {
  display: grid;
  gap: 14px;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-head p {
  margin-top: 4px;
  font-size: 12px;
}

.panel-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 20px;
  padding: 5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-sm);
}

.nav-btn {
  min-height: 34px;
  border-color: transparent;
  background: transparent;
  color: var(--muted);
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 750;
}

.nav-btn:hover {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: none;
}

.nav-btn.active {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.info-section {
  padding: 20px;
}

.info-section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.info-section-head p {
  margin-top: 4px;
  color: var(--text-soft);
  font-size: 12px;
}

.info-toggle {
  min-height: 32px;
  padding: 6px 12px;
}

.info-steps {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.info-step {
  display: grid;
  gap: 8px;
  min-height: 136px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 15px;
  background: var(--surface-2);
}

.info-step:hover {
  border-color: var(--accent-border);
}

.info-step-num {
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.info-step p {
  color: var(--muted);
  font-size: 12px;
}

.info-tip {
  margin-top: 14px;
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
}

.inline-form {
  display: flex !important;
  flex-flow: row wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.inline-form input,
.inline-form select {
  width: auto;
  min-width: 180px;
  flex: 1 1 180px;
}

.actions,
.template-bar,
.table-toolbar,
.pagination-controls,
.export-controls,
.template-bar-left,
.template-bar-right,
.inbox-control-row,
.inbox-bulk-bar,
.inbox-bulk-actions,
.inbox-pagination,
.inbox-select-all {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.actions {
  justify-content: flex-start;
}

.check-grid,
.stats-grid,
.ai-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.ai-lead-box {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
}

.panel-head.compact {
  margin-bottom: 0;
}

.panel-head.compact h3 {
  margin: 0 0 4px;
  font-size: 17px;
}

.ai-lead-box .ai-grid {
  grid-template-columns: minmax(260px, 1.6fr) minmax(150px, 0.7fr) minmax(220px, 1fr) minmax(190px, 0.8fr);
}

.ai-lead-once {
  min-height: 42px;
  align-self: end;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: #fff;
}

.check-label,
.inbox-filter,
.inbox-select-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 13px;
}

.check-progress-bar-wrap {
  height: 9px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-3);
}

.check-progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 0.2s ease;
}

.check-progress-info {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 7px;
  font-size: 12px;
}

.result-columns {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.result-box {
  min-height: 190px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 13px;
  border-bottom: 1px solid var(--border);
  background: #fff;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.results {
  display: grid;
  gap: 7px;
  max-height: 360px;
  overflow: auto;
  padding: 12px;
}

.list {
  display: grid;
  gap: 9px;
}

#inboxList {
  min-height: 0;
  max-height: 360px;
  overflow: auto;
  padding-right: 4px;
}

.item {
  display: grid;
  gap: 8px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: #fff;
}

.item:hover {
  border-color: var(--border-soft);
  box-shadow: 0 6px 18px rgba(39, 63, 89, 0.07);
}

.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 9px;
  min-width: 0;
}

.message-outgoing {
  border-color: var(--accent-border);
  background: #f0fbf7;
}

.message-incoming {
  border-color: rgba(49, 95, 189, 0.24);
  background: #f4f7ff;
}

.qr-box {
  display: grid;
  min-height: 280px;
  place-items: center;
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 18px;
  background: var(--surface-2);
  text-align: center;
}

.qr-box img {
  width: min(280px, 100%);
  height: auto;
  border-radius: 8px;
  background: #fff;
}

.secret-box,
.template-preview,
.ai-test-result {
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 12px 13px;
  background: var(--accent-soft);
  color: var(--text-soft);
}

.inventory-form {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(130px, .6fr) minmax(110px, .45fr) minmax(150px, .55fr);
  gap: 12px;
  margin-bottom: 16px;
}

.inventory-list {
  display: grid;
  gap: 10px;
}

.inventory-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px;
  background: var(--surface-2);
}

.inventory-thumb {
  width: 64px;
  height: 64px;
  flex: 0 0 auto;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
  cursor: zoom-in;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.inventory-thumb:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.inventory-main {
  flex: 1 1 auto;
  min-width: 0;
}

.inventory-image-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.inventory-image-preview {
  display: block;
  margin-top: 10px;
  max-width: 160px;
  max-height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: #fff;
}

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.82);
}

.image-lightbox.hidden {
  display: none;
}

.image-lightbox-inner {
  position: relative;
  max-width: 92vw;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-lightbox-inner img {
  max-width: 92vw;
  max-height: 82vh;
  object-fit: contain;
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.image-lightbox-caption {
  margin: 0;
  color: #fff;
  font-weight: 700;
  text-align: center;
}

.image-lightbox-close {
  position: absolute;
  top: -14px;
  right: -14px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: #fff;
  color: #111;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}

/* ── CRM / Leads ─────────────────────────────────────────────────────────── */
.crm-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.crm-stat {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 750;
  background: #fff;
  color: var(--text-soft);
}

.crm-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.crm-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface-2);
}

.crm-item.crm-status-nuevo { border-left-color: #3b82f6; }
.crm-item.crm-status-contactado { border-left-color: #f59e0b; }
.crm-item.crm-status-interesado { border-left-color: #8b5cf6; }
.crm-item.crm-status-pedido { border-left-color: var(--accent, #10b981); }
.crm-item.crm-status-cerrado { border-left-color: #16a34a; }
.crm-item.crm-status-descartado { border-left-color: #94a3b8; opacity: 0.75; }

.crm-main { min-width: 0; }

.crm-contact { font-size: 13px; margin-top: 2px; }

.crm-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.crm-meta span {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
  background: #fff;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 650;
}

.crm-summary { margin: 8px 0 4px; color: var(--text-soft); }

.crm-conf {
  border: 1px solid var(--accent-border, #a7f3d0);
  background: var(--accent-soft, #ecfdf5);
  color: var(--accent-dark, #047857);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 750;
}

.crm-notes {
  width: 100%;
  margin-top: 10px;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  font: inherit;
  background: #fff;
}

.crm-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  min-width: 150px;
}

.crm-actions .mini-btn { text-align: center; }

.crm-status-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-soft);
}

.mini-select {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font: inherit;
  background: #fff;
}

.crm-item.crm-status-enviado { border-left-color: #0ea5e9; }
.crm-item.crm-status-entregado { border-left-color: #16a34a; }
.crm-item.crm-status-cancelado { border-left-color: #dc2626; }
.crm-item.crm-status-reembolsado { border-left-color: #d97706; }

.crm-cancel {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 650;
  color: #b91c1c;
  background: #fff1f2;
  border: 1px solid rgba(220, 38, 38, 0.2);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
}

.crm-stock {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.crm-stock .crm-qty {
  width: 70px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font: inherit;
  background: #fff;
}

.crm-deducted {
  font-size: 12px;
  font-weight: 750;
  color: var(--accent-dark, #047857);
  background: var(--accent-soft, #ecfdf5);
  border: 1px solid var(--accent-border, #a7f3d0);
  border-radius: 999px;
  padding: 3px 9px;
}

.crm-templates {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 14px;
  margin-bottom: 14px;
}

.crm-tpl-row {
  display: block;
  margin-bottom: 10px;
}

.crm-tpl-row span {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 4px;
}

.crm-tpl-row textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  font: inherit;
  background: #fff;
}

.ai-template-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 12px;
}

.crm-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.crm-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-soft);
  border-radius: 999px;
  padding: 6px 13px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-tab:hover { border-color: var(--accent, #10b981); }

.crm-tab.active {
  background: var(--accent, #10b981);
  border-color: var(--accent, #10b981);
  color: #fff;
}

.crm-tab-count {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  font-size: 11px;
  text-align: center;
}

.crm-tab.active .crm-tab-count { background: rgba(255, 255, 255, 0.25); }

.crm-states {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.crm-states-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  margin-right: 2px;
}

.crm-state-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-soft);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.crm-state-chip:hover:not(:disabled) {
  border-color: var(--accent, #10b981);
  color: var(--accent-dark, #047857);
}

.crm-state-chip.active {
  background: var(--accent-soft, #ecfdf5);
  border-color: var(--accent-border, #a7f3d0);
  color: var(--accent-dark, #047857);
  cursor: default;
}

.crm-metrics {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: 16px;
  margin-bottom: 14px;
}

.metrics-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.kpi {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.kpi-n { font-size: 26px; font-weight: 900; color: var(--dark); letter-spacing: -.5px; }
.kpi-l { font-size: 12px; font-weight: 700; color: var(--muted); margin-top: 2px; }

.kpi-delta { font-size: 11px; font-weight: 800; margin-left: 4px; }
.kpi-delta.up { color: #16a34a; }
.kpi-delta.down { color: #dc2626; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.chart-box {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  min-width: 0;
}

.chart-box h3 { margin: 0 0 10px; font-size: 14px; font-weight: 750; color: var(--dark); }

.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: 130px 1fr 34px; align-items: center; gap: 8px; }
.hbar-label { font-size: 12.5px; color: var(--text-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbar-track { background: #eef2f7; border-radius: 999px; height: 14px; overflow: hidden; }
.hbar-fill { display: block; height: 100%; border-radius: 999px; }
.hbar-val { font-size: 12.5px; font-weight: 750; color: var(--dark); text-align: right; }

@media (max-width: 720px) {
  .crm-item { grid-template-columns: 1fr; }
  .crm-actions { min-width: 0; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-grid { grid-template-columns: 1fr; }
  .hbar-row { grid-template-columns: 100px 1fr 30px; }
}

.inventory-main p {
  margin: 8px 0 4px;
  color: var(--text-soft);
}

.inventory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 7px;
}

.inventory-meta span,
.inventory-status {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: #fff;
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 750;
}

.inventory-status.ok {
  border-color: var(--accent-border);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.inventory-status.danger {
  border-color: rgba(220, 38, 38, 0.24);
  background: #fff1f2;
  color: #b91c1c;
}

.inventory-status.muted {
  border-color: var(--border);
  background: #f8fafc;
  color: var(--muted);
}

.inventory-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.danger-btn {
  border: 1px solid rgba(220, 38, 38, 0.24);
  background: #fff7f7;
  color: #dc2626;
}

.secret-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.secret-line code {
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  background: #fff;
  color: var(--accent-dark);
  font-size: 11px;
  word-break: break-all;
}

.mini-btn {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.table-toolbar,
.template-bar,
.inbox-control-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
}

.table-toolbar {
  align-items: flex-end;
  justify-content: space-between;
}

.table-toolbar label,
.export-controls label {
  min-width: 130px;
}

.pagination-controls {
  justify-content: center;
}

.export-controls {
  justify-content: flex-end;
}

.export-controls input {
  width: 120px;
}

.template-bar {
  justify-content: space-between;
}

.template-bar select {
  width: min(100%, 260px);
}

.template-preview-label {
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.examples-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  background: var(--surface-2);
}

.examples-panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.inbox-control-panel {
  display: grid;
  gap: 12px;
}

.inbox-field {
  min-width: 170px;
}

.inbox-field-grow {
  flex: 1 1 220px;
}

.inbox-bulk-bar {
  justify-content: space-between;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.inbox-pagination {
  justify-content: center;
  margin-top: 4px;
}

.admin-list {
  display: grid;
  gap: 10px;
}

.admin-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.admin-tab {
  flex: 1 1 150px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-soft);
  box-shadow: none;
}

.admin-tab.active {
  border-color: var(--accent-border);
  background: #fff;
  color: var(--accent);
}

.admin-section-panel.hidden,
.admin-section.hidden {
  display: none;
}

.payment-amount {
  color: var(--text);
  font-size: 15px;
}

.payment-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  color: var(--text-soft);
  font-size: 13px;
}

.payment-method {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 750;
  color: var(--text);
}

.payment-method img,
.payment-method-fallback {
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border-radius: 7px;
}

.payment-method img {
  object-fit: cover;
}

.payment-method-fallback {
  display: inline-grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}

.membership-options {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
}

.membership-summary {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.feature-list,
.membership-limits {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.feature-pill {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 750;
}

.feature-pill.active {
  border-color: var(--accent-border);
  background: #eafaf4;
  color: var(--accent);
}

.feature-pill.inactive {
  background: var(--surface-2);
  color: var(--muted);
}

.membership-limits span {
  color: var(--text-soft);
  font-size: 12px;
}

.stats-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.stats-grid > * {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--surface-2);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 1000;
  max-width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: #eafaf4;
  color: var(--text);
  box-shadow: var(--shadow);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-soft);
}

::-webkit-scrollbar-thumb {
  border: 2px solid var(--bg-soft);
  border-radius: 999px;
  background: var(--border-soft);
}

@media (max-width: 980px) {
  .auth-grid,
  .dashboard-grid,
  .result-columns {
    grid-template-columns: 1fr;
  }

  #inboxView > .dashboard-grid > .panel,
  #inboxView > .dashboard-grid > .panel:first-child,
  #inboxView > .dashboard-grid > .panel:nth-child(2) {
    max-height: none;
    overflow: visible;
  }

  #inboxList {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .info-steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .check-grid,
  .ai-grid,
  .ai-lead-box .ai-grid,
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding-top: 12px;
  }

  .topbar,
  .account-banner,
  .panel-head,
  .info-section-head,
  .template-bar,
  .table-toolbar,
  .inbox-bulk-bar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar {
    min-height: auto;
  }

  .topbar .ghost,
  .panel-head .ghost,
  .actions button,
  .template-bar button,
  .table-toolbar button,
  .inline-form button,
  .inbox-bulk-actions button {
    width: 100%;
  }

  .account-metrics {
    justify-content: flex-start;
  }

  .panel-nav {
    position: static;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .nav-btn {
    flex: 0 0 auto;
  }

  .panel,
  .info-section {
    padding: 15px;
  }

  .info-steps,
  .check-grid,
  .ai-grid,
  .ai-lead-box .ai-grid,
  .inventory-form,
  .stats-grid,
  .examples-grid {
    grid-template-columns: 1fr;
  }

  .inventory-item {
    flex-wrap: wrap;
  }

  .inventory-actions {
    justify-content: flex-start;
  }

  .inline-form,
  .inline-form input,
  .inline-form select,
  .template-bar select,
  .inbox-field,
  .inbox-field-grow {
    width: 100%;
  }

  .pagination-controls,
  .export-controls,
  .template-bar-left,
  .template-bar-right,
  .inbox-control-row,
  .inbox-bulk-actions {
    width: 100%;
  }
}

@media (max-width: 440px) {
  body {
    font-size: 13px;
  }

  h1 {
    font-size: 19px;
  }

  h2 {
    font-size: 16px;
  }

  button {
    min-height: 36px;
    padding: 8px 12px;
  }

  .topbar-logo {
    width: 38px;
    height: 38px;
    min-width: 38px;
  }

  .results {
    max-height: 290px;
  }
}

/* ── Admin leads cards ─────────────────────────────────────── */
.admin-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: .75rem;
}

.lead-card {
  transition: box-shadow .15s;
}
.lead-card:hover {
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
}

.btn-sm {
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  white-space: nowrap;
  font-weight: 500;
  text-align: center;
  transition: background .15s, color .15s, border-color .15s;
}

.btn-sm:hover { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-sm.ghost { background: transparent; }

/* Lead action buttons */
.lead-btn-wa {
  background: #25d366;
  color: #fff;
  border-color: #25d366;
}
.lead-btn-wa:hover { background: #1ebe5d; border-color: #1ebe5d; color: #fff; }

.lead-btn-activate {
  background: #10b981;
  color: #fff;
  border-color: #10b981;
}
.lead-btn-activate:hover { background: #059669; border-color: #059669; color: #fff; }

.lead-btn-reject {
  background: transparent;
  color: #ef4444;
  border-color: #ef4444;
}
.lead-btn-reject:hover { background: #ef4444; color: #fff; }

/* ── Security block in profile ─────────────────────────────── */
.security-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.5rem;
}

/* ── Profile section subnav spacing ───────────────────────── */
#profileView .admin-subnav {
  margin-bottom: 1rem;
}
