:root {
  --bg:      #f5f6f8;
  --panel:   #ffffff;
  --line:    #e5e7eb;
  --text:    #1f2329;
  --muted:   #8a9099;
  --brand:   #e8b04b;
  --brand-d: #d99a2b;
  --up:      #d93026;
  --down:    #16a34a;
  --shadow:  0 1px 3px rgba(16,24,40,.06), 0 6px 20px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.muted { color: var(--muted); }
.err   { color: var(--up); min-height: 18px; margin: 8px 0 0; font-size: 13px; }

/* ==================== 登录 ==================== */
.login-wrap {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
  background: linear-gradient(160deg, #fffaf0 0%, #f5f6f8 55%);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 30px 28px 26px;
  box-shadow: var(--shadow);
}

.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }
.brand h1 { font-size: 17px; margin: 0; font-weight: 650; }
.brand p  { margin: 2px 0 0; font-size: 12px; }

.brand-mark {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--brand), var(--brand-d));
  color: #fff;
  display: grid; place-items: center;
  font-size: 20px; font-weight: 700;
}
.brand-mark.sm { width: 28px; height: 28px; flex-basis: 28px; border-radius: 8px; font-size: 15px; }

.field { display: block; margin-bottom: 15px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfbfc;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus { border-color: var(--brand); background: #fff; }

/* ==================== 按钮 ==================== */
.btn {
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 15px;
  background: #fff;
  transition: filter .15s, background .15s, border-color .15s;
}
.btn:active { filter: brightness(.96); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary { background: linear-gradient(145deg, var(--brand), var(--brand-d)); color: #fff; font-weight: 600; }
.btn-primary:hover:not(:disabled) { filter: brightness(1.04); }

.btn-ghost { background: #fff; border-color: var(--line); color: var(--text); }
.btn-ghost:hover:not(:disabled) { border-color: #cfd4da; }

.btn-danger { background: #fff; border-color: #f0c4c0; color: var(--up); }
.btn-danger:hover:not(:disabled) { background: #fdf3f2; }

.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; padding: 11px; margin-top: 6px; }

/* ==================== 布局 ==================== */
.app-wrap { display: flex; min-height: 100vh; }

.side {
  width: 206px;
  flex: 0 0 206px;
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 18px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand { display: flex; align-items: center; gap: 9px; padding: 0 6px 18px; font-weight: 650; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }

.nav-item {
  text-align: left;
  border: none;
  background: transparent;
  padding: 9px 11px;
  border-radius: 8px;
  color: #4a5160;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: #f3f4f6; }
.nav-item.active { background: #fdf4e1; color: #a9711a; font-weight: 600; }

.side-foot { border-top: 1px solid var(--line); padding-top: 12px; }
.who { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; padding: 0 4px; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.topbar h2 { margin: 0; font-size: 19px; font-weight: 650; }

/* ==================== 卡片 / 指标 ==================== */
.grid { display: grid; gap: 13px; }
.grid.k2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.k3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1080px) {
  .grid.k4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.k3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .side { display: none; }
  .main { padding: 16px; }
  .grid.k4, .grid.k3, .grid.k2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 17px;
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 13px;
  font-size: 13.5px;
  font-weight: 650;
  color: #3c424d;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}

.metric .label { font-size: 12.5px; color: var(--muted); margin-bottom: 5px; }
.metric .value { font-size: 25px; font-weight: 680; letter-spacing: -.4px; }
.metric .sub   { font-size: 12px; color: var(--muted); margin-top: 3px; }
.metric .value.up   { color: var(--up); }
.metric .value.down { color: var(--down); }

.bar { height: 6px; border-radius: 4px; background: #f0f1f3; overflow: hidden; margin-top: 9px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--brand), var(--brand-d)); }

/* ==================== 表格 ==================== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid #eef0f2; white-space: nowrap; }
th { color: var(--muted); font-weight: 550; font-size: 12.5px; background: #fafbfc; }
tbody tr:hover { background: #fcfcfd; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }

.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 20px;
  font-size: 11.5px;
  line-height: 18px;
  border: 1px solid transparent;
}
.tag.ok    { background: #eaf7ee; color: #16794a; border-color: #cbead8; }
.tag.warn  { background: #fdf4e1; color: #a9711a; border-color: #f3e0b8; }
.tag.bad   { background: #fdf0ef; color: #b52a21; border-color: #f2d0cd; }
.tag.gray  { background: #f2f3f5; color: #6b7280; border-color: #e5e7eb; }

/* ==================== 工具条 ==================== */
.toolbar { display: flex; flex-wrap: wrap; gap: 9px; align-items: center; margin-bottom: 13px; }
.toolbar input, .toolbar select {
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); }
.toolbar input { min-width: 190px; }
.spacer { flex: 1; }

.empty { text-align: center; color: var(--muted); padding: 34px 10px; font-size: 13px; }

.pager { display: flex; gap: 9px; align-items: center; justify-content: flex-end; margin-top: 13px; font-size: 12.5px; color: var(--muted); }

/* ==================== 图表 ==================== */
.chart-box { position: relative; width: 100%; height: 210px; }
.chart-box canvas { width: 100%; height: 100%; display: block; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); margin-top: 9px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

/* ==================== 弹层 ==================== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17,22,32,.42);
  display: grid; place-items: center;
  padding: 20px; z-index: 50;
}
.modal {
  background: var(--panel);
  border-radius: 13px;
  padding: 22px 22px 18px;
  width: 100%; max-width: 430px;
  box-shadow: 0 20px 50px rgba(16,24,40,.24);
  max-height: 86vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 15px; font-size: 16px; font-weight: 650; }
.modal-foot { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }

/* ==================== 提示 ==================== */
.toast {
  position: fixed;
  top: 18px; left: 50%;
  transform: translateX(-50%);
  background: #1f2329; color: #fff;
  padding: 9px 17px; border-radius: 9px;
  font-size: 13px; z-index: 90;
  box-shadow: 0 8px 24px rgba(16,24,40,.2);
}

.code-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 7px;
  max-height: 250px;
  overflow-y: auto;
  margin-top: 11px;
}
.code-list code {
  display: block;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 6px 9px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  text-align: center;
}

/* ==================== 业务配置 ==================== */
.cfg-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.cfg-row:first-of-type { border-top: none; padding-top: 4px; }
.cfg-label { flex: 1; min-width: 0; }
.cfg-name { font-size: 13.5px; color: var(--text); font-weight: 550; }
.cfg-hint { font-size: 12px; color: var(--muted); margin-top: 3px; line-height: 1.5; }
.cfg-input { flex: 0 0 170px; }
.cfg-input input,
.cfg-input select {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  outline: none;
  font-size: 13px;
  color: var(--text);
}
.cfg-input input:focus,
.cfg-input select:focus { border-color: var(--brand); }

@media (max-width: 720px) {
  .cfg-row { flex-direction: column; align-items: stretch; gap: 9px; }
  .cfg-input { flex: 1 1 auto; }
}
