/* CrossFlow styles. Palette and fonts from CrossFlowApp-accent.jsx.
   One file, no build step. Sections: tokens, base, layout, controls,
   summary strip, table, forms, panels, modal, small pieces. */

/* --- tokens ------------------------------------------------------------- */
:root {
  --page: #FAF8FA;
  --surface: #FFFFFF;
  --surface-alt: #F4F1F5;
  --ink: #332B33;
  --muted: #766F78;          /* template's #8E8890, darkened for readable small text */
  --faint: #A9A2AB;
  --pink: #D45D8B;
  --pink-deep: #B4426E;
  --pink-tint: #FBE4EE;
  --lav: #9B7FC7;
  --lav-tint: #EFE8F8;
  --teal: #3FA08A;
  --teal-tint: #E1F1EC;
  --coral: #E0736F;
  --coral-tint: #FBE7E5;
  --hairline: #ECE8EE;

  --font-display: "Poppins", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", ui-sans-serif, system-ui, sans-serif;
  --radius-panel: 14px;
  --radius-control: 10px;
}

/* --- base --------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 400 14px/1.5 var(--font-body);
}
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; margin: 0; line-height: 1.2; }
h1 { font-size: 26px; letter-spacing: -0.01em; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
a { color: var(--pink-deep); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0; }
:focus-visible { outline: 2px solid var(--pink); outline-offset: 2px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
svg.icon { width: 16px; height: 16px; flex-shrink: 0; fill: none; stroke: currentColor;
  stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }

/* --- layout ------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 32px; background: var(--surface); border-bottom: 1px solid var(--hairline);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 6px; }
.wordmark { font: 600 20px var(--font-display); color: var(--ink); margin-right: 18px; letter-spacing: -0.02em; }
.wordmark:hover { text-decoration: none; }
.wordmark b { color: var(--pink); font-weight: 600; }
.nav a { color: var(--muted); padding: 6px 12px; border-radius: var(--radius-control); font-weight: 500; }
.nav a:hover { color: var(--ink); text-decoration: none; }
.nav a[aria-current="page"] { color: var(--pink-deep); background: var(--pink-tint); }
.page { max-width: 1360px; margin: 0 auto; padding: 28px 32px 64px; }
.page-narrow { max-width: 1120px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.page-head .actions { display: flex; align-items: center; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); margin-bottom: 10px; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }

/* --- controls ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-control); border: 1px solid transparent;
  font: 500 14px var(--font-body); cursor: pointer; background: none; color: var(--ink);
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--pink); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--pink-deep); }
.btn-deep { background: var(--pink-deep); color: #fff; }
.btn-outline { border-color: var(--hairline); background: var(--surface); }
.btn-outline:hover:not(:disabled) { border-color: var(--pink); }
.btn-quiet { color: var(--muted); padding: 6px 8px; }
.btn-quiet:hover { color: var(--ink); }
.btn-danger { border-color: var(--hairline); background: var(--surface); color: var(--coral); }
.btn-block { width: 100%; padding: 11px 14px; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px;
  border-radius: 8px; border: 0; background: none; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-alt); color: var(--ink); }
.bell { position: relative; border: 1px solid var(--hairline); width: 36px; height: 36px; margin-left: 8px; }
.bell .count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--pink); color: #fff; font: 600 10.5px/18px var(--font-body);
}

/* segmented tabs (status filter, single item / lot, analytics period) */
.segmented { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px;
  background: var(--surface-alt); border: 1px solid var(--hairline); }
