/* RC-B / FS-A compact glance strip, cardless day crumbs, selected-range chrome. */
.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;
}

#calendarFreshness {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

#calendarGlanceStrip,
.calendar-glance-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
  max-height: 140px;
  overflow: hidden;
  scroll-snap-type: none;
}

#calendarGlanceStrip.is-stacked {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: 160px;
}

#calendarGlanceStrip.is-single-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.glance-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  min-width: 0;
  min-height: 52px;
  max-height: 72px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  box-shadow: none;
  touch-action: manipulation;
}

.glance-kicker {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.glance-value {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font: 800 16px/1.15 Manrope, sans-serif;
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.glance-meta {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.glance-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 16%, var(--card));
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .03em;
  text-transform: uppercase;
  vertical-align: middle;
}

.glance-card > .glance-chip {
  position: absolute;
  top: 7px;
  right: 8px;
  margin-left: 0;
}

.glance-card.is-projected .glance-value {
  color: color-mix(in srgb, var(--ink) 82%, var(--muted));
}

#calendarGlanceStrip .sts-meta,
#calendarGlanceStrip .sts-disclaimer,
#calendarGlanceStrip #calendarSafeToSpendAsOf,
#calendarGlanceStrip #calendarSafeToSpendHint,
#calendarGlanceStrip #calendarSafeToSpendConfidence,
#calendarGlanceStrip #calendarSafeToSpendDisclaimer {
  display: none !important;
}

#calendarGlanceStrip #calendarRailSts {
  margin-bottom: 0;
  cursor: pointer;
}

#calendarRailAccounts,
#calendarView .account-forecast-tile,
#calendarView .household-total-card {
  display: none !important;
}

#calendarRailBuffer .calendar-buffer-control {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

#calendarRailBuffer .calendar-buffer-control input {
  min-height: 44px;
  padding: 8px;
}

.calendar-insight-band {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 48px;
  max-height: 56px;
  margin: 10px 0 0;
  padding: 0 2px;
  color: var(--muted);
  font-size: 12px;
}

.calendar-insight-band strong {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.range-matrix {
  display: grid;
  gap: 0;
  margin: 0 0 12px;
}

.range-matrix-heading {
  margin: 0 0 8px;
  color: var(--muted);
  font: 750 12px/1.3 "DM Sans", sans-serif;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.range-matrix-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-height: 36px;
  padding: 6px 0;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}

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

.range-matrix-row dd {
  margin: 0;
  font: 800 13px/1.2 Manrope, sans-serif;
  font-variant-numeric: tabular-nums;
}

#calendarView .calendar .event.event-crumb {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 2px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 0;
  height: auto;
  margin: 1px 0 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  color: inherit;
  font-size: 12px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
}

#calendarView .calendar .event.event-crumb .event-name,
#calendarView .calendar .event.event-crumb .cs-calendar-item-title {
  display: block;
  min-width: 0;
  max-width: none;
  overflow: hidden;
  color: inherit;
  font-size: inherit;
  font-weight: 650;
  line-height: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#calendarView .calendar .event.event-crumb .event-amount {
  display: block;
  flex-shrink: 0;
  justify-self: end;
  min-width: max-content;
  overflow: visible;
  color: inherit;
  font-size: inherit;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  line-height: inherit;
  white-space: nowrap;
}

#calendarView .calendar .event.event-crumb .event-status,
#calendarView .calendar .event.event-crumb .event-visual,
#calendarView .calendar .event.event-crumb .mini-bank,
#calendarView .calendar .event.event-crumb .bank-avatar {
  display: none !important;
}

#calendarView .calendar .event.event-crumb.income { color: #08704c; }
#calendarView .calendar .event.event-crumb.expense { color: #b3372c; }
#calendarView .calendar .more {
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.15;
}

