:root {
  --paper: #f6f4ee;
  --ink: #17322f;
  --muted: #62716e;
  --line: #dcded7;
  --card: rgba(255, 255, 252, 0.94);
  --teal: #0a7a6b;
  --teal-dark: #075f55;
  --teal-soft: #d9eee8;
  --blue: #416b89;
  --blue-soft: #e2edf3;
  --coral: #c96a54;
  --coral-soft: #f7e5de;
  --gold-soft: #f6ecd9;
  --shadow: 0 18px 45px rgba(39, 58, 53, 0.08);
  --base-font: 17px;
}

:root[data-font-scale="normal"] { --base-font: 16px; }
:root[data-font-scale="large"] { --base-font: 17px; }
:root[data-font-scale="larger"] { --base-font: 19px; }

* { box-sizing: border-box; }

html {
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font-size: var(--base-font);
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 5% 8%, rgba(10, 122, 107, 0.08), transparent 27rem),
    linear-gradient(135deg, #f9f7f2 0%, var(--paper) 50%, #f1eee6 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font: inherit; }
button, a, input, textarea, summary { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid #f0a63d;
  outline-offset: 3px;
}

.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 1.25rem;
  place-items: center;
}

.login-card {
  width: min(480px, 100%);
  padding: clamp(1.5rem, 5vw, 2.4rem);
  border: 1px solid rgba(23, 50, 47, 0.12);
  border-radius: 26px;
  background: var(--card);
  box-shadow: 0 28px 70px rgba(39, 58, 53, 0.13);
}

.login-brand, .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--ink);
  text-decoration: none;
}

.login-brand { margin-bottom: 2.5rem; }
.login-brand > span:last-child,
.brand > span:last-child { display: flex; align-items: baseline; gap: 0.35rem; }
.login-brand strong, .brand strong { font-size: 1.2rem; font-weight: 760; }
.login-brand small, .brand small { color: var(--muted); font-size: 1.05rem; }

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 14px 14px 14px 4px;
  background: var(--teal);
  box-shadow: 0 8px 20px rgba(10, 122, 107, 0.2);
  color: white;
  font-size: 1.35rem;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 0.55rem;
  color: var(--teal);
  font-size: 0.72rem;
  font-weight: 780;
  letter-spacing: 0.13em;
}

h1, h2, p { text-wrap: pretty; }
h1, h2 { letter-spacing: -0.04em; }
h1 { margin: 0; font-size: clamp(2.2rem, 4vw, 4rem); font-weight: 690; line-height: 1.02; }
h2 { margin: 0; font-size: 1.25rem; font-weight: 680; }

.login-card h1 { font-size: clamp(2.2rem, 8vw, 3.2rem); }
.login-copy { margin: 0.85rem 0 1.5rem; color: var(--muted); line-height: 1.6; }
.error-box {
  margin-bottom: 1rem;
  padding: 0.9rem 1rem;
  border: 1px solid #e2b8ac;
  border-radius: 13px;
  background: var(--coral-soft);
  color: #7a3c2e;
  font-size: 0.86rem;
  line-height: 1.5;
}

.login-form { display: grid; gap: 1rem; }
.login-form label { display: grid; gap: 0.45rem; }
.login-form label span { color: var(--muted); font-size: 0.78rem; font-weight: 680; }
.login-form input {
  min-height: 58px;
  width: 100%;
  padding: 0.8rem 0.95rem;
  border: 1px solid #cbd4cf;
  border-radius: 13px;
  background: #fcfdfb;
  color: var(--ink);
}
.login-form input:focus { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(10, 122, 107, 0.1); outline: none; }
.login-form button {
  min-height: 62px;
  margin-top: 0.35rem;
  border: 0;
  border-radius: 14px;
  background: var(--teal);
  color: white;
  cursor: pointer;
  font-weight: 720;
}
.login-form button:hover { background: var(--teal-dark); }
.login-security { display: flex; gap: 0.5rem; margin: 1.2rem 0 0; color: var(--muted); font-size: 0.75rem; line-height: 1.5; }
.login-security span { color: var(--teal); font-weight: 800; }

