:root {
  --bg: #f2f3f5;
  --surface: #ffffff;
  --text: #1c1c1e;
  --text-secondary: #6c6c70;
  --text-tertiary: #8e8e93;
  --border: rgba(60, 60, 67, 0.12);
  --border-strong: rgba(60, 60, 67, 0.18);
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --complete: #34c759;
  --complete-soft: rgba(52, 199, 89, 0.1);
  --warn: #ff9f0a;
  --warn-soft: rgba(255, 159, 10, 0.12);
  --scheduled: #5ac8fa;
  --scheduled-soft: rgba(90, 200, 250, 0.12);
  --danger: #ff3b30;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  --radius: 14px;
  --font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dash-section-gap: 6px;
  /* Supporting card family (Planning / Previous / Authorized / Statistics) */
  --dash-support-card-min-height: 68.5px;
  --dash-support-card-padding-y: 14px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #e8eef8 0%, transparent 55%),
    linear-gradient(180deg, #eef0f4 0%, var(--bg) 40%, #ebecef 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.app {
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100vh;
}

/* ——— Header ——— */

.app-header {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 40px;
}

.settings-open-btn {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0;
  padding: 0;
  border-radius: 10px;
  color: var(--text-tertiary);
  transition: background-color 170ms ease-out, color 170ms ease-out;
}

.settings-open-btn:hover {
  color: var(--text-secondary);
  background: rgba(60, 60, 67, 0.06);
}

.settings-open-btn:focus {
  outline: none;
}

.settings-open-btn:focus-visible {
  color: var(--text-secondary);
  background: rgba(60, 60, 67, 0.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-open-icon {
  display: block;
  width: 18px;
  height: 18px;
  min-width: 18px;
  min-height: 18px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
}

.recipient-selector {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 10px 6px 4px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 170ms ease-out;
  position: relative;
}

.recipient-selector:focus-visible {
  background: rgba(255, 255, 255, 0.72);
  outline: none;
}

.recipient-selector.is-open {
  background: rgba(60, 60, 67, 0.05);
}

.recipient-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.recipient-label::after {
  content: ":";
}

.recipient-name {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.recipient-chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-tertiary);
  margin-left: 2px;
  position: relative;
  top: -1px;
  transition: transform 160ms ease-out;
}

.recipient-selector.is-open .recipient-chevron {
  transform: rotate(180deg);
}

.recipient-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 35;
  min-width: 168px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.recipient-menu[hidden] {
  display: none;
}

.recipient-option {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
}

.recipient-option.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

@media (hover: hover) and (pointer: fine) {
  .recipient-option:hover {
    background: rgba(60, 60, 67, 0.06);
  }

  .recipient-option.is-active:hover {
    background: var(--accent-soft);
  }
}

.recipient-menu-divider {
  height: 1px;
  margin: 6px 8px;
  background: var(--border);
  border: none;
  list-style: none;
}

.recipient-option.is-manage {
  color: var(--text-secondary);
  font-weight: 550;
  font-size: 0.88rem;
}

.recipient-option.is-manage:hover {
  color: var(--text);
}

.month-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

/* STEP 41.2A / 41.6B — Plan Visits entry row (below month nav; does not restyle .month-bar) */
.plan-visits-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 44px;
  width: 100%;
}

/* STEP 43.5B — Soft Hide: durable hide (author display:flex must not win). */
#plan-visits-row.is-plan-visits-entry-soft-hidden {
  display: none !important;
}

.plan-visits-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 14px;
  margin: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  outline: none;
  box-shadow: none;
  transition:
    background-color 170ms ease-out,
    color 170ms ease-out,
    border-color 170ms ease-out;
}

.plan-visits-btn:hover {
  background: rgba(60, 60, 67, 0.06);
  color: var(--text);
  border-color: var(--border);
}

.plan-visits-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.plan-visits-btn.is-active,
.plan-visits-btn[aria-pressed="true"] {
  color: var(--accent);
  background: rgba(10, 132, 255, 0.08);
  border-color: rgba(10, 132, 255, 0.18);
}

/* STEP 41.3 — Plan Visits sticky action bar */
.plan-visits-action-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  pointer-events: none;
  padding:
    0 max(10px, env(safe-area-inset-left, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(10px, env(safe-area-inset-right, 0px));
}

.plan-visits-action-bar[hidden] {
  display: none !important;
}

.plan-visits-action-bar-inner {
  pointer-events: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  column-gap: 8px;
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  min-height: 56px;
  padding: 8px 10px;
  box-sizing: border-box;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 1px 3px rgba(0, 0, 0, 0.06);
  backdrop-filter: blur(12px);
}

.plan-visits-summary {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.plan-visits-count {
  margin: 0;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* STEP 42.4B / 42.4B.1 — read-only allocation preview (sticky bar only) */
.plan-visits-preview {
  margin: 0;
  min-width: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: pre-line;
  overflow: hidden;
  overflow-wrap: anywhere;
}

.plan-visits-preview[hidden] {
  display: none !important;
}

.plan-visits-preview.is-invalid {
  color: var(--warn);
}

.plan-visits-cancel,
.plan-visits-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 72px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  outline: none;
  white-space: nowrap;
}

.plan-visits-cancel {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
}

.plan-visits-cancel:hover {
  background: rgba(60, 60, 67, 0.05);
}

.plan-visits-cancel:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.plan-visits-save {
  border: none;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25);
}

.plan-visits-save:hover:not(:disabled) {
  background: #0077ed;
}

.plan-visits-save:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.plan-visits-save:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

/* Temporary bottom space so last Calendar row stays tappable above the bar */
.app[data-plan-mode="true"] #planner-view {
  padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px));
}

/* STEP 41.4 — Plan Visits save feedback toast */
.plan-visits-feedback {
  position: fixed;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 41;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 2px;
  width: calc(100% - 20px);
  max-width: 920px;
  margin: 0 auto;
  padding: 12px 14px;
  box-sizing: border-box;
  background: rgba(28, 28, 30, 0.92);
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.25;
  text-align: center;
}

.plan-visits-feedback[hidden] {
  display: none !important;
}

.plan-visits-feedback.is-above-bar {
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
}

.plan-visits-feedback-primary {
  margin: 0;
  color: #fff;
}

.plan-visits-feedback-secondary {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.82rem;
  font-weight: 500;
}

.plan-visits-feedback-secondary[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: no-preference) {
  .plan-visits-feedback {
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 160ms ease-out, transform 160ms ease-out;
  }

  .plan-visits-feedback.is-visible {
    opacity: 1;
    transform: translateY(0);
  }
}

.month-title {
  margin: 0;
  font-size: clamp(1.55rem, 3.5vw, 1.9rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.month-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  backdrop-filter: blur(8px);
}

.nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 600;
  transition:
    background-color 170ms ease-out,
    transform 160ms ease-out,
    box-shadow 170ms ease-out;
}

.nav-btn:active {
  transform: scale(0.96);
  box-shadow: none;
}

.today-btn {
  flex: 0 0 auto;
  min-width: 72px;
  width: 72px;
  height: 40px;
  min-height: 40px;
  max-height: none;
  overflow: visible;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  padding: 0 6px;
  letter-spacing: 0;
  line-height: 1;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.today-btn-main {
  display: block;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0.02em;
  color: var(--accent);
  text-align: center;
}

.today-btn-date {
  display: block;
  margin-top: 2px;
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0;
  color: #7a7f87;
  text-align: center;
  white-space: nowrap;
  overflow: visible;
}

/* ——— Calendar ——— */

.calendar-section {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  overflow: hidden;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: min(58vh, 560px);
  touch-action: pan-y;
}

.weekday-row {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  padding: 10px 6px 6px;
  border-bottom: 1px solid var(--border);
}

.weekday-row span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-tertiary);
  letter-spacing: 0.04em;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(5, 1fr);
  flex: 1;
  min-height: 0;
}

.day-cell {
  /* Shared calendar vertical rhythm */
  --cal-rhythm-xs: 2px; /* date → TODAY */
  --cal-rhythm-sm: 2px; /* hours → status icon (tighter than date → hours) */

  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 6px 4px 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  transition:
    background-color 170ms ease-out,
    transform 90ms cubic-bezier(0.2, 0, 0, 1),
    box-shadow 170ms ease-out;
  min-height: 72px;
}

.day-cell:nth-child(7n) {
  border-right: none;
}

.day-cell:nth-last-child(-n + 7) {
  border-bottom: none;
}

.day-cell.empty-slot {
  cursor: default;
  background: #fafafa;
}

.day-cell.empty-slot:hover {
  background: #fafafa;
  transform: none;
  box-shadow: none;
}

.day-cell.is-selected {
  background: #eef6ff;
  box-shadow: 0 2px 10px rgba(10, 132, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  z-index: 2;
}

/* STEP 41.2B — Plan Visits multi-select (distinct from Visit Editor .is-selected) */
.day-cell.is-plan-selected {
  background: #f3f8ff;
  box-shadow: inset 0 0 0 2px rgba(10, 132, 255, 0.34);
  z-index: 1;
}

.day-cell.is-plan-selected:focus-visible {
  box-shadow:
    inset 0 0 0 2px rgba(10, 132, 255, 0.34),
    0 0 0 3px rgba(10, 132, 255, 0.22);
  z-index: 2;
}

.day-cell:focus {
  outline: none;
}

.day-cell:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.22);
  z-index: 2;
}

.day-cell:not(.empty-slot):active {
  transform: scale(0.98);
}

