:root {
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f9fb;
  --surface-3: #edf4f2;
  --ink: #181f2a;
  --muted: #657386;
  --line: #d9e1e8;
  --line-strong: #c4cfd9;
  --nav: #ffffff;
  --nav-2: #f7f9fb;
  --teal: #0a8f7b;
  --teal-soft: #dff5f0;
  --blue: #2f6df6;
  --blue-soft: #e7efff;
  --orange: #dc7a19;
  --orange-soft: #fff0df;
  --rose: #c53c5c;
  --rose-soft: #fdeaf0;
  --green: #3c8f4d;
  --green-soft: #e7f5e9;
  --violet: #7058d8;
  --violet-soft: #eeeafd;
  --shadow: 0 12px 28px rgba(26, 35, 52, 0.08);
  --shadow-soft: 0 4px 14px rgba(26, 35, 52, 0.06);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  color-scheme: light;
}

body {
  margin: 0;
  background:
    linear-gradient(90deg, rgba(24, 31, 42, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 31, 42, 0.035) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  color: var(--ink);
  font-family:
    "Inter",
    "Microsoft YaHei",
    "PingFang SC",
    Arial,
    sans-serif;
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: auto;
  background: var(--nav);
  color: var(--ink);
  padding: 18px 16px;
  border-right: 1px solid var(--line);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 6px 2px 18px;
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  font-size: 22px;
}

.brand h1,
.brand p,
.workspace h2,
.panel h3,
.table-toolbar h3,
.dialog-heading h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
  font-weight: 800;
}

.brand p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.nav-tabs {
  display: grid;
  gap: 8px;
  margin: 18px 0;
}

.nav-tab {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
}

.nav-tab:hover,
.nav-tab:focus-visible {
  border-color: var(--line-strong);
  background: var(--surface-2);
  outline: none;
}

.nav-tab.is-active {
  background: var(--ink);
  color: #ffffff;
  font-weight: 700;
}

.filter-stack {
  display: grid;
  gap: 12px;
}

.filter-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.icon-button {
  display: inline-grid;
  min-width: 32px;
  height: 32px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 18px;
}

.sidebar .icon-button {
  border-color: var(--line);
  background: var(--surface-2);
  color: var(--ink);
}

.field {
  display: grid;
  gap: 6px;
}

.field span,
.toggle-row span:last-child {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}

.workspace .field span,
.entry-dialog .field span {
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
}

.multi-field {
  position: relative;
}

.multi-select-trigger {
  position: relative;
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 8px 34px 8px 10px;
  outline: none;
  overflow: hidden;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.multi-select-trigger::after {
  content: "⌄";
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  color: var(--muted);
}

.multi-select-trigger[aria-expanded="true"] {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(10, 143, 123, 0.12);
}

.multi-select-panel {
  position: absolute;
  z-index: 10;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  overflow: hidden;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: 0 16px 40px rgba(10, 24, 39, 0.26);
}

.check-list {
  max-height: 220px;
  overflow: auto;
  padding: 4px;
}

#anchorFilterPanel {
  right: auto;
  width: min(372px, calc(100vw - 32px));
}

#anchorFilterOptions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 2px;
  padding: 6px;
}

#anchorFilterOptions .check-row {
  min-width: 0;
  border-radius: 6px;
  padding: 8px;
}

#anchorFilterOptions .check-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 10px;
  color: var(--ink);
}

.check-row:hover {
  background: #eef5f4;
}

.check-row.is-all {
  border-bottom: 1px solid var(--line);
  font-weight: 800;
}

.check-row input {
  width: 16px;
  height: 16px;
  min-height: 16px;
  border: 0;
  padding: 0;
  accent-color: var(--teal);
}

.check-row span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
}

.field select option {
  color: var(--ink);
}

.workspace .field input,
.workspace .field select,
.entry-dialog .field input,
.entry-dialog .field select {
  border-color: var(--line);
  background: var(--surface);
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.toggle-row:has(input:focus-visible) .toggle-ui {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
}

.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.toggle-ui {
  position: relative;
  width: 42px;
  height: 24px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: #dce5ed;
  transition:
    background 160ms ease,
    border-color 160ms ease;
}

.toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 160ms ease;
}

