:root {
  --bg: #f4f7fa;
  --surface: #fff;
  --surface2: #f8fafc;
  --surface3: #eef3f7;
  --text: #101d2c;
  --muted: #68798b;
  --line: #dbe4ec;
  --line2: #c9d6e1;
  --blue: #159fe0;
  --blue2: #087fbd;
  --blueSoft: #eaf7fd;
  --green: #119b6d;
  --greenSoft: #e8f8f1;
  --amber: #d88900;
  --amberSoft: #fff5df;
  --red: #d94c4c;
  --redSoft: #fdecec;
  --shadow: 0 8px 28px rgba(20, 44, 68, 0.07);
}
html.dark {
  --bg: #071521;
  --surface: #0d1f2e;
  --surface2: #102638;
  --surface3: #142d41;
  --text: #edf6fc;
  --muted: #9cafc0;
  --line: #284154;
  --line2: #38566b;
  --blue: #19a9eb;
  --blue2: #0c8fca;
  --blueSoft: #0b3149;
  --green: #24c58d;
  --greenSoft: #0c392e;
  --amber: #f0ad35;
  --amberSoft: #3c2d10;
  --red: #ff7373;
  --redSoft: #421f22;
  --shadow: 0 12px 34px rgba(0, 0, 0, 0.2);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font:
    14px/1.45 -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    Helvetica,
    Arial,
    sans-serif;
}
button,
input,
select {
  font: inherit;
}
button {
  cursor: pointer;
}
.header {
  height: 68px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 20px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand-logo {
  height: 32px;
  width: auto;
  display: block;
  object-fit: contain;
}
.logo-light {
  display: block;
}
.logo-dark {
  display: none;
}
html.dark .logo-light {
  display: none;
}
html.dark .logo-dark {
  display: block;
}
.divider {
  height: 30px;
  width: 1px;
  background: var(--line);
}
.product {
  font-weight: 750;
  letter-spacing: -0.1px;
}
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  height: 36px;
  width: 36px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 16px;
  padding: 0;
}
.user {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
}
.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--blueSoft);
  color: var(--blue2);
  display: grid;
  place-items: center;
  font-weight: 800;
}
.main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 32px 60px;
}
.stepbar {
  height: 76px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--line);
  margin-bottom: 24px;
}
.steps {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}
.step {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-weight: 650;
  white-space: nowrap;
}
.step .circle {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--line2);
  display: grid;
  place-items: center;
  font-size: 12px;
  background: var(--surface);
}
.step.active {
  color: var(--text);
}
.step.active .circle {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.step.done {
  color: var(--green);
}
.step.done .circle {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}
.connector {
  height: 1px;
  background: var(--line2);
  flex: 1;
  margin: 0 18px;
}
.connector.done {
  background: var(--green);
}
.page {
  max-width: 1200px;
  margin: 0 auto;
}
.eyebrow {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 8px;
}
h1 {
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: -0.8px;
  margin: 0 0 16px;
}
.screen {
  display: none;
}
.screen.active {
  display: block;
}
.content-center {
  width: 100%;
  margin: 24px 0 0;
}
.company-shell {
  width: 100%;
  margin: 24px 0 0;
}
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  width: 100%;
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}
.upload-card {
  padding: 20px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  align-items: flex-start;
  margin-bottom: 16px;
}
.card-title {
  font-weight: 800;
  font-size: 15px;
}
.card-copy {
  color: var(--muted);
  font-size: 12px;
  margin-top: 4px;
  line-height: 1.5;
}
.required {
  font-size: 10px;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 7px;
  border-radius: 99px;
}
.drop {
  min-height: 340px;
  border: 1.5px dashed var(--line2);
  border-radius: 11px;
  background: var(--surface2);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 20px;
  transition: 0.2s;
  cursor: pointer;
}
.drop:hover {
  border-color: var(--blue);
  background: var(--blueSoft);
}
.drop.dragover {
  border-color: var(--blue);
  background: var(--blueSoft);
}
.drop-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: var(--blueSoft);
  color: var(--blue);
  display: grid;
  place-items: center;
  font-size: 26px;
  margin: 0 auto 14px;
}
.drop strong {
  display: block;
  font-size: 13px;
}
.drop a {
  color: var(--blue2);
  font-weight: 800;
  cursor: pointer;
  text-decoration: underline;
}
.drop small {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 6px;
}
.file {
  margin-top: 10px;
  border: 1px solid var(--line);
  background: var(--surface2);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-list {
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}
.file-list .file:first-child {
  margin-top: 10px;
}
.file-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--greenSoft);
  color: var(--green);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.file-name {
  font-weight: 700;
  font-size: 12px;
}
.file-meta {
  font-size: 10px;
  color: var(--muted);
  margin-top: 2px;
}
.file-x {
  margin-left: auto;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
}
.actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 20px;
  width: 100%;
}
.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 6px;
  padding: 11px 20px;
  font-weight: 750;
}
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 5px 15px rgba(21, 159, 224, 0.2);
}
.btn.primary:hover {
  background: var(--blue2);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.mapping-tools {
  display: grid;
  grid-template-columns: 1fr 200px;
  gap: 10px;
  margin-bottom: 14px;
}
.search {
  position: relative;
}
.search input {
  width: 100%;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  padding: 0 12px 0 35px;
  outline: 0;
}
.search span {
  position: absolute;
  left: 12px;
  top: 9px;
  color: var(--muted);
}
select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--text);
  padding: 0 30px 0 11px;
}
.table-card {
  overflow: hidden;
}
.table-wrap {
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  min-width: 900px;
}
th {
  text-align: left;
  padding: 12px 16px;
  background: var(--surface2);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: var(--muted);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 2;
}
td {
  padding: 12px 16px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  white-space: nowrap;
}
td select {
  height: 34px;
  min-width: 185px;
  font-size: 12px;
}
.maps-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--blueSoft);
  color: var(--blue2);
  border-radius: 99px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 99px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 800;
}
.status-mapped {
  background: var(--greenSoft);
  color: var(--green);
}
.status-suggested {
  background: var(--amberSoft);
  color: var(--amber);
}

