.points-app {
  background:
    radial-gradient(circle at 64% 0%, rgba(var(--blue-rgb), 0.05), transparent 28%),
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}

.active-menu {
  background: var(--blue-soft);
  color: var(--blue-deep) !important;
  font-weight: 800;
}

.points-top-actions {
  gap: 12px;
}

.toolbar-btn {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: #0f172a;
  font-weight: 800;
}

.toolbar-btn svg,
.tab-arrow svg,
.secondary-action svg,
.review-action svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.points-tabbar {
  gap: 8px;
  padding: 0 16px;
}

.tab-arrow {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fff;
  color: #0f172a;
}

.points-tabbar .tab {
  height: 38px;
  padding: 0 13px;
  background: transparent;
  color: #64748b;
  font-weight: 700;
}

.points-tabbar .active-tab {
  background: #f1f5fb;
  color: var(--blue-ink);
}

.points-page {
  min-height: calc(100vh - 131px);
  padding: clamp(30px, 3vw, 38px) clamp(24px, 3vw, 58px) 84px;
}

.points-shell {
  width: 100%;
  max-width: 1266px;
  margin: 0 auto;
}

.points-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 23px;
}

.points-heading h1 {
  margin: 0;
  color: #0f172a;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 900;
}

.points-heading p {
  margin: 8px 0 0;
  color: #64748b;
}

.edit-status {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 13px;
  border-radius: 999px;
  background: #fff7ed;
  color: #c2410c;
  font-weight: 800;
}

.edit-status svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.edit-status.editing {
  background: #eff6ff;
  color: var(--blue-ink);
}

.edit-status.saved {
  background: #ecfdf5;
  color: #059669;
}

.points-tabs {
  width: fit-content;
  max-width: 100%;
  display: flex;
  gap: 4px;
  padding: 5px;
  margin-bottom: 20px;
  border-radius: 10px;
  background: #f1f5f9;
}

.points-tabs button {
  min-width: 112px;
  height: 34px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #64748b;
  font-weight: 800;
}

.points-tabs button.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}

.editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.05);
}

.editor-bar strong {
  display: block;
  margin-bottom: 3px;
  font-size: 15px;
}

.editor-bar span {
  color: #64748b;
  font-size: 12px;
}

.editor-actions {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.editor-actions [hidden] {
  display: none !important;
}

.secondary-action,
.review-action {
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: #fff;
  color: #0f172a;
  font-weight: 800;
}

.review-action {
  border-color: var(--blue-deep);
  background: #0f172a;
  color: #fff;
}

.secondary-action:disabled,
.review-action:disabled,
.primary-action:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.compact-action {
  width: auto;
  min-width: 86px;
  height: 38px;
  padding: 0 17px;
}

.points-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 405px);
  gap: clamp(20px, 2.1vw, 28px);
  align-items: start;
}

.config-stack,
.side-stack {
  display: grid;
  gap: 20px;
}

.points-layout .side-stack {
  position: sticky;
  top: calc(var(--app-chrome-height, 131px) + 24px);
  max-height: calc(100vh - var(--app-chrome-height, 131px) - 48px);
  align-self: start;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  scrollbar-color: #c8cdd4 transparent;
  scrollbar-width: thin;
}

.points-layout .side-stack::-webkit-scrollbar {
  width: 7px;
}

.points-layout .side-stack::-webkit-scrollbar-thumb {
  background: #c7ccd4;
  border-radius: 99px;
}

.settings-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

[data-reward-section][hidden],
[data-reward-divider][hidden],
.reward-empty[hidden] {
  display: none !important;
}

.config-stack .settings-card {
  padding: 30px 35px;
}

.side-card {
  padding: 28px 27px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.setting-row h3,
.reward-section h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 900;
}

.setting-row p,
.section-title p,
.reward-section p,
.side-card p {
  margin: 8px 0 0;
  color: #64748b;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.small-row {
  min-height: 44px;
}

.settings-divider {
  height: 1px;
  margin: 26px 0;
  background: #edf1f6;
}

.reward-empty {
  margin-top: 24px;
  padding: 18px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #f8fafc;
  color: #64748b;
  font-weight: 800;
  text-align: center;
}

.switch {
  position: relative;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch span {
  width: 46px;
  height: 26px;
  display: block;
  border-radius: 999px;
  background: #d9dee7;
  transition: background 0.15s ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.2);
  transition: transform 0.15s ease;
}

.switch input:checked + span {
  background: #22c55e;
}

.switch input:checked + span::after {
  transform: translateX(20px);
}