.toggle-row input:checked + .toggle-ui {
  border-color: var(--teal);
  background: var(--teal);
}

.toggle-row input:checked + .toggle-ui::after {
  transform: translateX(18px);
}

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 14px 16px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(12px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
}

.workspace h2 {
  font-size: 24px;
  line-height: 1.2;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 14px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #ffffff;
}

.ghost-button {
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
}

.primary-button:hover,
.ghost-button:hover,
.icon-button:hover {
  filter: brightness(0.98);
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(300px, 1.25fr) minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}

.hero-metric,
.selector-card {
  position: relative;
  overflow: hidden;
  min-height: 170px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.hero-metric {
  display: grid;
  align-content: center;
  padding: 24px 26px;
  background:
    linear-gradient(135deg, #1b2230 0%, #253245 58%, #204b44 100%);
  color: #ffffff;
}

.hero-kicker {
  color: rgba(255, 255, 255, 0.72);
  font-size: 14px;
  font-weight: 800;
}

.hero-value {
  margin-top: 10px;
  font-size: 48px;
  font-weight: 880;
  line-height: 1.04;
  font-variant-numeric: tabular-nums;
}

.hero-meta {
  margin-top: 10px;
  color: rgba(255, 255, 255, 0.72);
  font-weight: 700;
}

.hero-spark {
  position: absolute;
  right: 22px;
  bottom: 20px;
  display: flex;
  align-items: end;
  gap: 5px;
  height: 48px;
  opacity: 0.78;
}

.hero-spark span {
  width: 7px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.64);
}

.hero-spark span:nth-child(1) {
  height: 15px;
}

.hero-spark span:nth-child(2) {
  height: 23px;
}

.hero-spark span:nth-child(3) {
  height: 18px;
}

.hero-spark span:nth-child(4) {
  height: 34px;
}

.hero-spark span:nth-child(5) {
  height: 42px;
  background: #7ee0cb;
}

.hero-spark span:nth-child(6) {
  height: 25px;
}

.selector-card {
  padding: 20px;
}

.selector-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.selector-heading h3 {
  margin: 0;
  font-size: 17px;
}

.selector-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.quick-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.quick-chip {
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  padding: 8px 14px;
  font-weight: 800;
}

.quick-chip:hover {
  border-color: var(--line-strong);
  background: #ffffff;
}

.quick-chip.is-active {
  border-color: rgba(10, 143, 123, 0.22);
  background: var(--teal-soft);
  color: #075f53;
}

.month-grid .quick-chip.is-active {
  border-color: rgba(47, 109, 246, 0.2);
  background: var(--blue-soft);
  color: #1f56c5;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.kpi-card {
  min-height: 108px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.84);
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.kpi-card[data-tone="teal"] {
  border-top: 4px solid var(--teal);
}

.kpi-card[data-tone="blue"] {
  border-top: 4px solid var(--blue);
}

.kpi-card[data-tone="orange"] {
  border-top: 4px solid var(--orange);
}

.kpi-card[data-tone="rose"] {
  border-top: 4px solid var(--rose);
}

.kpi-label {
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}

.kpi-value {
  margin-top: 8px;
  font-size: 24px;
  font-weight: 850;
  line-height: 1.1;
}

.kpi-foot {
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.dashboard-bottom-metrics {
  margin-top: 14px;
}

.dashboard-bottom-metrics .insight-strip {
  margin-bottom: 0;
}

.insight-item {
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 10px 12px;
  box-shadow: var(--shadow-soft);
}

.insight-item strong {
  display: block;
  font-size: 14px;
}

.insight-item span {
  color: var(--muted);
  font-size: 12px;
}

.analytics-grid,
.rank-grid,
.config-grid {
  display: grid;
  gap: 12px;
}

.analytics-grid {
  grid-template-columns: minmax(0, 1.45fr) minmax(340px, 0.9fr);
  margin-bottom: 14px;
}

.rank-grid {
  grid-template-columns: repeat(4, minmax(240px, 1fr));
}

.monthly-layout {
  grid-template-columns: minmax(0, 1.2fr) minmax(440px, 0.8fr);
}

.config-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.anchor-config-panel {
  order: 0;
}

.standardization-panel {
  order: 1;
}

.quality-panel {
  order: 2;
}

.product-config-panel {
  order: 3;
}

.mechanism-config-panel {
  order: 4;
}

.sales-strategy-config-panel {
  order: 5;
}

.source-config-panel {
  order: 6;
}

.panel {
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 16px;
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-heading h3,
.table-toolbar h3,
.dialog-heading h3 {
  font-size: 16px;
  line-height: 1.25;
}

.panel-heading span,
.table-toolbar p,
.toolbar-note {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.panel-heading-actions,
.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.panel-heading-actions {
  flex: 0 0 auto;
}

.compact-icon,
.field-add-button {
  min-width: 28px;
  width: 28px;
  height: 28px;
  font-size: 17px;
}

.field-label-row > span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.trend-panel canvas,
.monthly-layout canvas {
  min-height: 300px;
}

.donut-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 14px;
  align-items: center;
}

.legend-list {
  display: grid;
  gap: 10px;
}

.legend-item {
  display: grid;
  grid-template-columns: 12px minmax(72px, 0.7fr) minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.legend-item span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
  white-space: nowrap;
}

.rank-list {
  display: grid;
  gap: 10px;
}

.rank-row {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) minmax(90px, auto);
  gap: 10px;
  align-items: center;
}

.rank-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-value {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.rank-bar {
  grid-column: 1 / -1;
  height: 8px;
  overflow: hidden;
  border-radius: 8px;
  background: #edf1f4;
}

.rank-fill {
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, var(--teal), var(--blue));
}

.table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table-wrap.compact {
  max-height: 430px;
  box-shadow: none;
}

.data-table {
  width: 100%;
  min-width: 1120px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  border-bottom: 1px solid var(--line);
  padding: 10px 11px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef5f4;
  color: #17324d;
  font-size: 12px;
  font-weight: 850;
}

.data-table th[data-sort] {
  cursor: pointer;
}

.data-table th[data-sort]::after {
  content: " ↕";
  color: var(--muted);
  font-weight: 600;
}

.data-table th.is-sorted-asc::after {
  content: " ↑";
  color: var(--teal);
}

.data-table th.is-sorted-desc::after {
  content: " ↓";
  color: var(--teal);
}

.data-table tbody tr:hover {
  background: #f7fbfa;
}

.row-action {
  min-height: 28px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  color: var(--teal);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 800;
}

.row-action:hover,
.row-action:focus-visible {
  border-color: var(--teal);
  background: var(--teal-soft);
  outline: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--blue-soft);
  color: #1f4fba;
  font-size: 12px;
  font-weight: 800;
}

.pill.channel-public {
  background: var(--teal-soft);
  color: #0b5f59;
}

.pill.channel-private {
  background: var(--orange-soft);
  color: #9a5302;
}

.pill.channel-mixed {
  background: #e8eefc;
  color: #304c99;
}

.pill.channel-pending,
.pill.price-scene.is-pending {
  background: #eef1f4;
  color: #5d6875;
}

.pill.strategy {
  background: var(--rose-soft);
  color: #9e2743;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f8fafc;
  padding: 4px 10px;
  font-weight: 750;
}

.mapping-list {
  display: grid;
  gap: 10px;
}

.mapping-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
}