.status-unmapped {
  background: var(--redSoft);
  color: var(--red);
}
.mapping-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 15px;
}
.mapping-foot b {
  color: var(--text);
}
.output-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}
.success {
  margin: 20px 0 16px;
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--greenSoft);
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  display: flex;
  gap: 10px;
  align-items: center;
}
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.stat {
  padding: 18px;
}
.stat-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.stat-value {
  font-size: 22px;
  font-weight: 850;
  margin-top: 5px;
  letter-spacing: -0.4px;
}
.company-card {
  padding: 44px;
}
.company-card .card-title {
  font-size: 18px;
}
.company-card .card-copy {
  max-width: none;
  line-height: 1.6;
  margin-top: 6px;
}
.company-select-label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.55px;
  color: var(--muted);
  margin: 36px 0 12px;
}
.company-select {
  width: 100%;
  height: 56px;
  font-size: 13px;
}
.company-proceed {
  margin-top: 32px;
  width: 100%;
  height: 56px;
}
.mapping-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}
.page-btn {
  height: 32px;
  min-width: 32px;
  padding: 0 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  border-radius: 7px;
  font-size: 11px;
  font-weight: 750;
}
.page-btn:hover {
  border-color: var(--blue);
  color: var(--blue);
}
.page-btn.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.page-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.page-info {
  margin-right: auto;
  color: var(--muted);
  font-size: 15px;
}
.global-error {
  margin: 0 0 24px;
  padding: 13px 16px;
  border-radius: 8px;
  background: #fbeae6;
  color: #b4432e;
  font-size: 13.5px;
  line-height: 1.5;
  border: 1px solid #f0c9c0;
}
@media (max-width: 1024px) {
  .upload-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 900px) {
  .main {
    padding: 0 18px 40px;
  }
  .header {
    padding: 0 18px;
  }
  .mapping-tools {
    grid-template-columns: 1fr 1fr;
  }
  .stats {
    grid-template-columns: 1fr 1fr;
  }
}
@media (max-width: 600px) {
  .product,
  .divider,
  .user {
    display: none;
  }
  .stepbar {
    height: 65px;
  }
  .steps {
    justify-content: center;
  }
  .connector {
    margin: 0 8px;
  }
  .step span:last-child {
    display: none;
  }
  .mapping-tools {
    grid-template-columns: 1fr;
  }
  .output-top {
    align-items: flex-start;
    flex-direction: column;
  }
  h1 {
    font-size: 24px;
  }
}

