/* FlipJudge design system: the category standard at Stripe / Apple polish.
   Grouped background, inset-grouped lists, system type, tabular money,
   one blue accent; verdict colours only where they carry meaning. */

:root {
  --bg: #f2f3f6;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --line: #e4e6eb;
  --line-strong: #d3d6dd;
  --fg: #15171c;
  --fg-2: #474c56;
  --fg-3: #626873;
  --accent: #1e5ad6;
  --accent-hover: #1a4fbd;
  --accent-weak: #e9f0fd;
  --on-accent: #ffffff;
  --btn: #1e5ad6; --btn-hover: #1a4fbd; --on-btn: #ffffff;
  --good: #0d7247;   --good-bg: #e7f5ee;  --good-line: #b9e2cc;
  --warn: #8a5300;   --warn-bg: #fdf3df;  --warn-line: #f0d49d;
  --bad: #b3261e;    --bad-bg: #fdeceb;   --bad-line: #f4c2bd;
  --none: #4d535e;   --none-bg: #eef0f3;  --none-line: #d9dce2;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.04);
  --radius: 12px;
  --radius-sm: 8px;
  --focus: 0 0 0 3px rgba(30, 90, 214, 0.32);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --surface: #1c1c1e;
    --surface-2: #2c2c2e;
    --line: #2e2e31;
    --line-strong: #3d3d41;
    --fg: #f2f2f4;
    --fg-2: #c3c3c8;
    --fg-3: #9a9aa0;
    --accent: #7ea8ff;
    --accent-hover: #98baff;
    --accent-weak: #1b2a47;
    --on-accent: #0a1530;
    --btn: #2563eb; --btn-hover: #1d4fd0; --on-btn: #ffffff;
    --good: #67d39b;  --good-bg: #11291c; --good-line: #1f4a33;
    --warn: #f1bd5a;  --warn-bg: #2e230e; --warn-line: #574215;
    --bad: #ff8d84;   --bad-bg: #351614;  --bad-line: #5e2622;
    --none: #c3c3c8;  --none-bg: #2c2c2e; --none-line: #3d3d41;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    --focus: 0 0 0 3px rgba(126, 168, 255, 0.38);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-weak); color: var(--fg); }
input, textarea { caret-color: var(--accent); }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 999px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

main { padding: 12px 12px 20px; max-width: 980px; margin: 0 auto; }
.num, .money { font-variant-numeric: tabular-nums; }
h1 { font-size: 20px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h2 { font-size: 15px; line-height: 1.3; font-weight: 600; margin: 0; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; text-underline-offset: 2px; }
a:hover { text-decoration: underline; }
.muted { color: var(--fg-3); }
.small { font-size: 12px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Keyboard focus: a solid ring outside the element, visible on every background. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
a:focus-visible, .link-btn:focus-visible { border-radius: 4px; }
/* Filled buttons get an inner ring in the text colour too, so the focus reads on the fill itself. */
.btn-primary:focus-visible, button.danger:focus-visible, input.switch:checked:focus-visible { box-shadow: inset 0 0 0 2px var(--on-btn); }
.field > input:focus-visible { outline: none; }
.field:has(> input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app header ---------- */
.appbar { display: flex; align-items: center; gap: 8px; padding: 2px 2px 12px; }
.brand { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; color: var(--fg); }
.brand svg { flex: none; }
.brand b { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px;
  color: var(--fg-2); background: transparent; border: 0; cursor: pointer;
}
.icon-btn:hover { background: var(--surface); color: var(--fg); text-decoration: none; }
.icon { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- sections and inset-grouped lists ---------- */
.section { margin-top: 18px; }
.section > .section-head { display: flex; align-items: baseline; gap: 8px; padding: 0 4px 8px; }
.section-head h2 { flex: 1; }
.group {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.group + .group { margin-top: 10px; }
.row {
  display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 8px 12px;
  border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row > .label { flex: 1; min-width: 0; color: var(--fg); }
.row > .label small { display: block; color: var(--fg-3); font-size: 12px; }
.row > .value { text-align: right; font-variant-numeric: tabular-nums; color: var(--fg); }
.row > .value small { display: block; color: var(--fg-3); font-size: 12px; }
.row.stack { display: block; }
.row.note { min-height: 0; color: var(--fg-2); font-size: 12px; }
.pad { padding: 12px; }
.foot { padding: 8px 4px 0; color: var(--fg-3); font-size: 12px; }

/* ---------- controls ---------- */
label { color: var(--fg-2); }
input[type="text"], input[type="number"], input[type="date"], input:not([type]), select, textarea {
  font: inherit; color: var(--fg); background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); padding: 6px 9px; min-height: 32px; width: 100%;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { border-color: var(--accent); }
.row input[type="number"], .row select { width: auto; text-align: right; }
.row input[type="number"] { width: 96px; font-variant-numeric: tabular-nums; }
.row select { max-width: 60%; }
.field { display: flex; align-items: center; background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); padding-left: 9px; }
.field:focus-within { border-color: var(--accent); }
.field > span { color: var(--fg-3); }
.field > input { border: 0; box-shadow: none !important; padding-left: 3px; min-width: 0; }
.row .field { width: 112px; flex: none; }
.row .field > input { width: 100%; text-align: right; }

button {
  font: inherit; font-weight: 600; color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  min-height: 32px; padding: 6px 12px; cursor: pointer;
}
button:hover { background: var(--surface-2); }
button:disabled { opacity: 0.55; cursor: default; }
.btn-primary {
  width: 100%; min-height: 40px; font-size: 14px; background: var(--btn); border-color: var(--btn); color: var(--on-btn);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { background: var(--btn-hover); border-color: var(--btn-hover); }
.btn-primary[aria-busy="true"]::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid color-mix(in srgb, var(--on-btn) 35%, transparent); border-top-color: var(--on-btn);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.link-btn { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 500; }
.link-btn:hover { background: none; text-decoration: underline; }
.actions { display: flex; align-items: center; gap: 14px; padding-top: 10px; font-size: 12px; }

/* iOS-style switch on a real checkbox */
input.switch {
  appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 999px; flex: none;
  background: var(--line-strong); position: relative; cursor: pointer; transition: background 0.18s ease-out; margin: 0;
}
input.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); transition: transform 0.18s ease-out;
}
input.switch:checked { background: var(--btn); }
input.switch:checked::after { transform: translateX(16px); }
input[type="checkbox"]:not(.switch) { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; flex: none; }

/* segmented control */
.segmented { display: inline-flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 2px; gap: 2px; }
.segmented button { border: 0; background: transparent; min-height: 26px; padding: 3px 10px; font-size: 12px; font-weight: 500; border-radius: 7px; color: var(--fg-2); }
.segmented button:hover { background: var(--surface); color: var(--fg); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--fg); box-shadow: var(--shadow); }

/* ---------- chips and notices ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 600; border: 1px solid var(--none-line); background: var(--none-bg); color: var(--none);
}
.chip .icon { width: 14px; height: 14px; stroke-width: 2; }
.chip.green { background: var(--good-bg); color: var(--good); border-color: var(--good-line); }
.chip.amber { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.chip.red { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.chip.quiet { font-weight: 500; }
.notice { display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: var(--radius-sm); font-size: 12px; margin-top: 8px; border: 1px solid; }
.notice .icon { width: 16px; height: 16px; flex: none; margin-top: 1px; }
.notice.warn { background: var(--warn-bg); border-color: var(--warn-line); color: var(--fg); }
.notice.warn .icon { color: var(--warn); }
.notice.err { background: var(--bad-bg); border-color: var(--bad-line); color: var(--fg); }
.notice.err .icon { color: var(--bad); }

/* ---------- decision card ---------- */
.decision { padding: 14px 14px 12px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow); }
.decision.green { background: var(--good-bg); border-color: var(--good-line); }
.decision.amber { background: var(--warn-bg); border-color: var(--warn-line); }
.decision.red { background: var(--bad-bg); border-color: var(--bad-line); }
.decision.grey { background: var(--none-bg); border-color: var(--none-line); }
.decision .headline { display: flex; align-items: baseline; gap: 8px; margin-top: 10px; }
.decision .big { font-size: 30px; line-height: 1.05; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.decision .headline span { color: var(--fg-2); }
.decision .walk { margin-top: 6px; color: var(--fg); font-size: 13px; }
.decision .walk b { font-variant-numeric: tabular-nums; }
.meter { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid color-mix(in srgb, var(--fg) 10%, transparent); font-size: 12px; color: var(--fg-2); }
.bars { display: inline-grid; grid-template-columns: repeat(4, 14px); gap: 3px; flex: none; }
.bars i { height: 6px; border-radius: 2px; background: color-mix(in srgb, var(--fg) 14%, transparent); }
.bars[data-level="1"] i:nth-child(-n+1), .bars[data-level="2"] i:nth-child(-n+2),
.bars[data-level="3"] i:nth-child(-n+3), .bars[data-level="4"] i:nth-child(-n+4) { background: var(--fg-2); }

/* ---------- comp lists ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.comp { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 10px; align-items: start; padding: 10px 12px; border-top: 1px solid var(--line); }
.comp:first-child { border-top: 0; }
.comp > input { margin-top: 2px; }
.comp .t { color: var(--fg); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.comp .t:hover { color: var(--accent); }
.comp .m { color: var(--fg-3); font-size: 12px; margin-top: 2px; }
.comp .p { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 600; }
.comp .p small { display: block; font-weight: 400; color: var(--fg-3); font-size: 12px; }
.comp .why { grid-column: 2 / 4; }
.comp.off .t, .comp.off .p { color: var(--fg-3); }
.empty-row { padding: 12px; color: var(--fg-3); }

details > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; padding: 12px; color: var(--fg); font-weight: 500; }
details > summary::-webkit-details-marker { display: none; }
details > summary::after { content: ""; margin-left: auto; width: 7px; height: 7px; border-right: 1.6px solid var(--fg-3); border-bottom: 1.6px solid var(--fg-3); transform: rotate(-45deg); transition: transform 0.15s ease-out; }
details[open] > summary::after { transform: rotate(45deg); }
details[open] > summary { border-bottom: 1px solid var(--line); }
details.group > summary .count { color: var(--fg-3); font-weight: 400; }

dl.kv { display: grid; grid-template-columns: 1fr auto; margin: 0; }
dl.kv dt, dl.kv dd { padding: 7px 12px; border-top: 1px solid var(--line); margin: 0; }
dl.kv dt { color: var(--fg-2); }
dl.kv dd { text-align: right; font-variant-numeric: tabular-nums; }
dl.kv dt:first-of-type, dl.kv dd:first-of-type { border-top: 0; }
dl.kv dt.total, dl.kv dd.total { font-weight: 700; color: var(--fg); }

/* ---------- full pages (flip log, settings) ---------- */
.page main { padding: 24px 20px 40px; }
.page .appbar { padding-bottom: 20px; }
.page h1 { flex: 1; }
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 0; }
.summary-grid > div { padding: 12px 14px; border-left: 1px solid var(--line); }
.summary-grid > div:first-child { border-left: 0; }
.summary-grid .k { color: var(--fg-3); font-size: 12px; }
.summary-grid .v { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; margin-top: 2px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th { text-align: left; font-weight: 500; color: var(--fg-3); font-size: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2); }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; position: relative; } /* keeps .sr-only labels inside the scroll box */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; padding: 14px; }
.form-grid label { display: block; font-size: 12px; margin-bottom: 4px; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--fg); padding: 0; width: min(420px, 92vw); box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18); }
dialog::backdrop { background: rgba(10, 12, 16, 0.4); }
dialog form { padding: 18px; }
dialog.wide { width: min(760px, 94vw); }
dialog td select { max-width: 260px; }
dialog form > label { display: block; font-size: 12px; margin: 12px 0 4px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* flip log table */
td.date, td.actions { white-space: nowrap; }
/* .actions is the panel's flex row; inside a table it must stay a cell or the row lines break */
td.actions { display: table-cell; padding: 10px 12px; font-size: inherit; }
td.actions button + button { margin-left: 6px; }
/* select rows read like iOS: value + chevron, no box */
.row select { border-color: transparent; background-color: transparent; color: var(--fg-2); padding-right: 4px; }
.row select:hover { color: var(--fg); }
/* one authored moment: the decision card settles in after a lookup */
@keyframes settle { from { transform: translateY(6px); box-shadow: 0 0 0 rgba(0,0,0,0); } to { transform: none; } }
.decision.arrive { animation: settle 0.42s cubic-bezier(0.16, 1, 0.3, 1); }
/* settings */
.page input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
#cats td:first-child { min-width: 170px; }
/* settings categories table: compact number inputs, fee note wraps */
#cats input[type="number"] { width: 64px; }
#cats td, .table-wrap:has(#cats) th { padding-left: 8px; padding-right: 8px; }
.table-wrap:has(#cats) th { white-space: normal; vertical-align: bottom; }
#cats td.muted { font-size: 12px; white-space: normal; max-width: 130px; }

/* flip log stats */
.stats-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding-bottom: 10px; }
#tiles .v.pos { color: var(--good); }
#tiles .v.neg { color: var(--bad); }
#tiles .sub { color: var(--fg-3); font-size: 12px; margin-top: 2px; }
table.no-bought .col-bought { display: none; }

/* inventory (flip log) */
.btn-inline { width: auto; min-height: 32px; padding: 0 14px; font-size: 13px; }
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; min-height: 32px; padding: 0 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); font-weight: 500; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary::after { content: ""; width: 6px; height: 6px; margin-left: 8px; border-right: 1.5px solid var(--fg-3); border-bottom: 1.5px solid var(--fg-3); transform: rotate(45deg) translateY(-2px); }
.menu[open] > summary { border-color: var(--accent); }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 5; width: 280px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16); padding: 6px; }
.menu-list button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 8px 10px; border-radius: var(--radius-sm); font-weight: 500; }
.menu-list button:hover { background: var(--surface-2); }
.menu-list small { display: block; color: var(--fg-3); font-weight: 400; font-size: 12px; margin-top: 2px; }
.filter-bar { display: flex; margin-top: 14px; overflow-x: auto; }
.status { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--none-line); background: var(--none-bg); color: var(--none); white-space: nowrap; }
.status.repairing { background: var(--warn-bg); border-color: var(--warn-line); color: var(--warn); }
.status.listed { background: var(--accent-weak); border-color: transparent; color: var(--accent); }
.status.sold { background: var(--good-bg); border-color: var(--good-line); color: var(--good); }
.form-grid .span2 { grid-column: 1 / -1; }
.form-grid label small { color: var(--fg-3); }
dialog textarea { width: 100%; font: inherit; padding: 8px 10px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--fg); }
.lot-toggle { padding: 12px 0 4px; border-top: 1px solid var(--line); margin-top: 12px; }
#lotBox label { display: block; font-size: 12px; margin: 6px 0 4px; color: var(--fg-2); }
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; margin-top: 16px; }
.label-text { display: block; font-size: 12px; margin-bottom: 4px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 14px; }
.checks label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.sub-h { font-size: 13px; margin: 16px 0 6px; }
.sub-h small { display: block; font-weight: 400; color: var(--fg-3); font-size: 12px; }
.cost-list { list-style: none; margin: 0 0 8px; padding: 0; }
.cost-list li { display: flex; align-items: center; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.cost-list li span:first-child { flex: 1; }
.cost-list .muted { font-size: 12px; }
.add-cost { display: flex; gap: 8px; align-items: center; }
.add-cost > input { flex: 1; }
.add-cost .field { width: 120px; }
.danger-link { border: 0; background: transparent; color: var(--bad); padding: 0; font-weight: 500; }
td .meta { color: var(--fg-3); font-size: 12px; }
td.item { min-width: 220px; }
#rows td.actions { padding-right: 12px; }
#rows td.actions button { min-height: 28px; padding: 0 9px; font-size: 12px; }
#rows td.date { font-size: 12px; color: var(--fg-2); }
.form-grid .span-all { grid-column: 1 / -1; padding: 0; }
.notice.cal { background: var(--accent-weak); border-color: transparent; margin-top: 10px; }
.notice.cal b { display: block; color: var(--fg); }
.cal-actions { display: flex; gap: 8px; margin-top: 8px; }

/* Very long listing titles: 3 lines, full title on hover. */
#title { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* Advanced features stay out of the way unless "Show extra features" is on (Settings). */
body:not(.extras) .extra { display: none !important; }
details.fold > summary .count { color: var(--fg-3); font-weight: 400; font-size: 0.92em; margin-left: 4px; }

/* ---------- decision-first panel ---------- */
.decision .sentence { margin-top: 8px; font-size: 15px; line-height: 1.35; font-weight: 600; color: var(--fg); }
.decision .headline { margin-top: 6px; }
.decision .channels { display: flex; gap: 8px; margin-top: 8px; font-size: 12.5px; color: var(--fg-2); }
.decision .channels span { flex: 1; padding: 6px 8px; border-radius: var(--radius-sm); background: color-mix(in srgb, var(--surface) 70%, transparent); border: 1px solid var(--line); }
.decision .channels span.best { border-color: var(--fg-3); color: var(--fg); }
.decision .channels b { font-variant-numeric: tabular-nums; }
.decision .channels small { color: var(--fg-3); }
.decision .offer { margin-top: 8px; font-size: 12.5px; color: var(--fg); }
.decision .offer small { display: block; margin-top: 2px; color: var(--fg-3); }
.decision #expTag { margin-top: 6px; color: var(--fg-2); }
.mini { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.mini .mini-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mini .mini-t b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#failCard { margin-top: 10px; }
#failCard h2 { font-size: 15px; }
#failCard p { margin-top: 6px; }
details.adv { margin-top: 6px; }
details.adv > summary { padding: 4px 0; color: var(--fg-2); font-weight: 400; }
details.adv[open] > summary { border-bottom: 0; }
#detailsFold > summary { gap: 8px; }

.decision .market { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; font-size: 12.5px; color: var(--fg-2); }
.trade-in { margin: 10px 0 0; padding: 10px 12px; border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: 10px; font-size: 13px; }
.trade-in.safe { border-color: rgba(31,138,76,.45); }
.trade-in .ti-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.trade-in .ti-row input { width: 90px; }
.scan-box { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line, rgba(127,127,127,.25)); }
.scan-controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.scan-controls input { width: 110px; }
.scan-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.scan-row { padding: 8px 10px; border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: 10px; }
.scan-row .scan-title { font-weight: 600; text-align: left; }
.scan-row .scan-nums { font-size: 12.5px; color: var(--fg-2); margin-top: 2px; }
.scan-skipped { margin-top: 10px; font-size: 12.5px; color: var(--fg-2); }
.decision .market .demand { font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--bg-2, rgba(127,127,127,.12)); color: var(--fg-1, inherit); }
.decision .market .demand.good { background: rgba(31,138,76,.12); }
.decision .market .demand.warn { background: rgba(183,121,31,.13); }
.decision .market .demand.bad { background: rgba(197,48,48,.11); }
.decision .market .demand::before { content: ""; display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--fg-3); }
.decision .market .demand.good::before { background: var(--good, #1f8a4c); }
.decision .market .demand.warn::before { background: var(--warn, #b7791f); }
.decision .market .demand.bad::before { background: var(--bad, #c53030); }
.lens-link { display: inline-block; margin-top: 6px; }

/* Optional account bar and sign-in dialog (flip log, Settings, web app). */
/* One line inside the page column, under the app header: status, then a small Account menu. */
.account-bar { display: flex; align-items: center; gap: 8px; min-height: 40px; margin: -8px 0 16px; padding: 4px 6px 4px 12px; font-size: 13px; color: var(--fg-2); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.account-bar .msg { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; gap: 7px; }
.account-bar .sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); flex: none; }
.account-bar.error .sync-dot { background: var(--warn); }
.account-bar > .link-btn { flex: none; padding: 0 6px; min-height: 32px; }
.account-menu { flex: none; }
.account-menu > summary { min-height: 30px; font-size: 13px; }
.account-menu .menu-list { width: 240px; }
.account-menu .account-who { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 500; overflow-wrap: anywhere; }
dialog.signin { max-width: 380px; width: calc(100% - 32px); }
dialog.signin label { display: block; margin-top: 10px; }
dialog.signin input { margin-top: 4px; }
dialog.signin .dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }

/* AI photo check */
.photo-check { margin-top: 8px; }
#lotCard { margin-top: 14px; }
.pro-tools { margin: 10px 2px 0; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px; }
.pro-tools .pro-tag { margin-left: 0; }
#lotCard > .section-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
#lotCard textarea { resize: vertical; min-height: 96px; }
#lotOut .decision { margin-top: 10px; }
#lotOut .lot-item .lot-line { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: baseline; margin-top: 2px; }
#lotOut .lot-item .chip { font-size: 11px; padding: 0 6px; }
.pro-tag { margin-left: 4px; padding: 0 5px; border-radius: 4px; font-size: 11px; font-weight: 600; background: var(--accent-weak); color: var(--accent); }
.photo-check #photoOut p { margin-top: 6px; }
.photo-check #photoOut .notice { margin-top: 6px; }

/* Account section (Settings) */
.device-list { list-style: none; margin: 6px 0 10px; padding: 0; }
.device-list li { padding: 6px 0; border-bottom: 1px solid var(--line); }
.device-list li:last-child { border-bottom: 0; }
#accountSection h3 { margin-top: 10px; }
#accountSection .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }
#accountSection input { width: 140px; }
button.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
button.danger:hover { background: var(--bad); filter: brightness(0.95); }
.plan-box { margin: 10px 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.plan-box p + p { margin-top: 6px; }
.plan-box .renew-terms { color: var(--fg-2); }
iframe.bot-check { width: 100%; height: 72px; border: 0; margin-top: 8px; background: transparent; }
.share-box { margin-top: 8px; }
.share-box dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 6px 0; }
.share-box dt { color: var(--fg-2); }
.share-box dd { margin: 0; overflow-wrap: anywhere; }
.share-box textarea { min-height: 60px; resize: vertical; }

/* Shown only in the web app (pwa.css turns it on). */
.pwa-only { display: none; }

/* Settings: fees and technical options folded away; the profit bar stays up top. */
.more-settings { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }
.more-settings > summary { cursor: pointer; padding: 6px 0; list-style-position: outside; }
.more-settings > summary .small { display: block; font-weight: 400; margin-top: 2px; }
.month-value:empty { display: none; }

/* ---------- Settings: "Your target" first, details folded ---------- */
.targets { display: flex; gap: 10px; padding: 12px; flex-wrap: wrap; }
.targets label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--fg-2); }
.targets .field { width: 140px; }
.targets { align-items: flex-end; }
.targets .field > input::placeholder { color: var(--fg-3); }
.section-head .per-cat { font-size: 11.5px; align-self: center; }
.bar-row select { flex: none; width: auto; min-width: 92px; border-color: var(--line-strong); background-color: var(--surface); color: var(--fg); }
.row > label.label { cursor: default; }
details.cat-fold { margin-top: 14px; }
details.cat-fold > summary .fold-sub { display: block; font-weight: 400; margin-top: 2px; }
.cell-label { display: none; }
/* Repair fields only when "I flip broken items" is on. */
.no-repair .repair-only, .no-repair .repair-col { display: none !important; }
/* Save stays reachable: a bar pinned to the bottom of the screen while the form scrolls. */
.save-bar {
  position: sticky; bottom: 0; z-index: 4; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin: 20px -20px -40px; padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
}
.save-bar .btn-primary { width: auto; padding: 0 20px; }
.save-bar.dirty #saved { color: var(--warn); font-weight: 500; }

/* ---------- account: plan cards, retry, danger zone ---------- */
.upgrade { margin: 12px 0; }
.upgrade > h3 { margin: 0 0 8px; }
.plan-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.plan-card { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.plan-card.featured { border-color: var(--accent); background: var(--surface); }
.plan-top { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; }
.plan-name { font-size: 15px; }
.plan-price { color: var(--fg-2); font-variant-numeric: tabular-nums; }
.plan-price b { font-size: 17px; color: var(--fg); }
.plan-save { font-size: 11px; padding: 0 7px; }
.plan-points { margin: 0; padding-left: 16px; color: var(--fg-2); font-size: 12.5px; line-height: 1.35; }
.plan-card.current { border-color: var(--good-line); }
.plan-buy .btn-primary, .plan-buy .plan-yearly { width: 100%; }
.plan-points li { margin: 2px 0; }
.plan-buy { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin-top: auto; }
.plan-buy .plan-yearly { font-weight: 700; }
.upgrade .renew-terms { margin-top: 8px; color: var(--fg-3); }
.retry-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.trust-line { margin-top: 12px; }
.danger-zone { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--bad-line); }
.danger-zone > h3 { margin: 0 0 4px; color: var(--bad); }

/* ---------- flip log header ---------- */
.log-head { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 12px; padding: 0 0 12px; }
.log-head h1 { flex: 1 1 auto; white-space: nowrap; }
.log-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.menu-h { padding: 6px 10px 2px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--fg-3); }
.menu-h:not(:first-child) { margin-top: 4px; border-top: 1px solid var(--line); padding-top: 8px; }

/* ---------- narrow screens: cards instead of wide tables ---------- */
@media (max-width: 600px) {
  .page main { padding: 16px 16px 32px; }
  .save-bar { margin: 20px -16px -32px; padding-left: 16px; padding-right: 16px; }
  .log-head h1 { flex-basis: 100%; }
  .log-actions { width: 100%; }
  .log-actions { position: relative; }
  .log-actions #moreMenu { margin-left: auto; }
  .menu-list { width: min(280px, calc(100vw - 32px)); }
  /* The flip log's menus open full width under the buttons, so they never run off the screen. */
  .log-actions .menu { position: static; }
  .log-actions .menu-list, #ebayMenu .menu-list { left: 0; right: 0; width: auto; }
  /* Tap targets: at least 44px tall. */
  .account-bar { min-height: 44px; }
  .account-bar > .link-btn, .account-menu > summary, .menu > summary, .log-actions button, .menu-list button, .menu-list a.menu-link, .save-bar button, #accountSection button, #accountSection .link-btn, .bar-row select, .targets input { min-height: 44px; }
  .menu-list button, .menu-list a.menu-link { padding: 10px 12px; }
  .plan-cards { gap: 8px; }
  .plan-card { padding: 10px; }

  /* Settings: one card per category, each box with its own label. */
  .table-wrap:has(#cats) { overflow: visible; }
  #catTable, #catTable tbody { display: block; }
  #catTable thead { display: none; }
  #cats tr { display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); align-items: end; gap: 8px 10px; padding: 12px; border-bottom: 1px solid var(--line); }
  #cats tr:last-child { border-bottom: 0; }
  #cats td { display: block; padding: 0; border: 0; text-align: left; }
  #cats td.cat-name { grid-column: 1 / -1; min-width: 0; font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
  #cats td.cat-fee { grid-column: 1 / -1; max-width: none; margin-top: -6px; }
  #cats .cell-label { display: block; font-size: 11.5px; color: var(--fg-3); margin-bottom: 3px; white-space: normal; }
  #cats input[type="number"] { width: 100%; }
  #golfShip { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* Flip log: one card per item. */
  .table-wrap:has(.log-table) { overflow: visible; }
  .log-table, .log-table tbody { display: block; }
  .log-table thead { display: none; }
  #rows tr { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; padding: 12px; border-bottom: 1px solid var(--line); }
  #rows tr:last-child { border-bottom: 0; }
  #rows td { display: block; padding: 0; border: 0; min-width: 0; }
  #rows td[colspan] { grid-column: 1 / -1; }
  #rows td.item { grid-column: 1 / -1; order: -2; min-width: 0; overflow-wrap: anywhere; }
  #rows td.date, #rows td.st { order: -1; }
  #rows td.st { text-align: right; }
  #rows td.num { text-align: left; }
  #rows td.num.unsold { display: none; }
  #rows td[data-label]::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--fg-3); }
  #rows td.actions { grid-column: 1 / -1; display: flex; gap: 8px; padding: 4px 0 0; }
  #rows td.actions button { flex: 1; min-height: 44px; font-size: 13px; }
  td.actions button + button { margin-left: 0; }
}
.pending-sale { color: var(--warn); font-weight: 600; }
/* Flip log: the actual profit is the number that matters; the prediction steps back. */
#rows td.predicted { color: var(--fg-3); }
#rows td.actual { font-weight: 700; }
#rows td.actual.gain { color: var(--good); }
#rows td.actual.loss { color: var(--bad); }
.menu-list a.menu-link { display: block; padding: 8px 10px; border-radius: var(--radius-sm); font-weight: 500; color: var(--fg); }
.menu-list a.menu-link:hover { background: var(--surface-2); text-decoration: none; }
#ebayMenu .menu-list { right: auto; left: 0; }