@media (hover: hover) and (pointer: fine) {
  .recipient-selector:hover {
    background: rgba(60, 60, 67, 0.05);
  }

  .nav-btn:hover {
    background: var(--accent-soft);
    box-shadow: 0 1px 4px rgba(10, 132, 255, 0.14);
  }

  .day-cell:not(.empty-slot):hover {
    background: #f7fafd;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    z-index: 2;
  }

  .day-cell:not(.empty-slot):hover:active {
    transform: translateY(-1px) scale(0.98);
  }

  .day-cell:not(.empty-slot).is-selected:hover {
    background: #eef6ff;
    box-shadow: 0 2px 10px rgba(10, 132, 255, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  }

  .day-cell:not(.empty-slot).is-plan-selected:hover {
    background: #f3f8ff;
    box-shadow: inset 0 0 0 2px rgba(10, 132, 255, 0.34);
  }

  .day-cell:not(.empty-slot):focus-visible:hover {
    box-shadow:
      0 2px 8px rgba(0, 0, 0, 0.04),
      0 0 0 3px rgba(10, 132, 255, 0.22);
  }

  .day-cell:not(.empty-slot).is-selected:focus-visible:hover {
    background: #eef6ff;
    box-shadow:
      0 2px 10px rgba(10, 132, 255, 0.08),
      0 0 0 3px rgba(10, 132, 255, 0.18);
  }
}

.day-cell.completed {
  background-color: rgba(52, 199, 89, 0.015);
}

.day-cell.scheduled {
  background-color: rgba(10, 132, 255, 0.012);
}

.day-cell.incomplete {
  background-color: rgba(255, 159, 10, 0.02);
}

.day-cell.is-today {
  background: linear-gradient(180deg, #f3f8ff 0%, #ffffff 70%);
}

.day-cell.is-today.is-selected {
  background: #eef6ff;
}

.day-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-bottom: 0;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
  flex-shrink: 0;
  position: relative;
  z-index: 1;
}

/*
 * TODAY label sits in normal flex flow under the day number so it cannot
 * overlap .day-status (hours / symbols). Today cells stack:
 * date → TODAY → status content.
 */
.today-label {
  position: static;
  margin: var(--cal-rhythm-xs) 0 0;
  display: block;
  flex: 0 0 auto;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  line-height: 1;
  text-align: center;
  pointer-events: none;
}

/*
 * Status block fills remaining cell height and centers its content so
 * completed / incomplete / scheduled / today share one optical rhythm:
 * date (and TODAY) at top → balanced whitespace → status group → balanced whitespace.
 */
.day-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--cal-rhythm-sm);
  flex: 1 1 auto;
  width: 100%;
  margin-top: 0;
  text-align: center;
  min-height: 0;
}

/* ——— Shared status-symbol primitives (STEP 31B) ——— */
.status-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
  box-sizing: border-box;
}

.status-symbol--completed {
  color: var(--complete);
  font-size: 13px;
  font-weight: 700;
}

.status-symbol--incomplete {
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

/* Past Scheduled: planned visit never logged — orange hollow ○ (Option D). */
.status-symbol--past-scheduled {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--warn);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 0;
}

.status-symbol--scheduled {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text-tertiary);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 0;
}

.status-symbol--current-period,
.status-symbol--previous-period,
.status-symbol--attention {
  width: var(--stats-dot-size, 10px);
  height: var(--stats-dot-size, 10px);
  flex: 0 0 var(--stats-dot-size, 10px);
  border-radius: 50%;
  margin-top: 4px;
}

.status-symbol--current-period {
  background: var(--text);
}

.status-symbol--previous-period {
  background: var(--text-tertiary);
}

.status-symbol--attention {
  background: var(--warn);
}

/* Temporary aliases — safe migration from pre-31B class names */
.status-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  line-height: 1;
}

.status-icon.complete {
  color: var(--complete);
  font-size: 13px;
  font-weight: 700;
}

.status-icon.incomplete {
  color: var(--warn);
  font-size: 13px;
  font-weight: 700;
}

.status-icon.scheduled {
  width: 12px;
  height: 12px;
  border: 1.5px solid var(--text-tertiary);
  border-radius: 50%;
  background: transparent;
  color: transparent;
  font-size: 0;
  opacity: 1;
}

.pay-period-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 10px;
  height: 10px;
  flex: 0 0 10px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
  box-sizing: border-box;
}

.pay-period-dot--current {
  background: var(--text);
}

.pay-period-dot--previous {
  background: var(--text-tertiary);
}

.status-hours {
  font-size: clamp(0.72rem, 1.6vw, 0.88rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.15;
}

.hours-compact {
  display: none;
}

.status-label {
  font-weight: 600;
  color: var(--text-tertiary);
  font-size: clamp(0.58rem, 1.15vw, 0.68rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  max-width: 100%;
}

.day-cell.completed .status-hours {
  color: var(--text);
}

.day-cell.scheduled .status-hours {
  color: var(--text-secondary);
  font-weight: 650;
}

.day-cell.incomplete .status-warning {
  color: #a86a00;
  font-weight: 650;
  padding-inline: 2px;
}

/* ——— Warning System (shared caution style) ——— */

.is-warning {
  color: var(--warn);
}

/* Beat component value colors without !important */
.dash-hero-value.is-warning,
.dash-metric-value.is-warning,
.dash-period-value.is-warning,
.dash-period-stat-value.is-warning,
.stats-hero-row dd.is-warning,
.stats-ring-legend-item dd.is-warning,
#stats-remaining.is-warning,
.stats-comparison-value.is-warning,
.stats-planning-value.is-warning {
  color: var(--warn);
}

.is-warning-message {
  font-variant-numeric: normal;
  white-space: normal;
  line-height: 1.25;
  letter-spacing: -0.02em;
}

.dash-metric-value.is-warning-message {
  font-size: clamp(0.95rem, 2.4vw, 1.1rem);
  font-weight: 650;
}

.dash-period-stat-value.is-warning-message {
  font-size: clamp(0.82rem, 2.2vw, 0.95rem);
  font-weight: 650;
}

/* ——— Dashboard ——— */

#planner-view {
  display: flex;
  flex-direction: column;
  gap: var(--dash-section-gap);
  min-width: 0;
}

.dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--dash-section-gap);
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  border-radius: 0;
}

.dash-card {
  background: var(--surface);
  border-radius: 18px;
  border: 1px solid rgba(60, 60, 67, 0.1);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.035),
    0 2px 8px rgba(0, 0, 0, 0.03);
  transition:
    transform 170ms ease-out,
    box-shadow 170ms ease-out,
    border-color 170ms ease-out;
}

.dash-hero {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  border: none;
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 1px 0 rgba(60, 60, 67, 0.04);
}

.dash-eyebrow {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.dash-hero-value {
  font-size: clamp(2.15rem, 5.5vw, 2.65rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--text);
}

/* Number hierarchy — Level 1 / 2 / 3 (same level = identical type) */
.dash-num-l1 {
  font-size: clamp(2.15rem, 5.5vw, 2.65rem);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.dash-num-l2 {
  font-size: clamp(1.35rem, 3.4vw, 1.55rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.dash-num-l3 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

/* Today's Visit Card (STEP 38A.2 Phase A — hierarchy / rhythm) */
.today-visit-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 16px 20px 16px;
  gap: 0;
  box-sizing: border-box;
  --today-value-inset: 0px;
  --today-rhythm-group: 10px;
  --today-rhythm-tight: 8px;
  /* STEP 39B.6B — Ready/Working Worked Today (~75.6% of Remaining Hours L1) */
  --today-worked-size: clamp(1.625rem, 4.158vw, 2.003rem);
}

.today-visit-card[data-state="completed"] {
  /* STEP 39B.6B — Completed Worked Today (~87.2% of Remaining Hours L1) */
  --today-worked-size: clamp(1.875rem, 4.796vw, 2.311rem);
}

.today-visit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: var(--today-rhythm-group);
  min-width: 0;
}

.today-visit-title {
  margin: 0;
  min-width: 0;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.25;
}

/* Compact status pill — secondary to title; text conveys state (not color alone) */
.today-status-badge {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 46%;
  margin: 0;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(60, 60, 67, 0.14);
  background: rgba(60, 60, 67, 0.05);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  line-height: 1.2;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.today-visit-card:has(#dash-today-action[data-state="working"]) .today-status-badge {
  border-color: rgba(52, 199, 89, 0.28);
  background: rgba(52, 199, 89, 0.1);
  color: #248a3d;
}

.today-visit-card:has(#dash-today-action[data-state="completed"]) .today-status-badge {
  border-color: rgba(60, 60, 67, 0.12);
  background: rgba(60, 60, 67, 0.05);
  color: var(--text-secondary);
}

.today-worked {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--today-rhythm-group);
}

.today-worked-label {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  line-height: 1.2;
}

/* Worked Today value — state size via card --today-worked-size (STEP 39B.6B) */
.today-worked-value {
  font-size: var(--today-worked-size);
  font-weight: 650;
  letter-spacing: -0.045em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
}

.today-visit-divider {
  width: 100%;
  height: 0;
  margin: 0;
  border: none;
  border-top: 1px solid rgba(60, 60, 67, 0.07);
}

.today-time-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  margin-bottom: var(--today-rhythm-tight);
  box-sizing: border-box;
}

.time-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  /* Icon ↔ label only; label flexes so time stays right-aligned */
  gap: 12px;
  width: 100%;
  min-width: 0;
}

