:root {
  --bg: #eef0ee;
  --surface: #f8f9f7;
  --surface-2: #e4e7e4;
  --line: #d3d8d4;
  --text: #182028;
  --muted: #56616b;
  --accent: #a67c1c;
  --accent-ink: #fbf7ec;
  --accent-soft: #f1e6c9;
  --good: #1d7a4a;
  --good-soft: #dcefe3;
  --warn: #9a5b12;
  --warn-soft: #f6e5cc;
  --bad: #b23a3a;
  --e0: #6b7580; --e1: #2f8a4c; --e2: #2c6cb8; --e3: #7a45b5; --e4: #b8860b;
  --radius: 8px;
  --sans: "Archivo", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #11151a; --surface: #171c22; --surface-2: #1f262e; --line: #2a323b;
    --text: #e6e9ec; --muted: #939ea8;
    --accent: #d8ae4f; --accent-ink: #1a1508; --accent-soft: #3a3020;
    --good: #58c48a; --good-soft: #173526; --warn: #e3a45a; --warn-soft: #3a2a17; --bad: #e36d6d;
    --e0: #9aa4ae; --e1: #5cc27d; --e2: #5f9ce6; --e3: #ad82e3; --e4: #e0b44a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #11151a; --surface: #171c22; --surface-2: #1f262e; --line: #2a323b;
  --text: #e6e9ec; --muted: #939ea8;
  --accent: #d8ae4f; --accent-ink: #1a1508; --accent-soft: #3a3020;
  --good: #58c48a; --good-soft: #173526; --warn: #e3a45a; --warn-soft: #3a2a17; --bad: #e36d6d;
  --e0: #9aa4ae; --e1: #5cc27d; --e2: #5f9ce6; --e3: #ad82e3; --e4: #e0b44a;
}

* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--sans); font-size: 14px; line-height: 1.45;
  padding-inline: 16px; padding-block: 0 32px;
}
.wrap { max-width: 1320px; margin: 0 auto; }

header.top {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding-block: 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -0.01em; }
.brand .route { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.brand .route b { color: var(--accent); font-weight: 600; }

.layout {
  display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 24px; padding-top: 20px;
}
@media (max-width: 900px) { .layout { grid-template-columns: minmax(0, 1fr); } }

aside.filters {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; display: grid; gap: 18px; align-self: start;
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px);
}
@media (max-width: 900px) { aside.filters { position: static; } }
.field { display: grid; gap: 6px; }
.field label, .group-label { font-size: 12px; font-weight: 600; color: var(--muted); }
.field .help { font-size: 12px; color: var(--muted); }
.input-row { display: flex; align-items: center; gap: 8px; }
input[type="number"], select {
  width: 100%; font: 500 14px var(--mono); color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
  padding: 8px 10px;
}
select { font-family: var(--sans); }
.unit { font-family: var(--mono); font-size: 12px; color: var(--muted); min-width: 28px; }
input:focus-visible, select:focus-visible, button:focus-visible, th button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 3px; gap: 3px; }
.segmented button {
  font: 600 13px var(--sans); color: var(--muted); background: transparent; border: 0;
  padding: 6px 8px; border-radius: 4px; cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(20 30 40 / .12); }

.toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.toggle input { accent-color: var(--accent); width: 18px; height: 18px; }

.scan-btn {
  font: 700 14px var(--sans); color: var(--accent-ink); background: var(--accent);
  border: 0; border-radius: 6px; padding: 11px 14px; cursor: pointer; width: 100%;
  transition: transform .12s ease, filter .12s ease;
}
.scan-btn:hover { filter: brightness(1.06); }
.scan-btn:active { transform: translateY(1px); }
.scan-btn[disabled] { opacity: .7; cursor: progress; }
.last-scan { font-size: 12px; color: var(--muted); text-align: center; }

