:root {
  --bg: #f4f6f7;
  --surface: #ffffff;
  --surface-soft: #f8faf9;
  --text: #17211d;
  --muted: #64716b;
  --line: #dfe5e2;
  --line-strong: #cbd5d0;
  --green: #18794e;
  --green-dark: #11623e;
  --green-soft: #e8f4ed;
  --blue: #2563a6;
  --blue-soft: #eaf2fb;
  --amber: #a96111;
  --amber-soft: #fff4df;
  --red: #b33a3a;
  --red-soft: #fcecec;
  --shadow: 0 1px 2px rgba(20, 33, 27, 0.05), 0 8px 24px rgba(20, 33, 27, 0.04);
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--bg); font-size: 16px; line-height: 1.5; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(37, 99, 166, 0.25);
  outline-offset: 2px;
}

.app-shell { min-height: 100vh; }
.topbar {
  height: 80px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; background: var(--green); color: white; border-radius: 7px; }
.brand-mark svg { width: 21px; height: 21px; }
.brand strong, .brand small { display: block; letter-spacing: 0; }
.brand strong { font-size: 17px; }
.brand small { font-size: 13px; color: var(--muted); margin-top: 2px; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.sync-state { color: var(--muted); font-size: 14px; display: inline-flex; align-items: center; gap: 7px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.sync-state.online .status-dot { background: var(--green); }
.sync-state.error .status-dot { background: var(--red); }
.mode-badge { font-size: 14px; color: var(--blue); background: var(--blue-soft); padding: 7px 10px; border-radius: 4px; }

.page-tabs {
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  height: 58px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 28px;
}
.page-tab { border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; gap: 8px; padding: 0 2px; position: relative; font-size: 15px; }
.page-tab svg { width: 19px; height: 19px; }
.page-tab.active { color: var(--green-dark); font-weight: 700; }
.page-tab.active::after { content: ""; position: absolute; height: 2px; left: 0; right: 0; bottom: 0; background: var(--green); }

main { width: min(1500px, 100%); margin: 0 auto; padding: 32px 28px 54px; }
.page { display: none; }
.page.active { display: block; }
.page-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.page-heading.compact { align-items: start; }
.eyebrow, .section-kicker { margin: 0 0 7px; color: var(--green); font-size: 14px; font-weight: 700; }
h1, h2, h3, p { letter-spacing: 0; }
h1 { font-size: 32px; line-height: 1.2; margin: 0; }
h2 { font-size: 20px; line-height: 1.35; margin: 0; }
h3 { font-size: 17px; margin: 0; }
.subtle { color: var(--muted); margin: 8px 0 0; font-size: 15px; }
.period-controls, .date-nav { display: flex; align-items: center; gap: 8px; }

.segmented { display: flex; padding: 3px; background: #e8ecea; border-radius: 6px; }
.segmented button { min-width: 42px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 4px; }
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(20,33,27,0.12); font-weight: 700; }
.icon-button { width: 42px; height: 42px; border: 1px solid var(--line-strong); border-radius: 6px; background: var(--surface); display: inline-grid; place-items: center; color: var(--text); }
.icon-button:hover { background: var(--surface-soft); }
.icon-button svg { width: 17px; height: 17px; }
.today-button, .primary-button, .secondary-button { height: 42px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 17px; font-weight: 700; text-decoration: none; }
.today-button { border: 1px solid var(--line-strong); background: var(--surface); }
.primary-button { border: 1px solid var(--green); background: var(--green); color: #fff; }
.primary-button:hover { background: var(--green-dark); }
.secondary-button { border: 1px solid var(--line-strong); background: var(--surface); color: var(--text); }
.secondary-button:hover { background: var(--surface-soft); }
.primary-button svg, .secondary-button svg { width: 16px; height: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.metric-card { min-height: 140px; padding: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); }
.metric-card-head { display: flex; justify-content: space-between; align-items: center; }
.metric-card-head span { color: var(--muted); font-size: 15px; }
.metric-icon { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 6px; background: var(--green-soft); color: var(--green); }
.metric-icon.blue { background: var(--blue-soft); color: var(--blue); }
.metric-icon.amber { background: var(--amber-soft); color: var(--amber); }
.metric-icon svg { width: 17px; height: 17px; }
.metric-value { margin-top: 18px; font-size: 32px; line-height: 1; font-weight: 750; }
.metric-foot { margin-top: 12px; font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.metric-target { color: var(--green-dark); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(300px, 0.8fr); gap: 14px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; box-shadow: var(--shadow); padding: 24px; min-width: 0; }
.panel-heading { display: flex; align-items: start; justify-content: space-between; gap: 18px; margin-bottom: 18px; }
.panel-meta { color: var(--muted); font-size: 14px; white-space: nowrap; }
.heading-icon { width: 18px; height: 18px; color: var(--muted); }
.progress-panel { min-height: 350px; }
.checkpoint-panel { min-height: 350px; }
.platform-goals-panel { grid-column: 1 / -1; padding-bottom: 0; }
.platform-goals-table { min-width: 560px; }
.goal-progress { font-variant-numeric: tabular-nums; }
.goal-progress.met { color: var(--green-dark); font-weight: 700; }
.data-summary-panel { grid-column: 1 / -1; padding-bottom: 0; }
.decisions-panel { grid-column: 1 / -1; }

.timeline { position: relative; }
.timeline::before { content: ""; position: absolute; left: 76px; top: 7px; bottom: 8px; width: 1px; background: var(--line); }
.timeline-item { display: grid; grid-template-columns: 62px 20px 1fr auto; gap: 10px; align-items: start; padding: 0 0 19px; }
.timeline-time { font-size: 14px; color: var(--muted); padding-top: 3px; text-align: right; }
.timeline-dot { width: 10px; height: 10px; margin: 5px auto 0; border: 2px solid var(--surface); box-shadow: 0 0 0 2px var(--line-strong); background: var(--surface); border-radius: 50%; z-index: 1; }
.timeline-item.done .timeline-dot { background: var(--green); box-shadow: 0 0 0 2px var(--green); }
.timeline-item.doing .timeline-dot { background: var(--blue); box-shadow: 0 0 0 2px var(--blue); }
.timeline-copy strong { font-size: 16px; display: block; }
.timeline-copy p { margin: 5px 0 0; color: var(--muted); font-size: 14px; line-height: 1.5; }
.result-lines { margin-top: 7px; display: grid; gap: 4px; }
.result-lines p { margin: 0; display: grid; grid-template-columns: 34px 1fr; gap: 5px; }
.result-lines b { color: var(--text); font-size: 13px; }
.status-chip { font-size: 13px; font-weight: 700; padding: 5px 8px; border-radius: 4px; background: #eef1ef; color: var(--muted); }
.status-chip.done { background: var(--green-soft); color: var(--green-dark); }
.status-chip.doing { background: var(--blue-soft); color: var(--blue); }
.status-chip.blocked { background: var(--red-soft); color: var(--red); }

.schedule-list { display: grid; }
.schedule-item { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 12px 0; border-top: 1px solid var(--line); }
.schedule-item:first-child { border-top: 0; padding-top: 0; }
.schedule-item.current { margin: 0 -10px; padding: 12px 10px; border-top-color: transparent; background: var(--green-soft); border-radius: 5px; }
.schedule-time { color: var(--muted); font-size: 14px; }
.schedule-copy strong { display: block; font-size: 15px; line-height: 1.45; }
.schedule-copy span { display: block; color: var(--muted); font-size: 13px; margin-top: 3px; }

.decision-list { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.decision-item { border-left: 3px solid var(--amber); background: var(--surface-soft); padding: 14px; border-radius: 0 5px 5px 0; }
.decision-item.next { border-left-color: var(--green); }
.decision-item .decision-date { color: var(--muted); font-size: 13px; }
.decision-item strong { display: block; margin-top: 6px; font-size: 15px; }
.decision-item p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.decision-item p b { color: var(--text); margin-right: 7px; }

.empty-state { min-height: 220px; display: grid; place-items: center; text-align: center; color: var(--muted); }
.empty-state.compact { min-height: 120px; }
.empty-state svg { width: 28px; height: 28px; margin: 0 auto 10px; color: var(--line-strong); }
.empty-state p { margin: 0; font-size: 15px; }
.empty-state small { display: block; margin-top: 6px; }

.history-toolbar { display: flex; align-items: end; gap: 10px; margin-bottom: 14px; }
.history-toolbar label { width: 170px; }
.history-section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin: 24px 0 10px; }
.history-section-heading span { color: var(--muted); font-size: 14px; }
.table-panel { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; color: var(--muted); font-weight: 700; background: var(--surface-soft); }
th, td { padding: 15px 16px; border-bottom: 1px solid var(--line); vertical-align: top; white-space: nowrap; }
td.wrap { white-space: normal; min-width: 170px; }
td.wrap strong, td.wrap small { display: block; }
td.wrap small { color: var(--muted); margin-top: 4px; line-height: 1.45; }
.summary-table { min-width: 680px; }
.summary-table th, .summary-table td { text-align: right; }
.summary-table th:first-child, .summary-table td:first-child { text-align: left; }
.summary-table tbody tr:last-child td { border-bottom: 0; }
.row-actions { display: flex; gap: 6px; }
.row-action { width: 30px; height: 30px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); color: var(--muted); display: grid; place-items: center; }
.row-action:hover { color: var(--green); background: var(--green-soft); }
.row-action.danger:hover { color: var(--red); background: var(--red-soft); }
.row-action svg { width: 14px; height: 14px; }

.entry-layout { display: grid; grid-template-columns: 225px minmax(0, 1fr); gap: 18px; align-items: start; }
.entry-tabs { background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px; display: grid; gap: 4px; position: sticky; top: 142px; }
.entry-tabs button { height: 48px; border: 0; border-radius: 5px; background: transparent; color: var(--muted); padding: 0 14px; display: flex; gap: 10px; align-items: center; text-align: left; font-size: 15px; }
.entry-tabs button svg { width: 19px; height: 19px; }
.entry-tabs button.active { background: var(--green-soft); color: var(--green-dark); font-weight: 700; }
.entry-form { display: none; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 30px; box-shadow: var(--shadow); }
.entry-form.active { display: block; }
.form-section-title { border-bottom: 1px solid var(--line); padding-bottom: 16px; margin-bottom: 20px; }
.form-section-title p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.work-form-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; border-bottom: 1px solid var(--line); padding-bottom: 18px; }
.work-form-heading p { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.work-date-control { width: 180px; flex: 0 0 auto; }
.work-mode-bar { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 18px 0 6px; }
.work-mode-bar p { margin: 0; color: var(--muted); font-size: 14px; text-align: right; }
.work-mode-toggle { display: inline-flex; padding: 3px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 6px; }
.work-mode-toggle button { min-width: 126px; height: 42px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-weight: 700; font-size: 15px; }
.work-mode-toggle button.active { background: var(--surface); color: var(--green-dark); box-shadow: 0 1px 3px rgba(20,33,27,0.12); }
.work-mode-toggle svg { width: 15px; height: 15px; }
.work-block-list { margin-top: 8px; }
.work-block { display: grid; grid-template-columns: 215px minmax(0, 1fr); gap: 26px; padding: 24px 0; border-top: 1px solid var(--line); }
.work-block:first-child { border-top: 0; }
.work-block-meta { min-width: 0; }
.work-block-time { display: inline-block; color: var(--green-dark); background: var(--green-soft); border-radius: 4px; padding: 5px 8px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.work-block-meta strong { display: block; margin-top: 10px; font-size: 16px; line-height: 1.4; }
.work-block-meta small { display: block; margin-top: 5px; color: var(--muted); font-size: 13px; line-height: 1.5; }
.work-block-main { min-width: 0; }
.work-target-input input { min-height: 42px; }
.work-target-summary { padding: 10px 12px; background: var(--surface-soft); border-left: 3px solid var(--line-strong); }
.work-target-summary span { color: var(--muted); font-size: 12px; font-weight: 700; }
.work-target-summary p { margin: 4px 0 0; font-size: 14px; line-height: 1.5; }
.work-target-summary.empty p { color: var(--muted); }
.work-status-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 10px; }
.work-status-row > span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.status-choice { display: inline-flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.status-choice input { position: absolute; opacity: 0; pointer-events: none; }
.status-choice label { min-height: 36px; display: inline-flex; align-items: center; justify-content: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); background: var(--surface); cursor: pointer; font-size: 13px; }
.status-choice input:checked + label { border-color: #9fcbb8; color: var(--green-dark); background: var(--green-soft); }
.status-choice input[value="未开始"]:checked + label { border-color: var(--line-strong); color: var(--muted); background: #eef1ef; }
.status-choice input[value="进行中"]:checked + label { border-color: #b8ccdf; color: var(--blue); background: var(--blue-soft); }
.status-choice input[value="受阻"]:checked + label { border-color: #e4b9b1; color: var(--red); background: var(--red-soft); }
.work-progress-fields { display: grid; gap: 12px; margin-top: 12px; }
.work-progress-fields[hidden], .work-blocker-field[hidden] { display: none !important; }
.work-progress-fields textarea { min-height: 70px; }
.work-form-actions { align-items: center; justify-content: space-between; }
.work-save-summary { color: var(--muted); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; }
label { display: grid; gap: 8px; color: #3f4d46; font-size: 14px; font-weight: 700; }
.field-name small { display: block; margin-top: 4px; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.4; }
input, select, textarea { width: 100%; border: 1px solid var(--line-strong); border-radius: 5px; background: var(--surface); color: var(--text); padding: 11px 12px; min-height: 46px; }
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: #9aa49f; }
.span-2 { grid-column: span 2; }
.data-section { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 18px; }
.numeric-grid, .goal-grid { display: grid; gap: 13px; margin-top: 13px; }
.numeric-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
.goal-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
.full-label { margin-top: 18px; }
.optional-data { border-top: 1px solid var(--line); margin-top: 22px; padding-top: 17px; }
.optional-data summary { color: var(--muted); font-size: 14px; font-weight: 700; cursor: pointer; }
.optional-data[open] summary { color: var(--text); }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; border-top: 1px solid var(--line); margin-top: 24px; padding-top: 18px; }
.goal-period-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }

footer { min-height: 64px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; display: flex; align-items: center; justify-content: space-between; padding: 0 max(28px, calc((100vw - 1500px) / 2)); }

dialog { border: 0; border-radius: 8px; padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: 0 24px 70px rgba(17, 30, 24, 0.24); }
.wide-dialog { width: min(760px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(17, 30, 24, 0.48); }
dialog form { padding: 28px; }
.dialog-icon { width: 42px; height: 42px; border-radius: 7px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); margin-bottom: 16px; }
.dialog-icon svg { width: 20px; height: 20px; }
dialog h2 { font-size: 20px; }
dialog p { color: var(--muted); font-size: 15px; line-height: 1.6; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.form-error { min-height: 20px; color: var(--red); margin-bottom: 0; }
.toast { position: fixed; right: 24px; bottom: 24px; padding: 13px 17px; border-radius: 6px; color: #fff; background: #1e2b25; box-shadow: 0 12px 30px rgba(17,30,24,0.22); opacity: 0; transform: translateY(10px); pointer-events: none; transition: 180ms ease; z-index: 40; font-size: 15px; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

body:not(.edit-mode) .editor-only { display: none !important; }

@media (max-width: 980px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dashboard-grid { grid-template-columns: 1fr; }
  .platform-goals-panel { grid-column: auto; }
  .data-summary-panel { grid-column: auto; }
  .decisions-panel { grid-column: auto; }
  .decision-list { grid-template-columns: 1fr; }
  .entry-layout { grid-template-columns: 1fr; }
  .entry-tabs { position: static; display: flex; overflow-x: auto; }
  .entry-tabs button { min-width: max-content; }
  .work-block { grid-template-columns: 190px minmax(0, 1fr); }
  .numeric-grid, .goal-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}

@media (max-width: 680px) {
  .topbar { height: 68px; padding: 0 16px; }
  .brand small, .sync-state { display: none; }
  .page-tabs { padding: 0 16px; height: 54px; gap: 20px; overflow-x: auto; }
  .page-tab { min-width: max-content; }
  main { padding: 24px 14px 40px; }
  .page-heading { display: grid; align-items: start; }
  .period-controls { flex-wrap: wrap; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .metric-card { min-height: 126px; padding: 17px; }
  .metric-value { font-size: 28px; }
  .panel { padding: 18px; }
  .dashboard-grid { gap: 9px; }
  .timeline::before { left: 62px; }
  .timeline-item { grid-template-columns: 49px 17px 1fr; }
  .timeline-item .status-chip { grid-column: 3; width: max-content; margin-top: -8px; }
  .schedule-item { grid-template-columns: 82px 1fr; }
  .history-toolbar { align-items: stretch; display: grid; grid-template-columns: 1fr 1fr; }
  .history-toolbar label { width: auto; }
  .history-toolbar button { grid-column: span 2; }
  .form-grid, .goal-period-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .numeric-grid, .goal-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .entry-form { padding: 22px 16px; }
  .work-form-heading { align-items: stretch; display: grid; gap: 14px; }
  .work-date-control { width: 100%; }
  .work-mode-bar { display: grid; gap: 10px; }
  .work-mode-toggle { display: grid; grid-template-columns: 1fr 1fr; }
  .work-mode-toggle button { min-width: 0; width: 100%; }
  .work-mode-bar p { text-align: left; line-height: 1.5; }
  .work-block { grid-template-columns: 1fr; gap: 12px; padding: 18px 0; }
  .work-block-meta { display: grid; grid-template-columns: max-content 1fr; column-gap: 10px; align-items: center; }
  .work-block-meta strong { margin-top: 0; }
  .work-block-meta small { grid-column: 1 / -1; }
  .work-status-row { align-items: start; display: grid; gap: 7px; }
  .status-choice { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .status-choice label { min-height: 38px; padding: 0 4px; font-size: 13px; }
  .work-form-actions { align-items: stretch; display: grid; }
  .work-form-actions .primary-button { width: 100%; }
  footer { padding: 0 16px; }
}

@media (max-width: 420px) {
  .metric-grid { grid-template-columns: 1fr; }
  .mode-badge { display: none; }
  h1 { font-size: 28px; }
  .numeric-grid, .goal-grid { grid-template-columns: 1fr 1fr; }
}
