body { font-size: 14px; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* --- Stats strip --- */

.stats-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 9px 20px;
  background: rgba(14,21,32,.6);
  border: 1px solid var(--border);
  border-radius: 9px;
  gap: 3px;
  min-width: 90px;
}

.stat-val {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.stat-label {
  font-size: 9px;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-sep {
  width: 1px;
  height: 28px;
  background: var(--border);
  flex-shrink: 0;
}

/* --- Toolbar --- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0 10px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
}

.search-shortcut {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 10px;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 5px;
  letter-spacing: .3px;
  pointer-events: none;
  opacity: .6;
}

.search {
  width: 100%;
  background: rgba(14,21,32,.8);
  border: 1px solid var(--border2);
  color: var(--text);
  padding: 8px 36px 8px 32px;
  border-radius: 8px;
  outline: none;
  font-size: 13px;
  font-family: var(--mono);
  transition: border-color .15s;
}

.search::placeholder { color: rgba(107,132,160,.55); }
.search:focus { border-color: rgba(79,156,249,.4); }

.toolbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: .3px;
}

/* --- View toggle (List / Tiles) --- */
.view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}
.vt {
  padding: 6px 11px;
  font-size: 13px;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.vt + .vt { border-left: 1px solid var(--border); }
.vt:hover { color: var(--text); }
.vt.active { color: var(--accent); background: rgba(79,156,249,.12); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .4px;
  text-transform: uppercase;
  padding: 7px 14px;
  border-radius: 7px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--muted);
}

.btn:hover { color: var(--text); border-color: rgba(100,140,200,.4); background: rgba(79,156,249,.06); }
.btn.primary { background: rgba(79,156,249,.1); border-color: rgba(79,156,249,.3); color: var(--accent); }
.btn.primary:hover { background: rgba(79,156,249,.18); }

/* --- Sections --- */

.fund-section { margin-top: 28px; }

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.section-title {
  font-family: var(--display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--muted);
}

.section-count {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(79,156,249,.09);
  border: 1px solid rgba(79,156,249,.2);
  color: var(--accent);
  letter-spacing: .2px;
}

/* --- Tile grid --- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}

/* Native app: one tile per row (matches the Upcoming page); web is unchanged. */
.cap-native .tiles { grid-template-columns: 1fr; }

/* Native app: fit all stat tiles on a single row, scaling to the device width.
   iPhones are too narrow for the web layout, so the tiles wrap there; in the app
   we make them flex equally and shrink instead. Web layout is untouched. */
.app-sections .stats-strip { flex-wrap: nowrap; gap: 6px; }
.app-sections .stat-sep { display: none; }
.app-sections .stat {
  flex: 1 1 0;
  min-width: 0;
  padding: 8px 6px;
  gap: 2px;
}
.app-sections .stat-val { font-size: 17px; }
.app-sections .stat-label {
  font-size: 8px;
  letter-spacing: .2px;
  line-height: 1.15;
  text-align: center;
}

/* --- Collapsible category sections (native app only, gated on .app-sections) --- */

/* Disclosure caret — hidden on the web, shown only in the app. */
.sec-caret { display: none; }
.app-sections .sec-caret {
  display: inline-block;
  font-size: 9px;
  color: var(--muted);
  transition: transform .15s;
  transform: rotate(90deg);  /* open: points down */
}
.app-sections .fund-section.collapsed .sec-caret,
.app-sections .tbl-section.collapsed .sec-caret { transform: rotate(0deg); }

/* Tappable headers with comfortable touch targets in the app. */
.app-sections .section-header,
.app-sections .tbl-band { cursor: pointer; user-select: none; -webkit-user-select: none; }
.app-sections .section-header { padding: 4px 0; }

/* Collapse the section bodies. */
.app-sections .fund-section.collapsed .tiles { display: none; }
.app-sections .tbl-section.collapsed .tbl-row { display: none; }

/* Expand all / Collapse all control — app only. */
#expandAll { display: none; }
.app-sections #expandAll {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  font-size: 12px;
}

/* --- Tile --- */

.tile {
  display: block;
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px 14px;
  text-decoration: none;
  color: inherit;
  transition: transform .15s, border-color .15s, background .15s;
  min-width: 0;
  overflow: hidden;
}

.tile:hover {
  transform: translateY(-2px);
  border-color: rgba(100,140,200,.28);
  background: var(--surface2);
  text-decoration: none;
}

.tile:hover .tile-arrow { opacity: 1; color: var(--accent2); }

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

.ticker-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

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

.ticker-sep {
  color: var(--muted);
  font-size: 11px;
  opacity: .4;
  font-family: var(--mono);
  margin: 0 1px;
}

.ticker-missing {
  font-size: 12px;
  color: var(--muted);
}

.days-badge {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  letter-spacing: .3px;
  white-space: nowrap;
}

