:root {
  color-scheme: light;
  --ink: #25242b;
  --muted: #74717f;
  --faint: #a29eaa;
  --line: #e9e6ec;
  --line-strong: #ded9e4;
  --surface: #ffffff;
  --canvas: #f8f7f5;
  --violet: #6f5bea;
  --violet-dark: #5744d8;
  --violet-soft: #f0edff;
  --green: #2e9b73;
  --green-soft: #e9f8f1;
  --amber: #b87518;
  --amber-soft: #fff6e7;
  --red: #c94f5b;
  --shadow: 0 12px 35px rgba(39, 33, 54, 0.06);
  font-family: "DM Sans", "Noto Sans SC", -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 0%, rgba(111, 91, 234, 0.07), transparent 24rem),
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(1460px, calc(100% - 48px));
  margin: 0 auto;
  padding: 54px 0 72px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 28px;
}

.hero-copy {
  max-width: 780px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 15px;
  color: var(--violet);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.eyebrow-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--violet);
  box-shadow: 0 0 0 5px rgba(111, 91, 234, 0.12);
}

.hero h1 {
  margin: 0;
  font-family: "Noto Sans SC", sans-serif;
  font-size: clamp(28px, 3vw, 43px);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.hero p {
  margin: 13px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 9px;
}

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

.button:hover {
  transform: translateY(-1px);
}

.button.secondary {
  border-color: var(--line-strong);
  background: rgba(255, 255, 255, 0.8);
}

.button.secondary:hover {
  border-color: #c9c1da;
  background: var(--surface);
}

.button.primary {
  color: #fff;
  background: var(--violet);
  box-shadow: 0 7px 18px rgba(111, 91, 234, 0.22);
}

.button.primary:hover {
  background: var(--violet-dark);
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-bottom: 24px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.summary article {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 16px;
  min-height: 98px;
  padding: 22px 24px;
}

.summary article + article::before {
  position: absolute;
  top: 22px;
  bottom: 22px;
  left: 0;
  width: 1px;
  content: "";
  background: var(--line);
}

.summary span {
  align-self: end;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.summary strong {
  grid-row: 1 / span 2;
  grid-column: 2;
  align-self: center;
  font-size: 28px;
  letter-spacing: -0.04em;
}

.summary small {
  color: var(--faint);
  font-size: 11px;
}

.summary article.valid strong {
  color: var(--green);
}

.summary article.warning strong {
  color: var(--amber);
}

.toolbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 58px;
  margin-bottom: 18px;
  padding: 9px 11px;
  border: 1px solid rgba(224, 220, 228, 0.9);
  border-radius: 12px;
  background: rgba(248, 247, 245, 0.92);
  backdrop-filter: blur(18px);
}

.section-tabs,
.view-tabs {
  display: flex;
  align-items: center;
  gap: 3px;
}

.section-tabs button,
.view-tabs button {
  min-height: 36px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.section-tabs button:hover,
.view-tabs button:hover {
  color: var(--ink);
  background: #efedf1;
}

.section-tabs button.active,
.view-tabs button.active {
  color: var(--violet);
  background: var(--violet-soft);
}

.view-tabs b {
  font-weight: 700;
}

.toolbar-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.search-field {
  display: flex;
  align-items: center;
  gap: 7px;
  width: min(240px, 20vw);
  min-width: 175px;
  height: 36px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--faint);
  background: var(--surface);
}

.search-field:focus-within {
  border-color: rgba(111, 91, 234, 0.45);
  box-shadow: 0 0 0 3px rgba(111, 91, 234, 0.08);
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}

.index-panel {
  position: sticky;
  top: 76px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.72);
}

.index-intro {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.index-intro strong {
  font-size: 13px;
}

.index-intro p {
  margin: 6px 0 0;
  color: var(--faint);
  font-size: 11px;
  line-height: 1.65;
}

.index-section {
  padding: 14px 12px 12px;
}

.index-section + .index-section {
  border-top: 1px solid var(--line);
}

.index-section button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 5px 7px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 11px;
  text-align: left;
}

.index-section button:hover {
  color: var(--ink);
  background: #f3f1f5;
}

.index-section button:first-child {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.index-section b {
  color: var(--violet);
  font-size: 10px;
}

.save-status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 8px 12px 12px;
  padding: 12px;
  border: 1px solid #d8eee4;
  border-radius: 9px;
  background: var(--green-soft);
}

.status-check {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--green);
  font-size: 11px;
  font-weight: 700;
}

