footer {
  padding: 16px 0 28px;
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

footer a { color: inherit; text-decoration: underline; }

/* ===== TOOLBAR ===== */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ctrl-btn {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 13px;
  padding: 6px 11px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
  line-height: 1;
}

.ctrl-btn:hover { color: var(--text); border-color: rgba(100,140,200,.4); }

.ctrl-btn.today {
  font-size: 11px;
  letter-spacing: .4px;
  text-transform: uppercase;
}

.period-label {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 700;
  min-width: 200px;
  text-align: center;
}

.view-tabs {
  display: flex;
  gap: 4px;
}

.view-tab {
  background: none;
  border: 1px solid var(--border2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .5px;
  text-transform: uppercase;
  padding: 6px 13px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
}

.view-tab:hover { color: var(--text); }

.view-tab.active {
  background: rgba(79,156,249,.12);
  border-color: rgba(79,156,249,.35);
  color: var(--accent);
}

/* ===== CALENDAR WRAPPER ===== */
.cal-wrap {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(14,21,32,.4);
  overflow: hidden;
}

.day-header {
  padding: 9px 10px;
  font-size: 10px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border2);
  background: rgba(8,12,16,.97);
  position: sticky;
  top: 0;
  z-index: 4;
}

.day-header:last-child { border-right: none; }

/* ===== GRID ===== */
.cal-grid {
  display: grid;
}

/* ===== CELL ===== */
.cal-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px;
  min-height: 90px;
  vertical-align: top;
  position: relative;
}

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

.cal-cell.other-month { opacity: .35; }

.cal-cell.today-cell .cell-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-num {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  line-height: 1;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cell-events {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* ===== TICKER CHIP ===== */
.ticker-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 500;
  font-family: var(--display);
  cursor: pointer;
  border: 1px solid transparent;
  transition: filter .12s, transform .1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  line-height: 1.4;
}

.ticker-chip:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}

.ticker-chip.projected {
  border-style: dashed;
  opacity: .72;
}

.ticker-chip.projected:hover { opacity: 1; }

.more-chip {
  font-size: 10px;
  color: var(--muted);
  padding: 1px 4px;
  cursor: pointer;
  letter-spacing: .2px;
}

.more-chip:hover { color: var(--text); }

/* ===== EXPAND OVERLAY ===== */
.cell-expand-overlay {
  position: absolute;
  z-index: 100;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0,0,0,.6);
  padding: 10px;
  min-width: 140px;
  max-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  pointer-events: all;
}

.overlay-close {
  align-self: flex-end;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  margin-bottom: 2px;
}
.overlay-close:hover { color: var(--text); }

/* ===== WEEK VIEW ===== */
.week-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.week-cell {
  border-right: 1px solid var(--border);
  border-bottom: none;
  padding: 12px 10px;
  min-height: 300px;
}

.week-cell:last-child { border-right: none; }

.week-cell .cell-num {
  font-size: 13px;
  margin-bottom: 10px;
  width: 26px;
  height: 26px;
}

.week-cell.today-cell .cell-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
}

.week-cell .ticker-chip {
  font-size: 11px;
  padding: 3px 9px;
}

/* ===== QUARTER VIEW ===== */
.quarter-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.quarter-month {
  border-right: 1px solid var(--border);
  padding: 0;
}

.quarter-month:last-child { border-right: none; }

.quarter-month-title {
  font-family: var(--display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 12px 12px 8px;
  border-bottom: 1px solid var(--border);
}

.quarter-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border-bottom: 1px solid var(--border);
}

.quarter-day-header {
  font-size: 9px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  padding: 5px 2px;
  border-right: 1px solid var(--border);
  opacity: .6;
}

.quarter-day-header:last-child { border-right: none; }

.quarter-mini-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
}

.quarter-cell {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 3px 2px;
  min-height: 52px;
  position: relative;
}