/* Calendar-only Compact denser type — does not change global CashShield fonts. */
html[data-calendar-text="compact"] #calendarView .calendar .day {
  padding: 4px;
}
html[data-calendar-text="compact"] #calendarView .calendar .day-number {
  font-size: 12px;
  line-height: 1.15;
}
html[data-calendar-text="compact"] #calendarView .calendar .event.event-crumb {
  font-size: 11px;
  line-height: 1.12;
  margin-top: 1px;
  min-height: 0;
  padding: 0 !important;
}
html[data-calendar-text="compact"] #calendarView .calendar .event.event-crumb .event-name,
html[data-calendar-text="compact"] #calendarView .calendar .event.event-crumb .event-amount {
  font-size: 11px;
  line-height: 1.12;
}
html[data-calendar-text="compact"] #calendarView .calendar .more,
html[data-calendar-text="compact"] #calendarView .calendar .day-projected-balance {
  font-size: 10px;
  line-height: 1.15;
}

.calendar .day-total,
.calendar .day-projected-balance {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  margin-top: auto;
  padding-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.calendar .day-projected-arrow { font-size: 11px; font-weight: 800; }
.calendar .day-projected-amount { color: var(--muted); }
.calendar .day-projected-balance.is-above,
.calendar .day-projected-balance.is-above .day-projected-arrow,
.calendar .day-projected-balance.is-above .day-projected-amount { color: #08704c; }
.calendar .day-projected-balance.is-below,
.calendar .day-projected-balance.is-below .day-projected-arrow,
.calendar .day-projected-balance.is-below .day-projected-amount { color: #b3372c; }
.calendar .day-projected-balance.is-zero .day-projected-arrow { display: none; }

#calendarView .calendar .day.today {
  box-shadow: none;
  background: var(--card);
}
body[data-theme="midnight"] #calendarView .calendar .day.today:not(.is-selected):not(.agenda-selected) {
  box-shadow: none;
  background: color-mix(in srgb, #12162b 88%, #2a3158);
}
body[data-theme="cloud"] #calendarView .calendar .day.today:not(.is-selected):not(.agenda-selected) {
  box-shadow: none;
}
#calendarView .calendar .day.today .day-number {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  min-height: 22px;
  padding: 0 5px;
  border-radius: 999px;
  background: transparent;
  box-shadow: inset 0 0 0 1.5px #3164f4;
  color: inherit;
}

#calendarView .calendar .day.is-selected .day-number,
#calendarView .calendar .day.agenda-selected .day-number {
  background: #3164f4;
  box-shadow: none;
  color: #fff;
}

#calendarView .calendar .day.today.is-selected .day-number,
#calendarView .calendar .day.today.agenda-selected .day-number {
  background: #3164f4;
  color: #fff;
  box-shadow: inset 0 0 0 2px #fff, 0 0 0 1.5px #3164f4;
}

#calendarView .calendar .day.is-range {
  background: color-mix(in srgb, #3164f4 8%, var(--card));
}

#calendarView .calendar .day.is-selected,
#calendarView .calendar .day.agenda-selected {
  background: color-mix(in srgb, #3164f4 16%, var(--card));
  box-shadow: inset 0 0 0 2px #3164f4;
}

/* Selected fill must keep footer ↑/↓ readable. Never force green on down/flat days. */
#calendarView .calendar .day.is-selected .day-projected-balance.is-zero .day-projected-amount,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-zero .day-projected-amount {
  color: color-mix(in srgb, var(--ink) 82%, var(--muted));
}
#calendarView .calendar .day.is-selected .day-projected-balance.is-above,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-above,
#calendarView .calendar .day.is-selected .day-projected-balance.is-above .day-projected-arrow,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-above .day-projected-arrow,
#calendarView .calendar .day.is-selected .day-projected-balance.is-above .day-projected-amount,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-above .day-projected-amount {
  color: #08704c;
}
#calendarView .calendar .day.is-selected .day-projected-balance.is-below,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-below,
#calendarView .calendar .day.is-selected .day-projected-balance.is-below .day-projected-arrow,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-below .day-projected-arrow,
#calendarView .calendar .day.is-selected .day-projected-balance.is-below .day-projected-amount,
#calendarView .calendar .day.agenda-selected .day-projected-balance.is-below .day-projected-amount {
  color: #b3372c;
}
#calendarView .calendar .day.is-selected .event.event-crumb.income,
#calendarView .calendar .day.agenda-selected .event.event-crumb.income { color: #08704c; }
#calendarView .calendar .day.is-selected .event.event-crumb.expense,
#calendarView .calendar .day.agenda-selected .event.event-crumb.expense { color: #b3372c; }

