:root {
  color-scheme: dark;
  --bg: #101214;
  --surface: #181d20;
  --surface-2: #242b2e;
  --line: #354047;
  --text: #edf2f7;
  --muted: #9aa7b5;
  --good: #22c55e;
  --warn: #f59e0b;
  --bad: #ef4444;
  --info: #38bdf8;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  overflow-y: auto;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--bg);
  color: var(--text);
  font-family: Segoe UI, Arial, sans-serif;
  touch-action: pan-y;
}

.auth-locked .topbar,
.auth-locked main {
  display: none;
}

.auth-view {
  min-height: 100vh;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 24px;
}

.auth-view.hidden {
  display: none;
}

.auth-panel {
  width: min(520px, 100%);
  display: grid;
  gap: 18px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.field-note {
  min-height: 18px;
  color: var(--muted);
  font-size: 13px;
}

.field-note.available {
  color: #8df0ad;
}

.field-note.unavailable {
  color: #ffaaa8;
}

.password-field {
  position: relative;
  display: block;
}

.password-field input {
  padding-right: 44px;
}

.password-toggle {
  position: absolute;
  right: 6px;
  top: 50%;
  width: 30px;
  min-width: 30px;
  min-height: 30px;
  height: 30px;
  padding: 0;
  transform: translateY(-50%);
  background: transparent;
  border-color: transparent;
  border-radius: 6px;
}

.password-toggle::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 10px;
  width: 14px;
  height: 8px;
  border: 2px solid var(--muted);
  border-radius: 50%;
}