.summary {
  display: flex; flex-wrap: wrap; gap: 8px 28px; align-items: baseline;
  padding-bottom: 14px;
}
.stat { display: flex; align-items: baseline; gap: 8px; }
.stat .v { font: 600 22px var(--mono); font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v.gold { color: var(--accent); }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; padding-bottom: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: 600 12px var(--sans); color: var(--muted); background: var(--surface);
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { color: var(--accent-ink); background: var(--accent); border-color: var(--accent); }
.search { max-width: 220px; font: 500 13px var(--sans) !important; }

.table-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 860px; }
thead th {
  text-align: right; font-size: 12px; font-weight: 600; color: var(--muted);
  padding: 0; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap;
}
thead th:first-child, thead th:nth-child(2) { text-align: left; }
th button {
  font: inherit; color: inherit; background: none; border: 0; cursor: pointer;
  padding: 10px 14px; width: 100%; text-align: inherit;
}
th button[data-active="true"] { color: var(--text); }
th button .arrow { color: var(--accent); margin-left: 4px; }
tbody td {
  padding: 10px 14px; text-align: right; white-space: nowrap;
  font-family: var(--mono); font-variant-numeric: tabular-nums; font-size: 13px;
}
tbody tr + tr td { border-top: 1px solid var(--line); }
tbody tr:hover td { background: var(--surface-2); }
td.item { text-align: left; font-family: var(--sans); font-size: 14px; }
td.qual { text-align: left; font-family: var(--sans); color: var(--muted); font-size: 13px; }
.item-cell { display: flex; align-items: center; gap: 10px; }
.tier {
  font: 600 12px var(--mono); padding: 2px 6px; border-radius: 4px; min-width: 38px; text-align: center;
  border: 1px solid currentColor;
}
.tier.e0 { color: var(--e0); } .tier.e1 { color: var(--e1); } .tier.e2 { color: var(--e2); }
.tier.e3 { color: var(--e3); } .tier.e4 { color: var(--e4); }
.item-name { font-weight: 600; }
.item-id { display: block; font: 400 11px var(--mono); color: var(--muted); }
.profit { color: var(--good); font-weight: 600; }
.margin { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--good-soft); color: var(--good); font-weight: 600; }
.age { color: var(--muted); }
.age.stale { color: var(--warn); }
.tax { color: var(--muted); }

.skeleton td span {
  display: block; height: 12px; border-radius: 4px; background: var(--surface-2);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .skeleton td span { animation: none; } .scan-btn { transition: none; } }

.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); font-size: 15px; margin-bottom: 4px; }

.progress { font: 500 12px var(--mono); color: var(--muted); padding-bottom: 10px; }
.progress[hidden] { display: none; }

footer.notes { margin-top: 18px; color: var(--muted); font-size: 12px; max-width: 80ch; display: grid; gap: 4px; }

.item-icon { width: 36px; height: 36px; flex: none; }
.error-note { font-size: 12px; color: var(--bad); text-align: center; }

/* Page tabs */
.tabs { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 6px; }
.tabs a {
  font: 600 13px var(--sans); color: var(--muted); text-decoration: none;
  padding: 6px 12px; border-radius: 4px;
}
.tabs a[aria-current="page"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(20 30 40 / .12); }
.tabs a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Crafting calculator */
.picker { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; padding-top: 20px; }
.picker .grow { flex: 1 1 280px; }
.picker input { width: 100%; font: 500 14px var(--sans); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.picker .scan-btn { width: auto; }
.picker + .progress { padding-top: 8px; min-height: 26px; }

.pick-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; text-align: left;
  font: 600 14px var(--sans); color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 6px; padding: 2px 10px 2px 4px; cursor: pointer;
}
.pick-btn:hover { border-color: var(--accent); }
.pick-btn #pickName { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick-hint { font: 500 12px var(--sans); color: var(--accent); }
#tier { min-width: 220px; }

