/* moneyness — structured-products finder, plus the sign-in/account pages that
   come with the webapp-skeleton boilerplate. One dark palette for the whole
   app: the finder already made that design decision, so the auth pages below
   are restyled onto it rather than introducing a second, lighter theme. */
:root {
  --bg: #0f1419;
  --panel: #1a2029;
  --panel-2: #222b36;
  --line: #2c3742;
  --ink: #e6edf3;
  --muted: #8b98a5;
  --accent: #3fb6a8;
  --accent-ink: #04120f;
  --pos: #4caf82;
  --warn: #e0a458;
  --error: #e0715f;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.topbar {
  display: flex; align-items: baseline; gap: 16px;
  padding: 12px 20px; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.brand { color: var(--accent); font-weight: 700; font-size: 18px; text-decoration: none; letter-spacing: .2px; }
.tagline { color: var(--muted); font-size: 13px; }
.asof { margin-left: auto; color: var(--muted); font-size: 12px; }
.topbar nav { margin-left: auto; }
.topbar nav a { color: var(--muted); text-decoration: none; margin-left: 1rem; font-size: 13px; }
.topbar nav a:hover { color: var(--ink); }
/* When both .asof and nav are present, only the first stays margin-left:auto. */
.topbar .asof + nav { margin-left: 0; }

.content { flex: 1; min-width: 0; padding: 16px 20px; }

/* --- shell + sidebar navigation (site structure, mirrors herdwork's spaces
   nav) ------------------------------------------------------------------- */
:root { --nav-w: 220px; }
.navtoggle {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 30px; height: 30px; padding: 0 7px; border: 0; border-radius: 7px;
  background: none; cursor: pointer; flex: none;
}
.navtoggle:hover { background: var(--panel-2); }
.navtoggle span { display: block; height: 2px; border-radius: 2px; background: var(--muted); }

.shell { display: flex; align-items: flex-start; }
.scrim { display: none; }

.sidebar {
  width: var(--nav-w); flex: none; background: var(--panel); border-right: 1px solid var(--line);
  overflow-x: hidden; transition: width .18s ease;
}
body:not(.nav-open) .sidebar { width: 0; border-right: 0; overflow: hidden; }

.navsec { padding: .8rem .6rem .2rem; min-width: calc(var(--nav-w) - 1.2rem); }
.navsec .h {
  display: flex; align-items: center; gap: .4rem; font-size: .68rem; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 700; padding: .15rem .5rem .35rem .3rem;
  border-radius: 7px; cursor: pointer; user-select: none;
}
.navsec .h:hover { background: var(--panel-2); }
.navsec-tw {
  width: 14px; flex: none; text-align: center; transition: transform .15s;
  border: 0; background: none; padding: 0; color: inherit; font: inherit; font-size: .6rem; line-height: 1;
  cursor: pointer;
}
.navsec-tw:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.navsec.folded .navsec-tw { transform: rotate(-90deg); }
.navsec.folded .navsec-b { display: none; }

.toollink {
  display: flex; align-items: center; gap: .55rem; padding: .42rem .55rem; border-radius: 7px;
  color: var(--ink); text-decoration: none; font-size: .9rem;
}
.toollink:hover { background: var(--panel-2); }
.toollink.active { background: var(--panel-2); font-weight: 600; }
.toolic {
  width: 22px; height: 22px; border-radius: 6px; display: grid; place-items: center;
  background: var(--accent); color: var(--accent-ink); font-size: .65rem; font-weight: 800; flex: none;
}

@media (max-width: 820px) {
  .scrim { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 55; }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: var(--nav-w);
    border-right: 1px solid var(--line); transform: translateX(-100%);
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim { display: block; }
}

.finder { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }

/* --- filters ------------------------------------------------------------ */
.filters {
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; position: sticky; top: 16px;
}
.fld { display: block; margin-bottom: 12px; }
.fld > span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.fld input, .fld select {
  width: 100%; padding: 7px 9px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--panel-2); color: var(--ink);
}
.fld.range { border: 0; margin: 0 0 12px; padding: 0; }
.fld.range .row { display: flex; gap: 6px; }
.fld.range input { width: 50%; }
.chk { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; margin: 10px 0 14px; }
.actions { display: flex; gap: 8px; }
button { cursor: pointer; border-radius: 7px; padding: 8px 12px; font-size: 13px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; flex: 1; }
button.ghost { background: transparent; color: var(--ink); }
button:disabled { opacity: .4; cursor: default; }

/* --- results ------------------------------------------------------------ */
.results { min-width: 0; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.count { color: var(--muted); }
.sort { color: var(--muted); font-size: 13px; }
.sort select { margin-left: 6px; padding: 6px 8px; border-radius: 7px; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 9px 10px; color: var(--muted); font-weight: 600;
  background: var(--panel); border-bottom: 1px solid var(--line); white-space: nowrap;
}
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody td { padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: var(--panel-2); }
tbody tr.delisted td { opacity: .5; }
td.isin { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--accent); }
.empty td { text-align: center; color: var(--muted); padding: 28px; cursor: default; }

.pager { display: flex; align-items: center; gap: 14px; justify-content: center; margin: 14px 0; color: var(--muted); }

/* --- detail dialog ------------------------------------------------------ */
dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  color: var(--ink); max-width: 560px; width: 92vw; padding: 0;
}
dialog::backdrop { background: rgba(0,0,0,.55); }
.detail-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.detail-head h2 { margin: 0; font-size: 16px; }
#d-body { margin: 0; padding: 16px 18px; display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; }
#d-body dt { color: var(--muted); }
#d-body dd { margin: 0; font-variant-numeric: tabular-nums; }

@media (max-width: 820px) {
  .finder { grid-template-columns: 1fr; }
  .filters { position: static; }
}

/* --- sign-in / account pages (from webapp-skeleton) ---------------------- */
.card {
  max-width: 26rem;
  margin: 3rem auto;
  padding: 1.75rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.card h1 { margin: 0 0 1.25rem; font-size: 1.35rem; }

.card label { display: block; margin-bottom: 1rem; color: var(--muted); font-size: 0.9rem; }

.card h2 { margin: 1.5rem 0 0.75rem; font-size: 1.05rem; }

.card input, .card select {
  display: block;
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--ink);
  font-size: 1rem;
}

.card input:focus, .card select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.card button[type="submit"] {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 0;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 1rem;
  font-weight: 600;
}

.card button:disabled { opacity: 0.6; cursor: default; }

.error { color: var(--error); font-size: 0.9rem; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.divider::before,
.divider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

.button-secondary {
  display: block;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  font-size: 1rem;
  text-align: center;
  text-decoration: none;
}

.button-secondary:hover { border-color: var(--accent); }

pre {
  overflow-x: auto;
  padding: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 0.85rem;
}