.password-toggle::after {
  content: "";
  position: absolute;
  left: 13px;
  top: 14px;
  width: 4px;
  height: 4px;
  background: var(--muted);
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.password-toggle.is-visible::before {
  border-color: var(--accent);
}

.password-toggle.is-visible::after {
  background: var(--accent);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  background: #0a0d0f;
  border-bottom: 1px solid var(--line);
}

.brand,
nav a {
  color: var(--text);
  text-decoration: none;
}

.brand {
  font-weight: 700;
}

nav {
  display: flex;
  gap: 14px;
}

nav a {
  color: var(--muted);
  padding: 7px 9px;
  border-radius: 6px;
  font-weight: 700;
}

nav a[href="/admin"] {
  display: none;
}

.admin-user nav a[href="/admin"] {
  display: inline-flex;
}

nav a.active,
nav a[aria-current="page"] {
  color: var(--text);
  background: #162026;
  box-shadow: inset 0 0 0 1px var(--line);
}

.privacy-mode nav {
  display: none;
}

.privacy-mode .brand::after {
  content: " Privacy";
  margin-left: 8px;
  color: var(--muted);
  font-weight: 600;
}

main {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
  height: calc(100vh - 58px);
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.home-view main {
  width: min(1500px, calc(100vw - 32px));
}

.section-heading,
.detail-head,
.panel-heading,
.heading-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.section-heading,
.detail-head {
  margin-bottom: 18px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 4px;
}

h2,
h3 {
  margin-bottom: 8px;
}

.heading-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.range-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.dosing-filter-stack {
  display: grid;
  gap: 8px;
  justify-items: end;
}

.filter-row {
  justify-content: flex-end;
}

.day-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.ghost-button.active {
  border-color: #0f766e;
  background: #0f2f2d;
  color: #b7fff6;
}

.warn-action-button {
  border-color: #f59e0b;
  color: #fed7aa;
  background: #3a2607;
}

.attendance-note {
  padding: 24px;
}

.home-notification-strip {
  display: grid;
  gap: 8px;
  margin: 0 0 12px;
}

.home-notification {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 12px;
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.home-notification strong {
  font-size: 14px;
}

.home-notification span {
  color: var(--muted);
  font-size: 13px;
}

.home-notification.request {
  border-color: #38bdf8;
  background: #0c1d26;
}

.home-notification.low {
  border-color: #ef4444;
  background: #2a1111;
}

.home-notification.warning {
  border-color: #f59e0b;
  background: #2b1d08;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.summary-tile,
.profile-card,
.request-card,
.request-panel,
.settings-panel,
.summary-section,
.metric,
.chart-wrap,
.request-queue {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-tile {
  min-height: 84px;
  padding: 14px;
}

.summary-tile-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.summary-tile-link:hover {
  border-color: #9ca3af;
}

.summary-tile-link.active-filter-tile {
  border-color: #38bdf8;
  box-shadow: inset 0 0 0 1px #38bdf8;
}

.summary-tile.ticket-load-low {
  border-color: #16a34a;
  background: #0d2818;
}

.summary-tile.ticket-load-low strong {
  color: #86efac;
}

.summary-tile.ticket-load-medium {
  border-color: #f59e0b;
  background: #2b1d08;
}

.summary-tile.ticket-load-medium strong {
  color: #ffd28a;
}

.summary-tile.ticket-load-high {
  border-color: #dc2626;
  background: #2a1111;
}

.summary-tile.ticket-load-high strong {
  color: #fca5a5;
}

.summary-tile span {
  display: block;
  color: var(--muted);
}

.summary-tile strong {
  display: block;
  margin-top: 8px;
  font-size: 34px;
}

.daily-filter-bar {
  display: grid;
  grid-template-columns: minmax(190px, 260px) minmax(260px, auto);
  gap: 12px;
  align-items: end;
}

.daily-date-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.daily-date-controls input {
  width: 150px;
}

.daily-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(220px, 1fr));
  gap: 14px;
}

.daily-chart-card {
  margin-top: 14px;
  padding: 16px;
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.daily-snapshot-card,
.daily-summary-card {
  min-height: 170px;
  padding: 16px;
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.daily-snapshot-card > span,
.daily-summary-card > span {
  color: var(--muted);
  font-weight: 700;
}

.daily-snapshot-card > strong {
  display: block;
  margin: 8px 0 12px;
  font-size: 46px;
  line-height: 1;
}

.daily-snapshot-grid,
.daily-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 12px;
}

.daily-summary-grid {
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  margin-top: 14px;
}

.daily-snapshot-grid p,
.daily-summary-grid p {
  margin: 0;
  color: var(--muted);
}

.daily-snapshot-grid b,
.daily-summary-grid b {
  display: block;
  margin-top: 2px;
  color: var(--text);
  font-size: 20px;
}

.daily-timeline {
  display: grid;
  gap: 10px;
}

.daily-timeline-item {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 14px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid #64748b;
  border-radius: 8px;
}

.daily-timeline-item.glucose {
  border-left-color: #22c55e;
}

.daily-timeline-item.request {
  border-left-color: #38bdf8;
}

.daily-timeline-item.dosing {
  border-left-color: #f59e0b;
}

.daily-timeline-item time {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}

.daily-timeline-item h3 {
  margin: 0 0 4px;
  font-size: 18px;
}

.daily-timeline-item p {
  margin: 0;
  color: var(--muted);
}

.panel-heading {
  margin-bottom: 12px;
}

.compact-heading {
  margin-bottom: 8px;
}

.panel-heading p {
  margin-bottom: 0;
}

.approval-inbox {
  margin-bottom: 22px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.approval-list {
  display: grid;
  gap: 12px;
}

.alert-list {
  display: grid;
  gap: 12px;
}

.approval-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: #11171a;
  border: 1px solid var(--line);
  border-left: 6px solid var(--muted);
  border-radius: 8px;
}

.approval-card.priority-good {
  border-left-color: var(--good);
}

.approval-card.priority-warn {
  border-left-color: var(--warn);
}

.approval-card.priority-bad {
  border-left-color: var(--bad);
}

.approval-card.conversation-card,
.request-card.conversation-card {
  border-left: 6px solid #38bdf8;
  background: #101820;
}

.conversation-summary {
  display: grid;
  justify-items: end;
  gap: 3px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.conversation-summary strong {
  color: #bae6fd;
  font-size: 20px;
}

.conversation-context strong {
  color: #bae6fd;
}

.alert-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 6px solid var(--good);
  border-radius: 8px;
}

.alert-hero.has-alerts {
  border-left-color: var(--bad);
  background: #201414;
}

.alert-hero h2 {
  margin-bottom: 6px;
  font-size: 32px;
}

.iob-alert-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  background: #201414;
  border: 1px solid #7a2d2d;
  border-left: 6px solid var(--bad);
  border-radius: 8px;
}

.alert-number {
  color: var(--bad);
}

.approval-primary,
.approval-context,
.approval-actions {
  display: flex;
  gap: 12px;
}

.approval-primary {
  align-items: flex-start;
  justify-content: space-between;
}

.approval-primary h3 {
  font-size: 24px;
}

.approval-reading {
  min-width: 92px;
  text-align: right;
}

.request-status-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.collapse-button {
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #1f242b;
  border-color: var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.collapsible-request-body {
  display: grid;
  gap: 14px;
}

.is-collapsed .collapsible-request-body {
  display: none;
}

.is-collapsed.approval-card,
.is-collapsed.request-card {
  gap: 0;
}

.approval-glucose-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 10px;
}

.approval-glucose {
  font-size: 52px;
  line-height: 1;
  font-weight: 800;
}

.trend-arrow {
  color: var(--text);
  font-size: 32px;
  line-height: 1;
  font-weight: 800;
}

.approval-iob,
.approval-metabolic-line {
  margin-top: 5px;
  color: var(--muted);
  font-size: 16px;
  font-weight: 700;
}

.approval-metabolic-line {
  display: grid;
  justify-items: end;
  gap: 4px;
}

.metric-iob strong,
strong.metric-iob,
.card-metrics .metric-iob strong {
  color: #38bdf8;
}

.metric-cob strong,
strong.metric-cob,
.card-metrics .metric-cob strong {
  color: #fbbf24;
}

.metric-source-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  margin-left: 6px;
  padding: 2px 6px;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 6px;
  color: #bae6fd;
  background: rgba(14, 165, 233, 0.12);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  text-transform: uppercase;
}

.approval-context {
  flex-wrap: wrap;
  color: var(--muted);
}

.approval-context span {
  min-width: 130px;
}

.approval-context strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
}

.approval-actions {
  flex-wrap: wrap;
  align-items: center;
}

.approval-actions select,
.approval-actions input {
  flex: 1 1 220px;
  padding: 0 10px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  color: var(--text);
  text-decoration: none;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 6px;
}

.empty-approval {
  min-height: 130px;
  padding: 22px;
  display: grid;
  align-content: center;
  background: #11171a;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.empty-approval p {
  margin-bottom: 0;
}

.dashboard-layout {
  display: block;
  margin-bottom: 22px;
}

.profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 340px));
  gap: 14px;
  justify-content: start;
}

