:root {
  /* 苹果官网精确配色 - 完全复制 */

  /* 苹果精确配色 - 根据截图调整 */
  --apple-text-primary: #000000; /* 主要文字 - 纯黑 */
  --apple-text-secondary: #424245; /* 次要文字 - 深灰 */
  --apple-text-tertiary: #8e8e93; /* 第三级文字 - 中灰 */
  --apple-separator: #d2d2d7; /* 分割线 - 极淡灰 */
  --apple-fill: #f2f2f7; /* 填充色 - 苹果灰6 */
  --apple-background: #f5f5f7; /* 页面背景 - 苹果灰 */
  --apple-card: #ffffff; /* 卡片背景 - 纯白 */

  /* 苹果系统颜色 */
  --apple-blue: #0071e3; /* 苹果标准蓝 */
  --apple-dark: #1d1d1f; /* 苹果深色 - 按钮等 */

  /* 强对比主色与柔和异常色 */
  --main-text: #1d1d1f; /* 苹果深灰黑 */
  --sub-text: #86868b; /* 苹果灰 */
  --danger-text: #d7263d; /* 柔和暗红 */
  --accent-blue: #007aff; /* 苹果蓝，仅用于强调 */

  /* 统一蓝色配色 */
  --data-color-1: #007aff; /* 苹果蓝 - 主色 */
  --data-color-2: #007aff; /* 苹果蓝 - 统一 */
  --data-color-3: #007aff; /* 苹果蓝 - 统一 */
  --data-color-4: #007aff; /* 苹果蓝 - 统一 */
  --data-color-5: #007aff; /* 苹果蓝 - 统一 */
  --data-color-6: #007aff; /* 苹果蓝 - 统一 */
  --data-color-7: #007aff; /* 苹果蓝 - 统一 */
  --data-color-8: #007aff; /* 苹果蓝 - 统一 */

  /* 功能色彩 - 苹果官网风格 */
  --success-color: #86868b; /* 成功 - 中灰 */
  --warning-color: #ff9500; /* 警告 - 苹果橙 */
  --danger-color: #d70015; /* 危险 - 暗红色 */

  /* 苹果级别的微妙阴影 - 无边框 */
  --shadow-card: 0 2px 10px 0 rgba(0, 0, 0, 0.08);
  --shadow-hover: 0 4px 20px 0 rgba(0, 0, 0, 0.12);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display",
    "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: var(--apple-background);
  color: var(--apple-text-primary);
  line-height: 1.47;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Header Styles */
.header {
  margin-bottom: 2rem;
  padding: 1.5rem 0;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
}

.header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--apple-text-primary);
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
  flex: 1;
}

.header .en-text {
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--apple-text-secondary);
  display: block;
  margin-top: 0.5rem;
}

.header .description {
  font-size: 1.25rem;
  font-weight: 400;
  color: var(--apple-text-secondary);
  margin-top: 1rem;
  line-height: 1.4;
  max-width: 600px;
}

/* Overview Cards */
.overview-section {
  margin-bottom: 1.5rem;
}

.section-title {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--apple-text-primary);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 1;
}

.section-title::before {
  content: "";
  width: 3px;
  height: 20px;
  background: var(--apple-dark);
  border-radius: 1.5px;
}




.section-header-with-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: nowrap;
  gap: 0.5rem;
  min-width: 0;
}

.view-all-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(0, 113, 227, 0.08);
  color: var(--apple-blue);
  border: none;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  flex-shrink: 0;
  white-space: nowrap;
}


.view-all-button:hover {
  background: rgba(0, 113, 227, 0.15);
  transform: translateY(-1px);
}

.view-all-icon {
  width: 16px;
  height: 16px;
}

.overview-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.875rem;
  margin-bottom: 1.25rem;
}

/* Show more cards on wider screens */
@media (min-width: 1200px) {
  .overview-cards {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (min-width: 1600px) {
  .overview-cards {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  }
}

.overview-card {
  background: var(--apple-card);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: var(--shadow-card);
  border: none;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

.overview-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(
    90deg,
    var(--primary-color),
    var(--secondary-color)
  );
}

.overview-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.overview-card h3 {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--apple-text-primary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.4rem;
}
.overview-card .value {
  font-size: 2rem;
  font-weight: 400;
  color: var(--main-text);
  margin-bottom: 0.15rem;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
.overview-card .value.danger {
  color: var(--danger-text);
}
.overview-card .label {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--sub-text);
  line-height: 1.2;
}
.overview-card .en-text {
  font-size: 0.75rem;
  color: var(--sub-text);
}

.overview-card .trend {
  position: absolute;
  top: 0.75rem;
  right: 1rem;
  padding: 0.2rem 0.5rem;
  border-radius: 8px;
  font-size: 0.7rem;
  font-weight: 600;
}

.trend.up {
  background: rgba(134, 134, 139, 0.1);
  color: var(--success-color);
}

.trend.down {
  background: rgba(255, 59, 48, 0.1);
  color: var(--danger-color);
}

.trend.stable {
  background: rgba(0, 122, 255, 0.1);
  color: #007aff;
}

/* Charts Grid */
.charts-section {
  margin-bottom: 1.5rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}

.chart-container {
  background: var(--apple-card);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  border: none;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
}

.chart-container:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-1px);
}

