:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #eef3f8;
  --text: #18202b;
  --muted: #657386;
  --line: #dce4ef;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --blue: #2563eb;
  --gold: #b7791f;
  --red: #b42318;
  --green: #15803d;
  --shadow: 0 18px 48px rgba(23, 34, 48, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 1080px;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100vw - 48px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: 30px;
  line-height: 1.2;
}

.sync-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
}

.sync-dot.ready {
  background: var(--green);
}

.sync-dot.error {
  background: var(--red);
}

.toolbar {
  display: grid;
  grid-template-columns: 190px 220px repeat(4, minmax(120px, 1fr)) minmax(260px, 1.5fr);
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.toolbar label,
.month-switch,
.view-switch {
  min-height: 66px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.toolbar label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

select,
input {
  width: 100%;
  height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 0 9px;
  outline: none;
}

select:focus,
input:focus {
  border-color: var(--accent);
  background: #fff;
}

.month-switch {
  display: grid;
  grid-template-columns: 34px 1fr 34px;
  align-items: center;
  gap: 8px;
}

.month-switch button {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  cursor: pointer;
  font-size: 22px;
  line-height: 1;
}

.month-switch strong {
  text-align: center;
  font-size: 16px;
}

.view-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: center;
  gap: 6px;
}

.view-switch button {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  cursor: pointer;
}

.view-switch button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

.calendar-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface);
}

.year-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.year-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.year-card {
  min-height: 220px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.year-card:nth-child(4n) {
  border-right: none;
}

.year-card:nth-last-child(-n + 4) {
  border-bottom: none;
}

.year-month-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f4f7fb;
}

.year-month-header strong {
  font-size: 16px;
}

.year-month-header span {
  color: var(--muted);
  font-size: 12px;
}