.segmented a, .segmented button {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 9px;
  border: 0; background: none; color: var(--muted); font: 500 13.5px var(--font-body); cursor: pointer;
}
.segmented a:hover, .segmented button:hover { color: var(--ink); text-decoration: none; }
.segmented .on { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--hairline); }
.segmented .tally { font-size: 12px; color: var(--faint); }
.segmented .on .tally { color: var(--pink-deep); }
.segmented.solid .on { background: var(--pink); color: #fff; box-shadow: none; }

/* --- summary strip (My listings) ---------------------------------------- */
.ledger {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline);
  margin-bottom: 26px;
}
.ledger > div { padding: 16px 24px 18px; }
.ledger .card-toggle { cursor: pointer; border-radius: 10px; }
.ledger .card-toggle:hover .what, .ledger .card-toggle:focus-visible .what { color: var(--pink-deep); }
.ledger > div + div { border-left: 1px solid var(--hairline); }
.ledger > div:first-child { padding-left: 0; }
.ledger .figure { font: 600 30px/1.1 var(--font-display); letter-spacing: -0.02em; }
.ledger .figure.loss { color: var(--coral); }
.ledger .what { margin-top: 4px; font-weight: 500; }
.ledger .context { color: var(--muted); font-size: 12.5px; }
.ledger a.figure { color: var(--ink); }
.ledger a.figure:hover { color: var(--pink-deep); text-decoration: none; }