.dashboard-empty-state {
  width: min(100%, 520px);
}

.profile-card {
  position: relative;
  display: block;
  min-height: 168px;
  padding: 14px;
  color: var(--text);
}

.profile-card.has-safety-warning {
  border-color: #f59e0b;
  background: #21190d;
  box-shadow: inset 0 0 0 1px rgba(245, 158, 11, 0.2);
}

.profile-card.is-stale-reading {
  border-color: #f59e0b;
}

.profile-card.is-stale-reading .glucose {
  text-decoration: line-through;
  text-decoration-thickness: 3px;
  text-decoration-color: #f59e0b;
}

.warning-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 8px;
  border: 1px solid #f59e0b;
  border-radius: 999px;
  color: #ffd28a;
  background: #3a2607;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  vertical-align: middle;
}

.profile-card-main {
  display: block;
  width: 100%;
  min-height: 0;
  padding: 0;
  padding-right: 88px;
  text-align: left;
  background: transparent;
  border: 0;
  color: inherit;
  font-weight: inherit;
}

.privacy-status-dot {
  width: 52px;
  height: 52px;
  margin: 18px auto 6px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
}

.privacy-mode .profile-card-main {
  min-height: 126px;
  display: grid;
  align-content: center;
  padding-right: 0;
  text-align: center;
}

.privacy-mode .profile-top {
  justify-content: center;
}

.privacy-green {
  background: #22c55e;
}

.privacy-yellow {
  background: #facc15;
}

.privacy-orange {
  background: #f97316;
}

.privacy-red {
  background: #dc2626;
}

.privacy-light-red {
  background: #fb7185;
}

.privacy-gray {
  background: #64748b;
}

.profile-card:hover,
.queue-item:hover {
  border-color: #5b6972;
  background: #1d2428;
}

.deleted-profile-card {
  border-style: dashed;
  border-color: #6b7280;
  background: #202326;
}

.deleted-profile-card:hover {
  border-color: #8b949e;
  background: #252a2e;
}

.deleted-profile-main {
  min-height: 210px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.deleted-profile-main .range-label {
  color: #fca5a5;
}

.deleted-profile-dismiss {
  width: fit-content;
  margin-top: 4px;
}

.profile-top,
.request-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.glucose-line {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 12px 0 6px;
}

.glucose {
  margin: 12px 0 6px;
  font-size: 46px;
  line-height: 1;
  font-weight: 800;
}

.glucose-line .glucose {
  margin: 0;
}

.card-trend-arrow {
  color: var(--text);
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
}

.reading-age-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.reading-age-line strong {
  color: var(--text);
}

.reading-age-line.stale {
  width: fit-content;
  padding: 5px 8px;
  color: #fed7aa;
  background: #3a2607;
  border: 1px solid #f59e0b;
  border-radius: 6px;
}

.reading-age-line.stale strong,
.reading-age-line.stale em {
  color: #fdba74;
}

.reading-age-line em {
  font-style: normal;
  text-transform: uppercase;
  letter-spacing: 0;
}

.range-label {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.card-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
}

.card-metrics span {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1417;
}

.card-metrics strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
}