.year-month-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.year-empty {
  padding: 18px 4px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.year-event {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 6px 8px;
  width: 100%;
  padding: 8px;
  border: 1px solid #c9d8ea;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f8fbff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.year-event.done {
  border-left-color: var(--green);
}

.year-event.pending {
  border-left-color: var(--gold);
}

.year-event span {
  grid-row: span 2;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.year-event strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.35;
}

.year-event em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

.analysis-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.analysis-grid {
  padding: 14px;
}

.analysis-overview {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.analysis-metric {
  min-height: 78px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analysis-metric span {
  color: var(--muted);
  font-size: 12px;
}

.analysis-metric strong {
  display: block;
  margin-top: 8px;
  font-size: 24px;
  line-height: 1;
}

.analysis-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.analysis-card {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.analysis-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.analysis-card-head h3 {
  margin: 0;
  font-size: 16px;
}

.analysis-card-head span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bar-list {
  display: grid;
  gap: 12px;
}

.bar-label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  margin-bottom: 6px;
  font-size: 13px;
}

.bar-label span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-label strong {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.bar-track {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.bar-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), #42a5a1);
}

.all-events-panel {
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background: #f4f7fb;
}

.panel-actions,
.detail-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.panel-heading h2 {
  margin: 0;
  font-size: 17px;
}

.panel-heading span {
  color: var(--muted);
  font-size: 13px;
}

.all-events-list {
  display: grid;
}

.event-row {
  display: grid;
  grid-template-columns: 112px 1fr 170px;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 68px;
  padding: 12px 16px;
  border: none;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.event-row:hover {
  background: #f8fbff;
}

.event-row:last-child {
  border-bottom: none;
}

.row-date {
  color: var(--accent-strong);
  font-weight: 700;
}

.row-main strong,
.row-main span {
  display: block;
}

.row-main strong {
  margin-bottom: 5px;
  line-height: 1.35;
}

.row-main span {
  color: var(--muted);
  font-size: 12px;
}

.row-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.empty-inline {
  padding: 22px 16px;
  color: var(--muted);
}

.weekday-row,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekday-row {
  background: #e8eef6;
  border-bottom: 1px solid var(--line);
}

.weekday-row span {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.day-cell {
  min-height: 142px;
  padding: 10px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: #fff;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell.outside {
  background: #f7f9fc;
  color: #9aa7b7;
}

.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  min-height: 20px;
}

.day-number {
  font-weight: 700;
}

.count-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
}

.event-button {
  display: block;
  width: 100%;
  margin: 6px 0 0;
  padding: 8px;
  border: 1px solid #c9d8ea;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f8fbff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.event-button.done {
  border-left-color: var(--green);
}

.event-button.pending {
  border-left-color: var(--gold);
}

.event-title {
  display: block;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.event-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 21px;
  padding: 2px 7px;
  border-radius: 999px;
  background: #e9f5f3;
  color: var(--accent-strong);
  font-size: 12px;
}

.drawer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  visibility: hidden;
  z-index: 10;
}

.drawer.open {
  pointer-events: auto;
  visibility: visible;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  background: rgba(20, 29, 40, 0.42);
}

.drawer-card {
  position: absolute;
  top: 0;
  right: 0;
  width: min(720px, 100vw);
  height: 100%;
  overflow: auto;
  padding: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.close-button {
  position: sticky;
  top: 0;
  float: right;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

.detail-head {
  padding-right: 48px;
  margin-bottom: 20px;
}

.detail-head h2 {
  margin: 8px 0 12px;
  font-size: 24px;
  line-height: 1.35;
}

.detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.info-box,
.file-section,
.table-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.info-box {
  padding: 12px;
}

.info-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 12px;
}

.info-box strong,
.info-box p {
  margin: 0;
  line-height: 1.55;
}

.section-title {
  margin: 22px 0 10px;
  font-size: 16px;
}

.file-section {
  overflow: hidden;
}

.file-group {
  border-top: 1px solid var(--line);
}

.file-group:first-child {
  border-top: none;
}

.file-group h4 {
  margin: 0;
  padding: 10px 12px;
  background: #f4f7fb;
  font-size: 13px;
}

.file-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.file-tools span {
  color: var(--muted);
  font-size: 12px;
}

.file-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
}

.file-name {
  overflow: hidden;
  color: var(--blue);
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-link span {
  color: var(--muted);
  font-size: 12px;
}

.file-action,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
}

button.file-action {
  cursor: pointer;
}

.danger-link {
  border-color: #f1b8b8;
  background: #fff5f5;
  color: #b42318;
}

.upload-box {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.upload-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.upload-row input {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fbff;
}

.primary-button {
  height: 38px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.danger-button {
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid #f1b8b8;
  border-radius: 6px;
  background: #fff5f5;
  color: #b42318;
  cursor: pointer;
  font-weight: 700;
}

.event-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.form-field {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.form-field span {
  color: var(--muted);
  font-size: 12px;
}

.form-field textarea {
  width: 100%;
  min-height: 84px;
  resize: vertical;
  border: 1px solid transparent;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--text);
  padding: 8px 9px;
  outline: none;
}

.form-field textarea:focus {
  border-color: var(--accent);
  background: #fff;
}

.form-actions {
  grid-column: 1 / -1;
  padding-top: 4px;
}

.form-actions span {
  color: var(--muted);
  font-size: 12px;
}

.upload-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.cloud-file-list {
  margin-bottom: 12px;
}

.table-section {
  overflow: auto;
  margin-bottom: 12px;
}

.table-section h4 {
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: #f4f7fb;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

td {
  max-width: 220px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.empty-state {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  color: var(--muted);
}

.empty-state h2 {
  margin: 0 0 8px;
  color: var(--text);
}

@media (max-width: 1180px) {
  body {
    min-width: 0;
  }

  .app-shell {
    width: calc(100vw - 24px);
  }

  .toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .summary-strip {
    grid-template-columns: repeat(2, 1fr);
  }

  .analysis-overview {
    grid-template-columns: repeat(2, 1fr);
  }

  .analysis-layout {
    grid-template-columns: 1fr;
  }

  .event-row {
    grid-template-columns: 1fr;
  }

  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .event-form {
    grid-template-columns: 1fr;
  }

  .year-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .year-card:nth-child(4n) {
    border-right: 1px solid var(--line);
  }

  .year-card:nth-child(2n) {
    border-right: none;
  }

  .year-card:nth-last-child(-n + 4) {
    border-bottom: 1px solid var(--line);
  }

  .year-card:nth-last-child(-n + 2) {
    border-bottom: none;
  }

  .row-tags {
    justify-content: flex-start;
  }

  .day-cell {
    min-height: 120px;
    padding: 8px;
  }
}

@media (max-width: 760px) {
  body {
    background: #f7f9fc;
  }

  .app-shell {
    width: 100%;
    padding: 14px 10px 28px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
  }

  .eyebrow {
    margin-bottom: 4px;
    font-size: 11px;
  }

  h1 {
    font-size: 22px;
  }

  .sync-panel {
    width: 100%;
    justify-content: flex-start;
    min-height: 34px;
    padding: 8px 10px;
  }

  .toolbar {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toolbar label,
  .month-switch,
  .view-switch {
    min-height: 0;
    padding: 8px;
  }

  .month-switch {
    grid-template-columns: 40px 1fr 40px;
  }

  .month-switch button {
    width: 40px;
    height: 38px;
  }

  .month-switch strong {
    font-size: 17px;
  }

  .view-switch {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .view-switch button {
    min-width: 0;
    height: 38px;
    padding: 0 6px;
    font-size: 13px;
  }

  select,
  input {
    height: 38px;
  }

  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric {
    min-height: 68px;
    padding: 11px;
  }

  .metric strong {
    font-size: 22px;
  }

  .weekday-row {
    display: none;
  }

  .calendar-grid {
    grid-template-columns: 1fr;
  }

  .day-cell {
    min-height: 0;
    padding: 10px;
    border-right: none;
  }

  .day-cell.outside {
    display: none;
  }

  .day-cell.empty {
    display: none;
  }

  .day-header {
    margin-bottom: 6px;
  }

  .event-button {
    padding: 10px;
  }

  .event-title {
    white-space: normal;
  }

  .year-grid {
    grid-template-columns: 1fr;
  }

  .year-card,
  .year-card:nth-child(2n),
  .year-card:nth-child(4n) {
    border-right: none;
  }

  .year-card:nth-last-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .analysis-grid {
    padding: 10px;
  }

  .analysis-overview,
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .analysis-metric {
    min-height: 68px;
    padding: 11px;
  }

  .analysis-metric strong {
    font-size: 22px;
  }

  .analysis-card {
    padding: 10px;
  }

  .bar-label {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .bar-label span {
    white-space: normal;
  }

  .panel-heading {
    gap: 10px;
    padding: 12px;
  }

  .panel-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .panel-actions .secondary-button {
    width: 100%;
    min-height: 36px;
    padding: 0 8px;
  }

  .event-row {
    gap: 8px;
    min-height: 0;
    padding: 12px;
  }

  .row-date {
    font-size: 14px;
  }

  .row-main strong {
    font-size: 15px;
  }

  .row-tags {
    gap: 6px;
  }

  .drawer-card {
    width: 100vw;
    padding: 18px 14px 24px;
  }

  .close-button {
    width: 34px;
    height: 34px;
  }

  .detail-head h2 {
    padding-right: 42px;
    font-size: 22px;
  }

  .detail-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .file-tools,
  .upload-row {
    grid-template-columns: 1fr;
  }

  .file-tools {
    display: grid;
  }

  .file-link {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }

  .file-link > span {
    grid-column: 1 / -1;
    order: 3;
  }

  .file-action {
    min-height: 30px;
  }

  .event-form {
    grid-template-columns: 1fr;
  }

  .form-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .form-actions .primary-button,
  .form-actions .secondary-button {
    width: 100%;
  }
}

@media (max-width: 430px) {
  .app-shell {
    padding-inline: 8px;
  }

  .summary-strip,
  .analysis-overview {
    grid-template-columns: 1fr;
  }

  .panel-actions {
    grid-template-columns: 1fr;
  }

  .view-switch button {
    font-size: 12px;
  }

  .tag {
    max-width: 100%;
  }
}