.app-shell { position: relative; min-height: 100vh; overflow: hidden; }
.ambient { position: fixed; z-index: -1; width: 24rem; height: 24rem; border-radius: 50%; pointer-events: none; }
.ambient-one { top: -13rem; right: -7rem; background: rgba(196, 222, 211, 0.34); }
.ambient-two { bottom: -17rem; left: 25%; background: rgba(238, 211, 192, 0.3); }

.topbar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 82px;
  padding: 0 4vw;
  border-bottom: 1px solid rgba(23, 50, 47, 0.1);
  background: rgba(249, 247, 242, 0.86);
  backdrop-filter: blur(18px);
}

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }
.font-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.74);
}
.font-controls > span { padding: 0 0.5rem; color: var(--muted); font-size: 0.72rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; }
.font-controls button {
  min-width: 44px;
  height: 42px;
  padding: 0 0.55rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 700;
}
.font-controls button.active { background: var(--ink); color: white; }
.logout-form button {
  min-height: 48px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255,255,255,.75);
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 680;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(230px, 270px) minmax(0, 1fr);
  width: min(1480px, 100%);
  min-height: calc(100vh - 82px);
  margin: 0 auto;
}
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  min-height: calc(100vh - 82px);
  padding: 2.2rem 1.35rem 1.8rem;
  border-right: 1px solid rgba(23, 50, 47, 0.1);
}
.profile-block { display: flex; align-items: center; gap: 0.8rem; padding: 0 0.6rem; }
.profile-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 50px;
  height: 50px;
  place-items: center;
  border: 1px solid #c9d7d2;
  border-radius: 50%;
  background: #e6efeb;
  color: var(--teal-dark);
  font-size: 0.85rem;
  font-weight: 750;
}
.profile-block > div:last-child { min-width: 0; }
.profile-block span, .profile-block strong { display: block; }
.profile-block span { margin-bottom: 0.18rem; color: var(--muted); font-size: 0.7rem; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; }
.profile-block strong { overflow: hidden; font-size: 0.96rem; text-overflow: ellipsis; white-space: nowrap; }

.main-nav { display: grid; gap: 0.4rem; }
.main-nav button {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  width: 100%;
  min-height: 56px;
  padding: 0.75rem 0.9rem;
  border: 0;
  border-radius: 14px;
  background: transparent;
  cursor: pointer;
  color: #53635f;
  text-align: left;
  font-size: 0.92rem;
  font-weight: 610;
}
.main-nav button > span { display: grid; width: 34px; height: 34px; place-items: center; border-radius: 10px; background: rgba(23, 50, 47, 0.05); font-size: 1.1rem; }
.main-nav button:hover, .main-nav button.active { background: #e3ede8; color: var(--teal-dark); }
.main-nav button.active > span { background: var(--teal); color: white; }

.privacy-note { display: flex; gap: 0.65rem; margin-top: auto; padding: 1rem; border: 1px solid #d2dfda; border-radius: 16px; background: rgba(231, 241, 237, 0.72); }
.privacy-mark { display: grid; flex: 0 0 auto; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--teal); color: white; font-size: 0.78rem; font-weight: 800; }
.privacy-note strong { display: block; margin: 0.2rem 0 0.35rem; font-size: 0.83rem; }
.privacy-note p { margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.5; }

.content-panel { min-width: 0; padding: 3.5rem clamp(1.4rem, 4vw, 4.5rem) 2rem; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 2rem; }
.hero-copy { max-width: 42rem; margin: 0.85rem 0 0; color: var(--muted); font-size: 1rem; line-height: 1.6; }
.primary-action, .save-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  min-height: 58px;
  padding: 0.85rem 1.25rem;
  border: 0;
  border-radius: 16px;
  background: var(--teal);
  box-shadow: 0 12px 26px rgba(10, 122, 107, 0.19);
  color: white;
  cursor: pointer;
  font-weight: 720;
}
.primary-action:hover, .save-button:hover { background: var(--teal-dark); transform: translateY(-1px); }
.primary-action > span, .save-button > span:first-child { font-size: 1.25rem; line-height: 1; }

.period-tabs { display: inline-flex; gap: 0.3rem; margin-top: 2.2rem; padding: 0.32rem; border: 1px solid var(--line); border-radius: 14px; background: rgba(255, 255, 255, 0.66); }
.period-tabs button { min-height: 44px; padding: 0.55rem 1rem; border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--muted); font-size: 0.82rem; font-weight: 650; }
.period-tabs button.active { background: var(--ink); color: white; }

