:root {
  --glucose-bg: #f2f7f4;
  --glucose-surface: #ffffff;
  --glucose-surface-soft: #fbfdfc;
  --glucose-primary: #008561;
  --glucose-primary-dark: #00694c;
  --glucose-primary-soft: #e6f5ee;
  --glucose-text: #10241c;
  --glucose-muted: #46665a;
  --glucose-border: #d6e4dc;
  --glucose-line: #e1ebe5;
  --glucose-normal: #137333;
  --glucose-high: #c5221f;
  --glucose-low: #1d6fc4;
  --glucose-warning-bg: #fff4d6;
  --glucose-warning-text: #7a4f00;
  --glucose-radius: 16px;
}

#glucose-log-app,
.glucose-log-gate {
  --glucose-bg: #f2f7f4;
  --glucose-surface: #ffffff;
  --glucose-surface-soft: #fbfdfc;
  --glucose-primary: #008561;
  --glucose-primary-dark: #00694c;
  --glucose-primary-soft: #e6f5ee;
  --glucose-text: #10241c;
  --glucose-muted: #46665a;
  --glucose-border: #d6e4dc;
  --glucose-line: #e1ebe5;
  --glucose-normal: #137333;
  --glucose-high: #c5221f;
  --glucose-low: #1d6fc4;
  --glucose-warning-bg: #fff4d6;
  --glucose-warning-text: #7a4f00;
  --glucose-radius: 16px;
}

#glucose-log-app,
.glucose-log-gate {
  box-sizing: border-box;
  color: var(--glucose-text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  letter-spacing: 0;
  line-height: 1.5;
}

#glucose-log-app *,
#glucose-log-app *::before,
#glucose-log-app *::after,
.glucose-log-gate *,
.glucose-log-gate *::before,
.glucose-log-gate *::after {
  box-sizing: border-box;
}

#glucose-log-app button,
#glucose-log-app input,
#glucose-log-app table,
.glucose-log-gate button,
.glucose-log-gate a {
  font: inherit;
}

#glucose-log-app button,
.glucose-log-gate button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#glucose-log-app [hidden],
.glucose-log-gate [hidden] {
  display: none !important;
}

#glucose-log-app :focus-visible,
.glucose-log-gate :focus-visible {
  outline: 3px solid var(--glucose-primary-dark);
  outline-offset: 2px;
}

#glucose-log-app {
  background: var(--glucose-bg);
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

.glucose-topbar {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 20px 0 16px;
}

.glucose-topbar-title {
  min-width: 0;
}

.glucose-topbar h1 {
  color: #0b2a1d;
  font-size: 28px;
  line-height: 1.25;
  margin: 0;
}

.glucose-date-line {
  color: var(--glucose-muted);
  font-size: 18px;
  margin: 0 0 2px;
}

.glucose-btn {
  align-items: center;
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  font-weight: 700;
  gap: 8px;
  justify-content: center;
  min-height: 56px;
  padding: 0 18px;
  text-decoration: none;
  transition: background 0.2s, box-shadow 0.2s, transform 0.1s;
}

.glucose-btn:active {
  transform: translateY(1px);
}

.glucose-btn-primary {
  background: var(--glucose-primary);
  box-shadow: 0 6px 14px rgba(0, 133, 97, 0.18);
  color: #ffffff;
}

.glucose-btn-primary:hover {
  background: var(--glucose-primary-dark);
  color: #ffffff;
}

.glucose-btn-ghost {
  background: var(--glucose-primary-soft);
  border: 2px solid #bfe0d2;
  color: var(--glucose-primary-dark);
}

.glucose-btn svg {
  flex: 0 0 auto;
  height: 24px;
  width: 24px;
}

.glucose-btn-stat {
  flex: 0 0 auto;
  font-size: 18px;
}

.glucose-summary-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 16px;
}

.glucose-summary-card {
  background: var(--glucose-surface);
  border: 1px solid var(--glucose-line);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(15, 50, 35, 0.05);
  padding: 14px 8px;
  text-align: center;
}

.glucose-summary-label {
  color: var(--glucose-muted);
  font-size: 16px;
  font-weight: 700;
}

