* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f4f6f9; color: #1f2933; display: flex; }
a { color: #2563eb; text-decoration: none; }

.sidebar { width: 210px; min-height: 100vh; background: #111827; padding: 20px 0; position: sticky; top: 0; display: flex; flex-direction: column; }
.sidebar .brand { color: #fff; font-size: 20px; font-weight: 700; padding: 0 22px 20px; }
.sidebar a { display: block; color: #cbd5e1; padding: 12px 22px; font-size: 15px; }
.sidebar a:hover { background: #1f2937; color: #fff; }
.sidebar a.active { background: #2563eb; color: #fff; font-weight: 600; }

.content { flex: 1; padding: 28px 36px; max-width: 1100px; }
h1 { font-size: 24px; margin: 0 0 20px; }
h2 { font-size: 18px; margin: 26px 0 12px; }

.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; }
.flash.ok { background: #dcfce7; color: #166534; }
.flash.error { background: #fee2e2; color: #991b1b; }

.cards { display: flex; gap: 16px; flex-wrap: wrap; }
.card { background: #fff; border-radius: 12px; padding: 20px 24px; box-shadow: 0 1px 3px rgba(0,0,0,.08); flex: 1; min-width: 160px; }
.card .num { font-size: 32px; font-weight: 700; color: #2563eb; }
.card .label { color: #6b7280; font-size: 14px; margin-top: 4px; }

.panel { background: #fff; border-radius: 12px; padding: 22px 26px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin-bottom: 22px; }

table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid #eef0f3; font-size: 14px; }
th { background: #f8fafc; color: #475569; font-weight: 600; }
tr:last-child td { border-bottom: none; }

label { display: block; font-size: 13px; color: #475569; margin: 12px 0 5px; font-weight: 600; }
input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 14px; font-family: inherit; background: #fff; }
input:focus, select:focus, textarea:focus { outline: none; border-color: #2563eb; }
.row { display: flex; gap: 16px; flex-wrap: wrap; }
.row > div { flex: 1; min-width: 140px; }

.btn { display: inline-block; background: #2563eb; color: #fff; border: none; padding: 10px 18px;
  border-radius: 8px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #1d4ed8; }
.btn.gray { background: #64748b; }
.btn.red { background: #dc2626; }
.btn.sm { padding: 5px 12px; font-size: 13px; }
form.inline { display: inline; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.on { background: #dcfce7; color: #166534; }
.badge.off { background: #f1f5f9; color: #94a3b8; }

.rating { display: inline-block; width: 26px; height: 26px; line-height: 26px; text-align: center;
  border-radius: 6px; font-weight: 800; color: #fff; font-size: 14px; }
.rating.A { background: #16a34a; }
.rating.B { background: #2563eb; }
.rating.C { background: #d97706; }
.rating.D { background: #dc2626; }
.reco { border: 2px solid #16a34a !important; position: relative; }
.reco-tag { position: absolute; top: -11px; left: 14px; background: #16a34a; color: #fff;
  font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 10px; }
.bar { height: 8px; background: #e5e7eb; border-radius: 5px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: #2563eb; }
.warn { background: #fef3c7; color: #92400e; padding: 10px 14px; border-radius: 8px; margin: 10px 0; }
.danger { background: #fee2e2; color: #991b1b; padding: 10px 14px; border-radius: 8px; margin: 10px 0; }

.cond-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.cond-row select, .cond-row input { margin: 0; }
.cond-row .del { color: #dc2626; cursor: pointer; font-weight: 700; padding: 0 6px; }

.result-price { font-size: 40px; font-weight: 800; color: #16a34a; }
.muted { color: #6b7280; font-size: 13px; }
.breakdown td { font-size: 13px; }
.breakdown .up { color: #dc2626; }
.breakdown .down { color: #16a34a; }
code { background: #f1f5f9; padding: 1px 6px; border-radius: 4px; font-size: 13px; }

/* 表格横向滚动容器（base.html 的 JS 自动包裹每个 table） */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* 移动端顶栏与遮罩：桌面隐藏 */
.mobile-topbar { display: none; }
.overlay { display: none; }

/* ---------- 移动端（≤ 820px）---------- */
@media (max-width: 820px) {
  body { display: block; }

  .mobile-topbar {
    display: flex; align-items: center; gap: 12px;
    position: sticky; top: 0; z-index: 60;
    background: #111827; color: #fff; padding: 11px 16px;
  }
  .mobile-topbar .menu-btn {
    background: none; border: none; color: #fff; font-size: 24px; line-height: 1;
    width: auto; padding: 0 4px; cursor: pointer;
  }
  .mobile-topbar .mt-logo {
    width: 26px; height: 26px; background: #fff; border-radius: 6px; padding: 2px; object-fit: contain;
  }
  .mobile-topbar span { font-weight: 700; font-size: 18px; }

  /* 侧边栏变成从左滑入的抽屉 */
  .sidebar {
    position: fixed; top: 0; left: 0; height: 100vh; width: 250px;
    transform: translateX(-100%); transition: transform .25s ease; z-index: 70;
  }
  .sidebar.open { transform: translateX(0); box-shadow: 2px 0 16px rgba(0,0,0,.3); }
  .sidebar a { padding: 14px 22px; font-size: 16px; }   /* 更好点按 */

  .overlay.show {
    display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 65;
  }

  .content { padding: 16px 14px; max-width: 100%; }
  h1 { font-size: 21px; margin-bottom: 16px; }
  h2 { font-size: 17px; }

  .panel { padding: 16px 16px; border-radius: 10px; }

  /* 表单一行内的多列在手机上竖排铺满 */
  .row { flex-direction: column; gap: 10px; }
  .row > div { min-width: 0; width: 100%; }

  /* 仪表盘卡片两列 */
  .card { min-width: 0; flex: 1 1 44%; }

  /* 输入更大更好点，避免 iOS 聚焦自动放大（≥16px） */
  input, select, textarea { font-size: 16px; padding: 11px 12px; }
  .btn { padding: 12px 18px; }
  .btn.sm { padding: 7px 12px; }
}
