:root {
  --bg: #f3f6f4;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --ink: #17231f;
  --ink-soft: #33423d;
  --muted: #6a7772;
  --line: #dce5e1;
  --line-strong: #c8d4cf;
  --primary: #0d7165;
  --primary-strong: #09584f;
  --primary-soft: #e7f3f0;
  --accent: #dfa52d;
  --accent-soft: #fbf2dc;
  --danger: #b6423e;
  --danger-soft: #faeceb;
  --shadow: 0 18px 50px rgba(24, 51, 43, 0.08);
  --font: "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC",
    "Hiragino Sans GB", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--bg);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: 0;
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(17, 75, 61, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(17, 75, 61, 0.035) 1px, transparent 1px);
  background-size: 48px 48px;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

button,
a,
label[for] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
label[for]:focus-visible {
  outline: 3px solid rgba(13, 113, 101, 0.24);
  outline-offset: 2px;
}

svg {
  display: block;
}

.app-shell {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}

.topbar {
  position: sticky;
  z-index: 30;
  top: 0;
  display: grid;
  min-height: 76px;
  padding: 0 34px;
  border-bottom: 1px solid rgba(200, 212, 207, 0.8);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  grid-template-columns: minmax(200px, 1fr) auto minmax(200px, 1fr);
  align-items: center;
}

.brand {
  display: inline-flex;
  width: fit-content;
  color: var(--ink);
  text-decoration: none;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--primary);
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 3px;
  padding: 9px;
}

.brand-mark span {
  display: block;
  min-height: 6px;
  border-radius: 2px 2px 0 0;
  background: #ffffff;
}

.brand-mark span:nth-child(1) {
  height: 45%;
  opacity: 0.72;
}

.brand-mark span:nth-child(2) {
  height: 72%;
  opacity: 0.9;
}

.brand-mark span:nth-child(3) {
  height: 100%;
  background: #f1bf59;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-text strong {
  font-size: 16px;
  line-height: 1.3;
}

.brand-text small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.4;
}

.topnav {
  display: flex;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  gap: 3px;
}

.nav-button {
  display: inline-flex;
  min-height: 38px;
  padding: 8px 17px;
  border: 0;
  border-radius: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  background: transparent;
  cursor: pointer;
  align-items: center;
  gap: 8px;
  transition:
    color 160ms ease,
    background-color 160ms ease,
    box-shadow 160ms ease;
}

.nav-button svg {
  width: 17px;
  height: 17px;
}

.nav-button:hover {
  color: var(--ink);
}

.nav-button.is-active {
  color: var(--primary-strong);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(29, 58, 49, 0.08);
}

.topbar-status {
  display: flex;
  justify-self: end;
  color: var(--muted);
  font-size: 13px;
  align-items: center;
  gap: 8px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  background: #36a47c;
  box-shadow: 0 0 0 1px rgba(54, 164, 124, 0.4);
}

main {
  flex: 1;
}

.view {
  display: none;
}

.view.is-visible {
  display: block;
  animation: view-in 300ms ease both;
}