.glucose-summary-value {
  align-items: baseline;
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 6px;
}

.glucose-summary-value strong {
  color: #0b2a1d;
  font-size: 30px;
  line-height: 1.1;
}

.glucose-summary-unit {
  color: var(--glucose-muted);
  font-size: 14px;
}

.glucose-summary-sub {
  color: var(--glucose-muted);
  font-size: 15px;
  margin-top: 4px;
}

.glucose-panel {
  background: var(--glucose-surface);
  border: 1px solid var(--glucose-line);
  border-radius: var(--glucose-radius);
  box-shadow: 0 4px 12px rgba(15, 50, 35, 0.06);
  margin-bottom: 16px;
  padding: 18px;
}

.glucose-panel-head {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-bottom: 14px;
}

.glucose-panel-head h2 {
  color: #0b2a1d;
  font-size: 22px;
  margin: 0;
}

.glucose-count-badge,
.glucose-editing-badge {
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  padding: 7px 12px;
  white-space: nowrap;
}

.glucose-count-badge {
  background: var(--glucose-primary-soft);
  color: var(--glucose-primary-dark);
}

.glucose-editing-badge {
  background: var(--glucose-warning-bg);
  color: var(--glucose-warning-text);
}

.glucose-field {
  display: block;
  margin-bottom: 16px;
}

.glucose-field > span,
.glucose-field legend {
  color: #173c2d;
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.glucose-field {
  border: 0;
  margin: 0 0 16px;
  padding: 0;
}

.glucose-input-with-unit {
  position: relative;
}

#glucose-log-app input[type="number"],
#glucose-log-app input[type="text"] {
  background: var(--glucose-surface-soft);
  border: 2px solid var(--glucose-border);
  border-radius: 10px;
  color: var(--glucose-text);
  font-size: 22px;
  min-height: 60px;
  padding: 0 14px;
  width: 100%;
}

#glucose-log-app input:focus {
  border-color: var(--glucose-primary);
  outline: none;
}

.glucose-input-with-unit input {
  padding-right: 74px;
}

.glucose-input-with-unit span {
  color: var(--glucose-muted);
  font-size: 16px;
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
}

.glucose-period-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(3, 1fr);
}

.glucose-chip {
  align-items: center;
  background: var(--glucose-surface-soft);
  border: 2px solid var(--glucose-border);
  border-radius: 10px;
  color: #173c2d;
  display: flex;
  font-size: 18px;
  font-weight: 700;
  gap: 6px;
  justify-content: center;
  min-height: 56px;
  padding: 4px 6px;
}

.glucose-chip.glucose-active {
  background: var(--glucose-primary);
  border-color: var(--glucose-primary);
  color: #ffffff;
}

.glucose-form-error {
  background: #fde8e8;
  border: 1px solid #f5b8b8;
  border-radius: 10px;
  color: #93000a;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 14px;
  padding: 12px 14px;
}

.glucose-form-actions {
  display: flex;
  gap: 10px;
}

.glucose-btn-save {
  flex: 1;
  font-size: 20px;
  min-height: 64px;
}

.glucose-record-list {
  display: flex;
  flex-direction: column;
}

.glucose-record-row {
  align-items: center;
  border-bottom: 1px solid #edf3ef;
  display: flex;
  gap: 10px;
  padding: 14px 0;
}

.glucose-record-row:last-child {
  border-bottom: 0;
}

.glucose-record-main {
  align-items: center;
  display: flex;
  flex: 1 1 auto;
  gap: 10px;
  min-width: 0;
}

