/* Quant Factory Adviser Portal — Quantmade design language
   Tokens from the Quantmade design system (navy / teal, IBM Plex, square corners,
   thin rules, no decoration), scaled from deck pixels to application sizes. */
:root {
  --navy: #0f2340;
  --teal: #0b7a71;          /* on light grounds and white */
  --teal-bright: #2dd4c4;   /* on navy, or as a fill carrying navy text */
  --grey-100: #eceef1;      /* page ground */
  --white: #ffffff;
  --slate-600: #465162;     /* body text */
  --slate-500: #5f6b7d;     /* muted text */
  --slate-400: #8098b5;     /* muted on navy */
  --slate-300: #b0becf;     /* body on navy */
  --line-100: #e1e6eb;      /* rows inside white plates */
  --line-200: #d5dae0;      /* card borders */
  --line-300: #c6ccd4;      /* dividers, inputs */
  --line-navy: #334154;
  --link: #0b6f68;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Consolas, monospace;
  --gutter: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--grey-100);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--link); }
a:hover { color: var(--navy); }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
h1, h2, h3 { margin: 0; font-weight: 500; }
p { margin: 0; }
code, .mono { font-family: var(--mono); }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 10;
  background: var(--white); color: var(--navy); padding: 10px 14px; border: 1px solid var(--navy);
}
.skip-link:focus { top: 8px; }

/* ---------- Environment bar (prototype controls) ---------- */
.env-bar {
  background: var(--navy); color: var(--slate-300);
  border-bottom: 1px solid var(--line-navy);
  padding: 8px 24px; display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px;
  font-size: 13px;
}
.env-bar__tag {
  background: var(--teal-bright); color: var(--navy);
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase;
  padding: 4px 8px;
}
.env-bar__text { flex: 1 1 260px; }
.env-bar__controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.env-bar label { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-400); }
.env-bar select {
  font: inherit; font-family: var(--sans); font-size: 13px; letter-spacing: 0; text-transform: none;
  background: var(--navy); color: var(--white); border: 1px solid var(--line-navy); border-radius: 0;
  padding: 6px 8px; min-height: 36px;
}
.env-bar :focus-visible { outline-color: var(--teal-bright); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 52px); }
.sidebar {
  background: var(--navy); color: var(--white);
  padding: 24px 16px; display: flex; flex-direction: column; gap: 28px;
}
.sidebar :focus-visible { outline-color: var(--teal-bright); }
.brand { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; color: var(--white); text-decoration: none; }
.brand:hover { color: var(--white); }
.brand__name { font-size: 18px; font-weight: 500; letter-spacing: -.01em; }
.brand__sub, .nav__group {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-400);
}
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav__group { padding: 0 12px 8px; }
.nav__group + .nav__link, .nav__link + .nav__group { margin-top: 0; }
.nav__link + .nav__group { padding-top: 20px; }
.nav__link {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px; min-height: 44px; color: var(--slate-300); text-decoration: none;
}
.nav__link:hover { color: var(--white); }
.nav__link[aria-current="page"] { background: var(--line-navy); color: var(--white); }
.nav__badge { font-family: var(--mono); font-size: 11px; background: var(--teal-bright); color: var(--navy); padding: 1px 6px; }
.identity { margin-top: auto; border-top: 1px solid var(--line-navy); padding: 16px 12px 0; display: flex; flex-direction: column; gap: 4px; }
.identity__name { color: var(--white); }
.identity__meta { color: var(--slate-300); font-size: 13px; }
.identity__note { font-family: var(--mono); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--slate-400); padding-top: 6px; }

.workspace { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--line-200);
  padding: 10px 32px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px;
}
.topbar__org { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.topbar__status { color: var(--slate-600); font-size: 13px; }

.page { padding: 32px; display: flex; flex-direction: column; gap: var(--gutter); max-width: 1240px; width: 100%; }
.page:focus { outline: none; }
.page-head { display: flex; flex-direction: column; gap: 8px; }
.page-head h1 { font-size: 32px; letter-spacing: -.01em; line-height: 1.15; text-wrap: balance; }
.page-head h1:focus { outline: none; }
.page-head p { color: var(--slate-600); max-width: 760px; text-wrap: pretty; }

.eyebrow { font-family: var(--mono); font-size: 12px; font-weight: 500; letter-spacing: .14em; text-transform: uppercase; color: var(--slate-600); }
.label { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); }
.muted { color: var(--slate-500); }
.body { color: var(--slate-600); }
.small { font-size: 13px; }

