:root {
  color-scheme: light;
  --brand: #07456f;
  --brand-deep: #053454;
  --brand-soft: #e8f4fa;
  --accent: #43b6ca;
  --glow: #7fd7e5;
  --steel: #8eb8c6;
  --success: #12805f;
  --surface: #ffffff;
  --surface-soft: #f5f9fb;
  --line: #d7e3e8;
  --text: #142638;
  --muted: #5c6f7c;
  --shadow: 0 18px 45px rgba(5, 52, 84, 0.1);
  background: #f5f9fb;
  color: var(--text);
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface-soft);
}

button,
input,
textarea,
select {
  font: inherit;
  min-width: 0;
}

select {
  background: #fff;
  border: 1px solid #cbdde4;
  border-radius: 6px;
  min-height: 40px;
  padding: 0 10px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--success);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  min-height: 40px;
  padding: 0 14px;
}

button:hover {
  background: #0e684e;
}

.ghost {
  background: #e7f0f4;
  color: var(--brand);
}

.ghost:hover {
  background: #d7e8ef;
}

.app {
  min-height: 100vh;
  padding: 32px;
}

.hidden {
  display: none !important;
}

.eyebrow {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  color: #102338;
  font-size: 38px;
  margin-bottom: 0;
}

h2 {
  font-size: 18px;
  margin-bottom: 0;
}