.mapping-item strong {
  display: block;
  margin-bottom: 6px;
}

.mapping-item span {
  display: inline-block;
  margin: 0 6px 6px 0;
  color: var(--muted);
}

.source-state {
  display: grid;
  gap: 10px;
}

.source-state p {
  margin: 0;
  color: var(--muted);
}

.standardization-state {
  display: grid;
  gap: 12px;
}

.standardization-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.standardization-summary strong {
  font-size: 14px;
}

.standardization-summary span,
.standardization-list > span,
.standardization-list li span {
  color: var(--muted);
  font-size: 12px;
}

.standardization-list {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.standardization-list > span {
  display: block;
  margin-bottom: 6px;
  font-weight: 800;
}

.standardization-list ul {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.standardization-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 10px;
}

.standardization-list li strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.standardization-list li span {
  flex: none;
  text-align: right;
  white-space: normal;
}

.standardization-list.review {
  border-top-color: #f0cfad;
}

.quality-state {
  display: grid;
  gap: 14px;
}

.quality-empty {
  display: grid;
  gap: 3px;
}

.quality-empty strong,
.quality-heading strong {
  font-size: 14px;
}

.quality-empty span,
.quality-heading span {
  color: var(--muted);
  font-size: 12px;
}

.quality-heading {
  display: flex;
  align-items: center;
  gap: 10px;
}

.quality-heading > div:last-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.quality-badge {
  flex: none;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 800;
}

.quality-badge.is-passed {
  border-color: #9ed6c9;
  background: #e7f6f1;
  color: #176b5a;
}

.quality-badge.is-review {
  border-color: #edc783;
  background: #fff4d9;
  color: #815719;
}

.quality-badge.is-attention {
  border-color: #e6a5b6;
  background: #fcebf0;
  color: #9d294b;
}

.quality-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-block: 1px solid var(--line);
  padding-block: 10px;
}