/* Item picker dialog */
.item-picker {
  width: min(1040px, calc(100vw - 32px)); height: min(760px, calc(100vh - 48px));
  padding: 0; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text);
}
.item-picker[open] { display: flex; flex-direction: column; }
.item-picker::backdrop { background: rgb(10 14 18 / .55); }
.ip-head { display: flex; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.ip-search {
  flex: 1; min-width: 0; font: 500 15px var(--sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 9px 12px;
}
.ip-close {
  font: 600 13px var(--sans); color: var(--muted); background: transparent;
  border: 1px solid var(--line); border-radius: 6px; padding: 0 14px; cursor: pointer;
}
.ip-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 210px minmax(0, 1fr); }
.ip-cats { overflow-y: auto; padding: 8px; border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 2px; }
.ip-cat, .ip-sub {
  display: flex; justify-content: space-between; gap: 8px; text-align: left;
  font: 600 13px var(--sans); color: var(--text); background: transparent; border: 0;
  border-radius: 4px; padding: 7px 10px; cursor: pointer;
}
.ip-sub { font-weight: 500; color: var(--muted); padding-left: 22px; }
.ip-cat span, .ip-sub span { font: 500 11px var(--mono); color: var(--muted); }
.ip-cat:hover, .ip-sub:hover { background: var(--surface-2); }
.ip-cat[aria-pressed="true"], .ip-sub[aria-pressed="true"] { background: var(--accent-soft); color: var(--text); }
.ip-main { overflow-y: auto; padding: 12px; }
.ip-count { font: 500 12px var(--mono); color: var(--muted); padding-bottom: 8px; }
.ip-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 8px; }
.ip-tile {
  display: grid; justify-items: center; gap: 2px; padding: 8px 6px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; color: var(--text);
  font: 500 12px var(--sans); text-align: center;
}
.ip-tile:hover, .ip-tile:focus-visible { border-color: var(--accent); }
.ip-tile img { width: 64px; height: 64px; }
.ip-name { line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ip-tiers { font: 500 11px var(--mono); color: var(--muted); }
@media (max-width: 700px) {
  .ip-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto minmax(0, 1fr); }
  .ip-cats { flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .ip-cat, .ip-sub { white-space: nowrap; padding-left: 10px; }
}

.craft-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
@media (max-width: 980px) { .craft-layout { grid-template-columns: minmax(0, 1fr); } }
.steps { display: grid; gap: 16px; }
.results { display: grid; gap: 16px; position: sticky; top: calc(env(safe-area-inset-top, 0px) + 16px); }
@media (max-width: 980px) { .results { position: static; } }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.card h2 { margin: 0; font-size: 15px; font-weight: 700; }
.card h3 { margin: 0; font-size: 14px; font-weight: 700; }
.card h4 { margin: 6px 0 0; font-size: 12px; font-weight: 600; color: var(--muted); }
.help { font-size: 12px; color: var(--muted); margin: 0; }
.warn-text { font-size: 11px; color: var(--warn); }

.mats { display: grid; gap: 12px; }
.mat-group { display: grid; gap: 10px; }
.mat-group.refining { border: 1px solid var(--line); border-radius: 6px; padding: 12px; background: var(--bg); }
.mat-group .mode { max-width: 240px; }
.sub-rows { display: grid; gap: 8px; padding-left: 16px; border-left: 2px solid var(--line); }
.mat-row {
  display: grid; grid-template-columns: minmax(180px, 1.4fr) minmax(170px, 1.2fr) minmax(110px, .8fr) 90px;
  gap: 12px; align-items: end;
}
@media (max-width: 720px) { .mat-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } .mat-name { grid-column: 1 / -1; } }
.mat-name { display: flex; align-items: center; gap: 10px; align-self: center; }
.mat-name span { display: grid; }
.mat-name small { font-size: 12px; color: var(--muted); }
.mat-cost { display: grid; text-align: right; font: 600 14px var(--mono); font-variant-numeric: tabular-nums; }
.mat-cost small { font: 400 11px var(--sans); color: var(--muted); }
.readout { font: 500 14px var(--mono); padding: 8px 0; font-variant-numeric: tabular-nums; }
.mat-row input[type="number"], .flags input[type="number"] { min-width: 0; }

