* { box-sizing: border-box; }

body.app-shell {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(25, 118, 210, .10), transparent 34rem),
    var(--app-bg);
  color: var(--app-text);
  font: 13px/1.45 var(--hp-font-family);
  overflow-x: hidden;
}

.app-container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 22px var(--app-gutter) 28px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.app-title-wrap h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 0;
  line-height: 1.12;
}

.app-subtitle {
  margin-top: 5px;
  color: var(--app-muted);
  font-size: 13px;
}

.app-actions,
.form-footer,
.card-title,
.rule-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.app-actions { justify-content: flex-end; }
.card-title { justify-content: space-between; margin-bottom: 14px; }
.card-title h2 { margin: 0; font-size: 18px; }

.card-title-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  background: var(--app-primary);
  color: #fff;
  padding: 8px 12px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 800;
  border: 0;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(25, 118, 210, .18);
  line-height: 1.2;
  white-space: nowrap;
}

.btn:hover,
button:hover { background: var(--app-primary-dark); }
.btn-secondary { background: var(--app-secondary); box-shadow: 0 2px 6px rgba(96, 125, 139, .18); }
.btn-danger, button.btn-danger { background: var(--app-danger); box-shadow: 0 2px 6px rgba(229, 57, 53, .16); }

.app-quick-access {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0 0 18px;
}

.app-quick-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  background: #e3f2fd;
  color: #0d47a1;
  border: 1px solid #bbdefb;
  padding: 7px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.app-quick-link:hover,
.app-quick-link.active {
  background: var(--app-primary);
  color: #fff;
  border-color: var(--app-primary);
}

.card {
  background: rgba(255, 255, 255, .96);
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  padding: 16px;
  margin-bottom: 18px;
  box-shadow: var(--app-shadow);
  min-width: 0;
}