.profile-flags {
  display: grid;
  gap: 6px;
  margin-bottom: 10px;
}

.profile-flag {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 30px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}

.profile-flag strong {
  color: var(--text);
}

.profile-flag em {
  color: var(--muted);
  font-style: normal;
}

.profile-flag.low-risk {
  border-color: #f97316;
  background: #2d1a0b;
}

.profile-flag.high-no-insulin {
  border-color: #dc2626;
  background: #2d1111;
}

.profile-card-actions,
.request-links,
.manual-approval-form,
.profile-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.profile-card-actions {
  flex-wrap: wrap;
  margin-top: 12px;
}

.profile-card-request-corner {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
}

.profile-card-request-corner .badge-button {
  width: auto;
  white-space: nowrap;
}

.readings-dashboard {
  margin-top: 18px;
}

.readings-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.reading-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.reading-panel.loading {
  min-height: 120px;
}

.reading-panel-top,
.trend-strip {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.reading-panel h3,
.reading-panel p {
  margin: 0;
}

.reading-current {
  display: flex;
  align-items: baseline;
  gap: 9px;
  margin: 12px 0;
}

.reading-current em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.reading-glucose {
  font-size: 42px;
  line-height: 1;
  font-weight: 800;
}

.reading-metrics,
.missing-data-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.missing-data-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.reading-metrics span,
.missing-data-grid span {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.reading-metrics strong,
.missing-data-grid strong,
.trend-strip strong {
  display: block;
  margin-top: 3px;
  color: var(--text);
  font-size: 14px;
}

.missing-data-grid .missing-warn {
  border-color: #f59e0b;
  background: #21190d;
}

.mini-chart {
  display: block;
  width: 100%;
  height: 78px;
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #11171a;
}

.mini-chart polyline {
  fill: none;
  stroke: #38bdf8;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.mini-chart .target-line {
  stroke: rgba(34, 197, 94, 0.28);
  stroke-width: 1;
}

.mini-chart .gap-lines line {
  stroke: rgba(245, 158, 11, 0.55);
  stroke-width: 2;
}

.empty-mini-chart {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 13px;
}

.trend-strip {
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.diagnostics-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.diagnostics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.diagnostic-card {
  display: grid;
  gap: 12px;
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-left: 6px solid var(--good);
  border-radius: 8px;
  background: var(--panel);
}

.diagnostic-card.attention {
  border-left-color: #f59e0b;
  background: #1d1911;
}

.diagnostic-card-top,
.diagnostic-current {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.diagnostic-current {
  justify-content: flex-start;
  align-items: baseline;
}

.diagnostic-current em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.diagnostic-card h2,
.diagnostic-card p {
  margin: 0;
}

.diagnostic-metrics,
.diagnostic-range-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.diagnostic-range-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.diagnostic-metric-updates {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.diagnostic-metric-update {
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.32);
}

.diagnostic-metric-update span,
.diagnostic-metric-update em,
.diagnostic-metric-update small {
  display: block;
}

.diagnostic-metric-update span {
  color: var(--muted);
  font-size: 12px;
}

.diagnostic-metric-update strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
}

.diagnostic-metric-update em,
.diagnostic-metric-update small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
}

.diagnostic-metrics span,
.diagnostic-range-grid span {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-size: 12px;
}

.diagnostic-metrics strong,
.diagnostic-range-grid strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 14px;
}

.diagnostic-warnings {
  display: grid;
  gap: 6px;
}

.diagnostic-warnings span {
  padding: 8px;
  border: 1px solid #f59e0b;
  border-radius: 6px;
  background: #2b1d08;
  color: #ffd28a;
  font-size: 13px;
}

.diagnostic-warnings .ok-note {
  border-color: #1f6b3a;
  background: #0d2818;
  color: #b7f7c5;
}

.raw-row-details,
.recent-row-details {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

.raw-row-details summary,
.recent-row-details summary {
  cursor: pointer;
  color: var(--muted);
  font-weight: 700;
}

.raw-row-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0 0;
}

.raw-row-grid div {
  min-width: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1417;
}

.raw-row-grid dt {
  color: var(--muted);
  font-size: 12px;
}

.raw-row-grid dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.recent-datapoints-wrap {
  max-height: 260px;
  margin-top: 10px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.recent-datapoints-table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  font-size: 12px;
}

.recent-datapoints-table th,
.recent-datapoints-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.recent-datapoints-table th {
  position: sticky;
  top: 0;
  background: #11171a;
  color: var(--muted);
  text-transform: uppercase;
}

.recent-datapoints-table tr:last-child td {
  border-bottom: 0;
}

.data-type-stack {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.data-type-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f1417;
  overflow: hidden;
}

.data-type-panel-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  cursor: pointer;
  list-style: none;
}