.section-title h2,
.side-card h2 {
  margin: 0;
  font-size: 24px;
  line-height: 1.15;
  font-weight: 900;
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 26px;
  margin-top: 20px;
}

.checkbox-grid label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #0f172a;
  font-weight: 800;
}

.checkbox-grid input {
  width: 20px;
  height: 20px;
  accent-color: #22c55e;
}

.formula-row,
.rule-grid {
  display: grid;
  gap: 14px;
}

.formula-row {
  grid-template-columns: minmax(120px, 1fr) auto minmax(120px, 1fr) minmax(120px, 1fr) minmax(120px, 1fr);
  align-items: end;
  margin-top: 18px;
}

.compact-formula {
  grid-template-columns: minmax(160px, 0.9fr) minmax(190px, 1fr) minmax(160px, 0.8fr);
}

.agent-deposit-formula {
  grid-template-columns: minmax(130px, 0.8fr) auto minmax(130px, 0.8fr) minmax(190px, 1fr) minmax(150px, 0.8fr);
}

.formula-symbol {
  display: grid;
  place-items: center;
  height: 46px;
  color: #0f172a;
  font-size: 24px;
  font-weight: 500;
}

label > span,
.field-block > span {
  display: block;
  margin-bottom: 8px;
  color: #0f172a;
  font-weight: 800;
}

input,
select {
  min-width: 0;
}

.input-with-unit,
.search-field,
.field-block select,
.cap-row select,
.rule-grid select,
.formula-row select {
  height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.04);
}

.input-with-unit input,
.search-field input {
  width: 100%;
  height: 100%;
  padding: 0 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #0f172a;
  font-size: 16px;
}

.input-with-unit em {
  flex: 0 0 auto;
  padding-right: 14px;
  color: #94a3b8;
  font-style: normal;
  font-weight: 800;
  white-space: nowrap;
}

.field-error {
  border-color: #ef4444 !important;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12) !important;
}

.reward-switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-top: 4px;
}

