:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #637089;
  --line: #dbe3ee;
  --blue: #176b87;
  --blue-dark: #0f4c68;
  --green: #1f8a5b;
  --red: #c24141;
  --amber: #a16207;
  --green-soft: #e8f7ef;
  --red-soft: #fdecec;
  --amber-soft: #fff7df;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
}

button {
  font: inherit;
}

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

.dashboard-shell {
  width: min(1520px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 4px 0 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  color: var(--blue-dark);
  font-size: 28px;
  line-height: 1.2;
}

h2 {
  color: var(--blue-dark);
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  font-size: 16px;
  line-height: 1.3;
}

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

.source-box {
  min-width: 260px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

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

.source-box strong {
  display: block;
  margin-top: 4px;
  color: var(--blue-dark);
  font-size: 14px;
  overflow-wrap: anywhere;
}

.topbar-side {
  display: grid;
  gap: 8px;
  justify-items: end;
}

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

.topbar-actions button,
.topbar-actions .button-like {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
}

.topbar-actions button:last-child {
  background: #536173;
}

.topbar-actions button.is-disabled,
.topbar-actions .button-like.is-disabled {
  cursor: wait;
  opacity: 0.66;
  pointer-events: none;
}

.account-summary {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px 16px;
  color: var(--muted);
  font-size: 14px;
}

.import-status {
  max-width: 360px;
  margin: 0;
  text-align: right;
}

.import-status.error,
.form-error {
  color: var(--red);
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(360px, 100%);
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(20, 35, 60, 0.04);
}

.login-panel label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.login-panel input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
}

.login-panel button {
  width: 100%;
  min-height: 38px;
  margin-top: 16px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.form-error {
  min-height: 20px;
  margin: 12px 0 0;
  font-size: 13px;
}

.module-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
}

.module-tabs a {
  min-height: 34px;
  padding: 8px 14px;
  border-radius: 6px;
  color: var(--blue-dark);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.module-tabs a:hover {
  background: #e8f2f7;
}

.module-section {
  margin-top: 18px;
  scroll-margin-top: 72px;
}

.module-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 12px;
}

.metric-grid {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}

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

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

.metric-card,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 1px 2px rgba(20, 35, 60, 0.04);
}

.metric-card {
  min-height: 118px;
  padding: 16px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-size: 26px;
  line-height: 1.1;
}

.metric-card small {
  display: inline-flex;
  align-items: center;
  margin-top: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f7;
  color: var(--muted);
}

.metric-card small.good,
.delta.good {
  background: var(--green-soft);
  color: var(--green);
}

.metric-card small.bad,
.delta.bad {
  background: var(--red-soft);
  color: var(--red);
}

.layout-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(340px, 0.72fr);
  gap: 14px;
  margin-bottom: 14px;
}

.service-grid {
  grid-template-columns: minmax(0, 1.55fr) minmax(340px, 0.72fr);
}

.panel {
  overflow: hidden;
}

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

.canvas-wrap {
  height: 340px;
  padding: 10px 16px 18px;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.segmented,
.table-actions {
  display: inline-flex;
  gap: 6px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.segment,
.icon-button {
  min-height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segment.active,
.icon-button.active {
  background: var(--blue);
  color: #ffffff;
}

.bar-list {
  display: grid;
  gap: 14px;
  padding: 16px 18px 20px;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
}

.bar-label strong {
  color: var(--blue-dark);
}

.bar-label span {
  color: var(--muted);
}

.bar-track {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef5;
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.comparison-list {
  display: grid;
  gap: 10px;
  padding: 16px 18px 20px;
}

.comparison-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.comparison-item span,
.comparison-item small {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.comparison-item strong {
  display: block;
  margin-top: 5px;
  color: var(--blue-dark);
  font-size: 18px;
}

.comparison-meta {
  text-align: right;
}

.comparison-meta em {
  display: inline-flex;
  margin-top: 6px;
  padding: 3px 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.comparison-meta em.good {
  background: var(--green-soft);
  color: var(--green);
}

.comparison-meta em.bad {
  background: var(--red-soft);
  color: var(--red);
}

.service-radar {
  min-height: 100%;
}

.service-summary {
  display: grid;
  gap: 10px;
  padding: 16px 18px 8px;
}

.service-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdff;
}

.service-summary strong {
  display: block;
  margin-top: 6px;
  color: var(--blue-dark);
  font-size: 16px;
  overflow-wrap: anywhere;
}

.note-text {
  margin: 6px 18px 18px;
  padding: 12px;
  border-radius: 8px;
  background: var(--amber-soft);
  color: #704d00;
  font-size: 13px;
  line-height: 1.55;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
}

.compact table {
  min-width: 920px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  font-size: 13px;
  white-space: nowrap;
}

th {
  background: #e8f2f7;
  color: var(--blue-dark);
  font-weight: 700;
}

th:first-child,
td:first-child,
th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

tbody tr:nth-child(even) {
  background: #f8fbfd;
}

.delta {
  display: inline-flex;
  justify-content: flex-end;
  min-width: 70px;
  padding: 3px 7px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f7;
  color: var(--muted);
}

.badge.good {
  background: var(--green-soft);
  color: var(--green);
}

.badge.bad {
  background: var(--amber-soft);
  color: var(--amber);
}

.badge.empty {
  background: #e9edf3;
  color: #536173;
}

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

.modal {
  width: min(760px, 100%);
  max-height: min(720px, 90vh);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.22);
}

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

.modal-head h2 {
  font-size: 20px;
}

.import-modal {
  max-width: 720px;
}

.import-rules {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
}

.import-rules p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.import-file-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.import-file-row button,
.template-download,
.modal-actions button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.template-download {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  text-decoration: none;
}

.modal-actions button.secondary {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
}

.import-modal-status {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  line-height: 1.5;
}

.import-modal-status.error {
  border-color: #fecaca;
  background: var(--red-soft);
  color: var(--red);
}

.import-modal-status.success {
  border-color: #bbf7d0;
  background: var(--green-soft);
  color: var(--green);
}

.import-result {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-result h3 {
  margin: 0 0 12px;
  font-size: 16px;
}

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

.import-result-card {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.import-result-card strong {
  font-size: 14px;
}

.import-result-card span {
  font-size: 20px;
  font-weight: 700;
}

.import-result-card small {
  color: var(--muted);
  line-height: 1.5;
}

.import-warning-list {
  margin: 12px 0 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.6;
}

.ghost-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  font-weight: 700;
  cursor: pointer;
}

.user-form,
.user-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
}

.user-form {
  margin-bottom: 12px;
}

.user-form label,
.user-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
}

.user-form input,
.user-row input {
  min-width: 0;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  color: var(--text);
  font: inherit;
}

.user-form button,
.user-row button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  background: var(--blue);
  color: #ffffff;
  font-weight: 700;
  cursor: pointer;
}

.user-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.user-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f8fafc;
}

.user-row > div {
  display: grid;
  gap: 4px;
}

.user-row span,
.user-row small {
  color: var(--muted);
}

@media (max-width: 1100px) {
  .dashboard-shell {
    width: min(100% - 24px, 1520px);
  }

  .topbar,
  .module-title,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-side {
    justify-items: stretch;
  }

  .source-box {
    min-width: 0;
  }

  .account-summary {
    justify-content: flex-start;
  }

  .import-status {
    max-width: none;
    text-align: left;
  }

  .import-result-grid {
    grid-template-columns: 1fr;
  }

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

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

@media (max-width: 640px) {
  .dashboard-shell {
    width: min(100% - 16px, 1520px);
  }

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

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

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