/* ==========================================================================
   Book Search & Stock Checker — "Ex Libris" theme
   Warm paper, library-green ink, saffron accents, serif display type.
   ========================================================================== */
:root {
  --paper: #f5efe3;
  --paper-2: #efe6d4;
  --panel: #fffcf6;
  --panel-2: #faf5ea;
  --ink: #1d2622;
  --ink-2: #4b5751;
  --muted: #7b847e;
  --line: #e7dcc8;
  --line-2: #d5c7ad;
  --forest: #13362e;
  --forest-2: #1f5246;
  --accent: #1f6b5a;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe8;
  --gold: #d49a2a;
  --gold-soft: #f7e8c8;
  --in: #1d7a47;
  --in-bg: #e1f1e6;
  --out: #b23a2c;
  --out-bg: #f8e3df;
  --nf: #6f756f;
  --nf-bg: #ece8df;
  --warn: #9a6200;
  --warn-bg: #fbeccb;
  --info: #255f8a;
  --info-bg: #e2ecf4;
  --mark: #f6dd8f;
  --shadow: 0 1px 0 rgba(94, 72, 34, .06), 0 2px 8px rgba(94, 72, 34, .07);
  --shadow-lg: 0 24px 60px rgba(30, 36, 32, .25);
  --radius: 14px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", "URW Palladio L", Georgia, serif;
  --sans: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: "Cascadia Mono", Consolas, "SF Mono", ui-monospace, Menlo, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #101512; --paper-2: #0c100e; --panel: #171e1a; --panel-2: #1c241f; --ink: #ece6d8; --ink-2: #c3bcac; --muted: #8d928a;
    --line: #28312c; --line-2: #36413a; --forest: #0b1f1a; --forest-2: #16362e; --accent: #58b394; --accent-ink: #0b1f1a; --accent-soft: #1a2e27;
    --gold: #e2ac45; --gold-soft: #3a3020; --in: #5fcf8c; --in-bg: #16301f; --out: #f0806f; --out-bg: #3a1d19; --nf: #a3a79f; --nf-bg: #242a26;
    --warn: #f0bd5a; --warn-bg: #3a2e14; --info: #8ec1ea; --info-bg: #17283a; --mark: #6a5418;
    --shadow: 0 1px 0 rgba(0,0,0,.35), 0 2px 10px rgba(0,0,0,.3); --shadow-lg: 0 24px 60px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased;
  background: var(--paper);
  background-image: radial-gradient(circle at 12% -10%, rgba(212, 154, 42, .10), transparent 42%), radial-gradient(circle at 100% 0%, rgba(31, 107, 90, .08), transparent 38%);
  background-attachment: fixed;
  min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; line-height: 1.2; margin: 0 0 .5em; letter-spacing: -.005em; }
h1 { font-size: 2.1rem; }
h2 { font-size: 1.28rem; }
h3 { font-size: 1.05rem; margin-top: 1.1em; }
code { font-family: var(--mono); font-size: .88em; background: var(--panel-2); padding: 1px 6px; border-radius: 5px; border: 1px solid var(--line); }
svg { fill: currentColor; }
ins { text-decoration: none; background: var(--gold-soft); color: var(--warn); border-bottom: 2px solid var(--gold); border-radius: 2px; padding: 0 1px; }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mono { font-family: var(--mono); font-size: .9em; letter-spacing: .01em; white-space: nowrap; }
.t-in { color: var(--in); font-weight: 700; }
.t-out { color: var(--out); font-weight: 700; }
.t-nf { color: var(--nf); font-weight: 700; }
.t-warn { color: var(--warn); font-weight: 700; }
.eyebrow { display: inline-block; font: 700 .72rem/1 var(--sans); letter-spacing: .16em; text-transform: uppercase; color: var(--gold); margin-bottom: 10px; }
.eyebrow::before { content: ""; display: inline-block; width: 22px; height: 2px; background: currentColor; vertical-align: middle; margin-right: 8px; border-radius: 2px; }

