.btn {
  border: none;
  border-radius: 6px;
  padding: 0.5em 1em;
  font-size: 0.875rem;
  cursor: pointer;
  font-weight: 500;
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-secondary {
  background: #e7ede9;
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.sync-status {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  /* Grid items default to min-width:auto, which lets a wide chart force its column
     past the 1fr track (seen live: the skin-temperature card spilling off-screen in
     .grid-2). This overrides that without affecting non-grid usage. */
  min-width: 0;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1rem;
}

.profile-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
}

.profile-name {
  font-weight: 500;
  color: var(--primary);
}

.profile-meta,
.profile-device {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.chart {
  width: 100%;
  min-width: 0;
  overflow-x: auto;
}

.chart svg {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
}

.chart-empty-text {
  color: var(--text-muted);
  font-size: 0.875rem;
}

.stat-highlight {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text);
  margin: 0 0 0.5rem;
}

.stat-date {
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-muted);
}

.stat-flagged {
  color: var(--accent-peach-strong);
}

.stage-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
}

.stage-breakdown-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
}

.stage-breakdown-item .swatch {
  width: 10px;
  height: 10px;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-axis-label {
  font-size: 10px;
  fill: var(--text-muted);
}

.chart-bar-total {
  font-size: 10px;
  font-weight: 500;
  fill: var(--text);
}

.chart-threshold {
  stroke: var(--accent-peach-strong);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.chart-threshold-label {
  font-size: 10px;
  fill: var(--accent-peach-strong);
}

/* For a reference line that isn't inherently a warning — e.g. a night's own SpO2
   baseline in the per-night detail view — so it doesn't read as "this is bad" when it's
   just "this is the middle." */
.chart-threshold-neutral {
  stroke: var(--text-muted);
}

.chart-threshold-label-neutral {
  fill: var(--text-muted);
}

.chart-marker {
  stroke: var(--accent-peach-strong);
  stroke-width: 2;
}

.chart-timeline-label {
  font-size: 9px;
  fill: var(--text-muted);
}

/* Matches .chart-marker's color so an out-of-bed timestamp visually ties back to its
   tick mark on the bar above, the same way an AWAKE segment's own bar color already
   ties its (muted) label back to it. */
.chart-timeline-label-marker {
  fill: var(--accent-peach-strong);
}

.chart-timeline-leader {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-empty {
  font-size: 0.875rem;
  fill: var(--text-muted);
}

.legend {
  display: flex;
  gap: 1rem;
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35em;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}

.hint {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.banner {
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  font-size: 0.9rem;
}

.banner-notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-border);
}

.data-table {
  font-size: 0.875rem;
}

.row-flagged {
  background: var(--notice-bg);
}

.table-total td {
  font-weight: 500;
  border-top: 2px solid var(--border);
  border-bottom: none;
  color: var(--text);
}

.error-toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(90vw, 640px);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: #fef2f2;
  border: 1px solid #fca5a5;
  color: #7f1d1d;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  font-size: 0.85rem;
  z-index: 50;
}

.error-toast-close {
  background: none;
  border: none;
  color: inherit;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}

.night-row {
  cursor: pointer;
}

.night-row:hover {
  background: var(--bg);
}

dialog.night-detail {
  width: min(680px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  border: none;
  border-radius: var(--radius);
  padding: 1.5rem;
  background: var(--bg);
  color: var(--text);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

dialog.night-detail::backdrop {
  background: rgba(30, 42, 68, 0.5);
}

.night-detail-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: none;
  border: none;
  font-size: 1.3rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
}

.night-detail-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.night-detail-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.night-detail-stat-label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.night-detail-stat-value {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}
