/* xs4 admin 简洁后台风格 */
* { box-sizing: border-box; margin: 0; padding: 0; }
[x-cloak] { display: none !important; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f7fb;
  color: #1f2937;
  font-size: 14px;
  line-height: 1.5;
}

a { color: #1e40af; text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  background: #1e40af;
  color: white;
  border: 0;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  margin: 2px;
}
button:hover { background: #1e3a8a; }
button:disabled { background: #94a3b8; cursor: not-allowed; }
button.warn { background: #d97706; }
button.warn:hover { background: #b45309; }
button.danger { background: #dc2626; }
button.danger:hover { background: #b91c1c; }
button.cancel { background: #94a3b8; }

input, select, textarea {
  border: 1px solid #cbd5e1;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: #1e40af; }
textarea { width: 100%; resize: vertical; }

h1 { font-size: 22px; margin-bottom: 12px; color: #0c1e4a; }
h2 { font-size: 20px; margin: 0 0 16px; color: #0c1e4a; }
h3 { font-size: 16px; margin: 20px 0 12px; color: #1e3a8a; }

.muted { color: #64748b; }
.small { font-size: 12px; }
.warn-text { color: #d97706; font-weight: bold; }
.plus { color: #16a34a; font-weight: bold; }
.minus { color: #dc2626; font-weight: bold; }
.error { color: #dc2626; margin-top: 8px; font-size: 13px; }
.hint { color: #64748b; font-size: 12px; margin-top: 8px; }

code {
  background: #f1f5f9;
  padding: 1px 6px;
  border-radius: 4px;
  font-family: "SF Mono", Consolas, Monaco, monospace;
  font-size: 12px;
}

pre {
  background: #f1f5f9;
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  font-family: "SF Mono", Consolas, Monaco, monospace;
  font-size: 12px;
  max-height: 400px;
  overflow-y: auto;
}

/* ====== Login ====== */
.login-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.login-card {
  background: white;
  padding: 40px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  max-width: 480px;
  width: 100%;
}
.login-card textarea {
  width: 100%;
  margin: 16px 0;
  font-family: "SF Mono", Consolas, Monaco, monospace;
  font-size: 12px;
}
.login-card input { width: 100%; margin: 12px 0; }
.login-card button { width: 100%; padding: 12px; font-size: 16px; }

.qr-box {
  text-align: center;
  margin: 20px 0;
  padding: 12px;
  background: #f8fafc;
  border-radius: 8px;
}
.qr-box img { max-width: 200px; }

/* ====== Shell layout ====== */
.shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: #0c1e4a;
  color: white;
  padding: 20px 0;
  display: flex;
  flex-direction: column;
}
.sidebar .brand {
  font-size: 18px;
  font-weight: bold;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.sidebar nav { flex: 1; padding-top: 20px; }
.sidebar nav a {
  display: block;
  color: #cbd5e1;
  padding: 10px 20px;
  font-size: 14px;
}
.sidebar nav a:hover, .sidebar nav a.active {
  background: rgba(255,255,255,0.08);
  color: white;
  text-decoration: none;
}
.sidebar-foot {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
}
.sidebar-foot .muted { color: #94a3b8; }
.sidebar-foot a { color: #f59e0b; }

.content {
  padding: 24px 32px;
  overflow-x: auto;
}

/* ====== Tables ====== */
table {
  width: 100%;
  background: white;
  border-radius: 8px;
  border-collapse: collapse;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
table.plain { width: auto; box-shadow: none; }
table th, table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e8f0;
  font-size: 13px;
}
table th {
  background: #f8fafc;
  font-weight: 600;
  color: #475569;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.05em;
}
table tr:last-child td { border-bottom: none; }
table tr:hover { background: #f8fafc; }

/* ====== Toolbar ====== */
.toolbar {
  display: flex;
  gap: 8px;
  margin: 16px 0;
  flex-wrap: wrap;
  align-items: center;
}
.toolbar input, .toolbar select { min-width: 140px; }

/* ====== Stat grid ====== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.stat {
  background: white;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.stat .num {
  font-size: 28px;
  font-weight: bold;
  color: #0c1e4a;
}
.stat.green .num { color: #16a34a; }
.stat.blue .num { color: #1e40af; }
.stat .lbl {
  font-size: 12px;
  color: #64748b;
  margin-top: 4px;
}

/* ====== Detail grid ====== */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
  background: white;
  padding: 20px;
  border-radius: 8px;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.detail-grid > div { padding: 4px 0; font-size: 13px; }
.detail-grid b { color: #475569; margin-right: 8px; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0 24px;
}

/* ====== Modal ====== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: white;
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: calc(100% - 32px);
  max-height: 90vh;
  overflow-y: auto;
}
.modal label {
  display: block;
  margin: 12px 0 4px;
  font-size: 13px;
  color: #475569;
  font-weight: 600;
}
.modal input, .modal select, .modal textarea { width: 100%; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ====== Toast ====== */
.toast {
  position: fixed;
  bottom: 32px;
  right: 32px;
  background: #0c1e4a;
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 200;
  max-width: 400px;
}

details summary { cursor: pointer; }
details pre { margin-top: 8px; }

/* ====== Bar Chart（纯 CSS）====== */
.bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 200px;
  background: white;
  padding: 16px;
  border-radius: 8px;
  margin: 12px 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  overflow-x: auto;
}
.bar-chart.day { gap: 6px; }
.bar-wrap {
  flex: 1;
  min-width: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.bar {
  width: 100%;
  background: linear-gradient(180deg, #3b82f6 0%, #1e40af 100%);
  border-radius: 3px 3px 0 0;
  min-height: 1px;
  transition: opacity 0.15s;
  margin-top: auto;
}
.bar-wrap:hover .bar { opacity: 0.8; }
.bar-lbl {
  font-size: 10px;
  color: #64748b;
  margin-top: 4px;
  white-space: nowrap;
}

/* ====== 配额进度条 ====== */
.pct-bar {
  position: relative;
  background: #e2e8f0;
  height: 18px;
  border-radius: 4px;
  overflow: hidden;
  min-width: 120px;
}
.pct-fill {
  background: #1e40af;
  height: 100%;
  transition: width 0.3s;
}
.pct-fill.orange { background: #d97706; }
.pct-fill.red { background: #dc2626; }
.pct-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: #0c1e4a;
  text-shadow: 0 0 4px rgba(255,255,255,0.8);
}
