/* Stocked – app styles. Stock-room vernacular: spruce shelving, yellow shelf-edge labels. */
@font-face { font-family: 'Bricolage Grotesque'; font-weight: 200 800; font-display: swap; src: url(/fonts/bricolage.woff2) format('woff2'); }
@font-face { font-family: 'Instrument Sans'; font-weight: 400 700; font-display: swap; src: url(/fonts/instrument-sans.woff2) format('woff2'); }

:root {
  --ink: #0f3b3a; --ink-deep: #0a2a29; --label: #f6c945; --label-deep: #d9a90f;
  --paper: #eef2ef; --surface: #fff; --line: #d5ddd8; --line-soft: #e6ebe7;
  --text: #14201f; --muted: #5c6b68; --red: #b93a26; --red-soft: #fbe9e5; --green: #1d7a55; --green-soft: #e2f3ea;
  --display: 'Bricolage Grotesque', system-ui, sans-serif; --body: 'Instrument Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 236px;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
body { font-family: var(--body); background: var(--paper); color: var(--text); font-size: 15px; line-height: 1.5; min-height: 100vh; display: flex; -webkit-font-smoothing: antialiased; }
a { color: var(--ink); }
:focus-visible { outline: 3px solid var(--label-deep); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); font-weight: 650; letter-spacing: -.01em; line-height: 1.15; }
svg.lucide { width: 18px; height: 18px; flex-shrink: 0; }

