:root {
  color-scheme: light;
  --ink: #17202d;
  --muted: #737a87;
  --muted-strong: #596170;
  --line: #dfe3e1;
  --line-strong: #cbd1ce;
  --bg: #f4f6f3;
  --surface: #ffffff;
  --surface-soft: #f8faf8;
  --green: #147d70;
  --green-soft: #e8f3ef;
  --coral: #e45d3f;
  --coral-soft: #fbece8;
  --blue: #4263a9;
  --blue-soft: #edf0f8;
  --amber: #a56217;
  --red: #c63d3d;
  --shadow: 0 16px 40px rgba(23, 32, 45, .06);
}

* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "WenQuanYi Zen Hei", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.5;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}
body.has-chart-expanded { overflow: hidden; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { color: inherit; font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid rgba(20, 125, 112, .2);
  outline-offset: 2px;
}
svg { flex: 0 0 auto; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 10px max(24px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid rgba(203, 209, 206, .8);
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(14px);
}
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: end;
  gap: 3px;
  padding: 8px;
  border: 1px solid var(--ink);
  border-radius: 8px;
}
.brand-mark span { display: block; height: 55%; background: var(--coral); }
.brand-mark span:nth-child(2) { height: 100%; background: var(--green); }
.brand-mark span:nth-child(3) { height: 75%; background: var(--blue); }
.brand-copy { display: grid; line-height: 1.05; }
.brand-copy strong { font-size: 16px; }
.brand-copy small { margin-top: 4px; color: var(--muted); font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 7px;
  color: var(--muted-strong);
  font-size: 14px;
  font-weight: 600;
}
.nav-link:hover, .nav-link.is-active { background: var(--surface-soft); color: var(--ink); }
.nav-record, .icon-link {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
}
.nav-record { gap: 7px; margin-left: 8px; padding: 0 14px; background: var(--ink); color: white; font-size: 14px; font-weight: 700; }
.nav-record svg, .icon-link svg { width: 18px; height: 18px; }
.icon-link { width: 40px; color: var(--muted-strong); }
.icon-link:hover { background: var(--surface-soft); color: var(--ink); }

.page { width: min(1200px, calc(100% - 40px)); margin: 0 auto; padding: 36px 0 96px; }
.messages { position: fixed; top: 76px; right: 24px; z-index: 50; }
.message {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  border: 1px solid #b9d9cf;
  border-radius: 8px;
  background: white;
  color: var(--green);
  box-shadow: var(--shadow);
  font-size: 14px;
}
.message svg { width: 18px; height: 18px; }

h1, h2, h3, p { margin-top: 0; }
h1, h2, h3 { margin-bottom: 0; line-height: 1.18; }
h1 { font-size: 36px; font-weight: 800; }
h2 { font-size: 22px; font-weight: 800; }
h3 { font-size: 18px; font-weight: 800; }
.eyebrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
  color: var(--muted-strong);
  font-size: 13px;
  font-weight: 700;
}
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.page-description { margin: 9px 0 0; color: var(--muted); font-size: 14px; }
.section-kicker { margin: 0 0 4px; color: var(--coral); font-size: 10px; font-weight: 800; letter-spacing: .16em; }

.button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 9px 14px;
  cursor: pointer;
  font-weight: 700;
}
.button svg { width: 18px; height: 18px; }
.button-primary { background: var(--ink); border-color: var(--ink); color: white; }
.button-primary:hover { background: #2a3544; }
.button-secondary { background: white; border-color: var(--line-strong); color: var(--ink); }
.button-secondary:hover { background: var(--surface-soft); }
.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0;
  background: white;
  color: var(--muted-strong);
  cursor: pointer;
}
.icon-button:hover { border-color: var(--line-strong); color: var(--ink); background: var(--surface-soft); }
.icon-button svg { width: 17px; height: 17px; }

.dashboard-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px auto;
  align-items: end;
  gap: 32px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--line-strong);
}
.campaign-meter { min-width: 0; padding-bottom: 2px; }
.campaign-meter-copy, .campaign-dates, .progress-copy { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.campaign-meter-copy { margin-bottom: 8px; color: var(--muted-strong); font-size: 12px; }
.campaign-meter-copy strong { color: var(--ink); font-size: 14px; }
.campaign-track, .progress-track { height: 6px; overflow: hidden; border-radius: 3px; background: #dfe5e1; }
.campaign-track span, .progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--green); }
.campaign-dates { margin-top: 6px; color: var(--muted); font-size: 10px; }
.head-record-button { align-self: end; }
.section-block { margin-top: 34px; }
.section-heading, .chart-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}
.section-heading > p, .chart-heading > p { margin: 0; color: var(--muted); font-size: 13px; }

