:root {
  --bg: #f3f4f4;
  --surface: #ffffff;
  --surface-soft: #f7f8f8;
  --line: #e4e7e7;
  --line-strong: #cbd4d3;
  --text: #1d2429;
  --muted: #617073;
  --subtle: #8a9698;
  --primary: #149f91;
  --primary-strong: #0c8278;
  --mint: #d9f3f0;
  --blue-soft: #dceff8;
  --cyan-soft: #d9f6f6;
  --success: #16845b;
  --warning: #a86605;
  --danger: #c2413a;
  --info: #2c68a4;
  --shadow: 0 6px 18px rgba(46, 59, 66, 0.06);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

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

.sidebar {
  background: #fafbfb;
  color: var(--text);
  padding: 18px 14px;
  border-right: 1px solid var(--line);
}

.brand {
  padding: 0 8px 16px;
  border-bottom: 1px solid var(--line);
}

.brand-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

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

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  margin: 16px 0;
  padding: 4px;
  background: #eef3f2;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mode-switch button {
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
}

.mode-switch button.active {
  background: #ffffff;
  color: var(--primary-strong);
  font-weight: 700;
  box-shadow: var(--shadow);
}

.nav-section {
  margin-top: 14px;
}

.nav-title {
  padding: 0 8px 8px;
  color: var(--subtle);
  font-size: 12px;
}

.nav-button {
  width: 100%;
  min-height: 38px;
  margin-bottom: 4px;
  padding: 0 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
}

.nav-button:hover,
.nav-button.active {
  background: #e8f6f3;
  border-color: #ccebe6;
  color: var(--primary-strong);
}

.main {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(243, 244, 244, 0.94);
  backdrop-filter: blur(10px);
}

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

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

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

.content {
  width: 100%;
  max-width: 1480px;
  padding: 22px;
}

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

.hero-panel {
  min-height: 132px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 26px;
  border-radius: 8px;
  background: #d8eff7;
  color: var(--text);
  text-align: center;
  overflow: hidden;
}

.hero-panel h2 {
  margin: 4px 0 8px;
  font-size: 28px;
}

.hero-panel p {
  margin: 0;
  color: var(--muted);
}

.hero-kicker {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary-strong) !important;
}

.section {
  margin-bottom: 18px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  padding: 18px 18px 0;
}

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

.section-header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section-body {
  padding: 18px;
}

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

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

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

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

.metric {
  min-height: 150px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

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

.metric .value {
  margin-top: 8px;
  font-size: 54px;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr repeat(3, 1fr);
  gap: 14px;
}

.quick-card {
  min-height: 150px;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  align-content: center;
  column-gap: 14px;
  padding: 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--blue-soft);
  color: var(--text);
  text-align: left;
}

.quick-card.alt {
  background: var(--cyan-soft);
}

.quick-card:hover {
  border-color: #b8dedc;
  color: var(--primary-strong);
}

.quick-card strong {
  align-self: end;
  font-size: 18px;
}

.quick-card small {
  grid-column: 2;
  color: var(--muted);
  font-size: 13px;
}

.quick-icon {
  grid-row: span 2;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: rgba(20, 159, 145, 0.14);
  color: var(--primary);
  font-size: 27px;
}

.quick-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.rule-card {
  padding: 14px;
  border: 1px solid #d8e7e5;
  border-radius: 8px;
  background: #f8fcfb;
}

.rule-card strong {
  display: block;
  margin-bottom: 7px;
}

.rule-card span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

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

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

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

.btn {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  white-space: nowrap;
}

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

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

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

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

.btn-warning {
  background: #fff7ed;
  color: var(--warning);
  border-color: #f2c37a;
}

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

.btn-plain {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
}

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

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

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

th {
  color: var(--muted);
  background: var(--surface-soft);
  font-weight: 700;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: #eef1f5;
  color: var(--muted);
}

.status.success {
  background: #e6f5ee;
  color: var(--success);
}

.status.info {
  background: #e8f1fb;
  color: var(--info);
}

.status.warning {
  background: #fff4df;
  color: var(--warning);
}

.status.danger {
  background: #fdecea;
  color: var(--danger);
}

.status.default {
  background: #eef1f5;
  color: var(--muted);
}

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

.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 16px;
  box-shadow: var(--shadow);
}

.item-card h3 {
  margin: 0;
  font-size: 16px;
}

.item-card .meta {
  display: grid;
  gap: 5px;
  margin: 12px 0;
  color: var(--muted);
  font-size: 13px;
}

.item-card .actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.notice {
  margin-bottom: 14px;
  padding: 12px 14px;
  border: 1px solid #f0d292;
  border-radius: 8px;
  background: #fff9eb;
  color: #6d4f12;
  font-size: 13px;
}

.notice.info {
  border-color: #a8c6e6;
  background: #edf6ff;
  color: #224f7b;
}

.notice.danger {
  border-color: #f0aaa6;
  background: #fff0ef;
  color: #8d2e28;
}

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

.timeline-item {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.timeline-item strong {
  color: var(--text);
}

.split {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 18px;
}

.admin-only {
  display: block;
}

.empty {
  padding: 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 50;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: var(--text);
}

.mobile-top {
  display: none;
}

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

  .sidebar {
    display: none;
  }

  .mobile-top {
    display: block;
    background: #fafbfb;
    color: var(--text);
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
  }

  .mobile-top .toolbar {
    margin-top: 10px;
  }

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

  .content {
    padding: 16px;
  }

  .grid-2,
  .grid-3,
  .grid-4,
  .split,
  .filters,
  .form-grid,
  .card-list,
  .quick-grid,
  .rule-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    min-height: 150px;
    align-items: center;
    text-align: center;
  }

  .hero-panel h2 {
    font-size: 28px;
  }

  .metric {
    min-height: 190px;
  }

  .section-header {
    flex-direction: column;
    padding: 16px 16px 0;
  }

  .section-body {
    padding: 16px;
  }

  .toolbar {
    width: 100%;
  }

  .toolbar .btn,
  .toolbar .input {
    flex: 1 1 auto;
  }

  .timeline-item {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

@media (max-width: 560px) {
  .topbar h1 {
    font-size: 18px;
  }

  .btn {
    width: 100%;
  }

  .item-card .actions .btn,
  .row-actions .btn {
    width: auto;
    flex: 1 1 110px;
  }
}
