:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --line: #dfe5ee;
  --line-strong: #c9d3e2;
  --text: #1f2937;
  --muted: #667085;
  --soft: #eef3f9;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #12925b;
  --warning: #b7791f;
  --danger: #c2412d;
  --info: #0f766e;
  --sidebar: #172033;
  --sidebar-soft: #253149;
  --shadow: 0 12px 36px rgba(31, 41, 55, 0.14);
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--text);
  background: var(--bg);
}

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

.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 16px 0 6px;
  font-size: 24px;
}

.muted {
  color: var(--muted);
  margin: 0 0 22px;
}

.brand-mark.large {
  width: 48px;
  height: 48px;
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form label,
.drawer-form label {
  display: grid;
  gap: 6px;
  color: #475467;
  font-size: 13px;
}

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

.wide {
  width: 100%;
}

.form-error {
  min-height: 20px;
  color: var(--danger);
  font-size: 13px;
}

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

.loading {
  padding: 30px;
  color: var(--muted);
}

.toast {
  position: fixed;
  right: 18px;
  top: 18px;
  z-index: 100;
  max-width: min(360px, calc(100vw - 36px));
  border-radius: 8px;
  padding: 12px 14px;
  color: #ffffff;
  box-shadow: var(--shadow);
}

.toast.success {
  background: var(--success);
}

.toast.error {
  background: var(--danger);
}

.modal-layer {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.38);
  z-index: 80;
}

.modal {
  width: min(560px, 100%);
  max-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

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

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

.modal-body {
  padding: 16px;
  overflow: auto;
}

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

.config-save {
  margin-top: 14px;
  padding: 14px 16px;
  display: flex;
  justify-content: flex-end;
}

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: var(--sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px 18px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2f80ed;
  font-weight: 800;
}

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

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

.menu {
  display: grid;
  gap: 4px;
  padding: 14px 10px;
}

.menu-item {
  height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #cbd5e1;
  background: transparent;
  text-align: left;
}

.menu-item:hover,
.menu-item.active {
  color: #ffffff;
  background: var(--sidebar-soft);
}

.main {
  min-width: 0;
}

.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.3;
}

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

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

.content {
  padding: 20px 22px 32px;
}

.toolbar,
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr)) auto;
  gap: 12px;
  align-items: end;
  padding: 14px;
  margin-bottom: 14px;
}

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

.form-field label {
  color: #475467;
  font-size: 13px;
}

.input,
.select,
.textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  background: #ffffff;
}

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

.toolbar-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 0 13px;
  white-space: nowrap;
}

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

.primary-button:hover {
  background: var(--primary-dark);
}

.secondary-button {
  color: #344054;
  background: #ffffff;
  border-color: var(--line-strong);
}

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

.icon-button {
  width: 36px;
  padding: 0;
  background: #ffffff;
  border-color: var(--line-strong);
}

.mobile-menu {
  display: none;
}

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

.stat-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

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

.stat-card strong {
  display: block;
  margin-top: 8px;
  font-size: 28px;
}

.stat-card small {
  color: var(--success);
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 14px;
}

.panel {
  overflow: hidden;
}

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

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

.panel-header p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 12px;
}

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

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

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

th {
  color: #475467;
  background: #f8fafc;
  font-weight: 600;
}

tr:hover td {
  background: #fbfdff;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.link-button {
  border: 0;
  padding: 0;
  color: var(--primary);
  background: transparent;
}

.link-button.danger {
  color: var(--danger);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 600;
}

.badge.success {
  color: #067647;
  background: #dcfae6;
}

.badge.warning {
  color: #93370d;
  background: #fef0c7;
}

.badge.danger {
  color: #b42318;
  background: #fee4e2;
}

.badge.info {
  color: #0e6f78;
  background: #ccfbef;
}

.badge.gray {
  color: #475467;
  background: #eef2f6;
}

.pagination {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 14px;
  color: var(--muted);
  font-size: 13px;
}

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

.setting-block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.setting-block h3 {
  margin: 0 0 14px;
  font-size: 16px;
}

.switch-row {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

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

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cbd5e1;
}

.slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.18s ease;
}

.switch input:checked + .slider {
  background: var(--primary);
}

.switch input:checked + .slider::after {
  transform: translateX(20px);
}

.timeline {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.timeline-item time {
  color: var(--muted);
  font-size: 12px;
}

.timeline-item strong {
  display: block;
  font-size: 14px;
}

.timeline-item span {
  color: var(--muted);
  font-size: 13px;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  z-index: 40;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(520px, 100vw);
  height: 100vh;
  background: var(--panel);
  box-shadow: var(--shadow);
  z-index: 50;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.drawer-header,
.drawer-footer {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

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

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

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

.drawer-body {
  padding: 16px;
  overflow: auto;
}

.drawer-form {
  display: grid;
  gap: 14px;
}

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

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

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

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

  .sidebar {
    position: fixed;
    left: -260px;
    width: 248px;
    transition: left 0.2s ease;
  }

  .sidebar.open {
    left: 0;
  }

  .mobile-menu {
    display: inline-grid;
    place-items: center;
    flex: 0 0 auto;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-actions {
    display: none;
  }

  .content {
    padding: 14px;
  }

  .toolbar,
  .stats-grid,
  .settings-grid,
  .split-grid {
    grid-template-columns: 1fr;
  }

  .toolbar-actions {
    justify-content: stretch;
  }

  .toolbar-actions button {
    flex: 1;
  }
}