/*
 * STEP 38A.2 Phase B — matched doorway icon family.
 * Check In: green box, arrow entering (→│).
 * Check Out: blue box, arrow exiting (│→).
 * Empty hooks still collapse (Phase A safety).
 */
.time-row-icon:empty {
  display: none;
}

.time-row-icon {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  box-sizing: border-box;
}

.time-row-icon--checkin {
  background: var(--complete);
}

.time-row-icon--checkout {
  background: var(--accent);
}

.time-row-icon-svg {
  width: 16px;
  height: 16px;
  display: block;
  overflow: visible;
}

.time-row-icon-door,
.time-row-icon-arrow {
  fill: none;
  stroke: #fff;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.time-row-icon-knob {
  fill: #fff;
  stroke: none;
}

.time-row-label {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.9rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  line-height: 1.3;
}

.time-row-value {
  flex-shrink: 0;
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
  line-height: 1.3;
  text-align: right;
  /* STEP 38B.2 — pull time ~10px closer to label; keep right-column feel */
  padding-right: 10px;
}

/* Secondary operational status — quieter than Worked Today */
.today-visit-state-row {
  margin: 0 0 var(--today-rhythm-tight);
  padding: 0;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-tertiary);
  line-height: 1.35;
}

.today-visit-state-row[hidden] {
  display: none;
}

.today-visit-card:has(#dash-today-action[data-state="working"]) .today-visit-state-row {
  color: #248a3d;
}

/* Screen-reader / a11y hook label — JS still updates this text */
.today-visit-sr-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Existing #dash-today-action hook — now the primary CTA */
.dash-today-action.today-start-button,
.today-start-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 50px;
  height: 50px;
  margin: 0;
  padding: 0 16px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25);
  -webkit-appearance: none;
  appearance: none;
  transition:
    background-color 170ms var(--ease),
    box-shadow 170ms var(--ease),
    transform 170ms var(--ease);
}

.today-start-button:hover {
  background: #0077ed;
  box-shadow: 0 2px 6px rgba(10, 132, 255, 0.26);
}

.today-start-button:active {
  transform: scale(0.98);
  box-shadow: none;
}

.today-start-button:focus {
  outline: none;
}

.today-start-button:focus-visible {
  box-shadow:
    0 0 0 3px var(--accent-soft),
    0 1px 2px rgba(10, 132, 255, 0.25);
}

@media (prefers-reduced-motion: reduce) {
  .today-start-button {
    transition: none;
  }

  .today-start-button:active {
    transform: none;
  }
}

/* Shared lower-card text axis: marker | text | trailing */
.dash-lower-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  column-gap: 8px;
  align-items: center;
  width: 100%;
  box-sizing: border-box;
  padding-inline: 16px;
  padding-block: var(--dash-support-card-padding-y);
}

/* Supporting card family — identical collapsed resting height */
.dash-planning,
.dash-reference .dash-card.dash-lower-row,
.dash-stats-entry.dash-card {
  min-height: var(--dash-support-card-min-height);
  border-radius: 18px;
}

.dash-card-marker {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 14px;
  min-height: 1em;
  padding-top: 0.35em;
}

.dash-card-marker .pay-period-dot,
.dash-card-marker .status-symbol--current-period,
.dash-card-marker .status-symbol--previous-period {
  margin-top: 0;
}

.dash-lower-trailing {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  text-align: right;
}

/* Planning collapsed / expand — supporting, not a primary CTA */
.dash-planning {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 0;
  overflow: hidden;
  gap: 0;
  border: 1px solid rgba(60, 60, 67, 0.1);
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.035),
    0 2px 8px rgba(0, 0, 0, 0.03);
}

.dash-planning-toggle {
  min-height: calc(var(--dash-support-card-min-height) - 2px);
  padding-block: var(--dash-support-card-padding-y);
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: left;
  -webkit-appearance: none;
  appearance: none;
  box-sizing: border-box;
}

.dash-planning-toggle:focus {
  outline: none;
}

.dash-planning-toggle:focus:not(:focus-visible) {
  outline: none;
}

.dash-planning-toggle:focus-visible {
  outline: 2px solid rgba(10, 132, 255, 0.45);
  outline-offset: -2px;
  border-radius: 12px;
}

.dash-planning.is-expanded {
  border-color: rgba(10, 132, 255, 0.34);
  box-shadow:
    0 0 0 2px rgba(10, 132, 255, 0.12),
    0 1px 2px rgba(0, 0, 0, 0.035),
    0 2px 8px rgba(0, 0, 0, 0.03);
}

.dash-planning-status {
  font-size: 0.84rem;
  font-weight: 550;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.dash-planning-chevron {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-right: 1.75px solid var(--text-tertiary);
  border-bottom: 1.75px solid var(--text-tertiary);
  transform: rotate(45deg);
  transition: transform 160ms ease-out;
  margin-top: -3px;
}

.dash-planning.is-expanded .dash-planning-chevron {
  transform: rotate(-135deg);
  margin-top: 3px;
}

.dash-planning-detail {
  /* Align detail with shared text column (16 + 14 + 8). */
  padding: 0 16px 14px calc(16px + 14px + 8px);
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.dash-planning-detail[hidden] {
  display: none;
}

.dash-planning .dash-period-summary {
  margin-top: 12px;
  width: 100%;
  align-items: flex-end;
}

/* Reference section */
.dash-reference {
  display: flex;
  flex-direction: column;
  gap: var(--dash-section-gap);
}

.dash-reference-card.dash-lower-row {
  padding-block: var(--dash-support-card-padding-y);
  min-height: var(--dash-support-card-min-height);
}

.dash-reference-card .dash-period-main {
  display: contents;
}

/* Statistics entry (no preview metrics) */
.dash-stats-entry {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  column-gap: 8px;
  align-items: center;
  padding-block: var(--dash-support-card-padding-y);
  padding-inline: 16px;
  min-height: var(--dash-support-card-min-height);
  text-align: left;
  cursor: pointer;
  font: inherit;
  color: inherit;
  -webkit-appearance: none;
  appearance: none;
  border: 1px solid rgba(60, 60, 67, 0.1);
  box-sizing: border-box;
}

.dash-stats-entry:focus {
  outline: none;
}

.dash-stats-entry:focus:not(:focus-visible) {
  outline: none;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.035),
    0 2px 8px rgba(0, 0, 0, 0.03);
}

.dash-stats-entry:focus-visible {
  outline: 2px solid rgba(10, 132, 255, 0.45);
  outline-offset: 2px;
}

.dash-stats-entry-label {
  font-size: 0.95rem;
  font-weight: 550;
  color: var(--text);
  letter-spacing: -0.015em;
}

.dash-stats-entry-arrow {
  font-size: 1rem;
  color: var(--text-tertiary);
  line-height: 1;
}

.dash-authorized-label {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-secondary);
  min-width: 0;
  line-height: 1.25;
}

.dash-progress {
  margin-top: 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.progress-track {
  height: 6px;
  width: 100%;
  margin-inline: 0;
  border-radius: 999px;
  background: #e8eaed;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.progress-fill.is-animating {
  transition: width 250ms ease-out;
}

.dash-progress-caption {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
}

.dash-hero-suggested {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dash-hero-suggested-label {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
}

.dash-hero-suggested-value {
  font-size: 1.125rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}

@media (min-width: 720px) {
  .dash-hero {
    /* Horizontal inset only — match Today's Visit content axis (20px). */
    padding: 23px 20px;
  }
}

.dash-metrics {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--dash-section-gap);
}

.dash-metric {
  padding: 9px 16px 11px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 0;
}

.dash-metric-label {
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-secondary);
  line-height: 1.2;
}

.dash-metric-value {
  font-size: clamp(1.2rem, 2.8vw, 1.4rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.05;
  margin-top: 0;
}

.dash-periods {
  display: flex;
  flex-direction: column;
  gap: var(--dash-section-gap);
}

.dash-period-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 16px;
  min-width: 0;
}

.dash-period-card.dash-lower-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  justify-content: stretch;
  row-gap: 0;
  column-gap: 8px;
  padding-inline: 16px;
}

/* Keep Planning outer shell flush; padding lives on the toggle/detail. */
.dash-planning.dash-period-card-current {
  padding: 0;
  gap: 0;
}

.dash-period-main {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.dash-period-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.dash-period-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}

.dash-period-card:has(.pay-period-dot--previous) .dash-period-title,
.dash-period-card:has(.status-symbol--previous-period) .dash-period-title {
  font-weight: 500;
  color: var(--text-secondary);
}

.dash-period-range {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-tertiary);
  opacity: 0.85;
}

.dash-period-value {
  flex-shrink: 0;
  align-self: center;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
  text-align: right;
}

.dash-period-summary {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: center;
  gap: 0;
  flex-shrink: 0;
  min-width: 0;
}

.dash-period-status,
.dash-period-planning {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  min-width: 0;
  width: 100%;
}

.dash-period-divider {
  width: 100%;
  height: 0;
  margin: 7px 0;
  border: 0;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.dash-period-stat {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.dash-period-stat-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-tertiary);
  line-height: 1;
  white-space: nowrap;
}

.dash-period-stat-value {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
  text-align: right;
  min-width: 4.75rem;
}

.dash-period-stat-value.is-warning-message {
  white-space: normal;
  text-align: right;
  max-width: 9.5rem;
  min-width: 0;
}

