:root {
  color-scheme: light;
  --background: #f3f6fb;
  --foreground: #172033;
  --card: #ffffff;
  --primary: #1557d5;
  --primary-hover: #0f49ba;
  --muted: #647087;
  --soft: #edf1f7;
  --border: #dce3ee;
  --success: #087a59;
  --danger: #c12848;
  --shadow: 0 1px 2px rgba(20, 36, 62, 0.04), 0 8px 28px rgba(37, 61, 96, 0.04);
  --radius: 22px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--background);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--foreground);
  background:
    radial-gradient(circle at 10% 0%, rgba(21, 87, 213, 0.08), transparent 30rem),
    linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
}

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

button,
[role="button"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
[role="button"]:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(75, 130, 233, 0.24);
  outline-offset: 2px;
}

.shell {
  width: min(1480px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 32px;
}

.card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel {
  padding: 24px;
}

.hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  overflow: hidden;
  padding: 22px 28px;
}

.market-stripe {
  position: absolute;
  inset: 0 0 auto;
  height: 4px;
  background: linear-gradient(90deg, #e53238 0 25%, #1557d5 25% 50%, #f5af02 50% 75%, #86b817 75%);
}

.hero-main {
  display: flex;
  align-items: flex-start;
  min-width: 0;
  gap: 16px;
}

.logo {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 13px;
  color: #fff;
  background: var(--primary);
  font-size: 22px;
  font-weight: 800;
  box-shadow: 0 7px 16px rgba(21, 87, 213, 0.2);
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(23px, 2vw, 29px);
  line-height: 1.2;
  letter-spacing: -0.025em;
}

h2 {
  margin-top: 4px;
  font-size: 20px;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

.hero p {
  max-width: 820px;
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  padding: 5px 9px;
  border-radius: 999px;
  color: #24324b;
  background: #e9eef8;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.pill-outline {
  border: 1px solid var(--border);
  background: transparent;
}

.privacy-badge {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  padding: 10px 13px;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--muted);
  background: rgba(248, 250, 253, 0.86);
  font-size: 13px;
  white-space: nowrap;
}

.privacy-badge span {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  color: #fff;
  background: #079669;
  font-size: 12px;
  font-weight: 800;
}

.top-grid,
.rules-grid {
  display: grid;
  gap: 20px;
  margin-top: 20px;
}

.top-grid {
  grid-template-columns: minmax(0, 1.4fr) minmax(340px, 0.6fr);
}

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

.panel-heading {
  margin-bottom: 16px;
}

.split-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.kicker {
  color: #4672bd;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kicker-light {
  color: #afd0ff;
}

.drop-zone {
  display: flex;
  min-height: 210px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 28px;
  border: 2px dashed #b8c7df;
  border-radius: 17px;
  background: linear-gradient(180deg, rgba(245, 248, 253, 0.92), rgba(238, 243, 251, 0.72));
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, box-shadow 160ms ease;
}

.drop-zone:hover,
.drop-zone.dragging {
  border-color: #3972da;
  background: #eef4ff;
  box-shadow: inset 0 0 0 1px rgba(57, 114, 218, 0.12);
}

.drop-zone.loaded {
  border-style: solid;
  border-color: #a9c1e8;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: 15px;
  border-radius: 16px;
  color: #1557d5;
  background: #e4edff;
  font-size: 30px;
  font-weight: 700;
  line-height: 1;
}

.drop-zone strong {
  max-width: 100%;
  overflow: hidden;
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drop-zone > span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
}

.drop-zone .replace-hint {
  margin-top: 15px;
  color: var(--primary);
  font-weight: 700;
}

.column-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 15px;
}

.column-list code {
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--muted);
  background: #f5f7fb;
  font-size: 11px;
}