.quality-counts div {
  display: grid;
  gap: 2px;
  padding-inline: 10px;
  text-align: center;
}

.quality-counts div + div {
  border-left: 1px solid var(--line);
}

.quality-counts strong {
  font-size: 18px;
}

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

.quality-checks {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.quality-check {
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
}

.quality-check-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1e8d76;
}

.quality-check > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.quality-check strong {
  font-size: 12px;
}

.quality-check span,
.quality-check em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.quality-check em {
  text-align: right;
}

.quality-check.is-warning .quality-check-dot {
  background: #d48a1d;
}

.quality-check.is-failed .quality-check-dot {
  background: #c53c5c;
}

.quality-check.is-info .quality-check-dot {
  background: #3178c6;
}

.entry-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(23, 32, 51, 0.28);
}

.entry-dialog::backdrop {
  background: rgba(23, 32, 51, 0.42);
}

.entry-dialog form {
  padding: 18px;
}

.dialog-heading,
.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.field.wide {
  grid-column: span 2;
}

.dialog-actions {
  justify-content: flex-end;
}

.empty-state {
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.upload-layout {
  display: grid;
  gap: 12px;
}

.upload-source-panel {
  max-width: 760px;
}

.upload-drop {
  display: grid;
  min-height: 132px;
  place-items: center;
  align-content: center;
  gap: 5px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
  text-align: center;
}

.upload-drop:hover,
.upload-drop.is-dragging {
  border-color: var(--teal);
  background: var(--teal-soft);
}

.upload-drop input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.upload-drop strong {
  font-size: 15px;
}

.upload-drop span,
.upload-message {
  color: var(--muted);
  font-size: 12px;
}

.upload-message {
  min-height: 20px;
  margin-top: 9px;
}

.upload-message.is-success {
  color: var(--green);
}

.upload-message.is-error {
  color: var(--rose);
}

.upload-message.is-loading {
  color: var(--blue);
}

.upload-workspace {
  padding: 0;
  overflow: hidden;
}

.upload-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
}

.upload-summary > div {
  display: grid;
  gap: 3px;
  min-height: 74px;
  align-content: center;
  padding: 12px 16px;
}

.upload-summary > div + div {
  border-left: 1px solid var(--line);
}

.upload-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.upload-summary strong {
  font-size: 20px;
}

.upload-summary [data-tone="ready"] strong {
  color: var(--green);
}

.upload-summary [data-tone="review"] strong {
  color: var(--orange);
}

.upload-summary [data-tone="blocked"] strong {
  color: var(--rose);
}

.batch-toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
  gap: 10px;
  align-items: end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.upload-fill-toggle {
  align-self: center;
  white-space: nowrap;
}

.upload-table-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
}

.upload-table-toolbar > div:first-child {
  display: grid;
  gap: 2px;
}

