/* IPO site pages: dashboard, open, upcoming, listed, screener, rankings, calendar.
   Uses the theme variables of styles.css, so light and dark themes both apply. */

.ipo-page {
  min-width: 0;
  padding: 18px 0 40px;
  color: var(--text);
}

.page-head { margin: 4px 0 14px; }
.page-head h1 { margin: 0 0 4px; font-size: 1.6rem; line-height: 1.2; }
.page-head p { margin: 0; }

.small { font-size: 0.85rem; }
.muted { color: var(--muted); }

/* Summary tiles (dashboard, year summary). */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 14px 0 22px;
}
.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
}
.tile a { color: inherit; text-decoration: none; display: block; }
.tile-value { display: block; font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.tile-label { display: block; margin-top: 4px; color: var(--muted); font-size: 0.85rem; }
.tile a:hover .tile-label { color: var(--accent); }

/* Sections. */
.ipo-section { margin: 0 0 26px; }
.ipo-section h2 { margin: 0 0 8px; font-size: 1.15rem; }

/* Tables. */
.table-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.ipo-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.ipo-table th,
.ipo-table td {
  text-align: left;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: nowrap;
}
.ipo-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--surface-2);
}
.ipo-table tr:last-child td { border-bottom: 0; }
.ipo-table td a { color: var(--accent); font-weight: 600; text-decoration: none; }
/* The list pages' filter bar (server-rendered): the status tabs, segment, exchange and grid/list icons on the first
   row, with the icons last; the search box takes the second row. */
.filter-bar.list-filter-bar .segmented[aria-label="Segment"] { order: 1; }
.filter-bar.list-filter-bar .segmented[aria-label="Exchange"] { order: 2; }
.filter-bar.list-filter-bar .view-toggle { order: 3; }
.filter-bar.list-filter-bar .search-form { display: block; order: 4; flex: 0 0 100%; }
.filter-bar.list-filter-bar .search-form .search { display: flex; width: 100%; }

/* A pre-IPO entry's stage (DRHP filed, SEBI observation) on the Upcoming page. */
.badge.s-pipeline { color: var(--accent); background: var(--surface-2); }

/* IPO symbols (NSE and BSE codes) wherever they show: the card line and the table's company column. */
.ipo-symbol {
  font-size: 11px;
  font-weight: 700;
}

/* IPO name links: no underline, in any state (the name is the link; the colour shows it). */
.ipo-table td a,
.ipo-table td a:hover,
.card h3 a,
.card h3 a:hover,
.cal-top h3 a,
.cal-top h3 a:hover,
.dash-card h3 a,
.dash-card h3 a:hover { text-decoration: none; }
.ipo-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.ipo-table th.num { text-align: right; }

/* Sortable headers (table-sort.js): the heading is a button; ⇅ unsorted, ▲ ascending, ▼ descending. */
.th-sort {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-transform: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
}
.th-sort:hover { color: var(--text); }
.th-sort.is-sorted { color: var(--accent); }
.th-sort::after { content: "⇅"; font-size: 0.8em; opacity: 0.35; }
.th-sort.is-sorted::after { content: "▲"; opacity: 1; }
.th-sort.is-sorted[aria-sort="descending"]::after { content: "▼"; }
.th-sort:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* A section after a table (the lead managers after the rankings table) gets room above it. */
.table-wrap + .ipo-section { margin-top: 28px; }

/* Calendar filter bar: the year, month and sector dropdowns, the height of the other filter controls. */
.filter-selects { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0; }
.filter-selects select {
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 40px;
  padding: 0 10px;
  min-width: 0;
  box-sizing: border-box;
}
.filter-selects select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Calendar: four cards per row, fewer as the screen narrows. */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.cal-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 14px 16px 16px;
}
.cal-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 10px; }
.cal-top h3 { flex: 1 1 140px; margin: 0; font-size: 1rem; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.cal-top h3 a { color: var(--text); text-decoration: none; }
.dash-card h3 { margin: 10px 0 12px; font-size: 1rem; line-height: 1.3; }
.dash-card h3 a { color: var(--text); text-decoration: none; }
.cal-badges { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex-shrink: 0; }
.cal-line, .cal-date { margin: 0; color: var(--muted); font-size: 0.9rem; }
.cal-line strong { color: var(--text); font-weight: 600; }
.cal-sep { margin: 0 8px; opacity: 0.5; }
@media (max-width: 1100px) { .cal-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px) { .cal-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px) { .cal-grid { grid-template-columns: 1fr; } }

/* Rankings tab list: the same look as the detail page's tabs (company.css): underlined labels, the selected one
   with an accent bar, on a divider line. */
.ranking-tablist {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin: 0 0 16px;
}
.ranking-tablist a {
  flex: 0 0 auto;
  padding: 10px 14px;
  margin: 0;
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
}
.ranking-tablist a:hover { color: var(--text); }
.ranking-tablist a[aria-selected="true"] { color: var(--text); border-bottom-color: var(--accent); }
.ranking-tablist a:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 6px; }