body[data-theme="midnight"] .calendar .day-projected-balance.is-above,
body[data-theme="midnight"] .calendar .day-projected-balance.is-above .day-projected-arrow,
body[data-theme="midnight"] .calendar .day-projected-balance.is-above .day-projected-amount { color: #6ee7b7; }
body[data-theme="midnight"] .calendar .day-projected-balance.is-below,
body[data-theme="midnight"] .calendar .day-projected-balance.is-below .day-projected-arrow,
body[data-theme="midnight"] .calendar .day-projected-balance.is-below .day-projected-amount { color: #fca5a5; }
body[data-theme="midnight"] .calendar .day-projected-balance.is-zero .day-projected-amount,
body[data-theme="midnight"] .glance-meta,
body[data-theme="midnight"] #calendarFreshness,
body[data-theme="midnight"] .calendar-insight-band { color: #9aa3c7; }
body[data-theme="midnight"] .glance-card {
  background: color-mix(in srgb, #12162b 88%, #2a3158);
  border-color: #2c3358;
}
body[data-theme="midnight"] .glance-value { color: #f3f5ff; }
body[data-theme="midnight"] .glance-card.is-projected .glance-value { color: #c6cce6; }
body[data-theme="midnight"] #calendarView .calendar .event.event-crumb.income { color: #6ee7b7; }
body[data-theme="midnight"] #calendarView .calendar .event.event-crumb.expense { color: #fca5a5; }
body[data-theme="midnight"] #calendarView .calendar .day.is-range {
  background: color-mix(in srgb, #7ea0ff 10%, #12162b);
}
body[data-theme="midnight"] #calendarView .calendar .day.is-selected,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected {
  background: color-mix(in srgb, #7ea0ff 18%, #12162b);
  box-shadow: inset 0 0 0 2px #7ea0ff;
}
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-zero .day-projected-amount,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-zero .day-projected-amount {
  color: #d7dcf5;
}
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-above,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-above,
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-above .day-projected-arrow,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-above .day-projected-arrow,
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-above .day-projected-amount,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-above .day-projected-amount {
  color: #6ee7b7;
}
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-below,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-below,
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-below .day-projected-arrow,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-below .day-projected-arrow,
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .day-projected-balance.is-below .day-projected-amount,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .day-projected-balance.is-below .day-projected-amount {
  color: #fca5a5;
}
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .event.event-crumb.income,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .event.event-crumb.income { color: #6ee7b7; }
body[data-theme="midnight"] #calendarView .calendar .day.is-selected .event.event-crumb.expense,
body[data-theme="midnight"] #calendarView .calendar .day.agenda-selected .event.event-crumb.expense { color: #fca5a5; }

@media (max-width: 720px) {
  #calendarGlanceStrip,
  .calendar-glance-strip,
  #calendarGlanceStrip.is-single-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    overflow: hidden;
    scroll-snap-type: none;
  }
  .glance-card { min-height: 56px; }
  /* Visual summary only — day cell is the sole interaction target on phone. */
  #calendarView .calendar .day .event.event-crumb,
  #calendarView .calendar .day .more {
    display: none !important;
    pointer-events: none !important;
  }
  #calendarView .calendar .event.event-crumb {
    display: none !important;
    font-size: 10px;
    column-gap: 0;
    cursor: inherit;
  }
  #calendarView .calendar .event.event-crumb .event-name {
    display: block;
    max-width: 100%;
    font-size: 10px;
  }
  /* Phone cells are too narrow for name+amount; full amounts stay in the day sheet. */
  #calendarView .calendar .event.event-crumb .event-amount {
    display: none !important;
  }
  .calendar .day-total,
  .calendar .day-projected-balance { font-size: 10px; }
  .calendar-insight-band { max-height: 56px; }
}

@media (min-width: 721px) and (max-width: 999px) {
  #calendarGlanceStrip.is-single-row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  #calendarGlanceStrip.is-stacked { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 1000px) {
  #calendarGlanceStrip,
  #calendarGlanceStrip.is-single-row {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
  .glance-value { font-size: 17px; }
}