.member-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.member-card {
  --member-color: var(--coral);
  min-width: 0;
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 24px rgba(23, 32, 45, .035);
  transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.member-card::before { content: ""; position: absolute; top: 0; left: 0; width: 100%; height: 3px; background: var(--member-color); }
.member-card-2 { --member-color: var(--green); }
.member-card-3 { --member-color: var(--blue); }
.member-card:hover { transform: translateY(-2px); border-color: var(--line-strong); box-shadow: var(--shadow); }
.member-card-head, .member-identity, .member-weight { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.member-card-head > svg { width: 18px; height: 18px; color: var(--muted); }
.member-identity { justify-content: flex-start; min-width: 0; }
.member-avatar, .profile-avatar {
  display: grid;
  place-items: center;
  border-radius: 7px;
  background: color-mix(in srgb, var(--member-color) 12%, white);
  color: var(--member-color);
  font-weight: 800;
}
.member-avatar { width: 40px; height: 40px; flex: 0 0 40px; }
.member-identity p { margin: 3px 0 0; color: var(--muted); font-size: 11px; }
.member-weight { align-items: end; margin-top: 26px; }
.member-weight > div > span, .stat-cell > span { display: block; color: var(--muted); font-size: 12px; }
.member-weight strong { display: block; margin-top: 4px; font-size: 30px; line-height: 1; font-variant-numeric: tabular-nums; }
.member-weight strong small, .stat-cell strong small { font-size: .48em; font-weight: 600; }
.delta { flex: 0 1 auto; padding: 4px 7px; border-radius: 5px; background: #f1f3f2; color: var(--muted-strong); font-size: 10px; white-space: nowrap; }
.delta.is-good { background: var(--green-soft); color: var(--green); }
.delta.is-warn { background: var(--coral-soft); color: var(--coral); }
.member-progress { margin-top: 22px; }
.progress-copy { margin-bottom: 7px; color: var(--muted); font-size: 11px; }
.progress-copy strong { color: var(--ink); font-size: 12px; }
.member-card .progress-track span { background: var(--member-color); }
.member-facts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 20px 0 0; padding-top: 14px; border-top: 1px solid var(--line); }
.member-facts div + div { padding-left: 12px; border-left: 1px solid var(--line); }
.member-facts dt { color: var(--muted); font-size: 10px; }
.member-facts dd { margin: 2px 0 0; overflow: hidden; color: var(--ink); font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }

.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgba(23, 32, 45, .035); }
.chart-panel { min-width: 0; padding: 20px; }
.team-chart-panel { margin-top: 18px; }
.chart-heading { align-items: center; margin-bottom: 14px; }
.chart-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 10px 0 14px; border-top: 1px solid var(--line); }
.chart-toolbar-right { display: flex; align-items: center; gap: 10px; }
.segmented { display: inline-flex; align-items: center; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-soft); }
.segmented button {
  min-height: 30px;
  border: 0;
  border-radius: 5px;
  padding: 5px 11px;
  background: transparent;
  color: var(--muted-strong);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.segmented button.is-active { background: white; color: var(--ink); box-shadow: 0 1px 3px rgba(23, 32, 45, .12); }
.icon-group { display: flex; align-items: center; gap: 4px; }
.icon-group .icon-button { width: 34px; height: 34px; flex-basis: 34px; }
.chart-box { position: relative; width: 100%; min-width: 0; height: 340px; }
.chart-box canvas { position: absolute; inset: 0; width: 100% !important; height: 100% !important; }
.chart-panel:fullscreen, .chart-panel.chart-expanded {
  z-index: 100;
  width: 100vw;
  height: 100vh;
  padding: 28px;
  border: 0;
  border-radius: 0;
  background: white;
}
.chart-panel.chart-expanded { position: fixed; inset: 0; }
.chart-panel:fullscreen .chart-box, .chart-panel.chart-expanded .chart-box { height: calc(100vh - 170px); }

.back-link { display: inline-flex; align-items: center; gap: 7px; margin-bottom: 22px; color: var(--muted-strong); font-size: 13px; font-weight: 700; }
.back-link:hover { color: var(--ink); }
.back-link svg { width: 16px; height: 16px; }
.member-head { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.member-profile { display: flex; align-items: center; gap: 16px; }
.profile-avatar { --member-color: var(--green); width: 64px; height: 64px; flex: 0 0 64px; font-size: 22px; }
.member-stat-strip { display: grid; grid-template-columns: 1.25fr repeat(3, 1fr); margin-top: 24px; border: 1px solid var(--line); border-radius: 8px; background: white; }
.stat-cell { min-width: 0; padding: 16px 18px; }
.stat-cell + .stat-cell { border-left: 1px solid var(--line); }
.stat-cell-primary { background: var(--green-soft); }
.stat-cell strong { display: block; margin-top: 5px; overflow: hidden; font-size: 24px; line-height: 1.1; font-variant-numeric: tabular-nums; text-overflow: ellipsis; white-space: nowrap; }
.stat-cell p { margin: 6px 0 0; overflow: hidden; color: var(--muted); font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.good-text { color: var(--green); }
.warn-text { color: var(--coral); }
.member-chart-panel { margin-top: 18px; }
.records-section { margin-top: 34px; }
.records-heading { align-items: center; }
.records-list { border-top: 1px solid var(--line-strong); }
.record-row {
  min-width: 0;
  display: grid;
  grid-template-columns: 92px minmax(300px, .9fr) minmax(140px, 1fr) auto;
  align-items: center;
  gap: 22px;
  min-height: 76px;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
}
.record-date { display: flex; align-items: center; gap: 8px; }
.record-date time { display: grid; line-height: 1.05; }
.record-date strong { font-size: 17px; font-variant-numeric: tabular-nums; }
.record-date time span { margin-top: 4px; color: var(--muted); font-size: 10px; }
.tag { padding: 2px 4px; border: 1px solid #e8c498; border-radius: 4px; color: var(--amber); font-size: 9px; white-space: nowrap; }
.record-row dl { display: grid; grid-template-columns: repeat(3, minmax(70px, 1fr)); gap: 12px; margin: 0; }
.record-row dt { color: var(--muted); font-size: 10px; }
.record-row dd { margin: 2px 0 0; font-size: 14px; font-weight: 700; white-space: nowrap; }
.record-note { margin: 0; overflow: hidden; color: var(--muted-strong); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; align-items: center; gap: 4px; }
.row-actions form { display: flex; }
.row-actions .icon-button { width: 34px; height: 34px; flex-basis: 34px; border-color: transparent; background: transparent; }
.danger-button:hover { background: #fff0f0 !important; color: var(--red) !important; }
.empty-state { display: grid; place-items: center; min-height: 180px; color: var(--muted); }
.empty-state svg { width: 28px; height: 28px; }
.empty-state p { margin: 8px 0 0; }

.record-dialog {
  width: min(590px, calc(100% - 28px));
  max-height: calc(100dvh - 28px);
  overflow: auto;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: white;
  box-shadow: 0 30px 90px rgba(23, 32, 45, .3);
}
.record-dialog::backdrop { background: rgba(23, 32, 45, .5); backdrop-filter: blur(4px); }
.modal-card { display: grid; gap: 16px; padding: 22px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.modal-head h2 { font-size: 24px; }
.modal-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px; }
.field { min-width: 0; display: grid; gap: 6px; color: var(--muted-strong); font-size: 12px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 10px 11px;
  background: white;
  color: var(--ink);
}
input:focus, select:focus, textarea:focus { border-color: var(--green); outline: 3px solid rgba(20, 125, 112, .12); }
input[readonly] { background: var(--surface-soft); color: var(--muted-strong); }
textarea { min-height: 82px; resize: vertical; }
.field-error, .form-error { color: var(--red); font-size: 11px; }
.form-error { padding: 9px 11px; border-radius: 6px; background: #fff0f0; }
.modal-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding-top: 4px; }

.login-page .topbar { position: static; background: transparent; border-bottom: 0; }
.login-page .page { min-height: calc(100dvh - 64px); display: grid; place-items: center; padding-top: 24px; }
.login-shell { width: min(420px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 8px; background: white; box-shadow: var(--shadow); }
.login-shell h1 { font-size: 30px; }
.login-shell > p { margin: 8px 0 24px; color: var(--muted); }
.login-form { display: grid; gap: 15px; }
.login-form label { display: grid; gap: 6px; color: var(--muted-strong); font-size: 12px; font-weight: 700; }
.login-form .button { width: 100%; margin-top: 3px; }
.bottom-nav { display: none; }

.record-form { display: grid; gap: 16px; max-width: 820px; }
.record-form fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 16px; background: white; }
.record-form legend { padding: 0 6px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.form-actions { display: flex; gap: 10px; align-items: center; }

@media (max-width: 900px) {
  .dashboard-head { grid-template-columns: minmax(0, 1fr) 230px; }
  .head-record-button { grid-column: 1 / -1; width: max-content; }
  .member-grid { grid-template-columns: 1fr; }
  .member-card { padding: 16px 18px; }
  .member-weight { margin-top: 18px; }
  .member-progress { margin-top: 16px; }
  .member-facts { margin-top: 16px; }
  .record-row { grid-template-columns: 82px minmax(240px, 1fr) auto; gap: 14px; }
  .record-note { grid-column: 2 / 3; grid-row: 2; }
  .row-actions { grid-column: 3; grid-row: 1 / 3; }
}

@media (max-width: 680px) {
  .topbar { min-height: 56px; padding: 9px 12px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-copy strong { font-size: 15px; }
  .nav { display: none; }
  .page { width: calc(100% - 24px); padding: 24px 0 92px; }
  .messages { top: 66px; left: 12px; right: 12px; }
  h1 { font-size: 30px; }
  h2 { font-size: 20px; }
  .dashboard-head { grid-template-columns: 1fr auto; gap: 18px 12px; padding-bottom: 22px; }
  .dashboard-heading { min-width: 0; }
  .dashboard-heading h1 { white-space: nowrap; }
  .campaign-meter { grid-column: 1 / -1; grid-row: 2; }
  .head-record-button { grid-column: 2; grid-row: 1; align-self: center; width: 44px; height: 44px; padding: 0; }
  .head-record-button span { display: none; }
  .section-block { margin-top: 28px; }
  .section-heading, .chart-heading { align-items: center; }
  .section-heading > p, .chart-heading > p { display: none; }
  .member-grid { gap: 10px; }
  .member-card { padding: 15px; }
  .member-weight strong { font-size: 27px; }
  .member-facts { padding-top: 12px; }
  .chart-panel { padding: 15px 12px 12px; }
  .team-chart-panel { margin-top: 12px; }
  .chart-toolbar { align-items: stretch; flex-direction: column; gap: 8px; }
  .chart-toolbar-right { justify-content: space-between; gap: 8px; }
  .metric-switch { align-self: flex-start; }
  .range-switch { min-width: 0; flex: 1; }
  .range-switch button { flex: 1; min-width: 0; padding-inline: 6px; }
  .icon-group { gap: 2px; }
  .icon-group .icon-button { width: 32px; height: 32px; flex-basis: 32px; }
  .chart-box { height: 300px; }
  .chart-panel:fullscreen, .chart-panel.chart-expanded { padding: 16px 10px; }
  .chart-panel:fullscreen .chart-box, .chart-panel.chart-expanded .chart-box { height: calc(100vh - 190px); }
  .back-link { margin-bottom: 18px; }
  .member-head { align-items: flex-start; }
  .member-profile { min-width: 0; gap: 12px; }
  .profile-avatar { width: 52px; height: 52px; flex-basis: 52px; }
  .member-head .button { width: 42px; height: 42px; padding: 0; }
  .member-head .button span { display: none; }
  .member-stat-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 20px; }
  .stat-cell { padding: 13px; }
  .stat-cell + .stat-cell { border-left: 0; }
  .stat-cell:nth-child(even) { border-left: 1px solid var(--line); }
  .stat-cell:nth-child(n+3) { border-top: 1px solid var(--line); }
  .stat-cell strong { font-size: 21px; }
  .member-chart-panel { margin-top: 12px; }
  .records-section { margin-top: 28px; }
  .record-row { grid-template-columns: 64px minmax(0, 1fr) auto; gap: 10px; min-height: 92px; padding: 11px 2px; }
  .record-date { align-items: flex-start; flex-direction: column; gap: 3px; }
  .record-date strong { font-size: 16px; }
  .record-row dl { gap: 6px; }
  .record-row dd { font-size: 12px; }
  .record-note { grid-column: 2 / 3; max-width: 100%; }
  .row-actions { grid-column: 3; }
  .row-actions .icon-button { width: 32px; height: 32px; flex-basis: 32px; }
  .modal-card { padding: 18px 15px; }
  .modal-grid { grid-template-columns: 1fr; gap: 11px; }
  .modal-actions .button { flex: 1; }
  .bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    min-height: 62px;
    border-top: 1px solid var(--line-strong);
    background: rgba(255, 255, 255, .96);
    backdrop-filter: blur(12px);
  }
  .bottom-nav a { min-width: 0; display: grid; place-items: center; align-content: center; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 700; }
  .bottom-nav a svg { width: 19px; height: 19px; }
  .bottom-nav a.is-active { color: var(--green); }
  .bottom-nav .bottom-action { color: white; background: var(--ink); }
  .form-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