/* 3-tier urgency: <=3d hot · <=14d warm(=accent) · else cool. */
.badge-hot    { background: rgba(255,107,102,.12); border-color: rgba(255,107,102,.40); color: var(--hot); }
.badge-warm   { background: rgba(79,156,249,.10);  border-color: rgba(79,156,249,.30);  color: var(--warm); }
.badge-cool   { background: rgba(125,142,166,.09); border-color: rgba(125,142,166,.26); color: var(--cool); }
.badge-passed { background: rgba(107,132,160,.07); border-color: rgba(107,132,160,.18); color: var(--muted); }
.badge-none   { background: transparent;           border-color: var(--border2);        color: var(--muted); }

.fund-name {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.4;
  margin-bottom: 12px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.stale-dot {
  font-size: 10px;
  color: var(--warn);
  margin-left: 4px;
  opacity: .7;
  vertical-align: middle;
}

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

.date-val {
  font-size: 12px;
  color: var(--text);
  letter-spacing: .2px;
}

.date-est {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

.date-muted {
  font-size: 12px;
  color: var(--muted);
}

.tile-arrow {
  font-size: 14px;
  color: var(--muted);
  opacity: 0;
  transition: opacity .15s, color .15s;
  line-height: 1;
}

/* --- List (table) view --- */
.tbl { margin-top: 8px; padding-bottom: 8px; }
.tbl-head,
.tbl-row {
  display: grid;
  grid-template-columns: minmax(100px,1fr) minmax(200px,3.4fr) 150px 70px;
  gap: 16px;
  align-items: center;
}
.tbl-head {
  padding: 9px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 1.1px;
  color: var(--faint);
}
.tbl-head .r,
.tbl-row .r { text-align: right; }
.tbl-band {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 1px;
  padding: 0 14px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 1.4px;
  color: var(--muted);
}
.tbl-rule { flex: 1; height: 1px; background: var(--border); }
.tbl-band-n { color: var(--faint); letter-spacing: .5px; white-space: nowrap; }
.tbl-row {
  position: relative;
  height: 52px;
  padding: 0 14px;
  border-bottom: 1px solid var(--border);
  text-decoration: none;
  color: inherit;
  transition: background .12s;
}
.tbl-row::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--rc, var(--accent));
  opacity: 0;
  transition: opacity .12s;
}
.tbl-row:hover { background: rgba(100,140,200,.06); }
.tbl-row:hover::before { opacity: .9; }
.t-tk { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.t-tk-1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.2px;
  white-space: nowrap;
  color: var(--text);
}
.t-tk-1.muted { font-family: var(--mono); font-weight: 400; color: var(--muted); }
.t-more {
  font-size: 9px;
  color: var(--muted);
  border: 1px solid var(--border2);
  border-radius: 3px;
  padding: 1px 4px;
  flex-shrink: 0;
  line-height: 1.3;
}
.t-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--text);
  opacity: .85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.t-date { font-size: 12px; color: var(--muted); white-space: nowrap; }
.t-date.est { font-style: italic; color: var(--faint); }
.t-days .t-pill {
  display: inline-block;
  min-width: 48px;
  text-align: center;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .4px;
  border: 1px solid currentColor;
  border-radius: 999px;
  padding: 2px 0;
}

/* --- Toast --- */

#toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--surface2);
  border: 1px solid var(--border2);
  color: var(--text);
  font-size: 12px;
  padding: 8px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 999;
  white-space: nowrap;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* --- Empty / error --- */

.empty-state {
  padding: 56px 24px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: .3px;
  margin-top: 12px;
}

.error-msg {
  margin-top: 24px;
  padding: 14px 16px;
  background: rgba(255,107,107,.07);
  border: 1px solid rgba(255,107,107,.2);
  border-radius: 8px;
  color: #ff9f9f;
  font-size: 12px;
}

footer { margin-top: 40px; padding: 14px 0 32px; }

/* --- Responsive --- */

@media (max-width: 640px) {
  .header-inner { flex-direction: column; align-items: flex-start; }
  .header-actions { flex-wrap: wrap; }
  .stat-sep { display: none; }
  .tiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tbl-head, .tbl-row { grid-template-columns: minmax(70px,1fr) minmax(110px,2.4fr) 100px 56px; gap: 10px; }
  .search-wrap { max-width: none; min-width: 0; }
  /* 16px prevents iOS from auto-zooming the page when the field is focused */
  .search { font-size: 16px; padding: 10px 14px 10px 32px; }
}

@media (max-width: 480px) {
  /* Drop the date column on narrow screens (header span 3 + the row date cell). */
  .tbl-head, .tbl-row { grid-template-columns: minmax(56px,1fr) minmax(80px,2fr) 52px; gap: 8px; }
  .tbl-head > span:nth-child(3), .tbl-row > .t-date { display: none; }
}

@media (max-width: 420px) {
  .tiles { grid-template-columns: 1fr; }
  .stat { min-width: 70px; padding: 8px 12px; }
  .stat-val { font-size: 18px; }
}

/* The ⌘K shortcut hint is meaningless without a keyboard */
@media (hover: none) {
  .search-shortcut { display: none; }
}
