:root {
  color-scheme: light;
  --bg: #f7f4ec;
  --bg-strong: #efe8da;
  --surface: rgba(255, 250, 240, 0.82);
  --surface-strong: #fffaf0;
  --surface-ink: #15231e;
  --muted: #5d6a63;
  --line: rgba(21, 35, 30, 0.12);
  --line-strong: rgba(21, 35, 30, 0.18);
  --brand: #145c4b;
  --brand-strong: #0f4b3d;
  --brand-soft: #d8efe8;
  --warn: #b6551d;
  --warn-soft: #f9e1d2;
  --danger: #9d2f2f;
  --danger-soft: #f7dddd;
  --shadow: 0 24px 60px rgba(37, 36, 28, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: 'IBM Plex Sans', sans-serif;
  color: var(--surface-ink);
  background:
    radial-gradient(circle at top left, rgba(20, 92, 75, 0.18), transparent 34%),
    radial-gradient(circle at right 10% top 15%, rgba(182, 85, 29, 0.18), transparent 22%),
    linear-gradient(180deg, #f9f6ee 0%, #f4efe3 45%, #efe6d6 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.page-shell {
  position: relative;
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px 72px;
}

.ambient {
  position: fixed;
  inset: auto;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  filter: blur(24px);
  opacity: 0.45;
  pointer-events: none;
  z-index: -1;
}

.ambient-left {
  top: -90px;
  left: -110px;
  background: rgba(20, 92, 75, 0.18);
}

.ambient-right {
  top: 120px;
  right: -110px;
  background: rgba(182, 85, 29, 0.18);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(300px, 420px);
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.hero-copy,
.panel {
  position: relative;
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.hero-copy {
  padding: 34px;
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.hero-copy::after {
  content: '';
  position: absolute;
  inset: auto 24px 20px auto;
  width: 180px;
  height: 180px;
  border-radius: 32px;
  background:
    linear-gradient(135deg, rgba(20, 92, 75, 0.12), rgba(182, 85, 29, 0.18)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180' fill='none'%3E%3Cpath d='M31 43c28-16 69-11 87 14 15 20 13 52-4 73-24 30-74 37-105 9C-6 123-2 92 18 72c13-13 11-19 13-29Z' stroke='%23145c4b' stroke-opacity='.18' stroke-width='2'/%3E%3Cpath d='M95 36c15 10 28 26 31 46' stroke='%23b6551d' stroke-opacity='.2' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M47 112c8 11 20 18 34 21' stroke='%23145c4b' stroke-opacity='.22' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
  opacity: 0.95;
}

.hero h1,
.panel h2,
.result-card h3,
.match-header h3 {
  font-family: 'Space Grotesk', sans-serif;
}

.hero h1 {
  max-width: 10ch;
  margin: 10px 0 16px;
  font-size: clamp(2.5rem, 4vw, 4.6rem);
  line-height: 0.96;
  letter-spacing: -0.05em;
}

.eyebrow,
.panel-label {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand);
}

.hero-text,
.helper-text,
.feature-list,
.save-status,
.rule-meta {
  color: var(--muted);
}

.hero-text {
  max-width: 62ch;
  font-size: 1.05rem;
  line-height: 1.7;
}

.hero-actions,
.toolbar,
.rule-actions-row,
.save-status-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.panel {
  border-radius: var(--radius-lg);
  padding: 24px;
}

.panel-glass {
  padding: 24px;
}

.feature-list {
  padding-left: 18px;
  line-height: 1.7;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(320px, 0.85fr);
  gap: 24px;
  align-items: start;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
}

.product-input,
.rule-form input,
.rule-form select,
.rule-form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--surface-ink);
  transition: border-color 180ms ease, box-shadow 180ms ease, transform 180ms ease;
}

.product-input {
  min-height: 280px;
  resize: vertical;
  line-height: 1.6;
}

.product-input:focus,
.rule-form input:focus,
.rule-form select:focus,
.rule-form textarea:focus {
  outline: none;
  border-color: rgba(20, 92, 75, 0.6);
  box-shadow: 0 0 0 5px rgba(20, 92, 75, 0.12);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.stat-card {
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
}

.stat-label {
  margin: 0 0 10px;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 2rem);
  font-weight: 700;
}

.result-panel {
  position: sticky;
  top: 20px;
}

.status-pill,
.rule-kind-badge,
.match-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 700;
}

.status-pill {
  min-width: 124px;
}

.status-approved,
.kind-exception {
  background: var(--brand-soft);
  color: var(--brand-strong);
}

.status-warning {
  background: var(--warn-soft);
  color: var(--warn);
}

.status-blocked,
.kind-blocked,
.button-danger {
  background: var(--danger-soft);
  color: var(--danger);
}

.status-loading {
  background: rgba(21, 35, 30, 0.08);
  color: var(--muted);
}

.result-card {
  border-radius: var(--radius-lg);
  padding: 22px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--line);
  margin-bottom: 18px;
  transform: translateY(0);
  animation: rise-in 480ms ease;
}

.result-approved {
  background: linear-gradient(180deg, rgba(216, 239, 232, 0.8), rgba(255, 255, 255, 0.96));
}

.result-warning {
  background: linear-gradient(180deg, rgba(249, 225, 210, 0.8), rgba(255, 255, 255, 0.96));
}

.result-blocked {
  background: linear-gradient(180deg, rgba(247, 221, 221, 0.86), rgba(255, 255, 255, 0.96));
}

.result-loading {
  opacity: 0.72;
}

.result-card h3 {
  margin: 0 0 10px;
  font-size: 1.45rem;
}

.result-card p {
  margin: 0;
  line-height: 1.7;
}

.match-section {
  display: grid;
  gap: 14px;
}

.match-block {
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
  padding: 16px;
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.match-header h3 {
  margin: 0;
  font-size: 1rem;
}

.match-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.match-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.88);
}