/* ---------- Cards and layout ---------- */
.card { background: var(--white); border: 1px solid var(--line-200); border-top: 4px solid var(--navy); }
.card--lead { border-top-color: var(--teal); }
.card__head { padding: 18px 24px 12px; display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px 16px; }
.card__head h2 { font-size: 18px; }
.card__body { padding: 0 24px 20px; display: flex; flex-direction: column; gap: 12px; }
.card__body--pad { padding: 20px 24px; }
.split { display: flex; flex-wrap: wrap; gap: var(--gutter); align-items: flex-start; }
.split__main { flex: 999 1 520px; min-width: 0; }
.split__side { flex: 1 1 320px; min-width: 0; display: flex; flex-direction: column; gap: var(--gutter); }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; background: var(--line-200); border: 1px solid var(--line-200); }
.tile { background: var(--white); padding: 20px; display: flex; flex-direction: column; gap: 6px; }
.tile__value { font-size: 28px; font-weight: 500; letter-spacing: -.02em; line-height: 1.2; }
.tile__value--text { font-size: 16px; }

/* ---------- Tables and lists ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 560px; }
.table th {
  text-align: left; padding: 10px 12px; border-bottom: 1.5px solid var(--navy);
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--teal);
}
.table td { padding: 13px 12px; border-bottom: 1px solid var(--line-100); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table th:first-child, .table td:first-child { padding-left: 24px; }
.table th:last-child, .table td:last-child { padding-right: 24px; }
.table tr.is-selected td { background: var(--grey-100); }
.strong { font-weight: 500; }

.rowlist { list-style: none; margin: 0; padding: 0; }
.rowbtn {
  display: flex; flex-direction: column; gap: 3px; width: 100%; text-align: left;
  background: var(--white); color: var(--navy); border: 0; border-bottom: 1px solid var(--line-100);
  padding: 14px 20px; min-height: 56px; font: inherit; cursor: pointer;
}
.rowbtn:hover, .rowbtn[aria-pressed="true"] { background: var(--grey-100); }
.rowbtn__top { display: flex; justify-content: space-between; gap: 8px; }

.linkbtn {
  background: none; border: 0; padding: 0; font: inherit; font-weight: 500; color: var(--navy); text-align: left; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--line-300); text-underline-offset: 3px; min-height: 24px;
}
.linkbtn:hover { text-decoration-color: var(--navy); }

.dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; font-size: 13px; }
.dl--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dl dt { color: var(--slate-500); }
.dl dd { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.dl .wide { grid-column: 1 / -1; }
.rule { border-top: 1px solid var(--line-100); padding-top: 16px; }

/* ---------- Chips ---------- */
.chips { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip { display: inline-block; font-size: 12px; font-weight: 500; line-height: 1.4; padding: 2px 8px; border: 1px solid transparent; white-space: nowrap; }
.chip--available { border-color: var(--navy); color: var(--navy); }
.chip--signal { background: var(--teal-bright); color: var(--navy); }
.chip--export { background: var(--navy); color: var(--white); }
.chip--pending { border: 1px dashed var(--slate-600); color: var(--slate-600); }
.chip--neutral { background: var(--grey-100); color: var(--slate-600); border-color: var(--line-200); }
.chip--mono { font-family: var(--mono); font-size: 11px; }

/* ---------- Controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 500; border-radius: 0; padding: 10px 16px; min-height: 44px;
  cursor: pointer; text-decoration: none; border: 1px solid var(--navy);
}
.btn--primary { background: var(--navy); color: var(--white); }
.btn--primary:hover { background: #1b3557; color: var(--white); }
.btn--secondary { background: var(--white); color: var(--navy); }
.btn--secondary:hover { background: var(--grey-100); color: var(--navy); }
.btn:disabled, .btn[aria-disabled="true"] { background: var(--grey-100); color: var(--slate-500); border-color: var(--line-300); cursor: not-allowed; }
.btn--icon { width: 44px; padding: 0; flex: none; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions--between { justify-content: space-between; }

.seg-group { display: flex; flex-wrap: wrap; gap: 6px; }
.seg { font: inherit; font-size: 13px; background: var(--white); color: var(--navy); border: 1px solid var(--line-300); border-radius: 0; padding: 10px 14px; min-height: 44px; cursor: pointer; }
.seg:hover { border-color: var(--navy); }
.seg[aria-pressed="true"] { background: var(--navy); color: var(--white); border-color: var(--navy); }

.filters { background: var(--white); border: 1px solid var(--line-200); padding: 16px 20px; display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field--grow { flex: 1 1 260px; }
.field--wide { flex: 999 1 420px; }
.field--narrow { flex: 1 1 200px; }
.form-stack { display: flex; flex-direction: column; gap: 16px; }
.form-grid { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-start; }
.form-grid > .actions, .form-grid > .notice { flex: 1 1 100%; }
.review-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(220px, .7fr); gap: 16px 24px; padding: 20px 0; border-bottom: 1px solid var(--line-100); }
.review-row:last-child { border-bottom: 0; }
.review-row .actions { grid-column: 1 / -1; }
.field__label, fieldset > legend { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; color: var(--teal); padding: 0; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
fieldset > legend { margin-bottom: 8px; }
.field__hint { color: var(--slate-600); font-size: 13px; }
.field__error { color: var(--navy); font-size: 13px; font-weight: 500; }
.input, .select, .textarea {
  font: inherit; color: var(--navy); background: var(--white);
  border: 1px solid var(--line-300); border-radius: 0; padding: 10px 12px; min-height: 44px; width: 100%;
}
.textarea { resize: vertical; min-height: 104px; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--slate-500); }
[aria-invalid="true"] { border-color: var(--navy); border-width: 2px; }
.topbar .select { width: auto; min-width: 240px; }

.option {
  display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; min-height: 44px;
  border: 1px solid var(--line-300); background: var(--white); cursor: pointer;
}
.option + .option { margin-top: 8px; }
.option:hover { border-color: var(--navy); }
.option:has(input:checked) { border-color: var(--navy); background: var(--grey-100); }
.option:has(input:disabled) { cursor: not-allowed; color: var(--slate-500); }
.option input { margin: 3px 0 0; width: 18px; height: 18px; accent-color: var(--navy); flex: none; }
.option__text { display: flex; flex-direction: column; gap: 2px; }

/* ---------- Notices and states ---------- */
.notice { background: var(--white); border: 1px solid var(--line-200); padding: 14px 20px; display: flex; gap: 12px; align-items: flex-start; color: var(--slate-600); }
.notice strong { color: var(--navy); font-weight: 500; }
.icon { width: 20px; height: 20px; flex: none; fill: none; stroke: var(--teal); stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.icon--navy { stroke: var(--navy); }

.state { padding: 40px 24px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.state h2, .state h3 { font-size: 18px; display: flex; gap: 8px; align-items: center; }
.state p { color: var(--slate-600); max-width: 620px; }
.state--card { background: var(--white); border: 1px solid var(--line-200); border-top: 4px solid var(--navy); }
.locked { background: var(--grey-100); border: 1px solid var(--line-200); padding: 16px; display: flex; flex-direction: column; gap: 8px; }

@keyframes qf-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.skeleton { background: var(--line-100); height: 14px; animation: qf-pulse 1.6s ease-in-out infinite; }
.skeleton-stack { display: flex; flex-direction: column; gap: 12px; padding: 24px; }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- Drawer ---------- */
.drawer { flex: 1 1 340px; min-width: 0; }
.drawer__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer__head h2 { font-size: 20px; line-height: 1.25; }
.close-x { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; }

/* ---------- Steps, status, timeline ---------- */
.steps { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.steps li { border-top: 3px solid var(--line-300); color: var(--slate-500); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
.steps li[aria-current="step"] { border-top-color: var(--teal); color: var(--navy); }
.steps li.is-done { border-top-color: var(--navy); color: var(--navy); }
.steps__n { font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .08em; text-transform: uppercase; }
.steps__t { font-weight: 500; }
.steps li.is-declined { border-top-color: var(--slate-600); border-top-style: dashed; color: var(--navy); }

.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.timeline li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 12px; padding: 8px 0; }
.timeline__dot { width: 8px; height: 8px; margin-top: 7px; background: var(--teal); }
.timeline__text { display: flex; flex-direction: column; gap: 2px; }
.timeline__meta { font-family: var(--mono); font-size: 12px; color: var(--slate-500); }

.activity { list-style: none; margin: 0; padding: 0; }
.activity li { padding: 10px 0; border-bottom: 1px solid var(--line-100); display: flex; flex-direction: column; gap: 2px; }
.activity li:last-child { border-bottom: 0; }

.footer { border-top: 1px solid var(--line-300); padding-top: 16px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; color: var(--slate-500); font-size: 12px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 12px 16px; gap: 12px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav__group { display: none; }
  .nav__link { padding: 10px 12px; }
  .identity { display: none; }
  .page, .topbar { padding-left: 16px; padding-right: 16px; }
}
@media (max-width: 600px) {
  .tiles, .dl, .dl--3, .steps { grid-template-columns: 1fr; }
  .review-row { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 26px; }
  .topbar .select { min-width: 0; width: 100%; }
  .topbar__org { width: 100%; }
}