.card-tall { min-height: 216px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.kpi-grid-six {
  grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
}

/* Painel de inteligência: denso, visual e com histórico limitado na interface. */
.learning-kpis { grid-template-columns: repeat(5, minmax(140px, 1fr)); gap: 10px; }
.learning-kpi { min-height: 108px; padding: 13px 15px; position: relative; overflow: hidden; }
.learning-kpi span { display: block; color: var(--app-muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.learning-kpi strong { display: block; margin-top: 8px; color: var(--app-text); font-size: 25px; line-height: 1.08; }
.learning-kpi small { display: block; margin-top: 6px; color: var(--app-muted); font-size: 11px; }
.learning-kpi-primary { border-color: #90caf9; background: linear-gradient(135deg, #eef7ff, #fff); }
.learning-kpi-primary strong { color: var(--app-primary); }
.learning-kpi-savings { border-color: #b39ddb; background: linear-gradient(135deg, #f7f2ff, #fff); }
.learning-kpi-savings strong { color: #6a1b9a; }
.learning-kpi-ok { border-color: #a5d6a7; }
.learning-kpi-ok strong { color: #2e7d32; font-size: 17px; }
.learning-head { margin-bottom: 12px; }
.learning-head h1 { margin-bottom: 3px; }
.learning-head p { margin: 0; }
.learning-control-card { padding: 13px 15px; }
.learning-control-card .card-header { margin-bottom: 10px; }
.learning-control-card h2, .learning-table-card h2 { margin: 0; font-size: 16px; }
.learning-muted { display: block; color: var(--app-muted); font-size: 11px; margin-top: 2px; }
.learning-policy { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--app-muted); font-size: 11px; }
.learning-status-dot { width: 8px; height: 8px; border-radius: 50%; background: #90a4ae; display: inline-block; }
.learning-status-dot.is-on { background: #43a047; box-shadow: 0 0 0 3px rgba(67,160,71,.13); }
.learning-count { color: var(--app-primary); font-size: 11px; font-weight: 900; }
.learning-table-card { padding-bottom: 10px; }
.learning-table table { min-width: 680px; }
.learning-table th, .learning-table td { padding: 8px 9px; }
.learning-type { color: #546e7a; font-size: 11px; font-weight: 900; }
.learning-evidence { white-space: nowrap; color: var(--app-muted); font-size: 11px; }
.learning-evidence b { color: var(--app-text); font-size: 13px; }
.learning-meter { width: 70px; height: 4px; margin-top: 5px; border-radius: 99px; background: #e6edf5; overflow: hidden; }
.learning-meter i { display: block; height: 100%; border-radius: inherit; background: #43a047; }
.learning-badge { display: inline-block; border-radius: 999px; padding: 3px 7px; font-size: 10px; font-weight: 900; text-transform: lowercase; background: #eceff1; color: #455a64; }
.learning-badge-complete, .learning-badge-approved { color: #1b5e20; background: #e8f5e9; }
.learning-badge-shadow { color: #8d6e00; background: #fff8e1; }
.learning-badge-error, .learning-badge-disabled { color: #b71c1c; background: #ffebee; }
.learning-runs { padding: 0; overflow: hidden; }
.learning-runs summary { cursor: pointer; list-style: none; padding: 13px 15px; color: var(--app-text); font-size: 13px; font-weight: 900; }
.learning-runs summary::-webkit-details-marker { display: none; }
.learning-runs summary::after { content: '＋'; float: right; color: var(--app-muted); }
.learning-runs[open] summary::after { content: '−'; }
.learning-runs .table-wrapper { border: 0; border-top: 1px solid var(--app-border); border-radius: 0; }

@media (max-width: 760px) {
  .learning-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .learning-policy { line-height: 1.7; }
}

/* Vitrine pública: tema amarelo Mercado Livre */
.marketplace-standalone { --market-yellow: #ffe600; --market-ink: #263238; --market-blue: #3483fa; }
.marketplace-standalone .marketplace-hero { color: var(--market-ink); background: linear-gradient(115deg, #ffe600 0%, #ffea3a 62%, #ffd400 100%); box-shadow: 0 14px 30px rgba(166, 133, 0, .18); }
.marketplace-standalone .marketplace-eyebrow { color: #6d5b00; }
.marketplace-standalone .marketplace-hero p { color: #514a00; }
.marketplace-standalone .marketplace-hero-mark { border-color: rgba(38, 50, 56, .28); color: var(--market-ink); background: rgba(255,255,255,.28); }
.marketplace-standalone .marketplace-storefront { border-color: #eadc72; }
.marketplace-standalone .offer-badge { color: #5c4d00; border-color: #e7ce00; background: #fff4a8; }
.marketplace-standalone .offer-product-icon { color: #5c4d00; background: linear-gradient(135deg, #fff7b8, #fffbea); }
.marketplace-standalone .offer-cta,
.marketplace-standalone .marketplace-search button,
.marketplace-standalone .marketplace-pagination .btn { color: #fff; background: var(--market-blue); box-shadow: 0 4px 10px rgba(52, 131, 250, .22); }
.marketplace-standalone .offer-cta:hover,
.marketplace-standalone .marketplace-search button:hover,
.marketplace-standalone .marketplace-pagination .btn:hover { background: #296dcc; }

/* Mercado Livre storefront */
.marketplace-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
  padding: 26px 30px;
  color: #fff;
  border-radius: 18px;
  background: linear-gradient(115deg, #102a43 0%, #174a72 58%, #1976d2 100%);
  box-shadow: 0 14px 30px rgba(16, 42, 67, .18);
  overflow: hidden;
}
.marketplace-eyebrow { color: #90caf9; font-size: 10px; font-weight: 900; letter-spacing: .14em; }
.marketplace-hero h2 { margin: 7px 0 4px; font-size: clamp(22px, 3vw, 32px); line-height: 1.1; }
.marketplace-hero h1 { margin: 7px 0 4px; font-size: clamp(22px, 3vw, 32px); line-height: 1.1; }
.marketplace-hero p { margin: 0; color: #d9ecff; font-size: 13px; }
.marketplace-hero-mark { display: grid; place-items: center; width: 74px; height: 74px; border: 1px solid rgba(255,255,255,.35); border-radius: 22px; color: #fff; font-size: 22px; font-weight: 950; transform: rotate(8deg); background: rgba(255,255,255,.12); }
.marketplace-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 18px; }
.marketplace-kpi { padding: 14px 16px; border: 1px solid #dbe7f2; border-radius: 13px; background: rgba(255,255,255,.94); box-shadow: 0 5px 16px rgba(18, 55, 86, .06); }
.marketplace-kpi span, .marketplace-kpi small { display: block; color: var(--app-muted); font-size: 10px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.marketplace-kpi strong { display: block; margin: 6px 0 2px; color: #12344d; font-size: 25px; line-height: 1.1; }
.marketplace-kpi-accent { background: linear-gradient(135deg, #eef8ff, #fff); border-color: #b8dcf8; }
.marketplace-kpi-accent strong { color: var(--app-primary); font-size: 18px; }
.marketplace-storefront { padding: 20px; }
.marketplace-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.marketplace-toolbar h2 { margin: 0 0 3px; color: #12344d; font-size: 20px; }
.marketplace-toolbar > div > span { color: var(--app-muted); font-size: 12px; }
.marketplace-search { display: flex; align-items: center; gap: 7px; }
.marketplace-search input { min-width: 240px; margin: 0; }
.marketplace-search button { padding: 9px 13px; }
.marketplace-search a { color: var(--app-muted); font-size: 11px; font-weight: 800; text-decoration: none; }
.marketplace-offer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(245px, 1fr)); gap: 15px; }
.offer-card { display: flex; min-height: 315px; flex-direction: column; overflow: hidden; border: 1px solid #dce8f1; border-radius: 15px; background: #fff; box-shadow: 0 7px 20px rgba(18, 55, 86, .07); transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.offer-card:hover { border-color: #90caf9; box-shadow: 0 12px 28px rgba(25, 118, 210, .16); transform: translateY(-3px); }
.offer-card-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid #edf3f7; }
.offer-badge { padding: 4px 7px; border-radius: 5px; color: #0d47a1; background: #e3f2fd; font-size: 9px; font-weight: 950; letter-spacing: .08em; }
.offer-time { color: #8495a3; font-size: 10px; }
.offer-card-body { flex: 1; padding: 17px 17px 12px; }
.offer-image { display: block; width: 100%; height: 156px; margin: -2px 0 15px; border-radius: 10px; object-fit: contain; background: #f7fafc; }
.offer-product-icon { display: grid; place-items: center; width: 43px; height: 43px; margin-bottom: 12px; border-radius: 12px; color: #1565c0; background: linear-gradient(135deg, #e7f4ff, #f2f8fc); font-size: 13px; font-weight: 950; }
.offer-card h3 { display: -webkit-box; min-height: 42px; margin: 0 0 14px; overflow: hidden; color: #173b55; font-size: 14px; line-height: 1.45; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.offer-price-label { color: #8799a6; font-size: 9px; font-weight: 900; letter-spacing: .09em; }
.offer-price { margin-top: 2px; color: #102a43; font-size: 25px; font-weight: 950; letter-spacing: -.03em; }
.offer-coupon { display: inline-flex; align-items: center; gap: 6px; max-width: 100%; margin-top: 13px; padding: 6px 8px; border: 1px dashed #f0b44c; border-radius: 7px; color: #8a5700; background: #fff8e8; font-size: 10px; font-weight: 800; }
.offer-coupon code { max-width: 112px; overflow: hidden; color: #704600; text-overflow: ellipsis; white-space: nowrap; }
.offer-no-coupon { margin-top: 15px; color: #8495a3; font-size: 11px; }
.offer-card-footer { padding: 12px 14px 14px; border-top: 1px solid #edf3f7; }
.offer-cta { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; padding: 10px 12px; border-radius: 8px; color: #fff; background: #1976d2; font-size: 12px; font-weight: 900; text-decoration: none; box-shadow: 0 4px 10px rgba(25, 118, 210, .2); }
.offer-cta:hover { background: #0d5cad; }
.offer-cta span { font-size: 15px; line-height: 1; }
.offer-trust { display: block; margin-top: 7px; color: #8da0ad; font-size: 9px; text-align: center; }
.marketplace-empty { grid-column: 1 / -1; padding: 55px 20px; color: var(--app-muted); text-align: center; }
.marketplace-empty-icon { margin: auto; color: #90caf9; font-size: 38px; }
.marketplace-empty h3 { margin: 10px 0 3px; color: #31536b; }
.marketplace-empty p { margin: 0; }
.marketplace-pagination { justify-content: center; margin-top: 20px; }

@media (max-width: 760px) {
  .marketplace-hero { padding: 22px; }
  .marketplace-hero-mark { width: 58px; height: 58px; border-radius: 17px; font-size: 18px; }
  .marketplace-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .marketplace-toolbar { align-items: stretch; flex-direction: column; }
  .marketplace-search input { min-width: 0; flex: 1; }
}

.daily-kpi-strip {
  display: grid;
  grid-template-columns: repeat(7, minmax(235px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.daily-kpi-card {
  border: 1px solid #dbe3ee;
  border-radius: 9px;
  background: linear-gradient(180deg, #fff, #f8fbff);
  padding: 12px 13px;
  box-shadow: var(--app-shadow);
  min-height: 132px;
}

.daily-kpi-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
  margin-bottom: 10px;
}

.daily-kpi-head strong {
  font-size: 13px;
  color: var(--app-text);
}

.daily-kpi-head span {
  color: var(--app-muted);
  font-size: 11px;
  white-space: nowrap;
}

.daily-kpi-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 6px 0;
  border-top: 1px solid #e8eef6;
}

.daily-kpi-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.daily-kpi-row span {
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.daily-kpi-row strong {
  color: var(--app-primary);
  font-size: 18px;
  font-weight: 950;
  line-height: 1;
}

.daily-kpi-row.daily-kpi-separator {
  margin-top: 4px;
  border-top-color: #c7d4e5;
}

.coupon-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 12px;
}

.coupon-legend-item {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.coupon-table-wrapper {
  max-height: calc(100vh - 280px);
}

.coupon-table {
  min-width: 1040px;
}

.coupon-row td {
  transition: background-color .2s ease, border-color .2s ease, box-shadow .2s ease;
}

.coupon-row td:first-child {
  border-left: 4px solid transparent;
}

.coupon-row-current td,
.coupon-row-new td {
  background: linear-gradient(90deg, rgba(67, 160, 71, .16), rgba(67, 160, 71, .05));
}

.coupon-row-stable td {
  background: #fafcff;
}

.coupon-row-moderate td,
.coupon-row-slow td {
  background: linear-gradient(90deg, rgba(251, 140, 0, .14), rgba(251, 140, 0, .05));
}

.coupon-row-expired td,
.coupon-row-stale td {
  background: linear-gradient(90deg, rgba(229, 57, 53, .15), rgba(229, 57, 53, .06));
}

.coupon-row-current td:first-child,
.coupon-row-current td:first-child .badge,
.coupon-legend-item.coupon-row-current,
.coupon-row-new td:first-child,
.coupon-row-new td:first-child .badge,
.coupon-legend-item.coupon-row-new {
  background: #43a047;
  color: #fff;
}

.coupon-row-current td:first-child,
.coupon-row-new td:first-child { border-left-color: #43a047; }

.coupon-row-stable td:first-child .badge,
.coupon-legend-item.coupon-row-stable {
  background: #90a4ae;
  color: #fff;
}

.coupon-row-stable td:first-child { border-left-color: #90a4ae; }

.coupon-row-moderate td:first-child .badge,
.coupon-legend-item.coupon-row-moderate,
.coupon-row-slow td:first-child .badge,
.coupon-legend-item.coupon-row-slow {
  background: #fb8c00;
  color: #fff;
}

.coupon-row-moderate td:first-child,
.coupon-row-slow td:first-child { border-left-color: #fb8c00; }

.coupon-row-expired td:first-child .badge,
.coupon-legend-item.coupon-row-expired,
.coupon-row-stale td:first-child .badge,
.coupon-legend-item.coupon-row-stale {
  background: #e53935;
  color: #fff;
}

.coupon-row-expired td:first-child,
.coupon-row-stale td:first-child { border-left-color: #e53935; }

.coupon-row-current,
.coupon-row-new {
  animation: couponPulse 1.5s ease-in-out 1;
}

.coupons-toolbar {
  margin-bottom: 16px;
  gap: 14px 16px;
  align-items: end;
  padding: 12px 12px 10px;
  border: 1px solid #dce4ef;
  border-radius: 9px;
  background: #f8fbff;
}

.coupons-toolbar label {
  min-width: 0;
}

@keyframes couponPulse {
  0% { box-shadow: inset 0 0 0 0 rgba(67, 160, 71, 0); }
  50% { box-shadow: inset 0 0 0 9999px rgba(67, 160, 71, .06); }
  100% { box-shadow: inset 0 0 0 0 rgba(67, 160, 71, 0); }
}

.kpi {
  background: linear-gradient(180deg, #fff, #f8fbff);
  border: 1px solid var(--app-border);
  border-left: 6px solid var(--app-primary);
  border-radius: var(--app-radius);
  padding: 15px 16px;
  box-shadow: var(--app-shadow);
  min-height: 96px;
}

.kpi div {
  color: var(--app-text);
  font-size: 13px;
  font-weight: 800;
}

.kpi strong {
  display: block;
  margin-top: 4px;
  color: var(--app-primary);
  font-size: 28px;
  font-weight: 950;
  line-height: 1.05;
}

.kpi-compact {
  min-height: 84px;
  padding: 12px 13px;
}

.kpi-compact strong {
  font-size: 24px;
}

.kpi span,
.muted,
.small {
  color: var(--app-muted);
  font-size: 12px;
}

.layout-main {
  display: grid;
  grid-template-columns: minmax(320px, .85fr) minmax(520px, 1.15fr);
  gap: 18px;
  align-items: stretch;
  min-width: 0;
}

.layout-secondary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  min-width: 0;
}

.layout-stacked {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  min-width: 0;
}

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

.ops-grid div,
.policy-grid div {
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #f8fafc;
  padding: 12px;
  min-width: 0;
}

.ops-grid span,
.policy-grid span {
  display: block;
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.ops-grid strong,
.policy-grid strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.table-wrapper {
  overflow: auto;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: #fff;
}

.table-wrapper.compact { max-height: 520px; }

table {
  width: 100%;
  min-width: 920px;
  border-collapse: separate;
  border-spacing: 0;
  background: #fff;
  font-size: 13px;
}

.compact table { min-width: 680px; }

th,
td {
  border-bottom: 1px solid var(--app-border);
  padding: 9px 10px;
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef2f7;
  color: #374151;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f9fbff; }

.wide-text {
  max-width: 620px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.unidentified-toolbar {
  grid-template-columns: minmax(260px, 1fr) auto;
}

.unidentified-store-table table {
  min-width: 1180px;
}

.unidentified-message pre {
  max-width: 680px;
  max-height: 260px;
  margin: 0;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
  color: inherit;
}

.kpi strong.kpi-date {
  font-size: 18px;
  line-height: 1.25;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

.nowrap { white-space: nowrap; }

.empty {
  color: var(--app-muted);
  text-align: center;
  padding: 22px 10px;
}

.empty-block {
  border: 1px dashed var(--app-border);
  border-radius: var(--app-radius);
  background: #f8fafc;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: #64748b;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  white-space: nowrap;
}

.badge-ok,
.badge.confirmed,
.badge.matched { background: var(--app-success); }
.badge-warning { background: var(--app-warning); }
.badge.rejected_ai { background: var(--app-danger); }

.coupon-code {
  font-size: 15px;
  letter-spacing: .4px;
  overflow-wrap: anywhere;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: var(--app-muted);
  font-size: 12px;
  font-weight: 900;
  min-width: 0;
}

input,
textarea,
select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 7px 8px;
  color: var(--app-text);
  background: #fff;
  font: inherit;
}

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

.stack {
  display: grid;
  gap: 10px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  align-items: end;
}

.inline-actions {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}

.inline-actions button {
  padding: 6px 9px;
  font-size: 11px;
}

.form-grid-wide {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.span-2 { grid-column: span 2; }
.span-full { grid-column: 1 / -1; }
.form-submit { align-self: end; }

.checkrow {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  color: #334155;
  min-height: 34px;
}

.checkrow input { width: auto; accent-color: var(--app-primary); }

.checkrow-strong {
  font-size: 13px;
  color: var(--app-text);
}

.control-band {
  display: grid;
  grid-template-columns: minmax(120px, auto) minmax(170px, auto) 1fr;
  gap: 10px 12px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.control-group {
  display: grid;
  gap: 4px;
}

.control-group-label {
  color: var(--app-muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.control-row {
  display: inline-flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.status-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 0 0 14px;
}

.status-filter .btn {
  width: auto;
  min-width: 0;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11px;
  line-height: 1.1;
  box-shadow: none;
}

.status-filter .btn-secondary {
  border: 1px solid #d6e0ea;
  color: #526575;
  background: #f7f9fc;
}

.status-filter .btn-secondary:hover {
  color: var(--app-primary-dark);
  background: #edf4fb;
}

.form-footer {
  justify-content: space-between;
}

.rules-list {
  display: grid;
  gap: 14px;
}

.rules-top {
  align-items: start;
}

.rules-builder {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  align-items: end;
}

.rules-builder.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

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

.catalog-item {
  width: 100%;
  text-align: left;
  border: 1px solid var(--app-border);
  border-radius: calc(var(--app-radius) - 2px);
  background: #f8fbff;
  padding: 10px 12px;
  color: var(--app-text);
  box-shadow: none;
}

.catalog-item:hover {
  background: #eef6ff;
}

.catalog-main,
.product-summary,
.destination-text {
  display: grid;
  gap: 4px;
}

.catalog-main strong,
.product-summary strong,
.destination-text h3 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.catalog-main span,
.product-summary span {
  color: var(--app-muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.catalog-meta,
.destination-badges,
.product-summary-right {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.destination-tree {
  display: grid;
  gap: 14px;
}

.rules-page .card {
  padding: 13px;
}

.rules-page .note {
  margin-top: 10px;
}

.rules-page .rules-builder {
  gap: 8px;
}

.rules-quick-card {
  margin-bottom: 12px;
}

.quick-rule-form {
  display: grid;
  grid-template-columns: minmax(260px, .9fr) minmax(360px, 1.25fr) minmax(220px, .75fr);
  gap: 12px;
  align-items: stretch;
}

.quick-section {
  display: grid;
  gap: 8px;
  align-content: start;
  min-width: 0;
  padding: 10px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #f8fafc;
}

.quick-section-title {
  color: #334155;
  font-size: 12px;
  font-weight: 950;
  text-transform: uppercase;
}

.quick-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  min-width: 0;
}

.quick-product {
  grid-template-columns: minmax(0, 1.2fr) minmax(120px, .55fr);
}

.quick-product .quick-section-title,
.quick-product label:nth-of-type(3),
.quick-product label:nth-of-type(4) {
  grid-column: 1 / -1;
}

.quick-options {
  align-content: start;
}

.compact-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px 8px;
}

.compact-controls .checkrow {
  min-height: 28px;
}

.catalog-compact-card {
  margin-bottom: 14px;
}

.catalog-list-compact {
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 8px;
}

.catalog-list-compact .catalog-item {
  display: grid;
  gap: 6px;
  padding: 8px 10px;
  max-width: 100%;
  overflow: hidden;
}

.catalog-list-compact .catalog-main strong {
  font-size: 13px;
}

.catalog-list-compact .catalog-main span {
  font-size: 11px;
  overflow-wrap: anywhere;
  word-break: break-word;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.catalog-list-compact .catalog-meta {
  justify-content: flex-start;
  min-width: 0;
}

.catalog-list-compact .catalog-item,
.catalog-list-compact .catalog-main,
.catalog-list-compact .catalog-meta {
  min-width: 0;
}

.catalog-list-compact .badge {
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: normal;
}

.rules-page .rules-builder.compact {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.rules-page .destination-tree {
  gap: 12px;
}

.destination-card {
  border: 1px solid #cbd5e1;
  border-radius: var(--app-radius);
  background: linear-gradient(180deg, #fff, #f8fbff);
  box-shadow: var(--app-shadow);
  padding: 14px;
}

.destination-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding-bottom: 11px;
  margin-bottom: 12px;
  border-bottom: 1px solid #e2e8f0;
}

.identity-add-product {
  margin-bottom: 14px;
  padding: 10px;
  border: 1px dashed #cbd5e1;
  border-radius: calc(var(--app-radius) - 2px);
  background: #f8fafc;
}

.identity-contact-form {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
  padding: 12px;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #fff;
}

.identity-add-product label {
  gap: 6px;
}

.identity-add-product textarea {
  min-height: 76px;
}

.products-section-title {
  margin: 0 0 8px;
  color: #475569;
  font-size: 11px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: 0;
}

.destination-products {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 10px;
  padding-top: 10px;
  border-top: 1px solid #e2e8f0;
  align-items: start;
}

.product-item {
  border: 1px solid #dbe3ee;
  border-radius: calc(var(--app-radius) - 2px);
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
  overflow: hidden;
}

.destination-products .product-item:nth-of-type(even) {
  background: #f6f9fd;
}

.destination-products .product-item:nth-of-type(even) input,
.destination-products .product-item:nth-of-type(even) textarea,
.destination-products .product-item:nth-of-type(even) select {
  background: #fff;
}

.product-item summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid transparent;
}

.product-item summary::-webkit-details-marker {
  display: none;
}

.product-item[open] summary {
  border-bottom-color: var(--app-border);
  background: #f8fafc;
}

.product-edit {
  padding: 9px 10px;
}

.product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
}

.product-edit .rule-actions {
  align-self: stretch;
  display: flex;
  justify-content: flex-end;
  align-content: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 0 0;
  border-left: 0;
  border-top: 1px solid #e5e7eb;
  margin-top: 0;
}

.product-edit .rule-actions button {
  width: 86px;
  min-width: 86px;
  padding: 7px 8px;
  font-size: 11px;
}

.product-edit .rule-actions button + button {
  margin-top: 0;
}

.product-main {
  display: grid;
  grid-template-columns:minmax(0,1fr) 110px;
  gap: 8px;
  min-width: 0;
  align-items:start;
}

.product-main label {
  gap: 4px;
  font-size: 11px;
}

.product-main textarea {
  min-height: 42px;
  height: 42px;
  resize: vertical;
}

.product-main .span-2 {
  grid-column:1 / -1;
}

.product-main input,
.product-main textarea,
.product-main select {
  padding: 7px 8px;
  font-size: 12px;
}

.product-main .control-band {
  grid-column:1 / -1;
  padding: 6px 8px;
  gap: 8px;
  align-self:stretch;
}

.product-main .control-group-label {
  font-size: 10px;
}

.product-main .checkrow {
  padding: 4px 7px;
  font-size: 11px;
}

@media (max-width: 1360px) {
  .destination-products {
    grid-template-columns: repeat(auto-fit, minmax(min(360px, 100%), 1fr));
  }

  .product-main {
    grid-template-columns:minmax(0,1fr) 110px;
  }

  .product-main .control-band,
  .product-main .span-2:last-of-type {
    grid-column:1 / -1;
  }
}

@media (min-width: 1700px) {
  .destination-products {
    grid-template-columns: repeat(auto-fit, minmax(390px, 1fr));
  }
}

@media (max-width: 980px) {
  .identity-contact-form,
  .product-row,
  .product-main {
    grid-template-columns:1fr;
  }

  .product-edit .rule-actions {
    border-left:0;
    border-top:1px solid #e5e7eb;
    padding-left:0;
    padding-top:8px;
    display:flex;
    min-width:0;
  }

  .product-edit .rule-actions button {
    width: 86px;
    min-width: 86px;
  }
}

.product-summary-right .badge,
.catalog-meta .badge {
  background: #e2e8f0;
  color: #334155;
}

.rule-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: #fff;
  padding: 14px;
}

.rule-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.rule-head {
  display: grid;
  grid-template-columns: minmax(260px, 1.2fr) 140px 100px 80px 70px;
  gap: 10px;
  align-items: end;
}

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

.inline-form {
  align-self: start;
}

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

.settings-layout .card { margin-bottom: 0; }

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

.prompt-field {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: #f8fafc;
}

.prompt-field > span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #475569;
}

.prompt-field textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.45;
  background: #fff;
}

.sticky-save {
  grid-column: 1 / -1;
  display: flex;
  justify-content: flex-end;
  position: sticky;
  bottom: 12px;
  padding: 10px;
  border: 1px solid var(--app-border);
  border-radius: var(--app-radius);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--app-shadow);
}

.note {
  margin-top: 12px;
  color: var(--app-muted);
  border-left: 4px solid var(--app-primary);
  padding: 8px 10px;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
}

.flash {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: var(--app-radius);
  padding: 10px 12px;
  margin-bottom: 16px;
  box-shadow: var(--app-shadow);
  overflow-wrap: anywhere;
}

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

  .layout-main,
  .layout-secondary,
  .settings-layout,
  .quick-rule-form {
    grid-template-columns: 1fr;
  }

  .quick-product {
    grid-template-columns: minmax(0, 1fr) minmax(150px, .4fr);
  }

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

  .rules-builder,
  .rules-builder.compact {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .rule-head,
  .rule-terms {
    grid-template-columns: 1fr 1fr;
  }

  .control-band {
    grid-template-columns: 1fr;
    align-items: start;
  }
}

@media (max-width: 760px) {
  .app-container {
    width: 100%;
    max-width: none;
    padding: 14px 12px 22px;
  }

  .app-header {
    display: block;
  }

  .app-subtitle {
    overflow-wrap: anywhere;
  }

  .app-actions {
    margin-top: 14px;
  }

  .app-actions,
  .app-quick-access {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    width: 100%;
  }

  .app-actions .btn,
  .app-quick-link {
    width: 100%;
    min-width: 0;
    white-space: normal;
    text-align: center;
  }

  .app-title-wrap h1 {
    font-size: 24px;
  }

  .kpi-grid,
  .form-grid,
  .form-grid-wide,
  .rules-builder,
  .quick-rule-form,
  .quick-product,
  .quick-inline,
  .ops-grid,
  .policy-grid,
  .rule-head,
  .rule-terms,
  .rule-card {
    grid-template-columns: 1fr;
  }

  .span-2 { grid-column: auto; }
  .span-full { grid-column: auto; }
  .card {
    padding: 14px;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .form-footer button,
  .sticky-save button {
    width: 100%;
  }

  .sticky-save {
    position: static;
  }

  table {
    font-size: 12px;
  }

  th,
  td {
    padding: 8px;
  }

  .destination-head,
  .product-item summary {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .product-row,
  .product-main {
    grid-template-columns: 1fr;
  }

  .product-main .span-2 {
    grid-column: auto;
  }

  .control-row {
    display: grid;
  }
}