/* ============================================================
   RULE BUILDER MODAL
   ============================================================ */

.modal-overlay {
  position: fixed;
  inset: 0;

  background: rgba(0, 0, 0, 0.55);

  display: none;

  align-items: center;
  justify-content: center;

  z-index: 9999;

  padding: 20px;
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  width: min(560px, 100%);

  max-height: 90vh;

  overflow-y: auto;

  background: var(--surface);

  border: 1px solid var(--line);

  border-radius: 16px;

  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);

  padding: 24px;
}

.modal-head {
  display: flex;

  align-items: flex-start;

  justify-content: space-between;

  gap: 20px;

  margin-bottom: 22px;
}

.modal-title {
  font-size: 17px;

  font-weight: 800;

  color: var(--text);
}

.modal-sub {
  margin-top: 5px;

  font-size: 12px;

  color: var(--muted);
}

.modal-close {
  width: 34px;
  height: 34px;

  border: 0;

  background: transparent;

  color: var(--text);

  font-size: 24px;

  border-radius: 8px;

  display: grid;

  place-items: center;

  cursor: pointer;
}

.modal-close:hover {
  background: var(--surface2);
}

.modal-section-label {
  /* font-size: 11px;

  font-weight: 800;

  color: var(--text);

  text-transform: uppercase;

  margin: 18px 0 9px; */

  display: block;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
  margin: 18px 0 8px;
}

.formula-box {
  width: 100%;

  min-height: 78px;

  resize: vertical;

  padding: 13px;

  border-radius: 10px;

  border: 1px solid var(--line2);

  background: var(--surface2);

  color: var(--text);

  outline: none;

  font-size: 13px;

  line-height: 1.5;
}

.formula-box:focus {
  border-color: var(--blue);
}

.token-row {
  display: flex;

  flex-wrap: wrap;

  gap: 8px;

  max-height: 150px;

  overflow-y: auto;

  padding-right: 4px;
}

.token-btn {
  border: 1px solid var(--line2);

  background: var(--surface2);

  color: var(--text);

  border-radius: 8px;

  padding: 8px 12px;

  font-size: 12px;

  font-weight: 700;

  cursor: pointer;

  transition: 0.15s;
}

.token-btn:hover {
  border-color: var(--blue);

  background: var(--blueSoft);

  color: var(--blue);
}

.token-btn.op {
  min-width: 36px;

  font-size: 15px;
}

.rule-example {
  margin-top: 18px;

  padding: 12px;

  border: 1px solid var(--line);

  border-radius: 10px;

  background: var(--surface2);

  color: var(--muted);

  font-size: 11px;

  line-height: 1.7;
}

.modal-actions {
  display: flex;

  justify-content: flex-end;

  gap: 10px;

  margin-top: 22px;
}

.rule-btn {
  border: 1px dashed var(--line2);

  background: transparent;

  color: var(--text);

  border-radius: 8px;

  padding: 7px 12px;

  font-size: 12px;

  font-weight: 700;

  white-space: nowrap;

  cursor: pointer;
}

.rule-btn:hover {
  border-color: var(--blue);

  color: var(--blue);

  background: var(--blueSoft);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;

  background: rgba(0, 0, 0, 0.35);

  opacity: 0;
  visibility: hidden;

  transition:
    opacity 0.25s ease,
    visibility 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-box {
  position: absolute;
  top: 0;
  right: 0;

  width: 430px;
  max-width: 90vw;
  height: 100vh;
  max-height: 100%;
  margin: 0;

  border-radius: 0;
  border-top-left-radius: 14px;
  border-bottom-left-radius: 14px;

  transform: translateX(100%);
  /* transition: transform 0.3s ease; */
  transition: transform 0.8s ease-out;
  overflow-y: auto;
}

.modal-overlay.active .modal-box {
  transform: translateX(0);
}
.rule-input-select {
  width: 100%;
  height: 40px;

  padding: 0 12px;

  color: var(--text);

  font-size: 14px;

  outline: none;

  cursor: pointer;

  border-radius: 10px;
  border: 1px solid var(--line2);
  background: var(--surface2);
}

.rule-input-select:focus {
  border-color: var(--primary);
}

.rule-input-select option {
  background: var(--surface);
  color: var(--text);
}

.modal-actions {
  padding: 17px 0px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
  /* width: 75%; */
}
