:root {
  --green: #4a7c59;
  --green-dark: #315b3e;
  --line: #e8e8e2;
  --muted: #777;
  --bg: #f7f7f2;
  --danger: #c43d2f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: #2d2d2a;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

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

.login-panel {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 32px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
}

.brand,
.sidebar-brand {
  color: var(--green);
  font-weight: 700;
}

.login-panel h1 {
  margin: 8px 0 28px;
}

label {
  display: grid;
  gap: 8px;
  color: #555;
  font-size: 14px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  color: #222;
}

textarea {
  resize: vertical;
}

.primary-btn,
.secondary-btn,
.nav-item,
.logout-btn,
.icon-btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.primary-btn {
  width: 100%;
  margin-top: 20px;
  padding: 11px 16px;
  background: var(--green);
  color: #fff;
  font-weight: 600;
}

.secondary-btn {
  padding: 9px 14px;
  background: #fff;
  color: var(--green);
  border: 1px solid var(--line);
}

.primary-btn-sm {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 9px 18px;
  background: var(--green);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}

.primary-btn-sm:hover {
  background: var(--green-dark);
}

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

.login-panel label + label {
  margin-top: 14px;
}

.admin-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}

.sidebar {
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-brand {
  font-size: 18px;
  margin-bottom: 20px;
}

.nav-item,
.logout-btn {
  width: 100%;
  padding: 11px 12px;
  text-align: left;
  background: transparent;
  color: #444;
}

.nav-item.active {
  background: #edf5ef;
  color: var(--green-dark);
  font-weight: 700;
}

.logout-btn {
  margin-top: auto;
  color: var(--danger);
}

.content {
  min-width: 0;
  padding: 28px;
}

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

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

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

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

.metric-card,
.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.metric-card {
  padding: 18px;
}

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

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

.panel {
  overflow: hidden;
}

.panel-title {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

/* 图表整体布局 */
.chart-wrapper {
  display: flex;
  gap: 0;
  align-items: stretch;
}

/* ECharts 趋势图容器 */
.trend-chart {
  width: 100%;
  height: 320px;
}

.table-tools {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.table-tools-spacer {
  flex: 1;
}

.search-input {
  max-width: 320px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

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

th {
  color: var(--muted);
  font-weight: 600;
  background: #fbfbf8;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.status-success {
  color: var(--green);
  font-weight: 700;
}

.status-failed {
  color: var(--danger);
  font-weight: 700;
}

.row-action {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
}

.row-action-edit {
  color: var(--green);
  background: #edf5ef;
}

.row-action-edit:hover {
  background: #d4e8d8;
}

.row-action-del {
  color: var(--danger);
  background: #fef0ef;
}

.row-action-del:hover {
  background: #fde0dc;
}

.col-actions {
  white-space: nowrap;
  display: flex;
  gap: 8px;
}

.pager {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px;
}

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

.modal-panel {
  width: min(720px, 100%);
  max-height: 90vh;
  overflow: auto;
  display: grid;
  gap: 16px;
  background: #fff;
  border-radius: 8px;
  padding: 22px;
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-header h2 {
  margin: 0;
}

.icon-btn {
  width: 34px;
  height: 34px;
  background: #f0f0ea;
  color: #555;
  font-size: 24px;
  line-height: 1;
}

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

.modal-actions {
  justify-content: flex-end;
}

.modal-actions .primary-btn {
  width: auto;
  margin: 0;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 30;
  max-width: 360px;
  background: #222;
  color: #fff;
  border-radius: 6px;
  padding: 12px 16px;
}

/* 确认删除弹窗 */
.confirm-panel {
  width: min(420px, 100%);
  background: #fff;
  border-radius: 8px;
  padding: 28px 28px 22px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.confirm-panel h3 {
  margin: 0 0 12px;
  font-size: 18px;
  color: #2d2d2a;
}

.confirm-panel p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.danger-btn {
  border: none;
  border-radius: 6px;
  cursor: pointer;
  padding: 9px 20px;
  background: var(--danger);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}

.danger-btn:hover {
  background: #a83328;
}

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

  .sidebar {
    position: sticky;
    top: 0;
    z-index: 10;
    flex-direction: row;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .sidebar-brand {
    white-space: nowrap;
    margin: 0 12px 0 0;
  }

  .nav-item,
  .logout-btn {
    width: auto;
    white-space: nowrap;
  }

  .content {
    padding: 18px;
  }

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

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