.data-type-panel-top::-webkit-details-marker {
  display: none;
}

.data-type-panel-top::after {
  content: "+";
  color: var(--muted);
  font-weight: 900;
}

.data-type-panel[open] .data-type-panel-top::after {
  content: "-";
}

.data-type-panel h3,
.data-type-panel p {
  margin: 0;
}

.data-type-panel h3 {
  font-size: 14px;
}

.data-type-panel-top strong {
  color: var(--text);
  font-size: 14px;
  white-space: nowrap;
}

.data-type-table-wrap {
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid var(--line);
}

.data-type-table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 13px;
}

.data-type-table th,
.data-type-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.data-type-table th {
  position: sticky;
  top: 0;
  background: #0f1417;
  color: var(--muted);
  text-transform: uppercase;
}

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

.compact-empty {
  margin-top: 10px;
  padding: 10px;
}

.compact-empty h3 {
  font-size: 13px;
}

.diagnostic-table-wrap {
  overflow-x: auto;
}

.diagnostic-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.diagnostic-table th,
.diagnostic-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.diagnostic-table th {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.dose-event-line {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  padding: 8px;
  background: #11171a;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.dose-event-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.dose-event-line span,
.dose-event-line em {
  color: var(--muted);
  font-style: normal;
  font-size: 13px;
}

.dose-event-line strong {
  color: var(--text);
}

.profile-title-row {
  align-items: center;
}

.profile-title-row h1 {
  margin-bottom: 0;
}

.icon-button {
  width: 40px;
  min-width: 40px;
  padding: 0;
  font-size: 19px;
}

.meta,
.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.badge.pending {
  border-color: #7c4d12;
  background: #2f210a;
  color: #ffd28a;
}

.badge.approved {
  border-color: #1f6b3a;
  background: #0d2818;
  color: #8df0ad;
}

.badge.denied {
  border-color: #7a2d2d;
  background: #2d1111;
  color: #ffaaa8;
}

.badge.attendance-present {
  border-color: #1f6b3a;
  background: #0d2818;
  color: #8df0ad;
}

.badge.attendance-absent {
  border-color: #7a2d2d;
  background: #2d1111;
  color: #ffaaa8;
}

.badge.attendance-late {
  border-color: #246b84;
  background: #0f1f26;
  color: #b7edff;
}

.badge.workflow-requested {
  border-color: #246b84;
  background: #0f1f26;
  color: #b7edff;
}

.badge.workflow-waiting_response {
  border-color: #7c4d12;
  background: #2f210a;
  color: #ffd28a;
}

.badge.workflow-responded {
  border-color: #0f766e;
  background: #0f2f2d;
  color: #b7fff6;
}

.badge.workflow-approved {
  border-color: #1f6b3a;
  background: #0d2818;
  color: #8df0ad;
}

.badge.workflow-acknowledged,
.badge.acknowledged {
  border-color: #246b84;
  background: #0f1f26;
  color: #b7edff;
}

.badge.workflow-denied {
  border-color: #7a2d2d;
  background: #2d1111;
  color: #ffaaa8;
}

.badge.canceled,
.badge.expired,
.badge.workflow-canceled,
.badge.workflow-closed,
.badge.workflow-expired {
  border-color: #4b5563;
  background: #1f242b;
  color: #cbd5e1;
}

.badge-button {
  width: 100%;
  justify-content: center;
  cursor: pointer;
}

.hidden {
  display: none;
}

.ghost-button,
button,
select,
input,
textarea {
  min-height: 38px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
}

button,
.ghost-button {
  padding: 0 14px;
  cursor: pointer;
}

button {
  background: #0f766e;
  border-color: #0f766e;
  font-weight: 700;
}

button.deny {
  background: #7f1d1d;
  border-color: #7f1d1d;
}

button.danger-button {
  background: #991b1b;
  border-color: #dc2626;
  color: #fff;
}

button.danger-button:hover {
  background: #7f1d1d;
  border-color: #ef4444;
}

button.secondary {
  background: #374151;
  border-color: #4b5563;
}

.ghost-button {
  background: var(--surface);
}

button.collapse-button,
.ghost-button.collapse-button {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #1f242b;
  border-color: var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.metric {
  padding: 14px;
}

.metric span {
  color: var(--muted);
}

.metric strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.chart-wrap {
  padding: 14px;
  margin-bottom: 16px;
}

#historyChart {
  width: 100%;
  height: 180px;
}

#dayChart {
  width: 100%;
  height: 220px;
}

#dailyEventsChart {
  width: 100%;
  height: 220px;
}