.dash-period-forecast-caption {
  margin: 1px 0 0;
  max-width: 11.5rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.25;
  color: var(--text-tertiary);
  text-align: right;
}

.dash-period-forecast-caption[hidden] {
  display: none;
}

.dash-period-card-current {
  padding-top: 10px;
  padding-bottom: 10px;
  gap: 10px;
}

.dash-stats-preview:not(.dash-stats-entry) {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 16px 18px;
  text-align: left;
  cursor: pointer;
  transition: background-color 170ms ease-out;
}

.dash-stats-preview:not(.dash-stats-entry):hover {
  background: #fafbfc;
}

.dash-stats-preview:not(.dash-stats-entry):focus {
  outline: none;
}

.dash-stats-preview:not(.dash-stats-entry):focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Stats entry uses shared lower-row grid (not legacy preview flex). */
.dash-stats-preview.dash-stats-entry {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  flex-direction: unset;
  align-items: center;
  gap: unset;
  column-gap: 8px;
  padding-block: var(--dash-support-card-padding-y);
  padding-inline: 16px;
  min-height: var(--dash-support-card-min-height);
}

.dash-stats-preview-title {
  font-size: 0.72rem;
  font-weight: 650;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.dash-stats-preview-used {
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.1;
}

.dash-stats-preview-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  width: 100%;
}

.dash-stats-preview-average {
  justify-content: space-between;
}

.dash-stats-preview-label {
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.dash-stats-preview-value {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.dash-stats-preview-cta {
  margin-top: 2px;
  font-size: 0.8125rem;
  font-weight: 550;
  color: var(--accent);
  letter-spacing: -0.01em;
}

/* Brief highlight on values that just changed (Save update). */
.dash-hero-value.dash-value-flash,
.dash-hero-suggested-value.dash-value-flash,
.dash-metric-value.dash-value-flash,
.dash-period-value.dash-value-flash,
.dash-period-stat-value.dash-value-flash {
  border-radius: 6px;
  animation: dash-value-highlight 500ms ease-out forwards;
}

@keyframes dash-value-highlight {
  0% {
    background-color: rgba(10, 132, 255, 0.14);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.12);
  }
  100% {
    background-color: rgba(10, 132, 255, 0);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0);
  }
}

.dash-authorized {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 17px 16px;
}

/* Reassert grid after legacy .dash-authorized flex rules. */
.dash-authorized.dash-lower-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) auto;
  justify-content: stretch;
  align-items: center;
  row-gap: 0;
  column-gap: 8px;
  padding-block: var(--dash-support-card-padding-y);
  padding-inline: 16px;
  min-height: var(--dash-support-card-min-height);
  box-sizing: border-box;
}

.dash-authorized-label {
  font-size: 0.88rem;
  font-weight: 400;
  color: var(--text-secondary);
  min-width: 0;
  line-height: 1.25;
}

.dash-authorized-value {
  flex-shrink: 0;
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
  text-align: right;
}

@media (hover: hover) and (pointer: fine) {
  .dash-card:hover:not(.dash-hero):not(.dash-stats-entry):not(.dash-today-action):not(.today-visit-card):not(.dash-planning) {
    transform: translateY(-2px);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.055), 0 1px 3px rgba(0, 0, 0, 0.03);
    border-color: rgba(60, 60, 67, 0.14);
  }

  /* Planning: quiet hover — no lift, no outline. */
  .dash-planning:hover {
    transform: none;
    border-color: rgba(60, 60, 67, 0.1);
    box-shadow:
      0 1px 2px rgba(0, 0, 0, 0.035),
      0 2px 8px rgba(0, 0, 0, 0.03);
  }

  .popover-delete:hover {
    background: rgba(255, 59, 48, 0.08);
  }

  .popover-cancel:hover {
    background: #f2f3f5;
  }

  .popover-save:hover {
    background: #0077ed;
    box-shadow: 0 2px 6px rgba(10, 132, 255, 0.26);
  }
}

/* ——— Popover ——— */

.popover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 22, 28, 0.28);
  backdrop-filter: blur(2px);
  z-index: 40;
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.popover-backdrop.is-open {
  opacity: 1;
}

.day-popover {
  --popover-pad: 18px;
  position: fixed;
  z-index: 50;
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: var(--popover-pad);
  opacity: 0;
  transform: scale(0.97);
  transition:
    opacity 200ms ease-out,
    transform 200ms ease-out;
  pointer-events: none;
}

.day-popover.is-open {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}

.day-popover.is-sheet {
  /* Floating mobile panel — margins on all sides, not edge-flush */
  left: max(14px, env(safe-area-inset-left, 0px)) !important;
  right: max(14px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  top: auto !important;
  width: auto;
  max-width: 430px;
  margin-inline: auto;
  border-radius: 24px;
  padding: 20px;
  transform: translateY(calc(100% + 24px));
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.18),
    0 2px 10px rgba(0, 0, 0, 0.08);
  /* Viewport-safe flex column: form scrolls, footer stays */
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-sizing: border-box;
  max-height: calc(100vh - 28px);
  max-height: calc(100dvh - 28px);
  max-height: calc(100svh - 28px);
  max-height: calc(var(--sheet-visible-height, 100svh) - 28px);
}

.day-popover.is-sheet.is-open {
  transform: translateY(0);
}

.day-popover.is-sheet .popover-header {
  flex: 0 0 auto;
}

.day-popover.is-sheet .popover-form {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.day-popover.is-sheet .popover-footer {
  flex: 0 0 auto;
  margin-top: 12px;
  padding-top: 8px;
  background: var(--surface);
  box-shadow: 0 -1px 0 rgba(60, 60, 67, 0.08);
}

.popover-caret {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 14px;
  height: 14px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 1px solid var(--border);
  transform: translateX(-50%) rotate(45deg);
  pointer-events: none;
}

.day-popover.caret-below .popover-caret {
  top: auto;
  bottom: -7px;
  border-left: none;
  border-top: none;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.day-popover.is-sheet .popover-caret {
  display: none;
}

.popover-header {
  text-align: center;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.popover-weekday {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.popover-date {
  margin: 2px 0 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text);
}

.popover-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--text-secondary);
  background: rgba(60, 60, 67, 0.08);
}

.popover-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 0;
  max-width: 100%;
}

.popover-auth-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  line-height: 1.2;
  color: var(--warn);
  background: var(--warn-soft);
}

.popover-auth-warning[hidden] {
  display: none;
}

.popover-auth-warning-detail {
  margin: 4px 0 0;
  max-width: 16.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.3;
  text-align: center;
  color: var(--text-secondary);
}

.popover-auth-warning-detail[hidden] {
  display: none;
}

.popover-status[data-status="completed"] {
  color: #248a3d;
  background: rgba(52, 199, 89, 0.14);
}

.popover-status[data-status="completed"]::before {
  content: "✓";
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.popover-status[data-status="scheduled"] {
  color: #2a9dcc;
  background: rgba(90, 200, 250, 0.16);
}

.popover-status[data-status="incomplete"] {
  color: #c77c00;
  background: rgba(255, 159, 10, 0.14);
}

.popover-status[data-status="new"] {
  color: var(--text-tertiary);
  background: rgba(60, 60, 67, 0.08);
}

.popover-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.popover-entry-notice {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(10, 132, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

.popover-entry-notice[hidden] {
  display: none;
}

.popover-entry-notice.is-warning {
  background: rgba(255, 159, 10, 0.12);
  color: #9a5b00;
}

.popover-schedule-copy {
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(10, 132, 255, 0.08);
  color: var(--text-secondary);
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1.35;
}

.popover-schedule-copy[hidden] {
  display: none;
}

.day-popover.is-schedule-mode .popover-service-fields {
  display: none;
}

/* STEP 43.3A / 43.4B — compact plan-confirm mode (existing shell; presentation only) */
.popover-plan-confirm {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  padding: 0;
}

.popover-plan-confirm[hidden] {
  display: none !important;
}

.popover-plan-confirm-title {
  margin: 0 0 6px;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  text-align: center;
}

.popover-plan-confirm-date {
  margin: 0 0 8px;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text);
  text-align: center;
}

.popover-plan-confirm-copy {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.35;
  text-align: center;
  max-width: 100%;
}

.day-popover.is-plan-confirm-mode {
  padding: 16px;
}

.day-popover.is-plan-confirm-mode .popover-header,
.day-popover.is-plan-confirm-mode .popover-badges,
.day-popover.is-plan-confirm-mode .popover-auth-warning-detail,
.day-popover.is-plan-confirm-mode .popover-form,
.day-popover.is-plan-confirm-mode .popover-delete {
  display: none !important;
}

.day-popover.is-plan-confirm-mode .popover-schedule-alt {
  display: none !important;
}

/* Full-width balanced action row (plan-confirm only). */
.day-popover.is-plan-confirm-mode .popover-footer {
  margin-top: 14px;
  padding-top: 0;
  box-shadow: none;
}

.day-popover.is-plan-confirm-mode .popover-footer-actions {
  margin-left: 0;
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 0.45fr) minmax(0, 0.55fr);
  column-gap: 10px;
  align-items: stretch;
}

.day-popover.is-plan-confirm-mode .popover-cancel,
.day-popover.is-plan-confirm-mode .popover-save {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  justify-content: center;
}

.day-popover.is-sheet.is-plan-confirm-mode {
  padding: 16px;
}

.day-popover.is-sheet.is-plan-confirm-mode .popover-footer {
  margin-top: 14px;
  padding-top: 0;
  box-shadow: none;
}

.popover-schedule-alt {
  color: var(--accent);
  font-weight: 550;
  font-size: 0.84rem;
  background: transparent;
  padding-inline: 10px;
}

.popover-schedule-alt[hidden] {
  display: none;
}

.popover-error {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--danger);
  line-height: 1.3;
}