.glucose-record-icon {
  align-items: center;
  background: var(--glucose-primary-soft);
  border-radius: 50%;
  color: var(--glucose-primary);
  display: flex;
  flex: 0 0 auto;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.glucose-record-icon svg {
  height: 22px;
  width: 22px;
}

.glucose-record-text {
  min-width: 0;
}

.glucose-record-period {
  color: var(--glucose-text);
  font-size: 20px;
  font-weight: 700;
}

.glucose-record-meta {
  color: var(--glucose-muted);
  font-size: 16px;
  margin-top: 2px;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glucose-record-side {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
  gap: 8px;
}

.glucose-record-value {
  color: #0b2a1d;
  font-size: 26px;
  line-height: 1;
}

.glucose-record-unit {
  color: var(--glucose-muted);
  font-size: 14px;
}

.glucose-status {
  border-radius: 999px;
  font-size: 16px;
  font-weight: 700;
  padding: 6px 10px;
  white-space: nowrap;
}

.glucose-status.glucose-normal {
  background: #e6f4ea;
  color: var(--glucose-normal);
}

.glucose-status.glucose-high {
  background: #fde8e8;
  color: var(--glucose-high);
}

.glucose-status.glucose-low {
  background: #e7f1fd;
  color: var(--glucose-low);
}

.glucose-icon-btn {
  align-items: center;
  background: #ffffff;
  border: 1px solid var(--glucose-line);
  border-radius: 10px;
  color: var(--glucose-primary-dark);
  display: inline-flex;
  height: 48px;
  justify-content: center;
  width: 48px;
}

.glucose-icon-btn.glucose-danger {
  color: var(--glucose-high);
}

.glucose-icon-btn svg {
  height: 22px;
  width: 22px;
}

.glucose-empty-state {
  color: var(--glucose-muted);
  font-size: 20px;
  padding: 32px 12px;
  text-align: center;
}

.glucose-app-footer {
  align-items: center;
  color: var(--glucose-muted);
  display: flex;
  font-size: 16px;
  gap: 12px;
  justify-content: center;
  padding: 10px 0 20px;
}

.glucose-link-btn {
  background: none;
  border: 0;
  color: var(--glucose-primary);
  font-size: 16px;
  font-weight: 700;
  padding: 8px;
  text-decoration: underline;
}

.glucose-overlay {
  background: var(--glucose-bg);
  bottom: 0;
  left: 0;
  overflow-y: auto;
  position: fixed;
  right: 0;
  top: 0;
  transform: translateY(100%);
  transition: transform 0.24s ease;
  z-index: 99990;
}

.glucose-overlay.glucose-open {
  transform: translateY(0);
}

.glucose-overlay-inner {
  display: flex;
  flex-direction: column;
  margin: 0 auto;
  max-width: 640px;
  min-height: 100%;
}

.glucose-stats-topbar {
  align-items: center;
  background: rgba(242, 247, 244, 0.95);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
  padding: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(10px);
}

.glucose-stats-topbar h2 {
  color: #0b2a1d;
  font-size: 24px;
  margin: 0;
  text-align: center;
}

.glucose-btn-close {
  justify-self: start;
}

.glucose-stats-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 0 16px 36px;
}

.glucose-segmented {
  background: #e3eee8;
  border-radius: 12px;
  display: grid;
  gap: 6px;
  grid-template-columns: 1fr 1fr;
  padding: 6px;
}

.glucose-segmented button {
  background: transparent;
  border: 0;
  border-radius: 10px;
  color: var(--glucose-muted);
  font-size: 20px;
  font-weight: 700;
  min-height: 56px;
}

.glucose-segmented button.glucose-active {
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(15, 50, 35, 0.1);
  color: var(--glucose-primary);
}

.glucose-filter-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: none;
}

.glucose-filter-scroll::-webkit-scrollbar {
  display: none;
}

.glucose-filter-scroll button {
  background: #ffffff;
  border: 2px solid var(--glucose-border);
  border-radius: 999px;
  color: #173c2d;
  flex: 0 0 auto;
  font-size: 17px;
  font-weight: 700;
  min-height: 48px;
  padding: 0 16px;
}

.glucose-filter-scroll button.glucose-active {
  background: var(--glucose-primary);
  border-color: var(--glucose-primary);
  color: #ffffff;
}

.glucose-stats-summary .glucose-summary-card {
  padding: 12px 6px;
}

.glucose-stats-summary .glucose-summary-value strong {
  font-size: 26px;
}

.glucose-chart-section {
  background: var(--glucose-surface);
  border: 1px solid var(--glucose-line);
  border-radius: var(--glucose-radius);
  box-shadow: 0 4px 12px rgba(15, 50, 35, 0.06);
  padding: 16px;
}

