/* MedOps — design system.
   Muted, restrained, financial. One accent for bid, one for ask, one for interaction.
   Light ground: this gets projected at 1080p in a lit room. */

:root {
  --bg:        #f4f3f0;
  --surface:   #fbfaf8;
  --surface-2: #f0eeea;
  --line:      #e0dcd4;
  --line-soft: #ebe8e2;

  --ink:   #23211e;
  --ink-2: #635e57;
  --ink-3: #938d84;

  --bid:  #3f7566;   /* muted teal — what the market will pay you */
  --ask:  #a8624a;   /* muted clay — what you must pay the market */
  --accent: #3c586a; /* slate — interactive only */
  --warn: #8a6d2f;

  --r: 3px;
  --pad: 20px;
  --maxw: 1440px;

  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Dark ground: muted, restrained — same relationships as light, not an inversion. */
:root[data-theme="dark"] {
  --bg:        #1c1b19;
  --surface:   #242320;
  --surface-2: #2b2a26;
  --line:      #3a382e;
  --line-soft: #302e28;

  --ink:   #e8e4db;
  --ink-2: #b2ab9e;
  --ink-3: #7a7468;

  --bid:  #6bab98;
  --ask:  #c68a68;
  --accent: #83a6ba;
  --warn: #c6a862;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, select, input { font: inherit; color: inherit; }

/* ---- top bar ------------------------------------------------------------ */

.topbar {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 32px;
  padding: 14px var(--pad) 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 34px; height: 34px; display: block;
}
/* Artwork is black linework on transparent — invert it so it stays visible on the
   dark ground instead of vanishing into it. */
:root[data-theme="dark"] .brand-mark { filter: invert(1); }

.wordmark {
  font-size: 19px; font-weight: 600; letter-spacing: .16em; color: var(--ink);
}

.brand-sub {
  font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
}

.brand-note { text-transform: none; letter-spacing: normal; opacity: .7; }

/* Default (browser) link blue/purple reads fine on the light ground — leave it. On
   dark it's illegible, so swap in the theme's accent color there only. */
:root[data-theme="dark"] .panel-body a,
:root[data-theme="dark"] .panel-body a:visited {
  color: var(--accent);
}

.controls { display: flex; align-items: flex-end; gap: 18px; }

.control { display: flex; flex-direction: column; gap: 4px; }

.control-label {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}

.control select {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 5px 8px; min-width: 190px;
}

.clock-row { display: flex; align-items: center; gap: 6px; }

.clock-day {
  font: 13px/1 var(--mono); font-variant-numeric: tabular-nums;
  padding: 6px 8px; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); min-width: 62px; text-align: center;
}

.btn-ghost, .btn-quiet {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  padding: 6px 10px; cursor: pointer; color: var(--ink-2);
  font-size: 13px; white-space: nowrap;
}
.btn-ghost:hover, .btn-quiet:hover { border-color: var(--ink-3); color: var(--ink); }
.btn-quiet { background: transparent; }
.btn-ghost[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }

/* ---- nav ---------------------------------------------------------------- */

.nav {
  display: flex; gap: 2px;
  padding: 0 var(--pad);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.nav button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  padding: 11px 16px; cursor: pointer; color: var(--ink-2);
  font-size: 13.5px; letter-spacing: .02em;
}
.nav button:hover { color: var(--ink); }
.nav button[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

/* ---- layout ------------------------------------------------------------- */

.view { max-width: var(--maxw); margin: 0 auto; padding: var(--pad); }

.split { display: grid; grid-template-columns: 264px minmax(0, 1fr); gap: var(--pad); align-items: start; }

.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}

.panel-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--line-soft);
}

.panel-title {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2);
}

.panel-body { padding: 16px; }

/* ---- framing band (landing) --------------------------------------------- */

.framing {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 32px; align-items: start;
  padding: 22px var(--pad); margin-bottom: var(--pad);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
}

.framing h1 {
  margin: 0 0 8px; font-size: 21px; font-weight: 600; letter-spacing: -.01em;
}

.framing p { margin: 0; color: var(--ink-2); max-width: 62ch; }
.framing p + p { margin-top: 8px; }

.contrast { border-collapse: collapse; width: 100%; font-size: 13px; }
.contrast caption {
  text-align: left; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); padding-bottom: 8px;
}
.contrast th, .contrast td {
  text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top;
}
.contrast thead th { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); font-weight: 500; }
.contrast tbody th { font-weight: 500; color: var(--ink-2); width: 32%; }
.contrast .vague { color: var(--ink-3); }
.contrast .clear { color: var(--ink); }

/* ---- filter rail -------------------------------------------------------- */

.rail .panel-body { padding: 0; }

.rail-step { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); }
.rail-step:last-child { border-bottom: 0; }

.rail-step > span {
  display: block; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--ink-3); margin-bottom: 6px;
}

.rail-step select, .rail-step input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px 8px; color: var(--ink-2);
}
.rail-step select:disabled { color: var(--ink-3); border-style: dashed; }

