:root {
  --bg: #f2f5f6;
  --panel: #ffffff;
  --ink: #14232b;
  --ink-2: #3d525c;
  --muted: #78889a;
  --line: #e2e9ec;
  --brand: #0e7c72;
  --brand-deep: #0b4f52;
  --brand-soft: #e6f3f1;
  --warn: #c2410c;
  --ok: #0f7a4d;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(15, 45, 55, 0.08);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* 登录页 */
.login-view {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(14, 124, 114, 0.16), transparent 55%),
    radial-gradient(circle at 85% 80%, rgba(11, 79, 82, 0.14), transparent 50%),
    #f2f5f6;
  padding: 24px;
}

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

.brand { display: flex; align-items: center; gap: 14px; }

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 13px;
  background: linear-gradient(145deg, var(--brand), var(--brand-deep));
  color: #fff;
  font-size: 22px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
  flex: 0 0 auto;
}

.brand h1 { font-size: 20px; margin: 0 0 4px; letter-spacing: 0.5px; }
.brand p { margin: 0; font-size: 12.5px; color: var(--muted); }

.login-card form { margin-top: 26px; display: grid; gap: 16px; }

label { display: grid; gap: 8px; font-size: 13px; color: var(--ink-2); }

input, select {
  height: 42px;
  padding: 0 13px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

input:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(14, 124, 114, 0.12);
}

.btn {
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.08s, opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:active { transform: translateY(1px); }
.btn-primary { background: linear-gradient(140deg, var(--brand), var(--brand-deep)); color: #fff; }
.btn-primary:hover { opacity: 0.94; }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-sm { height: 30px; padding: 0 12px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; height: 46px; font-size: 15px; letter-spacing: 2px; }
.btn-danger { color: var(--warn); border-color: rgba(194, 65, 12, 0.3); background: rgba(194, 65, 12, 0.06); }

.login-tip { margin: 2px 0 0; min-height: 18px; font-size: 12.5px; color: var(--warn); }

/* 主界面 */
.app-view { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 14px 26px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand.compact .brand-mark { width: 38px; height: 38px; font-size: 18px; border-radius: 11px; }
.brand.compact h1 { font-size: 16px; margin: 0; }
.brand.compact p { font-size: 11.5px; }

.tabs { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; }

.tab {
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--ink-2);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
}

.tab:hover { background: var(--brand-soft); color: var(--brand-deep); }

.tab.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  box-shadow: 0 6px 16px rgba(14, 124, 114, 0.24);
}

.panel { padding: 24px 26px 60px; display: none; }
.panel.active { display: block; }

/* 指标卡 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 4px 14px rgba(15, 45, 55, 0.04);
}

.card .label { font-size: 12.5px; color: var(--muted); letter-spacing: 0.3px; }
.card .value { font-size: 26px; font-weight: 700; margin-top: 8px; letter-spacing: -0.5px; }
.card .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.card.accent { background: linear-gradient(150deg, var(--brand), var(--brand-deep)); border-color: transparent; }
.card.accent .label, .card.accent .sub { color: rgba(255, 255, 255, 0.78); }
.card.accent .value { color: #fff; }

/* 区块 */
.grid-2 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 16px; margin-bottom: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

.box {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  box-shadow: 0 4px 14px rgba(15, 45, 55, 0.04);
}

.box-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 14px; }
.box-head h2 { font-size: 15px; margin: 0; }
.hint { font-size: 12px; color: var(--muted); }

#trendChart { width: 100%; height: 220px; display: block; }

.bars { display: grid; gap: 9px; }

.bar-row { display: grid; grid-template-columns: 62px 1fr 58px; align-items: center; gap: 10px; }
.bar-name { font-size: 13px; color: var(--ink-2); }
.bar-track { height: 12px; background: #eef2f4; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; transition: width 0.4s ease; }
.bar-value { font-size: 12.5px; color: var(--muted); text-align: right; }

.plan-sales { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.plan-sale {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  background: #fbfcfc;
}
.plan-sale .name { font-size: 13.5px; font-weight: 600; }
.plan-sale .num { font-size: 20px; font-weight: 700; color: var(--brand-deep); margin-top: 6px; }
.plan-sale .desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 工具条与表格 */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { width: 260px; }
.toolbar select { width: 160px; }
.toolbar input.wide-input { width: 340px; }

.table-wrap {
  overflow-x: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 4px 14px rgba(15, 45, 55, 0.04);
}

table { width: 100%; border-collapse: collapse; min-width: 760px; }

thead th {
  text-align: left;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink-2);
  background: #f7fafb;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

tbody td { padding: 12px 14px; font-size: 13px; border-bottom: 1px solid #f1f5f6; color: var(--ink-2); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #fbfdfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  line-height: 18px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge.guest { background: #f1f3f5; color: #6b7a90; border-color: #e2e9ec; }
.badge.registered { background: #eef4ff; color: #2b5fa8; border-color: #dbe7fb; }
.badge.paid { background: #fff3e0; color: #b35309; border-color: #f6dcc0; }
.badge.ok { background: #e7f6ee; color: var(--ok); border-color: #cfeadd; }
.badge.warn { background: #fdf0e8; color: var(--warn); border-color: #f6d8c6; }
.badge.muted { background: #f1f3f5; color: var(--muted); border-color: #e2e9ec; }
.badge.level { background: #f7fafb; border-color: var(--line); color: var(--ink); }
.badge.app { background: #eef6f4; color: #0e7c72; border-color: #cfe5e1; }

.pager { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.pager .page-text { font-size: 12.5px; color: var(--muted); margin-right: 6px; }

/* 弹窗 */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(13, 33, 38, 0.42);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 40;
}

.modal-card {
  background: #fff;
  width: 100%;
  max-width: 720px;
  max-height: 86vh;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(9, 30, 36, 0.28);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
}
.modal-head h2 { font-size: 16px; margin: 0; }

.modal-body { padding: 20px 22px 26px; overflow: auto; }

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 22px; margin-bottom: 18px; }
.detail-item { display: grid; gap: 4px; }
.detail-item .k { font-size: 12px; color: var(--muted); }
.detail-item .v { font-size: 14px; color: var(--ink); }

.sub-title { font-size: 13.5px; font-weight: 600; margin: 20px 0 10px; color: var(--ink); }

.adjust-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.adjust-row input { width: 130px; height: 36px; }
.adjust-row input.wide { width: 200px; }

.mini-table table { min-width: 0; }
.mini-table thead th { padding: 9px 10px; }
.mini-table tbody td { padding: 9px 10px; font-size: 12.5px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%);
  background: rgba(16, 45, 52, 0.92);
  color: #fff;
  font-size: 13px;
  padding: 10px 18px;
  border-radius: 10px;
  z-index: 60;
  box-shadow: 0 12px 30px rgba(9, 30, 36, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(-4px); }