.page-wrap {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.query-layout {
  display: grid;
  min-height: calc(100vh - 145px);
  padding-top: 70px;
  padding-bottom: 72px;
  grid-template-columns: minmax(0, 1fr) 330px;
  align-items: start;
  gap: 64px;
}

.query-main {
  min-width: 0;
}

.page-heading {
  max-width: 720px;
}

.eyebrow {
  display: inline-flex;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  align-items: center;
  gap: 8px;
}

.eyebrow svg {
  width: 17px;
  height: 17px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.page-heading h1,
.admin-heading h1 {
  margin: 15px 0 18px;
  font-size: clamp(38px, 5vw, 60px);
  font-weight: 720;
  line-height: 1.1;
}

.page-heading p,
.admin-heading p {
  max-width: 600px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
}

.query-form {
  margin-top: 44px;
}

.query-form > label {
  display: block;
  margin-bottom: 9px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
}

.query-control {
  display: grid;
  min-height: 68px;
  padding: 7px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.query-control:focus-within {
  border-color: var(--primary);
  box-shadow:
    0 0 0 4px rgba(13, 113, 101, 0.1),
    var(--shadow);
}

.input-icon {
  display: grid;
  color: var(--primary);
  place-items: center;
}

.input-icon svg {
  width: 20px;
  height: 20px;
}

.query-control input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 8px;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 17px;
  background: transparent;
}

.query-control input::placeholder {
  color: #9aa6a1;
}

.revenue-query-form {
  max-width: 820px;
}

.query-fields {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(175px, 0.75fr) auto;
  align-items: end;
  gap: 10px;
}

.query-field {
  display: grid;
  min-width: 0;
  gap: 8px;
}

.query-label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.query-input {
  display: grid;
  width: 100%;
  min-width: 0;
  min-height: 52px;
  padding: 0 13px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  box-shadow: 0 9px 28px rgba(24, 51, 43, 0.07);
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.query-input:focus-within {
  border-color: var(--primary);
  box-shadow:
    0 0 0 3px rgba(13, 113, 101, 0.1),
    0 9px 28px rgba(24, 51, 43, 0.07);
}

.query-input > svg {
  width: 17px;
  height: 17px;
  color: var(--primary);
}

.query-input input,
.query-input select {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  font-size: 15px;
  background: transparent;
}

.query-input input::placeholder {
  color: #9aa6a1;
}

.batch-query-fields {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
}

.query-field-batch {
  grid-column: 1 / -1;
}

.query-textarea {
  min-height: 82px;
  padding-top: 10px;
  padding-bottom: 10px;
  align-items: start;
}

.query-textarea > svg {
  margin-top: 4px;
}

.query-textarea textarea {
  width: 100%;
  min-width: 0;
  min-height: 60px;
  padding: 3px 0;
  border: 0;
  outline: 0;
  resize: vertical;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  line-height: 1.55;
  background: transparent;
}

.query-textarea textarea::placeholder {
  color: #9aa6a1;
}

.query-input select {
  padding-right: 20px;
  cursor: pointer;
  appearance: none;
}

.date-input {
  grid-template-columns: 20px minmax(0, 1fr) 16px;
  padding-right: 11px;
}

.date-input .select-chevron {
  width: 15px;
  height: 15px;
  color: var(--muted);
  pointer-events: none;
}

.query-submit {
  min-height: 52px;
  margin-bottom: 0;
  white-space: nowrap;
}

.primary-button,
.secondary-button,
.danger-button,
.danger-ghost-button,
.icon-button,
.text-button {
  border: 0;
  font: inherit;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  min-height: 50px;
  padding: 11px 19px;
  border-radius: 7px;
  color: #ffffff;
  font-size: 15px;
  font-weight: 650;
  background: var(--primary);
  box-shadow: 0 8px 20px rgba(13, 113, 101, 0.18);
  justify-content: center;
  align-items: center;
  gap: 9px;
  transition:
    background-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-strong);
  box-shadow: 0 10px 24px rgba(13, 113, 101, 0.25);
  transform: translateY(-1px);
}

.primary-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  box-shadow: none;
}

.primary-button svg,
.secondary-button svg,
.danger-button svg,
.danger-ghost-button svg {
  width: 18px;
  height: 18px;
}

.primary-button .loading-ring {
  width: 17px;
  height: 17px;
  border-width: 2px;
  border-color: rgba(255, 255, 255, 0.35);
  border-top-color: #ffffff;
}

.secondary-button {
  display: inline-flex;
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  background: var(--surface);
  justify-content: center;
  align-items: center;
  gap: 8px;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}

.secondary-button:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.compact-button {
  min-height: 38px;
  padding: 7px 13px;
  white-space: nowrap;
}

.full-button {
  width: 100%;
}

.form-help {
  display: flex;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
  justify-content: space-between;
  gap: 16px;
}

.form-help span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.form-help svg {
  width: 14px;
  height: 14px;
}

.query-result {
  min-height: 245px;
  margin-top: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 36px rgba(24, 51, 43, 0.055);
  overflow: hidden;
}

.result-placeholder {
  display: flex;
  min-height: 245px;
  padding: 36px;
  align-items: center;
  justify-content: center;
  gap: 18px;
}

.placeholder-visual {
  display: grid;
  width: 62px;
  height: 62px;
  flex: 0 0 62px;
  border: 1px dashed var(--line-strong);
  border-radius: 50%;
  color: var(--primary);
  background: var(--surface-soft);
  place-items: center;
}

.placeholder-visual svg {
  width: 26px;
  height: 26px;
}

.result-placeholder h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.result-placeholder p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.result-loading {
  display: flex;
  min-height: 245px;
  color: var(--muted);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.loading-ring {
  width: 30px;
  height: 30px;
  border: 3px solid var(--line);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

.error-result {
  display: flex;
  min-height: 245px;
  padding: 36px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.error-result .error-icon {
  display: grid;
  width: 52px;
  height: 52px;
  margin-bottom: 15px;
  border-radius: 50%;
  color: var(--danger);
  background: var(--danger-soft);
  place-items: center;
}

.error-result .error-icon svg {
  width: 24px;
  height: 24px;
}

.error-result h2 {
  margin-bottom: 5px;
  font-size: 19px;
}

.error-result p {
  max-width: 440px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}

.record-result {
  min-height: 245px;
}

.revenue-result {
  min-height: 245px;
}

.batch-result {
  min-height: 245px;
}

.batch-result-head {
  display: flex;
  padding: 22px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfb;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.batch-result-head h2 {
  margin-bottom: 2px;
  font-size: 19px;
}

.batch-result-head p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
}

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

.batch-table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  font-size: 12px;
}

.batch-table th,
.batch-table td {
  padding: 11px 13px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.batch-table th {
  color: var(--ink-soft);
  font-weight: 650;
  background: #f5f8f6;
}

.batch-table td {
  color: var(--ink-soft);
}

.batch-table tr th:last-child,
.batch-table tr td:last-child {
  border-right: 0;
}

.batch-table tbody tr:hover {
  background: #f9fbfa;
}

.batch-table tfoot td {
  color: var(--ink);
  font-weight: 700;
  background: #f3f8f6;
}

.batch-table .income-cell {
  color: var(--primary-strong);
  font-weight: 650;
}

.missing-ids {
  display: flex;
  padding: 12px 24px;
  border-top: 1px solid #ead9b4;
  color: #735a29;
  font-size: 12px;
  background: var(--accent-soft);
  align-items: flex-start;
  gap: 8px;
}

.missing-ids svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  margin-top: 1px;
}

.revenue-head {
  background:
    linear-gradient(90deg, rgba(13, 113, 101, 0.035), transparent 48%),
    #fbfcfb;
}

.metric-grid {
  display: grid;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.metric-card {
  display: flex;
  min-width: 0;
  min-height: 156px;
  padding: 21px;
  border-right: 1px solid var(--line);
  flex-direction: column;
}

.metric-card:last-child {
  border-right: 0;
}

.metric-top {
  display: flex;
  color: var(--muted);
  font-size: 12px;
  align-items: center;
  gap: 8px;
}

.metric-icon {
  display: grid;
  width: 30px;
  height: 30px;
  border-radius: 6px;
  color: var(--primary);
  background: var(--primary-soft);
  place-items: center;
}

.metric-card:last-child .metric-icon {
  color: #8d6109;
  background: var(--accent-soft);
}

.metric-icon svg {
  width: 16px;
  height: 16px;
}

.metric-card strong {
  overflow: hidden;
  margin-top: 16px;
  color: var(--ink);
  font-size: 30px;
  font-weight: 740;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric-foot {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.record-head {
  display: flex;
  padding: 26px 28px 24px;
  background: #fbfcfb;
  align-items: center;
  gap: 16px;
}

.record-avatar {
  display: grid;
  width: 52px;
  height: 52px;
  flex: 0 0 52px;
  border-radius: 8px;
  color: var(--primary-strong);
  font-size: 18px;
  font-weight: 750;
  background: var(--primary-soft);
  place-items: center;
}

.record-identity {
  min-width: 0;
  flex: 1;
}

.record-identity h2 {
  overflow: hidden;
  margin-bottom: 2px;
  font-size: 21px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.record-identity p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.matched-badge {
  display: inline-flex;
  padding: 5px 9px;
  border: 1px solid #bde0d4;
  border-radius: 5px;
  color: #14705d;
  font-size: 12px;
  font-weight: 650;
  background: #eff9f5;
  align-items: center;
  gap: 5px;
}

.matched-badge svg {
  width: 14px;
  height: 14px;
}

.record-fields {
  display: grid;
  border-top: 1px solid var(--line);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-field {
  min-width: 0;
  padding: 17px 28px;
  border-bottom: 1px solid var(--line);
}

.record-field:nth-child(odd) {
  border-right: 1px solid var(--line);
}

.record-field:last-child:nth-child(odd) {
  grid-column: 1 / -1;
  border-right: 0;
}

.record-field.is-wide {
  grid-column: 1 / -1;
  border-right: 0;
}

.record-field dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 12px;
}

.record-field dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: var(--ink-soft);
  font-size: 15px;
  font-weight: 560;
  white-space: pre-wrap;
}

.empty-value {
  color: #9ba5a1;
  font-weight: 400;
}

.record-actions {
  display: flex;
  padding: 15px 28px;
  justify-content: flex-end;
}

.text-button {
  display: inline-flex;
  padding: 4px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 650;
  background: transparent;
  align-items: center;
  gap: 5px;
}

.text-button:hover {
  color: var(--primary-strong);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-button svg {
  width: 15px;
  height: 15px;
}

.query-aside {
  display: grid;
  padding-top: 11px;
  gap: 18px;
}

.aside-panel {
  padding: 23px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

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

.aside-icon {
  display: grid;
  width: 40px;
  height: 40px;
  border-radius: 7px;
  color: var(--primary);
  background: var(--primary-soft);
  place-items: center;
}

.aside-icon svg {
  width: 19px;
  height: 19px;
}

.aside-heading div {
  display: flex;
  flex-direction: column;
}

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

.aside-heading strong {
  font-size: 15px;
}

.dataset-facts {
  display: grid;
  margin: 4px 0 0;
}

.dataset-facts div {
  display: flex;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  gap: 16px;
}

.dataset-facts div:last-child {
  padding-bottom: 2px;
  border-bottom: 0;
}

.dataset-facts dt {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 13px;
}

.dataset-facts dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.privacy-note {
  display: flex;
  padding: 20px 21px;
  border: 1px solid #ead9b4;
  border-radius: 8px;
  color: #675027;
  background: var(--accent-soft);
  gap: 12px;
}

.privacy-note > svg {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  margin-top: 1px;
}

.privacy-note strong {
  display: block;
  margin-bottom: 3px;
  font-size: 13px;
}

.privacy-note p {
  margin-bottom: 0;
  color: #79653f;
  font-size: 12px;
  line-height: 1.65;
}

.admin-page {
  padding-top: 55px;
  padding-bottom: 80px;
}

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

.admin-heading h1 {
  margin-top: 10px;
  margin-bottom: 8px;
  font-size: 42px;
}

.admin-heading p {
  font-size: 15px;
}

.auth-panel {
  display: grid;
  width: min(100%, 560px);
  margin: 60px auto 0;
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 0 16px;
}

.auth-icon {
  display: grid;
  width: 52px;
  height: 52px;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-soft);
  grid-row: 1 / 3;
  place-items: center;
}

.auth-icon svg {
  width: 23px;
  height: 23px;
}

.auth-copy h2 {
  margin-bottom: 2px;
  font-size: 20px;
}

.auth-copy p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-form {
  display: grid;
  grid-column: 1 / -1;
  margin-top: 26px;
  gap: 9px;
}

.auth-form label,
.config-field label,
.field-picker label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 650;
}

.password-control {
  position: relative;
}

.password-control input {
  width: 100%;
  height: 49px;
  padding: 0 48px 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  outline: 0;
  background: var(--surface);
}

.password-control input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 113, 101, 0.1);
}

.icon-button {
  position: absolute;
  top: 50%;
  right: 7px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 6px;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
  place-items: center;
}

.icon-button:hover {
  color: var(--ink);
  background: var(--surface-soft);
}

.icon-button svg {
  width: 18px;
  height: 18px;
}

.auth-form .primary-button {
  margin-top: 8px;
}

.admin-dashboard {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  align-items: start;
  gap: 24px;
}

.admin-summary,
.import-workspace {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.admin-summary {
  position: sticky;
  top: 100px;
  padding: 24px;
}

.summary-heading {
  display: flex;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 12px;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.state-badge {
  display: inline-flex;
  padding: 3px 7px;
  border-radius: 4px;
  color: #6a756f;
  font-size: 11px;
  font-weight: 650;
  background: #eff2f0;
}

.state-badge.is-active {
  color: #11705d;
  background: #e8f6f0;
}

.summary-number {
  display: block;
  font-size: 44px;
  font-weight: 740;
  line-height: 1;
}

.summary-unit {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
}

.summary-list {
  display: grid;
  margin: 25px 0 20px;
  padding: 0;
}

.summary-list div {
  display: grid;
  padding: 11px 0;
  border-top: 1px solid var(--line);
  grid-template-columns: 68px minmax(0, 1fr);
  gap: 12px;
}

.summary-list dt {
  color: var(--muted);
  font-size: 12px;
}

.summary-list dd {
  overflow: hidden;
  margin: 0;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.danger-ghost-button {
  display: inline-flex;
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid #efcfcd;
  border-radius: 6px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 600;
  background: transparent;
  justify-content: center;
  align-items: center;
  gap: 7px;
}

.danger-ghost-button:hover:not(:disabled) {
  background: var(--danger-soft);
}

.danger-ghost-button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.import-workspace {
  overflow: hidden;
}

.import-step {
  padding: 28px;
}

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

.step-heading {
  display: flex;
  margin-bottom: 22px;
  align-items: flex-start;
  gap: 13px;
}

.step-number {
  display: grid;
  width: 31px;
  height: 31px;
  flex: 0 0 31px;
  border-radius: 6px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 750;
  background: var(--primary-soft);
  place-items: center;
}

.step-heading h2 {
  margin-bottom: 2px;
  font-size: 18px;
}

.step-heading p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
}

.drop-zone {
  display: flex;
  min-height: 126px;
  padding: 24px;
  border: 1px dashed #b8c9c2;
  border-radius: 8px;
  background: #fafcfb;
  cursor: pointer;
  align-items: center;
  gap: 16px;
  transition:
    border-color 160ms ease,
    background-color 160ms ease;
}

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

.drop-icon {
  display: grid;
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  border-radius: 8px;
  color: var(--primary);
  background: var(--primary-soft);
  place-items: center;
}

.drop-icon svg {
  width: 23px;
  height: 23px;
}

.drop-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
}

.drop-copy strong {
  font-size: 14px;
}

.drop-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.file-summary {
  display: flex;
  min-height: 72px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
  align-items: center;
  gap: 12px;
}

.file-summary-batch {
  align-items: flex-start;
}

.file-list {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 7px;
}

.file-list-item {
  display: flex;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  align-items: center;
  gap: 10px;
}

.file-list-item .file-icon {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
}

.file-list-item > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.file-list-item strong {
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list-item span {
  color: var(--muted);
  font-size: 10px;
}

.file-icon {
  display: grid;
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 6px;
  color: #a66e00;
  background: var(--accent-soft);
  place-items: center;
}

.file-icon svg {
  width: 20px;
  height: 20px;
}

.file-summary strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.config-grid {
  display: grid;
  margin-bottom: 22px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

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

.mapping-grid .config-field-wide {
  grid-column: 1 / -1;
}

.batch-source-note {
  margin: -8px 0 16px;
  color: var(--muted);
  font-size: 11px;
}

.aggregation-note {
  display: flex;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #d2e5de;
  border-radius: 6px;
  color: #276858;
  font-size: 12px;
  background: #eef7f3;
  align-items: center;
  gap: 9px;
}

.aggregation-note svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
}

.config-field {
  display: grid;
  gap: 7px;
}

.select-wrap {
  position: relative;
}

.select-wrap select {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  outline: 0;
  color: var(--ink-soft);
  background: var(--surface);
  appearance: none;
  cursor: pointer;
}

.select-wrap select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(13, 113, 101, 0.1);
}

.select-wrap svg {
  position: absolute;
  top: 50%;
  right: 13px;
  width: 16px;
  height: 16px;
  color: var(--muted);
  pointer-events: none;
  transform: translateY(-50%);
}

.field-picker {
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-soft);
}

.field-picker-head {
  display: flex;
  margin-bottom: 13px;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}

.field-picker-head > div:first-child {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.field-picker-head span {
  color: var(--muted);
  font-size: 11px;
}

.field-actions {
  display: flex;
  gap: 10px;
}

.field-options {
  display: grid;
  max-height: 190px;
  overflow-y: auto;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.field-option {
  display: flex;
  min-width: 0;
  min-height: 34px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--ink-soft);
  font-size: 12px;
  background: var(--surface);
  align-items: center;
  gap: 7px;
}

.field-option:hover {
  border-color: #b6c9c1;
}

.field-option input {
  width: 14px;
  height: 14px;
  margin: 0;
  flex: 0 0 14px;
  accent-color: var(--primary);
}

.field-option span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.validation-strip {
  display: grid;
  margin-top: 18px;
  padding: 15px 17px;
  border-radius: 7px;
  color: var(--ink-soft);
  background: #eef5f2;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.validation-strip div {
  display: flex;
  flex-direction: column;
}

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

.validation-strip strong {
  font-size: 17px;
}

.validation-strip .is-invalid {
  color: var(--danger);
}

.preview-section {
  margin-top: 22px;
}

.preview-heading {
  display: flex;
  margin-bottom: 10px;
  justify-content: space-between;
  align-items: flex-end;
}

.preview-heading h3 {
  margin-bottom: 1px;
  font-size: 14px;
}

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

.table-scroller {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.preview-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 12px;
}

.preview-table th,
.preview-table td {
  max-width: 230px;
  padding: 9px 11px;
  overflow: hidden;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.preview-table th {
  color: var(--ink-soft);
  font-weight: 650;
  background: #f5f8f6;
}

.preview-table td {
  color: var(--muted);
}

.preview-table tr:last-child td {
  border-bottom: 0;
}

.preview-table th:last-child,
.preview-table td:last-child {
  border-right: 0;
}

.preview-table .empty-cell {
  padding: 28px;
  color: var(--muted);
  text-align: center;
}

.preview-table .income-cell {
  color: var(--primary-strong);
  font-weight: 650;
}

.inline-message {
  margin-top: 15px;
  padding: 10px 12px;
  border-radius: 5px;
  color: var(--danger);
  font-size: 12px;
  background: var(--danger-soft);
}

.inline-message.is-success {
  color: #126756;
  background: #eaf7f1;
}

.import-actions {
  display: flex;
  margin-top: 23px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  justify-content: space-between;
  align-items: center;
  gap: 18px;
}

.import-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.import-mode label {
  display: flex;
  min-width: 210px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  cursor: pointer;
  align-items: flex-start;
  gap: 8px;
}

.import-mode label:has(input:checked) {
  border-color: #9ecabf;
  background: var(--primary-soft);
}

.import-mode input {
  margin: 3px 0 0;
  accent-color: var(--primary);
}

.import-mode span {
  display: flex;
  flex-direction: column;
}

.import-mode strong {
  color: var(--ink-soft);
  font-size: 12px;
}

.import-mode small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.import-actions p {
  display: inline-flex;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  align-items: center;
  gap: 6px;
}

.import-actions p svg {
  width: 15px;
  height: 15px;
}

.footer {
  display: flex;
  min-height: 58px;
  padding: 0 34px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  background: rgba(255, 255, 255, 0.74);
  justify-content: space-between;
  align-items: center;
}

.toast-region {
  position: fixed;
  z-index: 100;
  right: 22px;
  bottom: 22px;
  display: grid;
  width: min(360px, calc(100vw - 32px));
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink-soft);
  font-size: 13px;
  background: var(--surface);
  box-shadow: 0 16px 40px rgba(24, 51, 43, 0.15);
  align-items: flex-start;
  gap: 9px;
  animation: toast-in 220ms ease both;
  pointer-events: auto;
}

.toast svg {
  width: 17px;
  height: 17px;
  flex: 0 0 17px;
  margin-top: 2px;
  color: var(--primary);
}

.toast.is-error svg {
  color: var(--danger);
}

.confirm-dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 28px 70px rgba(13, 34, 28, 0.25);
}

.confirm-dialog::backdrop {
  background: rgba(13, 26, 22, 0.52);
  backdrop-filter: blur(3px);
}

.dialog-icon {
  display: grid;
  width: 46px;
  height: 46px;
  margin-bottom: 17px;
  border-radius: 50%;
  place-items: center;
}

.dialog-icon.danger {
  color: var(--danger);
  background: var(--danger-soft);
}

.dialog-icon svg {
  width: 22px;
  height: 22px;
}

.confirm-dialog h2 {
  margin-bottom: 6px;
  font-size: 20px;
}

.confirm-dialog p {
  color: var(--muted);
  font-size: 13px;
}

.dialog-actions {
  display: flex;
  margin-top: 24px;
  justify-content: flex-end;
  gap: 9px;
}

.danger-button {
  display: inline-flex;
  min-height: 42px;
  padding: 9px 14px;
  border-radius: 6px;
  color: #ffffff;
  font-size: 13px;
  font-weight: 650;
  background: var(--danger);
  justify-content: center;
  align-items: center;
  gap: 7px;
}

.danger-button:hover {
  background: #993632;
}

.is-hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

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

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .topbar {
    padding: 0 22px;
    grid-template-columns: 1fr auto;
  }

  .topbar-status {
    display: none;
  }

  .query-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 32px;
  }

  .admin-dashboard {
    grid-template-columns: 230px minmax(0, 1fr);
  }

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

@media (max-width: 1100px) {
  .query-fields {
    grid-template-columns: minmax(0, 1fr) 210px;
  }

  .query-submit {
    width: 100%;
    grid-column: 1 / -1;
  }

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

  .query-field-batch {
    grid-column: 1 / -1;
  }
}

@media (max-width: 780px) {
  .topbar {
    position: static;
    min-height: auto;
    padding: 16px 18px 14px;
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .topnav {
    width: 100%;
  }

  .nav-button {
    flex: 1;
    justify-content: center;
  }

  .page-wrap {
    width: min(100% - 32px, 620px);
  }

  .query-layout {
    min-height: 0;
    padding-top: 42px;
    padding-bottom: 48px;
    grid-template-columns: 1fr;
    gap: 34px;
  }

  .page-heading h1 {
    font-size: 42px;
  }

  .query-aside {
    padding-top: 0;
  }

  .query-fields {
    grid-template-columns: 1fr;
  }

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

  .query-field-batch {
    grid-column: auto;
  }

  .query-submit {
    grid-column: auto;
  }

  .metric-card {
    padding: 19px;
  }

  .admin-page {
    padding-top: 38px;
  }

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

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

  .admin-summary {
    position: static;
  }

  .summary-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 18px;
  }

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

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

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

@media (max-width: 560px) {
  body {
    background-size: 38px 38px;
  }

  .topbar {
    padding-right: 16px;
    padding-left: 16px;
  }

  .nav-button {
    padding-right: 10px;
    padding-left: 10px;
    font-size: 13px;
  }

  .page-wrap {
    width: calc(100% - 28px);
  }

  .query-layout {
    padding-top: 32px;
  }

  .page-heading h1 {
    font-size: 36px;
  }

  .page-heading p {
    font-size: 15px;
  }

  .query-form {
    margin-top: 30px;
  }

  .query-control {
    min-height: 0;
    padding: 10px;
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .query-control .primary-button {
    min-height: 46px;
    margin-top: 7px;
    grid-column: 1 / -1;
  }

  .query-control input {
    height: 44px;
    font-size: 16px;
  }

  .form-help {
    flex-direction: column;
    gap: 5px;
  }

  .query-result {
    margin-top: 24px;
  }

  .result-placeholder {
    min-height: 225px;
    padding: 26px 18px;
    flex-direction: column;
    text-align: center;
  }

  .record-head {
    padding: 20px 18px;
  }

  .record-identity h2 {
    font-size: 18px;
  }

  .matched-badge {
    display: none;
  }

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

  .metric-card {
    min-height: 0;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric-card:last-child {
    border-bottom: 0;
  }

  .metric-card strong {
    margin-top: 10px;
    font-size: 27px;
  }

  .record-fields {
    grid-template-columns: 1fr;
  }

  .record-field,
  .record-field:nth-child(odd) {
    padding: 14px 18px;
    border-right: 0;
  }

  .record-field.is-wide,
  .record-field:last-child:nth-child(odd) {
    grid-column: auto;
  }

  .record-actions {
    padding: 13px 18px;
  }

  .aside-panel {
    padding: 20px;
  }

  .admin-heading h1 {
    font-size: 36px;
  }

  .auth-panel {
    margin-top: 35px;
    padding: 22px;
  }

  .import-step {
    padding: 20px;
  }

  .drop-zone {
    padding: 20px 15px;
    flex-direction: column;
    text-align: center;
  }

  .drop-copy {
    align-items: center;
  }

  .drop-zone .compact-button {
    width: 100%;
  }

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

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

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

  .field-picker-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-options {
    grid-template-columns: 1fr;
  }

  .validation-strip {
    padding: 13px;
  }

  .validation-strip strong {
    font-size: 15px;
  }

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

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

  .import-mode {
    flex-direction: column;
  }

  .import-mode label {
    width: 100%;
    min-width: 0;
  }

  .file-summary-batch {
    flex-direction: column;
  }

  .file-summary-batch .text-button {
    align-self: flex-end;
  }

  .import-actions .primary-button {
    width: 100%;
  }

  .footer {
    padding: 0 16px;
  }
}

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

.standalone-topbar {
  grid-template-columns: 1fr auto;
}

@media (max-width: 780px) {
  .standalone-topbar {
    grid-template-columns: 1fr;
  }
}
