/* IndexLoom. Indigo-dye ink on cool paper; numbers set in tabular figures.
   The one flourish is the two-thread bar that shows actual against target. */
:root {
  --paper: #f3f5f7;
  --sheet: #ffffff;
  --ink: #1b2a3a;
  --quiet: #5c6b7a;
  --rule: #d5dbe2;
  --indigo: #2f4ba0;
  --indigo-pale: #e4e9f6;
  --gain: #1f7a5c;
  --loss: #a8323a;
  --warn-bg: #fbeeee;
  --ok-bg: #e9f4ef;
  --title: Charter, "Bitstream Charter", "Iowan Old Style", Georgia, serif;
  --body: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { font-size: 16px; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--body); line-height: 1.5; font-variant-numeric: tabular-nums;
}
a { color: var(--indigo); }
:focus-visible { outline: 3px solid var(--indigo); outline-offset: 2px; }

.masthead { background: var(--ink); color: #fff; }
.masthead-inner {
  max-width: 1120px; margin: 0 auto; padding: 0.75rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1.5rem;
}
.brand { font-family: var(--title); font-size: 1.35rem; letter-spacing: 0.01em; color: #fff; text-decoration: none; }
.masthead nav { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; flex: 1; }
.masthead nav a { color: #c9d3e6; text-decoration: none; padding: 0.15rem 0; border-bottom: 2px solid transparent; }
.masthead nav a:hover, .masthead nav a[aria-current="page"] { color: #fff; border-bottom-color: #8fa4e0; }
.who { color: #c9d3e6; font-size: 0.875rem; display: flex; gap: 0.75rem; align-items: baseline; }
.linkish { background: none; border: 0; padding: 0; color: #c9d3e6; font: inherit; text-decoration: underline; cursor: pointer; }

main { max-width: 1120px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }
h1 { font-family: var(--title); font-weight: 600; font-size: 1.9rem; line-height: 1.2; margin: 0.25rem 0 0.25rem; }
h2 { font-family: var(--title); font-weight: 600; font-size: 1.3rem; margin: 2rem 0 0.5rem; }
.lede { color: var(--quiet); max-width: 68ch; margin: 0 0 1.25rem; }
.note { color: var(--quiet); font-size: 0.9rem; max-width: 72ch; }

.flash { padding: 0.6rem 0.9rem; border-left: 4px solid var(--gain); background: var(--ok-bg); margin: 0 0 1rem; }
.flash.error, .problem { border-left: 4px solid var(--loss); background: var(--warn-bg); padding: 0.6rem 0.9rem; margin: 0 0 1rem; }

.sheet { background: var(--sheet); border: 1px solid var(--rule); padding: 1rem 1.1rem; margin: 0 0 1.25rem; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0.75rem 2rem; margin: 0; }
.facts div { border-top: 2px solid var(--ink); padding-top: 0.4rem; }
.facts dt { color: var(--quiet); font-size: 0.875rem; }
.facts dd { margin: 0; font-size: 1.25rem; }

table { border-collapse: collapse; width: 100%; background: var(--sheet); }
th, td { padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: baseline; }
thead th { font-weight: 600; font-size: 0.875rem; color: var(--quiet); border-bottom: 2px solid var(--ink); position: sticky; top: 0; background: var(--sheet); }
td.num, th.num { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); }
.gain { color: var(--gain); }
.loss { color: var(--loss); }
.muted { color: var(--quiet); }
.tag { font-size: 0.8rem; padding: 0.05rem 0.4rem; background: var(--indigo-pale); color: var(--indigo); border-radius: 2px; white-space: nowrap; }
.sell { color: var(--loss); font-weight: 600; }
.buy { color: var(--indigo); font-weight: 600; }

/* Two threads: the pale one is the target weight, the dark one what is held. */
.threads { position: relative; width: 120px; height: 14px; display: inline-block; vertical-align: middle; }
.threads i { position: absolute; left: 0; height: 4px; border-radius: 2px; }
.threads .target { top: 2px; background: #9db0e3; }
.threads .actual { top: 8px; background: var(--ink); }

form.inline { display: inline; }
label { display: block; font-weight: 600; margin-bottom: 0.2rem; }
.hint { display: block; font-weight: 400; color: var(--quiet); font-size: 0.875rem; }
input[type="text"], input[type="number"], select, input[type="file"] {
  font: inherit; padding: 0.4rem 0.5rem; border: 1px solid #9aa7b5; background: #fff; color: var(--ink); width: 100%; max-width: 16rem;
}
td input[type="text"] { width: 6.5rem; padding: 0.2rem 0.4rem; text-align: right; }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem 1.5rem; }
fieldset { border: 0; border-top: 2px solid var(--ink); padding: 0.75rem 0 0; margin: 0 0 1.5rem; }
legend { font-family: var(--title); font-size: 1.15rem; font-weight: 600; padding: 0 0.5rem 0 0; }
button, .button {
  font: inherit; font-weight: 600; padding: 0.5rem 1rem; border: 1px solid var(--indigo);
  background: var(--indigo); color: #fff; cursor: pointer; text-decoration: none; display: inline-block; border-radius: 3px;
}
button.secondary, .button.secondary { background: #fff; color: var(--indigo); }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; margin: 1rem 0; }
.check { display: flex; gap: 0.5rem; align-items: baseline; font-weight: 400; }
.check input { width: auto; }

details.stock > summary, details.acct > summary { list-style: none; cursor: pointer; }
details.stock > summary::-webkit-details-marker, details.acct > summary::-webkit-details-marker { display: none; }
.row { display: grid; align-items: baseline; gap: 0.5rem; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--rule); }
.row.stock-row, .row.head { grid-template-columns: 1.2rem 5rem minmax(8rem, 1fr) 6rem 8rem 9rem 4.5rem 4.5rem 8rem; }
.row.head { font-size: 0.875rem; font-weight: 600; color: var(--quiet); border-bottom: 2px solid var(--ink); }
.row > .num { text-align: right; white-space: nowrap; }
.twist { color: var(--quiet); transition: transform 0.12s; display: inline-block; }
details[open] > summary .twist { transform: rotate(90deg); }
details.stock[open] > summary .row { background: var(--indigo-pale); }
.inner { padding: 0 0 0.5rem 1.8rem; background: #f8f9fb; border-bottom: 1px solid var(--rule); }
.row.acct-row { grid-template-columns: 1.2rem minmax(10rem, 1fr) 6rem 8rem 8rem 8rem; border-bottom: 1px dashed var(--rule); }
.inner table { background: transparent; margin: 0 0 0.25rem 1.2rem; width: calc(100% - 1.2rem); font-size: 0.925rem; }
.inner thead th { position: static; background: transparent; border-bottom: 1px solid var(--quiet); }
.positions { background: var(--sheet); border: 1px solid var(--rule); overflow-x: auto; }
.positions-inner { min-width: 900px; }
pre.report { background: var(--sheet); border: 1px solid var(--rule); padding: 1rem; overflow-x: auto; font-size: 0.85rem; line-height: 1.45; }
tr.placed td { color: var(--quiet); text-decoration: line-through; }
tr.placed td:first-child { text-decoration: none; }
.login { max-width: 30rem; margin: 4rem auto; }
@media (prefers-reduced-motion: reduce) { .twist { transition: none; } }
@media (max-width: 640px) { h1 { font-size: 1.5rem; } }
