* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #101820;
  color: #e0e6ed;
  min-height: 100vh;
}

.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 14px; color: #8899aa; }
.form-group input, .form-row-inline input {
  width: 100%; padding: 10px 14px; border: 1px solid #2d3e4d; border-radius: 999px;
  background: #0d151d; color: #e0e6ed; font-size: 15px; outline: none; transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus, .form-row-inline input:focus, textarea:focus, select:focus {
  border-color: #4a9eff;
  box-shadow: 0 0 0 3px rgba(74, 158, 255, 0.12);
}

.btn-primary {
  padding: 11px 22px; border: 1px solid rgba(74, 158, 255, 0.55); border-radius: 999px; background: #4a9eff;
  color: #fff; font-size: 14px; font-weight: 650; cursor: pointer; transition: background .2s, transform .2s, box-shadow .2s;
  box-shadow: 0 8px 20px rgba(74, 158, 255, 0.18);
}
.btn-primary:hover { background: #3a8eef; transform: translateY(-1px); }
.btn-primary:disabled { background: #2a4a6a; cursor: not-allowed; }

.btn-danger {
  padding: 11px 22px; border: 1px solid rgba(231, 76, 60, 0.55); border-radius: 999px; background: #e74c3c;
  color: #fff; font-size: 14px; font-weight: 650; cursor: pointer;
  box-shadow: 0 8px 20px rgba(231, 76, 60, 0.14);
}
.btn-danger:hover { background: #c0392b; transform: translateY(-1px); }
.btn-danger:disabled { background: #5a2a2a; cursor: not-allowed; opacity: 0.65; }

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.detail-actions h3 { margin-bottom: 6px; font-size: 15px; }

.btn-secondary {
  padding: 10px 20px; border: 1px solid #2d3e4d; border-radius: 999px;
  background: #121d27; color: #b3c0ca; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-secondary:hover { border-color: #4a9eff; color: #4a9eff; transform: translateY(-1px); }

.btn-logout {
  padding: 7px 16px; border: 1px solid #2a3a4a; border-radius: 999px;
  background: transparent; color: #8899aa; font-size: 13px; cursor: pointer;
}
.btn-logout:hover { border-color: #e74c3c; color: #e74c3c; }

.btn-small {
  padding: 8px 14px; border: 1px solid #2a3a4a; border-radius: 999px;
  background: transparent; color: #8899aa; font-size: 12px; cursor: pointer; white-space: nowrap;
}
.btn-small:hover { border-color: #4a9eff; color: #4a9eff; }

.msg { margin-top: 10px; font-size: 13px; min-height: 18px; }
.msg.success { color: #2ecc71; }
.msg.error { color: #e74c3c; }
.hint { font-size: 12px; color: #5a6a7a; margin-top: 8px; }

footer {
  text-align: center; padding: 20px; color: #5a6a7a; font-size: 12px; margin-top: auto;
  line-height: 1.6;
}

/* 主页框架 */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.top-bar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 24px; background: rgba(26, 38, 52, 0.96); border-bottom: 1px solid #2a3a4a;
  flex-wrap: wrap; gap: 10px;
  position: sticky; top: 0; z-index: 20; backdrop-filter: blur(10px);
}
.top-bar h1 { font-size: 18px; color: #fff; }
.top-actions { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.nav-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.nav-tab {
  padding: 7px 14px; border-radius: 999px; color: #a6b4c0; text-decoration: none;
  font-size: 13px; transition: all .2s; border: 1px solid transparent;
}
.nav-tab:hover { color: #e0e6ed; background: #22313f; border-color: #2f4354; }
.nav-tab.active { color: #fff; background: rgba(74, 158, 255, 0.16); border-color: rgba(74, 158, 255, 0.35); }

.main-content { flex: 1; padding: 24px; max-width: 1100px; width: 100%; margin: 0 auto; }

.page { display: none; }
.page.active { display: block; }

.card {
  background: #1a2634; border: 1px solid #2a3a4a; border-radius: 10px;
  padding: 24px; margin-bottom: 20px;
}
.card h2 { font-size: 16px; margin-bottom: 16px; color: #fff; }

/* Bot 状态 */
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%; background: #e74c3c; flex-shrink: 0;
}
.status-dot.online { background: #2ecc71; }
#statusText { font-size: 15px; flex: 1; min-width: 60px; }
.btn-group { display: flex; gap: 8px; }

.token-row { display: flex; gap: 8px; }
.token-row input { flex: 1; }

/* 统计 */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px;
}
.stat-item {
  background: #0d151d; border-radius: 8px; padding: 16px; text-align: center;
  border: 1px solid #263746;
}
.stat-num { display: block; font-size: 22px; font-weight: bold; color: #4a9eff; margin-bottom: 6px; }
.stat-label { font-size: 12px; color: #8899aa; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid #2a3a4a; white-space: nowrap; }
th { color: #8899aa; font-weight: 500; }
td { color: #e0e6ed; }

.btn-table {
  padding: 6px 12px; border: none; border-radius: 999px; font-size: 12px; font-weight: 650; cursor: pointer;
  margin: 2px;
}
.btn-table.green { background: #2ecc71; color: #fff; }
.btn-table.green:hover { background: #27ae60; }
.btn-table.red { background: #e74c3c; color: #fff; }
.btn-table.red:hover { background: #c0392b; }
.btn-table.blue { background: #4a9eff; color: #fff; }
.btn-table.blue:hover { background: #3a8eef; }

/* 弹窗 */
.modal {
  position: fixed; top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal-content {
  background: #1a2634; border: 1px solid #2a3a4a; border-radius: 12px;
  padding: 24px; width: 90%; max-width: 400px;
}
.modal-content h3 { margin-bottom: 16px; color: #fff; }
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn-primary { flex: 1; }
.modal-actions .btn-secondary { flex: 1; text-align: center; }

@media (max-width: 768px) {
  .top-bar { flex-direction: column; align-items: flex-start; }
  .nav-tabs { flex-wrap: wrap; }
  .main-content { padding: 16px; }
  .card { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
}

.ok-text { color: #2ecc71; }
.warn-text { color: #f39c12; }
.link-id { color: #4a9eff; text-decoration: none; }
.link-id:hover { text-decoration: underline; }

.bal-up { color: #e74c3c !important; transition: color .3s; }
.bal-down { color: #2ecc71 !important; transition: color .3s; }

.btn-reminder {
  padding: 7px 14px; border: 1px solid #2a3a4a; border-radius: 999px;
  background: #1a2634; color: #e0e6ed; font-size: 12px; cursor: pointer;
}
.btn-reminder.off { opacity: 0.6; }

.admin-notice {
  margin: 0 24px; padding: 12px 16px; background: rgba(46, 204, 113, 0.15);
  border: 1px solid #2ecc71; border-radius: 8px; color: #2ecc71; font-size: 14px;
}

.detail-grid p { margin-bottom: 8px; font-size: 14px; line-height: 1.6; }
.grid2-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid2-cards h3 { font-size: 14px; color: #fff; margin-bottom: 8px; }
@media (max-width: 768px) { .grid2-cards { grid-template-columns: 1fr; } }

.ledger-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; font-size: 14px;
}
.ledger-grid span { background: #0f1923; padding: 12px; border-radius: 8px; }

.table-wrap-mid { max-height: 320px; overflow-y: auto; }
.table-wrap-tall { max-height: 420px; overflow-y: auto; }

.pill { display: inline-block; padding: 3px 9px; border-radius: 999px; font-size: 11px; }
.pill-ok { background: rgba(46,204,113,.2); color: #2ecc71; }
.pill-bad { background: rgba(231,76,60,.2); color: #e74c3c; }
.pill-wait { background: rgba(243,156,18,.2); color: #f39c12; }

.reject-reason {
  width: 100px; padding: 4px 6px; margin-right: 4px; font-size: 12px;
  border: 1px solid #2a3a4a; border-radius: 4px; background: #0f1923; color: #e0e6ed;
}

.main-content { max-width: 1280px; }

.grid4 {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.ledger-period-card {
  background: #0f1923;
  border-radius: 8px;
  padding: 14px;
  border: 1px solid #2a3a4a;
}
.ledger-period-title { font-size: 13px; color: #8899aa; margin-bottom: 10px; }
.ledger-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; }
.ledger-metrics dt { color: #5a6a7a; }
.ledger-metrics dd { text-align: right; }
.ledger-filter { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.ledger-filter input[type=date] {
  padding: 8px; border-radius: 6px; border: 1px solid #2a3a4a; background: #0f1923; color: #e0e6ed;
}
.ledger-day-summary {
  display: flex; flex-wrap: wrap; gap: 12px 20px; font-size: 13px; margin-bottom: 12px;
  padding: 12px; background: #0f1923; border-radius: 8px;
}
.btn-link {
  color: #4a9eff; text-decoration: none; font-size: 13px;
}
.btn-link:hover { text-decoration: underline; }
.form-row-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; font-size: 13px; }
.form-row-inline input {
  flex: 1 1 180px;
  width: auto;
  min-width: 0;
}
.welcome-box { min-height: 80px; background: #0f1923; border-radius: 8px; padding: 12px; text-align: center; }
.manual-pre, .diagnostic-pre {
  white-space: pre-wrap; word-break: break-word;
  background: #0a1219; border: 1px solid #2a3a4a; border-radius: 8px;
  padding: 14px; font-size: 12px; line-height: 1.55; max-height: 70vh; overflow: auto;
}
.simple-list { list-style: none; margin-top: 10px; font-size: 13px; }
.simple-list li { padding: 6px 0; border-bottom: 1px solid #2a3a4a; }
.ua-cell { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.inline-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: #8899aa; }
textarea {
  width: 100%; padding: 10px 14px; border: 1px solid #2a3a4a; border-radius: 14px;
  background: #0f1923; color: #e0e6ed; font-size: 14px; resize: vertical;
  outline: none;
}
select {
  width: 100%; padding: 10px 14px; border: 1px solid #2a3a4a; border-radius: 999px;
  background: #0f1923; color: #e0e6ed; outline: none;
}

.section-title-row {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 12px; flex-wrap: wrap; margin-bottom: 8px;
}
.section-title-row h2 { margin-bottom: 4px; }
.status-pill {
  display: inline-block; padding: 6px 12px; border-radius: 20px; font-size: 12px;
  background: #2a3a4a; color: #8899aa; white-space: nowrap;
}
.status-pill.is-ok { background: rgba(46, 204, 113, 0.15); color: #2ecc71; border: 1px solid rgba(46, 204, 113, 0.35); }
.status-pill.is-warn { background: rgba(243, 156, 18, 0.15); color: #f39c12; border: 1px solid rgba(243, 156, 18, 0.35); }
.group-settings-grid h3 { font-size: 14px; color: #fff; margin-bottom: 10px; }
.compact-table { max-height: 280px; overflow-y: auto; }
.tbl-compact th, .tbl-compact td { padding: 8px 10px; font-size: 12px; }
.settings-panel { border-color: #3a4a5a; }

.guide-panel { border-color: #314657; }
.guide-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.guide-jump a {
  color: #d8e7f5;
  text-decoration: none;
  padding: 9px 14px;
  border-radius: 999px;
  background: #101b25;
  border: 1px solid #304657;
  font-size: 13px;
}
.guide-jump a:hover { border-color: #4a9eff; color: #4a9eff; }
.guide-steps {
  display: grid;
  gap: 10px;
}
.guide-steps div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 12px;
  align-items: start;
  background: #0d151d;
  border: 1px solid #273a49;
  border-radius: 8px;
  padding: 12px;
}
.guide-steps span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: rgba(74, 158, 255, 0.14);
  color: #72b5ff;
  font-weight: 700;
  font-size: 13px;
}
.guide-steps p, .guide-card p { font-size: 13px; line-height: 1.65; color: #c7d2dc; }
.guide-steps.compact div { padding: 10px 12px; }
.guide-note {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(46, 204, 113, 0.08);
  border: 1px solid rgba(46, 204, 113, 0.22);
  color: #bfe8cf;
  font-size: 13px;
  line-height: 1.65;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
}
.guide-card {
  background: #0d151d;
  border: 1px solid #273a49;
  border-radius: 8px;
  padding: 16px;
}
.guide-card h3 {
  color: #fff;
  font-size: 14px;
  margin-bottom: 8px;
}
.guide-card p + p { margin-top: 8px; }
.guide-table-wrap {
  overflow-x: auto;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
}
.guide-table th, .guide-table td {
  white-space: normal;
  vertical-align: top;
  line-height: 1.55;
  min-width: 140px;
}
.guide-table th {
  background: #111d27;
  color: #c4d2de;
}
.guide-table td:first-child {
  color: #8ec5ff;
  font-weight: 650;
}

.log-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  margin-bottom: 10px; font-size: 13px;
}
.log-toolbar label { color: #8899aa; }
.log-toolbar select {
  margin-left: 6px; padding: 6px 8px; border-radius: 6px;
  border: 1px solid #2a3a4a; background: #0f1923; color: #e0e6ed;
}

.log-viewer {
  display: block;
  max-height: 65vh;
  min-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 14px 16px;
  background: #0a1219;
  border: 1px solid #2a3a4a;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  color: #b8c5d0;
  white-space: pre-wrap;
  word-break: break-all;
}
.log-viewer .log-line { display: block; }
.log-viewer .log-err { color: #ff6b6b; }
.log-viewer .log-warn { color: #feca57; }
.log-viewer .log-dbg { color: #7f8c9a; }