.login-form,
.panel,
.metrics article {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

label {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.input-row {
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto;
}

input,
textarea {
  background: #fff;
  border: 1px solid #cbdde4;
  border-radius: 6px;
  padding: 0 12px;
}

input {
  min-height: 44px;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(36, 138, 162, 0.14);
  outline: 0;
}

textarea {
  padding: 10px 12px;
  resize: vertical;
}

.message {
  color: #b42318;
  min-height: 20px;
}

.login-hero {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(0deg, rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(30deg, transparent 0 48%, rgba(127, 215, 229, 0.2) 48% 49%, transparent 49%),
    linear-gradient(150deg, transparent 0 48%, rgba(5, 52, 84, 0.28) 48% 49%, transparent 49%),
    linear-gradient(115deg, rgba(67, 182, 202, 0.16), transparent 36%),
    linear-gradient(285deg, rgba(7, 69, 111, 0.3), transparent 42%),
    linear-gradient(135deg, #f6fbfd 0%, #dfeef4 18%, #0a3048 18.1%, #071522 53%, #0b2638 100%);
  background-size: 76px 76px, 76px 76px, 124px 124px, 124px 124px, auto, auto, auto;
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr;
  margin: -32px;
  min-height: 100vh;
  overflow: hidden;
  padding: 32px clamp(24px, 5vw, 82px);
  position: relative;
}

.login-hero::before {
  background:
    linear-gradient(112deg, rgba(255, 255, 255, 0.52), rgba(255, 255, 255, 0.06) 28%, transparent 45%),
    linear-gradient(278deg, rgba(127, 215, 229, 0.16), transparent 38%);
  bottom: -8%;
  content: "";
  height: 46%;
  left: 0;
  position: absolute;
  right: 0;
}

.login-hero > * {
  position: relative;
  z-index: 1;
}

.login-nav {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 16px;
}

.brand-lockup img {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(127, 215, 229, 0.36);
  border-radius: 8px;
  box-shadow: 0 16px 42px rgba(2, 20, 34, 0.18);
  height: 58px;
  object-fit: contain;
  padding: 7px 10px;
  width: 188px;
}

.brand-lockup span,
.nav-pill,
.product-kicker,
.card-kicker {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-lockup span {
  color: #f8fcfd;
}

.nav-pill {
  border: 1px solid rgba(127, 215, 229, 0.34);
  border-radius: 999px;
  color: #e4f8fb;
  padding: 9px 12px;
}

.login-stage {
  align-items: center;
  align-self: center;
  display: grid;
  gap: clamp(40px, 7vw, 120px);
  grid-template-columns: minmax(560px, 1.08fr) minmax(360px, 430px);
  justify-self: stretch;
  margin: 42px auto 0;
  max-width: 1340px;
  width: 100%;
}

.login-product {
  max-width: 820px;
}

.product-logo {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(127, 215, 229, 0.32);
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(2, 20, 34, 0.28);
  display: block;
  margin-bottom: 30px;
  max-width: min(560px, 100%);
  object-fit: contain;
  padding: 18px 22px;
  width: 560px;
}

.product-kicker,
.card-kicker {
  color: var(--glow);
}

.login-product h1 {
  color: #fff;
  font-size: clamp(44px, 5.7vw, 74px);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 0.98;
  margin: 18px 0 0;
  max-width: 790px;
}

.login-product p {
  color: #d5e1e8;
  font-size: 19px;
  line-height: 1.55;
  margin-top: 22px;
  max-width: 720px;
}

.login-highlights {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 30px;
  max-width: 760px;
}

.login-highlights span {
  background: rgba(255, 255, 255, 0.065);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-left: 3px solid var(--glow);
  border-radius: 7px;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  padding: 14px 16px;
}

.login-form {
  background: rgba(7, 17, 31, 0.74);
  border: 1px solid rgba(205, 231, 240, 0.2);
  border-radius: 8px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.32);
  display: grid;
  gap: 13px;
  padding: 30px;
  position: relative;
}

.login-form::before {
  background: linear-gradient(90deg, #dff7fb, var(--glow), #43b6ca, #176f98);
  border-radius: 8px 8px 0 0;
  content: "";
  height: 4px;
  left: -1px;
  position: absolute;
  right: -1px;
  top: -1px;
}

.login-form h2 {
  color: #fff;
  font-size: 30px;
  margin-bottom: 4px;
}

.login-form label {
  color: #e5edf2;
  font-size: 12px;
}

.login-form input {
  background: #e8eef7;
  border-color: transparent;
  color: #07111f;
  font-weight: 700;
}

.login-form input:focus {
  border-color: var(--glow);
  box-shadow: 0 0 0 3px rgba(127, 215, 229, 0.24);
}

.login-form button {
  background: linear-gradient(135deg, #0d5f82, #2598ad);
  color: #fff;
  margin-top: 6px;
}

.login-form button:hover {
  background: linear-gradient(135deg, #0a4d6b, #1d7e92);
}

.login-form .message {
  color: #b9f0f7;
  margin-bottom: 0;
}

.dashboard {
  display: grid;
  gap: 20px;
  margin: 0 auto;
  max-width: 1400px;
}

.topbar,
.panel-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  background: linear-gradient(135deg, #07111f, #0b1d33);
  border: 1px solid rgba(205, 231, 240, 0.16);
  border-radius: 10px;
  box-shadow: 0 18px 45px rgba(5, 52, 84, 0.2);
  color: #fff;
  padding: 18px 20px;
}

.topbar-brand {
  align-items: center;
  display: flex;
  gap: 18px;
}

.topbar-brand img {
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  height: 74px;
  object-fit: contain;
  padding: 8px 10px;
  width: 190px;
}

.topbar h1 {
  color: #fff;
}

.topbar .ghost {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.topbar .ghost:hover {
  background: rgba(255, 255, 255, 0.18);
}

.panel-subheader {
  align-items: center;
  border-top: 1px solid #e1e8e4;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 14px;
}

.panel-note {
  color: var(--muted);
  margin: 6px 0 0;
}

.quickstart-panel {
  grid-column: 1 / -1;
}

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

.metrics article {
  display: grid;
  gap: 8px;
  padding: 18px;
}

.metrics span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.metrics strong {
  color: var(--brand);
  font-size: 30px;
}

.module-tabs {
  align-items: center;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px;
}

.module-tabs button {
  background: transparent;
  color: var(--muted);
  min-height: 36px;
  white-space: nowrap;
}

.module-tabs button:hover,
.module-tabs button.active {
  background: linear-gradient(135deg, var(--brand), #0d6385);
  color: #fff;
}

.workspace {
  display: block;
}

.admin-panel {
  display: grid;
  gap: 18px;
}

.admin-section {
  display: none;
  gap: 18px;
  grid-template-columns: minmax(360px, 0.85fr) minmax(480px, 1.15fr);
}

.admin-section.active {
  display: grid;
}

.admin-section[data-admin-section="rules"] {
  grid-template-columns: 1fr;
}

.admin-section[data-admin-section="operations"] {
  grid-template-columns: 1fr;
}

.admin-section[data-admin-section="analysis"] {
  grid-template-columns: 1fr;
}

.full-admin-panel {
  min-height: 520px;
}

.admin-section[data-admin-section="rules"] .panel:first-child {
  order: 2;
}

.admin-section[data-admin-section="rules"] #ruleForm {
  order: 1;
}

.module-section {
  display: none;
}

.module-section.active {
  display: block;
}

.panel {
  min-height: 360px;
  padding: 18px;
}

.editor-form {
  display: grid;
  gap: 16px;
}

.embedded-form {
  border: 0;
  box-shadow: none;
  min-height: 0;
  padding: 0;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.admin-section[data-admin-section="rules"] .form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.full-field {
  display: grid;
  gap: 6px;
}

.diagnostic {
  background: #f8fbfd;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: #1f2933;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.rule-rows {
  display: grid;
  gap: 12px;
}

.rule-row {
  background: #fbfdfe;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns:
    minmax(72px, 0.5fr)
    minmax(96px, 0.7fr)
    minmax(150px, 1.1fr)
    minmax(150px, 1.1fr)
    minmax(150px, 1fr)
    minmax(150px, 1fr)
    minmax(96px, 0.65fr)
    minmax(92px, 0.6fr)
    minmax(120px, 0.8fr)
    minmax(102px, 0.65fr);
  padding: 10px;
}

.rule-row label {
  display: grid;
  gap: 4px;
}

.rule-row label span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
}

.rule-row input,
.rule-row select {
  min-height: 38px;
  padding: 0 10px;
}

.rule-row .danger {
  align-self: end;
  background: #f8e8e6;
  color: #8a1f17;
  min-height: 38px;
  padding: 0 10px;
}

.rule-row .danger:hover {
  background: #f2d2ce;
}

.store-mapping-row {
  grid-template-columns:
    minmax(160px, 1fr)
    minmax(180px, 1.4fr)
    minmax(140px, 0.8fr)
    minmax(150px, 0.8fr)
    minmax(102px, 0.65fr);
}

.compact-list {
  margin-top: 14px;
}

.compact-item {
  min-height: 0;
  padding: 12px 14px;
}

.rule-card {
  gap: 14px;
}

.admin-section[data-admin-section="rules"] .rule-card {
  gap: 12px;
}

.rule-card-head {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(240px, 1fr) auto minmax(210px, auto);
}

.rule-lines {
  display: grid;
  gap: 8px;
}

.rule-line {
  background: #f8fbfd;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns:
    minmax(70px, 0.5fr)
    minmax(90px, 0.65fr)
    minmax(130px, 1fr)
    minmax(130px, 1fr)
    minmax(120px, 0.9fr)
    minmax(120px, 0.9fr)
    minmax(86px, 0.55fr)
    minmax(76px, 0.5fr)
    minmax(90px, 0.65fr)
    minmax(84px, 0.55fr);
  padding: 10px;
}

.admin-section[data-admin-section="rules"] .rule-line {
  grid-template-columns:
    minmax(70px, 0.5fr)
    minmax(90px, 0.65fr)
    minmax(130px, 1fr)
    minmax(130px, 1fr)
    minmax(120px, 0.9fr)
    minmax(120px, 0.9fr)
    minmax(86px, 0.55fr)
    minmax(76px, 0.5fr)
    minmax(90px, 0.65fr)
    minmax(84px, 0.55fr);
}

.rule-line span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
  min-width: 0;
}

.rule-line b {
  color: #1f2933;
  display: block;
  font-size: 11px;
  white-space: nowrap;
}

.list {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.item {
  background: #fff;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  padding: 14px;
}

.item-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}

.badge {
  background: var(--brand-soft);
  border-radius: 999px;
  color: var(--brand);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 8px;
}

.badge.ok {
  background: #def3ec;
  color: var(--success);
}

.badge.warn {
  background: #fdf0d5;
  color: #9a6700;
}

.badge.off {
  background: #eef1f3;
  color: var(--muted);
}

.health-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.health-badge {
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
}

.health-badge.ok {
  background: #def3ec;
  color: var(--success);
}

.health-badge.off {
  background: #fde4e1;
  color: #b42318;
}

.integrations-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 4px;
}

.ghost.small {
  font-size: 12px;
  padding: 4px 10px;
}

button.warn-action {
  background: #e08a00;
  color: #fff;
}

button.warn-action:hover {
  background: #c67900;
}

.admin-runs {
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
}

.admin-runs h3 {
  margin: 0 0 8px;
}

.admin-runs h3 small {
  color: var(--muted);
  font-weight: 400;
}

.runs-alert {
  background: #fdecec;
  color: #b3261e;
  border: 1px solid #f0b4b0;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  font-size: 13px;
  line-height: 1.5;
}

.runs-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 360px;
  overflow-y: auto;
}

.run-line {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 5px 8px;
  border-radius: 6px;
  font-size: 12px;
  border-left: 3px solid transparent;
}

.run-line.run-ok { border-left-color: #1e7e34; background: #fbfdfb; }
.run-line.run-fail { border-left-color: #c0392b; background: #fdf6f6; }

.run-when { color: var(--muted); min-width: 130px; }
.run-dir { font-weight: 600; min-width: 70px; }

.run-src {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
}
.run-src.auto { background: #e6f0fb; color: #1d5fa8; }
.run-src.manual { background: #eee; color: #555; }

.run-status {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
}
.run-status.ok { background: #e7f6ec; color: #1e7e34; }
.run-status.fail { background: #fdecec; color: #b3261e; }

.run-msg { color: var(--muted); flex: 1 1 240px; }

.env-banner {
  margin: 0 0 12px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
}

.env-banner.env-hml {
  background: #e7f6ec;
  color: #1e7e34;
  border-color: #b6e0c2;
}

.env-banner.env-blocked {
  background: #fdf0e3;
  color: #9a5b00;
  border-color: #f0cda0;
}

.env-banner.env-prod {
  background: #fdecec;
  color: #b3261e;
  border-color: #f0b4b0;
}

.schedule-panel {
  margin: 10px 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.schedule-panel summary {
  cursor: pointer;
  font-weight: 600;
}

.schedule-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 6px 0;
}

.schedule-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 4px 0;
}

.schedule-toggle {
  min-width: 230px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.schedule-warn {
  font-size: 11px;
  color: #fff;
  background: #c0392b;
  padding: 1px 6px;
  border-radius: 10px;
}

.schedule-status {
  font-size: 12px;
  color: var(--muted);
}

.schedule-status.on { color: var(--success); }
.schedule-status.fail { color: #c0392b; }
.schedule-status.off { color: #99a; }

.schedule-msg {
  font-size: 12px;
  margin-top: 6px;
}

button.danger {
  background: #c0392b;
  color: #fff;
}

button.danger:hover {
  background: #a52f22;
}

.actions-danger {
  border-top: 1px dashed #f1d3ce;
  margin-top: 6px;
  padding-top: 10px;
}

.integration-card.status-disabled {
  opacity: 0.62;
}

.token-hint {
  align-self: center;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.link-sku {
  background: none;
  border: 0;
  color: var(--brand);
  cursor: pointer;
  font-weight: 700;
  min-height: auto;
  padding: 0;
  text-align: left;
  text-decoration: underline dotted;
}

.link-sku:hover {
  background: none;
  color: var(--accent);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 30, 40, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 22px 24px;
  max-width: 440px;
  width: 90%;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.modal-box h3 {
  margin: 0 0 8px;
  color: var(--brand);
}

.modal-box p {
  margin: 0 0 18px;
  color: var(--muted);
  line-height: 1.45;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.build-badge {
  background: #eef7fb;
  border: 1px solid #c9e3ed;
  border-radius: 999px;
  color: #24547a;
  display: inline-flex;
  font-size: 12px;
  font-weight: 700;
  margin-top: 10px;
  padding: 5px 9px;
}

.build-badge.badge-prod {
  background: #fdecec;
  border-color: #f0b4b0;
  color: #b3261e;
}

.build-badge.badge-hml {
  background: #e7f6ec;
  border-color: #b6e0c2;
  color: #1e7e34;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.products-panel {
  display: grid;
  gap: 14px;
  margin-top: 16px;
}

.product-toolbar {
  align-items: center;
  background: #f8fbfd;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
}

.product-toolbar span {
  color: var(--muted);
  font-weight: 700;
}

.analysis-controls {
  align-items: end;
  background: #f8fbfd;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(260px, 1fr) auto;
  padding: 12px;
}

.analysis-controls label {
  display: grid;
  gap: 6px;
}

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

.analysis-card {
  background: #fff;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 12px;
}

.analysis-card h3 {
  color: var(--brand);
  font-size: 15px;
  margin: 0;
}

.analysis-table {
  border: 1px solid #d7e7ee;
  border-radius: 8px;
  display: grid;
  overflow: auto;
}

.analysis-filterbar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.analysis-filterbar button {
  padding: 9px 12px;
}

.analysis-filterbar span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  margin-left: auto;
}

.analysis-head,
.analysis-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 120px minmax(210px, 1fr) 100px 100px 90px 100px 110px 110px 84px 84px 130px minmax(220px, 1fr);
  min-width: 1480px;
  padding: 10px 12px;
}

.analysis-head {
  background: #eef6fa;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.table-sort {
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
  padding: 0;
  text-align: left;
  text-transform: inherit;
}

.table-sort:hover {
  color: var(--brand);
}

.analysis-row {
  background: #fff;
  border-bottom: 1px solid #edf4f7;
  border-left: 4px solid #cbdde4;
}

.analysis-row:last-child {
  border-bottom: 0;
}

.analysis-row.new,
.analysis-row.changed {
  border-left-color: var(--accent);
}

.analysis-row.blocked,
.analysis-row.invalid {
  border-left-color: #b42318;
}

.analysis-row.unchanged {
  border-left-color: var(--success);
}

.analysis-row strong,
.analysis-row span,
.analysis-row small {
  overflow-wrap: anywhere;
}

.analysis-row small {
  color: var(--muted);
}

.product-summary {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.product-summary article {
  background: #fff;
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 12px;
}

.product-summary span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.product-summary strong {
  color: var(--brand);
  font-size: 24px;
}

.product-summary.compact {
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.product-table {
  display: grid;
  gap: 8px;
}

.product-row {
  align-items: center;
  background: #fff;
  border: 1px solid #dfeaf0;
  border-left: 4px solid #cbdde4;
  border-radius: 8px;
  display: grid;
  gap: 10px;
  grid-template-columns: 150px minmax(260px, 1fr) 110px 90px 130px minmax(220px, 0.9fr);
  padding: 10px 12px;
}

.product-row.new,
.product-row.changed {
  border-left-color: var(--accent);
}

.product-row.blocked,
.product-row.invalid {
  border-left-color: #b42318;
}

.product-row.unchanged {
  border-left-color: var(--success);
}

.product-row strong,
.product-row span,
.product-row small {
  overflow-wrap: anywhere;
}

.product-row small {
  color: var(--muted);
}

.sync-feedback {
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
  margin: 14px 0 0;
  padding: 12px 14px;
}

.sync-info {
  background: #eef7fb;
  border-color: #c9e3ed;
  color: #24547a;
}

.sync-success {
  background: #edf8f4;
  border-color: #bfe5d7;
  color: #11684f;
}

.sync-error {
  background: #fff4f2;
  border-color: #f4c7c0;
  color: #a23125;
}

.sync-preview {
  background: #fbfdfe;
  border: 1px solid #d7e7ee;
  border-radius: 8px;
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
}

.readiness-panel {
  border-top: 1px solid #e1edf2;
  display: grid;
  gap: 14px;
  margin-top: 14px;
  padding-top: 14px;
}

.readiness-score {
  align-items: center;
  background: linear-gradient(135deg, #eef8fb, #f8fcfd);
  border: 1px solid #cfe7ef;
  border-radius: 8px;
  display: flex;
  gap: 12px;
  padding: 14px;
}

.readiness-score strong {
  color: var(--brand);
  font-size: 34px;
}

.readiness-score span {
  color: var(--muted);
  font-weight: 700;
}

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

.readiness-item {
  border: 1px solid #dfeaf0;
  border-radius: 8px;
  display: grid;
  gap: 6px;
  padding: 12px;
}

.readiness-item.ready {
  background: #f0fbf7;
  border-color: #bfe5d7;
}

.readiness-item.pending {
  background: #fff8ee;
  border-color: #f2d2a3;
}

.readiness-item strong {
  color: #1f2933;
  font-size: 13px;
}

.readiness-item span {
  color: var(--brand);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.readiness-item small {
  color: var(--muted);
  line-height: 1.35;
}

.preview-block {
  display: grid;
  gap: 8px;
}

.preview-block h3 {
  color: var(--brand);
  font-size: 14px;
  margin: 0;
}

.preview-block ul {
  margin: 0;
  padding-left: 18px;
}

.preview-block li,
.preview-block p {
  color: var(--muted);
  margin: 0;
}

.preview-block pre {
  background: #0b1d2b;
  border-radius: 8px;
  color: #dff7fb;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  margin: 0;
  overflow: auto;
  padding: 10px;
  white-space: pre-wrap;
}

.preview-table {
  border: 1px solid #d7e7ee;
  border-radius: 8px;
  display: grid;
  gap: 0;
  overflow: auto;
}

.preview-table-head,
.preview-table-row {
  align-items: center;
  display: grid;
  gap: 10px;
  min-width: 980px;
  padding: 10px 12px;
}

.preview-table-head {
  background: #eef6fa;
  border-bottom: 1px solid #d7e7ee;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.preview-table-row {
  background: #fff;
  border-bottom: 1px solid #edf4f7;
  border-left: 4px solid #cbdde4;
}

.preview-table-row:last-child {
  border-bottom: 0;
}

.preview-table-row.new,
.preview-table-row.changed {
  border-left-color: var(--accent);
}

.preview-table-row.blocked,
.preview-table-row.invalid {
  border-left-color: #b42318;
}

.preview-table-row.unchanged,
.preview-table-row.stock,
.preview-table-row.order {
  border-left-color: var(--success);
}

.preview-table-row strong,
.preview-table-row span,
.preview-table-row small {
  overflow-wrap: anywhere;
}

.preview-table-row small {
  color: var(--muted);
}

.preview-products .preview-table-head,
.preview-products .preview-table-row {
  grid-template-columns: 120px minmax(220px, 1fr) 110px 130px 100px 110px minmax(220px, 0.9fr);
}

.preview-stock .preview-table-head,
.preview-stock .preview-table-row {
  grid-template-columns: 120px 90px 100px 110px 90px 90px 80px 80px 120px minmax(220px, 0.9fr) minmax(260px, 1fr);
  min-width: 1360px;
}

.preview-orders .preview-table-head,
.preview-orders .preview-table-row {
  grid-template-columns: 120px 120px minmax(180px, 1fr) 130px 110px 80px minmax(260px, 1fr);
}

.preview-orphans .preview-table-head,
.preview-orphans .preview-table-row {
  grid-template-columns: 110px minmax(130px, 0.7fr) minmax(220px, 1.3fr) minmax(240px, 1.4fr);
}

.preview-table-row.orphan {
  border-left-color: #b42318;
}

.preview-table-row.review {
  border-left-color: #d9a300;
}

.preview-table-row.linked {
  border-left-color: var(--success);
}

.run-success {
  border-left: 4px solid var(--success);
}

.run-failed {
  border-left: 4px solid #b42318;
}

@media (max-width: 1380px) {
  .admin-section[data-admin-section="rules"] {
    grid-template-columns: 1fr;
  }

  .rule-row {
    grid-template-columns:
      minmax(70px, 0.5fr)
      minmax(90px, 0.65fr)
      repeat(3, minmax(120px, 1fr))
      repeat(3, minmax(86px, 0.6fr))
      minmax(96px, 0.7fr)
      minmax(94px, 0.65fr);
  }

  .rule-row .danger {
    grid-column: span 1;
  }
}

@media (max-width: 1100px) {
  .admin-section[data-admin-section="rules"] {
    grid-template-columns: 1fr;
  }

  .admin-section[data-admin-section="rules"] .form-grid,
  .admin-section[data-admin-section="rules"] .rule-card {
    grid-template-columns: 1fr;
  }

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

  .admin-section[data-admin-section="rules"] .rule-line {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 820px) {
  .app {
    padding: 18px;
  }

  .login-panel {
    margin-top: 4vh;
  }

  .login-hero {
    margin: -18px;
    padding: 22px;
  }

  .login-nav,
  .brand-lockup {
    align-items: flex-start;
    flex-direction: column;
  }

  .login-stage,
  .login-highlights {
    grid-template-columns: 1fr;
  }

  .brand-lockup img,
  .product-logo {
    width: min(100%, 320px);
  }

  .product-logo {
    margin-bottom: 22px;
    padding: 14px 16px;
  }

  .login-product h1 {
    font-size: clamp(36px, 11vw, 54px);
  }

  .topbar,
  .topbar-brand {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-brand img {
    width: min(100%, 260px);
  }

  .input-row,
  .metrics,
  .product-summary,
  .product-summary.compact,
  .product-row,
  .readiness-grid,
  .workspace,
  .admin-panel,
  .admin-section,
  .form-grid,
  .rule-row,
  .rule-line {
    grid-template-columns: 1fr;
  }
}

/* De-para de produtos canal<->ERP (modal de vinculo) */
.link-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
}
.link-table th,
.link-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border, #e2e8f0);
  vertical-align: middle;
}
.link-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface, #fff);
  z-index: 1;
}
.link-table code {
  font-size: 0.82rem;
}
.link-table input {
  padding: 4px 6px;
}
.badge-ok {
  background: #16a34a;
  color: #fff;
}
.link-modal-status.error {
  color: #dc2626;
}
.muted {
  color: var(--muted, #64748b);
}

/* Tela "Vincular produtos da loja" (de-para amigavel para o usuario final) */
.link-item {
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
  background: var(--surface, #fff);
}
.link-item-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.link-item-name { flex: 1 1 320px; min-width: 0; }
.link-item-name code { font-size: 0.78rem; color: var(--muted, #64748b); }
.link-item-sum { flex: 1 1 240px; font-size: 0.9rem; }
.link-item-head > button { flex: 0 0 auto; }
.link-editor {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border, #e2e8f0);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kit-comp {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.kit-prod { flex: 1 1 340px; max-width: 100%; padding: 5px 6px; }
.kit-qty { font-size: 0.82rem; color: var(--muted, #64748b); display: inline-flex; align-items: center; gap: 4px; }
.kit-qty input { width: 64px; padding: 4px 6px; }
button.small { padding: 3px 8px; font-size: 0.8rem; }
.link-help { margin-top: 10px; font-size: 0.82rem; }

/* Cabecalho com select + botoes (form de integracao so abre em Nova/Editar) */
.form-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
