:root {
  --ink: #13231f;
  --muted: #63716d;
  --line: #dce6e2;
  --panel: #ffffff;
  --soft: #f5f8f6;
  --soft-2: #eef5f2;
  --green: #0f6b55;
  --green-2: #14846b;
  --teal: #0e8b91;
  --blue: #2f66a1;
  --amber: #b56b16;
  --red: #b33a3a;
  --shadow: 0 10px 30px rgba(18, 35, 31, 0.08);
  color-scheme: light;
  font-family: Inter, "Segoe UI", Arial, "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #f7faf8;
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px 18px;
  background: #102721;
  color: #eef7f3;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 26px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: #145f3a;
  border: 1px solid rgba(255, 255, 255, 0.16);
  overflow: hidden;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand strong {
  display: block;
  font-size: 16px;
}

.brand span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: #a6c8bd;
}

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

.nav button {
  border: 0;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  border-radius: 8px;
  color: #d5e7e0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}

.nav button:hover,
.nav button.active {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.nav-icon {
  width: 18px;
  text-align: center;
  color: #78d1bd;
  flex: 0 0 auto;
}

.workspace-card {
  margin-top: 22px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.workspace-card .label {
  color: #a6c8bd;
  font-size: 12px;
}

.workspace-card .value {
  margin-top: 6px;
  font-weight: 700;
}

.identity-picker {
  position: relative;
  margin-top: 8px;
}

.identity-display {
  min-height: 58px;
  padding: 8px 30px 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  display: grid;
  align-content: center;
  gap: 3px;
}

.identity-display::after {
  content: "⌄";
  position: absolute;
  right: 11px;
  top: 18px;
  color: #a6c8bd;
  font-size: 16px;
  pointer-events: none;
}

.identity-display strong,
.identity-display span {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity-display strong {
  font-size: 13px;
  line-height: 1.25;
}

.identity-display span {
  color: #d7eee6;
  font-size: 12px;
  line-height: 1.25;
}

.identity-select {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  opacity: 0;
  cursor: pointer;
}

.identity-picker:focus-within .identity-display {
  border-color: #5fbda8;
  box-shadow: 0 0 0 3px rgba(95, 189, 168, 0.2);
}

.identity-select option {
  color: #13231f;
}

.identity-meta {
  display: grid;
  gap: 4px;
  margin-top: 10px;
  font-size: 12px;
}

.identity-meta span {
  color: #a6c8bd;
}

.identity-meta strong {
  color: #ffffff;
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.role-select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 7px 9px;
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  white-space: normal;
}

.role-select option {
  color: #13231f;
}

.sidebar-link {
  width: 100%;
  margin-top: 12px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  min-height: 36px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef7f3;
  cursor: pointer;
}

.demo-identity-note {
  margin-top: 12px;
  padding: 10px;
  border: 1px solid rgba(255, 214, 130, 0.35);
  border-radius: 8px;
  background: rgba(255, 246, 229, 0.08);
  color: #f7ead0;
}

.demo-identity-note strong {
  display: block;
  margin-bottom: 4px;
  color: #ffe0a6;
  font-size: 12px;
  line-height: 1.25;
}

.demo-identity-note span {
  display: block;
  font-size: 11px;
  line-height: 1.4;
  color: #f1dcc0;
}

.main {
  min-width: 0;
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef5f2;
}

.auth-card {
  width: min(440px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 26px;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 22px;
}

.auth-brand strong,
.auth-brand span {
  display: block;
}

.auth-brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.auth-card h1 {
  margin: 0;
  font-size: 24px;
}

.auth-card p {
  margin: 8px 0 18px;
  color: var(--muted);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 12px;
}

.auth-form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 700;
  color: #42514d;
}

.auth-form input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
}

.captcha-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captcha-row img {
  width: 160px;
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef5f2;
}

.auth-notice {
  margin-bottom: 14px;
  border: 1px solid #bfe4d7;
  border-radius: 8px;
  background: #ecf8f3;
  color: #153f35;
  padding: 10px 12px;
  font-size: 13px;
}

.link-button {
  margin-top: 14px;
  border: 0;
  background: transparent;
  color: var(--green);
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}

.admin-page {
  min-height: 100vh;
  background: #f7faf8;
}

.admin-header {
  min-height: 74px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.admin-main {
  padding: 24px 28px 42px;
}

.admin-users {
  display: grid;
  gap: 12px;
}

.admin-user-row {
  display: grid;
  grid-template-columns: minmax(220px, 0.7fr) minmax(320px, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.admin-user-row strong,
.admin-user-row span {
  display: block;
}

.admin-user-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.role-checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.role-checks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 74px;
  padding: 16px 28px;
  background: rgba(247, 250, 248, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.title-block h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.2;
  letter-spacing: 0;
}

.title-block p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 14px;
}

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

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  min-height: 38px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.btn.primary {
  border-color: var(--green);
  background: var(--green);
  color: #ffffff;
}

.btn.small {
  min-height: 30px;
  padding: 5px 9px;
  font-size: 12px;
}

.btn:hover {
  box-shadow: 0 4px 14px rgba(18, 35, 31, 0.1);
}

.content {
  padding: 24px 28px 42px;
}

.notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #bfe4d7;
  border-radius: 8px;
  background: #ecf8f3;
  color: #153f35;
  box-shadow: var(--shadow);
}

.notice strong {
  display: block;
  margin-bottom: 2px;
}

.notice p {
  margin: 0;
  color: #345f55;
  font-size: 13px;
}

.notice a {
  color: var(--green);
  font-weight: 800;
}

.notice button {
  border: 0;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 24, 20, 0.45);
}

.modal {
  width: min(560px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 20px 70px rgba(8, 24, 20, 0.28);
}

.match-detail-modal {
  width: min(1080px, 100%);
  max-height: min(88vh, 920px);
  display: flex;
  flex-direction: column;
}

.modal-head,
.modal-foot {
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.modal-foot {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  justify-content: flex-end;
}

.modal h3 {
  margin: 0;
  font-size: 18px;
}

.modal-body {
  padding: 16px;
  display: grid;
  gap: 12px;
}

.match-detail-modal .modal-body {
  overflow: auto;
}

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

.field label {
  font-size: 13px;
  font-weight: 700;
  color: #42514d;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
}

.field textarea {
  min-height: 88px;
  resize: vertical;
}

.grid {
  display: grid;
  gap: 16px;
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.metric {
  padding: 18px;
}

.metric .label {
  color: var(--muted);
  font-size: 13px;
}

.metric .value {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
}

.metric .delta {
  margin-top: 10px;
  font-size: 12px;
  color: var(--green);
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(360px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

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

.panel {
  padding: 18px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 17px;
}

.panel .sub {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.chart {
  display: grid;
  gap: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--soft-2);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--green-2), var(--teal));
}

.trend {
  width: 100%;
  height: 180px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  width: 100%;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
  background: var(--panel);
}

th,
td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  color: #42514d;
  font-weight: 700;
  background: var(--soft);
}

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

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.ok {
  background: #dff5ec;
  color: #0f6b55;
}

.warn {
  background: #fff0d6;
  color: #92500d;
}

.bad {
  background: #ffe1df;
  color: #9b2f2f;
}

.info {
  background: #e1eefb;
  color: #255988;
}

.neutral {
  background: #edf1ef;
  color: #52615d;
}

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

.steps {
  display: grid;
  gap: 10px;
}

.process-items {
  display: grid;
  gap: 10px;
}

.process-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.process-item strong {
  display: block;
  font-size: 13px;
}

.process-item span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.step {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.step-num {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #ffffff;
  background: var(--green);
  font-weight: 800;
}

.step strong {
  display: block;
  font-size: 13px;
}

.step span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.record-pair {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
}

.mini-record {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.mini-record .meta {
  color: var(--muted);
  font-size: 12px;
}

.mini-record .amount {
  margin-top: 8px;
  font-size: 20px;
  font-weight: 800;
}

.match-score {
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #e6f4ef;
  color: var(--green);
  font-weight: 800;
}

.evidence {
  margin-top: 12px;
  padding: 12px;
  border-left: 4px solid var(--teal);
  background: #eef8f8;
  border-radius: 0 8px 8px 0;
  color: #29433f;
  font-size: 13px;
  line-height: 1.55;
}

.detail-body {
  gap: 16px;
}

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

.detail-summary div,
.detail-box,
.audit-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.detail-summary span,
.detail-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.detail-summary strong,
.detail-box strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.detail-section {
  display: grid;
  gap: 10px;
}

.detail-section h4 {
  margin: 0;
  font-size: 15px;
}

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

.detail-box p,
.audit-box p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.audit-box span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.row-actions {
  min-width: 230px;
}

.filterbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.filterbar select,
.filterbar input {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  min-height: 38px;
  padding: 8px 10px;
  min-width: 170px;
}

.footer-note {
  margin-top: 16px;
  color: var(--muted);
  font-size: 12px;
}

.report-preview {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

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

  .section-grid,
  .split {
    grid-template-columns: 1fr;
  }
}

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

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

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

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

  .content {
    padding: 16px;
  }

  .notice {
    flex-direction: column;
    gap: 8px;
  }

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

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

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

  .match-score {
    min-height: 48px;
  }
}
