:root {
  --accent: #0a6b69;
  --accent-contrast: #fff;
  --bg: #f6f8f8;
  --surface: #fff;
  --text: #1c2526;
  --muted: #5f6c6d;
  --border: #d9e0e0;
  --error-bg: #fdecec;
  --error-text: #8a1c1c;
  --ok-bg: #e5f4f1;
}
@media (prefers-color-scheme: dark) {
  :root {
    --accent: #5cc7b9;
    --accent-contrast: #062624;
    --bg: #121717;
    --surface: #1a2121;
    --text: #e8eeee;
    --muted: #9aa8a8;
    --border: #2d3838;
    --error-bg: #3a1c1c;
    --error-text: #ffb4b4;
    --ok-bg: #173532;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0.5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 2rem 0 0.75rem; }
.muted { color: var(--muted); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.topbar { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.6rem 1rem; background: var(--surface); border-bottom: 3px solid var(--accent); }
.brand { font-weight: 700; color: var(--accent); text-decoration: none; font-size: 1.1rem; }
.topbar form { margin: 0; }
.nav-link { text-decoration: none; }
.spacer { flex: 1; }
.who { color: var(--muted); font-size: 0.9rem; }
.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
/* Pages with wide tables (import preview) use the whole window. */
.container.wide { max-width: none; padding: 1rem 1.5rem; }
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(--border); border-radius: 8px; background: var(--surface); color: var(--text); min-width: 0;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button { font: inherit; cursor: pointer; }
button.primary { background: var(--accent); color: var(--accent-contrast); border: 0; border-radius: 8px; padding: 0.5rem 1rem; font-weight: 600; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; }
.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.message { padding: 0.6rem 0.9rem; border-radius: 8px; background: var(--ok-bg); margin-bottom: 0.5rem; }
.message.error { background: var(--error-bg); color: var(--error-text); }
.login-card { max-width: 380px; margin: 12vh auto; padding: 1.5rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.login-card h1 { color: var(--accent); margin-top: 0; }
.login-card label { display: block; margin: 0.9rem 0 0.25rem; font-weight: 600; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 1.25rem; padding: 0.7rem; }
.filters { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.75rem; margin-bottom: 1rem; }
.filters .row { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.filters .row + .row, .filters details { margin-top: 0.6rem; }
.filters #q { flex: 1 1 260px; }
.filters select { flex: 0 1 240px; }
.checks label { display: inline-flex; gap: 0.35rem; align-items: center; }
.tag-filter summary { cursor: pointer; }
.tag-list { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.5rem; }
.chip { display: inline-block; padding: 0.1rem 0.55rem; border: 1px solid var(--border); border-radius: 999px; font-size: 0.85rem; text-decoration: none; background: var(--bg); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; }
.table th, .table td { text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
.table tr:last-child td { border-bottom: 0; }
.thumb-col { width: 56px; }
.thumb { width: 44px; height: 44px; object-fit: cover; border-radius: 6px; display: block; }
.thumb.empty { background: var(--bg); border: 1px dashed var(--border); }
.badge { display: inline-block; font-size: 0.75rem; padding: 0.05rem 0.5rem; border-radius: 999px; background: var(--accent); color: var(--accent-contrast); vertical-align: middle; }
.badge.default { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.count { margin: 0 0 0.4rem; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }
.empty-state { padding: 2rem; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border); border-radius: 12px; }
.inline-form { display: flex; gap: 0.6rem; flex-wrap: wrap; }
.inline-form input { flex: 1 1 240px; max-width: 400px; }
.actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.actions form { margin: 0; }
/* In a table, "actions" must stay a table cell (flex on a <td> breaks the
   row, e.g. an empty actions cell collapsed the Spaces table's lines);
   its forms and links sit side by side instead. */
td.actions { display: table-cell; white-space: nowrap; }
td.actions > form, td.actions > a { display: inline-block; margin: 0 1rem 0 0; vertical-align: middle; }
td.actions > :last-child { margin-right: 0; }
.photos { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.photos img { height: 140px; width: auto; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
.facts { display: grid; grid-template-columns: 11rem 1fr; gap: 0.5rem 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; margin: 0; }
.facts dt { color: var(--muted); font-weight: 600; }
.facts dd { margin: 0; }
.pre { white-space: pre-wrap; }
ul.plain { list-style: none; padding: 0; margin: 0; }
@media (max-width: 600px) {
  .facts { grid-template-columns: 1fr; gap: 0.1rem; }
  .facts dd { margin-bottom: 0.6rem; }
}
.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 0.25rem 1rem 1rem; margin-bottom: 1rem; }
.card h2 { margin-top: 0.75rem; }
.stack { display: flex; flex-direction: column; gap: 0.5rem; align-items: flex-start; margin-bottom: 0.75rem; }
.stack input[type=text], .stack textarea { width: 100%; max-width: 560px; }
textarea { font: inherit; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.stack label:not(.check) { font-weight: 600; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; }
button:not(.primary):not(.link-button):not(.chip-x):not(.menu-button) { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 8px; padding: 0.4rem 0.8rem; }
button.small { padding: 0.2rem 0.55rem; font-size: 0.85rem; }
button.danger { color: var(--error-text); }
.field-error { margin: 0; padding: 0.5rem 0.75rem; border-radius: 8px; background: var(--error-bg); color: var(--error-text); }
.warning { margin: 0; padding: 0.5rem 0.75rem; border-radius: 8px; background: var(--ok-bg); }
.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(--muted); padding: 0 0.3rem; }
.tag-list { margin-bottom: 0.75rem; }
.card .inline-form { margin-bottom: 0.75rem; }
.photo-edit { list-style: none; display: flex; gap: 1rem; flex-wrap: wrap; padding: 0; margin: 0 0 1rem; }
.photo-edit li { display: flex; flex-direction: column; gap: 0.35rem; align-items: flex-start; }
.photo-edit img { height: 140px; width: auto; max-width: 100%; border-radius: 8px; border: 1px solid var(--border); display: block; }
.photo-actions { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.photo-actions form { margin: 0; }
.code-list li { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.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(--accent); margin: 0.3rem 0; }
.loc { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.2rem 0.8rem; margin-bottom: 0.4rem; }
.loc summary { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; color: var(--text); padding: 0.4rem 0; }
.loc-name { font-weight: 600; }
.loc-body { padding: 0.2rem 0 0.6rem; }
.loc-toolbar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.5rem; }
.loc-toolbar form { margin: 0; }
.loc-list .loc-list { margin-left: 0.5rem; }
.loc-leaf { display: flex; gap: 0.6rem; align-items: baseline; flex-wrap: wrap; padding: 0.3rem 0.2rem; border-bottom: 1px solid var(--border); }
button.danger-solid, a.danger-link { color: var(--error-text); }
button.danger-solid { background: var(--error-bg); border: 1px solid var(--error-text); border-radius: 8px; padding: 0.5rem 1rem; font-weight: 600; }
.link-box { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 0.5rem 0; }
.link-box input { flex: 1 1 320px; max-width: 640px; font-family: ui-monospace, monospace; }
.narrow { max-width: 460px; margin: 4vh auto; }
.narrow label { display: block; margin: 0.8rem 0 0.25rem; font-weight: 600; }
.narrow input { width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.page-head .row { align-items: center; }
a.button, summary.button { display: inline-block; padding: 0.45rem 0.9rem; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); text-decoration: none; margin: 0; }
a.button.primary { background: var(--accent); color: var(--accent-contrast); border-color: var(--accent); font-weight: 600; }
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(--surface); border: 1px solid var(--border); 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(--bg); }
.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(--surface); border: 1px solid var(--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(--border); border-radius: 8px; background: var(--surface); color: var(--text); }
.undo-form { display: inline; margin: 0 0 0 0.75rem; }
fieldset.where { border: 1px solid var(--border); border-radius: 10px; display: flex; flex-direction: column; gap: 0.5rem; }
fieldset.where[hidden] { display: none; }
.stock-row { padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.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; }
.stock-actions details .stack { margin-top: 0.4rem; }
.add-stock { margin-top: 0.8rem; }
.stack .row { align-items: center; }
.menu-note { margin: 0.2rem 0.6rem; font-size: 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; }
/* The Columns menu sits in a filter row: no extra top margin (that rule is
   for the Tags toggle below the rows), and the same height as the inputs
   and selects next to it. */
.filters .row details.menu { margin-top: 0; }
.filters .row summary.button { padding: 0.45rem 0.6rem; line-height: inherit; }
.attr-filter { align-items: center; }
.table td { max-width: 24rem; overflow-wrap: anywhere; }

/* Header (top bar): brand + space · daily pages · Manage and account menus. */
.brand { display: inline-flex; align-items: center; gap: 0.45rem; }
.brand img { border-radius: 7px; display: block; }
.main-nav { display: flex; gap: 0.25rem; }
.topbar .nav-link { padding: 0.35rem 0.6rem; border-radius: 8px; text-decoration: none; border-bottom: 2px solid transparent; }
.topbar .nav-link:hover { background: var(--bg); }
.topbar .nav-link.active { color: var(--accent); border-bottom-color: var(--accent); border-radius: 8px 8px 0 0; font-weight: 600; }
.nav-menu summary { list-style: none; cursor: pointer; }
.nav-menu summary::-webkit-details-marker { display: none; }
.nav-menu .menu-list { min-width: 14rem; }
.nav-menu .menu-list form { margin: 0; }
.menu-button { all: unset; box-sizing: border-box; display: block; width: 100%; padding: 0.4rem 0.6rem; border-radius: 6px; cursor: pointer; color: var(--text); }
.menu-button:hover, .menu-button:focus-visible { background: var(--bg); }
.topbar .who { max-width: 16rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted, inherit); }
.topbar > * { min-width: 0; }
.topbar .nav-menu { flex-shrink: 0; }
.who-short { display: none; }
@media (max-width: 720px) {
  /* Logo only; the daily pages get their own row below; the menus stay on
     the first row and shrink rather than overflow. */
  .brand-name { display: none; }
  .space-switch select { max-width: 9rem; }
  .main-nav { order: 10; width: 100%; justify-content: space-around; }
  .who-email { display: none; }
  .who-short { display: inline; }
}

td.break { word-break: break-all; }

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

/* 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; }
.import-rows thead th { position: sticky; top: 0; background: var(--surface); }
tr.excluded td { opacity: 0.5; }
tr.excluded td:first-child { opacity: 1; }

/* 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(--text); }
.import-table .col-field { display: block; font-weight: 400; text-transform: none; font-size: 0.75rem; }
.case-menu { display: inline-block; margin-top: 0.15rem; }
.case-menu summary { font-size: 0.75rem; font-weight: 600; color: var(--accent); cursor: pointer; text-transform: none; }
.case-menu .menu-list { position: fixed; left: 0; right: auto; z-index: 20; text-transform: none; font-weight: 400; box-shadow: 0 6px 20px rgb(0 0 0 / 0.12); }
.case-menu .affix { display: flex; flex-direction: column; gap: 0.35rem; border-top: 1px solid var(--border); margin-top: 0.3rem; padding: 0.5rem 0.6rem 0.3rem; letter-spacing: normal; }
.case-menu .affix-title { font-size: 0.8rem; color: var(--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(--text); }
.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(--border); }
.import-table td.cell.edited { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.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(--border); }
.cell-input { width: 100%; min-width: 8rem; font: inherit; padding: 0.2rem 0.3rem; border: 1px solid var(--accent); border-radius: 6px; }
.row-problem { font-size: 0.8rem; color: var(--muted); max-width: 18rem; white-space: normal; margin-top: 0.2rem; }
.stale-note { background: color-mix(in srgb, var(--accent) 10%, transparent); border-radius: 8px; padding: 0.5rem 0.75rem; }

/* "Importing…" dialog with a spinner (long imports with photos). */
.busy-dialog { border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem 2rem; max-width: 26rem; text-align: center; background: var(--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(--border); border-top-color: var(--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; } }

/* History (owner): stock changes, newest first. */
.history-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.history-table .nowrap { white-space: nowrap; }
.history-table tr.undone td { color: var(--muted); }
.history-table tr.undone td:not(:nth-child(4)) { text-decoration: line-through; }

/* Pick lists */
.badge.warn { background: var(--error-bg); color: var(--error-text); }
.tabs { display: flex; gap: 1rem; margin: 1.25rem 0 0.75rem; border-bottom: 1px solid var(--border); }
.tabs a { padding: 0.35rem 0.1rem; text-decoration: none; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