/* ------------------------------------------------ top bar */
.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 22px;
  background: var(--forest); color: #f3ead6; padding: 0 26px; height: 62px;
  box-shadow: inset 0 -3px 0 var(--gold), 0 6px 18px rgba(12, 30, 25, .18);
}
.brand { display: flex; align-items: center; gap: 11px; color: #fbf3e0; white-space: nowrap; font: 700 1.14rem/1 var(--serif); letter-spacing: .01em; }
.brand:hover { text-decoration: none; }
.monogram {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%;
  font: 700 1.05rem/1 var(--serif); color: var(--forest); background: linear-gradient(145deg, #f1c46a, var(--gold));
  box-shadow: inset 0 0 0 2px rgba(19, 54, 46, .25), 0 0 0 2px rgba(241, 196, 106, .35);
}
.mainnav {
  display: flex; gap: 2px; flex: 1 1 auto; min-width: 0;
  /* the menu can never sit on top of the user's name: if the window is too narrow
     for every item, the menu scrolls sideways instead of overflowing */
  overflow-x: auto; overflow-y: hidden; scrollbar-width: none; -ms-overflow-style: none;
}
.mainnav::-webkit-scrollbar { display: none; }
.mainnav a {
  display: flex; align-items: center; gap: 7px; padding: 9px 13px; border-radius: 9px; color: rgba(243, 234, 214, .72);
  font-weight: 600; font-size: .92rem; white-space: nowrap; position: relative;
}
.mainnav a svg { width: 17px; height: 17px; opacity: .8; }
.mainnav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.mainnav a.active { color: #fff; background: rgba(255, 255, 255, .1); }
.mainnav a.active::after { content: ""; position: absolute; left: 13px; right: 13px; bottom: -11px; height: 3px; border-radius: 3px 3px 0 0; background: #f6d38b; }
.usermenu { display: flex; align-items: center; gap: 14px; font-size: .88rem; white-space: nowrap; flex: 0 0 auto; margin-left: auto; }
.usermenu .who { opacity: .8; padding: 5px 11px; border: 1px solid rgba(243, 234, 214, .25); border-radius: 99px; }
.usermenu form { margin: 0; }
.usermenu .btn-link { color: #f6d38b; font-weight: 600; }
.nav-toggle { display: none; background: none; border: 0; padding: 8px; margin-left: auto; cursor: pointer; }
.nav-toggle span { display: block; width: 22px; height: 2px; background: #f3ead6; margin: 4px 0; border-radius: 2px; }

.wrap { max-width: 1380px; margin: 0 auto; padding: 30px 26px 70px; }
.page-head { margin: 4px 0 22px; }
.page-head h1 { margin-bottom: .25em; }
.page-head p { color: var(--ink-2); margin: 0; max-width: 820px; font-size: 1.02rem; }

/* ------------------------------------------------ buttons & forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 17px; border-radius: 10px;
  border: 1.5px solid var(--line-2); background: var(--panel); color: var(--ink); font: 600 .92rem/1.2 var(--sans);
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .08s, box-shadow .15s; white-space: nowrap;
}
.btn:hover { border-color: var(--ink-2); text-decoration: none; background: var(--panel-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 17px; height: 17px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); box-shadow: 0 2px 0 rgba(0,0,0,.12), 0 6px 16px rgba(31, 107, 90, .22); }
.btn.primary:hover { background: var(--forest-2); border-color: var(--forest-2); }
.btn.big { padding: 13px 24px; font-size: 1rem; border-radius: 12px; }
.btn.small { padding: 5px 11px; font-size: .82rem; }
.btn.in { color: var(--in); border-color: color-mix(in srgb, var(--in) 55%, transparent); }
.btn.out { color: var(--out); border-color: color-mix(in srgb, var(--out) 55%, transparent); }
.btn.nf { color: var(--nf); }
.btn.warn { color: var(--warn); border-color: color-mix(in srgb, var(--gold) 70%, transparent); background: var(--warn-bg); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }

input, select, textarea {
  font: inherit; color: var(--ink); background: var(--panel); border: 1.5px solid var(--line-2); border-radius: 10px; padding: 8px 11px; max-width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.btn:focus-visible, button:focus-visible, tr:focus-visible, a:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
input[type=checkbox], input[type=radio] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label, .grid-2 label, label.stack-inline { display: flex; flex-direction: column; gap: 6px; font-weight: 700; font-size: .86rem; color: var(--ink-2); }
.stack label.check, label.check { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; font-weight: 500; font-size: .93rem; margin: 7px 0; color: var(--ink); }
.check input { margin-top: 2px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
.inline-form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form .grow { flex: 1; min-width: 200px; }
.wrap-form > * { flex: 1 1 160px; }
.wrap-form > .btn { flex: 0 0 auto; }
.w-small { width: 130px; }
.w-tiny { width: 70px; }
textarea.code { width: 100%; font-family: var(--mono); font-size: .8rem; }

/* ------------------------------------------------ cards & stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.two-col { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.two-col > .card { margin-bottom: 0; }
.two-col.flush { margin: 12px 0 6px; gap: 28px; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(175px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat {
  position: relative; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 18px 20px 16px 24px; box-shadow: var(--shadow);
  overflow: hidden;
}
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--line-2); }
.stat::after { content: ""; position: absolute; right: 14px; top: 14px; width: 26px; height: 3px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); opacity: .9; }
.stat b { display: block; font: 700 2rem/1.05 var(--serif); font-variant-numeric: lining-nums tabular-nums; letter-spacing: -.01em; }
.stat span { color: var(--muted); font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.stat.in::before { background: var(--in); } .stat.in b { color: var(--in); }
.stat.out::before { background: var(--out); } .stat.out b { color: var(--out); }
.stat.nf::before { background: var(--nf); } .stat.nf b { color: var(--nf); }
.stat.warn::before { background: var(--gold); } .stat.warn b { color: var(--warn); }
.stat.good::before { background: var(--in); }
.stat.info::before { background: var(--info); } .stat.info b { color: var(--info); }
.stat-row.compact .stat { padding: 13px 16px 12px 20px; }
.stat-row.compact .stat b { font-size: 1.5rem; }

.alert { padding: 12px 16px; border-radius: 11px; margin: 0 0 16px; border: 1px solid; font-size: .93rem; }
.alert.ok { background: var(--in-bg); border-color: color-mix(in srgb, var(--in) 30%, transparent); }
.alert.err { background: var(--out-bg); border-color: color-mix(in srgb, var(--out) 30%, transparent); }
.alert.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 6px; font: 800 .72rem/1.4 var(--sans); letter-spacing: .09em; text-transform: uppercase; background: var(--nf-bg); color: var(--ink-2); }
.badge.big { font-size: .76rem; padding: 5px 12px; }
.badge.t-stock { background: var(--in-bg); color: var(--in); }
.badge.t-book, .badge.t-isbn { background: var(--info-bg); color: var(--info); }
.badge.t-noisbn, .badge.t-unknown { background: var(--warn-bg); color: var(--warn); }

/* ------------------------------------------------ search hero */
.search-hero {
  max-width: 1040px; margin: 8px auto 28px; padding: 34px 38px 26px; border-radius: 22px; position: relative; overflow: hidden;
  background: var(--forest) linear-gradient(135deg, var(--forest) 0%, var(--forest-2) 100%); color: #f3ead6;
  box-shadow: 0 18px 40px rgba(19, 54, 46, .22);
}
.search-hero::before { /* faint ruled lines like a catalogue card */
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .09;
  background: repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 32px);
}
.search-hero::after { /* book spines on the right */
  content: ""; position: absolute; right: 34px; top: 26px; width: 150px; height: 92px; opacity: .5; pointer-events: none;
  background:
    linear-gradient(#d49a2a, #d49a2a) 0 18px / 16px 74px no-repeat,
    linear-gradient(#f3ead6, #f3ead6) 20px 6px / 12px 86px no-repeat,
    linear-gradient(#58b394, #58b394) 36px 26px / 18px 66px no-repeat,
    linear-gradient(#b23a2c, #b23a2c) 58px 10px / 14px 82px no-repeat,
    linear-gradient(#f1c46a, #f1c46a) 76px 30px / 20px 62px no-repeat,
    linear-gradient(#f3ead6, #f3ead6) 100px 0 / 10px 92px no-repeat,
    linear-gradient(#d49a2a, #d49a2a) 114px 22px / 16px 70px no-repeat,
    linear-gradient(#58b394, #58b394) 134px 14px / 12px 78px no-repeat;
}
.hero-copy { position: relative; z-index: 1; margin-bottom: 20px; padding-right: 170px; }
.hero-copy .eyebrow { color: #f1c46a; }
.hero-copy h1 { font-size: 2.35rem; margin: 0 0 6px; color: #fbf3e0; }
.hero-copy h1 em { font-style: italic; color: #f1c46a; font-weight: 600; }
.hero-copy p { margin: 0; color: rgba(243, 234, 214, .75); font-size: .98rem; }
.searchbox {
  position: relative; z-index: 1; display: flex; align-items: center; background: var(--panel); border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .22), inset 0 0 0 2px transparent; transition: box-shadow .2s;
}
.searchbox:focus-within { box-shadow: 0 10px 30px rgba(0, 0, 0, .22), 0 0 0 4px #f1c46a; }
.searchbox > svg { width: 26px; height: 26px; margin-left: 20px; color: var(--accent); flex: none; }
.searchbox input { flex: 1; border: 0; background: transparent; font: 400 1.35rem var(--sans); padding: 19px 16px; min-width: 0; border-radius: 16px; color: var(--ink); }
.searchbox input:focus { box-shadow: none; }
.searchbox input::placeholder { color: var(--muted); }
.searchbox kbd { margin-right: 18px; border: 1px solid var(--line-2); border-bottom-width: 3px; border-radius: 6px; padding: 1px 8px; font: 600 .8rem var(--mono); color: var(--muted); }
.search-options { position: relative; z-index: 1; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 12px; margin-top: 16px; align-items: center; }
.seg { display: inline-flex; background: rgba(0, 0, 0, .2); border-radius: 12px; padding: 4px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: none; font: 700 .88rem var(--sans); color: rgba(243, 234, 214, .78); padding: 7px 14px; border-radius: 9px; cursor: pointer; }
.seg button:hover { color: #fff; background: rgba(255, 255, 255, .07); }
.seg button.on { background: #f1c46a; color: var(--forest); box-shadow: 0 2px 6px rgba(0, 0, 0, .2); }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters label { display: flex; align-items: center; gap: 7px; font-size: .78rem; color: rgba(243, 234, 214, .7); font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.filters input, .filters select { padding: 6px 10px; font-size: .88rem; border-color: transparent; background: rgba(255, 255, 255, .95); color: #1d2622; }
.filters input { width: 150px; }
.search-hero .btn-link { color: #f1c46a; font-weight: 700; }

.dashboard { max-width: 1040px; margin: 0 auto; }
.quick { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 4px 0 20px; }
.qcard {
  position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
  padding: 20px; box-shadow: var(--shadow); color: var(--ink); transition: transform .15s, border-color .15s, box-shadow .15s;
}
.qcard:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--gold); box-shadow: 0 12px 26px rgba(94, 72, 34, .14); }
.qcard b { font: 700 1.1rem var(--serif); }
.qcard span { color: var(--muted); font-size: .88rem; }
.qcard i { width: 42px; height: 42px; border-radius: 12px; background: var(--accent-soft); color: var(--accent); margin-bottom: 8px; display: flex; align-items: center; justify-content: center; }
.qcard i svg { width: 22px; height: 22px; }
.qcard::after { content: "→"; position: absolute; right: 18px; top: 18px; color: var(--gold); font-weight: 700; opacity: 0; transition: opacity .15s, transform .15s; }
.qcard:hover::after { opacity: 1; transform: translateX(3px); }
.empty-db { text-align: center; background: var(--panel); border: 2px dashed var(--line-2); border-radius: 16px; padding: 34px; margin-bottom: 20px; }

.results { position: relative; }
.results.loading .table-wrap { opacity: .55; transition: opacity .1s; }
.results-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.result-info { font-size: 1.02rem; }
.result-info b { font-family: var(--serif); font-size: 1.2rem; }
.results-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.results-actions label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.results-actions select { padding: 6px 9px; font-size: .88rem; }

/* ------------------------------------------------ tables */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card .table-wrap { box-shadow: none; border-radius: 11px; }
table.grid { width: 100%; border-collapse: collapse; font-size: .93rem; }
.grid th, .grid td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid thead th { background: var(--panel-2); font: 800 .7rem/1.3 var(--sans); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); position: sticky; top: 0; white-space: nowrap; border-bottom: 2px solid var(--line-2); }
.grid tbody tr:last-child td { border-bottom: 0; }
.grid.small th, .grid.small td { padding: 8px 11px; font-size: .86rem; }
.grid .num { text-align: right; white-space: nowrap; }
.grid.books tbody tr { cursor: pointer; transition: background .1s; }
.grid.books tbody tr:hover { background: var(--panel-2); }
.grid.books tbody tr.exact { background: var(--gold-soft); }
.grid td.title, .grid .title { font: 700 1rem/1.35 var(--serif); min-width: 240px; }
.grid td .sub, .grid .sub { font: 400 .8rem/1.4 var(--sans); color: var(--muted); margin-top: 2px; }
.grid th.hl, .grid td.hl { background: var(--accent-soft); }
.grid tr.dim td { opacity: .55; }
.grid .was { font-size: .75rem; color: var(--muted); font-family: var(--mono); }
.grid td.links a { margin-right: 10px; white-space: nowrap; }
.grid tr.flag td:first-child { box-shadow: inset 4px 0 0 var(--gold); }
.grid tr.r5 { background: color-mix(in srgb, var(--warn-bg) 55%, transparent); }
.grid .in-title { font: 600 .95rem/1.35 var(--serif); }
.grid td.check { min-width: 210px; font-size: .84rem; }
.grid td.check .note { display: inline-block; color: var(--warn); background: var(--warn-bg); padding: 4px 9px; border-radius: 8px; line-height: 1.35; }
.grid .ok-tick { color: var(--in); font-weight: 800; }
.grid .by { display: block; font-size: .72rem; color: var(--muted); margin-top: 5px; font-weight: 600; letter-spacing: .04em; }
mark { background: var(--mark); color: inherit; padding: 0 2px; border-radius: 3px; }
mark.soft { background: none; }

.qty {
  display: inline-grid; place-items: center; min-width: 50px; height: 38px; padding: 0 11px; border-radius: 10px;
  font: 700 1.25rem/1 var(--serif); font-variant-numeric: lining-nums tabular-nums;
}
.qty.in { background: var(--in-bg); color: var(--in); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--in) 35%, transparent); }
.qty.out { background: var(--out-bg); color: var(--out); box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--out) 30%, transparent); }
/* rubber-stamp status labels */
.status {
  display: inline-block; font: 800 .68rem/1 var(--sans); letter-spacing: .13em; padding: 6px 9px 5px; border-radius: 5px; white-space: nowrap;
  border: 1.5px solid currentColor; text-transform: uppercase; transform: rotate(-1.5deg);
}
.status.in { color: var(--in); background: var(--in-bg); }
.status.out { color: var(--out); background: var(--out-bg); }
.status.nf { color: var(--nf); background: var(--nf-bg); }
.status.warn { color: var(--warn); background: var(--warn-bg); }
.warn-dot { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--warn-bg); color: var(--warn); font: 800 .7rem var(--sans); vertical-align: middle; }
.no-results { text-align: center; padding: 50px 20px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.no-results h3 { font-size: 1.35rem; }
.no-results .nr-ic { font: 400 2.8rem/1 var(--serif); color: var(--gold); margin-bottom: 8px; }
.dym { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px; margin-top: 18px; }
.dym > span { font: italic 600 1rem var(--serif); color: var(--ink-2); }
.chip { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 1px; border: 1.5px solid var(--line-2); background: var(--panel-2); border-radius: 12px; padding: 8px 14px; cursor: pointer; font: inherit; color: var(--ink); text-align: left; }
.chip b { font: 700 .95rem var(--serif); }
.chip small { color: var(--muted); font-size: .76rem; }
.chip:hover { border-color: var(--gold); background: var(--gold-soft); }

.pager { display: flex; justify-content: center; gap: 5px; margin: 18px 0 0; flex-wrap: wrap; }
.pager button { border: 1.5px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: 9px; padding: 6px 12px; font: 600 .88rem var(--sans); cursor: pointer; }
.pager button:hover:not(:disabled) { border-color: var(--accent); }
.pager button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .gap { padding: 6px 4px; color: var(--muted); }

/* ------------------------------------------------ drawer (book details) */
.drawer { position: fixed; inset: 0; background: rgba(12, 22, 18, .5); backdrop-filter: blur(2px); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .18s; }
.drawer.open { opacity: 1; pointer-events: auto; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0; width: min(580px, 100%); background: var(--panel); box-shadow: var(--shadow-lg);
  padding: 30px 32px; overflow-y: auto; transform: translateX(40px); transition: transform .22s cubic-bezier(.2, .8, .2, 1);
  border-left: 6px solid var(--forest);
}
.drawer.open .drawer-panel { transform: none; }
.drawer-close { position: absolute; top: 14px; right: 16px; border: 0; background: var(--panel-2); width: 38px; height: 38px; border-radius: 50%; font-size: 1.5rem; line-height: 1; color: var(--ink-2); cursor: pointer; }
.drawer h2 { font-size: 1.6rem; margin: 20px 0 16px; padding-right: 30px; }
.d-status { display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-items: center; padding: 16px 20px; border-radius: 14px; margin-right: 44px; border: 2px dashed currentColor; }
.d-status .d-qty { grid-row: span 2; font: 700 3rem/1 var(--serif); font-variant-numeric: lining-nums; }
.d-status span:not(.d-qty) { font-weight: 800; letter-spacing: .14em; font-size: .9rem; }
.d-status small { color: var(--ink-2); }
.d-status.in { background: var(--in-bg); color: var(--in); }
.d-status.out { background: var(--out-bg); color: var(--out); }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 9px 20px; margin: 0 0 18px; }
dl.kv dt { color: var(--muted); font-size: .76rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; padding-top: 2px; }
dl.kv dd { margin: 0; word-break: break-word; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--gold); border-radius: 50%; margin: 60px auto; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------ upload / reports */
.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px; text-align: center;
  border: 2px dashed var(--line-2); border-radius: 16px; padding: 44px 20px; cursor: pointer; transition: border-color .15s, background .15s;
  background: var(--panel-2) repeating-linear-gradient(-45deg, transparent 0 14px, rgba(212, 154, 42, .05) 14px 28px);
}
.dropzone:hover, .dropzone.over { border-color: var(--accent); background-color: var(--accent-soft); }
.dropzone > svg { width: 44px; height: 44px; color: var(--accent); margin-bottom: 6px; padding: 9px; border-radius: 50%; background: var(--panel); box-shadow: var(--shadow); }
.dropzone strong { font: 700 1.2rem var(--serif); }
.dropzone span { color: var(--ink-2); }
.dropzone small { color: var(--muted); }
.dropzone.busy { pointer-events: none; }
.dz-progress { width: min(440px, 90%); margin-top: 16px; }
.dz-progress .bar, .progress { height: 9px; border-radius: 99px; background: var(--line); overflow: hidden; }
.dz-progress .bar i, .progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--gold)); border-radius: 99px; transition: width .25s; }
.dropzone.working .bar i { width: 100% !important; background: linear-gradient(90deg, var(--accent) 0%, var(--gold) 50%, var(--accent) 100%); background-size: 200% 100%; animation: slide 1.1s linear infinite; }
@keyframes slide { to { background-position: -200% 0; } }
.dz-progress em { display: block; font-style: normal; font-size: .86rem; color: var(--ink-2); margin-top: 7px; }
.progress.big { height: 14px; max-width: 620px; margin: 22px auto; }
.big-num { font: 700 1.6rem var(--serif); font-variant-numeric: lining-nums tabular-nums; margin: 6px 0; }

.report-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.file-line { display: flex; align-items: center; gap: 10px; font-size: 1.08rem; flex-wrap: wrap; }
.file-line b { font-family: var(--serif); }
.file-line select { padding: 4px 8px; font-size: .88rem; }
.file-ic { display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 44px; border-radius: 6px 12px 6px 6px; background: var(--in-bg); color: var(--in); font-size: .66rem; font-weight: 800; letter-spacing: .05em; box-shadow: inset 0 -3px 0 color-mix(in srgb, var(--in) 30%, transparent); }
.file-ic.ok { font-size: 1.1rem; }
.type-line { display: flex; gap: 10px; align-items: center; margin-top: 10px; flex-wrap: wrap; font-size: .9rem; }
.issues ul.notes { margin: 0; padding-left: 20px; color: var(--ink-2); font-size: .92rem; }
.issues ul.notes li { margin: 3px 0; }
details.issue { border-top: 1px solid var(--line); margin-top: 12px; padding-top: 10px; }
details.issue summary { cursor: pointer; }
details.issue .grid { margin-top: 10px; }

table.maptable { width: 100%; border-collapse: collapse; font-size: .9rem; }
.maptable th { text-align: left; font-weight: 700; padding: 7px 12px 7px 0; white-space: nowrap; color: var(--ink-2); width: 1%; border-top: 1px solid var(--line); }
.maptable td { padding: 6px 6px; border-top: 1px solid var(--line); }
.maptable tr:first-child th, .maptable tr:first-child td { border-top: 0; }
.maptable select { width: 100%; min-width: 150px; padding: 6px 9px; font-size: .88rem; }
.maptable tr:not(.mapped) select { color: var(--muted); }
.maptable tr.mapped th { color: var(--ink); }
.maptable td.sample { color: var(--muted); font-size: .8rem; max-width: 260px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.maptable .req { font-size: .62rem; background: var(--gold-soft); color: var(--warn); padding: 2px 6px; border-radius: 4px; text-transform: uppercase; font-weight: 800; letter-spacing: .08em; }
.conf { font-size: .7rem; font-weight: 800; padding: 3px 8px; border-radius: 99px; white-space: nowrap; letter-spacing: .03em; }
.conf.high { background: var(--in-bg); color: var(--in); }
.conf.medium { background: var(--info-bg); color: var(--info); }
.conf.low { background: var(--warn-bg); color: var(--warn); }
.conf.manual { background: var(--nf-bg); color: var(--ink-2); }
.mapping.inline { margin: 6px 0; }
.preview-mini { margin: 10px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.actions.center { justify-content: center; }

.mode-opt { display: flex; gap: 13px; padding: 13px 16px; border: 1.5px solid var(--line-2); border-radius: 12px; margin-bottom: 10px; cursor: pointer; align-items: flex-start; transition: border-color .15s, background .15s; background: var(--panel); }
.mode-opt:hover { border-color: var(--accent); }
.mode-opt input { margin-top: 3px; }
.mode-opt:has(input:checked), .mode-opt.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.mode-opt b { display: block; font-family: var(--serif); font-size: 1.02rem; }
.mode-opt small { color: var(--ink-2); display: block; font-size: .85rem; margin-top: 3px; }
.confirm-replace { background: var(--warn-bg); border-radius: 11px; padding: 11px 15px; margin-top: 6px; border: 1px dashed var(--gold); }
.confirm-replace label { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; font-size: .9rem; }
.confirm-replace input { width: 150px; font-family: var(--mono); }
.done-ic { width: 66px; height: 66px; border-radius: 50%; background: var(--in-bg); color: var(--in); font-size: 2.1rem; display: flex; align-items: center; justify-content: center; margin: 4px auto 12px; border: 2px dashed currentColor; }

.downloads { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.downloads > span { font: 700 1rem var(--serif); margin-right: 6px; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; font: 700 .92rem var(--sans); color: var(--ink-2); padding: 10px 15px; cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; border-radius: 8px 8px 0 0; }
.tabs button:hover { background: var(--panel-2); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--gold); }
.tabs button[data-f=review].on { color: var(--warn); }
.tabs .count { font-size: .74rem; background: var(--nf-bg); border-radius: 99px; padding: 2px 8px; margin-left: 5px; color: var(--ink-2); }
.review-hint { background: var(--warn-bg); border: 1px dashed var(--gold); color: var(--ink); border-radius: 12px; padding: 12px 16px; margin: -4px 0 14px; font-size: .92rem; }
.review-hint b { font-family: var(--serif); }
.recent { margin-top: 24px; }

.export-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 20px; }
.xcard { position: relative; display: flex; flex-direction: column; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 20px 22px 20px 26px; box-shadow: var(--shadow); color: var(--ink); overflow: hidden; transition: transform .15s, box-shadow .15s; }
.xcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--accent); }
.xcard:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 12px 26px rgba(94, 72, 34, .14); }
.xcard.in::before { background: var(--in); } .xcard.out::before { background: var(--out); }
.xcard svg { width: 24px; height: 24px; color: var(--gold); }
.xcard b { font: 700 1.1rem var(--serif); }
.xcard span { color: var(--muted); font-size: .88rem; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row-actions form { margin: 0; }
.row-actions input { width: 140px; padding: 5px 9px; font-size: .84rem; }

/* ------------------------------------------------ login / install */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; background: var(--forest) linear-gradient(160deg, var(--forest), var(--forest-2)); }
.login-page.split { display: grid; grid-template-columns: 1.1fr 1fr; padding: 0; background: var(--paper); }
.login-art { position: relative; background: var(--forest) linear-gradient(160deg, var(--forest) 0%, var(--forest-2) 100%); color: #f3ead6; display: flex; flex-direction: column; justify-content: flex-end; padding: 60px; overflow: hidden; min-height: 100vh; }
.login-art::before { content: ""; position: absolute; inset: 0; opacity: .08; background: repeating-linear-gradient(0deg, #fff 0 1px, transparent 1px 36px); }
.shelf { position: absolute; left: 60px; right: 60px; top: 18%; height: 220px; display: flex; align-items: flex-end; gap: 7px; border-bottom: 10px solid #0c231e; }
.shelf i { display: block; flex: 1; border-radius: 3px 3px 0 0; background: #f3ead6; box-shadow: inset -5px 0 0 rgba(0,0,0,.12), inset 0 14px 0 rgba(255,255,255,.12), inset 0 -22px 0 rgba(0,0,0,.08); }
.shelf i:nth-child(1) { height: 70%; background: #d49a2a; } .shelf i:nth-child(2) { height: 88%; background: #f3ead6; }
.shelf i:nth-child(3) { height: 62%; background: #58b394; } .shelf i:nth-child(4) { height: 95%; background: #b23a2c; }
.shelf i:nth-child(5) { height: 76%; background: #f1c46a; } .shelf i:nth-child(6) { height: 58%; background: #2c7a68; transform: rotate(-8deg); transform-origin: bottom left; margin-left: 10px; }
.shelf i:nth-child(7) { height: 84%; background: #e9dcc2; } .shelf i:nth-child(8) { height: 68%; background: #d49a2a; }
.shelf i:nth-child(9) { height: 92%; background: #7f2d24; } .shelf i:nth-child(10) { height: 74%; background: #58b394; }
.shelf i:nth-child(11) { height: 60%; background: #f3ead6; } .shelf i:nth-child(12) { height: 86%; background: #c98a1c; }
.login-art blockquote { position: relative; margin: 0; font: italic 600 1.6rem/1.4 var(--serif); max-width: 460px; color: #fbf3e0; }
.login-art cite { display: block; margin-top: 12px; font: normal 700 .8rem var(--sans); letter-spacing: .14em; text-transform: uppercase; color: #f1c46a; }
.login-box { width: 100%; max-width: 420px; background: var(--panel); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px 36px 30px; margin: auto; }
.login-page.split .login-box { box-shadow: none; background: transparent; }
.login-box.wide { max-width: 780px; }
.login-brand { text-align: center; margin-bottom: 22px; }
.login-brand .monogram { width: 58px; height: 58px; font-size: 1.8rem; }
.login-brand svg { width: 44px; height: 44px; color: var(--accent); }
.login-brand h1 { font-size: 1.7rem; margin: 12px 0 4px; }
.login-brand p { color: var(--muted); margin: 0; font-size: .92rem; }
.login-box .btn.big { width: 100%; margin-top: 6px; }
.checks { list-style: none; padding: 0; margin: 0 0 16px; columns: 2; font-size: .9rem; }
.checks li.ok { color: var(--in); } .checks li.bad { color: var(--out); font-weight: 700; } .checks li.warn { color: var(--warn); }

.toast { position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 30px); background: var(--forest); color: #fbf3e0; padding: 12px 20px; border-radius: 12px; box-shadow: var(--shadow-lg); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: min(640px, 92vw); font-size: .93rem; border-left: 5px solid var(--gold); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #7f2419; border-left-color: #f0806f; }
.toast.ok { background: #145233; border-left-color: #5fcf8c; }
body.loading { cursor: progress; }

/* compact hero while results are shown */
.searching .hero-copy { display: none; }
.searching .search-hero { padding: 20px 24px 18px; margin-bottom: 22px; }
.searching .search-hero::after { display: none; }

/* ------------------------------------------------ responsive */
@media (max-width: 1700px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .mainnav a svg { display: none; }
  .mainnav a { padding: 8px 8px; font-size: .87rem; }
  .usermenu .who { display: none; }
  .nav-badge { margin-left: 4px; padding: 1px 5px; font-size: .68rem; }
}
@media (max-width: 1340px) {
  .brand span:last-child { display: none; }
  .mainnav a { padding: 8px 6px; font-size: .84rem; }
}
@media (max-width: 1120px) {
  .two-col { grid-template-columns: 1fr; }
  .nav-toggle { display: block; }
  .brand span:last-child { display: inline; }
  .mainnav { display: none; position: absolute; top: 62px; left: 0; right: 0; background: var(--forest); flex-direction: column; padding: 8px 12px 14px; box-shadow: var(--shadow-lg); border-bottom: 3px solid var(--gold); }
  .mainnav a svg { display: inline; }
  .mainnav a.active::after { display: none; }
  body.nav-open .mainnav { display: flex; }
  .usermenu .who { display: none; }
  .topbar { gap: 12px; }
  .login-page.split { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .hero-copy { padding-right: 0; }
  .search-hero::after { display: none; }
}
@media (max-width: 640px) {
  h1 { font-size: 1.7rem; }
  .wrap { padding: 16px 16px 50px; }
  .topbar { padding: 0 14px; }
  .brand span:last-child { font-size: 1rem; }
  .search-hero { padding: 22px 18px 18px; border-radius: 18px; margin-top: 0; }
  .hero-copy h1 { font-size: 1.6rem; }
  .searchbox input { font-size: 1.05rem; padding: 15px 10px; }
  .searchbox > svg { margin-left: 13px; width: 22px; height: 22px; }
  .searchbox kbd { display: none; }
  .search-options { flex-direction: column; align-items: stretch; }
  .seg { justify-content: space-between; }
  .seg button { padding: 7px 8px; font-size: .82rem; }
  .filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .filters label { flex-direction: column; align-items: stretch; gap: 4px; font-size: .68rem; }
  .filters input, .filters select { width: 100%; }
  .stat b { font-size: 1.55rem; }
  .grid-2 { grid-template-columns: 1fr; }
  .grid.books thead { display: none; }
  .grid.books, .grid.books tbody, .grid.books tr, .grid.books td { display: block; width: 100%; }
  .grid.books tr { padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto; gap: 3px 10px; }
  .grid.books td { border: 0; padding: 0; min-width: 0; }
  .grid.books td.title { grid-column: 1 / -1; order: -1; min-width: 0; }
  .grid.books td.num { grid-column: 2; grid-row: 2 / span 3; align-self: center; }
  .grid.books td.check { min-width: 0; }
  .checks { columns: 1; }
  dl.kv { grid-template-columns: 1fr; gap: 2px; }
  dl.kv dd { margin-bottom: 8px; }
  .drawer-panel { padding: 24px 20px; }
}

/* ==========================================================================
   Price
   ========================================================================== */
.price { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink-2); white-space: nowrap; }

/* ==========================================================================
   Scanner
   ========================================================================== */
.scan-stage { margin: 18px 0 22px; }
.scan-box {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  background: var(--panel); border: 2px solid var(--forest); border-radius: var(--radius);
  box-shadow: var(--shadow); position: relative;
}
.scan-box::after {
  content: ""; position: absolute; inset: 4px; border-radius: 10px; border: 1px dashed var(--line-2); pointer-events: none;
}
.scan-box > svg { width: 30px; height: 30px; color: var(--forest); flex: none; }
.scan-box input {
  flex: 1; border: 0; background: none; font: 600 1.35rem var(--mono); color: var(--ink);
  padding: 10px 2px; letter-spacing: .04em; min-width: 0;
}
.scan-box input:focus { outline: none; }
.scan-box input::placeholder { font: 400 1rem var(--sans); letter-spacing: 0; color: var(--muted); }
.scan-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 12px 2px 0; font-size: .9rem; }
.scan-opts .grow { flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; color: var(--ink-2); }
.chk small { color: var(--muted); }
.scan-last {
  margin-top: 16px; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); border-left: 6px solid var(--line-2); box-shadow: var(--shadow);
  animation: pop .18s ease-out;
}
@keyframes pop { from { transform: scale(.985); opacity: .5; } to { transform: none; opacity: 1; } }
.scan-last.ok { border-left-color: var(--in); background: color-mix(in srgb, var(--in-bg) 55%, var(--panel)); }
.scan-last.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-bg) 45%, var(--panel)); }
.scan-last.bad { border-left-color: var(--out); background: color-mix(in srgb, var(--out-bg) 45%, var(--panel)); }
.sl-title { font: 700 1.3rem/1.25 var(--serif); }
.sl-sub { color: var(--ink-2); margin-top: 2px; }
.sl-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 10px; }
.sl-facts .scanned { font-size: .85rem; color: var(--warn); background: var(--warn-bg); padding: 2px 9px; border-radius: 999px; }
.scan-results { margin-top: 18px; }

/* a list that came back after a reload, a timeout or a different address */
/* where the copies are — under the quantity in a list, and in the book panel */
.places { display: block; margin-top: 3px; font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .01em; white-space: nowrap; }
.d-places { display: flex; gap: 10px; flex-wrap: wrap; margin: -6px 0 18px; }
.d-places span {
  display: inline-flex; align-items: baseline; gap: 6px; padding: 7px 13px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line); font-size: .86rem; color: var(--ink-2);
}
.d-places b { font: 700 1.05rem var(--sans); color: var(--forest); }

/* tidy-up: groups of names that mean the same thing */
.tidy-groups { display: grid; gap: 10px; }
.tidy-group {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2);
}
.tg-tag { font: 700 .68rem var(--sans); letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 4px 9px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); }
.tg-tag.warn { color: var(--warn); border-color: var(--warn); background: var(--warn-bg); }
.tidy-group.unsure { border-left: 4px solid var(--warn); }
.tg-names { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; flex: 1; min-width: 0; }
.pick { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; border: 1.5px solid var(--line-2); border-radius: 99px; background: var(--panel); cursor: pointer; font-size: .9rem; }
.pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.pick input { margin: 0; }
.pick small, .cur-from small { color: var(--muted); font-size: .75rem; }
.cur-code { font: 700 .9rem var(--sans); color: var(--accent-ink); background: var(--accent); padding: 5px 12px; border-radius: 99px; }
.cur-from { padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 99px; background: var(--panel); font-size: .88rem; }
.dup-line { padding: 3px 0; font-size: .9rem; }
.dup-line span { display: block; font-size: .8rem; }

/* "only apply documents from this date" on Stock Update */
.sub-opt { display: block; margin: -4px 0 0 30px; font-size: .9rem; }
.sub-opt select { font: inherit; padding: 6px 10px; border-radius: 9px; border: 1.5px solid var(--line-2); background: var(--panel); margin: 0 0 0 6px; }
.sub-opt small { display: block; margin-top: 5px; max-width: 70ch; }

.from-date {
  margin: 4px 0 18px; padding: 14px 16px; border-radius: 12px;
  background: var(--gold-soft); border: 1px solid var(--line-2); border-left: 4px solid var(--gold);
}
.from-date label { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-weight: 600; margin: 0; }
.from-date input[type=date] { font: inherit; padding: 7px 11px; border-radius: 9px; border: 1.5px solid var(--line-2); background: var(--panel); }
.from-date p { margin: 8px 0 0; max-width: 78ch; }

.places-table input { width: 100%; }
.places-table .num-input { width: 5em; }

.recovered {
  margin: 0 0 12px; padding: 9px 14px; font-size: .92rem; color: var(--ink-2);
  background: var(--accent-soft); border: 1px solid var(--line); border-left: 4px solid var(--accent);
  border-radius: 10px;
}
.recovered b { color: var(--forest); }

/* “saved” marker next to the count */
.save-state { font-size: .82rem; color: var(--muted); letter-spacing: .02em; }
.save-state.ok { color: var(--in); }
.save-state.bad { color: var(--out); font-weight: 700; }

/* the login timed out while a screen still holds unfinished work */
.session-bar {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  max-width: min(900px, calc(100vw - 32px)); z-index: 60;
  padding: 12px 16px; border-radius: 12px; font-size: .92rem;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--line-2); border-left: 5px solid var(--warn);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
}
.session-bar span { color: var(--ink-2); flex: 1 1 260px; }

/* ==========================================================================
   Stock update from the billing backup
   ========================================================================== */
.bak-zone { border-style: solid; border-width: 2px; }
.bak-run { margin-top: 18px; }
.bak-run .bar { height: 10px; background: var(--paper-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.bak-run .bar i { display: block; height: 100%; width: 2%; background: linear-gradient(90deg, var(--accent), var(--gold)); transition: width .25s ease; }
.bak-run p { margin-top: 8px; }
.doc-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 12px; margin-bottom: 16px; }
.dt { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); border-left: 5px solid var(--nf); }
.dt b { display: block; font: 600 1rem var(--sans); }
.dt span { display: block; color: var(--muted); font-size: .85rem; margin: 3px 0 6px; }
.dt em { font-style: normal; font-size: .82rem; font-weight: 600; color: var(--nf); }
.dt.plus { border-left-color: var(--in); } .dt.plus em { color: var(--in); }
.dt.minus { border-left-color: var(--out); } .dt.minus em { color: var(--out); }
.dt.off { opacity: .6; }
.bak-actions { display: flex; flex-direction: column; gap: 10px; }
.rules select { padding: 5px 8px; }
.rules .muted-row td { color: var(--muted); }
.eff.none { color: var(--muted); font-size: .88rem; }
.stat.warn::before { background: var(--warn); } .stat.warn b { color: var(--warn); }
.btn.danger { color: var(--out); border-color: color-mix(in srgb, var(--out) 45%, transparent); }
.btn.danger:hover { background: var(--out-bg); border-color: var(--out); }
#bakLinks { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0; }

/* ==========================================================================
   Low stock: nav badge, pop-up and reorder list
   ========================================================================== */
.nav-badge {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--gold); color: var(--forest); font-size: .72rem; font-weight: 800; line-height: 1.45;
}
a.stat { text-decoration: none; color: inherit; }
a.stat:hover { text-decoration: none; border-color: var(--line-2); box-shadow: var(--shadow-lg); }

.lowstock-pop {
  position: fixed; right: 20px; bottom: 20px; z-index: 60; width: min(420px, calc(100vw - 32px));
  background: var(--panel); border: 1px solid var(--line-2); border-radius: 16px; box-shadow: var(--shadow-lg);
  overflow: hidden; transform: translateY(18px) scale(.98); opacity: 0; transition: transform .26s ease, opacity .26s ease;
}
.lowstock-pop.in { transform: none; opacity: 1; }
.ls-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; background: var(--warn-bg); border-bottom: 1px solid var(--line); }
.ls-ic {
  flex: none; display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%;
  background: var(--gold); color: var(--forest); font: 800 1.1rem/1 var(--sans);
}
.ls-head b { display: block; font: 700 1.05rem var(--serif); color: var(--warn); }
.ls-head small { color: var(--ink-2); }
.ls-head div { flex: 1; min-width: 0; }
.ls-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; color: var(--muted); cursor: pointer; padding: 0 4px; }
.ls-close:hover { color: var(--ink); }
.ls-list { list-style: none; margin: 0; padding: 6px 0; max-height: 46vh; overflow: auto; }
.ls-list li { display: flex; align-items: center; gap: 10px; padding: 7px 16px; border-bottom: 1px solid var(--line); }
.ls-list li:last-child { border-bottom: 0; }
.ls-qty {
  flex: none; min-width: 58px; text-align: center; padding: 3px 8px; border-radius: 6px;
  font-size: .78rem; font-weight: 700; background: var(--warn-bg); color: var(--warn);
}
.ls-qty.zero { background: var(--out-bg); color: var(--out); }
.ls-title { flex: 1; min-width: 0; font-size: .92rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ls-title small { display: block; color: var(--muted); font-size: .78rem; overflow: hidden; text-overflow: ellipsis; }
.ls-order { flex: none; font-size: .8rem; color: var(--accent); font-weight: 700; }
.ls-foot { display: flex; gap: 8px; padding: 12px 16px; background: var(--panel-2); border-top: 1px solid var(--line); }
@media (max-width: 640px) { .lowstock-pop { right: 8px; bottom: 8px; } .ls-list { max-height: 36vh; } }

#roTable .order { color: var(--accent); }
.num-input { width: 5.5em; }
.alert.no-price { margin-bottom: 18px; }
.pub-note { margin: -6px 0 16px; padding: 10px 14px; border-left: 4px solid var(--gold); background: var(--panel-2); border-radius: 0 10px 10px 0; font-size: .92rem; }
.pub-match { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; background: var(--panel-2); font-size: .9rem; }
.pub-match summary { cursor: pointer; color: var(--accent); margin-top: 4px; }
.pub-list { margin: 8px 0 0; padding-left: 0; list-style: none; font-size: .86rem; color: var(--ink-2); }
.pub-list li { padding: 3px 0; border-top: 1px solid var(--line); }
.pub-list .pat { display: inline-block; min-width: 9em; font-weight: 700; color: var(--forest); }
.pub-group { padding: 10px 0; border-top: 1px solid var(--line); }
.pub-group:first-of-type { border-top: 0; }
.pub-group .pat { font: 700 .8rem var(--sans); letter-spacing: .04em; color: var(--forest); text-transform: uppercase; margin-bottom: 6px; }
.pub-names { display: flex; flex-wrap: wrap; gap: 6px; }
.pub-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 7px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel); font-size: .84rem; cursor: pointer; user-select: none;
}
.pub-chip.on { border-color: color-mix(in srgb, var(--in) 45%, transparent); background: var(--in-bg); color: var(--in); }
.pub-chip.off { opacity: .55; text-decoration: line-through; }
.pub-chip:hover { border-color: var(--ink-2); }
.pub-chip input { margin: 0; }
.pub-match form .btn { margin-top: 12px; }

/* ==========================================================================
   Quotation
   ========================================================================== */
.quote-card { border-left: 5px solid var(--gold); }
.quote-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 12px; }
.quote-grid .wide { grid-column: span 2; }
@media (max-width: 700px) { .quote-grid .wide { grid-column: span 1; } }
.quote-card .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.logo-row { display: flex; gap: 16px; align-items: flex-start; }
.logo-row .grow { flex: 1; min-width: 0; }
.logo-box {
  flex: none; width: 170px; height: 74px; border: 1px dashed var(--line-2); border-radius: 10px;
  display: grid; place-items: center; background: var(--panel-2); overflow: hidden; padding: 6px;
}
.logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.quote-sum { margin: 16px 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel-2); }
.qs-row { display: flex; justify-content: space-between; gap: 16px; padding: 8px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; }
.qs-row:last-child { border-bottom: 0; }
.qs-row.warn { color: var(--warn); }
.qs-row.total { background: var(--accent-soft); font: 700 1.05rem var(--serif); padding: 12px 14px; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 640px) { .row-3 { grid-template-columns: 1fr; } }

/* ==========================================================================
   Camera scanning, phone pairing, scanner help
   ========================================================================== */
.scan-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.scan-tools .grow { flex: 1; }
.or-line { display: flex; align-items: center; gap: 14px; margin: 22px 0 16px; color: var(--muted); font-size: .9rem; }
.or-line::before, .or-line::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.scan-inline .scan-box.small { padding: 6px 12px; }
.scan-inline .scan-box.small input { font-size: 1.1rem; padding: 8px 2px; }
.scan-inline .table-wrap { margin-top: 16px; max-height: 420px; overflow: auto; }
.scan-inline .actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 14px; }

.cam-box { position: relative; margin-top: 14px; border-radius: 14px; overflow: hidden; background: #000; max-width: 560px; }
.cam-box video { display: block; width: 100%; max-height: 380px; object-fit: cover; }
.cam-frame {
  position: absolute; left: 10%; right: 10%; top: 28%; bottom: 28%; pointer-events: none;
  border: 2px solid rgba(246, 211, 139, .9); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .35);
}
.cam-bar {
  position: absolute; left: 0; right: 0; bottom: 0; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); color: #fff; font-size: .85rem;
}
.cam-bar .btn { margin-left: auto; background: rgba(255, 255, 255, .92); }
.cam-bar .btn + .btn { margin-left: 0; }
.cam-bar .btn.on { background: var(--gold); }

.pair-box { margin-top: 14px; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel-2); padding: 16px 18px; }
.pair-main { display: flex; flex-wrap: wrap; gap: 22px; align-items: flex-start; }
.pair-main > div:first-child { flex: 1; min-width: 260px; }
.pair-side { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.pair-box h3 { margin: 0 0 8px; font: 700 1.1rem var(--serif); }
.pair-steps { margin: 0 0 10px; padding-left: 20px; font-size: .92rem; color: var(--ink-2); }
.pair-url { font-family: var(--mono); font-size: .9rem; color: var(--forest); word-break: break-all; }
.pair-code {
  display: inline-block; font: 800 1.9rem/1 var(--mono); letter-spacing: .12em; color: var(--forest);
  background: var(--panel); border: 2px dashed var(--gold); border-radius: 12px; padding: 12px 18px; cursor: copy;
}
.help-box { margin-top: 14px; }
.help-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 18px; }
.help-grid > div > b { display: block; margin-bottom: 4px; color: var(--forest); }
.help-grid p b { color: var(--forest); }
.help-grid p { margin: 0 0 6px; font-size: .9rem; color: var(--ink-2); }