.popover-error[hidden] {
  display: none;
}

.popover-field input:disabled,
.popover-field select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  background: #eef0f3;
}

.popover-time-picker:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

.popover-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.popover-field label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.popover-field input,
.popover-field select {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 550;
  color: var(--text);
  background: #f7f8fa;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 11px 12px;
  min-height: 44px;
  width: 100%;
  appearance: none;
  transition:
    border-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease),
    background-color 0.18s var(--ease);
}

.popover-time-wrap {
  position: relative;
  display: block;
  width: 100%;
}

.popover-time-wrap input[type="time"] {
  padding-right: 44px;
}

/* Hide native indicator only when a custom picker button is present. */
.popover-time-wrap:has(.popover-time-picker) input[type="time"]::-webkit-calendar-picker-indicator {
  display: none;
}

.popover-time-picker {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.popover-time-picker:hover {
  color: var(--text-secondary);
  background: rgba(60, 60, 67, 0.06);
}

.popover-time-picker:focus {
  outline: none;
}

.popover-time-picker-icon {
  width: 18px;
  height: 18px;
  display: block;
}

.popover-field select {
  background-image: linear-gradient(45deg, transparent 50%, var(--text-tertiary) 50%),
    linear-gradient(135deg, var(--text-tertiary) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.popover-field input:hover,
.popover-field select:hover {
  background-color: #f2f4f7;
}

.popover-field input:focus,
.popover-field select:focus,
.popover-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.popover-btn:focus-visible {
  border-radius: 10px;
}

/* ——— Auth exceed save confirmation ——— */

.auth-exceed-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 22, 28, 0.34);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.auth-exceed-backdrop.is-open {
  opacity: 1;
}

.auth-exceed-backdrop[hidden] {
  display: none;
}

.auth-exceed-modal {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: min(320px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 20px 18px 16px;
  opacity: 0;
  transition:
    opacity 200ms ease-out,
    transform 200ms ease-out;
}

.auth-exceed-modal.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.auth-exceed-modal[hidden] {
  display: none;
}

.auth-exceed-title {
  margin: 0 0 10px;
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text);
  text-align: center;
}

.auth-exceed-copy {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 18px;
}

.auth-exceed-copy p {
  margin: 0;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-secondary);
  text-align: center;
}

.auth-exceed-emphasis {
  color: var(--warn);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.auth-exceed-actions {
  display: flex;
  align-items: center;
  justify-content: stretch;
  gap: 8px;
}

.auth-exceed-btn {
  flex: 1;
  min-height: 44px;
  margin: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition:
    background-color 0.18s var(--ease),
    box-shadow 0.18s var(--ease);
}

.auth-exceed-cancel {
  color: var(--text-secondary);
  background: rgba(60, 60, 67, 0.08);
}

.auth-exceed-cancel:hover {
  background: rgba(60, 60, 67, 0.12);
}

.auth-exceed-save {
  color: #fff;
  background: var(--warn);
  box-shadow: 0 1px 2px rgba(255, 159, 10, 0.28);
}

.auth-exceed-save:hover {
  background: #f09300;
}

.auth-exceed-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--warn-soft);
}

@media (prefers-reduced-motion: reduce) {
  .auth-exceed-backdrop,
  .auth-exceed-modal {
    transition: none;
  }
}

.day-popover .popover-service {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 6px;
  margin-top: 4px;
  padding: 18px 16px;
  border-radius: 12px;
  background: #f2f3f5;
  border: 1px solid transparent;
  width: 100%;
  box-sizing: border-box;
}

.day-popover .popover-service-label {
  display: block;
  width: 100%;
  font-size: 0.75rem;
  font-weight: 600;
  color: #8a8a8a;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1.2;
  text-align: left;
}

.day-popover .popover-service-value {
  display: block;
  width: 100%;
  font-size: 1.9375rem;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1.1;
  color: var(--text);
  text-align: left;
}

/* Authorization warning: value color only (not chrome) */
.popover-field input[type="time"].is-warning {
  color: var(--warn);
}

.day-popover .popover-service-value.is-warning {
  color: var(--warn);
}

.popover-footer {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  flex-wrap: nowrap;
  margin-top: 16px;
  padding-top: 4px;
}

.popover-footer-actions {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-wrap: nowrap;
}

.popover-btn {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 42px;
  border: 1px solid transparent;
  transition:
    background-color 160ms ease-out,
    transform 160ms ease-out,
    box-shadow 160ms ease-out,
    color 160ms ease-out;
}

.popover-btn:active {
  transform: scale(0.97);
}

.popover-delete,
.popover-cancel,
.popover-save {
  flex: 0 0 auto;
}

.popover-delete {
  color: var(--danger);
  font-weight: 550;
  font-size: 0.84rem;
  background: transparent;
}

/* New entry: hide Delete visually but keep its width in the row. */
.popover-delete[hidden] {
  display: inline-flex !important;
  align-items: center;
  visibility: hidden;
  pointer-events: none;
}

.popover-cancel {
  color: var(--text-secondary);
  background: transparent;
}

.popover-save {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25);
  padding-inline: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  white-space: nowrap;
}

.popover-save:active {
  box-shadow: none;
}

.popover-save:disabled {
  cursor: default;
  opacity: 1;
}

.popover-save.is-saving,
.popover-save.is-saved {
  pointer-events: none;
}

.popover-save.is-saving:active,
.popover-save.is-saved:active {
  transform: none;
}

.save-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: save-spin 0.55s linear infinite;
  flex-shrink: 0;
}

@keyframes save-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ——— Responsive ——— */

@media (max-width: 640px) {
  .app {
    padding: 10px 10px 16px;
    gap: 8px;
  }

  .calendar-section {
    min-height: 420px;
  }

  .day-cell {
    min-height: 64px;
    padding: 4px 2px 6px;
  }

  .day-number {
    width: 24px;
    height: 24px;
    font-size: 0.82rem;
  }

  .hours-full {
    display: none;
  }

  .hours-compact {
    display: inline;
  }

  .status-hours {
    font-size: 0.7rem;
  }

  .status-warning {
    font-size: 0.58rem;
  }

  .dash-metrics {
    gap: var(--dash-section-gap);
  }

  .dash-metric {
    padding: 8px 14px 10px;
  }

  .dash-period-card-current {
    align-items: flex-start;
    gap: 8px;
  }

  .dash-period-summary {
    gap: 0;
  }

  .dash-period-status,
  .dash-period-planning {
    gap: 4px;
  }

  .dash-period-divider {
    margin: 6px 0;
  }

  .dash-period-stat {
    gap: 6px;
  }

  .dash-period-stat-label {
    font-size: 0.68rem;
  }

  .dash-period-stat-value {
    font-size: 1.05rem;
    min-width: 4.4rem;
  }

  .dash-period-stat-value.is-warning-message {
    max-width: 8.75rem;
    font-size: 0.78rem;
  }

  .dash-period-forecast-caption {
    max-width: 9.75rem;
    font-size: 0.64rem;
  }

  .month-title {
    font-size: 1.4rem;
  }

  .day-popover.is-sheet .popover-field input,
  .day-popover.is-sheet .popover-field select,
  .day-popover.is-sheet .popover-btn {
    min-height: 48px;
    font-size: 1.02rem;
  }

  .day-popover.is-sheet .popover-cancel {
    background: #f2f3f5;
  }

  /*
   * STEP 41.3B/C — mobile hierarchical footer (Remove / Cancel / Keep).
   * Proportions ~25% / ~20% / ~55%. Unchanged by STEP 41.3D (tablet/desktop equal).
   */
  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden])) {
    display: grid;
    grid-template-columns: minmax(0, 2.5fr) minmax(0, 2fr) minmax(0, 5.5fr);
    column-gap: 8px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
  }

  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-footer-actions {
    display: contents;
  }

  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-delete,
  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-cancel,
  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-save {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: none;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    line-height: 1.2;
    min-height: 52px;
    height: 52px;
    padding: 0 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    border-radius: 10px;
  }

  /* STEP 41.3C — Remove: slightly heavier weight, perfectly centered */
  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-delete {
    font-size: 0.9375rem;
    font-weight: 700;
    align-items: center;
    justify-content: center;
    text-align: center;
  }

  /* STEP 41.3C — Keep: +6–8px horizontal breathing room only */
  .day-popover.is-sheet
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-save {
    padding-inline: 17px;
    white-space: nowrap;
  }

  /*
   * Today-only three-action footer (Save Schedule + Cancel + Save).
   * Activates only when sheet + schedule-alt visible. Non-Today two-action unchanged.
   */
  .day-popover.is-sheet .popover-footer.is-schedule-alt {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr) minmax(0, 1fr);
    column-gap: 12px;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    justify-content: stretch;
    padding-inline: 8px;
  }

  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-delete[hidden] {
    display: none !important;
  }

  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-footer-actions {
    display: contents;
  }

  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-schedule-alt {
    grid-column: 1;
    white-space: nowrap;
    width: max-content;
    max-width: 100%;
    min-width: 0;
    flex: none;
    padding-inline: 6px;
    box-sizing: border-box;
  }

  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-cancel,
  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-save {
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    padding-inline: 12px;
    justify-self: stretch;
  }

  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-cancel {
    grid-column: 2;
  }

  .day-popover.is-sheet .popover-footer.is-schedule-alt .popover-save {
    grid-column: 3;
  }
}