.quarter-cell:nth-child(7n) { border-right: none; }
.quarter-cell.other-month { opacity: .25; }

.quarter-cell .cell-num {
  font-size: 9px;
  width: 16px;
  height: 16px;
  margin-bottom: 3px;
}

.quarter-cell.today-cell .cell-num {
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  font-size: 9px;
}

.quarter-cell .ticker-chip {
  font-size: 9px;
  padding: 1px 4px;
  border-radius: 3px;
}

/* ===== POPUP MODAL ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s;
}

.modal-backdrop.open {
  opacity: 1;
  pointer-events: all;
}

.fund-popup {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
  width: 100%;
  max-width: 380px;
  padding: 0;
  transform: translateY(10px);
  transition: transform .18s;
  overflow: hidden;
  position: relative;
}

.modal-backdrop.open .fund-popup {
  transform: translateY(0);
}

.popup-accent-bar {
  height: 2px;
  width: 100%;
}

.popup-inner {
  padding: 20px 22px 18px;
}

.popup-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.popup-tickers {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.popup-ticker {
  font-family: var(--display);
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
  line-height: 1;
  text-decoration: none;
}

.popup-ticker:hover { text-decoration: underline; }

.popup-ticker-sep {
  color: var(--muted);
  font-size: 13px;
  opacity: .5;
  font-family: var(--mono);
}

.popup-days-badge {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,.05);
  letter-spacing: .3px;
  white-space: nowrap;
}

.popup-fund-name {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 14px;
}

.popup-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.popup-date {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: .3px;
}

.popup-cik {
  font-size: 11px;
  color: var(--muted);
}

.popup-cik a { color: inherit; text-decoration: none; }
.popup-cik a:hover { color: var(--accent2); }

.popup-notes {
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--border);
  padding-top: 10px;
}

.popup-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 5px;
  border-radius: 5px;
  transition: color .12s, background .12s;
  z-index: 1;
}

.popup-close:hover { color: var(--text); background: rgba(255,255,255,.06); }

/* ===== LOADING / ERROR ===== */
.cal-placeholder {
  padding: 60px 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.cal-placeholder.loading::after {
  content: '';
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

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

@media (max-width: 700px) {
  .quarter-grid { grid-template-columns: 1fr; }
  .quarter-month { border-right: none; border-bottom: 1px solid var(--border); }

  /* Toolbar: let it use the full width and give buttons room to tap */
  .toolbar { gap: 10px; }
  .nav-controls { flex: 1 1 auto; }
  .period-label { min-width: 0; flex: 1; font-size: 14px; text-align: left; }
  .ctrl-btn { padding: 9px 12px; }
  .view-tabs { width: 100%; gap: 6px; }
  .view-tab { flex: 1; text-align: center; padding: 9px 8px; }

  /* Month view: tighter cells so 7 columns fit comfortably */
  .cal-cell { min-height: 66px; padding: 4px; }
  .day-header { padding: 7px 2px; font-size: 9px; letter-spacing: .3px; }
  .cell-num,
  .cal-cell.today-cell .cell-num { font-size: 10px; width: 18px; height: 18px; margin-bottom: 3px; }
  .ticker-chip { font-size: 9px; padding: 1px 5px; }
  .cell-events { gap: 2px; }

  /* Week view: much shorter, still readable */
  .week-cell { min-height: 130px; padding: 8px 5px; }
  .week-cell .cell-num { font-size: 12px; width: 22px; height: 22px; margin-bottom: 6px; }
  .week-cell .ticker-chip { font-size: 10px; padding: 2px 6px; }
}

/* Narrow phones */
@media (max-width: 430px) {
  .cal-cell { min-height: 58px; padding: 3px; }
  .cell-num,
  .cal-cell.today-cell .cell-num { font-size: 9px; width: 16px; height: 16px; }
  .day-header { font-size: 8px; padding: 6px 1px; }
  .ticker-chip { font-size: 8px; padding: 1px 4px; }
}
