:root {
  color: #202321;
  background: #f7f7f4;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f7f7f4; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, summary:focus-visible { outline: 3px solid #d8e970; outline-offset: 3px; }

.login-view { min-height: 100svh; display: grid; place-items: center; padding: 24px; background: #25332c; color: #f7f7f4; }
.login-view[hidden] { display: none; }
.login-form { width: min(100%, 380px); }
.login-form h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.35rem, 11vw, 3.8rem); font-weight: 500; letter-spacing: -.06em; }
.login-form p:not(.status) { margin: 12px 0 30px; color: #c7cec7; }
.login-form label { display: grid; gap: 8px; font-size: .875rem; }
.login-form input { min-height: 48px; padding: 10px 12px; color: inherit; background: transparent; border: 0; border-bottom: 1px solid #839087; border-radius: 0; }
.login-form button { width: 100%; min-height: 50px; margin-top: 28px; color: #202321; background: #d8e970; border: 0; border-radius: 999px; font-weight: 700; }

.topbar { display: flex; justify-content: space-between; align-items: center; max-width: 760px; margin: 0 auto; padding: 20px 20px 14px; font-size: .9rem; }
.topbar a { color: inherit; text-decoration: none; }
.brand { font-weight: 700; letter-spacing: -.03em; }
.topbar a:not(.brand) { text-decoration: underline; text-underline-offset: 4px; }
.workspace { width: min(100%, 760px); margin: 0 auto; padding: 0 20px 100px; }
.datebar { display: grid; grid-template-columns: 42px 1fr 42px; align-items: end; gap: 12px; padding: 14px 0 28px; }
.date-step { width: 42px; height: 42px; color: #202321; background: transparent; border: 1px solid #cbd0ca; border-radius: 50%; font-size: 1.35rem; }
.date-field { display: grid; gap: 6px; font-size: .75rem; color: #677068; letter-spacing: .08em; }

label { color: #4e574f; font-size: .875rem; }
input, textarea { width: 100%; color: #202321; background: #fff; border: 1px solid #cbd0ca; border-radius: 8px; }
input { min-height: 48px; padding: 8px 10px; }
textarea { padding: 12px; resize: vertical; }
.record-section { padding: 28px 0; border-top: 1px solid #d7dbd5; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 20px; margin-bottom: 20px; }
.eyebrow { margin: 0 0 5px; color: #677068; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
h2 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(1.65rem, 7vw, 2.25rem); font-weight: 500; letter-spacing: -.05em; }
h1 { margin: 0; font-family: Georgia, "Songti SC", serif; font-size: clamp(2.3rem, 9vw, 3.5rem); font-weight: 500; letter-spacing: -.06em; }
.time-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.time-grid label, .details-grid label, .note-field { display: grid; gap: 7px; }
.sleep-summary { display: block; margin-top: 18px; color: #435b50; font-family: Georgia, "Songti SC", serif; font-size: 1.2rem; }
.toggle-row { display: flex; gap: 12px; flex-wrap: wrap; }
.toggle { display: inline-flex; align-items: center; gap: 9px; padding: 7px 0; color: #202321; }
.toggle input, .quality-options input { position: absolute; width: 1px; min-height: 1px; height: 1px; margin: -1px; padding: 0; border: 0; opacity: 0; pointer-events: none; }
.toggle span { position: relative; width: 42px; height: 24px; background: #cbd0ca; border-radius: 999px; transition: background .16s ease; }
.toggle span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; background: #fff; border-radius: 50%; transition: transform .16s ease; }
.toggle input:checked + span { background: #435b50; }
.toggle input:checked + span::after { transform: translateX(18px); }
.quality-options { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 24px; }
.quality-options span { display: inline-block; padding: 8px 12px; border: 1px solid #cbd0ca; border-radius: 999px; color: #4e574f; transition: background .16s ease, color .16s ease; }
.quality-options input:checked + span { color: #fff; background: #435b50; border-color: #435b50; }
.details-section { padding: 24px 0 4px; border-top: 1px solid #d7dbd5; }
.details-section summary { color: #435b50; cursor: pointer; font-weight: 700; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 12px; padding-top: 20px; }
.savebar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 34px; }
.save-button { min-width: 128px; min-height: 50px; padding: 10px 20px; color: #202321; background: #d8e970; border: 0; border-radius: 999px; font-weight: 750; }
.status { min-height: 1.3em; margin: 0; color: #435b50; font-size: .875rem; }
.status.error { color: #9c3f34; }
.stats-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; padding: 18px 0 12px; }
.stats-heading label { display: grid; gap: 6px; min-width: 100px; color: #677068; font-size: .75rem; letter-spacing: .08em; }
select { min-height: 42px; padding: 6px 8px; color: #202321; background: #fff; border: 1px solid #cbd0ca; border-radius: 8px; }
.table-wrap { overflow-x: auto; border: 1px solid #d7dbd5; border-radius: 8px; }
table { width: 100%; min-width: 560px; border-collapse: collapse; font-size: .83rem; }
th, td { padding: 11px 10px; text-align: right; border-bottom: 1px solid #e1e4df; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead { color: #677068; background: #f1f2ee; font-size: .75rem; }
tbody tr:last-child > * { border-bottom: 0; }
.annual-row { font-weight: 700; background: #f1f2ee; }
.chart { width: 100%; height: 330px; }
.search-field { display: grid; gap: 7px; }
.note-results { padding: 0; list-style: none; }
.note-results li { display: grid; grid-template-columns: 92px 1fr; gap: 12px; padding: 14px 0; border-bottom: 1px solid #e1e4df; font-size: .9rem; }
.note-results time { color: #677068; font-variant-numeric: tabular-nums; }
.note-results .empty { display: block; color: #677068; }

@media (min-width: 640px) {
  .topbar { padding-left: 32px; padding-right: 32px; }
  .workspace { padding-left: 32px; padding-right: 32px; }
  .details-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
