:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-soft: #f9fafb;
  --text: #172033;
  --muted: #657084;
  --line: #dbe1ea;
  --line-soft: #edf0f5;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eaf1ff;
  --green: #169b62;
  --green-soft: #e8f7ef;
  --amber: #b7791f;
  --amber-soft: #fff4df;
  --red: #c2413b;
  --red-soft: #fff0ef;
  --cyan: #0e7490;
  --cyan-soft: #e8f7fb;
  --purple: #7048b8;
  --purple-soft: #f1edfb;
  --shadow: 0 12px 30px rgba(25, 35, 55, 0.08);
  --radius: 8px;
  --sidebar: 248px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1120px;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.5;
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(420px, 0.95fr) minmax(560px, 1.35fr);
  background: #f2f5f9;
}

.login-brand {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border-right: 1px solid var(--line);
  color: #ffffff;
  background: #041426;
}

.login-brand-visual {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.login-brand-content {
  position: relative;
  z-index: 1;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 750;
  font-size: 20px;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(135deg, #2563eb, #0e7490);
  border-radius: 8px;
  font-weight: 800;
}

.login-copy h1 {
  margin: 42px 0 0;
  max-width: 520px;
  font-size: 40px;
  line-height: 1.16;
  letter-spacing: 0;
  text-wrap: balance;
}

.login-brand-footer {
  position: relative;
  z-index: 1;
  color: rgba(255, 255, 255, 0.7);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0;
}

.login-form-wrap {
  display: grid;
  place-items: center;
  padding: 48px;
}

.login-form {
  width: 420px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 32px;
}

.login-form h2 {
  margin: 0 0 6px;
  font-size: 24px;
}

.login-form .muted {
  margin-bottom: 24px;
}

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

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #ffffff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}

.sidebar-header {
  height: 68px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar-title {
  min-width: 0;
}

.sidebar-title strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
}

.sidebar-title span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.nav {
  padding: 16px 12px 24px;
  overflow-y: auto;
}

.nav-group {
  margin-bottom: 18px;
}

.nav-group-title {
  padding: 0 10px 6px;
  color: #8a94a6;
  font-size: 12px;
  font-weight: 700;
}

.nav-item {
  width: 100%;
  height: 38px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px;
  border-radius: 8px;
  color: #3d4758;
  text-align: left;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--surface-soft);
}

.nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
  font-weight: 700;
}

.nav-symbol {
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #eef2f8;
  color: #4b5565;
  font-size: 12px;
  font-weight: 800;
  flex: 0 0 auto;
}

.nav-item.active .nav-symbol {
  background: #ffffff;
  color: var(--primary);
}

.sidebar-footer {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--line-soft);
}

.admin-mini {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  background: var(--surface-soft);
}

