:root {
  color-scheme: light;
  --ink: #17252c;
  --muted: #718087;
  --line: #e5eaec;
  --paper: #ffffff;
  --canvas: #f4f6f8;
  --teal: #087e77;
  --teal-dark: #076760;
  --teal-light: #e5f4f1;
  --amber: #a65b0a;
  --amber-light: #fff3dd;
  --red: #a34537;
  --red-light: #fff0ed;
  font-family: 'Noto Sans SC', 'Microsoft YaHei', 'Segoe UI', sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button, input { font: inherit; }
button { color: inherit; }

.page-shell { width: min(1440px, calc(100% - 56px)); margin: 0 auto; padding: 22px 0 36px; }
.topbar, .brand, .connection-status, .section-heading, .list-heading, .form-heading, .form-actions, .page-footer { display: flex; align-items: center; }
.topbar, .section-heading, .list-heading, .form-heading, .form-actions, .page-footer { justify-content: space-between; }
.brand { gap: 10px; color: var(--ink); font-size: 13px; font-weight: 700; text-decoration: none; letter-spacing: .02em; }
.brand-mark { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; color: #fff; background: var(--teal); font-size: 14px; }
.status-dot { width: 7px; height: 7px; flex: 0 0 auto; border-radius: 50%; background: #35a77d; }

.intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; padding: 44px 0 25px; }
.eyebrow { margin: 0 0 8px; color: var(--teal); font-size: 10px; font-weight: 700; letter-spacing: .14em; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 9px; font-size: clamp(28px, 3.4vw, 40px); line-height: 1.16; letter-spacing: -.045em; }
.intro-copy { margin-bottom: 0; color: var(--muted); font-size: 14px; }
.connection-status { gap: 8px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 999px; color: #597069; background: rgba(255,255,255,.7); font-size: 11px; white-space: nowrap; }
.connection-status.error { color: var(--red); border-color: #f2d2cc; background: var(--red-light); }
.connection-status.error .status-dot { background: #c35b4d; }

.summary-grid { display: grid; grid-template-columns: 1.2fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.summary-card { display: flex; align-items: baseline; gap: 8px; min-height: 90px; padding: 18px 20px; border: 1px solid var(--line); border-radius: 13px; background: var(--paper); }
.summary-main { border-color: #d5e9e4; background: #f0f8f6; }
.summary-label { align-self: center; margin-right: auto; color: #64757b; font-size: 12px; }
.summary-card strong { color: var(--ink); font-size: 28px; line-height: 1; }
.summary-main strong { color: var(--teal-dark); }
.summary-unit { align-self: center; color: #879399; font-size: 11px; white-space: nowrap; }

.panel { padding: 22px; border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: 0 3px 14px rgba(29, 48, 56, .025); }
.week-panel { margin-bottom: 16px; }
.section-heading { align-items: flex-end; gap: 20px; margin-bottom: 18px; }
.section-heading .eyebrow { margin-bottom: 5px; }
h2 { margin-bottom: 0; font-size: 19px; letter-spacing: -.025em; }
.quiet-copy { margin: 0; color: #8a969a; font-size: 11px; }
.week-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 9px; }
.day-card { min-width: 0; min-height: 190px; padding: 12px 10px 10px; border: 1px solid var(--line); border-radius: 11px; background: #fff; text-align: left; cursor: pointer; transition: border-color .15s, background .15s, transform .15s; }
.day-card:hover { border-color: #a9d2cb; transform: translateY(-1px); }
.day-card.is-selected { border-color: var(--teal); background: #f4faf8; box-shadow: inset 0 0 0 1px var(--teal); }
.day-card.is-today .day-date { color: var(--teal-dark); }
.day-top { display: flex; align-items: baseline; justify-content: space-between; gap: 4px; padding-bottom: 10px; border-bottom: 1px solid #edf0f1; }
.day-date { font-size: 19px; font-weight: 700; line-height: 1; }
.day-weekday { color: #859197; font-size: 10px; }
.today-label { display: inline-block; margin-top: 5px; color: var(--teal); font-size: 9px; font-weight: 700; }
.day-records { display: grid; gap: 8px; padding-top: 10px; }
.day-empty { color: #a0aaae; font-size: 10px; line-height: 1.6; }
.mini-event { display: grid; gap: 5px; min-width: 0; }
.mini-event-name { overflow: hidden; color: #34454c; font-size: 10px; font-weight: 600; line-height: 1.45; text-overflow: ellipsis; }
.role-tags { display: flex; flex-wrap: wrap; gap: 3px; }
.role-tag { padding: 2px 5px; border-radius: 4px; color: #51716b; background: #ecf5f2; font-size: 8px; line-height: 1.3; }
.mini-materials { color: var(--amber); font-size: 9px; line-height: 1.35; }
.mini-materials.complete { color: var(--teal); }
.week-legend { display: flex; gap: 14px; margin: 12px 0 0; color: #889398; font-size: 10px; }
.legend-dot { display: inline-block; width: 6px; height: 6px; margin: 0 5px 1px 0; border-radius: 50%; background: var(--teal); }

.selected-panel { padding-bottom: 25px; }
.selected-heading { align-items: center; margin-bottom: 21px; }
.date-picker-label { display: flex; align-items: center; gap: 9px; color: #728087; font-size: 11px; }
.date-picker-label > label { flex: 0 0 auto; }
.date-picker-label .date-control { width: min(280px, 65vw); }
.selected-layout { display: grid; grid-template-columns: minmax(250px, .85fr) minmax(360px, 1.15fr); gap: 18px; align-items: start; }
.record-list-area { min-height: 270px; padding: 17px; border: 1px solid var(--line); border-radius: 12px; background: #fbfcfc; }
.list-heading { gap: 12px; align-items: center; margin-bottom: 14px; }
h3 { margin-bottom: 4px; font-size: 14px; }
.list-heading .quiet-copy { font-size: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 0 13px; border: 1px solid transparent; border-radius: 8px; font-size: 11px; font-weight: 600; cursor: pointer; transition: background .15s, border-color .15s; }
.button-secondary { flex: 0 0 auto; border-color: #d9e7e4; color: var(--teal-dark); background: #fff; }
.button-secondary:hover { border-color: #9bcac2; background: #f2f9f7; }
.button-primary { min-width: 112px; color: #fff; background: var(--teal); }
.button-primary:hover { background: var(--teal-dark); }
.button:disabled { opacity: .55; cursor: wait; }
.selected-records { display: grid; gap: 8px; }
.record-button { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px; border: 1px solid #e8edee; border-radius: 9px; background: #fff; text-align: left; cursor: pointer; }
.record-button:hover { border-color: #9bcac2; }
.record-main { min-width: 0; }
.record-name { display: block; overflow: hidden; color: #293a41; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.record-dates { display: block; margin-top: 4px; color: #89959a; font-size: 10px; }
.record-missing { display: block; margin-top: 5px; color: var(--amber); font-size: 9px; line-height: 1.5; }
.record-missing.complete { color: var(--teal); }
.record-progress { min-width: 34px; flex: 0 0 auto; padding: 5px 7px; border-radius: 6px; color: var(--amber); background: var(--amber-light); font-size: 9px; font-weight: 600; text-align: center; }
.record-progress.complete { color: var(--teal-dark); background: var(--teal-light); }
.empty-state { padding: 30px 12px; color: #8a969a; font-size: 11px; text-align: center; }

.event-form, .form-placeholder { min-height: 270px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.event-form[hidden] { display: none; }
.form-heading { margin-bottom: 15px; }
.form-heading .eyebrow { margin-bottom: 4px; }
.text-button { padding: 5px; border: 0; color: #879398; background: transparent; font-size: 10px; cursor: pointer; }
.text-button:hover { color: var(--ink); }
.field-label { display: grid; gap: 7px; margin-bottom: 13px; color: #5f6f75; font-size: 10px; font-weight: 600; }
.text-input { width: 100%; min-height: 38px; padding: 9px 10px; border: 1px solid #dfe6e8; border-radius: 7px; outline: none; color: var(--ink); background: #fff; font-size: 12px; }
.text-input:focus, .date-picker-label input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(8,126,119,.1); }
.text-input::placeholder { color: #a5afb3; }
.date-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.date-field { min-width: 0; }
.date-field .field-label { margin-bottom: 7px; }
.date-control { position: relative; min-width: 0; }
.date-text { padding-right: 42px; }
.date-trigger { position: absolute; top: 1px; right: 1px; display: grid; width: 38px; height: calc(100% - 2px); place-items: center; border: 0; border-radius: 6px; color: #718087; background: transparent; cursor: pointer; }
.date-trigger:hover { color: var(--teal); background: #f2f8f7; }
.date-trigger svg { width: 17px; height: 17px; }
.native-date-picker { position: absolute; top: 50%; left: 50%; width: 1px; height: 1px; padding: 0; overflow: hidden; opacity: 0; pointer-events: none; clip-path: inset(50%); }
.materials-fieldset { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 16px; margin: 3px 0 0; padding: 13px 0 0; border: 0; border-top: 1px solid #edf0f1; }
.materials-fieldset legend { padding: 0 0 10px; color: #5f6f75; font-size: 10px; font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 8px; color: #46585f; font-size: 10px; cursor: pointer; }
.check-row input { width: 15px; height: 15px; margin: 0; accent-color: var(--teal); }
.privacy-note { grid-column: 1 / -1; margin: 0; color: #909b9f; font-size: 9px; line-height: 1.5; }
.form-actions { gap: 12px; margin-top: 16px; }
.form-message { margin: 0; color: var(--teal-dark); font-size: 10px; }
.form-message.error { color: var(--red); }
.form-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: #8a969a; background: #fbfcfc; text-align: center; }
.placeholder-icon { display: grid; width: 38px; height: 38px; margin-bottom: 3px; place-items: center; border-radius: 11px; color: var(--teal); background: var(--teal-light); font-size: 18px; }
.form-placeholder strong { color: #506168; font-size: 11px; }
.form-placeholder span:last-child { font-size: 10px; }
.form-placeholder[hidden] { display: none; }
.page-footer { gap: 12px; padding: 17px 3px 0; color: #909b9f; font-size: 9px; }

@media (max-width: 980px) {
  .page-shell { width: min(100% - 32px, 760px); }
  .week-grid { grid-template-columns: repeat(4, minmax(120px, 1fr)); overflow-x: auto; }
  .day-card { min-height: 165px; }
  .selected-layout { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .page-shell { width: calc(100% - 24px); padding-top: 14px; }
  .intro { align-items: flex-start; flex-direction: column; gap: 14px; padding: 33px 0 20px; }
  .intro-copy { max-width: 36ch; font-size: 12px; line-height: 1.7; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .summary-card { min-height: 73px; padding: 12px; flex-wrap: wrap; gap: 5px 7px; }
  .summary-card:first-child { grid-column: 1 / -1; }
  .summary-label { font-size: 10px; }
  .summary-card strong { font-size: 23px; }
  .summary-unit { font-size: 9px; }
  .panel { padding: 15px 12px; border-radius: 12px; }
  .section-heading { align-items: flex-start; flex-direction: column; gap: 10px; }
  .week-grid { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; padding-bottom: 0; overflow: visible; }
  .day-card { min-height: 150px; padding: 7px 2px; border-radius: 8px; }
  .day-top { align-items: center; flex-direction: column; justify-content: center; gap: 3px; padding-bottom: 6px; }
  .day-date { font-size: 13px; }
  .day-weekday { font-size: 8px; }
  .today-label { display: block; margin-top: 3px; font-size: 7px; text-align: center; }
  .day-records { gap: 6px; padding-top: 5px; }
  .day-empty { font-size: 7px; line-height: 1.3; text-align: center; overflow-wrap: anywhere; }
  .mini-event { justify-items: center; gap: 3px; }
  .mini-event-name { font-size: 8px; line-height: 1.25; text-align: center; overflow: visible; overflow-wrap: anywhere; text-overflow: clip; white-space: normal; word-break: break-all; }
  .role-tags { justify-content: center; gap: 2px; }
  .role-tag { padding: 1px 2px; font-size: 7px; line-height: 1.2; }
  .mini-materials { font-size: 0; line-height: 1.2; text-align: center; }
  .mini-materials::after { content: attr(data-compact); font-size: 7px; }
  .week-legend { flex-wrap: wrap; }
  .selected-heading { align-items: flex-start; }
  .date-picker-label { width: 100%; justify-content: space-between; }
  .date-picker-label .date-control { width: 65%; }
  .record-list-area, .event-form, .form-placeholder { padding: 14px; }
  .list-heading { align-items: flex-start; }
  .date-fields { grid-template-columns: 1fr; gap: 0; }
  .materials-fieldset { grid-template-columns: 1fr; }
  .privacy-note { grid-column: auto; }
  .page-footer { align-items: flex-start; flex-direction: column; line-height: 1.5; }
}