.chart-header {
  padding: 0.75rem 1rem;
  background: var(--apple-card);
  border-bottom: 1px solid rgba(210, 210, 215, 0.3);
}

.chart-container h2 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--apple-text-primary);
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.015em;
}

.chart-container h2 .en-text {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--apple-text-secondary);
  margin-top: 0.25rem;
}

.chart-body {
  padding: 1rem;
  height: 220px;
}

.canvas-wrapper {
  position: relative;
  height: 100%;
}

/* Medical Events Timeline */
.events-timeline {
  background: var(--apple-card);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
  border: none;
}

.timeline-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(210, 210, 215, 0.3);
}

.timeline-item:last-child {
  border-bottom: none;
}

.timeline-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--apple-dark);
  flex-shrink: 0;
}

.timeline-content {
  flex: 1;
}

.timeline-date {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--apple-text-primary);
}

.timeline-description {
  font-size: 0.8rem;
  color: var(--apple-text-secondary);
  margin-top: 0.2rem;
}

/* Data Table */
.table-section {
  margin-top: 1.5rem;
}

.table-container {
  background: var(--apple-card);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  border: none;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  min-width: 1100px; /* Reduced from 1200px */
  border-collapse: collapse; /* Changed from separate */
  border-spacing: 0;
  font-size: 0.8rem; /* Reduced from 0.9rem */
  color: var(--main-text);
}

.data-table th,
.data-table td {
  padding: 0.75rem 0.75rem; /* Reduced padding */
  text-align: center;
  white-space: nowrap;
}

.data-table th {
  font-weight: 600;
  font-size: 0.85rem; /* Increased for better readability */
  color: var(--main-text);
  background: var(--apple-fill);
  padding: 0.75rem 0.75rem; /* Reduced padding */
}

.data-table td {
  font-weight: 400;
  font-size: 1rem; /* Increased to match Health Overview readability */
  color: var(--main-text);
}

.data-table tbody tr:hover {
  background: var(--apple-fill);
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table .en-text {
  font-size: 0.9rem;
  color: #6e6e73;
}

.data-table tr {
  height: 2.5rem;
}

.data-table thead tr {
  height: 2.25rem;
}

.indicator-name .en-text {
  font-size: 0.65rem; /* Reduced from 0.7rem */
  color: var(--apple-text-tertiary);
  display: block;
  margin-top: 0.15rem;
}

/* Sticky date column */
.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  background: var(--apple-fill);
  z-index: 10;
  box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
  min-width: 90px; /* Reduced from 100px for more compact date column */
  padding-left: 1rem; /* Slightly more padding for readability */
}

.data-table tbody tr:hover td:first-child {
  background: var(--apple-separator);
}

/* Header Upload Button */
.header-upload-button {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--apple-card);
  color: var(--apple-dark);
  border: 1px solid var(--apple-separator);
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  flex-shrink: 0;
}

.header-upload-button:hover {
  background: var(--apple-dark);
  color: white;
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.upload-icon {
  width: 16px;
  height: 16px;
}

/* Buttons */
.btn {
    background: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger-color);
}

.btn-danger:hover {
    background: #b01e2e;
}

/* Form Elements */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--apple-text-primary);
    margin-bottom: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--apple-separator);
    border-radius: 8px;
    font-size: 1rem;
    font-family: inherit;
    background: var(--apple-card);
    color: var(--apple-text-primary);
    transition: border-color 0.2s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1);
}

/* Login Card */
.login-card {
    max-width: 400px;
    margin: 2rem auto;
    background: var(--apple-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-card);
}

.login-title {
    text-align: center;
    font-size: 2rem;
    font-weight: 700;
    color: var(--apple-text-primary);
    margin-bottom: 2rem;
}

/* Error Page */
.error-card {
    max-width: 500px;
    margin: 2rem auto;
    text-align: center;
    background: var(--apple-card);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: var(--shadow-card);
}