/* STEP 41.3D — tablet/desktop: equal-width Remove / Cancel / Keep */
@media (min-width: 641px) {
  .day-popover
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden])) {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: 8px;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
  }

  .day-popover
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-footer-actions {
    display: contents;
  }

  .day-popover
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-delete,
  .day-popover
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-cancel,
  .day-popover
    .popover-footer:not(.is-schedule-alt):has(> .popover-delete:not([hidden]))
    .popover-save {
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: none;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
  }
}

@media (min-width: 720px) {
  .day-cell {
    min-height: 88px;
  }
}

/* ——— Recipient Manager modal ——— */

.manager-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 22, 28, 0.28);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.manager-backdrop.is-open {
  opacity: 1;
}

.manager-backdrop[hidden] {
  display: none;
}

.recipient-manager {
  position: fixed;
  z-index: 70;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: min(360px, calc(100vw - 32px));
  max-height: min(80vh, 560px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  opacity: 0;
  transition:
    opacity 200ms ease-out,
    transform 200ms ease-out;
}

.recipient-manager.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.recipient-manager[hidden] {
  display: none;
}

.manager-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.manager-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.manager-add-btn {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 8px;
  outline: none;
  box-shadow: none;
}

.manager-add-btn:hover {
  background: var(--accent-soft);
}

/* Kill browser default (often orange) focus ring; keep a11y via :focus-visible. */
.manager-add-btn:focus {
  outline: none;
}

.manager-add-btn:focus:not(:focus-visible) {
  outline: none;
  box-shadow: none;
  border-color: var(--accent);
}

.manager-add-btn:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.manager-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manager-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
  padding: 12px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fafbfc;
}

.manager-row-main {
  min-width: 0;
}

.manager-row-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.manager-row-name {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.manager-row-meta {
  display: block;
  margin-top: 3px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.manager-row-status {
  flex: 0 0 auto;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #e8f2ff;
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.01em;
}

.manager-row-edit {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
  flex-shrink: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.84rem;
  font-weight: 600;
  padding: 8px 6px;
  cursor: pointer;
  border-radius: 8px;
  white-space: nowrap;
}

.manager-row-edit:hover {
  background: var(--accent-soft);
}

.manager-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 14px;
}

.manager-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.manager-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.manager-field label,
.manager-field-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.manager-field input {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
}

.manager-field input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.manager-authorized-field {
  display: flex;
  align-items: stretch;
  min-height: 42px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: #fff;
  overflow: hidden;
}

.manager-authorized-field:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.manager-authorized-field.is-invalid {
  border-color: var(--danger);
}

.manager-authorized-field.is-invalid:focus-within {
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.16);
}

.manager-authorized-segment {
  display: flex;
  align-items: center;
  flex: 1 1 0;
  min-width: 0;
  padding: 0 10px;
  gap: 2px;
}

.manager-authorized-segment input {
  width: 100%;
  min-width: 0;
  min-height: 40px;
  padding: 8px 0;
  border: none;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.manager-authorized-segment input:focus,
.manager-authorized-segment input:focus-visible {
  outline: none;
  border: none;
  box-shadow: none;
}

.manager-authorized-unit {
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.manager-authorized-divider {
  width: 1px;
  align-self: stretch;
  margin: 8px 0;
  background: var(--border);
  flex-shrink: 0;
}

/*
 * Resting / unfocused: compact left-aligned "90h 12m".
 * Applies only when at least one segment has a value so an empty
 * field keeps the separated placeholder layout (never bare "h m").
 * Editing layout is restored immediately via :focus-within.
 */
.manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown)) {
  justify-content: flex-start;
  align-items: center;
  column-gap: 6px;
  gap: 6px;
  /* Match .manager-field input horizontal inset (10px 12px). */
  padding-inline: 12px;
}

.manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
  .manager-authorized-segment {
  flex: 0 0 auto;
  width: auto;
  min-width: 0;
  max-width: none;
  padding: 0;
  margin: 0;
  gap: 2px;
}

.manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
  .manager-authorized-segment input {
  /* Intrinsic compact width; ch max prevents overflow. */
  field-sizing: content;
  width: auto;
  min-width: 1ch;
  max-width: 3ch;
  flex: 0 0 auto;
  text-align: left;
  padding-inline: 0;
}

.manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
  .manager-authorized-segment:last-child input {
  max-width: 2ch;
}

@supports not (field-sizing: content) {
  /* Fixed ch widths keep digits readable; right-align keeps number flush to unit. */
  .manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
    .manager-authorized-segment input {
    width: 3ch;
    min-width: 3ch;
    max-width: 3ch;
    text-align: right;
  }

  .manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
    .manager-authorized-segment:last-child input {
    width: 2ch;
    min-width: 2ch;
    max-width: 2ch;
  }
}

.manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
  .manager-authorized-divider {
  display: none;
}

/*
 * Partial empty (e.g. hours filled, minutes blank): collapse the empty
 * segment so resting never shows a lone "h"/"m" or a misleading placeholder.
 * The input stays in the tab order; :focus-within restores the full layout.
 */
.manager-authorized-field:not(:focus-within):has(input:not(:placeholder-shown))
  .manager-authorized-segment:has(input:placeholder-shown) {
  flex: 0 0 0;
  width: 0;
  min-width: 0;
  max-width: 0;
  padding: 0;
  margin: 0;
  gap: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.manager-error {
  margin: 0;
  font-size: 0.75rem;
  color: var(--danger);
  font-weight: 500;
}

.manager-error[hidden] {
  display: none;
}

.manager-hint {
  margin: 0;
  font-size: 0.75rem;
  color: var(--text-tertiary);
  font-weight: 400;
  line-height: 1.3;
}

.manager-hint[hidden] {
  display: none;
}

.manager-form-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.manager-btn {
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.manager-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.manager-btn-ghost {
  color: var(--text-secondary);
  background: transparent;
}

.manager-btn-ghost:hover {
  background: #f2f3f5;
}

.manager-btn-primary {
  color: #fff;
  background: var(--accent);
  box-shadow: 0 1px 2px rgba(10, 132, 255, 0.25);
}

.manager-btn-primary:hover:not(:disabled) {
  background: #0077ed;
}

.manager-btn-danger {
  width: 100%;
  margin-top: 10px;
  color: var(--danger);
  background: transparent;
  border-top: 1px solid var(--border);
  border-radius: 0;
  padding-top: 14px;
}

.manager-btn-danger:hover {
  background: rgba(255, 59, 48, 0.08);
}

#manager-confirm-delete.manager-btn-danger {
  width: auto;
  margin-top: 0;
  border-top: none;
  border-radius: 10px;
  padding: 10px 14px;
  background: rgba(255, 59, 48, 0.1);
}

.manager-confirm-copy {
  margin: 0 0 16px;
  font-size: 0.9rem;
  line-height: 1.45;
  color: var(--text-secondary);
}

@media (prefers-reduced-motion: reduce) {
  .manager-backdrop,
  .recipient-manager {
    transition: none;
  }
}

/* ——— Settings modal ——— */

.settings-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 22, 28, 0.28);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 200ms ease-out;
}

.settings-backdrop.is-open {
  opacity: 1;
}

.settings-backdrop[hidden] {
  display: none;
}

.settings-modal {
  position: fixed;
  z-index: 90;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -48%) scale(0.98);
  width: min(360px, calc(100vw - 32px));
  max-height: min(80vh, 560px);
  overflow: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px;
  opacity: 0;
  transition:
    opacity 200ms ease-out,
    transform 200ms ease-out;
}