.daily-chart-wrap {
  margin-top: 14px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  margin-bottom: 10px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 999px;
}

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

.roster-row {
  cursor: pointer;
}

.roster-row:hover,
.roster-row:focus {
  background: #111c22;
  outline: none;
}

.small-action-button {
  min-height: 28px;
  padding: 3px 9px;
  font-size: 12px;
  border-radius: 999px;
  white-space: nowrap;
}

.student-profile-modal {
  display: grid;
  gap: 16px;
}

.student-attendance-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10171a;
}

.student-attendance-panel.at-school {
  border-color: #1f6b3a;
  background: #0d2818;
}

.student-attendance-panel.not-at-school {
  border-color: #7c4d12;
  background: #2f210a;
}

.student-attendance-panel h3,
.student-attendance-panel p {
  margin: 0;
}

.student-profile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}

.student-profile-detail {
  min-width: 0;
  padding: 12px;
  background: #10171a;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.student-profile-detail span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.student-profile-detail strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.student-profile-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.glucose-dot {
  background: #38bdf8;
}

.iob-dot {
  background: #f59e0b;
}

.back-button,
.page-actions {
  margin-bottom: 16px;
}

.page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.empty-state {
  margin-bottom: 0;
}

.requests {
  display: grid;
  gap: 12px;
}

.request-card {
  padding: 16px;
}

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

.calculation-card {
  min-height: 112px;
  padding: 12px;
  background: #10171a;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.calculation-card span {
  color: var(--muted);
  font-size: 13px;
}

.calculation-card p,
.calculation-card strong {
  margin: 0;
}

.calculation-card strong {
  display: block;
  margin: 6px 0;
  font-size: 28px;
  color: var(--text);
}

.calculation-card.total {
  border-color: #0f766e;
  background: #0f1f1d;
}

.compact-request {
  display: grid;
  gap: 12px;
}

.manual-approval-form {
  flex-wrap: wrap;
}

.manual-approval-form input {
  flex: 1 1 280px;
}

.manual-note {
  margin: 0;
  padding: 10px;
  background: #0d2818;
  border: 1px solid #1f6b3a;
  border-radius: 6px;
}

.school-id-panel {
  border-left: 6px solid var(--info);
}

.school-id-code {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 14px;
  background: #0f1f26;
  border: 1px solid #246b84;
  border-radius: 6px;
  color: #b7edff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0;
}

.school-id-code.compact {
  min-height: 28px;
  padding: 4px 8px;
  font-size: 13px;
}

.school-id-stack {
  display: grid;
  justify-items: end;
  gap: 6px;
}

.school-id-stack strong {
  font-size: 16px;
}

.iob-alert-card.resolved {
  background: #111c16;
  border-color: #1f6b3a;
  border-left-color: var(--good);
}

.request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.request-actions select,
.request-actions input {
  flex: 1 1 220px;
  padding: 0 10px;
}

.conversation-actions input {
  flex-basis: 320px;
}

button.end-conversation-button {
  background: #991b1b;
  border-color: #dc2626;
  color: #fff;
}

button.end-conversation-button:hover {
  background: #7f1d1d;
  border-color: #ef4444;
}

.message-thread {
  display: grid;
  gap: 8px;
  margin-top: 6px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.message-thread h4 {
  margin: 0;
  color: var(--muted);
}

.message-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  background: #0f1417;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.message-row.approver {
  border-color: #3b5362;
  background: #111c22;
}

.message-row.student {
  border-color: #3f4b36;
  background: #141c12;
}

.message-row span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  text-transform: capitalize;
  font-size: 13px;
}

.message-row p {
  margin: 0;
}

