:root {
  --accent: #ff6900;
  --accent-dark: #e55c00;
  --accent-soft: #fff3e8;
  --sidebar-bg: #141a2e;
  --sidebar-hover: #1d2540;
  --sidebar-active: #232c4a;
  --sidebar-text: #c6cde0;
  --sidebar-dim: #7a86a8;
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1f2733;
  --muted: #7a8699;
  --line: #e4e8f0;
  --ok: #0c8a5f;
  --ok-bg: #e7f7f0;
  --danger: #c0392b;
  --danger-bg: #fdecea;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 侧边栏 ---------- */

.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 18px;
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}
.brand svg { width: 34px; height: 34px; flex-shrink: 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: 0.3px; }
.brand-text small { color: var(--sidebar-dim); font-size: 12px; }

.nav { flex: 1; padding: 14px 0; display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 15px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  font-size: 14px;
}
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--sidebar-active);
  border-left-color: var(--accent);
  color: #fff;
  font-weight: 500;
}

.sidebar-foot { padding: 10px 0 18px; border-top: 1px solid rgba(255, 255, 255, 0.07); }
.sidebar-foot form { margin: 0; }
.logout-btn {
  width: 100%;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

/* ---------- 内容区 ---------- */

.content {
  flex: 1;
  min-width: 0;
  padding: 26px 30px 40px;
  max-width: 1180px;
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 { font-size: 20px; margin: 0; }
.run-meta { color: var(--muted); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; }

/* ---------- 统计卡 ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
  border-left: 4px solid var(--accent);
  box-shadow: 0 1px 2px rgba(20, 26, 46, 0.04);
}
.stat-card.neutral { border-left-color: #b8c2d4; }
.stat-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 20px; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 8px; }
.stat-value.small { font-size: 15px; font-weight: 500; }
.stat-value.accent { color: var(--accent); }
.stat-value small { font-size: 12px; color: var(--muted); font-weight: 400; }
.stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px var(--ok-bg); }
.dot.off { background: #b8c2d4; box-shadow: 0 0 0 3px #eef1f6; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px 22px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(20, 26, 46, 0.04);
}

h2 {
  font-size: 15px;
  margin: 26px 0 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
h2:first-of-type { margin-top: 4px; }

/* ---------- 表单 ---------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid .w-narrow input { max-width: 160px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #3d4a57; }
label.check {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  align-self: end;
  padding-bottom: 10px;
}
label.check input { width: auto; accent-color: var(--accent); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #cfd6de;
  border-radius: 6px;
  font: inherit;
  color: var(--text);
  background: #fff;
}
input:focus, select:focus {
  outline: 2px solid rgba(255, 105, 0, 0.25);
  border-color: var(--accent);
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.action-row { display: flex; gap: 10px; flex-wrap: wrap; }

button, .button {
  display: inline-block;
  padding: 9px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
button.secondary, .button.secondary {
  background: #fff;
  color: var(--accent-dark);
  border-color: #ffd9bd;
}
button.secondary:hover, .button.secondary:hover { background: var(--accent-soft); }

/* ---------- 提示 ---------- */

.flash {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  border: 1px solid var(--line);
  background: #fff;
}
.flash.success { background: var(--ok-bg); border-color: #b7e4d4; color: var(--ok); }
.flash.error { background: var(--danger-bg); border-color: #f3c2bc; color: var(--danger); }

/* ---------- 表格 ---------- */

table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table-wrap { overflow-x: auto; }
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th {
  color: var(--muted);
  font-weight: 500;
  background: #f8fafd;
  white-space: nowrap;
}
tbody tr:hover td { background: var(--accent-soft); }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }

.cell-sub { display: block; font-size: 12px; color: var(--muted); line-height: 1.45; }
.cell-sub.nowrap { white-space: nowrap; }
.cell-amount { color: var(--accent); font-weight: 600; white-space: nowrap; }
.error-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--danger);
}
.addr-cell {
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.subject-cell { min-width: 180px; max-width: 320px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  background: #eef1f4;
  color: #4a5866;
  font-size: 12px;
  white-space: nowrap;
}
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--danger-bg); color: var(--danger); }

.view-link { color: var(--accent-dark); text-decoration: none; margin-left: 6px; white-space: nowrap; }
.view-link:hover { text-decoration: underline; }

.row-actions { display: inline-flex; align-items: center; gap: 6px; margin-left: 8px; }
.row-actions .view-link { margin-left: 0; }
.link-btn {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--accent-dark);
  cursor: pointer;
  white-space: nowrap;
}
.link-btn:hover { text-decoration: underline; background: none; }

/* ---------- 分页 / 筛选 / 空态 ---------- */

.pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; color: var(--muted); }
.pager a { color: var(--accent-dark); text-decoration: none; }
.pager .disabled { color: #b6bec8; }

.filter { margin: 0; }
.filter label { flex-direction: row; align-items: center; gap: 8px; }
.filter select { width: auto; }

.empty { color: var(--muted); text-align: center; padding: 34px 0; }
.empty svg { width: 40px; height: 40px; margin-bottom: 8px; opacity: 0.45; }
.hint { color: var(--muted); font-size: 12px; margin: 12px 0 0; }

/* ---------- 登录页 ---------- */

body.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-bg);
}
body.auth .content {
  max-width: 400px;
  width: 100%;
  padding: 20px;
}
.auth-card {
  background: var(--card);
  border-radius: 12px;
  padding: 30px 28px 26px;
  box-shadow: 0 10px 32px rgba(0, 0, 0, 0.28);
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 20px;
}
.auth-brand svg { width: 46px; height: 46px; }
.auth-brand strong { font-size: 18px; color: var(--text); }
.auth-brand small { color: var(--muted); font-size: 13px; }
.auth-card form { display: flex; flex-direction: column; gap: 14px; }
body.auth .flash { margin-bottom: 14px; }

/* ---------- 响应式 ---------- */

@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    padding: 0 10px;
  }
  .brand { border-bottom: 0; padding: 12px 8px; }
  .brand svg { width: 26px; height: 26px; }
  .nav { flex-direction: row; padding: 0; }
  .nav-item { border-left: 0; border-bottom: 3px solid transparent; padding: 10px 12px; }
  .nav-item.active { border-bottom-color: var(--accent); }
  .sidebar-foot { border-top: 0; padding: 0; margin-left: auto; }
  .logout-btn { border-left: 0; padding: 10px 12px; }
  .content { padding: 16px 14px 30px; }
  .card { padding: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  table { font-size: 12px; }
  th, td { padding: 7px 8px; }
}
