:root {
  --green-950: #06261f;
  --green-900: #0a352b;
  --green-800: #0d493b;
  --green-700: #11614d;
  --green-600: #177a60;
  --green-500: #239478;
  --green-200: #b9e2d2;
  --green-100: #dff2e8;
  --green-50: #eef8f3;
  --orange-600: #e56630;
  --orange-500: #f2814b;
  --orange-100: #ffeadf;
  --gold-600: #b88735;
  --gold-100: #faf0d9;
  --ink: #17251f;
  --ink-2: #34453e;
  --muted: #718079;
  --muted-2: #96a29d;
  --line: #e4ebe6;
  --line-2: #eef2ef;
  --paper: #ffffff;
  --paper-2: #fbfcfa;
  --bg: #f4f7f4;
  --red: #d9534f;
  --red-soft: #fdeceb;
  --blue: #3f7cac;
  --blue-soft: #eaf2f9;
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 22px;
  --radius-xl: 28px;
  --shadow-sm: 0 1px 2px rgba(15, 58, 45, .04), 0 4px 14px rgba(15, 58, 45, .04);
  --shadow: 0 8px 30px rgba(12, 53, 41, .08);
  --shadow-lg: 0 24px 70px rgba(5, 35, 27, .16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
  --num: "DIN Alternate", "Bahnschrift", "Avenir Next Condensed", var(--font);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body { min-height: 100vh; }

a { color: var(--green-700); text-decoration: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4, p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

.ic { display: inline-block; vertical-align: -0.18em; flex: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

.num { font-family: var(--num); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 700; }
.row { display: flex; align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-4 { gap: 4px; } .gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-10 { gap: 10px; }
.gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-20 { gap: 20px; }
.grow { flex: 1; min-width: 0; }
.wrap { flex-wrap: wrap; }
.ellipsis { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.mt-4 { margin-top: 4px; } .mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.hidden { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  padding: 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 14px;
  font-weight: 650;
  line-height: 1.2;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease, border-color .15s ease;
  white-space: nowrap;
  background: #eef2ef;
  color: var(--ink-2);
  border: 1px solid transparent;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: linear-gradient(135deg, var(--green-700), var(--green-600)); color: #fff; box-shadow: 0 6px 16px rgba(17, 97, 77, .2); }
.btn-primary:hover { background: linear-gradient(135deg, var(--green-800), var(--green-700)); box-shadow: 0 8px 22px rgba(17, 97, 77, .26); }
.btn-accent { background: linear-gradient(135deg, #f6905d, var(--orange-600)); color: #fff; box-shadow: 0 6px 16px rgba(229, 102, 48, .22); }
.btn-outline { background: transparent; border-color: var(--line); color: var(--ink-2); }
.btn-outline:hover { border-color: var(--green-500); color: var(--green-700); background: var(--green-50); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #f0f4f1; color: var(--ink); }
.btn-soft { background: var(--green-50); color: var(--green-700); }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fbdcdb; }
.btn-dark { background: var(--green-900); color: #fff; }
.btn-sm { min-height: 34px; padding: 0 12px; border-radius: 9px; font-size: 12.5px; gap: 5px; }
.btn-xs { min-height: 28px; padding: 0 10px; border-radius: 8px; font-size: 11.5px; gap: 4px; }
.btn-lg { min-height: 50px; padding: 0 24px; border-radius: 14px; font-size: 15.5px; }
.btn-block { width: 100%; }
.btn-icon { min-width: 42px; width: 42px; padding: 0; }
.btn[disabled] { transform: none; }

.icon-btn {
  border: 0;
  background: transparent;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-2);
  position: relative;
  transition: background .15s ease;
}
.icon-btn:hover { background: rgba(17, 97, 77, .07); }

/* ---------- badges / tags ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #f0f4f1;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  line-height: 1.5;
  white-space: nowrap;
}
.badge-green { background: var(--green-50); color: var(--green-700); }
.badge-orange { background: var(--orange-100); color: var(--orange-600); }
.badge-gold { background: var(--gold-100); color: var(--gold-600); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-dark { background: var(--green-900); color: #fff; }
.tag {
  display: inline-flex;
  align-items: center;
  height: 25px;
  padding: 0 9px;
  border-radius: 7px;
  background: #f2f5f2;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.tag-green { background: var(--green-50); color: var(--green-700); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }
.dot-red { background: var(--red); }

/* ---------- cards ---------- */
.card {
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 18px; }
.card-hover { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
.card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #dbe7df; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h2 { font-size: 17px; letter-spacing: -.01em; font-weight: 750; }
.section-head .more { font-size: 12.5px; color: var(--green-700); display: inline-flex; align-items: center; gap: 2px; font-weight: 600; }

/* ---------- avatar ---------- */
.avatar {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .02em;
  background: linear-gradient(135deg, var(--green-600), var(--green-800));
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.14);
  overflow: hidden;
  position: relative;
}
.avatar::after {
  content: "";
  position: absolute;
  width: 70%;
  height: 70%;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
  top: -32%;
  right: -20%;
}
.avatar-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.avatar-lg { width: 58px; height: 58px; border-radius: 18px; font-size: 22px; }
.avatar-xl { width: 76px; height: 76px; border-radius: 24px; font-size: 28px; }
.avatar-ring { box-shadow: 0 0 0 3px #fff, 0 0 0 4px var(--green-200); }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -8px; border: 2px solid #fff; }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .field-label { font-size: 13px; font-weight: 650; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted-2); line-height: 1.6; }
.input, .textarea, .select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 11px;
  min-height: 44px;
  padding: 10px 13px;
  font-size: 14px;
  outline: none;
  transition: border-color .16s ease, box-shadow .16s ease;
  color: var(--ink);
}
.textarea { resize: vertical; min-height: 96px; line-height: 1.7; }
.input::placeholder, .textarea::placeholder { color: #abb6b0; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 3px rgba(35, 148, 120, .12);
}
.input-group { position: relative; }
.input-group .ic { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted-2); pointer-events: none; }
.input-group .input { padding-left: 40px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.check { display: flex; gap: 9px; align-items: flex-start; font-size: 12.5px; color: var(--ink-2); line-height: 1.6; cursor: pointer; }
.check input { width: 16px; height: 16px; margin-top: 1px; accent-color: var(--green-700); }

.segmented {
  display: flex;
  padding: 3px;
  background: #f0f4f1;
  border-radius: 10px;
  gap: 2px;
}
.segmented button {
  flex: 1;
  border: 0;
  background: transparent;
  border-radius: 8px;
  min-height: 34px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
  transition: all .15s ease;
}
.segmented button.on { background: #fff; color: var(--green-800); box-shadow: 0 2px 7px rgba(10,53,43,.09); }
.chip-row { display: flex; gap: 7px; overflow-x: auto; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  transition: all .15s ease;
}
.chip.on { background: var(--green-800); border-color: var(--green-800); color: #fff; }
.chip:hover:not(.on) { border-color: var(--green-300, #8fceb9); color: var(--green-700); }

.switch { position: relative; width: 42px; height: 24px; flex: none; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #cfd8d3; border-radius: 99px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--green-600); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------- data ---------- */
.metric-label { font-size: 12px; color: var(--muted); }
.metric-value { font-size: 28px; font-weight: 760; letter-spacing: -.035em; font-family: var(--num); }
.metric-unit { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }
.divider { height: 1px; background: var(--line-2); border: 0; margin: 14px 0; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line-2); }
.list-row:last-child { border-bottom: 0; }

.empty {
  padding: 44px 20px;
  text-align: center;
  color: var(--muted-2);
}
.empty .empty-icon {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--green-50);
  color: var(--green-600);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}
.empty h4 { font-size: 14px; color: var(--ink-2); margin-bottom: 5px; }
.empty p { font-size: 12px; line-height: 1.6; }

.progress { height: 6px; border-radius: 99px; background: #eaf0ec; overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--green-500), var(--green-700)); transition: width .4s ease; }

/* ---------- modal / toast ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 28, 22, .44);
  backdrop-filter: blur(4px);
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade .18s ease;
}
.modal {
  background: #fff;
  border-radius: 20px;
  width: min(520px, 100%);
  max-height: min(86vh, 760px);
  overflow: auto;
  box-shadow: var(--shadow-lg);
  animation: pop .2s ease;
}
.modal-head { padding: 20px 22px 0; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.modal-head h3 { font-size: 17px; font-weight: 750; }
.modal-body { padding: 16px 22px; }
.modal-foot { padding: 12px 22px 20px; display: flex; justify-content: flex-end; gap: 8px; }
.modal-sub { font-size: 12px; color: var(--muted); margin-top: 4px; line-height: 1.6; }
.modal-close { border: 0; width: 30px; height: 30px; border-radius: 50%; background: #f2f5f2; color: var(--muted); display: flex; align-items: center; justify-content: center; }

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.985); opacity: 0; } }

.toast-stack { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(92vw, 480px); }
.toast {
  background: rgba(10, 46, 36, .94);
  color: #fff;
  border-radius: 11px;
  padding: 10px 16px;
  font-size: 13px;
  box-shadow: 0 10px 28px rgba(4, 27, 20, .22);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn .2s ease;
  max-width: 100%;
}
.toast.err { background: #822b28; }
.toast .ic { color: #a9e7d1; }
.toast.err .ic { color: #ffd3d0; }
@keyframes toastIn { from { transform: translateY(-8px); opacity: 0; } }

.spinner { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton { background: linear-gradient(90deg, #eff3f0 25%, #f8faf8 37%, #eff3f0 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 8px; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* skeleton lines */
.sk-line { height: 12px; margin-bottom: 8px; }
.sk-avatar { width: 40px; height: 40px; border-radius: 12px; flex: none; }

/* mini status bar shared */
.statusbar {
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  font-family: var(--num);
  color: var(--ink);
  flex: none;
}
.statusbar .status-icons { display: flex; align-items: center; gap: 4px; }
.statusbar .battery { width: 20px; height: 10px; border: 1.2px solid currentColor; border-radius: 2.5px; position: relative; }
.statusbar .battery::after { content: ""; position: absolute; left: 1.5px; top: 1.5px; bottom: 1.5px; width: 13px; background: currentColor; border-radius: 1px; }
.statusbar .battery::before { content: ""; position: absolute; right: -3px; top: 3px; width: 2px; height: 4px; background: currentColor; border-radius: 0 1px 1px 0; }

/* wechat-like capsule */
.capsule {
  display: flex;
  align-items: center;
  height: 30px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .62);
  border: 1px solid rgba(0, 0, 0, .06);
  padding: 0 4px;
  backdrop-filter: blur(8px);
}
.capsule .cap-dots { width: 30px; display: flex; justify-content: center; gap: 3px; }
.capsule .cap-dots i { width: 3px; height: 3px; border-radius: 50%; background: currentColor; }
.capsule .cap-sep { width: 1px; height: 14px; background: rgba(0,0,0,.12); }
.capsule .cap-circle { width: 30px; display: flex; justify-content: center; }
.capsule .cap-circle i { width: 11px; height: 11px; border: 1.6px solid currentColor; border-radius: 50%; position: relative; }
.capsule .cap-circle i::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 1.3px solid currentColor; }

/* scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cdd8d1; border-radius: 8px; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal { border-radius: 22px 22px 0 0; max-height: 88vh; }
}
