:root {
  color-scheme: light;
  --ink: #1f303b;
  --muted: #60717c;
  --blue: #1f72aa;
  --blue-deep: #145a89;
  --sky: #e8f3fa;
  --line: #dce8ed;
  --paper: #ffffff;
  --background: #f5f9fb;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--background); color: var(--ink); }
button, input, textarea { font: inherit; }
a { color: var(--blue-deep); }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid #76b6dc; outline-offset: 3px; }

.site-shell { max-width: 1500px; margin: 0 auto; padding: 0 24px; }
.site-header {
  min-height: 76px; display: flex; align-items: center; justify-content: space-between;
  gap: 24px; border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-size: 19px; font-weight: 750; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; width: 31px; height: 31px; border-radius: 10px; background: var(--blue); color: white; font-size: 29px; line-height: 1; font-weight: 400; }
.top-nav { display: flex; align-items: center; gap: 20px; }
.top-nav a, .nav-logout { display: inline-flex; min-height: 44px; align-items: center; border: 0; background: transparent; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 650; cursor: pointer; white-space: nowrap; }
.top-nav a[aria-current="page"] { color: var(--blue-deep); }
.top-nav a:hover, .nav-logout:hover { color: var(--blue-deep); }
.top-nav form { margin: 0; }

main { padding: 30px 0 48px; }
.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.page-heading h1 { font-size: clamp(30px, 3vw, 38px); line-height: 1.15; letter-spacing: -.03em; margin: 4px 0 0; }
.eyebrow { text-transform: uppercase; font-size: 12px; letter-spacing: .10em; font-weight: 750; color: var(--blue); margin: 0; }
.latest-pill { display: flex; align-items: center; gap: 13px; padding: 10px 16px; border-radius: 14px; background: var(--sky); color: var(--blue-deep); }
.latest-pill span { font-size: 13px; font-weight: 650; }
.latest-pill strong { font-size: 25px; font-variant-numeric: tabular-nums; }
.dashboard-grid { display: grid; grid-template-columns: minmax(290px, 340px) minmax(0, 1fr); gap: 18px; align-items: start; }
.card { background: var(--paper); border: 1px solid var(--line); border-radius: 20px; padding: 24px; box-shadow: 0 8px 26px rgba(40, 82, 102, .045); }
.card h1, .card h2 { margin: 0; letter-spacing: -.02em; }
.card h2 { font-size: 21px; }
.section-heading { margin-bottom: 20px; }
.section-heading p, .subtle { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
.stacked-form { display: grid; gap: 9px; }
.stacked-form label { margin-top: 8px; color: var(--ink); font-size: 15px; font-weight: 700; }
.stacked-form input, .stacked-form textarea { width: 100%; min-height: 50px; padding: 12px 14px; border: 1.5px solid #cbdde4; border-radius: 11px; background: #fff; color: var(--ink); outline: none; box-shadow: none; }
.stacked-form textarea { resize: vertical; min-height: 82px; }
.stacked-form input:focus, .stacked-form textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31, 114, 170, .12); }
.stacked-form input::placeholder, .stacked-form textarea::placeholder { color: #8c9aa2; }
.required { color: #bc4e4e; }
.unit, .optional { color: var(--muted); font-size: 12px; font-weight: 500; margin-left: 3px; }
.primary-button { min-height: 52px; border: none; border-radius: 11px; margin-top: 14px; padding: 12px 18px; background: var(--blue); color: white; font-size: 16px; font-weight: 750; cursor: pointer; box-shadow: 0 5px 13px rgba(31, 114, 170, .18); }
.primary-button:hover { background: var(--blue-deep); }
.primary-button:active { transform: translateY(1px); }

.chart-card { overflow: hidden; }
.chart-topline { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.chart-topline h2 { margin-top: 4px; }
.segmented { display: inline-flex; flex-shrink: 0; gap: 2px; padding: 4px; border-radius: 12px; background: #eef4f7; }
.segmented a { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 13px; border-radius: 9px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 700; }
.segmented a[aria-current="page"] { color: var(--blue-deep); background: white; box-shadow: 0 1px 4px rgba(26, 75, 99, .10); }
.range-callout { display: flex; align-items: center; gap: 7px; margin: 0 0 5px; color: var(--muted); font-size: 13px; line-height: 1.4; }
.range-callout strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.range-swatch { width: 15px; height: 15px; flex: 0 0 15px; border: 1px solid #a9d0b4; border-radius: 4px; background: #e6f3e9; }
.chart-picture { display: block; width: 100%; min-height: 220px; }
.chart-picture img { display: block; width: 100%; height: auto; }
.chart-enlarge { display: block; text-decoration: none; }
.chart-note { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 6px 0 16px; }
.export-links { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--line); }
.export-links a { display: inline-flex; align-items: center; min-height: 40px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 12px; font-weight: 700; text-decoration: none; background: white; }
.export-links a:hover { border-color: #a8cfdf; background: #f4fafc; }
.range-settings { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.range-settings summary { width: fit-content; color: var(--blue-deep); font-weight: 700; cursor: pointer; }
.range-settings p { margin: 10px 0; line-height: 1.55; }
.range-form { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; align-items: end; gap: 10px; }
.range-form label { display: grid; gap: 5px; color: var(--ink); font-weight: 700; }
.range-form input { width: 100%; min-height: 42px; padding: 8px 10px; border: 1.5px solid #cbdde4; border-radius: 9px; color: var(--ink); font: inherit; font-variant-numeric: tabular-nums; }
.range-form button { min-height: 42px; padding: 8px 13px; border: none; border-radius: 9px; background: var(--blue); color: white; font: inherit; font-weight: 700; cursor: pointer; }
.range-form button:hover { background: var(--blue-deep); }

.history-card { margin-top: 18px; }
.record-list, .event-list { list-style: none; margin: 0; padding: 0; }
.record-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.record-main { display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap; }
.record-main time { color: var(--muted); font-size: 14px; font-variant-numeric: tabular-nums; }
.record-main strong { min-width: 85px; color: var(--blue-deep); font-size: 18px; font-variant-numeric: tabular-nums; }
.record-main span { color: var(--ink); font-size: 14px; }
.record-note { grid-column: 1; color: var(--muted); margin: 0; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.record-edit { grid-column: 2; grid-row: 1 / span 2; display: inline-flex; align-items: center; justify-content: center; min-width: 52px; min-height: 40px; border-radius: 8px; text-decoration: none; font-size: 13px; font-weight: 700; }
.record-edit:hover { background: var(--sky); }
.empty-state { color: var(--muted); margin: 0; padding: 20px 0 10px; }

.narrow-page { max-width: 680px; margin: 0 auto; }
.narrow-page .card + .card { margin-top: 18px; }
.back-link { display: inline-flex; align-items: center; min-height: 38px; margin: 0 0 14px; text-decoration: none; font-size: 14px; font-weight: 650; }
.narrow-page .card h1 { font-size: 27px; }
.narrow-page .stacked-form { margin-top: 18px; }
.compact-heading { margin-bottom: 18px; }
.event-list li { border-top: 1px solid var(--line); padding: 17px 0; }
.event-list strong { display: block; margin-top: 4px; font-size: 16px; }
.event-list p { color: var(--muted); margin: 5px 0 0; font-size: 13px; line-height: 1.5; }
.event-date { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.danger-zone, .remove-event { margin-top: 24px; color: #8e3f3f; font-size: 13px; }
.danger-zone summary, .remove-event summary { cursor: pointer; }
.danger-zone p { color: var(--muted); line-height: 1.5; }
.danger-button { min-height: 42px; padding: 8px 12px; border: 1px solid #dca2a2; border-radius: 9px; background: #fff7f7; color: #983e3e; cursor: pointer; }
.delete-entry { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); }
.delete-link { display: inline-flex; align-items: center; min-height: 44px; padding: 9px 12px; border: 1px solid #e5baba; border-radius: 9px; color: #983e3e; background: #fff9f8; font-size: 14px; font-weight: 700; text-decoration: none; }
.delete-link:hover { background: #fff0ee; }
.delete-summary { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; margin: 22px 0 6px; padding: 16px; border: 1px solid var(--line); border-radius: 11px; background: #f7fafb; font-variant-numeric: tabular-nums; }
.delete-summary time { color: var(--muted); }
.delete-summary strong { color: var(--ink); font-size: 20px; }
.delete-confirm-form { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 24px; }
.delete-confirm-form .danger-button { min-height: 48px; padding: 11px 16px; border-color: #983e3e; background: #a44747; color: #fff; font-size: 15px; font-weight: 700; }
.delete-confirm-form .danger-button:hover { background: #8f3636; }
.delete-confirm-form a { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; font-weight: 700; text-decoration: none; }
.flash { margin-top: 18px; padding: 13px 16px; border-radius: 11px; font-size: 14px; line-height: 1.5; }
.flash.success { background: #e8f6ee; color: #176338; }
.flash.error { background: #fff0ee; color: #9d3e34; }
.login-wrap { min-height: calc(100vh - 160px); display: grid; place-items: center; }
.login-card { width: min(100%, 430px); padding: 34px; }
.login-card h1 { margin-top: 6px; font-size: 27px; }
.login-card .stacked-form { margin-top: 23px; }
.site-footer { border-top: 1px solid var(--line); padding: 18px 0 32px; color: var(--muted); font-size: 12px; line-height: 1.5; }

@media (max-width: 1100px) {
  .dashboard-grid { grid-template-columns: minmax(270px, 310px) minmax(0, 1fr); }
  .card { padding: 20px; }
}
@media (max-width: 800px) {
  .dashboard-grid { grid-template-columns: minmax(0, 1fr); }
  .entry-card { max-width: none; }
  .page-heading { align-items: center; }
}
@media (max-width: 700px) {
  .site-shell { padding: 0 16px; }
  .site-header { min-height: 64px; gap: 9px; }
  .brand { font-size: 16px; gap: 7px; }
  .brand-mark { width: 27px; height: 27px; font-size: 25px; }
  .top-nav { gap: 10px; }
  .top-nav a, .nav-logout { font-size: 12px; }
  main { padding-top: 22px; }
  .page-heading { align-items: flex-start; gap: 12px; }
  .page-heading h1 { font-size: 30px; }
  .latest-pill { flex-direction: column; align-items: flex-end; gap: 0; padding: 7px 10px; }
  .latest-pill span { font-size: 10px; }
  .latest-pill strong { font-size: 21px; }
  .card { padding: 18px; border-radius: 16px; }
  .chart-topline { align-items: flex-start; flex-direction: column; }
  .chart-card { padding: 16px 12px 18px; }
  .segmented { width: 100%; }
  .segmented a { flex: 1; }
  .chart-picture { min-height: 160px; }
  .range-form { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .range-form button { grid-column: 1 / -1; }
  .record-main { gap: 3px 12px; }
  .record-main time { width: 100%; }
  .record-main strong { min-width: 84px; }
  .record-row { gap: 4px 6px; }
  .login-wrap { min-height: calc(100vh - 150px); }
  .login-card { padding: 26px 22px; }
}
@media (max-width: 370px) {
  .top-nav { gap: 5px; }
  .top-nav a, .nav-logout { font-size: 11px; }
  .brand { font-size: 14px; }
  .latest-pill span { display: none; }
}
