/* Web admin base styles. Tokens and fonts are in tokens.css (loaded first),
   components and pages in components.css. This file is the low "legacy"
   cascade layer: page basics plus older rules that later layers build on
   (components.css wins over anything here whatever the specificity). */
@layer legacy {
* { box-sizing: border-box; }
body { margin: 0; background: var(--st-canvas); color: var(--st-ink); font: var(--st-weight-regular) var(--st-text-md)/var(--st-leading-body) var(--st-font); }
a { color: var(--st-accent); }
h1, h2, h3 { font-weight: var(--st-weight-bold); line-height: var(--st-leading-tight); }
h1 { font-size: var(--st-text-xl); letter-spacing: -0.01em; margin: 0.5rem 0 1rem; }
h2 { font-size: var(--st-text-lg); margin: 2rem 0 0.75rem; }
.muted { color: var(--st-ink-muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* Fields the component rules leave alone (the import preview's column menu). */
input[type=text], input[type=search], input[type=email], input[type=password], input[type=url], select {
  font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--st-field); border-radius: 8px; background: var(--st-surface); color: var(--st-ink); min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--st-focus); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
.chip { display: inline-block; padding: 0.1rem 0.55rem; border: 1px solid var(--st-line); border-radius: 999px; font-size: 0.85rem; text-decoration: none; background: var(--st-canvas); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--st-surface); border: 1px solid var(--st-line); border-radius: 12px; }
.table th, .table td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--st-line); vertical-align: middle; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--st-ink-muted); }
.table tr:last-child td { border-bottom: 0; }
.table td { max-width: 24rem; overflow-wrap: anywhere; }
.thumb-col { width: 56px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.thumb.empty { background: var(--st-canvas); border: 1px dashed var(--st-line); }
/* Things list: the last row loads the next ones as it scrolls into view. */
.load-more td { text-align: center; padding: 1rem; }
.load-more__busy { display: none; }
.load-more.htmx-request .load-more__busy { display: inline; }
.empty-state { padding: 2rem; text-align: center; color: var(--st-ink-muted); background: var(--st-surface); border: 1px dashed var(--st-line); border-radius: 12px; }
.pre { white-space: pre-wrap; }
ul.plain { list-style: none; padding: 0; margin: 0; }
.card { background: var(--st-surface); border: 1px solid var(--st-line); border-radius: 12px; padding: 0.25rem 1rem 1rem; margin-bottom: 1rem; }
.card h2 { margin-top: 0.75rem; }
textarea { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--st-field); border-radius: 8px; background: var(--st-surface); color: var(--st-ink); }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.attr-row { display: flex; gap: 0.5rem; margin-bottom: 0.4rem; }
.attr-row input:first-child { flex: 0 1 12rem; }
.attr-row input:nth-child(2) { flex: 1 1 14rem; max-width: 400px; }
.chip-form { display: inline-flex; align-items: center; margin: 0; }
.chip-x { background: none; border: 0; color: var(--st-ink-muted); padding: 0 0.3rem; }
.tag-list { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; margin-bottom: 0.75rem; }
.code-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--st-line); }
.code-line { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.code-line form { margin: 0; }
.check { display: flex; gap: 0.5rem; align-items: flex-start; }
details summary { cursor: pointer; color: var(--st-accent); margin: 0.3rem 0; }
.link-box { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.5rem 0; }
.link-box input { flex: 1 1 320px; max-width: 640px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head .row { align-items: center; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; z-index: 5; display: flex; flex-direction: column; min-width: 12rem; margin-top: 0.25rem; background: var(--st-surface); border: 1px solid var(--st-line); border-radius: 8px; padding: 0.3rem; }
.menu-list a { padding: 0.4rem 0.6rem; text-decoration: none; border-radius: 6px; }
.menu-list a:hover { background: var(--st-canvas); }
.check-col { width: 36px; }
.bulk-bar { position: sticky; top: 0; z-index: 4; display: flex; gap: 0.75rem 1.25rem; flex-wrap: wrap; align-items: center; padding: 0.6rem 0.8rem; margin-bottom: 0.6rem; background: var(--st-surface); border: 1px solid var(--st-accent); border-radius: 12px; }
.bulk-bar[hidden] { display: none; }
.bulk-group { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
input.qty, input[type=number] { font: inherit; padding: 0.4rem 0.5rem; width: 5.5rem; border: 1px solid var(--st-field); border-radius: 8px; background: var(--st-surface); color: var(--st-ink); }
/* Optional note on a stock change (shown in History). */
input.note { font: inherit; padding: 0.4rem 0.5rem; width: 16rem; max-width: 100%; border: 1px solid var(--st-field); border-radius: 8px; background: var(--st-surface); color: var(--st-ink); }
.stock-row { padding: 0.6rem 0; border-bottom: 1px solid var(--st-line); }
.stock-actions { display: flex; gap: 0.8rem 1.2rem; flex-wrap: wrap; align-items: flex-start; margin-top: 0.4rem; }
.stock-actions form { margin: 0; }
.add-stock { margin-top: 0.8rem; }
.columns-menu .menu-list { right: auto; left: 0; max-height: 18rem; overflow-y: auto; }
.columns-menu .menu-list label { padding: 0.3rem 0.6rem; white-space: nowrap; }

/* Photos: drop area (shown only when photo_drop.js runs). */
.dropzone { border: 2px dashed var(--st-line); border-radius: 12px; padding: 1rem; margin: 0.5rem 0 0.8rem; text-align: center; color: var(--st-ink); line-height: 1.5; }
.dropzone .muted { display: block; font-size: 0.9rem; }
.dropzone.is-dragging { border-color: var(--st-accent); background: var(--st-accent-soft); }
.dropzone-status { display: block; font-weight: var(--st-weight-bold); color: var(--st-accent); }

/* Import mapping: tags for every imported thing. */
fieldset.import-tags { border: 1px solid var(--st-line); border-radius: 10px; margin: 1rem 0 0; padding: 0.6rem 1rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
fieldset.import-tags legend { font-weight: var(--st-weight-bold); padding: 0 0.3rem; }
fieldset.import-tags p { margin: 0; }
fieldset.import-tags input[type=text] { max-width: 28rem; }

/* Import preview: tick rows to import. */
.import-tools { align-items: center; margin: 0.5rem 0; }
.import-tools input[type=search] { flex: 0 1 220px; }
.import-rows { max-height: max(32rem, calc(100vh - 20rem)); overflow: auto; }
/* z-index: dimmed (opacity) and outlined cells paint in their own layer;
   without it they show through the sticky header and its Aa menu and take
   its clicks. */
.import-rows thead th { position: sticky; top: 0; z-index: 3; background: var(--st-surface); }

/* Import preview: editable cells and per-column case menu. */
.import-table th { white-space: nowrap; vertical-align: top; }
.import-table .col-name { display: block; text-transform: none; color: var(--st-ink); }
.import-table .col-field { display: block; font-weight: var(--st-weight-regular); text-transform: none; font-size: 0.75rem; }
.case-menu { display: inline-block; margin-top: 0.15rem; }
.case-menu summary { display: inline-block; margin: 0 0 0 -0.45rem; padding: 0.25rem 0.55rem; border-radius: 6px; font-size: 0.85rem; font-weight: var(--st-weight-bold); color: var(--st-accent); cursor: pointer; text-transform: none; }
.case-menu summary:hover, .case-menu[open] summary { background: var(--st-accent-soft); }
.case-menu .menu-list { position: fixed; left: 0; right: auto; z-index: 20; text-transform: none; font-weight: var(--st-weight-regular); box-shadow: var(--st-shadow-menu); }
.case-menu .affix { display: flex; flex-direction: column; gap: 0.35rem; border-top: 1px solid var(--st-line); margin-top: 0.3rem; padding: 0.5rem 0.6rem 0.3rem; letter-spacing: normal; }
.case-menu .affix-title { font-size: 0.8rem; color: var(--st-ink-muted); }
.case-menu .affix label { display: grid; grid-template-columns: 3.2rem 1fr; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--st-ink); }
.case-menu .affix input { flex: 1; min-width: 0; width: 9rem; padding: 0.25rem 0.4rem; font: inherit; }
.case-menu .affix button { align-self: flex-start; }
.import-table td.cell { cursor: text; min-width: 5rem; max-width: 22rem; overflow-wrap: anywhere; }
.import-table td.cell:hover { outline: 1px dashed var(--st-field); }
.import-table td.cell.edited { background: var(--st-accent-soft); }
.import-table td.cell.saving { opacity: 0.5; }
/* Web addresses (e.g. photo links) are cut short; the full text shows on
   hover and when editing. Photo columns get a small thumbnail. */
.import-table td.cell-url { max-width: 14rem; white-space: nowrap; }
.import-table td.cell-url .cell-text { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.import-table td.cell-url .cell-thumb + .cell-text { max-width: calc(100% - 2.75rem); }
.cell-thumb { width: 2.25rem; height: 2.25rem; object-fit: cover; border-radius: 4px; margin-right: 0.5rem; vertical-align: middle; background: var(--st-line); }
.cell-input { width: 100%; min-width: 8rem; font: inherit; padding: 0.2rem 0.3rem; border: 1px solid var(--st-accent); border-radius: 6px; background: var(--st-surface); color: var(--st-ink); }
.row-problem { font-size: 0.8rem; color: var(--st-ink-muted); max-width: 18rem; white-space: normal; margin-top: 0.2rem; }
.stale-note { background: var(--st-accent-soft); border-radius: 8px; padding: 0.5rem 0.75rem; }

/* "Importing…" dialog with a spinner (long imports with photos). */
.busy-dialog { border: 1px solid var(--st-line); border-radius: 12px; padding: 1.5rem 2rem; max-width: 26rem; text-align: center; background: var(--st-surface); color: inherit; }
.busy-dialog:focus { outline: none; }
.busy-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.busy-dialog p { margin: 0.5rem 0 0; }
.spinner { width: 2rem; height: 2rem; margin: 0 auto 0.5rem; border: 3px solid var(--st-line); border-top-color: var(--st-accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

} /* @layer legacy */