.commission-table {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.commission-head,
.commission-row {
  display: grid;
  grid-template-columns: minmax(140px, 0.72fr) minmax(280px, 1.45fr) minmax(320px, 1.55fr);
  gap: 18px;
  align-items: center;
}

.commission-head {
  color: #64748b;
  font-weight: 900;
}

.commission-row {
  padding: 14px;
  border: 1px solid #edf1f6;
  border-radius: 12px;
  background: #fbfdff;
}

.readonly-chip {
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
  background: #f8fafc;
  color: #64748b;
  font-weight: 900;
}

.commission-formula,
.cap-row {
  display: grid;
  align-items: center;
  gap: 8px;
}

.commission-formula {
  grid-template-columns: minmax(92px, 0.75fr) auto minmax(120px, 1.2fr);
}

.cap-row {
  grid-template-columns: minmax(150px, 1fr) minmax(138px, 0.75fr);
}

.colon-symbol {
  color: #0f172a;
  font-size: 22px;
  font-weight: 700;
}

.deduction-card {
  display: grid;
  gap: 22px;
}

.deduction-grid,
.exemption-grid {
  display: grid;
  gap: 18px;
}

.deduction-grid {
  grid-template-columns: minmax(140px, 0.6fr) minmax(140px, 0.6fr) minmax(0, 1fr);
}

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

.tag-select {
  min-height: 58px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 2px 7px rgba(15, 23, 42, 0.04);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 0 11px;
  border-radius: 7px;
  background: #14b8a6;
  color: #fff;
  font-weight: 900;
  white-space: nowrap;
}

.tag-editor,
.tag-select input {
  flex: 1 1 120px;
  min-width: 110px;
  height: 32px;
  border: 0;
  outline: 0;
  background: transparent;
  color: #0f172a;
  font-size: 14px;
}

select {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  font-size: 15px;
}

.rule-card {
  margin-top: 20px;
  padding: 18px;
  border: 1px solid #edf1f6;
  border-radius: 13px;
  background: #fbfdff;
}

.rule-card.is-new {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.rule-card.invalid,
[data-reward-section].invalid {
  border-color: #ef4444;
}

.rule-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.rule-card-head strong {
  color: var(--blue-deep);
  font-size: 15px;
}

.remove-rule {
  height: 32px;
  padding: 0 11px;
  border: 1px solid #fecaca;
  border-radius: 7px;
  background: #fff;
  color: #dc2626;
  font-weight: 800;
}

.remove-rule:hover {
  background: #fff1f2;
}

.remove-rule:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  background: #f8fafc;
}

.top-rule {
  grid-template-columns: minmax(240px, 1fr) minmax(240px, 1fr);
  margin-bottom: 18px;
}

.bottom-rule {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.search-field svg {
  width: 18px;
  height: 18px;
  margin-right: 14px;
  fill: none;
  stroke: #64748b;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.add-rule {
  height: 40px;
  margin-top: 16px;
  padding: 0 15px;
  border: 1px dashed #94a3b8;
  border-radius: 8px;
  background: #fff;
  color: var(--blue-ink);
  font-weight: 800;
}

.add-rule:disabled {
  opacity: 0.5;
}

.side-title {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.chip {
  height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.chip.success {
  color: #047857;
  background: #d1fae5;
}

.note-box {
  margin: 18px 0 23px;
  padding: 16px;
  border-radius: 10px;
  background: #f8fafc;
  color: #64748b;
  line-height: 1.65;
}

.subscription span {
  display: block;
  color: #64748b;
}

.subscription strong {
  display: block;
  margin-top: 7px;
  font-size: 32px;
  line-height: 1;
  font-weight: 900;
}

.subscription em {
  font-size: 15px;
  font-style: normal;
}

.subscription p {
  margin: 8px 0 22px;
  color: #0f172a;
}

.field-block {
  display: block;
  margin-top: 22px;
}

.audit-card {
  display: grid;
  gap: 18px;
}

.audit-step {
  display: flex;
  gap: 13px;
}

.audit-step > span {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-weight: 900;
}

.audit-step.active > span {
  background: var(--blue);
  color: #fff;
}

.audit-step strong {
  display: block;
  margin-bottom: 3px;
}

.audit-step p {
  margin: 0;
  font-size: 12px;
}

.points-app[data-editing="false"] [data-editable],
.points-app[data-editing="false"] .add-rule {
  cursor: not-allowed;
}

.points-app[data-editing="false"] [data-editable] {
  color: #64748b;
}

.points-app[data-editing="false"] .switch span,
.points-app[data-editing="false"] .checkbox-grid input {
  opacity: 0.72;
}

.points-app[data-editing="true"] .settings-card {
  box-shadow: 0 16px 38px rgba(37, 99, 235, 0.08);
}

.points-app[data-dirty="true"] .editor-bar {
  border-color: #bfdbfe;
  background: #f8fbff;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 320px;
  padding: 14px 16px;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  background: #fff;
  color: #0f172a;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .points-layout {
    grid-template-columns: 1fr;
  }

  .side-stack {
    position: static;
    max-height: none;
    overflow: visible;
    padding-right: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .points-page {
    padding: 26px 16px 42px;
  }

  .points-top-actions .toolbar-btn,
  .points-top-actions .language {
    display: none;
  }

  .points-heading,
  .editor-bar,
  .setting-row {
    flex-direction: column;
    align-items: stretch;
  }

  .editor-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    justify-content: stretch;
    width: 100%;
  }

  .editor-actions button {
    width: 100%;
    min-width: 0;
  }

  .review-action {
    grid-column: 1 / -1;
  }

  .config-stack .settings-card,
  .side-card {
    padding: 24px 18px;
  }

  .side-stack,
  .checkbox-grid,
  .formula-row,
  .commission-row,
  .commission-formula,
  .cap-row,
  .deduction-grid,
  .exemption-grid,
  .top-rule,
  .bottom-rule {
    grid-template-columns: 1fr;
  }

  .commission-head {
    display: none;
  }

  .reward-switch-row {
    flex-direction: column;
    align-items: stretch;
  }

  .formula-symbol {
    height: auto;
    justify-content: start;
  }
}

@media (max-width: 640px) {
  html,
  body,
  .app,
  .points-page,
  .points-shell {
    width: 100%;
    max-width: 100%;
  }

  .points-page * {
    max-width: 100%;
  }

  .points-page {
    width: 100vw;
    padding: 22px 12px 34px;
    overflow: hidden;
  }

  .points-shell {
    max-width: calc(100vw - 24px);
  }

  .points-heading h1 {
    font-size: 26px;
  }

  .points-tabs {
    width: 100%;
    overflow: hidden;
  }

  .points-tabs button {
    flex: 1;
    min-width: 0;
    padding: 0 8px;
    font-size: 13px;
  }

  .points-tabbar {
    overflow: hidden;
  }

  .points-tabbar .tab {
    min-width: 0;
  }

  .points-tabbar .muted-tab {
    display: none;
  }

  .editor-actions {
    grid-template-columns: 1fr;
  }

  .review-action {
    grid-column: auto;
  }
}
