:root {
  color-scheme: light;
  --ink: #14211d;
  --ink-soft: #4c5d56;
  --paper: #f3f5f0;
  --surface: #ffffff;
  --surface-soft: #f8faf7;
  --line: #dce3dc;
  --line-strong: #c5d0c7;
  --brand: #087f5b;
  --brand-dark: #056447;
  --brand-soft: #ddf3e9;
  --warning: #a15c00;
  --warning-soft: #fff0d4;
  --danger: #b42318;
  --danger-soft: #ffebe9;
  --info: #295a8a;
  --shadow: 0 18px 45px rgba(18, 45, 35, 0.08);
  --radius-lg: 22px;
  --radius-md: 14px;
  --radius-sm: 9px;
  --sidebar-width: 248px;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); line-height: 1.5; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

:focus-visible {
  outline: 3px solid rgba(8, 127, 91, 0.35);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  left: 16px;
  top: -80px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 8px;
  color: white;
  background: var(--brand-dark);
  transition: top .15s ease;
}
.skip-link:focus { top: 16px; }

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  padding: 26px 20px;
  background: #10241d;
  color: #e8f3ee;
  z-index: 20;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 42px; }
.sidebar-brand strong { display: block; font-size: 17px; }
.sidebar-brand span { display: block; color: #98b1a7; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: #b8f3d9;
  color: #0c4d3a;
  font-family: "Songti SC", "STSong", serif;
  font-size: 34px;
  font-weight: 700;
}
.brand-mark-small { width: 42px; height: 42px; border-radius: 12px; font-size: 22px; }
.nav-list { display: grid; gap: 7px; }
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  color: #afc4bb;
  text-decoration: none;
  border-radius: 10px;
  font-size: 14px;
}
.nav-link span { color: #66867a; font: 600 10px/1 ui-monospace, SFMono-Regular, monospace; }
.nav-link:hover, .nav-link.is-active { background: rgba(216, 255, 238, .09); color: white; }
.sidebar-footer { margin-top: auto; display: grid; grid-template-columns: auto 1fr; gap: 6px 9px; align-items: center; color: #9eb7ad; font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 99px; background: #e2a12c; box-shadow: 0 0 0 4px rgba(226, 161, 44, .12); }
.status-dot.is-online { background: #45d69c; box-shadow: 0 0 0 4px rgba(69, 214, 156, .12); }
.text-button { grid-column: 2; justify-self: start; border: 0; padding: 0; color: #d7e7e0; background: none; text-decoration: underline; text-underline-offset: 3px; }

.main-content { margin-left: var(--sidebar-width); padding: 44px clamp(24px, 4vw, 64px) 30px; max-width: 1600px; }
.page-header { display: flex; justify-content: space-between; gap: 30px; align-items: flex-end; margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 8px; font-size: clamp(30px, 4vw, 48px); line-height: 1.05; letter-spacing: -.04em; }
h2 { margin-bottom: 4px; font-size: 21px; letter-spacing: -.02em; }
h3 { margin-bottom: 5px; font-size: 15px; }
.lead { margin-bottom: 0; color: var(--ink-soft); font-size: 16px; }
.muted { color: var(--ink-soft); }
.header-meta { min-width: 170px; padding: 12px 16px; border-left: 2px solid var(--brand); }
.header-meta span { display: block; color: var(--ink-soft); font-size: 11px; }
.header-meta strong { display: block; font-size: 15px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 20px; }
.metric-card { padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }
.metric-card-accent { background: #15372c; color: white; border-color: #15372c; }
.metric-label { display: block; color: var(--ink-soft); font-size: 12px; }
.metric-card-accent .metric-label, .metric-card-accent small { color: #a9c8bc; }
.metric-card strong { display: block; margin: 9px 0 4px; font-size: 28px; line-height: 1; }
.metric-card small { color: #788780; }

.section-card { margin-top: 20px; padding: clamp(20px, 3vw, 30px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: 0 4px 18px rgba(19, 44, 35, .025); scroll-margin-top: 20px; }
.section-heading { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; margin-bottom: 24px; }
.section-heading > div { display: flex; gap: 13px; }
.section-heading p { margin-bottom: 0; color: var(--ink-soft); font-size: 13px; }
.step-number { flex: 0 0 auto; width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; background: var(--brand-soft); color: var(--brand-dark); font: 800 11px/1 ui-monospace, monospace; }
.badge { display: inline-flex; align-items: center; min-height: 27px; padding: 4px 9px; border-radius: 99px; font-size: 11px; font-weight: 700; white-space: nowrap; }
.badge-muted { color: #5a6a63; background: #edf1ed; }
.badge-success { color: #056447; background: var(--brand-soft); }
.badge-warning { color: #7a4900; background: var(--warning-soft); }
.badge-danger { color: #912018; background: var(--danger-soft); }
.badge-info { color: #24527c; background: #e6f0fa; }

.config-grid { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(300px, .9fr); gap: 28px; }
.field { display: grid; gap: 7px; }
.field label, .segmented-fieldset legend { color: #33443d; font-size: 12px; font-weight: 700; }
.field small, .panel-note { color: #718078; font-size: 11px; }
input, textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  color: var(--ink);
  background: var(--surface);
  transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(8, 127, 91, .1); outline: 0; }
textarea { resize: vertical; }
.stack-md { display: grid; gap: 17px; }
.stack-lg { display: grid; gap: 22px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.button {
  min-height: 39px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 750;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .55; }
.button-primary { color: white; background: var(--brand); }
.button-primary:hover:not(:disabled) { background: var(--brand-dark); }
.button-secondary { color: var(--brand-dark); background: var(--surface); border-color: var(--line-strong); }
.button-secondary:hover:not(:disabled) { background: var(--brand-soft); border-color: #acd9c7; }
.button-danger { color: white; background: var(--danger); }
.button-ghost { color: var(--ink-soft); background: var(--surface-soft); border-color: var(--line); }
.button-lg { min-height: 46px; padding-inline: 22px; }
.button-block { width: 100%; }
.instruction-panel { padding: 20px; border-radius: 16px; background: var(--surface-soft); border: 1px solid var(--line); }
.numbered-list { margin: 15px 0 0; padding-left: 20px; color: var(--ink-soft); font-size: 13px; }
.numbered-list li + li { margin-top: 8px; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.action-card { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 15px; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface-soft); }
.action-card p { margin: 0; color: var(--ink-soft); font-size: 12px; }
.action-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: var(--brand-dark); background: var(--brand-soft); font-family: "Songti SC", serif; font-weight: 700; }

.choice-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.segmented-fieldset { min-width: 0; padding: 0; border: 0; }
.segmented-fieldset legend { margin-bottom: 7px; }
.segmented-control { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 11px; background: #edf1ed; }
.segmented-control label { position: relative; cursor: pointer; }
.segmented-control input { position: absolute; opacity: 0; pointer-events: none; }
.segmented-control span { display: block; padding: 8px 12px; border-radius: 8px; text-align: center; color: #65736d; font-size: 12px; font-weight: 700; }
.segmented-control input:checked + span { color: var(--brand-dark); background: white; box-shadow: 0 2px 7px rgba(20, 45, 36, .08); }
.segmented-control input:focus-visible + span { outline: 3px solid rgba(8, 127, 91, .3); }

.selection-grid { display: grid; grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr); align-items: center; gap: 12px; }
.selection-panel { min-width: 0; padding: 17px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-soft); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px; }
.panel-heading h3 { font-size: 16px; }
.panel-heading strong { color: var(--brand-dark); font-size: 13px; }
.panel-kicker { display: block; color: #84928b; font: 800 9px/1 ui-monospace, monospace; letter-spacing: .14em; margin-bottom: 5px; }
.search-field { display: block; margin-bottom: 10px; }
.search-field input { padding: 8px 10px; font-size: 12px; background: white; }
.flow-arrow { width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 99px; color: var(--brand); background: white; font-weight: 800; }
.member-table-wrap { height: 310px; margin-bottom: 12px; background: white; border: 1px solid var(--line); border-radius: 10px; }
.panel-note { margin: 10px 0 0; }
.table-scroll { overflow: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th { position: sticky; top: 0; z-index: 1; padding: 10px 12px; color: #66766e; background: #f6f8f5; border-bottom: 1px solid var(--line); text-align: left; font-size: 10px; letter-spacing: .04em; }
.data-table td { padding: 12px; border-bottom: 1px solid #e9ede9; vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: #fbfdfb; }
.compact-table td { padding-block: 9px; }
.align-right { text-align: right !important; }
.member-cell strong, .member-cell small { display: block; }
.member-cell strong { font-size: 12px; }
.member-cell small { color: #78877f; font-size: 10px; }
.count-pill { display: inline-block; min-width: 26px; padding: 2px 6px; border-radius: 99px; color: var(--brand-dark); background: var(--brand-soft); text-align: center; font-weight: 700; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--brand); }
.quota-input { width: 82px; padding: 6px 8px; text-align: right; }
.empty-cell { padding: 30px 12px !important; color: #7c8b84; text-align: center; }

.plan-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.planner-footer { display: flex; justify-content: space-between; gap: 20px; align-items: center; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--line); }
.allocation-summary { display: flex; gap: 18px; flex-wrap: wrap; color: var(--ink-soft); font-size: 12px; }
.allocation-summary strong { color: var(--ink); }
.state-link { border: 0; padding: 0; color: var(--brand-dark); background: none; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.page-footer { display: flex; justify-content: space-between; padding: 24px 4px 0; color: #79877f; font-size: 11px; }

.plan-dialog { width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 40px); padding: 0; border: 0; border-radius: 20px; color: var(--ink); background: white; box-shadow: var(--shadow); }
.plan-dialog::backdrop { background: rgba(7, 25, 18, .64); backdrop-filter: blur(3px); }
.dialog-header { position: sticky; top: 0; z-index: 4; display: flex; justify-content: space-between; align-items: flex-start; padding: 22px 24px 16px; border-bottom: 1px solid var(--line); background: white; }
.dialog-header h2 { font-size: 23px; }
.icon-button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; color: var(--ink-soft); background: white; font-size: 24px; line-height: 1; }
.dialog-content { padding: 22px 24px; overflow: auto; }
.dialog-actions { position: sticky; bottom: 0; display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--line); background: white; }
.dialog-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 18px; }
.dialog-metric { padding: 13px; border-radius: 11px; background: var(--surface-soft); border: 1px solid var(--line); }
.dialog-metric span, .dialog-metric strong { display: block; }
.dialog-metric span { color: var(--ink-soft); font-size: 10px; }
.dialog-metric strong { margin-top: 4px; font-size: 17px; }
.warning-box { margin-bottom: 16px; padding: 12px 14px; border-radius: 10px; color: #764600; background: var(--warning-soft); font-size: 12px; }
.spaced-heading { margin-top: 20px; }
.danger-zone { margin-top: 18px; padding: 15px; border: 1px solid #efc3bf; border-radius: 12px; background: #fff8f7; }
.danger-zone p { margin-bottom: 10px; color: #74423d; font-size: 12px; }
.confirm-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.toast-region { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: grid; gap: 9px; width: min(360px, calc(100vw - 44px)); }
.toast { padding: 13px 15px; border-radius: 11px; color: white; background: #17372c; box-shadow: var(--shadow); font-size: 13px; animation: toast-in .18s ease-out; }
.toast.is-error { background: #8f241c; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 32px; background: #10241d; }
.login-shell { width: min(1040px, 100%); display: grid; grid-template-columns: 1.05fr .95fr; overflow: hidden; border-radius: 28px; background: white; box-shadow: 0 35px 90px rgba(0,0,0,.28); }
.login-brand { padding: clamp(32px, 6vw, 68px); color: #eaf5ef; background: #17372c; }
.login-brand .eyebrow { margin-top: 38px; color: #7fdbb9; }
.login-brand h1 { max-width: 440px; font-size: clamp(36px, 5vw, 58px); }
.login-brand > p:not(.eyebrow) { max-width: 430px; color: #adc7bc; }
.feature-list { display: grid; gap: 13px; margin: 42px 0 0; padding: 0; list-style: none; }
.feature-list li { display: flex; align-items: center; gap: 12px; color: #d3e5dd; font-size: 13px; }
.feature-list span { color: #6da68f; font: 700 10px/1 ui-monospace, monospace; }
.login-card { display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: clamp(32px, 6vw, 64px); }
.login-card h2 { font-size: 28px; }
.login-footnote { margin: 0; color: #839087; font-size: 11px; }
.alert { padding: 11px 13px; border-radius: 9px; font-size: 12px; }
.alert-danger { color: #8f211a; background: var(--danger-soft); border: 1px solid #f0c4c0; }

@media (max-width: 1100px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
  .selection-grid { grid-template-columns: 1fr; }
  .flow-arrow { margin: -3px auto; transform: rotate(90deg); }
  .member-table-wrap { height: 260px; }
  .action-card { grid-template-columns: auto 1fr; }
  .action-card .button { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  .sidebar { position: static; width: auto; padding: 16px 18px; }
  .sidebar-brand { margin-bottom: 14px; }
  .nav-list { display: flex; overflow-x: auto; }
  .nav-link { flex: 0 0 auto; }
  .sidebar-footer { display: none; }
  .main-content { margin-left: 0; padding: 26px 16px; }
  .page-header { align-items: flex-start; }
  .header-meta { display: none; }
  .config-grid, .choice-grid, .plan-fields, .action-grid { grid-template-columns: 1fr; }
  .planner-footer { align-items: stretch; flex-direction: column; }
  .metric-grid { gap: 9px; }
  .metric-card { padding: 15px; }
  .metric-card strong { font-size: 23px; }
  .section-heading { flex-direction: column; }
  .login-page { padding: 14px; }
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .dialog-metrics { grid-template-columns: 1fr 1fr; }
  .confirm-row { grid-template-columns: 1fr; }
}

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