.sync-banner, .notice-card { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 1.2rem; padding: 0.85rem 1rem; border: 1px solid #e5d2aa; border-radius: 14px; background: var(--gold-soft); color: #6a4a18; font-size: 0.84rem; }
.sync-banner button, .notice-card button { min-height: 42px; margin-left: auto; padding: 0.5rem 0.85rem; border: 1px solid currentColor; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 680; }
.notice-card { margin: 1.2rem 0 0; border-color: #e2b8ac; background: var(--coral-soft); color: #7a3c2e; }

.stat-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 1.5rem; }
.stat-card, .panel-card { border: 1px solid rgba(23, 50, 47, 0.1); background: var(--card); box-shadow: var(--shadow); }
.stat-card { position: relative; min-height: 178px; overflow: hidden; padding: 1.25rem; border-radius: 20px; }
.stat-card::after { position: absolute; right: -2rem; bottom: -3rem; width: 8rem; height: 8rem; border-radius: 50%; content: ""; opacity: 0.5; }
.stat-card.accent-teal::after { background: var(--teal-soft); }
.stat-card.accent-blue::after { background: var(--blue-soft); }
.stat-card.accent-coral::after { background: var(--coral-soft); }
.stat-heading { position: relative; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 1rem; color: var(--muted); font-size: 0.8rem; font-weight: 650; }
.stat-code { display: grid; min-width: 34px; height: 34px; padding: 0 0.3rem; place-items: center; border-radius: 10px; background: #edf1ee; color: var(--ink); font-size: 0.72rem; font-weight: 780; }
.stat-value { position: relative; z-index: 1; display: flex; align-items: baseline; gap: 0.45rem; margin-top: 1.1rem; }
.stat-value strong { font-size: clamp(2.1rem, 3vw, 3rem); font-weight: 690; letter-spacing: -0.06em; }
.stat-value span { color: var(--muted); font-size: 0.75rem; font-weight: 620; }
.stat-card p { position: relative; z-index: 1; margin: 0.25rem 0 0; color: var(--muted); font-size: 0.7rem; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, 0.8fr); gap: 1rem; margin-top: 1rem; }
.panel-card { border-radius: 22px; }
.chart-card, .target-card, .measurements-card { padding: 1.35rem; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.panel-heading .eyebrow { margin-bottom: 0.35rem; }
.target-pill, .record-count { padding: 0.45rem 0.65rem; border-radius: 999px; background: #edf1ee; color: var(--muted); font-size: 0.68rem; font-weight: 650; white-space: nowrap; }

.bar-chart { position: relative; height: 250px; margin-top: 1.5rem; padding: 0 0 0.4rem 2.2rem; }
.chart-guide { position: absolute; right: 0; left: 2.2rem; border-top: 1px dashed #d7ddd9; }
.chart-guide span { position: absolute; top: -0.62rem; left: -2.2rem; color: #8a9692; font-size: 0.61rem; }
.guide-high { top: 18%; }
.guide-mid { top: 48%; }
.chart-columns { position: relative; z-index: 1; display: grid; grid-template-columns: repeat(7, minmax(24px, 1fr)); gap: clamp(0.3rem, 1vw, 0.75rem); height: 100%; }
.chart-column { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.bar-slot { display: flex; align-items: flex-end; justify-content: center; width: 100%; height: calc(100% - 1.5rem); }
.chart-bar { position: relative; width: min(32px, 78%); min-height: 18px; border-radius: 10px 10px 4px 4px; background: linear-gradient(180deg, #32a18f, var(--teal)); box-shadow: 0 8px 15px rgba(10, 122, 107, 0.13); }
.chart-bar.above { background: linear-gradient(180deg, #dc8a74, var(--coral)); box-shadow: 0 8px 15px rgba(201, 106, 84, 0.13); }
.chart-bar span { position: absolute; top: -1.25rem; left: 50%; color: var(--ink); font-size: 0.62rem; font-weight: 720; transform: translateX(-50%); }
.chart-bar.height-10 { height: 10%; }
.chart-bar.height-15 { height: 15%; }
.chart-bar.height-20 { height: 20%; }
.chart-bar.height-25 { height: 25%; }
.chart-bar.height-30 { height: 30%; }
.chart-bar.height-35 { height: 35%; }
.chart-bar.height-40 { height: 40%; }
.chart-bar.height-45 { height: 45%; }
.chart-bar.height-50 { height: 50%; }
.chart-bar.height-55 { height: 55%; }
.chart-bar.height-60 { height: 60%; }
.chart-bar.height-65 { height: 65%; }
.chart-bar.height-70 { height: 70%; }
.chart-bar.height-75 { height: 75%; }
.chart-bar.height-80 { height: 80%; }
.chart-bar.height-85 { height: 85%; }
.chart-bar.height-90 { height: 90%; }
.chart-bar.height-95 { height: 95%; }
.chart-bar.height-100 { height: 100%; }
.chart-column small { margin-top: 0.55rem; color: var(--muted); font-size: 0.65rem; text-transform: capitalize; }

.empty-chart { display: grid; min-height: 250px; margin-top: 1rem; place-items: center; align-content: center; border: 1px dashed #cfd7d3; border-radius: 16px; background: rgba(247, 248, 244, 0.7); text-align: center; }
.empty-mark { display: grid; width: 48px; height: 48px; margin-bottom: 0.75rem; place-items: center; border-radius: 15px; background: var(--teal-soft); color: var(--teal); font-size: 1.5rem; }
.empty-chart strong { font-size: 0.92rem; }
.empty-chart p { max-width: 19rem; margin: 0.4rem 1rem 0; color: var(--muted); font-size: 0.76rem; line-height: 1.5; }

.target-list { display: grid; gap: 1rem; margin-top: 1.5rem; }
.target-list > div { display: flex; align-items: center; gap: 0.8rem; padding: 0.8rem; border: 1px solid #e2e5df; border-radius: 15px; background: #fafbf8; }
.target-icon { display: grid; flex: 0 0 auto; min-width: 42px; height: 42px; padding: 0 0.4rem; place-items: center; border-radius: 12px; font-size: 0.75rem; font-weight: 780; }
.target-icon.teal { background: var(--teal-soft); color: var(--teal-dark); }
.target-icon.blue { background: var(--blue-soft); color: var(--blue); }
.target-list small, .target-list strong { display: block; }
.target-list small { margin-bottom: 0.22rem; color: var(--muted); font-size: 0.68rem; }
.target-list strong { font-size: 0.9rem; }
.target-list em { color: var(--muted); font-size: 0.63rem; font-style: normal; font-weight: 580; }
.target-footnote { margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid #e6e8e2; color: var(--muted); font-size: 0.7rem; line-height: 1.55; }

.measurements-card { margin-top: 1rem; }
.measurement-list { display: grid; margin-top: 1rem; }
.measurement-row { display: grid; grid-template-columns: 46px minmax(160px, 1fr) auto minmax(145px, auto); align-items: center; gap: 0.85rem; min-height: 74px; padding: 0.75rem 0; border-top: 1px solid #e6e8e2; }
.measurement-code { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; background: #e7eeeb; color: var(--ink); font-size: 0.7rem; font-weight: 780; }
.measurement-code.within { background: var(--teal-soft); color: var(--teal-dark); }
.measurement-code.above, .measurement-code.below { background: var(--coral-soft); color: #8e4535; }
.measurement-meta strong, .measurement-meta span { display: block; }
.measurement-meta strong { margin-bottom: 0.25rem; font-size: 0.85rem; }
.measurement-meta span { color: var(--muted); font-size: 0.7rem; }
.measurement-result { display: flex; align-items: baseline; gap: 0.3rem; min-width: 92px; }
.measurement-result strong { font-size: 1.4rem; font-weight: 690; letter-spacing: -0.04em; }
.measurement-result span { color: var(--muted); font-size: 0.63rem; }
.status-label { justify-self: end; padding: 0.45rem 0.65rem; border-radius: 999px; background: #edf1ee; color: var(--muted); font-size: 0.67rem; font-weight: 680; white-space: nowrap; }
.status-label.within { background: var(--teal-soft); color: var(--teal-dark); }
.status-label.above, .status-label.below { background: var(--coral-soft); color: #8e4535; }

.empty-list { display: grid; min-height: 180px; place-items: center; align-content: center; text-align: center; }
.empty-list strong { font-size: 0.98rem; }
.empty-list p { margin: 0.35rem 0 0.9rem; color: var(--muted); font-size: 0.78rem; }
.empty-list button, .back-button { min-height: 48px; padding: 0.65rem 1rem; border: 1px solid #bfcac5; border-radius: 12px; background: #f9faf7; cursor: pointer; font-size: 0.8rem; font-weight: 680; }

.record-page { width: min(840px, 100%); margin: 0 auto; }
.back-button { display: inline-flex; align-items: center; gap: 0.5rem; margin-bottom: 2rem; }
.record-heading { text-align: center; }
.record-heading h1 { font-size: clamp(2.2rem, 6vw, 3.8rem); }
.record-heading > p:last-child { max-width: 35rem; margin: 0.9rem auto 0; color: var(--muted); line-height: 1.6; }
.record-form { display: grid; gap: 1rem; margin-top: 2rem; }
.record-form fieldset, .note-details { margin: 0; padding: clamp(1.1rem, 3vw, 1.6rem); border: 1px solid rgba(23, 50, 47, 0.11); border-radius: 22px; background: var(--card); box-shadow: var(--shadow); }
.record-form legend { padding: 0 0.45rem; font-size: 1.03rem; font-weight: 690; }
.type-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.7rem; margin-top: 0.5rem; }
.type-grid button { display: grid; grid-template-columns: 44px minmax(0, 1fr) 28px; align-items: center; gap: 0.75rem; min-height: 72px; padding: 0.7rem; border: 2px solid #dce1dc; border-radius: 16px; background: #fbfcf9; cursor: pointer; text-align: left; font-size: 0.83rem; font-weight: 650; line-height: 1.35; }
.type-grid button:hover { border-color: #aac5bd; }
.type-grid button.selected { border-color: var(--teal); background: #edf6f2; box-shadow: 0 0 0 3px rgba(10, 122, 107, 0.08); }
.type-code { display: grid; min-width: 44px; height: 44px; padding: 0 0.3rem; place-items: center; border-radius: 12px; background: #e8eeeb; color: var(--ink); font-size: 0.73rem; font-weight: 800; }
.selected .type-code { background: var(--teal); color: white; }
.selection-mark { display: grid; width: 26px; height: 26px; place-items: center; border: 2px solid #cfd7d3; border-radius: 50%; color: transparent; font-size: 0.7rem; }
.selected .selection-mark { border-color: var(--teal); background: var(--teal); color: white; }

.value-input { display: flex; align-items: baseline; justify-content: center; gap: 0.75rem; min-height: 130px; margin-top: 0.5rem; padding: 1rem; border: 2px solid #cdd7d2; border-radius: 18px; background: #fbfcfa; }
.value-input:focus-within { border-color: var(--teal); box-shadow: 0 0 0 4px rgba(10, 122, 107, 0.1); }
.value-input input { width: 4.2ch; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: clamp(3.3rem, 10vw, 5.2rem); font-weight: 660; letter-spacing: -0.07em; text-align: right; }
.value-input input::placeholder { color: #b9c3be; letter-spacing: 0.04em; }
.value-input strong { color: var(--muted); font-size: 0.92rem; }
.input-help { margin: 0.75rem 0 0; color: var(--muted); font-size: 0.76rem; text-align: center; }
.note-details summary { min-height: 48px; cursor: pointer; font-size: 0.9rem; font-weight: 680; }
.note-details summary span { color: var(--muted); font-weight: 500; }
.note-details label { display: grid; gap: 0.55rem; margin-top: 1rem; color: var(--muted); font-size: 0.76rem; font-weight: 650; }
.note-details textarea { width: 100%; resize: vertical; padding: 0.9rem; border: 1px solid #cfd7d3; border-radius: 13px; background: #fbfcfa; color: var(--ink); line-height: 1.5; }
.save-button { width: 100%; min-height: 70px; margin-top: 0.25rem; font-size: 1.05rem; }
.save-button:disabled { cursor: not-allowed; opacity: 0.48; transform: none; }
.offline-assurance { display: flex; align-items: center; justify-content: center; gap: 0.55rem; margin: 0.25rem auto 0; color: var(--muted); font-size: 0.73rem; line-height: 1.45; text-align: center; }
.offline-assurance span { color: var(--teal); font-size: 1rem; }

.device-page { width: min(980px, 100%); margin: 0 auto; }
.device-grid { display: grid; grid-template-columns: minmax(0, 1.18fr) minmax(280px, 0.82fr); gap: 1rem; margin-top: 2rem; }
.device-status-card, .device-help-card { padding: clamp(1.2rem, 3vw, 1.8rem); }
.device-status-heading { display: flex; align-items: center; gap: 0.9rem; }
.device-status-heading h2, .device-help-card h2 { margin-top: 0.15rem; font-size: 1.35rem; }
.device-status-dot { width: 18px; height: 18px; flex: 0 0 18px; border: 4px solid #d8dedb; border-radius: 50%; background: #8a9894; box-shadow: 0 0 0 5px rgba(138, 152, 148, 0.1); }
.device-status-dot.busy { border-color: #d8e8e3; background: var(--teal); box-shadow: 0 0 0 5px rgba(10, 122, 107, 0.11); animation: device-pulse 1.4s ease-in-out infinite; }
.device-status-dot.connected { border-color: #d5ebe4; background: #13856f; box-shadow: 0 0 0 5px rgba(19, 133, 111, 0.11); }
.device-status-dot.error { border-color: #f3d8d0; background: var(--coral); box-shadow: 0 0 0 5px rgba(201, 106, 84, 0.11); }
@keyframes device-pulse { 50% { transform: scale(0.78); opacity: 0.72; } }
.device-status-detail { min-height: 3.2rem; margin: 1.1rem 0 0; color: var(--muted); font-size: 0.83rem; line-height: 1.55; }
.device-notice { margin-top: 1rem; padding: 1rem; border: 1px solid #e6d4aa; border-radius: 14px; background: #fff8e8; }
.device-notice strong { display: block; font-size: 0.86rem; }
.device-notice p { margin: 0.35rem 0 0; color: #78633b; font-size: 0.75rem; line-height: 1.5; }
.device-actions { display: grid; gap: 0.65rem; margin-top: 1.25rem; }
.device-actions button { min-height: 58px; padding: 0.75rem 1rem; border: 1px solid #c5d0cb; border-radius: 14px; background: #f8faf7; cursor: pointer; color: var(--ink); font-size: 0.86rem; font-weight: 700; }
.device-actions button.device-primary { border-color: var(--teal); background: var(--teal); color: white; }
.device-actions button.device-danger { border-color: #ebc8bf; color: #934f3e; }
.device-actions button:disabled { cursor: not-allowed; opacity: 0.44; }
.device-readiness { display: grid; gap: 0.8rem; margin-top: 1.35rem; padding-top: 1.2rem; border-top: 1px solid rgba(23, 50, 47, 0.1); }
.device-readiness > div { display: grid; grid-template-columns: 32px minmax(0, 1fr); gap: 0.7rem; align-items: start; }
.device-readiness > div > span:first-child { display: grid; width: 30px; height: 30px; place-items: center; border-radius: 9px; background: var(--teal-soft); color: var(--teal); font-size: 0.7rem; font-weight: 800; }
.device-readiness strong, .device-readiness small { display: block; }
.device-readiness strong { font-size: 0.78rem; }
.device-readiness small { margin-top: 0.18rem; color: var(--muted); font-size: 0.67rem; line-height: 1.45; }
.device-help-card ol { display: grid; gap: 0.9rem; margin: 1.2rem 0 0; padding: 0; list-style: none; }
.device-help-card li { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 0.75rem; align-items: start; }
.device-help-card li > span { display: grid; width: 36px; height: 36px; place-items: center; border-radius: 11px; background: #e7efeb; color: var(--teal-dark); font-size: 0.78rem; font-weight: 780; }
.device-help-card li p { margin: 0; color: var(--muted); font-size: 0.74rem; line-height: 1.55; }
.device-help-note { margin: 1.3rem 0 0; padding-top: 1rem; border-top: 1px solid rgba(23, 50, 47, 0.1); color: var(--muted); font-size: 0.69rem; line-height: 1.55; }

footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid rgba(23, 50, 47, 0.1); color: var(--muted); font-size: 0.65rem; }
.toast { position: fixed; z-index: 50; right: 1.25rem; bottom: 1.25rem; max-width: min(400px, calc(100vw - 2rem)); padding: 0.95rem 1.1rem; border-radius: 14px; background: var(--ink); box-shadow: 0 18px 40px rgba(23, 50, 47, 0.25); color: white; font-size: 0.83rem; font-weight: 620; opacity: 0; pointer-events: none; transform: translateY(18px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.mobile-nav { display: none; }

@media (max-width: 1020px) {
  .workspace { grid-template-columns: 210px minmax(0, 1fr); }
  .side-panel { padding-inline: 0.85rem; }
  .content-panel { padding-inline: 1.5rem; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-card:last-child { grid-column: 1 / -1; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .device-grid { grid-template-columns: 1fr; }
  .target-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .app-shell { padding-bottom: 86px; }
  .topbar { min-height: 70px; padding: 0.65rem 1rem; }
  .brand-mark { width: 42px; height: 42px; }
  .brand > span:last-child { display: none; }
  .font-controls > span, .logout-form { display: none; }
  .font-controls button { min-width: 42px; height: 40px; }
  .workspace { display: block; min-height: calc(100vh - 70px); }
  .side-panel { display: none; }
  .content-panel { padding: 2rem 1rem 1rem; }
  .hero-row { display: grid; gap: 1.25rem; }
  h1 { font-size: clamp(2.2rem, 12vw, 3.4rem); }
  .primary-action { width: 100%; min-height: 62px; }
  .period-tabs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; }
  .period-tabs button { padding-inline: 0.35rem; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .stat-card { min-height: 160px; }
  .stat-card:last-child { grid-column: 1 / -1; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .target-list { grid-template-columns: 1fr; }
  .chart-card { padding-inline: 0.85rem; }
  .target-pill { display: none; }
  .bar-chart { height: 220px; padding-left: 1.85rem; }
  .chart-guide { left: 1.85rem; }
  .chart-guide span { left: -1.85rem; }
  .measurement-row { grid-template-columns: 42px minmax(0, 1fr) auto; }
  .status-label { grid-column: 2 / -1; justify-self: start; margin-top: -0.55rem; }
  .type-grid { grid-template-columns: 1fr; }
  .type-grid button { min-height: 76px; }
  .record-page { max-width: 620px; }
  .device-page { max-width: 620px; }
  .record-form fieldset, .note-details { border-radius: 18px; }
  footer { display: grid; justify-content: center; text-align: center; }
  .toast { right: 1rem; bottom: 96px; left: 1rem; }
  .mobile-nav { position: fixed; z-index: 40; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.45rem; min-height: 76px; padding: 0.6rem max(0.75rem, env(safe-area-inset-right)) max(0.6rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left)); border-top: 1px solid rgba(23, 50, 47, 0.12); background: rgba(250, 249, 245, 0.94); box-shadow: 0 -12px 30px rgba(23, 50, 47, 0.08); backdrop-filter: blur(18px); }
  .mobile-nav button { display: flex; align-items: center; justify-content: center; gap: 0.4rem; min-height: 56px; border: 0; border-radius: 14px; background: transparent; cursor: pointer; color: var(--muted); font-size: 0.76rem; font-weight: 680; }
  .mobile-nav button.active { background: #e5efeb; color: var(--teal-dark); }
  .mobile-nav button.mobile-add { background: transparent; color: var(--muted); }
  .mobile-nav button.mobile-add.active { background: var(--teal); color: white; }
  .mobile-nav button > span { font-size: 1.15rem; }
}

@media (max-width: 430px) {
  .stat-grid { grid-template-columns: 1fr; }
  .stat-card:last-child { grid-column: auto; }
  .stat-card { min-height: 150px; }
  .sync-banner { flex-wrap: wrap; }
  .sync-banner button { width: 100%; margin-left: 0; }
  .measurement-row { gap: 0.65rem; }
  .measurement-result strong { font-size: 1.25rem; }
  .record-count { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}

@media print {
  .topbar, .side-panel, .mobile-nav, .primary-action, .period-tabs, footer { display: none !important; }
  .workspace { display: block; }
  .content-panel { padding: 0; }
  .stat-card, .panel-card { box-shadow: none; }
}
