:root {
  --green: #16a34a;
  --green-hover: #15803d;
  --green-soft: rgba(22, 163, 74, 0.1);
  --red: #dc2626;
  --red-soft: rgba(239, 68, 68, 0.1);
  --amber: #d97706;
  --amber-soft: rgba(245, 158, 11, 0.12);
  --text: #0a0a0a;
  --body: #555;
  --label: #999;
  --border: #e5e5e5;
  --side: #f2f2f2;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.6 -apple-system, "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--side);
  display: flex;
  min-height: 100vh;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-hover); }
.muted { color: var(--label); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; }
.hint { display: block; color: var(--label); font-size: 12px; margin-top: 4px; font-weight: normal; }
p.hint { font-size: 13px; }

/* layout */
.side {
  width: 200px;
  flex-shrink: 0;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 20px; font-weight: 600; }
.brand img { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--text); background: #fff; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: var(--body); padding: 8px 12px; border-radius: 8px; }
.side nav a:hover { background: rgba(0, 0, 0, 0.035); }
.side nav a.active { background: rgba(0, 0, 0, 0.055); color: var(--text); font-weight: 500; }
.side-foot { margin-top: auto; padding: 12px 8px 0; border-top: 1px solid rgba(0, 0, 0, 0.05); display: flex; justify-content: space-between; }

.main {
  flex: 1;
  min-width: 0;
  background: #fff;
  margin-top: 12px;
  border-top-left-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-right: 0;
  border-bottom: 0;
  padding: 20px 28px 40px;
}
h1 { font-size: 18px; margin: 0 0 18px; }
h2 { font-size: 15px; margin: 0; }

/* cards */
.card {
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
  overflow-x: auto;
}
.card.narrow { max-width: 520px; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; gap: 12px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: #fafafa; border-radius: 10px; padding: 16px 18px; }
.stat-label { color: var(--label); font-size: 13px; }
.stat-value { font-size: 24px; font-weight: 600; margin: 2px 0; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 190px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; }
.bar { width: 100%; max-width: 34px; border-radius: 4px 4px 0 0; background: var(--green); opacity: 0.85; }
.bar-col:hover .bar { opacity: 1; }
.bar-val { font-size: 11px; color: var(--body); margin-bottom: 4px; white-space: nowrap; }
.bar-day { font-size: 11px; color: var(--label); margin-top: 6px; }

/* tables */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; color: var(--label); font-size: 13px; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid rgba(0, 0, 0, 0.05); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline-flex; gap: 6px; }
.empty { color: var(--label); text-align: center; padding: 32px 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 12px; font-weight: 500; }
.badge-green { color: var(--green); background: var(--green-soft); }
.badge-red { color: var(--red); background: var(--red-soft); }
.badge-gray { color: var(--body); background: rgba(0, 0, 0, 0.05); }
.badge-amber { color: var(--amber); background: var(--amber-soft); }

.plan-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.plan-stat { background: #fafafa; border-radius: 10px; padding: 14px 16px; }
.plan-stat-head { display: flex; gap: 8px; align-items: center; }
.plan-stat-value { font-size: 18px; font-weight: 600; margin-top: 6px; }
.plans-edit input:not([type=checkbox]), .plans-edit select { width: 100%; min-width: 0; }
.plans-edit td { vertical-align: middle; }
.plans-edit .narrow-input { width: 64px; }
select.select-sm { height: 28px; font-size: 13px; padding: 0 6px; }
.plan-cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin: 28px 0; }
.plan-card { width: 170px; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px; position: relative; }
.plan-card.best { border: 2px solid var(--green); }
.plan-card .plan-badge { position: absolute; top: -10px; left: 50%; transform: translateX(-50%); background: #e11d48; color: #fff; font-size: 12px; padding: 0 8px; border-radius: 10px; white-space: nowrap; }
.plan-card .plan-price { font-size: 26px; font-weight: 700; color: #e11d48; }

.pager { display: flex; justify-content: space-between; align-items: center; padding-top: 12px; margin-top: 8px; border-top: 1px solid rgba(0, 0, 0, 0.05); }
.pager > span:last-child { display: flex; gap: 10px; align-items: center; }

/* forms */
input, select {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  background: #fff;
  color: var(--text);
  outline: none;
}
input:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.toolbar input { min-width: 260px; }
.toolbar input.wide { min-width: 400px; }
.card .toolbar { margin-bottom: 0; }
.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f7f7f7; color: var(--text); }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: var(--green-hover); color: #fff; }
.btn-danger { color: var(--red); border-color: rgba(220, 38, 38, 0.35); }
.btn-danger:hover { background: var(--red-soft); color: var(--red); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-block { width: 100%; height: 40px; font-size: 15px; }

.alert { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.alert-ok { background: var(--green-soft); color: var(--green-hover); }
.alert-error { background: var(--red-soft); color: var(--red); }
.alert-warn { background: var(--amber-soft); color: var(--amber); }

.preview { display: flex; align-items: baseline; gap: 10px; padding: 14px 16px; background: #fafafa; border-radius: 8px; }
.preview-price { font-size: 26px; font-weight: 700; color: var(--red); }

/* login */
.login-body { align-items: center; justify-content: center; background: linear-gradient(160deg, #f0fdf4 0%, #f2f2f2 60%); }
.login-card { width: 360px; background: #fff; border-radius: 14px; padding: 28px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08); display: flex; flex-direction: column; gap: 14px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.login-brand img { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--text); }
.login-title { font-size: 17px; font-weight: 600; }

/* home */
.home { justify-content: center; background: linear-gradient(160deg, #f0fdf4 0%, #fff 55%); }
.home-wrap { max-width: 620px; padding: 80px 24px; text-align: center; }
.home-logo { width: 72px; height: 72px; border-radius: 16px; border: 1px solid var(--text); background: #fff; }
.home h1 { font-size: 30px; margin: 18px 0 8px; }
.home-lead { color: var(--body); font-size: 16px; }
.home-price { display: flex; gap: 12px; align-items: baseline; justify-content: center; margin: 28px 0; }
.home-points { list-style: none; padding: 0; color: var(--body); line-height: 2.2; }
.home-points li::before { content: "✓"; color: var(--green); font-weight: 700; margin-right: 8px; }

@media (max-width: 900px) {
  body { flex-direction: column; }
  .side { position: static; width: auto; height: auto; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { margin-top: 0; border-radius: 0; padding: 16px; }
}