/* sidebar */
.sidebar { width: var(--sidebar-w); background: var(--ink); color: #fff; position: fixed; inset: 0 auto 0 0; display: flex; flex-direction: column; z-index: 50; transition: transform .2s; }
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 6px; color: #fff; text-decoration: none; font-family: var(--display); font-weight: 700; font-size: 22px; letter-spacing: -.02em; }
.brand img { width: 30px; height: 30px; }
.org { padding: 0 18px 14px 58px; font-size: 12.5px; color: rgba(255,255,255,.6); min-height: 14px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav a, .nav button { display: flex; align-items: center; gap: 11px; padding: 9px 11px; color: rgba(255,255,255,.82); text-decoration: none; font: 600 14.5px var(--body); border-radius: 6px; border: 0; background: none; width: 100%; cursor: pointer; text-align: left; }
.nav a:hover, .nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav a.active { background: var(--label); color: var(--ink-deep); }
.nav .gap { height: 14px; }
.nav .count { margin-left: auto; background: var(--red); color: #fff; font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.nav a.active .count { background: var(--ink-deep); }
.who { border-top: 1px solid rgba(255,255,255,.12); padding: 12px 10px; }
.who p { padding: 0 11px 6px; font-size: 13px; color: rgba(255,255,255,.6); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who b { color: #fff; font-weight: 600; display: block; font-size: 14px; }
.overlay { display: none; position: fixed; inset: 0; background: rgba(10,42,41,.5); z-index: 40; }

/* main */
.main { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 22px 32px 0; flex-wrap: wrap; }
.topbar h1 { font-size: 30px; flex: 1; min-width: 0; }
.menu-btn { display: none; background: none; border: 0; padding: 6px; cursor: pointer; color: var(--ink); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 20px 32px 48px; max-width: 1180px; }
.lede { color: var(--muted); max-width: 68ch; margin-bottom: 18px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; font: 600 14.5px var(--body); border-radius: 6px; border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-deep); }
.btn-label { background: var(--label); border-color: var(--label-deep); color: var(--ink-deep); }
.btn-label:hover { background: #f3bf2c; border-color: var(--ink-deep); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); background: var(--red-soft); }
.btn-sm { padding: 6px 10px; font-size: 13.5px; }
.btn-sm svg.lucide { width: 15px; height: 15px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: default; }
.link-btn { background: none; border: 0; color: var(--ink); font: inherit; text-decoration: underline; cursor: pointer; padding: 0; }

/* cards, alerts */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; margin-bottom: 18px; }
.card h2 { font-size: 18px; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card h2 .more { margin-left: auto; font: 600 13.5px var(--body); }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 6px; margin-bottom: 16px; border: 1px solid; font-weight: 500; }
.alert svg { margin-top: 2px; }
.alert-success { background: var(--green-soft); border-color: #b5dcc7; color: #145a3e; }
.alert-error { background: var(--red-soft); border-color: #f0c4bb; color: #8a2a1b; }
.alert-info { background: #e7eef0; border-color: #c7d6da; color: #244a52; }
.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty h2 { color: var(--text); justify-content: center; font-size: 20px; }
.empty p { max-width: 48ch; margin: 0 auto 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid-2 > .card { margin-bottom: 0; }
.split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 18px; align-items: start; }

/* the shelf label: quantity on yellow with a punched hole */
.tag { display: inline-flex; align-items: baseline; gap: 5px; background: var(--label); color: var(--ink-deep); padding: 3px 10px 3px 20px; border-radius: 4px; font: 650 15px var(--display); position: relative; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tag::before { content: ''; position: absolute; left: 7px; top: 50%; width: 6px; height: 6px; margin-top: -3px; border-radius: 50%; background: var(--surface); box-shadow: inset 0 0 0 1px rgba(10,42,41,.25); }
.tag small { font: 500 12px var(--body); }
.tag.low { background: var(--red); color: #fff; }
.tag.big { font-size: 34px; padding: 6px 18px 6px 32px; }
.tag.big::before { left: 12px; width: 9px; height: 9px; margin-top: -4.5px; }
.tag.big small { font-size: 15px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; padding: 2px 9px; border-radius: 99px; background: var(--paper); border: 1px solid var(--line); white-space: nowrap; }
.chip svg.lucide { width: 14px; height: 14px; }
.chip.warn { background: var(--red-soft); border-color: #f0c4bb; color: #8a2a1b; }
.chip.ok { background: var(--green-soft); border-color: #b5dcc7; color: #145a3e; }
.dot { width: 9px; height: 9px; border-radius: 2px; display: inline-block; flex-shrink: 0; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--ink); }
.stat b { display: block; font: 650 32px/1.1 var(--display); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }
.stat.warn b { color: var(--red); }
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 12px; align-items: center; text-decoration: none; color: inherit; font-weight: 600; }
.bar-row span:first-child { display: flex; align-items: center; gap: 8px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.bar { height: 14px; background: var(--paper); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 3px; }
.bar-row em { font-style: normal; color: var(--muted); font-weight: 500; font-size: 13.5px; font-variant-numeric: tabular-nums; }

/* tables */
.table-wrap { overflow-x: auto; margin: 0 -20px -20px; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; font-weight: 600; color: var(--muted); padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
th:first-child, td:first-child { padding-left: 20px; } th:last-child, td:last-child { padding-right: 20px; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #f7f9f7; }
td.num, th.num { text-align: right; }
.item-cell { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.item-cell a { font-weight: 600; text-decoration: none; }
.item-cell a:hover { text-decoration: underline; }
.item-cell small, .sub { display: block; color: var(--muted); font-size: 13px; }
.thumb { width: 44px; height: 44px; border-radius: 6px; object-fit: cover; background: var(--paper); border: 1px solid var(--line); flex-shrink: 0; display: grid; place-items: center; color: var(--muted); }
.attrs { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13.5px; color: var(--muted); max-width: 380px; }
.attrs b { color: var(--text); font-weight: 600; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.delta-in { color: var(--green); font-weight: 700; } .delta-out { color: var(--red); font-weight: 700; }

/* forms */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.filters .form-control { width: auto; }
.filters input[type=search] { flex: 1; min-width: 180px; }
.check { display: inline-flex; align-items: center; gap: 7px; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--ink); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.form-label small { font-weight: 500; color: var(--muted); }
.form-control { width: 100%; padding: 9px 11px; font: 15px var(--body); border: 1px solid #b9c5bf; border-radius: 6px; background: #fff; color: var(--text); }
.form-control:focus { outline: 3px solid rgba(246,201,69,.6); border-color: var(--ink); }
textarea.form-control { resize: vertical; min-height: 64px; }
.help { font-size: 13px; color: var(--muted); margin-top: 4px; }
.with-unit { display: flex; } .with-unit .form-control { border-radius: 6px 0 0 6px; }
.with-unit span { padding: 9px 11px; border: 1px solid #b9c5bf; border-left: 0; border-radius: 0 6px 6px 0; background: var(--paper); color: var(--muted); font-size: 14px; white-space: nowrap; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.section-rule { grid-column: 1 / -1; border-top: 1px dashed var(--line); padding-top: 14px; margin-top: 4px; font: 650 15px var(--display); display: flex; align-items: center; gap: 8px; }
.ai-filled { background: #fff8dc !important; border-color: var(--label-deep) !important; }

/* photo + AI */
.photo-box { aspect-ratio: 4 / 3; background: var(--ink-deep); border-radius: 8px; overflow: hidden; position: relative; display: grid; place-items: center; color: rgba(255,255,255,.7); text-align: center; }
.photo-box video, .photo-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-box .ph svg { width: 40px; height: 40px; margin-bottom: 8px; }
.photo-box .shutter { position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); width: 60px; height: 60px; border-radius: 50%; border: 4px solid #fff; background: var(--label); cursor: pointer; }
.photo-box.scanning::after { content: ''; position: absolute; left: 0; right: 0; height: 3px; background: var(--label); box-shadow: 0 0 18px 4px rgba(246,201,69,.7); animation: scan 1.4s ease-in-out infinite alternate; }
@keyframes scan { from { top: 4%; } to { top: 96%; } }
.photo-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.photo-actions .btn { flex: 1; }
.ai-status { margin-top: 12px; padding: 11px 13px; border-radius: 6px; background: #fff8dc; border: 1px solid var(--label-deep); font-size: 14px; }
.ai-status.err { background: var(--red-soft); border-color: #f0c4bb; color: #8a2a1b; }
.ai-status b { display: block; }

/* type editor */
.field-row { display: grid; grid-template-columns: 1.3fr .9fr 1.4fr .6fr .8fr auto; gap: 8px; align-items: start; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.field-row .hint { grid-column: 1 / 6; }
.field-row .form-control { padding: 7px 9px; font-size: 14px; }
.field-head { display: grid; grid-template-columns: 1.3fr .9fr 1.4fr .6fr .8fr 34px; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.icon-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.icon-pick label { cursor: pointer; }
.icon-pick input { position: absolute; opacity: 0; }
.icon-pick span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.icon-pick input:checked + span { background: var(--label); border-color: var(--ink); }
.icon-pick input:focus-visible + span { outline: 3px solid var(--label-deep); }
.type-card { display: flex; gap: 14px; align-items: flex-start; }
.type-icon { width: 44px; height: 44px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.type-card h2 { margin-bottom: 4px; }
.fieldchips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.presets { display: flex; flex-wrap: wrap; gap: 8px; }

/* item detail */
.detail-photo { width: 100%; border-radius: 8px; border: 1px solid var(--line); display: block; margin-bottom: 14px; }
dl.meta { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; }
dl.meta dt { color: var(--muted); } dl.meta dd { font-weight: 600; }
.move-form { display: grid; grid-template-columns: auto minmax(90px, 1fr); gap: 8px; margin-top: 14px; }
.move-form [name=note] { grid-column: 1 / -1; }
.move-form .btn { grid-column: 1 / -1; justify-self: start; }
.seg { display: inline-flex; border: 1px solid #b9c5bf; border-radius: 6px; overflow: hidden; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 9px 12px; font-weight: 600; font-size: 14px; background: #fff; }
.seg label + label span { border-left: 1px solid #b9c5bf; }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--label-deep); outline-offset: -3px; }

/* auth */
body.auth { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); }
.auth-side { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side .brand { padding: 0; }
.auth-side h2 { font-size: clamp(30px, 3.4vw, 46px); font-weight: 600; max-width: 14ch; }
.auth-side p { color: rgba(255,255,255,.7); max-width: 40ch; margin-top: 14px; }
.shelf { display: grid; gap: 8px; }
.shelf div { height: 12px; border-radius: 2px; background: rgba(255,255,255,.14); }
.shelf div:nth-child(1) { width: 62%; background: var(--label); } .shelf div:nth-child(2) { width: 38%; } .shelf div:nth-child(3) { width: 80%; }
.auth-main { display: grid; place-items: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 440px; }
.auth-card h1 { font-size: 30px; margin-bottom: 6px; }
.auth-card .lede { margin-bottom: 22px; }
.auth-card .form-group { margin-bottom: 14px; }
.preset-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.preset-pick label { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; background: #fff; cursor: pointer; font-weight: 600; font-size: 14px; }
.preset-pick input { accent-color: var(--ink); width: 16px; height: 16px; }

@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: none; }
  .overlay.show { display: block; }
  .main { margin-left: 0; } .menu-btn { display: block; }
  .topbar { padding: 16px 16px 0; } .topbar h1 { font-size: 24px; } .content { padding: 16px 16px 40px; }
  .stats { grid-template-columns: 1fr 1fr; } .grid-2, .split, .form-grid { grid-template-columns: 1fr; }
  .field-head { display: none; } .field-row { grid-template-columns: 1fr 1fr; } .field-row .hint { grid-column: 1 / -1; }
  .move-form { grid-template-columns: 1fr 1fr; } .move-form .seg, .move-form .btn { grid-column: 1 / -1; } .seg label { flex: 1; text-align: center; }
  body.auth { grid-template-columns: 1fr; } .auth-side { padding: 24px; gap: 20px; } .auth-side h2 { font-size: 26px; } .shelf { display: none; }
  .hide-sm { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