.formula-card {
  color: #f8fbff;
  border: 1px solid rgba(96, 142, 217, 0.42);
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 100% 0%, rgba(64, 126, 245, 0.36), transparent 17rem),
    linear-gradient(145deg, #14223a, #102b57 62%, #12366f);
  box-shadow: var(--shadow);
}

.formula-card h2 {
  color: #fff;
}

.formula-options {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 22px;
}

.formula-options > div {
  padding: 15px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.055);
}

.formula-options small {
  display: block;
  color: #b9d4fb;
  font-size: 10px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.formula-options strong {
  display: block;
  margin-top: 8px;
  font-size: 25px;
}

.formula-options > span {
  color: #8bb9fa;
}

.formula-steps {
  display: grid;
  gap: 13px;
  margin: 21px 0 0;
  padding: 0;
  list-style: none;
  color: #d6e3f5;
  font-size: 13px;
  line-height: 1.55;
}

.formula-steps li {
  display: flex;
  align-items: flex-start;
  gap: 11px;
}

.formula-steps span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 23px;
  height: 23px;
  border: 1px solid rgba(147, 187, 255, 0.38);
  border-radius: 50%;
  color: #b9d5ff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 10px;
  font-weight: 800;
}

.muted {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.rule-boxes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-top: 19px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #f7f9fc;
}

.rule-boxes small,
.metric small,
.reason-grid small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.rule-boxes strong {
  display: block;
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 18px;
}

textarea {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid #cbd6e5;
  border-radius: 11px;
  color: var(--foreground);
  background: #fff;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.65;
}

textarea::placeholder {
  color: #99a5b7;
}

.textarea-help {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 11px;
}

.text-button {
  cursor: pointer;
  padding: 0;
  border: 0;
  color: var(--primary);
  background: transparent;
  font-size: 11px;
  font-weight: 700;
}

.message-panel {
  margin-top: 20px;
  padding: 20px 24px;
}

.progress-label {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 10px;
  font-size: 13px;
}

.progress-label span {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4eaf3;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #1557d5, #4f8cf5);
  transition: width 120ms linear;
}

.error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.error span {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  color: #fff;
  background: var(--danger);
  font-size: 12px;
  font-weight: 900;
}

.results-panel {
  margin-top: 20px;
}

.actions-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 750;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease, transform 80ms ease;
}

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

.button:disabled {
  cursor: not-allowed;
  opacity: 0.46;
}

.button-primary {
  color: #fff;
  background: var(--primary);
  box-shadow: 0 6px 14px rgba(21, 87, 213, 0.14);
}

.button-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.button-secondary {
  border-color: var(--border);
  color: #31405a;
  background: #fff;
}

.button-secondary:hover:not(:disabled) {
  background: #f4f7fb;
}

.button-ghost {
  min-height: 34px;
  padding: 6px 9px;
  color: var(--primary);
  background: transparent;
}

.button-ghost:hover {
  background: #edf3ff;
}

.empty-state {
  display: flex;
  min-height: 145px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-top: 22px;
  padding: 24px;
  border: 1px dashed #c5d0df;
  border-radius: 13px;
  color: var(--muted);
  background: #f9fafc;
  text-align: center;
  font-size: 13px;
}

.empty-state span {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  margin-bottom: 8px;
  border: 1px solid #9caabd;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.metric {
  min-height: 83px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #f9fafc;
}

.metric strong,
.reason-grid strong {
  display: block;
  margin-top: 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 21px;
  line-height: 1.2;
}

.metric-success {
  border-color: rgba(5, 150, 105, 0.28);
  color: var(--success);
  background: rgba(5, 150, 105, 0.06);
}

.metric-danger {
  border-color: rgba(217, 45, 79, 0.24);
  color: var(--danger);
  background: rgba(217, 45, 79, 0.05);
}

.reason-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
  margin-top: 12px;
}

.reason-grid > div {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: rgba(247, 249, 252, 0.7);
}

.reason-grid strong {
  font-size: 16px;
}