.upload-table-toolbar span {
  color: var(--muted);
  font-size: 12px;
}

.upload-actions,
.upload-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-table-wrap {
  max-height: 560px;
  border: 0;
  border-top: 1px solid var(--line);
  border-radius: 0;
  box-shadow: none;
}

.upload-table {
  min-width: 1540px;
}

.upload-table th:first-child,
.upload-table td:first-child {
  width: 42px;
  text-align: center;
}

.upload-table input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--teal);
}

.upload-status {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: var(--surface-3);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.upload-status.is-ready {
  background: var(--green-soft);
  color: var(--green);
}

.upload-status.is-review {
  background: var(--orange-soft);
  color: #94520e;
}

.upload-status.is-blocked {
  background: var(--rose-soft);
  color: var(--rose);
}

.upload-row.is-excluded td {
  opacity: 0.52;
}

.upload-row-dialog {
  width: min(820px, calc(100vw - 28px));
}

@media (max-width: 1280px) {
  .dashboard-hero {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-metric {
    grid-column: 1 / -1;
  }

  .kpi-grid {
    grid-template-columns: repeat(3, minmax(150px, 1fr));
  }

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

  .monthly-layout {
    grid-template-columns: minmax(0, 1.15fr) minmax(380px, 0.85fr);
  }

  .rank-grid,
  .config-grid {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .nav-tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .nav-tab {
    text-align: center;
  }

  .filter-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: 340px;
    overflow: auto;
    padding-right: 2px;
  }

  .filter-title {
    grid-column: 1 / -1;
  }

  .monthly-layout {
    grid-template-columns: 1fr;
  }

  .dashboard-hero {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 16px;
  }

  .topbar,
  .table-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

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

  .insight-strip,
  .rank-grid,
  .config-grid {
    grid-template-columns: 1fr;
  }

  .donut-layout {
    grid-template-columns: 1fr;
  }

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

  #channelChart {
    max-width: 220px;
    margin: 0 auto;
  }
}

@media (max-width: 640px) {
  .kpi-grid,
  .filter-stack,
  .form-grid {
    grid-template-columns: 1fr;
  }

  .hero-value {
    font-size: 36px;
  }

  .hero-metric,
  .selector-card {
    min-height: 148px;
    padding: 18px;
  }

  .quick-chip {
    min-height: 34px;
    padding: 7px 11px;
  }

  .field.wide {
    grid-column: auto;
  }

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

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

  .upload-summary > div:nth-child(3) {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .upload-summary > div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .batch-toolbar {
    grid-template-columns: 1fr;
  }

  .upload-table-toolbar,
  .upload-actions {
    align-items: stretch;
    flex-direction: column;
  }
}

/* Authenticated data workspace */
[hidden] {
  display: none !important;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

textarea {
  width: 100%;
  min-height: 76px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--ink);
  background: var(--surface);
  font: inherit;
  letter-spacing: 0;
}

textarea:focus {
  border-color: var(--blue);
  outline: 2px solid var(--blue-soft);
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(24, 31, 42, 0.035) 1px, transparent 1px),
    linear-gradient(180deg, rgba(24, 31, 42, 0.035) 1px, transparent 1px),
    #eef1f5;
  background-size: 32px 32px;
}

.login-panel {
  width: min(420px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

.login-brand h1,
.login-brand p,
.login-heading h2,
.login-heading p {
  margin: 0;
}

.login-brand h1 {
  font-size: 18px;
}

.login-brand p,
.login-heading p {
  margin-top: 3px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.auth-mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 18px 24px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 3px;
  background: var(--surface-2);
}

.auth-mode-tab {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
}

.auth-mode-tab.is-active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(26, 35, 52, 0.1);
}

.login-heading h2 {
  font-size: 20px;
}

.login-submit {
  width: 100%;
  min-height: 42px;
  justify-content: center;
}

.login-message {
  border: 1px solid #efc8d2;
  border-radius: 6px;
  padding: 9px 11px;
  color: #9b2744;
  background: #fff2f5;
}

.login-message[data-tone="info"] {
  border-color: #bdd0fb;
  color: #254f9e;
  background: #edf3ff;
}

.login-message[data-tone="success"] {
  border-color: #bcd8d0;
  color: #135d50;
  background: #edfaf6;
}

.user-identity {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 8px;
  min-width: 190px;
  border-left: 1px solid var(--line);
  padding-left: 14px;
}

.user-avatar,
.user-card-avatar {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  color: #ffffff;
  background: #181f2a;
  font-weight: 800;
}

.user-copy {
  display: grid;
  min-width: 0;
}

.user-copy strong,
.user-copy span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-copy span {
  color: var(--muted);
  font-size: 12px;
}

.logout-button {
  width: 32px;
  height: 32px;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selection-count {
  color: var(--blue);
  font-weight: 700;
}

.compact-button {
  min-height: 34px;
  padding: 7px 12px;
}

.select-cell {
  width: 40px;
  min-width: 40px;
  text-align: center !important;
}

.select-cell input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--blue);
}

.action-cell {
  width: 112px;
  min-width: 112px;
  position: sticky;
  right: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: -8px 0 14px rgba(24, 31, 42, 0.06);
}

thead .action-cell {
  z-index: 4;
  background: var(--surface-3);
}

.editable-row {
  cursor: pointer;
}

.editable-row:hover .action-cell {
  background: #f5f8fb;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row-action.secondary {
  border-color: var(--line);
  color: var(--muted);
  background: var(--surface);
}

.entry-drawer {
  width: min(620px, 100vw);
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0 0 0 auto;
  border-width: 0 0 0 1px;
  border-radius: 0;
}

.entry-drawer-form {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  background: var(--surface);
}

.entry-drawer .dialog-heading {
  flex: 0 0 auto;
  min-height: 76px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.entry-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 0 20px 24px;
}

.form-section {
  padding: 20px 0;
  border-bottom: 1px solid var(--line);
}

.form-section:last-child {
  border-bottom: 0;
}

.form-section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.form-section-heading strong {
  font-size: 14px;
}

.form-section-heading span {
  color: var(--muted);
  font-size: 12px;
}

.entry-drawer .form-grid {
  margin: 0;
}

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

.form-grid.three-columns {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calculation-preview {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  align-items: center;
  gap: 12px;
  margin-top: 14px;
  border: 1px solid #c8d8ef;
  border-radius: 6px;
  padding: 12px;
  background: #f3f7fd;
}

.calculation-preview > div {
  display: grid;
  gap: 2px;
}

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

.calculation-preview strong {
  font-size: 17px;
}

.switch-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.switch-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
}

.manual-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
  padding-left: 12px;
  border-left: 3px solid var(--orange);
}