.settings-modal.is-open {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.settings-modal[hidden] {
  display: none;
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.settings-title {
  margin: 0;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}

.settings-section {
  margin: 0;
}

.settings-section-label {
  margin: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.settings-rows {
  margin: 0;
  padding: 0;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 46px;
  padding: 0;
}

.settings-row + .settings-row {
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.settings-row-label {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 400;
  color: var(--text-secondary);
}

.settings-row-value {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.settings-export-block {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.settings-action-row {
  align-items: center;
}

.settings-action-btn {
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent);
  text-align: left;
  cursor: pointer;
  outline: none;
}

.settings-action-btn:hover {
  text-decoration: underline;
}

.settings-action-btn:focus {
  outline: none;
}

.settings-action-btn:focus-visible {
  border-radius: 4px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.settings-action-status {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  text-align: right;
  min-height: 1.2em;
}

.settings-action-status.is-error {
  color: var(--danger);
}

.settings-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 24px;
  padding-top: 0;
}

.settings-done-btn {
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  outline: none;
}

.settings-done-btn:hover {
  background: rgba(60, 60, 67, 0.05);
}

.settings-done-btn:focus {
  outline: none;
}

.settings-done-btn:focus-visible {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

@media (prefers-reduced-motion: reduce) {
  .settings-backdrop,
  .settings-modal {
    transition: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .day-cell,
  .nav-btn,
  .popover-btn,
  .dash-card,
  .day-popover,
  .popover-backdrop,
  .recipient-selector {
    transition-property: opacity, background-color, box-shadow, border-color, color;
  }

  .progress-fill.is-animating {
    transition: none;
  }

  .save-spinner {
    animation: none;
    opacity: 0.9;
  }

  .dash-hero-value.dash-value-flash,
  .dash-hero-suggested-value.dash-value-flash,
  .dash-metric-value.dash-value-flash,
  .dash-period-value.dash-value-flash,
  .dash-period-stat-value.dash-value-flash {
    animation: none;
  }

  .day-cell:not(.empty-slot):active,
  .day-cell:not(.empty-slot):hover,
  .day-cell:not(.empty-slot):hover:active,
  .nav-btn:hover,
  .nav-btn:active,
  .popover-btn:active,
  .dash-card:hover,
  .day-popover,
  .day-popover.is-open,
  .day-popover.is-sheet,
  .day-popover.is-sheet.is-open {
    transform: none;
  }
}

/* ——— Statistics ——— */

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.stats-nav-btn {
  flex-shrink: 0;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 0.875rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  transition: background-color 170ms ease-out, color 170ms ease-out;
}

.stats-nav-btn:hover {
  color: var(--text);
  background: rgba(60, 60, 67, 0.06);
}

.stats-nav-btn:focus {
  outline: none;
}

.stats-nav-btn:focus-visible {
  color: var(--text);
  background: rgba(60, 60, 67, 0.06);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.app[data-view="statistics"] #planner-view,
.app[data-view="statistics"] #planner-month-bar,
.app[data-view="statistics"] #plan-visits-row {
  display: none;
}

.app[data-view="statistics"] #statistics-view {
  display: flex;
}

/* Statistics-only: widen outer shell on tablet/desktop; mobile unchanged */
@media (min-width: 641px) {
  .app[data-view="statistics"] {
    padding-left: 12px;
    padding-right: 12px;
  }
}

@media (min-width: 920px) {
  .app[data-view="statistics"] {
    max-width: 1100px;
  }
}

.statistics-view {
  display: none;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
  --stats-section-gap: 10px;
  --stats-row-card-height: 80px;
  --stats-row-card-pad-y: 16px;
  --stats-row-card-pad-x: 20px;
  /* Shared lower-card horizontal rhythm (STEP 45.3A) */
  --stats-lower-card-pad-x: var(--stats-row-card-pad-x);
  /* Shared pay-period status-dot / text-column contract (STEP 45.2C/D) */
  --stats-dot-size: 8px;
  --stats-status-dot-size: var(--stats-dot-size);
  --stats-status-dot-top: 4px;
  --stats-ring-track: #eef1f4;
  /* Scoped muted text for activity legend/weekdays (contrast safety) */
  --stats-activity-muted: #6e6e73;
  --stats-status-on-track: #148030;
  --stats-delta-positive: #148030;
  --stats-delta-negative: #dc3228;
}

.stats-header {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0 0 6px;
}

.stats-header-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stats-header-text {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.stats-title {
  margin: 0;
  font-size: 1.3125rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
  line-height: 1.15;
}

.stats-meta {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
}

.stats-month-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-top: 2px;
}

.stats-scroll {
  display: flex;
  flex-direction: column;
  gap: var(--stats-section-gap);
  padding-bottom: 28px;
}

.stats-card {
  background: var(--surface);
  border: none;
  border-radius: calc(var(--radius) + 2px);
  padding: 18px 16px;
  box-shadow: 0 1px 0 rgba(60, 60, 67, 0.04);
}

.stats-section-title {
  margin: 0 0 12px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1.2;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.stats-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 22px 16px 20px;
}

.stats-hero-ring-wrap {
  position: relative;
  width: clamp(188px, 42vw, 216px);
  aspect-ratio: 1;
  flex-shrink: 0;
}

.stats-ring {
  display: block;
  width: 100%;
  height: 100%;
}

.stats-ring-track {
  stroke: var(--stats-ring-track);
  stroke-width: 7;
  stroke-linecap: round;
}

.stats-ring-fill {
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  transition: stroke-dasharray 420ms var(--ease);
}

.stats-ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  pointer-events: none;
  text-align: center;
  padding: 18px;
}

.stats-ring-kicker,
.stats-ring-caption {
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
  line-height: 1.2;
}

.stats-ring-hours {
  margin: 2px 0 4px;
  font-size: clamp(1.75rem, 6.5vw, 2.125rem);
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.stats-used-pct {
  font-size: clamp(1.125rem, 4.2vw, 1.25rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 1.1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stats-used-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: var(--text-tertiary);
}

.stats-ring-legend {
  margin: 0;
  width: min(360px, 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 25px;
  flex-wrap: wrap;
}

.stats-ring-legend-item {
  margin: 0;
  min-width: 0;
}

.stats-ring-legend-item dd {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  font-weight: 550;
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  white-space: nowrap;
}

.stats-ring-legend-text {
  font-weight: 450;
  color: #747478;
  margin-inline-start: 3px;
  line-height: 1;
}

.stats-ring-legend-dot {
  width: var(--stats-dot-size);
  height: var(--stats-dot-size);
  border-radius: 50%;
  flex: 0 0 var(--stats-dot-size);
  align-self: center;
  translate: 0 0.5px;
}

.stats-ring-legend-dot.is-authorized {
  background: var(--accent);
}

.stats-ring-legend-dot.is-remaining {
  background: var(--text-secondary);
}

.stats-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  background: var(--surface);
  border-radius: calc(var(--radius) + 2px);
  box-shadow: 0 1px 0 rgba(60, 60, 67, 0.04);
  padding: 14px 8px 16px;
  overflow: hidden;
}

.stats-metric {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 4px 6px;
  min-width: 0;
  text-align: center;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
}

.stats-metric-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  color: var(--accent);
  margin-bottom: 2px;
}

.stats-metric-icon svg {
  display: block;
}

.stats-metric-value {
  font-size: clamp(0.9375rem, 3.4vw, 1.125rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
}

.stats-metric-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.stats-comparison {
  padding: 18px var(--stats-lower-card-pad-x, var(--stats-row-card-pad-x, 20px)) 18px;
}

.stats-comparison-header {
  margin-bottom: 4px;
}

.stats-comparison-heading .stats-section-title {
  margin-bottom: 4px;
}

.stats-comparison-vs {
  margin: 0 0 10px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: -0.01em;
}

.stats-comparison-list {
  margin: 0;
}

.stats-comparison-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-top: 1px solid #f1f5f9;
}

.stats-comparison-row:first-child {
  border-top: none;
}

.stats-comparison-row dt.stats-status-lead {
  display: block;
  min-width: 0;
}

.stats-comparison-label {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.015em;
}

.stats-comparison-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

.stats-comparison-row dd {
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.stats-comparison-value {
  font-size: 0.9375rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.stats-comparison-delta {
  font-size: 0.875rem;
  font-weight: 550;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--stats-delta-positive, #148030);
}

.stats-comparison-delta.is-negative {
  color: var(--stats-delta-negative, #dc3228);
}

.stats-weekly {
  padding: 20px var(--stats-lower-card-pad-x, var(--stats-row-card-pad-x, 20px)) 18px;
}

.stats-activity {
  padding: 18px var(--stats-lower-card-pad-x, var(--stats-row-card-pad-x, 20px));
}

.stats-weekly-chart {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  min-height: 140px;
}

.stats-week-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.stats-week-bar-track {
  width: 100%;
  max-width: 37px;
  height: 104px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border-radius: 8px;
  background: rgba(60, 60, 67, 0.04);
  overflow: hidden;
}

.stats-week-bar {
  width: 100%;
  min-height: 0;
  border-radius: 8px 8px 0 0;
  background: var(--accent);
  transition: height 420ms var(--ease);
}

.stats-week-bar.is-zero {
  min-height: 3px;
  background: rgba(60, 60, 67, 0.12);
  border-radius: 8px;
}

.stats-week-label {
  display: block;
  width: 100%;
  font-size: 0.75rem;
  font-weight: 550;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

.stats-week-hours {
  display: block;
  width: 100%;
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.25;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.stats-activity-weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  margin-bottom: 6px;
}

.stats-activity-weekdays span {
  text-align: center;
  font-size: 0.64rem;
  font-weight: 600;
  color: var(--stats-activity-muted, #6e6e73);
  line-height: 1;
}

.stats-activity-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
  padding-block: 1px;
}

.stats-activity-cell {
  min-height: 26px;
  min-width: 0;
  border-radius: 7px;
  border: 1px solid transparent;
  background: rgba(60, 60, 67, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 1px 2px;
  color: var(--text-secondary);
  font-size: 0.625rem;
  font-weight: 600;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stats-activity-cell.empty-slot {
  visibility: hidden;
}

.stats-activity-cell.is-future {
  opacity: 0.42;
}

.stats-activity-cell.is-scheduled {
  border-color: rgba(90, 200, 250, 0.55);
  background: var(--scheduled-soft);
}

.stats-activity-cell.is-incomplete {
  border-color: rgba(255, 159, 10, 0.65);
  background: var(--warn-soft);
}

.stats-activity-cell.is-completed.is-light {
  background: rgba(10, 132, 255, 0.16);
  color: var(--text);
}

.stats-activity-cell.is-completed.is-medium {
  background: rgba(10, 132, 255, 0.32);
  color: var(--text);
}

.stats-activity-cell.is-completed.is-strong {
  background: rgba(10, 132, 255, 0.52);
  color: var(--text);
}

.stats-activity-marker {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
}

.stats-activity-cell.is-scheduled .stats-activity-marker {
  background: transparent;
  border: 1.25px solid var(--scheduled);
}

.stats-activity-cell.is-incomplete .stats-activity-marker {
  background: var(--warn);
}

.stats-activity-cell.is-completed .stats-activity-marker {
  background: currentColor;
}

.stats-activity-cell.is-none .stats-activity-marker {
  opacity: 0;
}

.stats-activity-legend {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  font-size: 0.64rem;
  color: var(--stats-activity-muted, #6e6e73);
  line-height: 1.2;
}

.stats-activity-legend li {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.stats-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 4px;
  border: 1px solid transparent;
  background: rgba(60, 60, 67, 0.04);
  flex-shrink: 0;
}

.stats-legend-swatch.is-scheduled {
  border-color: rgba(90, 200, 250, 0.55);
  background: var(--scheduled-soft);
}

.stats-legend-swatch.is-incomplete {
  border-color: rgba(255, 159, 10, 0.65);
  background: var(--warn-soft);
}

.stats-legend-swatch.is-light {
  background: rgba(10, 132, 255, 0.16);
}

.stats-legend-swatch.is-medium {
  background: rgba(10, 132, 255, 0.32);
}

.stats-legend-swatch.is-strong {
  background: rgba(10, 132, 255, 0.52);
}


.stats-insights {
  padding: 16px;
}

.stats-planning {
  padding: 20px var(--stats-lower-card-pad-x, var(--stats-row-card-pad-x, 20px));
}

.stats-planning-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

/* Heading-only planning cards (no metrics grid) keep the same header, without trailing gap. */
.stats-planning-header:not(:has(+ .stats-planning-grid)) {
  margin-bottom: 0;
}

/*
 * Shared pay-period status lead (STEP 45.2C).
 * Guide B (text): content starts at the card’s left padding edge.
 * Guide A (dots): centered in the left padding — outside the text flow.
 * Used by Comparison rows and Current Pay Period / Attention cards.
 */
.stats-status-lead {
  position: relative;
  min-width: 0;
}

.stats-status-lead > .status-symbol--current-period,
.stats-status-lead > .status-symbol--previous-period,
.stats-status-lead > .status-symbol--attention {
  position: absolute;
  top: var(--stats-status-dot-top, 4px);
  left: calc(
    (0px - var(--stats-row-card-pad-x, 20px) - var(--stats-status-dot-size, var(--stats-dot-size, 8px))) /
      2
  );
  margin-top: 0;
  width: var(--stats-status-dot-size, var(--stats-dot-size, 8px));
  height: var(--stats-status-dot-size, var(--stats-dot-size, 8px));
  flex: 0 0 var(--stats-status-dot-size, var(--stats-dot-size, 8px));
  border-radius: 50%;
  flex-shrink: 0;
  box-sizing: border-box;
}

.stats-status-lead-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stats-planning-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: start;
}

.stats-period-heading-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  grid-column: 1;
}

.stats-comparison .stats-status-lead-text {
  gap: 4px;
}

.stats-planning-heading .stats-section-title {
  margin: 0 0 4px;
  text-transform: none;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
}

.stats-planning-period-label {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.stats-planning-period-range {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
  line-height: 1.4;
  margin-top: 2px;
}

.stats-planning-status {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  flex-shrink: 0;
  padding-top: 2px;
}

.stats-planning-status-label {
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  line-height: 1;
}

.stats-planning-status-value {
  font-size: 0.8125rem;
  font-weight: 650;
  color: var(--stats-status-on-track, #148030);
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.stats-planning-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: 28px;
  row-gap: 0;
  align-items: start;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
  padding-top: 16px;
}

.stats-planning-metric {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.stats-planning-metric:nth-child(1) {
  text-align: left;
  justify-self: start;
}

.stats-planning-metric:nth-child(2) {
  text-align: center;
  justify-self: center;
}

.stats-planning-metric:nth-child(3) {
  text-align: right;
  justify-self: end;
}

.stats-planning-label {
  font-size: 0.6875rem;
  font-weight: 500;
  color: var(--text-tertiary);
  letter-spacing: 0.01em;
  line-height: 1.25;
}

.stats-planning-value {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1.1;
}

.stats-previous-period .dash-period-card {
  min-height: var(--stats-row-card-height);
  height: var(--stats-row-card-height);
  padding: var(--stats-row-card-pad-y) var(--stats-row-card-pad-x);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stats-previous-period .stats-planning-heading {
  flex: 1;
  min-width: 0;
}

.stats-previous-period-title {
  color: var(--text-secondary);
  font-weight: 500;
}

.stats-previous-period .pay-period-dot,
.stats-previous-period .status-symbol--previous-period {
  margin-top: 4px;
}

.stats-previous-period .dash-period-value {
  font-size: 1.0625rem;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

@media (max-width: 520px) {
  .statistics-view {
    --stats-row-card-pad-x: 16px;
    --stats-lower-card-pad-x: 16px;
    --stats-mobile-dot-size: 8px;
    --stats-mobile-dot-gap: 8px;
  }

  .stats-planning {
    padding: 18px var(--stats-lower-card-pad-x, 16px);
  }

  /*
   * STEP 45.2D — Real iPhone Safari: in-flow shared status grid.
   * Negative absolute gutters are clipped by WebKit when the lead sits in a
   * flex item with min-width: 0 (Comparison rows). Keep dots in normal flow.
   */
  .stats-status-lead,
  .stats-comparison-row dt.stats-status-lead,
  .stats-planning-heading.stats-status-lead {
    display: grid;
    grid-template-columns: var(--stats-mobile-dot-size) minmax(0, 1fr);
    column-gap: var(--stats-mobile-dot-gap);
    align-items: start;
    overflow: visible;
  }

  .stats-status-lead > .status-symbol--current-period,
  .stats-status-lead > .status-symbol--previous-period,
  .stats-status-lead > .status-symbol--attention {
    position: static;
    top: auto;
    left: auto;
    margin-top: var(--stats-status-dot-top, 4px);
    width: var(--stats-mobile-dot-size);
    height: var(--stats-mobile-dot-size);
    flex: 0 0 var(--stats-mobile-dot-size);
    align-self: start;
  }

  .stats-status-lead-text,
  .stats-period-heading-text {
    grid-column: auto;
    min-width: 0;
  }

  .stats-comparison-row {
    overflow: visible;
  }

  /* STEP 45.3A — balanced 3+3 legend wrap on narrow phones */
  .stats-activity-legend {
    display: grid;
    grid-template-columns: repeat(3, max-content);
    column-gap: 12px;
    row-gap: 8px;
    justify-content: start;
  }

  .stats-previous-period .dash-period-card {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stats-planning-header {
    margin-bottom: 16px;
  }

  .stats-planning-header:not(:has(+ .stats-planning-grid)) {
    margin-bottom: 0;
  }

  .stats-planning-grid {
    grid-template-columns: 1fr;
    column-gap: 0;
    row-gap: 0;
    padding-top: 14px;
  }

  .stats-planning-metric {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 40px;
    padding: 10px 0;
    box-sizing: border-box;
    text-align: left;
    justify-self: stretch;
    border-bottom: 1px solid rgba(60, 60, 67, 0.06);
  }

  .stats-planning-metric:last-child {
    border-bottom: none;
  }

  .stats-planning-metric:nth-child(1),
  .stats-planning-metric:nth-child(2),
  .stats-planning-metric:nth-child(3) {
    text-align: left;
    justify-self: stretch;
  }
}


/* Needs Attention: same planning card/heading template; content + warn accents only. */
.stats-attention .stats-planning-heading .stats-section-title {
  color: var(--warn);
}

.stats-attention .stats-planning-period-range {
  white-space: pre-line;
}

.stats-placeholder {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 14px 4px;
  border-top: 1px solid rgba(60, 60, 67, 0.08);
}

.stats-placeholder .stats-section-title {
  margin-bottom: 2px;
  text-transform: none;
  letter-spacing: -0.01em;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-tertiary);
}

.stats-placeholder-copy {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 400;
  color: #a1a1a6;
  letter-spacing: -0.01em;
}

@media (min-width: 720px) {
  .stats-scroll {
    gap: var(--stats-section-gap);
    padding-bottom: 28px;
  }

  .stats-hero {
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 28px 20px 24px;
  }

  .stats-hero-ring-wrap {
    width: 216px;
  }

  .stats-metrics {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0;
    padding: 16px 12px 18px;
  }

  .stats-metric {
    padding: 6px 8px;
  }

  .stats-weekly-chart {
    gap: 14px;
    min-height: 156px;
  }

  .stats-week-bar-track {
    max-width: 48px;
    height: 116px;
  }

  .stats-placeholder {
    padding: 16px 6px;
  }
}

@media (max-width: 520px) {
  .stats-hero {
    justify-content: center;
    gap: 16px;
    padding: 18px 14px 16px;
  }

  .stats-hero-ring-wrap {
    width: min(200px, 58vw);
  }

  .stats-metrics {
    padding: 12px 4px 14px;
  }

  .stats-metric {
    padding: 4px 2px;
  }

  .stats-metric-value {
    font-size: 0.875rem;
  }

  .stats-metric-label {
    font-size: 0.6875rem;
  }

  .stats-ring-legend {
    gap: 23px;
  }

  .stats-activity-cell {
    min-height: 28px;
    font-size: 0.64rem;
  }

  .stats-activity-weekdays span {
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stats-ring-fill,
  .stats-week-bar {
    transition: none;
  }

  .stats-nav-btn {
    transition: none;
  }
}