.glucose-section-head {
  align-items: center;
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.glucose-section-head h3 {
  color: #0b2a1d;
  font-size: 20px;
  margin: 0;
}

.glucose-section-head svg {
  color: var(--glucose-primary);
  height: 24px;
  width: 24px;
}

.glucose-range-note {
  color: var(--glucose-muted);
  font-size: 16px;
  margin: 0 0 0 auto;
}

.glucose-chart-wrap {
  height: 280px;
  position: relative;
}

.glucose-chart-wrap canvas {
  display: block;
  height: 100%;
  width: 100%;
}

.glucose-chart-empty {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  bottom: 0;
  color: var(--glucose-muted);
  display: flex;
  font-size: 20px;
  justify-content: center;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.glucose-chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 10px;
}

.glucose-chart-legend span {
  align-items: center;
  color: var(--glucose-muted);
  display: inline-flex;
  font-size: 16px;
  font-weight: 700;
  gap: 6px;
}

.glucose-legend-dot {
  border-radius: 50%;
  display: inline-block;
  height: 14px;
  width: 14px;
}

.glucose-legend-normal {
  background: var(--glucose-normal);
}

.glucose-legend-high {
  background: var(--glucose-high);
}

.glucose-legend-low {
  background: var(--glucose-low);
}

.glucose-day-picker {
  align-items: center;
  display: grid;
  gap: 8px;
  grid-template-columns: auto 1fr auto;
  margin-bottom: 12px;
}

.glucose-day-picker button {
  background: #ffffff;
  border: 2px solid var(--glucose-border);
  border-radius: 10px;
  color: var(--glucose-primary-dark);
  font-size: 17px;
  font-weight: 700;
  min-height: 52px;
  padding: 0 12px;
}

.glucose-day-picker strong {
  color: #0b2a1d;
  font-size: 20px;
  text-align: center;
}

.glucose-compliance-layout {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: 180px 1fr;
}

.glucose-donut-wrap {
  height: 180px;
  position: relative;
  width: 180px;
}

.glucose-donut-wrap svg {
  height: 100%;
  width: 100%;
}

.glucose-donut-center {
  align-items: center;
  bottom: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.glucose-donut-center strong {
  color: #0b2a1d;
  font-size: 36px;
  line-height: 1;
}

.glucose-donut-center span {
  color: var(--glucose-muted);
  font-size: 16px;
  margin-top: 6px;
}

.glucose-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.glucose-legend-item {
  align-items: center;
  border-bottom: 1px solid #edf3ef;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  padding-bottom: 8px;
}

.glucose-legend-item:last-child {
  border-bottom: 0;
}

.glucose-legend-label {
  align-items: center;
  display: flex;
  font-size: 18px;
  font-weight: 700;
  gap: 8px;
}

.glucose-legend-range {
  color: var(--glucose-muted);
  font-size: 14px;
  font-weight: 400;
}

.glucose-legend-count {
  color: var(--glucose-muted);
  font-size: 16px;
}

.glucose-legend-pct {
  font-size: 20px;
  font-weight: 800;
  white-space: nowrap;
}

.glucose-table-section {
  overflow: hidden;
}

.glucose-table-head-row {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-bottom: 10px;
}

.glucose-table-head-row .glucose-section-head {
  margin-bottom: 0;
}

.glucose-table-head-row .glucose-range-note {
  margin-left: auto;
}

.glucose-table-scroll {
  background: var(--glucose-surface);
  border: 1px solid var(--glucose-line);
  border-radius: 10px;
  max-height: 440px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.glucose-data-table {
  border-collapse: separate;
  border-spacing: 0;
  min-width: 620px;
  width: 100%;
}

.glucose-data-table th,
.glucose-data-table td {
  border-bottom: 1px solid #edf3ef;
  font-size: 17px;
  padding: 12px 10px;
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

.glucose-data-table th {
  background: #eef6f1;
  color: #173c2d;
  font-size: 17px;
  font-weight: 700;
  position: sticky;
  top: 0;
  z-index: 1;
}

.glucose-data-table tbody tr:last-child td {
  border-bottom: 0;
}

.glucose-data-table .glucose-value-cell {
  color: #0b2a1d;
  font-size: 20px;
  font-weight: 800;
}

.glucose-data-table .glucose-note-cell {
  color: var(--glucose-muted);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glucose-data-table .glucose-status {
  display: inline-block;
  font-size: 15px;
  padding: 4px 9px;
}

.glucose-table-empty-row td {
  color: var(--glucose-muted);
  font-size: 18px;
  padding: 28px 12px;
  text-align: center;
  white-space: normal;
}

.glucose-log-gate {
  align-items: center;
  background: var(--glucose-bg);
  display: flex;
  justify-content: center;
  margin: 0 auto;
  max-width: 640px;
  min-height: 70vh;
  padding: 24px 16px;
}

.glucose-log-gate-card {
  background: var(--glucose-surface);
  border: 1px solid var(--glucose-line);
  border-radius: var(--glucose-radius);
  box-shadow: 0 8px 24px rgba(15, 50, 35, 0.08);
  max-width: 420px;
  padding: 36px 28px;
  text-align: center;
  width: 100%;
}

.glucose-log-gate-title {
  color: #0b2a1d;
  font-size: 30px;
  font-weight: 800;
  margin: 0 0 10px;
}

.glucose-log-gate-text {
  color: var(--glucose-muted);
  font-size: 18px;
  margin: 0 0 24px;
}

.glucose-login-button {
  font-size: 20px;
  min-height: 60px;
  width: 100%;
}

@media (max-width: 480px) {
  #glucose-log-app {
    padding: 0 12px 20px;
  }

  .glucose-topbar h1 {
    font-size: 26px;
  }

  .glucose-date-line {
    font-size: 17px;
  }

  .glucose-btn-stat {
    font-size: 17px;
    padding: 0 12px;
  }

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

  .glucose-record-value {
    font-size: 24px;
  }

  .glucose-record-unit {
    display: none;
  }

  .glucose-record-meta {
    max-width: 120px;
  }

  .glucose-status {
    font-size: 15px;
    padding: 5px 8px;
  }

  .glucose-compliance-layout {
    grid-template-columns: 1fr;
    justify-items: center;
  }

  .glucose-legend {
    width: 100%;
  }

  .glucose-day-picker button {
    font-size: 15px;
    padding: 0 8px;
  }

  .glucose-day-picker strong {
    font-size: 18px;
  }
}

body {
  background: #f2f7f4;
  margin: 0;
}

.glucose-login-body {
  align-items: center;
  background: #f2f7f4;
  display: flex;
  justify-content: center;
  min-height: 100vh;
  padding: 24px 16px;
}

.glucose-login-card {
  background: #ffffff;
  border: 1px solid #e1ebe5;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15, 50, 35, 0.08);
  max-width: 420px;
  padding: 36px 28px;
  text-align: center;
  width: 100%;
}

.glucose-login-title {
  color: #0b2a1d;
  font-size: 30px;
  font-weight: 800;
  margin: 0 0 10px;
}

.glucose-login-text {
  color: #46665a;
  font-size: 18px;
  margin: 0 0 24px;
}

.glucose-login-error {
  background: #fde8e8;
  border: 1px solid #f5b8b8;
  border-radius: 10px;
  color: #93000a;
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 16px;
  padding: 12px 14px;
}

.glucose-login-card .glucose-field {
  text-align: left;
}

.glucose-login-card .glucose-field > span {
  color: #173c2d;
  display: block;
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.glucose-pin-input {
  background: #fbfdfc;
  border: 2px solid #d6e4dc;
  border-radius: 10px;
  color: #10241c;
  font-size: 28px;
  height: 68px;
  letter-spacing: 0.6em;
  padding: 0 16px;
  text-align: center;
  width: 100%;
}

.glucose-pin-input:focus {
  border-color: #008561;
  outline: none;
}

.glucose-login-button {
  background: #008561;
  color: #ffffff;
  font-size: 20px;
  margin-top: 18px;
  min-height: 60px;
  width: 100%;
}