.compact-section {
  padding-bottom: 14px;
}

.change-reason-section {
  border-bottom: 0;
}

.entry-warning {
  margin-top: 14px;
  border: 1px solid #efc8d2;
  border-radius: 6px;
  padding: 10px 12px;
  color: #9b2744;
  background: #fff2f5;
}

.entry-drawer .dialog-actions {
  flex: 0 0 auto;
  min-height: 68px;
  padding: 12px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.dialog-spacer {
  flex: 1;
}

.danger-button {
  min-height: 36px;
  border: 1px solid #e7b7c3;
  border-radius: 6px;
  padding: 8px 12px;
  color: #a92c4a;
  background: #fff2f5;
  font-weight: 700;
}

.compact-dialog {
  width: min(620px, calc(100vw - 28px));
}

.compact-dialog form {
  padding: 20px;
}

.batch-summary {
  margin: 14px 0 0;
  color: var(--muted);
}

.history-list,
.history-feed {
  display: grid;
}

.history-card {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr);
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.history-marker {
  width: 8px;
  height: 8px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--blue);
}

.history-content,
.history-heading > div {
  display: grid;
  gap: 4px;
}

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

.history-heading span,
.history-heading time,
.history-meta {
  color: var(--muted);
  font-size: 12px;
}

.history-content p {
  margin: 8px 0;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
}

.history-diff-list {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  border-left: 2px solid var(--line-strong);
  padding-left: 10px;
}