.save-status strong,
.save-status small {
  display: block;
}

.save-status strong {
  color: #267a5d;
  font-size: 11px;
}

.save-status small {
  margin-top: 3px;
  color: #57927a;
  font-size: 9px;
  line-height: 1.45;
}

.reset-button {
  width: calc(100% - 24px);
  margin: 0 12px 14px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
}

.reset-button:hover {
  color: var(--red);
  border-color: rgba(201, 79, 91, 0.35);
}

.review-content {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.dimension-card,
.loading-card,
.empty-card {
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(40, 34, 55, 0.035);
}

.dimension-card {
  scroll-margin-top: 76px;
  overflow: hidden;
}

.dimension-card.changed {
  border-color: rgba(111, 91, 234, 0.32);
}

.dimension-card.has-issues {
  border-color: rgba(184, 117, 24, 0.38);
}

.dimension-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 24px 17px;
  border-bottom: 3px solid var(--violet);
}

.dimension-heading {
  display: flex;
  align-items: flex-start;
  gap: 13px;
  min-width: 0;
}

.dimension-order {
  display: grid;
  width: 27px;
  height: 27px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--violet);
  background: var(--violet-soft);
  font-size: 10px;
  font-weight: 700;
}

.editable-title input {
  width: min(460px, 55vw);
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 17px;
  font-weight: 700;
}

.editable-title input:focus {
  box-shadow: 0 2px 0 var(--violet);
}

.dimension-id {
  display: block;
  margin-top: 4px;
  color: var(--faint);
  font-family: inherit;
  font-size: 10px;
}

.dimension-total {
  flex: 0 0 auto;
  padding-left: 20px;
  border-left: 1px solid var(--line);
  text-align: right;
}

.dimension-total span {
  display: block;
  color: var(--faint);
  font-size: 10px;
}

.dimension-total strong {
  display: block;
  margin-top: 2px;
  color: var(--green);
  font-size: 18px;
}

.dimension-total.invalid strong {
  color: var(--amber);
}

.dimension-description {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: #fcfbfc;
}

.dimension-description label {
  flex: 1;
}

.description-input {
  display: block;
  width: 100%;
  resize: vertical;
  padding: 7px 9px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  line-height: 1.6;
}

.description-input:hover,
.description-input:focus {
  border-color: var(--line);
  background: var(--surface);
}

.scope-pill {
  max-width: 260px;
  flex: 0 0 auto;
  padding: 6px 9px;
  border-radius: 7px;
  color: var(--violet);
  background: var(--violet-soft);
  font-size: 9px;
  font-weight: 600;
  line-height: 1.4;
  text-align: right;
}

.options-table {
  padding: 0 24px;
}

.table-head,
.option-row {
  display: grid;
  grid-template-columns: 70px minmax(150px, 1.35fr) minmax(140px, 1fr) minmax(150px, 0.8fr) 44px;
  align-items: center;
  gap: 13px;
}

.table-head {
  min-height: 41px;
  color: var(--faint);
  font-size: 9px;
  font-weight: 600;
}

.option-row {
  min-height: 52px;
  border-top: 1px solid var(--line);
}

.sort-tools {
  display: flex;
  align-items: center;
  gap: 3px;
}

.sort-index {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  background: #f0eef2;
  font-size: 9px;
  font-weight: 700;
}

.icon-button {
  display: grid;
  width: 21px;
  height: 21px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 5px;
  color: var(--faint);
  background: transparent;
  cursor: pointer;
  font-size: 10px;
}

.icon-button:hover:not(:disabled) {
  color: var(--violet);
  background: var(--violet-soft);
}

.icon-button:disabled {
  cursor: default;
  opacity: 0.3;
}

.delete-option:hover:not(:disabled) {
  color: var(--red);
  background: #fff0f1;
}

.cell-input {
  width: 100%;
  min-height: 33px;
  padding: 6px 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  outline: 0;
  background: transparent;
  font-size: 11px;
}