/* --- toolbar + table ---------------------------------------------------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.search {
  display: flex; align-items: center; gap: 8px; padding: 0 12px; height: 38px; width: 260px;
  background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-control); color: var(--muted);
}
.search input { border: 0; outline: 0; background: none; font: inherit; color: var(--ink); width: 100%; }
.filter-select {
  height: 38px; padding: 0 10px; border-radius: var(--radius-control); border: 1px solid var(--hairline);
  background: var(--surface); font: inherit; color: var(--ink);
}

.table-wrap { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-panel); overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; min-width: 900px; }
table.list th {
  text-align: left; font: 500 12.5px var(--font-body); color: var(--muted);
  padding: 11px 12px; background: var(--surface-alt); border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
table.list th a { color: inherit; display: inline-flex; align-items: center; gap: 4px; }
table.list th a:hover { color: var(--ink); text-decoration: none; }
table.list th a.sorted { color: var(--pink-deep); }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: #FCFAFC; }
table.list tbody tr.selected { background: var(--pink-tint); }
table.list td.check, table.list th.check { width: 36px; padding-right: 0; }
table.list .row-actions { display: flex; justify-content: flex-end; gap: 2px; opacity: 0.35; }
table.list tr:hover .row-actions, table.list tr:focus-within .row-actions { opacity: 1; }
.item-cell { display: flex; align-items: center; gap: 10px; min-width: 240px; }
.item-cell a { color: var(--ink); }
.empty { padding: 56px 16px; text-align: center; color: var(--muted); }
.empty h3 { color: var(--ink); margin-bottom: 4px; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; background: #CFC6D1; }
.dot.listed { background: var(--pink); }
.dot.scheduled { background: var(--lav); }
.dot.sold { background: var(--teal); }

.thumb { width: 38px; height: 38px; border-radius: 9px; flex-shrink: 0; object-fit: cover;
  background: var(--surface-alt); border: 1px solid var(--hairline); }

.badge { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; color: #fff; font: 600 11px var(--font-body); flex-shrink: 0; }
.badge.lg { width: 26px; height: 26px; font-size: 12px; }
.badges { display: flex; gap: 4px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 6px;
  font-size: 12px; background: var(--lav-tint); color: #6F55A0; white-space: nowrap; }
.chip.pink { background: var(--pink-tint); color: var(--pink-deep); }
.chip.teal { background: var(--teal-tint); color: #2C7A68; }
.chip.coral { background: var(--coral-tint); color: #B4504C; }
.chip.grey { background: var(--surface-alt); color: var(--muted); }

input[type="checkbox"].tick { width: 17px; height: 17px; accent-color: var(--pink); cursor: pointer; margin: 0; }

/* --- forms -------------------------------------------------------------- */
.panel { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-panel); padding: 18px; }
.panel h2 { margin-bottom: 12px; }
.panel-note { color: var(--muted); font-size: 12.5px; margin: -8px 0 12px; }
.field { display: block; }
.field + .field { margin-top: 12px; }
.grid-2 > .field, .grid-3 > .field { margin-top: 0; }
summary.label { display: list-item; }
.field > span, .label { display: block; font-weight: 500; margin-bottom: 6px; }
.field .hint { display: block; font-weight: 400; color: var(--muted); font-size: 12px; margin-top: 4px; }
.input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea {
  width: 100%; padding: 9px 12px; border-radius: var(--radius-control); border: 1px solid var(--hairline);
  background: var(--surface-alt); font: inherit; color: var(--ink); outline: 0;
}
.field textarea { resize: vertical; min-height: 92px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--pink); background: var(--surface); }
.money { position: relative; }
.money::before { content: "£"; position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.money input { padding-left: 26px !important; }
.section-label { font-weight: 600; color: var(--pink-deep); margin: 18px 0 10px; padding-top: 14px; border-top: 1px solid var(--hairline); }
.choice { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.form-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr) 310px; gap: 16px; align-items: start; }
.market-list { display: flex; flex-direction: column; gap: 6px; }
.market-option {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-control);
  border: 1px solid var(--hairline); cursor: pointer; background: var(--surface);
}
.market-option:has(input:checked) { border-color: var(--pink); background: var(--pink-tint); }
.market-option .state { margin-left: auto; font-size: 12px; color: var(--muted); }
/* the item page's status list: platform name, with its status underneath */
.market-option .who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.market-option .who .state { margin-left: 0; display: inline-flex; align-items: center; gap: 3px; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.photo .open { display: block; width: 100%; height: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; }
.photo[draggable="true"] { cursor: grab; }
.photo.drop-before { outline: 2px solid var(--pink); outline-offset: 2px; }
.photo.dragging { opacity: .4; }

/* photo editor */
.modal.photo-editor { width: min(960px, 100%); }
.crop-stage { display: grid; place-items: center; background: var(--surface-alt); border-radius: 12px; padding: 12px; }
.crop-area { position: relative; display: inline-block; line-height: 0; overflow: hidden; cursor: crosshair; touch-action: none; user-select: none; }
.crop-area img { max-width: 100%; max-height: 62vh; display: block; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(51, 43, 51, .45); pointer-events: none; }
.photo { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; border: 1px solid var(--hairline); background: var(--surface-alt); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .linked { position: absolute; left: 6px; bottom: 6px; background: rgba(255,255,255,.92); border-radius: 6px;
  padding: 1px 6px; font-size: 11px; color: var(--muted); }
.photo .main { position: absolute; left: 6px; top: 6px; background: rgba(255,255,255,.92); border-radius: 6px; padding: 1px 6px; font-size: 11px; }
.photo .remove { position: absolute; top: 6px; right: 6px; opacity: 0; width: 28px; height: 28px; padding: 0;
  display: grid; place-items: center; border: 0; border-radius: 8px; background: rgba(255,255,255,.95); color: var(--ink); cursor: pointer; }
.photo .remove svg { display: block; }
.photo:hover .remove, .photo:focus-within .remove { opacity: 1; }
.photo .remove:hover { color: var(--coral); }
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  aspect-ratio: 1; border: 1.5px dashed #DCD5DE; border-radius: 10px; color: var(--muted);
  background: var(--surface-alt); cursor: pointer; font-size: 12.5px; text-align: center; padding: 6px;
}
.dropzone:hover, .dropzone.dragging { border-color: var(--pink); color: var(--pink-deep); }
.dropzone.dragging { background: var(--pink-tint); }
.photos.previews:not(:empty) { margin-top: 10px; }
.dropzone input { display: none; }
.dropzone.wide { aspect-ratio: auto; padding: 26px; }

/* per-platform listing panels on the item page */
.listing-panel { border: 1px solid var(--hairline); border-radius: 12px; padding: 14px; background: var(--surface); }
.listing-panel + .listing-panel { margin-top: 10px; }
.listing-panel .head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.listing-panel .head .name { font-weight: 600; }
.listing-panel .head .acts { margin-left: auto; display: flex; gap: 6px; flex-wrap: wrap; }
details.listing-panel > summary { cursor: pointer; list-style: none; }
.specifics-boxes select[multiple] { min-height: 96px; }
.html-description { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.html-description .code { font-family: ui-monospace, monospace; font-size: 12.5px; }
.html-description .preview { width: 100%; min-height: 180px; height: 100%; border: 1px solid var(--hairline);
  border-radius: 10px; background: #fff; }
@media (max-width: 760px) { .html-description { grid-template-columns: 1fr; } }
details.listing-panel > summary::-webkit-details-marker { display: none; }
details.listing-panel .fold { display: grid; color: var(--muted); transition: transform .15s; margin-left: 2px; }
details.listing-panel:not([open]) .fold { transform: rotate(-90deg); }
details.listing-panel:not([open]) > summary { margin-bottom: 0; }
.listing-panel .error { margin-top: 8px; color: #B4504C; font-size: 12.5px; }
.suggestions { margin-top: 6px; border: 1px solid var(--hairline); border-radius: 10px; overflow: hidden; }
.suggestions button { display: block; width: 100%; text-align: left; padding: 8px 10px; border: 0; background: var(--surface); cursor: pointer; font: inherit; }
.suggestions button + button { border-top: 1px solid var(--hairline); }
.suggestions button:hover { background: var(--pink-tint); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* top bar: spins while listings go up or come down */
.activity { display: inline-flex; align-items: center; gap: 4px; color: var(--pink-deep); font-size: 12.5px; font-weight: 600; }
.activity svg { animation: spin 1.2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .activity svg { animation: none; } }

/* page links under the listings table */
.pager { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pager .size { padding: 2px 8px; border-radius: 6px; color: var(--muted); font-size: 12.5px; }
.pager .size:hover { color: var(--pink-deep); text-decoration: none; }
.pager .size.on { background: var(--pink-tint); color: var(--pink-deep); font-weight: 600; }

/* notices */
.flash-area { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.flash { display: flex; align-items: flex-start; gap: 10px; padding: 11px 8px 11px 14px; border-radius: 12px;
  background: var(--ink); color: #fff; font-weight: 500; box-shadow: 0 8px 24px rgba(51, 43, 51, 0.18); }
.flash-text { flex: 1; overflow-wrap: anywhere; }
.flash-close { flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: -2px;
  border: 0; border-radius: 6px; background: transparent; color: inherit; opacity: 0.7; cursor: pointer; }
.flash-close:hover { opacity: 1; background: rgba(255, 255, 255, 0.14); }
.flash.error { background: #9E3B37; }
.notice { padding: 10px 12px; border-radius: 10px; font-size: 13px; background: var(--surface-alt); color: var(--muted); }
.notice.warn { background: var(--coral-tint); color: #8E3E3A; }
.notice.good { background: var(--teal-tint); color: #2C7A68; }

/* --- modal -------------------------------------------------------------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(51, 43, 51, 0.35); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 6vh 16px; overflow-y: auto; }
.modal { width: min(880px, 100%); background: var(--surface); border-radius: 16px; padding: 22px 24px;
  box-shadow: 0 24px 60px rgba(51, 43, 51, 0.22); }
.modal.narrow { width: min(560px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
/* "Are you sure?" box, used instead of the browser's own confirm alert */
dialog.confirm { width: min(440px, calc(100% - 32px)); border: 0; border-radius: 16px; padding: 22px 24px;
  background: var(--surface); color: var(--ink); box-shadow: 0 24px 60px rgba(51, 43, 51, 0.22); }
dialog.confirm::backdrop { background: rgba(51, 43, 51, 0.35); }
dialog.confirm p { margin: 0; line-height: 1.5; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 0 28px; }
.split > div:first-child { border-right: 1px solid var(--hairline); padding-right: 28px; }
.split h3.in { color: #2C7A68; margin-bottom: 10px; }
.split h3.out { color: #B4504C; margin-bottom: 10px; }

/* Sales to finish (analytics) */
.to-finish-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 0; border-top: 1px solid var(--hairline); }
.to-finish-row .what { display: flex; align-items: center; gap: 10px; min-width: 0; }
.to-finish-row .what > span { display: flex; flex-direction: column; min-width: 0; }

/* notifications dropdown */
.dropdown { position: absolute; right: 0; top: 44px; width: 340px; z-index: 40; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 14px; box-shadow: 0 12px 32px rgba(51, 43, 51, 0.14); overflow: hidden; }
.dropdown .item { padding: 11px 14px; border-bottom: 1px solid var(--hairline); display: flex; gap: 10px; align-items: flex-start; }
.dropdown .item:last-child { border-bottom: 0; }
.dropdown .item.important { background: var(--pink-tint); }
.dropdown .item.important a { font-weight: 600; }

/* charts (server-drawn SVG) */
.chart { width: 100%; height: 220px; display: block; }
.chart .bar { fill: var(--pink); }
.chart .bar.neg { fill: var(--coral); }
.chart .bar.current { fill: var(--pink-deep); }
.chart text { fill: var(--muted); font: 11px var(--font-body); }
.chart .axis { stroke: var(--hairline); }

/* figures row on analytics (same ledger idea, smaller) */
.figures { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 1px solid var(--hairline); border-bottom: 1px solid var(--hairline); margin-bottom: 24px; }
.figures > div { padding: 14px 18px; }
.figures > div + div { border-left: 1px solid var(--hairline); }
.figures > div:first-child { padding-left: 0; }
.figures .figure { font: 600 22px var(--font-display); }
.figures .what { color: var(--muted); font-size: 12.5px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth .panel { width: min(400px, 100%); padding: 28px; }
.auth h1 { margin-bottom: 4px; }

/* diff table on imports */
.diff td { padding: 4px 8px; font-size: 13px; vertical-align: top; }
.diff .ours { color: var(--muted); text-decoration: line-through; }

/* --- phones, tablets and touch screens ----------------------------------
   Every page has to work one-handed on a phone: CrossFlow is run from one.
   Tablet (up to 1100px): one column. Phone (up to 760px): menu button,
   listings as cards, save bar at the bottom, full-screen popups. */
.nav-links { display: flex; align-items: center; gap: 6px; }
.save-bar { display: grid; gap: 8px; }
.menu-btn { display: none; }

@media (max-width: 1100px) {
  .form-layout { grid-template-columns: 1fr !important; }
  .ledger { grid-template-columns: 1fr 1fr; }
  .ledger > div:nth-child(3) { border-left: 0; padding-left: 0; }
  .ledger > div:nth-child(n+3) { border-top: 1px solid var(--hairline); }
  /* the item page's Save buttons stay at the bottom of the screen */
  .save-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: 1fr 1fr;
    gap: 8px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); background: var(--surface);
    border-top: 1px solid var(--hairline); box-shadow: 0 -6px 18px rgba(51, 43, 51, 0.08); }
  .save-bar .btn-block { margin: 0; }
  body:has(.save-bar) .page { padding-bottom: 96px; }
  body:has(.save-bar) .flash-area { bottom: 84px; }
}

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; flex-wrap: wrap; gap: 8px; }
  .wordmark { margin-right: 6px; }
  .menu-btn { display: inline-flex; }
  .nav-links { display: none; order: 9; flex-basis: 100%; flex-direction: column; align-items: stretch; gap: 2px; padding-top: 6px; }
  .topbar.menu-open .nav-links { display: flex; }
  /* the right-hand group dissolves, so the links can drop below as a full-width list */
  .topbar-right { display: contents; }
  #activity { margin-left: auto; }
  .nav-links a { padding: 11px 12px; }
  .page { padding: 18px 16px 48px; }
  h1 { font-size: 22px; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { flex-wrap: wrap; }
  .ledger, .grid-2, .grid-3, .split { grid-template-columns: 1fr !important; }
  .figures { grid-template-columns: 1fr 1fr; }
  .figures > div { padding: 12px 0; border-left: 0 !important; }
  .figures > div:nth-child(n+3) { border-top: 1px solid var(--hairline); }
  .ledger > div { padding: 12px 0; border-left: 0 !important; }
  .ledger > div + div { border-top: 1px solid var(--hairline); }
  .ledger .figure { font-size: 24px; }
  .split > div:first-child { border-right: 0; padding-right: 0; }
  .segmented { max-width: 100%; overflow-x: auto; }
  .search { width: 100%; }
  .toolbar .tools { width: 100%; }
  .filter-select { flex: 1; }
  .photos { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
  .listing-panel .head { flex-wrap: wrap; }
  .crop-area img { max-height: 52vh; }

  /* My listings: each item as a card instead of a wide table row */
  table.list.cards { min-width: 0; }
  table.list.cards thead { display: none; }
  table.list.cards tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 10px;
    padding: 12px; border-bottom: 1px solid var(--hairline); }
  table.list.cards tr:last-child { border-bottom: 0; }
  table.list.cards td { display: block; padding: 0; border: 0; }
  table.list.cards .c-check { grid-column: 1; grid-row: 1; align-self: center; }
  table.list.cards .c-item { grid-column: 2; grid-row: 1; }
  table.list.cards .c-item { grid-column: 2 / 4; }
  table.list.cards .c-item a { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  table.list.cards .c-actions { grid-column: 2 / 4; }
  table.list.cards .row-actions { justify-content: flex-start; margin-left: -8px; }
  table.list.cards .c-meta { grid-column: 2 / 4; display: flex; align-items: center; gap: 6px; font-size: 13px; }
  /* lines with nothing to say ("Lot: -") are left out on a phone */
  table.list.cards .c-meta:has(> .muted:only-child), table.list.cards .c-meta:has(> .badges > .muted:only-child) { display: none; }
  table.list.cards .c-meta::before { content: attr(data-label); color: var(--faint); font-size: 12px; min-width: 64px; }
  table.list.cards .c-price { font-weight: 600; }
  table.list.cards td[colspan] { grid-column: 1 / 4; }
  .item-cell { min-width: 0 !important; }

  /* any other table marked "stacked": each row a card, each cell labelled with its
     column (data-label); a cell without a label is the card's title or buttons */
  table.list.stacked { min-width: 0 !important; }
  table.list.stacked thead { display: none; }
  table.list.stacked tr { display: block; padding: 12px; border-bottom: 1px solid var(--hairline); }
  table.list.stacked tr:last-child { border-bottom: 0; }
  table.list.stacked td { display: flex; align-items: center; gap: 8px; padding: 3px 0; border: 0; min-width: 0 !important;
    width: auto !important; text-align: left !important; }
  table.list.stacked td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: 12px; min-width: 76px; }
  table.list.stacked td:not([data-label]):first-child { font-weight: 600; padding-bottom: 6px; }
  table.list.stacked td:empty { display: none; }

  /* popups take the whole screen */
  .modal-backdrop { padding: 0; }
  .modal, .modal.narrow, .modal.photo-editor { width: 100%; min-height: 100%; border-radius: 0; padding: 18px 16px; }
  .modal-foot { flex-wrap: wrap; }
  .dropdown { position: fixed; left: 8px; right: 8px; top: 60px; width: auto; }
  .flash-area { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* touch screens: nothing hides until hover, and everything is finger-sized */
@media (hover: none) {
  table.list .row-actions { opacity: 1; }
  .photo .remove { opacity: 1; }
}
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .btn-small { min-height: 36px; }
  .icon-btn { width: 40px; height: 40px; }
  input[type="checkbox"].tick { width: 22px; height: 22px; }
  /* 16px stops phones zooming in when a box is tapped */
  .input, .field input:not([type="checkbox"]):not([type="radio"]):not([type="file"]), .field select, .field textarea,
  .search input, .filter-select { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
