:root {
    --bg: #f3f0ea;
    --paper: #ffffff;
    --ink: #17140f;
    --muted: #857c70;
    --line: #e7e1d7;
    --brass: #c9a24b;
    --brass-soft: #f4ecda;
    --green: #2f7a4f;
    --red: #b4432f;
    --radius: 18px;
    --shadow: 0 1px 2px rgba(23, 20, 15, .04), 0 8px 24px rgba(23, 20, 15, .06);
    --glass: rgba(23, 20, 15, .88);
    --serif: "Fraunces", Georgia, serif;
    --sans: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--ink); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.02em; }
h1 { font-size: 2.6rem; font-weight: 700; }
h2 { font-size: 1.6rem; margin-top: 1.6em; }
img { max-width: 100%; display: block; }

.wrap { max-width: 1200px; margin: 0 auto; padding: 36px 16px 130px; }

/* floating glass header */
.top { position: sticky; top: 12px; z-index: 10; margin: 12px auto 0; max-width: 1200px; width: calc(100% - 24px);
    display: flex; align-items: center; gap: 20px; padding: 8px 8px 8px 16px; border-radius: 999px;
    background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); color: #fff;
    box-shadow: 0 10px 30px rgba(23, 20, 15, .18); }
.brand { font: 700 1.3rem var(--serif); color: #fff; text-decoration: none; display: flex; align-items: center; gap: 10px; letter-spacing: -.01em; }
.brand img { width: 38px; height: 38px; }
.links { display: flex; gap: 2px; flex: 1; min-width: 0; }
.links a { white-space: nowrap; }
.links a { color: #fff; text-decoration: none; opacity: .7; padding: 7px 14px; border-radius: 999px; font-size: 14px; transition: .15s; }
.links a:hover { opacity: 1; background: rgba(255, 255, 255, .1); }
.top .btn { background: var(--brass); color: var(--ink); border-color: var(--brass); }

.tabbar { display: none; }
@media (max-width: 760px) {
    .has-tabbar .links, .scan-top { display: none !important; }
    .top.has-tabbar { justify-content: center; padding: 8px; }
    .top:not(.has-tabbar) { gap: 8px; }
    .top:not(.has-tabbar) .brand { font-size: 0; gap: 0; }
    .tabbar { display: flex; position: fixed; bottom: calc(10px + env(safe-area-inset-bottom)); left: 10px; right: 10px; z-index: 10;
        background: var(--glass); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        border-radius: 26px; padding: 8px 4px; box-shadow: 0 10px 30px rgba(23, 20, 15, .25); }
    .tabbar a { flex: 1; text-align: center; color: #fff; text-decoration: none; font-size: 11px; display: flex; flex-direction: column; align-items: center; opacity: .8; }
    .tabbar span { font-size: 20px; line-height: 1.3; }
    .tabbar .scan { opacity: 1; }
    .tabbar .scan span { background: var(--brass); color: var(--ink); width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
        margin-top: -30px; font-size: 26px; border: 4px solid var(--bg); box-shadow: 0 6px 16px rgba(201, 162, 75, .5); }
    h1 { font-size: 2rem; }
}

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 10px 18px; border-radius: 999px; border: 1px solid var(--ink); background: var(--ink); color: #fff;
    font: 500 14px var(--sans); text-decoration: none; cursor: pointer; white-space: nowrap; transition: transform .12s, box-shadow .12s; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(23, 20, 15, .15); }
.btn.ghost { background: var(--paper); color: var(--ink); border-color: var(--line); }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red); }
.btn.small { padding: 5px 12px; font-size: 13px; }
input, select, textarea { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); font: 15px var(--sans); color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brass); outline-offset: 1px; border-color: var(--brass); }
label { display: block; font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 5px; }
.form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px 18px; }
.form .full { grid-column: 1 / -1; }
fieldset { min-width: 0; border: 0; border-radius: var(--radius); padding: 22px; margin: 0 0 18px; background: var(--paper); box-shadow: var(--shadow); }
legend { font: 600 1.3rem var(--serif); padding: 0; float: left; width: 100%; margin-bottom: 14px; }
legend + * { clear: both; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.error { color: var(--red); }
.muted { color: var(--muted); }
.inline { display: inline; }
details summary { cursor: pointer; }

/* cards & stats */
.card { background: var(--paper); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 8px; }
.stat { background: var(--paper); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.stat:first-child { background: var(--ink); color: #fff; }
.stat:first-child small { color: var(--brass); }
.stat small { color: var(--muted); font-size: 12px; font-weight: 500; }
.stat b { display: block; font: 700 2.1rem var(--serif); letter-spacing: -.03em; margin-top: 4px; }
.up { color: var(--green); }
.down { color: var(--red); }

table { width: 100%; border-collapse: collapse; background: var(--paper); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; border-radius: var(--radius); }
.bar { height: 8px; background: var(--brass); border-radius: 4px; min-width: 2px; }

/* gallery */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr auto; gap: 10px; margin-bottom: 22px; }
@media (max-width: 760px) { .filters { grid-template-columns: 1fr 1fr; } .filters input[type=search] { grid-column: 1 / -1; } }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
@media (max-width: 500px) { .grid { grid-template-columns: 1fr 1fr; gap: 10px; } }
.tile { position: relative; border-radius: var(--radius); overflow: hidden; text-decoration: none; color: #fff; display: block; box-shadow: var(--shadow); transition: transform .2s, box-shadow .2s; }
.tile:hover { transform: translateY(-3px); box-shadow: 0 14px 34px rgba(23, 20, 15, .18); }
.tile .ph { aspect-ratio: 4/5; background: linear-gradient(135deg, var(--brass-soft), #e9dfcb); display: grid; place-items: center; font-size: 42px; color: var(--brass); }
.tile .ph img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.tile:hover img { transform: scale(1.04); }
.tile .meta { position: absolute; left: 0; right: 0; bottom: 0; padding: 48px 14px 12px; background: linear-gradient(transparent, rgba(23, 20, 15, .85)); }
.tile .meta b { font: 600 1.1rem var(--serif); display: block; line-height: 1.2; }
.tile .meta small { color: rgba(255, 255, 255, .75); }
.badge { position: absolute; top: 10px; left: 10px; background: var(--red); color: #fff; font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 20px; }

/* item details */
.detail { display: grid; grid-template-columns: 1.2fr 1fr; gap: 28px; }
@media (max-width: 860px) { .detail { grid-template-columns: 1fr; } }
.hero { border-radius: var(--radius); overflow: hidden; background: var(--brass-soft); aspect-ratio: 4/3; display: grid; place-items: center; box-shadow: var(--shadow); }
.hero img { width: 100%; height: 100%; object-fit: contain; background: var(--ink); }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; margin-top: 10px; }
.thumb { position: relative; border-radius: 12px; overflow: hidden; border: 2px solid transparent; aspect-ratio: 1; }
.thumb.main { border-color: var(--brass); }
.thumb img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; }
.thumb .acts { position: absolute; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-between; background: rgba(23, 20, 15, .7); }
.thumb .acts button { background: none; border: 0; color: #fff; cursor: pointer; padding: 3px 7px; font-size: 14px; }
dl.props { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.props dt { color: var(--muted); font-size: 13px; padding-top: 1px; }
dl.props dd { margin: 0; }
.log { list-style: none; padding: 0; margin: 0; }
.log li { padding: 10px 0; border-bottom: 1px solid var(--line); }
.log time { color: var(--muted); font-size: 12px; display: block; }
.log .auto { color: var(--muted); font-style: italic; }

/* photo drop zone */
.drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 20px; text-align: center; background: var(--paper); margin-top: 12px; transition: .15s; }
.drop.over { border-color: var(--brass); background: var(--brass-soft); }
.drop .row { justify-content: center; }
.drop input[type=file] { display: none; }
.progress { margin-top: 8px; font-size: 13px; color: var(--muted); }

/* scanner */
#reader { max-width: 460px; margin: 0 auto; border-radius: var(--radius); overflow: hidden; background: var(--ink); box-shadow: var(--shadow); }
#reader video { width: 100% !important; }

/* tree */
.tree { list-style: none; margin: 0; }
.tree li { padding: 8px 0; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tree li:last-child { border-bottom: 0; }
.tree .name { flex: 1; min-width: 140px; }
.tree .count { color: var(--muted); font-size: 13px; }

/* login */
.login { max-width: 440px; margin: 10vh auto 0; text-align: center; padding: 36px; }
.login img { width: 64px; margin: 0 auto 14px; }
.login form { text-align: left; display: grid; gap: 14px; margin-top: 22px; }
.login .btn { justify-content: center; }

/* print sheet */
.sheet { display: flex; flex-wrap: wrap; gap: 4mm; }
.sheet div { text-align: center; font: 9px monospace; break-inside: avoid; background: #fff; padding: 1mm; }
.sheet b { font: 600 9px var(--sans); }
.sheet-s div { width: 25mm; } .sheet-m div { width: 35mm; } .sheet-l div { width: 50mm; }
/* Dymo labels: on screen a preview strip, in print exactly one label per page (size set by @page on the page) */
.labels { display: flex; flex-wrap: wrap; gap: 4mm; }
.label { background: #fff; color: #000; display: flex; align-items: center; box-sizing: border-box; overflow: hidden;
    outline: 1px dashed var(--line); break-after: page; page-break-after: always; font: 600 2.2mm/1.1 ui-monospace, monospace; }
.label img { display: block; }
.labels-dymo13 .label { width: 25mm; height: 13mm; padding: 1mm 1.2mm; gap: 1.2mm; }
.labels-dymo13 .label img { width: 11mm; height: 11mm; flex: none; }
.labels-dymo13 .label span { font-size: 2mm; word-break: break-all; }
.labels-dymo25 .label { width: 25mm; height: 25mm; padding: 1.2mm; flex-direction: column; justify-content: center; gap: .6mm; text-align: center; }
.labels-dymo25 .label img { width: 19mm; height: 19mm; }
.labels-dymo25 .label span { font-size: 2.2mm; }
@media print {
    .labels { display: block; }
    .label { outline: none; }
    .label:last-child { break-after: auto; page-break-after: auto; }
    .top, .tabbar, .noprint { display: none !important; }
    body { background: #fff; }
    .wrap { padding: 0; max-width: none; }
}

.chart { width: 100%; height: 110px; overflow: visible; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; color: var(--ink); margin-top: 26px; }
label.check input { width: auto; }
.badge.sale { background: var(--green); }

/* public sale page */
.public-head { display: flex; align-items: center; gap: 14px; margin-bottom: 28px; }
.public-head img { width: 48px; }
.public-head small { display: block; color: var(--muted); font-size: 12px; }
.public-head b { font: 700 1.6rem var(--serif); letter-spacing: -.02em; }
.price { font: 700 2rem var(--serif); color: var(--green); margin: -6px 0 16px; }

/* inventory */
.inventory img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.print-only { display: none; }
@media print {
    .print-only { display: block; }
    table { box-shadow: none; font-size: 12px; }
    tr { break-inside: avoid; }
}

/* read-only accounts: hide anything that changes data */
.ro form[method=post]:not(.keep), .ro .edit, .ro .drop, .ro .thumb .acts { display: none !important; }
.notice { border-left: 4px solid var(--brass); margin: 18px 0; display: grid; gap: 6px; }

/* photo carousel */
.carousel { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--ink); box-shadow: var(--shadow); outline-offset: 3px; }
.carousel .slides { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; aspect-ratio: 4/3; }
.carousel .slides::-webkit-scrollbar { display: none; }
.carousel .slides img { flex: 0 0 100%; width: 100%; height: 100%; object-fit: contain; scroll-snap-align: center; }
.carousel .nav { position: absolute; top: 50%; translate: 0 -50%; width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer;
    background: rgba(255, 255, 255, .85); color: var(--ink); font-size: 26px; line-height: 1; box-shadow: var(--shadow); }
.carousel .prev { left: 10px; } .carousel .next { right: 10px; }
.carousel .counter { position: absolute; bottom: 10px; right: 12px; background: rgba(23, 20, 15, .7); color: #fff; font-size: 12px; padding: 2px 10px; border-radius: 20px; }
@media (hover: none) { .carousel .nav { display: none; } }
.thumb.current { outline: 2px solid var(--ink); outline-offset: 2px; }
.thumb img { cursor: pointer; }
.carousel .slides img { cursor: zoom-in; }
.carousel .close { display: none; position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; border-radius: 50%; border: 0;
    background: rgba(255, 255, 255, .15); color: #fff; font-size: 20px; cursor: pointer; }
.carousel.big { position: fixed; inset: 0; z-index: 100; border-radius: 0; background: rgba(10, 8, 6, .96); }
.carousel.big .slides { aspect-ratio: auto; height: 100dvh; }
.carousel.big .slides img { cursor: default; }
.carousel.big .close { display: block; }
.carousel.big .nav { display: block; background: rgba(255, 255, 255, .15); color: #fff; }
.carousel.big .counter { bottom: calc(16px + env(safe-area-inset-bottom)); right: 50%; translate: 50% 0; }
.row > input { min-width: 0; }
@media (min-width: 761px) { .mobile-only { display: none !important; } }
.card.editing { outline: 2px solid var(--brass); }
tr.selected td { background: var(--brass-soft); }
#form { scroll-margin-top: 90px; }
.login .logo { margin: 0 0 14px; }
.login .logo img { width: 100%; height: auto; margin: 0; }
.brand img { border-radius: 8px; }