/* ==========================================================================
   phone.php
   ========================================================================== */
body.phone { background: var(--paper); margin: 0; }
.ph-top {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: var(--forest); color: #f3ead6; box-shadow: inset 0 -3px 0 var(--gold);
}
.ph-brand { font: 700 1rem var(--serif); }
.ph-state { font-size: .8rem; padding: 3px 10px; border-radius: 999px; background: rgba(255, 255, 255, .14); }
.ph-state.ok { background: var(--in); color: #fff; }
.ph-state.bad { background: var(--out); color: #fff; }
.ph-main { padding: 16px; max-width: 640px; margin: 0 auto; }
.ph-join h1 { font: 700 1.5rem var(--serif); margin: 8px 0; }
.ph-join input {
  width: 100%; font: 700 1.6rem var(--mono); text-align: center; letter-spacing: .12em; text-transform: uppercase;
  padding: 14px; border-radius: 12px; border: 2px solid var(--line-2); margin: 12px 0;
}
.ph-join .btn { width: 100%; justify-content: center; }
.ph-err { color: var(--out); font-weight: 600; }
.ph-hint { color: var(--muted); font-size: .85rem; margin-top: 14px; }
.ph-actions { display: flex; flex-direction: column; gap: 12px; }
.ph-actions .btn.big { justify-content: center; }
.ph-manual { display: flex; gap: 8px; }
.ph-manual input { flex: 1; font: 600 1.1rem var(--mono); padding: 12px; border-radius: 10px; border: 1px solid var(--line-2); min-width: 0; }
.ph-cam { position: relative; border-radius: 14px; overflow: hidden; background: #000; margin-bottom: 14px; }
.ph-cam video { display: block; width: 100%; max-height: 60vh; object-fit: cover; }
.ph-frame {
  position: absolute; left: 8%; right: 8%; top: 30%; bottom: 30%; pointer-events: none;
  border: 2px solid rgba(246, 211, 139, .9); border-radius: 10px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .3);
}
.ph-stop, .ph-torch {
  position: absolute; bottom: 12px; padding: 8px 14px; border-radius: 999px; border: 0;
  background: rgba(255, 255, 255, .92); font-weight: 600; cursor: pointer;
}
.ph-stop { right: 12px; }
.ph-torch { left: 12px; }
.ph-torch.on { background: var(--gold); }
.ph-last {
  margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--panel);
  border-left: 6px solid var(--line-2); box-shadow: var(--shadow);
}
.ph-last.ok { border-left-color: var(--in); background: color-mix(in srgb, var(--in-bg) 55%, var(--panel)); }
.ph-last.warn { border-left-color: var(--warn); background: color-mix(in srgb, var(--warn-bg) 45%, var(--panel)); }
.ph-last.bad { border-left-color: var(--out); background: color-mix(in srgb, var(--out-bg) 45%, var(--panel)); }
.ph-last b { display: block; font: 700 1.1rem/1.3 var(--serif); }
.ph-last small { display: block; color: var(--ink-2); margin-top: 2px; }
.ph-qty { display: inline-block; margin-top: 8px; padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 700; }
.ph-qty.in { background: var(--in-bg); color: var(--in); }
.ph-qty.out { background: var(--out-bg); color: var(--out); }
.ph-list { list-style: none; margin: 14px 0 0; padding: 0; font-size: .86rem; }
.ph-list li { display: flex; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line); }
.ph-list li span:last-child { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); }
.ph-list li.bad { color: var(--out); }