.match-chip strong {
  font-size: 0.95rem;
}

.match-chip span {
  font-size: 0.84rem;
  color: var(--muted);
}

.empty-state {
  color: var(--muted);
}

.rules-panel {
  margin-top: 24px;
}

.rules-heading {
  align-items: flex-end;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.78);
  overflow: hidden;
}

.rule-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  cursor: pointer;
  list-style: none;
}

.rule-summary::-webkit-details-marker {
  display: none;
}

.rule-title {
  display: block;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1.05rem;
}

.rule-meta {
  margin: 6px 0 0;
  font-size: 0.88rem;
}

.rule-form {
  display: grid;
  gap: 14px;
  padding: 0 20px 20px;
}

.rule-form label {
  display: grid;
  gap: 8px;
}

.rule-form label span {
  font-size: 0.88rem;
  font-weight: 600;
}

.button {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease, border-color 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(21, 35, 30, 0.08);
}

.button-primary {
  background: var(--brand);
  color: #fff7ef;
}

.button-primary:hover {
  background: var(--brand-strong);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.82);
  color: var(--surface-ink);
  border-color: var(--line);
}

.button-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.button-danger {
  border-color: transparent;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
}

.save-status::before {
  content: '';
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.4;
}

.save-status.pending {
  color: var(--warn);
}

.save-status.error {
  color: var(--danger);
}

.save-status.ready {
  color: var(--brand);
}

.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;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1080px) {
  .hero,
  .layout,
  .rules-grid {
    grid-template-columns: 1fr;
  }

  .result-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 18px 14px 42px;
  }

  .hero-copy,
  .panel {
    padding: 20px;
  }

  .hero h1 {
    max-width: none;
    font-size: 2.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .panel-heading,
  .rules-heading,
  .toolbar,
  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .button {
    width: 100%;
    justify-content: center;
  }
}