.hist-chip {
  display: inline-block; margin: 4px 6px 0 0; padding: 4px 9px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px;
  font-size: 11px; color: var(--ink-2); cursor: pointer;
}
.hist-chip:hover { border-color: var(--ink-3); color: var(--ink); }

/* ---- chain table -------------------------------------------------------- */

.chain { width: 100%; border-collapse: collapse; font-size: 13.5px; }

.chain thead th {
  position: sticky; top: 0; background: var(--surface);
  text-align: left; font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 500; color: var(--ink-3);
  padding: 10px 12px; border-bottom: 1px solid var(--line);
}

.chain thead th[data-sort] { cursor: pointer; user-select: none; }
.chain thead th[data-sort]:hover { color: var(--ink-2); }

.chain td { padding: 9px 12px; border-bottom: 1px solid var(--line-soft); }

.chain th:first-child, .chain td:first-child { padding-left: 16px; }
.chain th:last-child,  .chain td:last-child  { padding-right: 16px; }
.chain tbody tr:hover { background: var(--surface-2); }

.chain .num {
  text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: 13px; white-space: nowrap;
}

.chain .bid { color: var(--bid); }
.chain .ask { color: var(--ask); }
.chain .nobid { color: var(--ink-3); }

.chain .service { color: var(--ink); }
.chain .region  { color: var(--ink-2); }
.chain .lapsed  { opacity: .42; }

.chain tbody tr[data-contract] { cursor: pointer; }
.chain tbody tr.selected { background: var(--surface-2); }
.chain tbody tr.selected td:first-child { box-shadow: inset 2px 0 0 var(--accent); }

/* ---- contract detail + trade ticket -------------------------------------- */

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }

/* Collapsed, the detail panel keeps its one-line summary and drops the rule that
   would otherwise underline an empty header. */
.panel.collapsed .panel-head { border-bottom: 0; }
.head-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.detail-sum {
  flex: 1 1 auto; min-width: 0; text-align: right;
  font-size: 12.5px; color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.detail-sum .bid { color: var(--bid); }
.detail-sum .ask { color: var(--ask); }

.ticket .kv th strong, .ticket .kv td strong { color: var(--ink); }

.btn-buy {
  width: 100%; padding: 10px 14px; margin-top: 4px;
  background: var(--accent); border: 1px solid var(--accent); border-radius: var(--r);
  color: var(--bg); font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn-buy:hover { opacity: .88; }

.group-row td {
  background: var(--surface-2); color: var(--ink-2);
  font-size: 11px; letter-spacing: .08em; text-transform: uppercase;
  padding: 8px 12px; border-bottom: 1px solid var(--line);
}

.spark { display: inline-block; width: 6px; text-align: center; color: var(--ink-3); font-size: 11px; }
.spark.up   { color: var(--bid); }
.spark.down { color: var(--ask); }

/* ---- seller console: origination ticket ---------------------------------- */

.form-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(184px, 1fr)); gap: 14px 16px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.field > span {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3);
}

.field select, .field input {
  width: 100%; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r); padding: 6px 8px; color: var(--ink-2);
}
.field input { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.field input[readonly] { color: var(--ink-3); border-style: dashed; }

.match-line { font-size: 12.5px; color: var(--ink-2); margin: 14px 0 0; max-width: 78ch; }

.btn-buy.inline { width: auto; padding: 9px 20px; margin-top: 12px; }

.msg { font-size: 12.5px; line-height: 1.5; margin: 0 0 14px; max-width: 78ch; }
.msg.ok  { color: var(--bid); }
.msg.err { color: var(--ask); }

.qty-in {
  width: 58px; padding: 3px 6px; text-align: right;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 12px;
}

/* ---- small parts -------------------------------------------------------- */

.chip {
  display: inline-block; padding: 2px 7px; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 10.5px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3);
  white-space: nowrap;
}
.chip.phase { border-style: dashed; }
.chip.pass { color: var(--bid); border-color: var(--bid); }
.chip.fail { color: var(--ask); border-color: var(--ask); }

/* ---- governance ballot --------------------------------------------------- */

.prop {
  padding: 16px 18px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.prop:last-of-type { margin-bottom: 0; }
.prop-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; }
.prop-head h3 { margin: 0 0 8px; font: 500 15px/1.35 var(--sans); color: var(--ink); }
.prop-body { font-size: 13px; line-height: 1.6; color: var(--ink-2); margin: 10px 0 0; max-width: 82ch; }

.tally {
  display: flex; height: 5px; margin: 14px 0 6px;
  background: var(--line); border-radius: 3px; overflow: hidden;
}
.tally i { display: block; height: 100%; }
.tally .y { background: var(--bid); }
.tally .n { background: var(--ask); }

.cond { font-size: 11px; color: var(--warn); }

.stats { display: flex; flex-wrap: wrap; gap: 10px; }

.stat {
  width: 168px; padding: 12px 14px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
}
.stat b {
  display: block; font: 500 20px/1.2 var(--mono); font-variant-numeric: tabular-nums;
  color: var(--ink); margin-bottom: 3px;
}
.stat span { font-size: 11px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }

.empty {
  padding: 44px 24px; text-align: center; color: var(--ink-3);
  border: 1px dashed var(--line); border-radius: var(--r); background: var(--surface-2);
}
.empty strong { display: block; color: var(--ink-2); font-weight: 500; margin-bottom: 6px; }

.note { font-size: 12.5px; color: var(--ink-3); margin: 10px 0 0; }

.kv { border-collapse: collapse; font-size: 13.5px; width: 100%; }
.kv th {
  text-align: left; font-weight: 400; color: var(--ink-3); padding: 6px 28px 6px 0;
  white-space: nowrap; vertical-align: top; width: 1%;
}
.kv td { padding: 6px 0; vertical-align: top; width: 99%; }
.kv .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.holdings { width: 100%; border-collapse: collapse; font-size: 13px; }
.holdings th {
  text-align: left; font-size: 10px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 500; padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.holdings td { padding: 8px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.holdings tbody tr:hover { background: var(--surface-2); }
.holdings .num { text-align: right; font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.row-actions button { padding: 4px 9px; font-size: 12px; }
.row-actions button[disabled] { opacity: .5; cursor: default; }

/* ---- info tooltip / popup (hover or click) ------------------------------- */

.tip {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; margin-left: 5px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line);
  font-size: 10px; line-height: 1; color: var(--ink-3); cursor: help;
  vertical-align: middle; user-select: none;
}
.tip-bubble {
  display: none; position: absolute; left: 50%; bottom: calc(100% + 7px); transform: translateX(-50%);
  width: max-content; max-width: 240px; padding: 8px 10px;
  background: var(--ink); color: var(--bg); font-size: 11.5px; line-height: 1.45;
  border-radius: var(--r); z-index: 5; text-align: left; font-weight: 400;
  letter-spacing: normal; text-transform: none; pointer-events: none;
}
.tip:hover .tip-bubble, .tip:focus .tip-bubble, .tip.open .tip-bubble { display: block; }

/* ---- exercise: provider picker ------------------------------------------- */

.provider-pick { padding: 10px 0 2px; }
.provider-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 4px;
  border-bottom: 1px solid var(--line-soft); cursor: pointer; font-size: 13px;
}
.provider-row:last-of-type { border-bottom: 0; }
.provider-row span:nth-child(2) { flex: 1 1 auto; color: var(--ink); }
.provider-row span:nth-child(3) { color: var(--ink-3); font-size: 12px; }

/* ---- bought confirmation -------------------------------------------------- */

.bought-confirm {
  display: flex; align-items: center; gap: 4px; margin-top: 4px;
  font-size: 13.5px; color: var(--ink);
}
.bought-confirm .tip-check {
  color: var(--bid); font-weight: 700;
}

/* ---- images embedded in About / FAQ content ------------------------------ */

.content-img {
  display: block; max-width: 100%; margin-top: 10px;
  border: 1px solid var(--line); border-radius: var(--r);
}

/* ---- FAQ ------------------------------------------------------------------ */

.faq details {
  padding: 12px 4px; border-bottom: 1px solid var(--line-soft);
}
.faq details:last-of-type { border-bottom: 0; }
.faq summary {
  cursor: pointer; font-size: 14px; color: var(--ink); font-weight: 500;
}
.faq summary::marker { color: var(--ink-3); }
.faq details p { margin: 10px 0 0; color: var(--ink-2); font-size: 13.5px; line-height: 1.6; max-width: 78ch; }

/* ---- feedback form --------------------------------------------------------- */

.feedback-form { display: flex; flex-direction: column; gap: 12px; max-width: 520px; }
.feedback-form textarea {
  width: 100%; min-height: 92px; resize: vertical;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 10px; color: var(--ink); font: inherit;
}
.feedback-check {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2);
  cursor: pointer;
}
.feedback-form input[type="text"] {
  width: 100%;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 10px; color: var(--ink); font: inherit;
}

/* ---- confirm pop-up: gates every buy/sell action behind a deliberate click ----- */

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: var(--pad);
}
.modal-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: 0 12px 32px rgba(0, 0, 0, .28);
  max-width: 420px; width: 100%; padding: 20px;
}
.modal-box h3 { margin: 0 0 8px; font-size: 15px; color: var(--ink); }
.modal-box .note { margin: 0; max-width: none; }

.disclaimer {
  max-width: var(--maxw); margin: 8px auto 28px; padding: 0 var(--pad);
  font-size: 11.5px; line-height: 1.6; color: var(--ink-3);
}

/* ---- responsive: laptop width and projector ----------------------------- */

@media (max-width: 1100px) {
  .framing { grid-template-columns: 1fr; gap: 20px; }
  .split { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
}

@media (max-width: 780px) {
  .topbar { flex-direction: column; align-items: flex-start; gap: 14px; }
  .controls { flex-wrap: wrap; gap: 12px; }
}