/* IPO list filter bar: status tabs, search, grid/list icons, then segment and exchange (the same order as the
   server-rendered list pages). The base order is set in styles.css; these rules put the icons after the search. */
.filter-bar .view-toggle { order: 1; }
.filter-bar #exchange-group { order: 3; }
.filter-bar.is-wrapped .search { flex: 1 1 200px; }
.filter-bar.is-wrapped .view-toggle { order: -1; flex: 0 0 auto; }

/* Segment and gain. */
.seg { font-weight: 600; font-size: 0.82rem; }
.seg.main { color: var(--mainboard); }
.seg.sme { color: var(--sme); }
.gain { font-weight: 700; font-variant-numeric: tabular-nums; }
.gain.up { color: var(--listed); }
.gain.down { color: var(--danger); }
.gain.flat { color: var(--muted); font-weight: 600; }

/* Notices and empty states. */
.notice,
.empty {
  background: var(--surface);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--muted);
  margin: 8px 0;
}

/* Sort links, tabs, pager. */
.sort { margin: 0 0 12px; color: var(--muted); }
.sort a,
.tabs a { color: var(--accent); text-decoration: none; font-weight: 600; margin-right: 10px; }
.sort a[aria-current="true"],
.tabs a[aria-current="true"] { color: var(--text); text-decoration: underline; text-underline-offset: 4px; }
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 0; }
.tabs a {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  margin: 0;
  background: var(--surface);
}
.tabs a[aria-current="true"] { background: var(--surface-2); text-decoration: none; }

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0;
}
.pager a { color: var(--accent); font-weight: 600; text-decoration: none; }

.more { margin-top: 18px; }
.more a { color: var(--accent); font-weight: 600; text-decoration: none; margin-right: 8px; }

/* Screener form. */
.screener-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px 12px;
  align-items: end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin: 0 0 14px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 0.85rem; color: var(--muted); }
.field input,
.field select {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 700;
  color: var(--accent-contrast, #fff);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 8px 14px;
  text-decoration: none;
  cursor: pointer;
  text-align: center;
}
.btn.ghost { background: transparent; color: var(--accent); }

/* Calendar months. */
.month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.month h2 { display: flex; align-items: baseline; gap: 10px; }
.month-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px 14px;
}
.month-list a { color: var(--accent); text-decoration: none; }
.month-list a:hover { text-decoration: underline; }

@media (max-width: 720px) {
  .page-head h1 { font-size: 1.3rem; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .tile-value { font-size: 1.25rem; }
}

/* Page tabs (links), the same look as the list page's status tabs. */
.tabs a {
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 7px 12px;
  border-radius: 8px;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.tabs a:hover { color: var(--text); }
.tabs a[aria-selected="true"] { background: var(--accent); color: var(--accent-contrast); }

/* Exchange badges: NSE and BSE, in the same style as the segment and status badges. */
.badge.exch-nse { color: var(--upcoming); }
.badge.exch-bse { color: var(--accent); }

/* Cards on the new pages use the list page's card style (styles.css); the calendar cards are shorter. */
.month .results { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.month .card h3 { font-size: 0.98rem; }

/* Grid and list view links: the same look as the list page's view toggle (styles.css), for links. */
.list-controls { display: flex; justify-content: flex-end; margin: 0 0 12px; }
.segmented a {
  appearance: none;
  background: none;
  border: 0;
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 8px 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.segmented a:hover { color: var(--text); }
.segmented a + a { border-left: 1px solid var(--border); }
.segmented a[aria-current="true"] { background: var(--accent); color: var(--accent-contrast); }
.segmented .icon-btn { display: grid; place-items: center; padding: 8px 11px; }

/* Paging links: the same look as the list page's page buttons. */
.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
}
.page-btn:hover { border-color: var(--accent); color: var(--accent); }
.page-btn[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.page-btn[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.pager-size { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.pager-size a {
  color: var(--muted);
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
  text-decoration: none;
}
.pager-size a[aria-current="true"] { background: var(--accent); color: var(--accent-contrast); }

/* Filter bar alignment: the status tabs, the segment and exchange controls, the view toggle and the search box
   share one height and one line on the IPO pages. */
.filter-bar { align-items: center; }
.filter-bar .tabs,
.filter-bar .segmented { height: 40px; box-sizing: border-box; align-items: stretch; }
.filter-bar .tabs button,
.filter-bar .tabs a { height: 34px; display: inline-flex; align-items: center; }
.filter-bar .segmented button,
.filter-bar .segmented a { display: inline-flex; align-items: center; justify-content: center; height: 100%; box-sizing: border-box; }
.filter-bar .search-form { display: contents; }
.filter-bar .search { height: 40px; box-sizing: border-box; align-items: center; }
.filter-bar .search input { height: 34px; }

/* No bottom margin under the tabs. */
.tabs { margin-bottom: 0; }

/* No background on the tabs; only the selected tab is filled. */
.tabs,
.filter-bar .tabs { background: none; }
.tabs a:not([aria-selected="true"]):not([aria-current="true"]) { background: transparent; }