.history-diff-row {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 18px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  font-size: 12px;
}

.history-diff-row span,
.history-diff-row del {
  color: var(--muted);
}

.history-diff-row del,
.history-diff-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-diff-row i {
  color: var(--line-strong);
  font-style: normal;
  text-align: center;
}

.history-content .row-action {
  justify-self: start;
}

.history-feed {
  border-top: 1px solid var(--line);
}

.history-feed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 74px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--line);
}

.history-feed-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.history-feed-main strong,
.history-feed-main p,
.history-feed-side strong,
.history-feed-side span {
  display: block;
  margin: 0;
}

.history-feed-main p,
.history-feed-side span {
  color: var(--muted);
  font-size: 12px;
}

.history-feed-side {
  flex: 0 0 auto;
  text-align: right;
}

.user-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.registration-section {
  margin-bottom: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 20px;
}

.section-heading-inline {
  margin-bottom: 10px;
}

.section-heading-inline h3,
.section-heading-inline p {
  margin: 0;
}

.section-heading-inline h3 {
  font-size: 15px;
}

.section-heading-inline p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.registration-grid {
  display: grid;
  gap: 8px;
}

.registration-card {
  display: grid;
  grid-template-columns: 42px minmax(150px, 1fr) minmax(150px, 190px) auto;
  align-items: center;
  gap: 12px;
  min-height: 82px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface);
}

.role-pending {
  color: #8a560d;
  background: var(--orange-soft);
}

.inline-role-field {
  display: grid;
  gap: 4px;
}

.inline-role-field span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.inline-role-field select {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--ink);
  background: var(--surface-2);
}

.registration-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.compact-empty {
  min-height: 54px;
}

.user-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface);
}

.user-card.is-disabled {
  opacity: 0.58;
}

.user-card-avatar {
  width: 42px;
  height: 42px;
}

.user-card-copy > div {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.user-card-copy p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.role-badge {
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
}

.role-admin {
  color: #9b2744;
  background: var(--rose-soft);
}

.role-editor {
  color: #2456b9;
  background: var(--blue-soft);
}

.role-viewer {
  color: #3f6950;
  background: var(--green-soft);
}

.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1000;
  display: grid;
  gap: 8px;
  width: min(390px, calc(100vw - 40px));
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 48px;
  border: 1px solid #bcd8d0;
  border-radius: 6px;
  padding: 10px 12px;
  color: #135d50;
  background: #edfaf6;
  box-shadow: var(--shadow);
}

.toast.is-error {
  border-color: #efc8d2;
  color: #9b2744;
  background: #fff2f5;
}

.toast.is-warning {
  border-color: #f0d0a4;
  color: #945710;
  background: #fff8ee;
}

.toast button {
  border: 0;
  padding: 4px;
  color: inherit;
  background: transparent;
  font-weight: 800;
}

@media (max-width: 1100px) {
  .user-copy {
    display: none;
  }

  .user-identity {
    grid-template-columns: 34px 32px;
    min-width: 82px;
  }

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

  .registration-card {
    grid-template-columns: 42px minmax(0, 1fr) minmax(140px, 180px);
  }

  .registration-actions {
    grid-column: 2 / -1;
  }
}

@media (max-width: 720px) {
  .entry-drawer {
    width: 100vw;
  }

  .form-grid.two-columns,
  .form-grid.three-columns,
  .manual-values,
  .user-grid {
    grid-template-columns: 1fr;
  }

  .registration-card {
    grid-template-columns: 42px minmax(0, 1fr);
  }

  .registration-card .inline-role-field,
  .registration-actions {
    grid-column: 1 / -1;
  }

  .registration-actions > button {
    flex: 1;
  }

  .field.wide {
    grid-column: auto;
  }

  .calculation-preview {
    grid-template-columns: 1fr 1fr;
  }

  .calculation-preview .switch-row {
    grid-column: 1 / -1;
  }

  .history-feed-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .history-feed-side {
    text-align: left;
  }

  .topbar-actions > .ghost-button {
    display: none;
  }
}