.flags { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: end; }
.flags .field.small { width: 150px; }
.field label small { font-weight: 400; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { accent-color: var(--accent); width: 16px; height: 16px; }

.result-card .headline { display: grid; gap: 4px; }
.result-card .k { font-size: 12px; color: var(--muted); font-weight: 600; }
.big { font: 600 30px var(--mono); font-variant-numeric: tabular-nums; }
.pos { color: var(--good); }
.neg { color: var(--bad); }
.margin-pill { justify-self: start; font: 600 12px var(--mono); padding: 2px 10px; border-radius: 999px; background: var(--good-soft); color: var(--good); }
.margin-pill.bad { background: var(--warn-soft); color: var(--bad); }

.breakdown { margin: 0; display: grid; gap: 6px; }
.breakdown div { display: flex; justify-content: space-between; gap: 12px; }
.breakdown dt { color: var(--muted); }
.breakdown dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.breakdown .sum { border-top: 1px solid var(--line); padding-top: 6px; font-weight: 600; }
.breakdown .sum dt { color: var(--text); }

.batch-qty { color: var(--text) !important; font-weight: 600 !important; }
.shopping { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.shopping li { display: flex; align-items: center; gap: 10px; }
.shopping li span { display: grid; }
.shopping small { font-size: 12px; color: var(--muted); }
.shopping .item-icon { width: 32px; height: 32px; }

.choices { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.choices li { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.choices b { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Craft log */
#logBtn { width: 100%; }
.batch-overrides { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.batch-overrides input { min-width: 0; }
.batch-overrides label small { display: block; }
.log-dialog {
  width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.log-dialog::backdrop { background: rgb(10 14 18 / .55); }
.log-form { display: grid; gap: 14px; padding: 18px; }
.log-form-head { display: flex; align-items: center; gap: 12px; }
.log-form-head div { display: grid; }
.log-form-head small { font-size: 12px; color: var(--muted); }
.log-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.log-form input[type="text"], .log-form input[type="datetime-local"] {
  width: 100%; font: 500 14px var(--sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
}
.log-profit { display: flex; align-items: baseline; gap: 12px; padding: 10px 12px; background: var(--bg); border-radius: 6px; }
.log-profit span { font-weight: 600; color: var(--muted); }
.log-profit b { font: 600 22px var(--mono); font-variant-numeric: tabular-nums; }
.log-profit small { font: 500 12px var(--mono); color: var(--muted); }
.log-actions { display: flex; justify-content: flex-end; gap: 8px; }
.log-actions .ip-close { padding: 10px 14px; }
.log-actions .scan-btn { width: auto; }

.log-summary { padding-top: 20px; }
.stat .v.neg { color: var(--bad); }
.log-table thead th { padding: 10px 14px; }
.log-table td.neg { color: var(--bad); font-weight: 600; }
.log-table .notes-cell { white-space: normal; min-width: 160px; max-width: 260px; }
.log-table .row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.log-table tfoot td { padding: 10px 14px; text-align: right; border-top: 1px solid var(--line); font: 600 13px var(--mono); background: var(--surface-2); }
.log-table tfoot td:first-child { text-align: left; font-family: var(--sans); color: var(--muted); }
.chip.danger { color: #fff; background: var(--bad); border-color: var(--bad); }
.picker-search { width: 100%; font: 500 13px var(--sans); color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.empty a, .progress a { color: var(--accent); }

/* Price history chart. Series colors are the validated categorical palette, one slot per city. */
:root {
  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  }
}
:root[data-theme="dark"] {
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
}
.icon-btn { padding: 0; border: 1px solid transparent; border-radius: 6px; background: none; cursor: zoom-in; line-height: 0; flex: none; }
.icon-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
.chart-dialog {
  width: min(980px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text);
}
.chart-dialog::backdrop { background: rgb(10 14 18 / .55); }
.pc-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.pc-title { flex: 1; display: grid; min-width: 0; }
.pc-title small { font: 500 12px var(--mono); color: var(--muted); }
.pc-head .ip-close { padding: 8px 14px; }
.pc-body { padding: 16px; display: grid; gap: 16px; }
.pc-controls { display: grid; gap: 10px; }
.pc-legend { display: flex; flex-wrap: wrap; gap: 6px; }
.pc-key {
  display: inline-flex; align-items: center; gap: 6px; font: 600 12px var(--sans); color: var(--text);
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer;
}
.pc-key i, .pc-city i, .pc-tip-row i { display: inline-block; width: 14px; height: 2px; border-radius: 2px; }
.pc-key[aria-pressed="false"] { color: var(--muted); opacity: .55; }
.pc-key[aria-pressed="false"] i { background: var(--muted) !important; }
.pc-charts { position: relative; display: grid; gap: 12px; transition: opacity .15s; }
.pc-charts.pc-loading { opacity: .45; }
.pc-chart h3 { margin: 0 0 4px; font-size: 13px; font-weight: 600; color: var(--muted); }
.pc-plot svg { display: block; width: 100%; height: auto; overflow: visible; }
.pc-grid line { stroke: var(--line); stroke-width: 1; }
.pc-grid text, .pc-label { font: 500 11px var(--mono); fill: var(--muted); }
.pc-label { fill: var(--text); font-family: var(--sans); font-weight: 600; }
.pc-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.pc-dot { stroke: var(--surface); stroke-width: 2; }
.pc-hair { stroke: var(--muted); stroke-width: 1; }
.pc-hit { fill: transparent; cursor: crosshair; }
.pc-hit:focus-visible { outline: none; stroke: var(--accent); stroke-width: 1; }
.pc-tooltip {
  position: absolute; z-index: 3; pointer-events: none; min-width: 190px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px;
  box-shadow: 0 6px 20px rgb(10 14 18 / .18); display: grid; gap: 4px;
}
.pc-tooltip[hidden] { display: none; }
.pc-tip-date { font: 600 12px var(--sans); color: var(--muted); }
.pc-tip-row { display: grid; grid-template-columns: 14px auto 1fr; align-items: center; gap: 8px; font-size: 12px; }
.pc-tip-row b { font: 600 13px var(--mono); font-variant-numeric: tabular-nums; }
.pc-tip-row span { color: var(--muted); white-space: nowrap; }
.pc-table table { min-width: 640px; }
.pc-table thead th { padding: 10px 14px; }
.pc-table td small.age { display: block; font: 400 11px var(--mono); }
.pc-city { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .pc-charts { transition: none; } }

/* Confirmation after logging a batch */
#logBtn.logged { background: var(--good); color: #fff; }
.toast {
  position: fixed; z-index: 10; right: 16px; bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 14px;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--good);
  border-radius: var(--radius); padding: 12px 14px; box-shadow: 0 10px 30px rgb(10 14 18 / .22);
  animation: toast-in .2s ease-out;
}
.toast[hidden] { display: none; }
.toast-check { display: grid; place-items: center; width: 28px; height: 28px; flex: none; border-radius: 50%; background: var(--good-soft); color: var(--good); font-weight: 800; }
.toast-text { display: grid; gap: 2px; min-width: 0; }
.toast-text span { font-size: 13px; color: var(--muted); }
.toast-text .pos, .toast-text .neg { font-family: var(--mono); }
.toast a { font: 600 13px var(--sans); color: var(--accent); white-space: nowrap; }
.toast button { font: 600 13px var(--sans); color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 6px; padding: 5px 10px; cursor: pointer; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* Flip log */
.lots { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 0; display: grid; gap: 8px; }
.lots legend { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.lot-rows { display: grid; gap: 6px; }
.lot-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .7fr) minmax(0, 1fr) minmax(70px, auto) auto; gap: 6px; align-items: center; }
.lot-row input, .lot-row select { min-width: 0; }
.lot-total { font: 500 12px var(--mono); color: var(--muted); text-align: right; }
.lots [data-add] { justify-self: start; }
@media (max-width: 520px) {
  .lot-row { grid-template-columns: 1fr 1fr; }
  .lot-total { text-align: left; }
}

/* Login */
.signout { margin: 0; }
.login { max-width: 360px; margin: 12vh auto 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; display: grid; gap: 16px; }
.login h1 { margin: 0; font-size: 20px; font-weight: 800; }
.login .error-note { margin: 0; }

/* Trade notes on the craft page */
.trade-notes { display: grid; gap: 8px; padding-top: 4px; }
.notes-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.notes-head h4 { margin: 0; }
.trade-notes .lots legend span { font-family: var(--mono); color: var(--text); }
.trade-notes [data-add-line] { justify-self: start; }
/* The results column is narrow, so the label gets its own line above the numbers. */
.note-row {
  display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1fr) minmax(64px, auto) auto; gap: 6px; align-items: center;
}
.note-row input[name="label"] { grid-column: 1 / -1; }
.note-row input { min-width: 0; }
.note-row input[type="text"] {
  width: 100%; font: 500 13px var(--sans); color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px;
}
.note-row + .note-row { border-top: 1px dashed var(--line); padding-top: 8px; }