.avatar {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #ffffff;
  background: #172033;
  font-weight: 800;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(246, 247, 249, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0;
}

.topbar-subtitle {
  color: var(--muted);
  font-size: 12px;
}

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

.page {
  padding: 24px 28px 44px;
}

.section {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.section + .section {
  margin-top: 16px;
}

.section-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.section-title {
  margin: 0;
  font-size: 16px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 12px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

.deduction-overview {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.deduction-preview-panel {
  padding-top: 2px;
}

.deduction-preview-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.deduction-preview-grid > div {
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #ffffff;
}

.deduction-preview-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.deduction-preview-grid strong {
  display: block;
  margin-top: 6px;
  font-size: 20px;
}

.deduction-preview-grid .is-result {
  border-color: #b9cffb;
  background: var(--primary-soft);
}

.deduction-preview-grid .is-result strong,
.monitor-count {
  color: var(--primary);
}

.metric {
  min-height: 112px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

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

.metric-value {
  margin-top: 14px;
  font-size: 26px;
  line-height: 1.1;
  font-weight: 780;
}

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

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(360px, 0.7fr);
  gap: 16px;
  margin-top: 16px;
}

.chart {
  height: 292px;
  padding: 18px;
}

.chart-bars {
  height: 188px;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  align-items: end;
  gap: 12px;
  padding: 12px 2px 0;
}

.bar-wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.bar {
  width: 100%;
  min-width: 22px;
  max-width: 48px;
  border-radius: 6px 6px 2px 2px;
  background: linear-gradient(180deg, #2563eb, #0e7490);
}

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

.alert-list {
  padding: 12px 16px 16px;
}

.alert-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}

.alert-row:last-child {
  border-bottom: 0;
}

.alert-title {
  font-weight: 700;
}

.alert-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(130px, 1fr)) auto;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.filter-bar.wide {
  grid-template-columns: 1.25fr 1fr 1fr 1fr 1fr auto;
}

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

.field label {
  color: #4b5565;
  font-size: 12px;
  font-weight: 700;
}

.chip-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-option {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.chip-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-option:has(input:checked) {
  border-color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

.event-values {
  gap: 10px;
}

.event-value-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.event-value-row {
  display: grid;
  gap: 6px;
}

.event-value-name {
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.event-value-row.is-disabled {
  opacity: 0.45;
}

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

.secret-field-list,
.link-secret-value-list {
  display: grid;
  gap: 10px;
}

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

.secret-required {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.secret-required input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.secret-add {
  width: fit-content;
  margin-top: 4px;
}

.link-secret-value-row {
  display: grid;
  grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr);
  align-items: center;
  gap: 8px;
}

.link-secret-key {
  background: #f2f5f9;
  color: #475569;
  font-weight: 720;
  cursor: default;
}

.link-secret-card {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.link-secret-card > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.link-secret-card span {
  color: var(--muted);
  font-size: 12px;
}

.link-secret-card strong {
  color: #152033;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.link-secret-card.is-empty {
  grid-template-columns: 1fr;
  color: #4b5565;
}

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

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

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

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

.report-table {
  min-width: 1680px;
}

th,
td {
  height: 48px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line-soft);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  color: #526071;
  background: #fbfcfe;
  font-size: 12px;
  font-weight: 760;
}

td {
  color: #263244;
}

tr:hover td {
  background: #fbfcfe;
}

.cell-strong {
  font-weight: 740;
}

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

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 720;
}

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

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

.tag.red {
  color: var(--red);
  background: var(--red-soft);
}

.tag.blue {
  color: var(--primary);
  background: var(--primary-soft);
}

.tag.cyan {
  color: var(--cyan);
  background: var(--cyan-soft);
}

.tag.purple {
  color: var(--purple);
  background: var(--purple-soft);
}

.tag.gray {
  color: #586274;
  background: #edf0f5;
}

.btn {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #2f3a4b;
  font-size: 13px;
  font-weight: 720;
}

.btn:hover {
  border-color: #c3ccd9;
  background: #fbfcfe;
}

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

.btn.primary:hover {
  border-color: var(--primary-dark);
  background: var(--primary-dark);
}

.btn.danger {
  border-color: #f2c8c6;
  background: var(--red-soft);
  color: var(--red);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

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

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

.tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px 0;
}

.tab {
  min-height: 36px;
  padding: 8px 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 740;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

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

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

.form-grid .full {
  grid-column: 1 / -1;
}

.drawer-backdrop,
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(15, 23, 42, 0.32);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 70;
  width: min(720px, 82vw);
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  box-shadow: -14px 0 34px rgba(15, 23, 42, 0.16);
}

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 70;
  width: min(780px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: 8px;
  box-shadow: var(--shadow);
  transform: translate(-50%, -50%);
}

.drawer-header,
.modal-header {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.drawer-header h2,
.modal-header h2 {
  margin: 0;
  font-size: 18px;
}

.drawer-body,
.modal-body {
  padding: 18px 20px 22px;
  overflow: auto;
}

.drawer-footer,
.modal-footer {
  margin-top: auto;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  background: #fbfcfe;
}

.close-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

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

.detail-item {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #fbfcfe;
}

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

.detail-value {
  margin-top: 6px;
  font-weight: 720;
  word-break: break-all;
}

.code-box {
  margin-top: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101827;
  color: #dbeafe;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-all;
}

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

.step {
  min-height: 130px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.step.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.08);
}

.step-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 760;
}

.step-desc {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
}

.step-actions {
  margin-top: 14px;
}

.template-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.template-tip-panel {
  padding: 12px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: #f8fafc;
}

.template-tip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.template-tip-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
}

.field-tip {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #e0ecff;
  color: var(--primary);
  font-size: 12px;
  font-weight: 800;
  cursor: help;
}

.template-guide {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
}

.template-guide strong {
  flex: 0 0 auto;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line-soft);
}

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

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 6px;
  font-size: 18px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: 380px;
  padding: 12px 14px;
  border: 1px solid #b7d5c5;
  border-radius: 8px;
  background: #f0fbf5;
  color: #145b3d;
  box-shadow: var(--shadow);
  font-weight: 720;
}

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

@media (max-width: 900px) {
  body {
    min-width: 0;
  }

  .login-shell {
    grid-template-columns: 1fr;
  }

  .login-brand {
    min-height: 420px;
    padding: 34px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .login-brand-visual {
    object-position: center 42%;
  }

  .login-copy h1 {
    max-width: 520px;
    font-size: 32px;
  }

  .login-form {
    width: 100%;
    max-width: 420px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

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

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

  .main {
    min-width: 0;
  }

  .page {
    padding: 18px;
  }

  .metric-grid,
  .deduction-overview,
  .dashboard-grid,
  .stat-row,
  .steps,
  .form-grid,
  .split {
    grid-template-columns: 1fr;
  }

  .filter-bar,
  .filter-bar.wide {
    grid-template-columns: 1fr;
  }

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

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

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

  .deduction-preview-grid .is-result {
    grid-column: 1 / -1;
  }
}