.preview-card {
  overflow: hidden;
  margin-top: 22px;
  border: 1px solid var(--border);
  border-radius: 13px;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 15px;
  border-bottom: 1px solid var(--border);
  background: #f7f9fc;
  font-size: 12px;
}

.preview-heading span {
  color: var(--muted);
  font-size: 11px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  white-space: nowrap;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid #e7ebf2;
  text-align: left;
}

th {
  color: var(--muted);
  background: #fbfcfe;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.035em;
  text-transform: uppercase;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover {
  background: #f8faff;
}

td {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.number {
  text-align: right;
}

.status {
  display: inline-flex;
  align-items: center;
  padding: 4px 7px;
  border-radius: 999px;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 10px;
  font-weight: 750;
}

.status-included {
  color: #fff;
  background: #079669;
}

.status-excluded {
  color: #9d2941;
  background: #fee9ee;
}

.export-panel {
  display: grid;
  grid-template-columns: minmax(230px, 1fr) minmax(230px, 1fr) auto;
  align-items: end;
  gap: 15px;
  margin-top: 22px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: #f7f9fc;
}

.export-panel label {
  display: grid;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
}

.export-hint {
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

.ad-rate-export {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  margin-top: 13px;
  padding: 15px;
  border: 1px solid #bfd3f5;
  border-radius: 13px;
  background: #f1f6ff;
}

.ad-rate-export-icon {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 11px;
  color: #1557d5;
  background: #dce9ff;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.04em;
}

.ad-rate-export-copy {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.ad-rate-export-copy strong {
  font-size: 13px;
}

.ad-rate-export-copy span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}

select {
  width: 100%;
  min-height: 40px;
  padding: 8px 34px 8px 11px;
  border: 1px solid #cbd6e5;
  border-radius: 9px;
  color: var(--foreground);
  background: #fff;
  font-size: 12px;
}

footer {
  padding: 20px 8px 0;
  color: #8793a6;
  font-size: 11px;
  text-align: center;
}

.noscript {
  position: fixed;
  inset: auto 16px 16px;
  padding: 14px 16px;
  border-radius: 10px;
  color: #fff;
  background: #a92740;
  text-align: center;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1080px) {
  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .top-grid {
    grid-template-columns: 1fr;
  }

  .privacy-badge {
    align-self: stretch;
    justify-content: center;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 22px, 1480px);
    padding-top: 11px;
  }

  .panel,
  .hero {
    padding: 20px;
  }

  .rules-grid {
    grid-template-columns: 1fr;
  }

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

  .actions-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .button-row {
    justify-content: flex-start;
  }

  .export-panel {
    grid-template-columns: 1fr 1fr;
  }

  .export-panel .button {
    grid-column: 1 / -1;
  }

  .ad-rate-export {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .ad-rate-export .button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .hero-main {
    gap: 12px;
  }

  .logo {
    width: 40px;
    height: 40px;
    font-size: 19px;
  }

  .title-line {
    align-items: flex-start;
  }

  h1 {
    font-size: 20px;
  }

  h2 {
    font-size: 18px;
  }

  .split-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .drop-zone {
    min-height: 190px;
    padding: 22px 14px;
  }

  .drop-zone strong {
    font-size: 14px;
    white-space: normal;
  }

  .formula-options {
    gap: 8px;
  }

  .formula-options > div {
    padding: 12px;
  }

  .rule-boxes {
    grid-template-columns: 1fr;
  }

  .metrics,
  .reason-grid,
  .export-panel {
    grid-template-columns: 1fr;
  }

  .button-row,
  .button-row .button,
  .export-panel .button {
    width: 100%;
  }

  .ad-rate-export {
    grid-template-columns: 1fr;
  }

  .ad-rate-export-icon {
    display: none;
  }

  .ad-rate-export .button {
    width: 100%;
  }

  .textarea-help {
    align-items: flex-start;
    flex-direction: column;
  }
}