.error-title {
    color: var(--danger-color);
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.error-message {
    color: var(--apple-text-secondary);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  .header h1 {
    font-size: 2rem;
  }




  .section-title {
    font-size: 1.1rem;
    margin-bottom: 1rem;
  }




  .view-all-button {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .charts-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .chart-container {
    min-width: unset;
  }

  .chart-container.mobile-hidden {
    display: none;
  }

  .chart-body {
    height: 300px;
    padding: 1rem;
  }

  .overview-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .overview-card {
    padding: 0.875rem;
  }

  .overview-card h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--apple-text-primary);
  }

  .overview-card .value {
    font-size: 1.8rem;
  }

  .overview-card .label {
    font-size: 0.75rem;
  }

  .overview-card .en-text {
    font-size: 0.7rem;
  }

  .overview-card .trend {
    top: 0.625rem;
    right: 0.875rem;
    padding: 0.15rem 0.4rem;
    font-size: 0.65rem;
  }

  .data-table th,
  .data-table td {
    padding: 0.75rem 1rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .overview-cards {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.625rem;
  }

  .overview-card {
    padding: 0.75rem;
  }

  .overview-card h3 {
    font-size: 0.7rem;
  }

  .overview-card .value {
    font-size: 1.6rem;
  }

  .overview-card .label {
    font-size: 0.7rem;
  }

  .overview-card .en-text {
    font-size: 0.65rem;
  }

  .overview-card .trend {
    top: 0.5rem;
    right: 0.625rem;
    padding: 0.1rem 0.3rem;
    font-size: 0.6rem;
  }

  .chart-body {
    height: 250px;
    padding: 0.5rem;
  }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.danger {
    color: var(--danger-color) !important;
    font-weight: 500;
}

.success {
    color: var(--success-color) !important;
}

.warning {
    color: var(--warning-color) !important;
}

/* Modal Styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2000;
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.modal-content {
  position: relative;
  background: var(--apple-card);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 400px;
  width: 85%;
  box-shadow: var(--shadow-hover);
  animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.modal-close {
  background: none;
  border: none;
  font-size: 32px;
  cursor: pointer;
  color: var(--apple-text-secondary);
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--apple-text-primary);
}

.form-group input[type="file"] {
  width: 100%;
  padding: 12px;
  border: 2px dashed var(--apple-separator);
  border-radius: 8px;
  background: var(--apple-fill);
  font-size: 16px;
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: var(--apple-blue);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.btn-primary:hover {
  background: #0056b3;
}

.progress-bar {
  height: 4px;
  background: var(--apple-fill);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

/* Modal File List Styles */
.file-list {
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: var(--apple-fill);
  border-radius: 8px;
  border: 1px solid var(--apple-separator);
}

.file-list h4 {
  margin: 0 0 0.5rem 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--apple-text-primary);
}

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem;
  background: var(--apple-card);
  border: 1px solid var(--apple-separator);
  border-radius: 6px;
  margin-bottom: 0.4rem;
  font-size: 0.8rem;
}

.file-item:last-child {
  margin-bottom: 0;
}

.file-name {
  font-weight: 500;
  color: var(--apple-text-primary);
}

.file-size {
  color: var(--apple-text-tertiary);
  font-size: 0.8rem;
}

.file-remove {
  background: none;
  border: none;
  color: var(--apple-text-tertiary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 4px;
  font-size: 0.8rem;
}

.file-remove:hover {
  color: var(--danger-color);
  background: rgba(215, 0, 21, 0.1);
}

/* Trends Modal Styles */
.trends-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3000;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.trends-modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.trends-modal-content {
  background: var(--apple-background);
  border-radius: 16px;
  padding: 2rem;
  max-width: 1600px;
  width: 95%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: modalSlideIn 0.3s ease;
}

.trends-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--apple-separator);
}

.trends-modal-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--apple-text-primary);
  margin: 0;
}

.trends-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--apple-text-secondary);
  padding: 0.5rem;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.trends-modal-close:hover {
  background: var(--apple-fill);
  color: var(--apple-text-primary);
}

.trends-modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  gap: 1.25rem;
  padding: 1.25rem;
}

.trends-modal-chart {
  background: var(--apple-card);
  border-radius: 14px;
  padding: 1rem 1.25rem; /* Better balance for spacing */
  box-shadow: var(--shadow-card);
  height: 280px; /* Increased to prevent overlap */
}

.trends-modal-chart .chart-header h2 {
  font-size: 0.9rem;
}

.trends-modal-chart .chart-header h2 .en-text {
  font-size: 0.7rem;
}

.trends-modal-chart .chart-body {
  height: 200px; /* Reduced from overall to account for header */
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.trends-modal-chart .chart-header {
  margin-bottom: 0.75rem;
  text-align: center;
}

.trends-modal-chart .canvas-wrapper {
  width: 100%;
  height: 100%;
}

/* Responsive for tablets */
@media (max-width: 1024px) {
  .trends-modal-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
    padding: 1.5rem;
  }

  .trends-modal-chart {
    height: 280px;
  }
}

/* Responsive for mobile */
@media (max-width: 768px) {
  .trends-modal-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }

  .trends-modal-chart {
    height: 250px;
  }

  .trends-modal-content {
    padding: 1rem;
    width: 98%;
  }
}