/* The shared page grammar (docs/design-guidelines.md): one vocabulary for every page, linked by
   _grammar.html, which base.html includes after its own stylesheet. It was inlined into every
   page; as a file it is fetched once and cached (?v= from static_v changes with the file). */
  :root {
    --warn:       #D97706;   /* amber: warn / stale / dormant / over a threshold */
    --warn-bg:    #FEF3C7;
    --warn-ink:   #92400E;
    --warn-deep:  #78350F;
    --run-bg:     #DBEAFE;   /* blue: running / in flight */
    --run-ink:    #1E3A8A;
    --brass:      #b4771a;   /* brass: idle cash, the "under target" nudge */
    --brass-bg:   #FBF6EC;
    --brass-ink:  #8a6312;
    --info-bg:    #E0E7FF;   /* indigo: neutral secondary state (bought back, proposed) */
    --info-ink:   #3730A3;
    --gain-fill:  #DCFCE7;   /* solid tints for pills that sit on tinted rows */
  }

  /* ---- the container: main.page IS the container (1800px, 44px gutters). The two
     wrapper aliases are no-ops kept for pages written against the old dialects. ---- */
  .op-wrap, .st-wrap { max-width: 1800px; margin: 0 auto; }

  /* ---- the lead paragraph under a page head: one or two sentences, a measure ---- */
  .lead, .op-lead, .st-lead { font-family: 'Newsreader', serif; font-size: 0.98rem; line-height: 1.55; color: var(--ink-mute); max-width: 80ch; margin: 0 0 18px; }
  .lead a, .op-lead a, .st-lead a, .page-head .meta a { color: var(--navy); }

  /* ---- breadcrumb above a page head ---- */
  .crumb, .op-crumb, .st-crumb { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.88rem; color: var(--ink-faint); margin: 0 0 10px; }
  .crumb a, .op-crumb a, .st-crumb a { color: var(--ink-faint); }
  .crumb a:hover, .op-crumb a:hover, .st-crumb a:hover { color: var(--navy); text-decoration: none; }
  .page-head .meta .st-tags, .page-head .meta .tags { display: flex; gap: 10px; align-items: center; justify-content: flex-end; flex-wrap: wrap; margin-bottom: 6px; }
  .op-hidden, .hidden { display: none; }

  /* ---- the summary band: a sensible default column count, so a page that forgets
     the inline grid still reads as a band (inline styles still win) ---- */
  .summary { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

  /* ---- the spacing scale for the gaps pages used to hand-tune inline ---- */
  .section-bar.gap-sm { margin-top: 18px; }
  .section-bar.gap    { margin-top: 30px; }
  .section-bar.gap-lg { margin-top: 40px; }

  /* ---- the tag: a small tracked mono word for a STATE. Always a word, never a colour
     alone. Variants recolour the fill and drop the border so every tag has the same box. ---- */
  .tag, .op-tag, .st-status { display: inline-block; font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.62rem; font-style: normal; font-weight: 400; letter-spacing: 0.1em; text-transform: uppercase; padding: 3px 8px; border-radius: 2px; vertical-align: middle; white-space: nowrap; line-height: 1.2; background: var(--bg-row); color: var(--ink-mute); border: 1px solid var(--rule); }
  .tag.ok,   .op-tag.ok,   .st-status.active  { background: rgba(21, 128, 61, 0.10); color: var(--gain-deep); border-color: transparent; }
  .tag.bad,  .op-tag.bad                       { background: var(--loss-bg); color: var(--loss-deep); border-color: transparent; }
  .tag.run,  .op-tag.run                       { background: var(--run-bg); color: var(--run-ink); border-color: transparent; }
  .tag.warn, .op-tag.warn, .st-status.dormant  { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
  .tag.navy, .op-tag.navy                      { background: rgba(15, 42, 74, 0.08); color: var(--navy); border-color: transparent; }
  .tag.info                                     { background: var(--info-bg); color: var(--info-ink); border-color: transparent; }
  .tag.brass                                    { background: var(--brass-bg); color: var(--brass-ink); border-color: transparent; }
  .tag.quiet, .st-status.retired                { background: var(--bg-row); color: var(--ink-faint); border-color: var(--rule); }
  .st-kind { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.86rem; color: var(--ink-faint); }
  .st-id, .id { font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.72rem; font-style: normal; letter-spacing: 0.03em; color: var(--ink-faint); }
  .summary .sub a, .summary .lbl a { color: var(--navy); }   /* grey italic context: links are navy */

  /* ---- the state word: icon + word in the tag voice, no box (tables, cards) ---- */
  .state { display: inline-flex; align-items: center; gap: 5px; font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.66rem; font-style: normal; letter-spacing: 0.07em; text-transform: uppercase; white-space: nowrap; color: var(--ink-mute); }
  .state.ok { color: var(--gain-deep); }
  .state.bad { color: var(--loss-deep); }
  .state.run { color: var(--run-ink); }
  .state.warn { color: var(--warn-ink); }
  .state.info { color: var(--info-ink); }
  .state.dim { color: var(--ink-ghost); }

  /* ---- the outcome pill on closed contracts (the /options vocabulary) ---- */
  .oc-pill { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 0.7rem; font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; letter-spacing: .02em; white-space: nowrap; }
  .oc-expired { background: var(--gain-fill); color: var(--gain); }
  .oc-bought-back { background: var(--info-bg); color: var(--info-ink); }
  .oc-assigned { background: var(--warn-bg); color: var(--warn-ink); }
  .neg { color: var(--loss); }

  /* ---- notice bands: a sentence the reader must not miss, under the page head ---- */
  .notice, .op-notice, .st-notice { margin: 0 0 18px; padding: 12px 18px; border: 1px solid var(--rule); border-left: 3px solid var(--ink-thin); background: var(--bg-tint); font-family: 'Newsreader', serif; font-size: 0.95rem; line-height: 1.5; color: var(--ink-mute); }
  .notice.warn, .op-notice.warn, .st-notice.warn { border-left-color: var(--warn); background: var(--warn-bg); color: var(--warn-deep); }
  .notice.bad { border-left-color: var(--loss); background: var(--loss-bg); color: var(--loss-deep); }
  .notice.ok { border-left-color: var(--gain); background: rgba(21, 128, 61, 0.07); color: var(--gain-deep); }
  .notice strong, .op-notice strong, .st-notice strong { font-weight: 500; color: var(--ink); }
  .notice a, .op-notice a, .st-notice a { color: var(--navy); }

  /* ---- filter pills: the one control that sits inside a section bar or a page head ---- */
  .pills, .op-filter { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-right: 10px; }
  .pills a, .op-filter a { font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.72rem; letter-spacing: 0.03em; text-decoration: none; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--rule); color: var(--ink-mute); background: var(--bg); font-style: normal; }
  .pills a:hover, .op-filter a:hover { text-decoration: none; border-color: var(--navy); color: var(--navy); }
  .pills a.on, .pills a.on:hover, .op-filter a.on, .op-filter a.on:hover { background: var(--navy); color: #fff; border-color: var(--navy); }

  /* ---- ledger tables of TEXT (left-aligned): the base ledger is numeric and right-aligns ---- */
  table.ledger.text-table thead th, table.ledger.op-table thead th, table.ledger.st-table thead th { text-align: left; }
  table.ledger.text-table thead th.r, table.ledger.op-table thead th.r, table.ledger.st-table thead th.r { text-align: right; }
  table.ledger.text-table thead th[title], table.ledger.op-table thead th[title], table.ledger.st-table thead th[title] { cursor: help; }
  table.ledger.text-table td.r, table.ledger.op-table td.r, table.ledger.st-table td.r { text-align: right; }
  table.ledger.text-table td.txt, table.ledger.op-table td.txt, table.ledger.st-table td.txt { font-family: 'Newsreader', serif; font-size: 0.92rem; color: var(--ink-2); }
  table.ledger.text-table td.mono-cell, table.ledger.op-table td.mono-cell, table.ledger.st-table td.mono-cell { font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.78rem; color: var(--ink-2); }
  table.ledger tbody tr[data-href] { cursor: pointer; }
  table.ledger tbody tr.bad { background: rgba(220, 38, 38, 0.035); }
  table.ledger tbody tr.over td { background: rgba(217, 159, 33, 0.09); }
  table.ledger tbody tr.day-row td { background: var(--bg-tint); font-family: 'Newsreader', serif; font-style: italic; font-size: 0.82rem; color: var(--ink-faint); padding: 6px 18px; border-bottom: 1px solid var(--rule); }
  table.ledger tbody tr.dormant-row .sym-name,
  table.ledger tbody tr.dormant-row td.num-cell:not(.gain):not(.loss) .v { color: var(--ink-faint); }
  table.ledger tbody tr.st-transfer td, table.ledger tbody tr.st-mark td, table.ledger tbody tr.synthetic td { background: var(--bg-tint); }
  table.ledger tbody tr.st-transfer .sym-name, table.ledger tbody tr.st-mark .sym-name, table.ledger tbody tr.synthetic .sym-name { color: var(--ink-mute); }
  .st-why, .why { font-style: italic; color: var(--ink-faint); font-size: 0.86rem; }
  .subline, .op-sub, .st-sub { display: block; font-family: 'Newsreader', serif; font-style: italic; font-size: 0.74rem; color: var(--ink-faint); margin-top: 3px; line-height: 1.3; white-space: normal; }
  .clip, .op-clip { display: block; max-width: 440px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .empty, .op-empty, .st-empty { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.92rem; color: var(--ink-faint); margin: 12px 0 0; }
  .foot, .op-foot { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.82rem; color: var(--ink-faint); margin: 18px 0 0; }

  /* ---- key / value lists: the key in prose, the value in mono (a literal) ---- */
  .kv, .op-kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); gap: 0; margin: 0; }
  .kv dt, .kv dd, .op-kv dt, .op-kv dd { margin: 0; padding: 7px 0; border-bottom: 1px solid var(--rule-faint); line-height: 1.45; }
  .kv dt, .op-kv dt { font-family: 'Newsreader', serif; font-size: 0.9rem; color: var(--ink-mute); padding-right: 14px; }
  .kv dd, .op-kv dd { font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.78rem; color: var(--ink); overflow-wrap: anywhere; }
  .kv dd.txt, .op-kv dd.txt { font-family: 'Newsreader', serif; font-size: 0.9rem; }
  .kv dd.over, .op-kv dd.over { color: var(--warn-ink); }
  table.mini, table.op-mini { width: 100%; border-collapse: collapse; }
  table.mini th, table.op-mini th { text-align: left; font-family: 'Newsreader', serif; font-weight: 600; font-size: 0.62rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-mute); padding: 6px 8px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
  table.mini th.r, table.mini td.r, table.op-mini th.r, table.op-mini td.r { text-align: right; }
  table.mini td, table.op-mini td { padding: 6px 8px; border-bottom: 1px solid var(--rule-faint); font-family: 'Newsreader', serif; font-size: 0.9rem; color: var(--ink-2); vertical-align: top; }
  table.mini td.mono-cell, table.op-mini td.mono-cell { font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.78rem; }
  table.mini tr.over td, table.op-mini tr.over td { background: rgba(217, 159, 33, 0.09); }

  /* ---- chips: a small bordered link or label, square-cornered like everything else ---- */
  .chips, .op-chips { display: flex; flex-wrap: wrap; gap: 6px; }
  .kchip, .op-chip { display: inline-flex; align-items: baseline; gap: 6px; padding: 3px 10px; border: 1px solid var(--rule); border-radius: 2px; font-family: 'Newsreader', serif; font-size: 0.88rem; color: var(--ink-2); text-decoration: none; background: var(--bg); }
  a.kchip:hover, a.op-chip:hover { border-color: var(--navy); color: var(--navy); text-decoration: none; }
  .kchip .sz, .op-chip .sz { font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.64rem; color: var(--ink-ghost); letter-spacing: 0.03em; }
  .kchip.present, .op-chip.present { border-color: rgba(21, 128, 61, 0.35); color: var(--gain-deep); font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.72rem; }
  .kchip.missing, .op-chip.missing { border-color: rgba(220, 38, 38, 0.4); color: var(--loss-deep); font-family: 'Recursive', monospace; font-variation-settings: 'MONO' 1; font-size: 0.72rem; }

  /* ---- a fold: a details block whose summary reads as a quiet italic line ---- */
  details.fold > summary { cursor: pointer; list-style: none; font-family: 'Newsreader', serif; font-style: italic; font-size: 0.92rem; color: var(--ink-mute); margin: 0 0 12px; display: inline-flex; align-items: center; gap: 6px; }
  details.fold > summary::-webkit-details-marker { display: none; }
  details.fold > summary:hover { color: var(--navy); }
  details.fold[open] > summary .ico.chev { transform: rotate(180deg); }

  /* ---- icons: the sprite in _icons.html; a stroke on currentColor, always beside a word ---- */
  .ico { width: 15px; height: 15px; vertical-align: -3px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
  .ico.lg { width: 28px; height: 28px; vertical-align: -7px; stroke-width: 1.7; }
  .ico.sm { width: 13px; height: 13px; vertical-align: -2px; }

  /* ---- the equation walk: an arithmetic with the operators drawn ---- */
  .eq-strip { display: grid; grid-template-columns: 1fr auto 1fr auto 1fr auto 1.15fr; align-items: center; gap: 4px; margin-top: 16px; border: 1px solid var(--rule); border-radius: 4px; padding: 20px 18px; background: var(--bg-row); }
  .eq-term { display: flex; flex-direction: column; gap: 3px; padding: 0 10px; min-width: 0; }
  .eq-lbl { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.82rem; color: var(--ink-mute); }
  .eq-val { font-family: 'Fraunces', serif; font-variation-settings: 'opsz' 40; font-feature-settings: 'tnum', 'lnum'; font-size: 1.85rem; font-weight: 600; line-height: 1.1; }
  .eq-sub { font-family: 'Newsreader', serif; font-size: 0.76rem; color: var(--ink-faint); line-height: 1.35; }
  .eq-op { font-family: 'Fraunces', serif; font-size: 1.5rem; color: var(--ink-thin); text-align: center; padding: 0 2px; align-self: center; }
  .eq-equals { color: var(--ink-mute); font-weight: 600; }
  .eq-result { border-left: 2px solid var(--navy); padding-left: 16px; }
  .eq-result .eq-val { font-size: 2.15rem; }
  .eq-result .eq-lbl { color: var(--navy); font-style: normal; font-weight: 600; }
  .eq-aside { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-top: 10px; padding: 0 18px; }
  .eq-aside-lbl { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.82rem; color: var(--ink-mute); }
  .eq-aside-val { font-family: 'Fraunces', serif; font-variation-settings: 'opsz' 40; font-feature-settings: 'tnum', 'lnum'; font-size: 1.15rem; font-weight: 560; }
  .eq-aside-note { font-family: 'Newsreader', serif; font-size: 0.78rem; color: var(--ink-faint); }

  /* ---- the verdict band: the answer first (Fleet, and any page whose first job is
     "is it fine?"): one wide cell for the verdict, three facts beside it ---- */
  .verdict { display: grid; grid-template-columns: minmax(0, 1.55fr) repeat(3, minmax(0, 1fr)); border: 1px solid var(--rule); border-left: 4px solid var(--ink-thin); background: var(--bg); margin: 0 0 28px; }
  .verdict.ok { border-left-color: var(--gain); }
  .verdict.bad { border-left-color: var(--loss); }
  .verdict.warn { border-left-color: var(--warn); }
  .verdict > div { padding: 18px 22px 16px; border-right: 1px solid var(--rule); min-width: 0; }
  .verdict > div:last-child { border-right: 0; }
  .verdict .lbl { display: flex; align-items: center; gap: 6px; font-family: 'Newsreader', serif; font-weight: 600; font-size: 0.64rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 9px; }
  .verdict .v { display: flex; align-items: center; gap: 10px; font-family: 'Fraunces', serif; font-variation-settings: 'opsz' 60; font-weight: 420; font-size: 30px; letter-spacing: -0.015em; line-height: 1.05; color: var(--ink); min-height: 34px; }
  .verdict .v.ok { color: var(--gain); }
  .verdict .v.bad { color: var(--loss); }
  .verdict .v.warn { color: var(--warn-ink); }
  .verdict .v.run { color: var(--run-ink); }
  .verdict .v .small { font-size: 20px; }
  .verdict .sub { display: block; font-family: 'Newsreader', serif; font-style: italic; font-size: 0.86rem; line-height: 1.45; color: var(--ink-mute); margin-top: 8px; }
  .verdict .sub a { color: var(--navy); }
  .verdict .sub .loss { color: var(--loss-deep); font-style: normal; }

  /* ---- buttons: one shape for every action. Default = a quiet bordered button;
     .primary = navy fill, the one action a form exists for; .sm for row actions;
     .danger for the destructive one. A link that acts like a button uses the class. ---- */
  .btn { display: inline-flex; align-items: center; gap: 6px; font-family: 'Newsreader', serif; font-size: 0.88rem; font-weight: 480; font-style: normal; line-height: 1.2; padding: 6px 14px; border: 1px solid var(--ink-thin); border-radius: 2px; background: var(--bg); color: var(--ink-2); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background 0.16s, border-color 0.16s, color 0.16s; }
  .btn:hover { background: var(--bg-row); border-color: var(--ink-mute); color: var(--ink); text-decoration: none; }
  .btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
  .btn.primary { background: var(--navy); border-color: var(--navy); color: #fff; }
  .btn.primary:hover { background: var(--navy-deep); border-color: var(--navy-deep); color: #fff; }
  .btn.ok { background: var(--gain); border-color: var(--gain); color: #fff; }
  .btn.ok:hover { background: var(--gain-deep); border-color: var(--gain-deep); }
  .btn.danger:hover { border-color: var(--loss); color: var(--loss-deep); background: var(--loss-bg); }
  .btn.sm { font-size: 0.78rem; padding: 3px 10px; gap: 4px; }
  .btn[disabled], .btn.disabled { background: var(--bg-row); border-color: var(--rule); color: var(--ink-ghost); cursor: not-allowed; }
  form.inline { display: inline; margin: 0; }

  /* ---- form fields: text inputs, selects and text areas, one look ---- */
  .field { font-family: 'Newsreader', serif; font-size: 0.92rem; font-style: normal; padding: 6px 10px; border: 1px solid var(--rule); border-radius: 2px; background: var(--bg); color: var(--ink); min-width: 0; }
  .field:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 2px rgba(15, 42, 74, 0.12); }
  .field::placeholder { color: var(--ink-ghost); font-style: italic; text-transform: none; letter-spacing: 0; }
  textarea.field { line-height: 1.5; resize: vertical; }

  /* ---- a table too dense for the container scrolls inside its own box, never the page.
     On the phone a ledger becomes cards anyway, so the box only matters on desktop. ---- */
  .table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table-scroll > table { min-width: 100%; }

  /* ---- a ledger's total row on the desktop (base styles it only on the phone);
     a page with its own footer grammar (Holdings' bridge) overrides it locally ---- */
  @media (min-width: 769px) {
    table.ledger tfoot tr.total-row td { background: var(--bg-tint); border-top: 1px solid var(--ink-thin); border-bottom: 0; padding-top: 12px; padding-bottom: 12px; }
    table.ledger tfoot tr.total-row td.num-cell .v { font-weight: 500; }
    table.ledger tfoot tr.total-row .total-label { font-family: 'Newsreader', serif; font-size: 0.95rem; font-weight: 600; color: var(--ink); }
  }

  /* ---- an empty table: one full-width row holding a sentence ---- */
  table.ledger td.empty, table.mini td.empty { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.92rem; color: var(--ink-faint); text-align: left; padding: 16px 18px; }

  /* ---- a row that opens something: the first cell carries a real link (keyboard,
     middle-click), and data-href on the <tr> makes the whole row clickable ---- */
  table.ledger tbody tr[data-href]:hover .sym-name, table.ledger tbody tr[data-href]:hover .sym-link { color: var(--navy); }

  /* ---- the stale/error line under a page head, one voice for every page ---- */
  .stale-line { font-family: 'Newsreader', serif; font-style: italic; font-size: 0.92rem; color: var(--warn-deep); background: var(--warn-bg); border: 1px solid var(--warn); border-radius: 3px; padding: 8px 14px; margin: 0 0 16px; }

  @media (max-width: 768px) {
    .clip, .op-clip { max-width: 100%; white-space: normal; }
    .kv, .op-kv { grid-template-columns: 1fr; }
    .kv dt, .op-kv dt { border-bottom: 0; padding-bottom: 0; }
    .page-head .meta .pills, .page-head .meta .op-filter, .page-head .meta .st-tags, .page-head .meta .tags { justify-content: flex-start; }
    .verdict { grid-template-columns: 1fr; }
    .verdict > div { border-right: 0; border-bottom: 1px solid var(--rule); }
    .verdict > div:last-child { border-bottom: 0; }
    .verdict .v { font-size: 24px; }
    .eq-strip { grid-template-columns: 1fr; gap: 2px; padding: 16px 14px; }
    .eq-op { text-align: left; padding: 4px 10px; }
    .eq-result { border-left: none; border-top: 2px solid var(--navy); padding-left: 10px; padding-top: 10px; margin-top: 6px; }
    .btn { padding: 8px 14px; }
    .btn.sm { padding: 5px 10px; }
  }