.message-attachments {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.message-image-link {
  display: grid;
  gap: 6px;
  width: min(260px, 100%);
  color: var(--accent);
  font-size: 13px;
  text-decoration: none;
}

.message-image-link img {
  display: block;
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #080b0d;
}

.message-image-link span {
  margin: 0;
  color: inherit;
  text-transform: none;
  font-size: inherit;
}

.message-image-removed {
  width: min(260px, 100%);
  padding: 10px 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #0b0f12;
  font-size: 13px;
}

.message-row time {
  color: var(--muted);
  white-space: nowrap;
  font-size: 13px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 7vh 18px 24px;
  background: rgba(0, 0, 0, 0.62);
}

.modal.hidden {
  display: none;
}

.modal-panel {
  width: min(880px, 100%);
  max-height: 86vh;
  overflow: auto;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(0, 0, 0, 0.45);
}

.requester {
  max-width: 620px;
}

.request-panel,
.settings-panel,
.summary-section {
  padding: 20px;
}

.summary-section {
  margin-bottom: 18px;
}

.inline-settings-form {
  gap: 12px;
}

form {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

input,
select,
textarea {
  width: 100%;
  padding: 0 10px;
}

input[readonly] {
  color: #b7edff;
  background: #0f1f26;
  border-color: #246b84;
  font-weight: 800;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

legend {
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.admin-inline-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(160px, 220px) auto;
  gap: 12px;
  align-items: end;
  margin: 16px 0;
}

.admin-inline-form label {
  display: grid;
  gap: 6px;
}

.admin-overview {
  padding-top: 16px;
}

.admin-user-toolbar {
  margin: 14px 0;
}

.admin-user-toolbar label {
  max-width: 520px;
}

.admin-users-table select {
  min-width: 118px;
}

.school-settings-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.school-settings-context span {
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}

.school-settings-context code {
  padding: 4px 8px;
  color: #b7edff;
  background: #0f1f26;
  border: 1px solid #246b84;
  border-radius: 6px;
}

.diagnostic-review-list,
.ticket-board {
  display: grid;
  gap: 12px;
}

.ticket-filter-panel {
  margin-bottom: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-start;
}

.ticket-filter-row label {
  min-width: min(240px, 100%);
}

.diagnostic-review-card,
.ticket-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.diagnostic-review-card,
.ticket-card-top,
.ticket-reply-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.diagnostic-review-card h3,
.ticket-card h2 {
  margin-bottom: 4px;
}

.diagnostic-review-meta {
  display: grid;
  justify-items: end;
  gap: 6px;
  color: var(--muted);
  white-space: nowrap;
}

.ticket-card.closed {
  opacity: 0.82;
}

.ticket-card-preview {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-card-preview span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-card-preview p {
  margin: 0;
}

.ticket-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ticket-thread {
  display: grid;
  gap: 10px;
  padding: 12px;
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-message {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 10px;
  border-radius: 8px;
  background: #162026;
}

.ticket-message.admin {
  background: #0f2f2d;
}

.ticket-message.system {
  background: #202329;
}

.ticket-message span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.ticket-message p {
  margin: 0;
}

.ticket-message time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.ticket-reply-row input {
  flex: 1 1 260px;
}

.ticket-detail-modal {
  display: grid;
  gap: 16px;
}

.ticket-modal-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.ticket-modal-meta span {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  color: var(--muted);
  background: #10171b;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.ticket-modal-meta strong {
  color: var(--text);
}

.ticket-detail-form textarea {
  min-height: 118px;
  padding: 10px;
  resize: vertical;
}

.settings-ticket-list {
  margin-top: 14px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
}

.checkbox-row input {
  width: auto;
}

.weekday-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 10px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-weight: 600;
}

pre {
  overflow: auto;
  margin: 16px 0 0;
  padding: 12px;
  background: #0a0d0f;
  border: 1px solid var(--line);
  border-radius: 6px;
}

@media (min-width: 1600px) {
  .home-view main {
    width: min(1680px, calc(100vw - 48px));
  }

  .profile-grid {
    grid-template-columns: repeat(auto-fill, minmax(300px, 360px));
  }
}

@media (max-width: 900px) {
  .summary-grid {
    grid-template-columns: repeat(2, minmax(130px, 1fr));
  }

  .daily-filter-bar,
  .daily-card-grid {
    grid-template-columns: 1fr;
  }

  .readings-grid {
    grid-template-columns: 1fr;
  }

  .diagnostics-summary,
  .diagnostics-grid {
    grid-template-columns: 1fr;
  }

  .reading-metrics,
  .missing-data-grid,
  .diagnostic-metrics,
  .diagnostic-metric-updates,
  .diagnostic-range-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calculation-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .admin-inline-form {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 9px;
    padding: 10px 12px;
  }

  nav {
    width: 100%;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
  }

  nav a {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 7px 9px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--surface);
    white-space: nowrap;
  }

  main {
    width: min(1180px, calc(100vw - 16px));
    padding: 14px 0 28px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 19px;
  }

  h3 {
    font-size: 16px;
  }

  .section-heading,
  .detail-head,
  .panel-heading,
  .heading-actions {
    gap: 10px;
  }

  .section-heading {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .section-heading,
  .detail-head {
    margin-bottom: 12px;
  }

  .heading-actions,
  .range-controls,
  .day-picker,
  .filter-row {
    justify-content: flex-start;
  }

  .dosing-filter-stack {
    justify-items: start;
  }

  .daily-timeline-item {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .daily-date-controls input {
    width: 100%;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
  }

  .summary-tile {
    min-height: 66px;
    padding: 10px;
  }

  .summary-tile strong {
    margin-top: 4px;
    font-size: 26px;
  }

  .approval-inbox,
  .request-panel,
  .settings-panel,
  .summary-section,
  .request-queue {
    margin-bottom: 12px;
    padding: 12px;
  }

  .approval-list,
  .alert-list,
  .requests {
    gap: 9px;
  }

  .approval-card,
  .request-card,
  .iob-alert-card {
    gap: 10px;
    padding: 12px;
  }

  .approval-primary {
    gap: 10px;
  }

  .approval-primary h3 {
    font-size: 18px;
  }

  .approval-glucose {
    font-size: 38px;
  }

  .approval-reading {
    min-width: 84px;
  }

  .approval-context {
    gap: 8px;
  }

  .approval-context span {
    min-width: 96px;
  }

  .profile-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .profile-card {
    min-height: 0;
    padding: 10px;
  }

  .profile-card-main {
    padding-right: 74px;
  }

  .profile-card-request-corner {
    top: 10px;
    right: 10px;
  }

  .profile-card-request-corner .badge-button {
    min-height: 28px;
    padding: 4px 7px;
    font-size: 12px;
  }

  .profile-top,
  .request-top {
    gap: 8px;
  }

  .glucose-line {
    gap: 7px;
    margin: 8px 0 4px;
  }

  .glucose {
    margin: 8px 0 4px;
    font-size: 36px;
  }

  .card-trend-arrow {
    font-size: 24px;
  }

  .card-metrics,
  .profile-flags {
    gap: 6px;
    margin-bottom: 8px;
  }

  .profile-flag {
    min-height: 28px;
    padding: 5px 7px;
    font-size: 12px;
  }

  .dose-event-line {
    gap: 5px;
    margin: 8px 0 0;
    padding: 7px;
  }

  .privacy-status-dot {
    width: 46px;
    height: 46px;
    margin: 12px auto 4px;
  }

  .privacy-mode .profile-card-main {
    min-height: 92px;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .metric {
    padding: 10px;
  }

  .metric strong {
    font-size: 24px;
  }

  .calculation-grid {
    gap: 8px;
  }

  .calculation-card {
    min-height: 92px;
    padding: 10px;
  }

  .calculation-card strong {
    font-size: 24px;
  }

  .alert-hero {
    margin-bottom: 12px;
    padding: 14px;
  }

  .alert-hero h2 {
    font-size: 24px;
  }

  #dayChart {
    height: 170px;
  }

  #historyChart {
    height: 150px;
  }

  button,
  .ghost-button,
  select,
  input,
  textarea {
    min-height: 34px;
  }

  th,
  td {
    padding: 8px;
  }
}

@media (max-width: 640px) {
  .detail-head,
  .detail-head .heading-actions {
    align-items: flex-start;
    flex-direction: column;
  }

  .glucose {
    font-size: 34px;
  }

  .approval-primary,
  .approval-actions,
  .alert-hero,
  .diagnostic-review-card,
  .ticket-card-top,
  .ticket-reply-row {
    flex-direction: column;
    align-items: stretch;
  }

  .diagnostic-review-meta {
    justify-items: start;
  }

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

  .approval-reading,
  .approval-glucose-line {
    justify-content: flex-start;
    text-align: left;
  }
}

@media (max-width: 560px) {
  .profile-grid,
  .summary-grid,
  .metrics {
    grid-template-columns: 1fr;
  }

  .profile-card-main {
    padding-right: 82px;
  }
}