.cell-input:hover,
.cell-input:focus {
  border-color: var(--line);
  background: #fbfafc;
}

.system-value {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 10px;
}

.percentage-cell {
  display: grid;
  grid-template-columns: minmax(55px, 1fr) 56px;
  align-items: center;
  gap: 10px;
}

.percentage-track {
  height: 3px;
  overflow: hidden;
  border-radius: 99px;
  background: #ece9ef;
}

.percentage-track i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--violet);
  transition: width 180ms ease;
}

.percentage-input-wrap {
  position: relative;
}

.percentage-input {
  padding-right: 20px;
  text-align: right;
}

.percentage-input-wrap span {
  position: absolute;
  top: 50%;
  right: 7px;
  color: var(--faint);
  font-size: 9px;
  pointer-events: none;
  transform: translateY(-50%);
}

.dimension-footer {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 24px 17px;
  border-top: 1px solid var(--line);
}

.add-option {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--violet);
  background: var(--surface);
  cursor: pointer;
  font-size: 10px;
  font-weight: 600;
}

.add-option:hover {
  border-color: rgba(111, 91, 234, 0.35);
  background: var(--violet-soft);
}

.note-field {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.note-field span {
  flex: 0 0 auto;
  color: var(--faint);
  font-size: 9px;
}

.note-field input {
  width: 100%;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: 0;
  color: var(--muted);
  background: #fbfafc;
  font-size: 10px;
}

.note-field input:focus {
  border-color: rgba(111, 91, 234, 0.4);
}

.issue-list {
  display: none;
  gap: 7px;
  padding: 0 24px 17px;
}

.has-issues .issue-list {
  display: flex;
  flex-wrap: wrap;
}

.issue-badge {
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--amber);
  background: var(--amber-soft);
  font-size: 9px;
  font-weight: 600;
}

.loading-card,
.empty-card {
  display: grid;
  min-height: 180px;
  place-items: center;
  padding: 40px;
  color: var(--muted);
  font-size: 13px;
}

.loading-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.spinner {
  width: 17px;
  height: 17px;
  border: 2px solid #ddd8e6;
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.toast {
  position: fixed;
  z-index: 100;
  right: 26px;
  bottom: 26px;
  max-width: min(360px, calc(100vw - 40px));
  padding: 11px 15px;
  border-radius: 9px;
  color: #fff;
  background: #2d2935;
  box-shadow: 0 12px 34px rgba(30, 25, 39, 0.24);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

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

.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;
}

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

  .hero-actions {
    justify-content: flex-start;
  }

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

  .toolbar-right {
    width: 100%;
    justify-content: space-between;
  }

  .search-field {
    width: min(340px, 45vw);
  }
}

@media (max-width: 900px) {
  .page-shell {
    width: min(100% - 24px, 760px);
    padding-top: 28px;
  }

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

  .summary article:nth-child(3)::before {
    display: none;
  }

  .summary article:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }

  .workspace {
    display: block;
  }

  .index-panel {
    position: static;
    display: none;
  }

  .section-tabs {
    max-width: 100%;
    overflow-x: auto;
  }

  .dimension-header,
  .dimension-description,
  .dimension-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .dimension-total {
    padding: 0;
    border: 0;
    text-align: left;
  }

  .scope-pill {
    max-width: none;
    text-align: left;
  }

  .editable-title input {
    width: calc(100vw - 130px);
  }

  .options-table {
    padding: 0 14px;
    overflow-x: auto;
  }

  .table-head,
  .option-row {
    min-width: 760px;
  }

  .note-field {
    width: 100%;
  }
}

@media (max-width: 620px) {
  .page-shell {
    width: min(100% - 16px, 560px);
  }

  .hero-actions,
  .button {
    width: 100%;
  }

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

  .summary article {
    min-height: 82px;
  }

  .summary article + article::before {
    display: none;
  }

  .summary article:nth-child(n + 2) {
    border-top: 1px solid var(--line);
  }

  .toolbar-right {
    align-items: stretch;
    flex-direction: column;
  }

  .search-field {
    width: 100%;
  }

  .view-tabs {
    overflow-x: auto;
  }

  .dimension-header {
    padding: 18px;
  }

  .dimension-description,
  .dimension-footer {
    padding-right: 18px;
    padding-left: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
