/* Inventārs — design mockup stylesheet (becomes the real app CSS) */
:root {
  --paper: #F2F4F1;
  --surface: #FFFFFF;
  --ink: #1A241E;
  --muted: #64716A;
  --line: #D8E0DA;
  --accent: #176B4E;
  --accent-press: #0E4A34;
  --danger: #B3261E;
  --radius: 10px;
  --mono: ui-monospace, "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --st-jauns: #2563EB;
  --st-noliktava: #64748B;
  --st-lietosana: #16803C;
  --st-remonta: #B45309;
  --st-uznorakstisanu: #C2410C;
  --st-norakstits: #6B7280;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px; line-height: 1.5;
  background: var(--paper); color: var(--ink);
  min-height: 100vh;
  padding-bottom: 76px; /* room for bottom nav */
}
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Header ── */
.top {
  position: sticky; top: 0; z-index: 10;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.top-inner {
  max-width: 480px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.top h1 { font-size: 1.05rem; font-weight: 700; letter-spacing: -0.01em; }
.ver {
  font-family: var(--mono); font-size: 0.68rem; color: var(--muted);
  border: 1px solid var(--line); background: var(--surface);
  padding: 2px 8px; border-radius: 20px; white-space: nowrap;
}

/* ── Layout ── */
main { max-width: 480px; margin: 0 auto; padding: 16px; }
.eyebrow {
  font-size: 0.69rem; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--muted); font-weight: 600; margin: 20px 0 8px;
}
.eyebrow:first-child { margin-top: 0; }
footer.pagefoot {
  max-width: 480px; margin: 24px auto 0; padding: 0 16px;
  font-family: var(--mono); font-size: 0.7rem; color: var(--muted);
  text-align: center;
}

/* ── Inventory plate (signature element) ── */
.tag {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); font-weight: 600; font-size: 0.92rem;
  color: var(--ink); background: var(--surface);
  border: 1.5px solid var(--ink); border-radius: 4px;
  padding: 2px 9px 2px 7px; white-space: nowrap;
}
.tag::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: var(--paper);
  box-shadow: inset 0 0 0 1.5px var(--ink);
  flex: none;
}
.tag-lg { font-size: 1.25rem; padding: 5px 13px 5px 10px; border-width: 2px; }
.tag-lg::before { width: 9px; height: 9px; }

/* ── Status badge ── */
.badge {
  display: inline-block; font-size: 0.74rem; font-weight: 600;
  padding: 2px 10px; border-radius: 20px; white-space: nowrap;
}
.b-jauns          { color: var(--st-jauns);          background: rgba(37,99,235,.12); }
.b-noliktava      { color: var(--st-noliktava);      background: rgba(100,116,139,.14); }
.b-lietosana      { color: var(--st-lietosana);      background: rgba(22,128,60,.12); }
.b-remonta        { color: var(--st-remonta);        background: rgba(180,83,9,.13); }
.b-uznorakstisanu { color: var(--st-uznorakstisanu); background: rgba(194,65,12,.12); }
.b-norakstits     { color: var(--st-norakstits);     background: rgba(107,114,128,.14); }
.b-pending        { color: var(--st-remonta);        background: rgba(180,83,9,.13); }

/* ── Cards ── */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.card h2 { font-size: 1.05rem; font-weight: 700; margin-bottom: 4px; }

/* ── Field rows (item card) ── */
.fields { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 0.9rem; }
.fields dt { color: var(--muted); }
.fields dd { text-align: right; font-weight: 500; }
.fields dd.num { font-family: var(--mono); }

/* ── Buttons ── */
.btn {
  display: block; width: 100%; min-height: 48px;
  font: inherit; font-weight: 600; font-size: 1rem;
  border: none; border-radius: var(--radius); cursor: pointer;
  background: var(--accent); color: #fff;
  padding: 12px 16px; margin-top: 12px;
  transition: transform .1s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn:hover { background: var(--accent-press); }
.btn-outline { background: var(--surface); color: var(--accent); border: 1.5px solid var(--accent); }
.btn-outline:hover { background: rgba(23,107,78,.06); }
.btn-danger { background: var(--surface); color: var(--danger); border: 1.5px solid var(--danger); }
.btn-danger:hover { background: rgba(179,38,30,.06); }
.btn-sm { display: inline-block; width: auto; min-height: 36px; padding: 6px 14px; font-size: 0.85rem; margin-top: 0; }

/* ── Inputs ── */
label.fld { display: block; margin: 12px 0 4px; font-size: 0.85rem; font-weight: 600; }
input[type=text], input[type=email], input[type=search], textarea, select {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; min-height: 48px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); outline: none; }
.code-input {
  font-family: var(--mono); font-size: 1.8rem; letter-spacing: 0.5em;
  text-align: center; padding-left: 0.5em;
}
.hint { font-size: 0.82rem; color: var(--muted); margin-top: 6px; }

/* ── Action rows (item card actions) ── */
.action-row {
  display: flex; align-items: center; gap: 12px; width: 100%;
  min-height: 52px; padding: 10px 4px;
  background: none; border: none; border-bottom: 1px solid var(--line);
  font: inherit; font-weight: 500; color: var(--ink);
  cursor: pointer; text-align: left;
}
.action-row:last-child { border-bottom: none; }
.action-row .ico { flex: none; width: 28px; text-align: center; }
.action-row::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 1.3rem; }

/* ── Lists ── */
.item-row {
  display: block; text-decoration: none; color: inherit;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px;
}
.item-row .row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.item-row .name { font-weight: 600; font-size: 0.95rem; }
.item-row .meta { font-size: 0.82rem; color: var(--muted); }
.item-row .meta .num { font-family: var(--mono); color: var(--ink); }

/* ── Note clamp ── */
.note-clamp { font-size: 0.88rem; margin-top: 6px; }
.note-clamp .more { font-size: 0.82rem; }

/* ── History ── */
.history { list-style: none; }
.history li { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.history li:last-child { border-bottom: none; }
.history .when { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 2px; }
.history .old { text-decoration: line-through; color: var(--muted); }

/* ── Photos ── */
.thumbs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.thumbs figure { margin: 0; }
.thumbs .ph {
  aspect-ratio: 1; border-radius: 6px; border: 1px solid var(--line);
  background: linear-gradient(135deg, #E4E9E5, #CBD5CE);
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 1.4rem;
}
.thumbs figcaption { font-size: 0.68rem; color: var(--muted); text-align: center; margin-top: 2px; font-family: var(--mono); }

/* ── Scanner ── */
.viewport {
  position: relative; border-radius: 12px; overflow: hidden;
  background: #10201A; aspect-ratio: 3/4; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center;
}
.viewport .cam-hint { color: #9DB8AC; font-size: 0.85rem; text-align: center; padding: 16px; }
.reticle {
  position: absolute; inset: 18%;
  border-radius: 12px;
  box-shadow: 0 0 0 999px rgba(16,32,26,.45);
  border: 2px solid rgba(255,255,255,.85);
}
.scan-controls { position: absolute; bottom: 12px; left: 0; right: 0; display: flex; justify-content: center; gap: 10px; }
.scan-controls .btn-sm { background: rgba(255,255,255,.92); color: var(--ink); border: none; }

/* ── Bottom sheet dialog ── */
.sheet-demo { border: 1px dashed var(--line); border-radius: 14px 14px 0 0; background: var(--surface); padding: 8px 16px 16px; margin-top: 12px; }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto 12px; }
.sheet-demo h3 { font-size: 1rem; margin-bottom: 8px; }
.choices { display: grid; gap: 8px; }
.choices .choice {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1.5px solid var(--line); border-radius: var(--radius);
  background: var(--surface); padding: 12px 14px; min-height: 48px;
  font: inherit; cursor: pointer; text-align: left;
}
.choices .choice[aria-pressed=true] { border-color: var(--accent); background: rgba(23,107,78,.05); }

/* ── Tables (admin, handover) ── */
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.check-row:last-child { border-bottom: none; }
.check-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check-row .grow { flex: 1; min-width: 0; }

/* ── Alerts ── */
.alert { border-radius: var(--radius); padding: 12px 14px; font-size: 0.88rem; margin-bottom: 12px; }
.alert-ok    { background: rgba(22,128,60,.1);  color: var(--st-lietosana); }
.alert-warn  { background: rgba(180,83,9,.1);   color: var(--st-remonta); }
.alert-error { background: rgba(179,38,30,.08); color: var(--danger); }

/* ── Bottom navigation ── */
nav.bottom {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 10;
  background: var(--surface); border-top: 1px solid var(--line);
}
nav.bottom .nav-inner {
  max-width: 480px; margin: 0 auto;
  display: grid; grid-template-columns: repeat(4, 1fr);
}
nav.bottom a {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 4px 10px; text-decoration: none;
  color: var(--muted); font-size: 0.68rem; font-weight: 600;
}
nav.bottom a .nico { font-size: 1.25rem; line-height: 1; }
nav.bottom a[aria-current=page] { color: var(--accent); }

/* ── Desktop (≥900px): left nav rail, wider content ── */
@media (min-width: 900px) {
  body { padding-bottom: 16px; padding-left: 200px; }
  nav.bottom {
    top: 0; bottom: 0; right: auto; width: 200px;
    border-top: none; border-right: 1px solid var(--line);
  }
  nav.bottom .nav-inner {
    grid-template-columns: 1fr; align-content: start;
    max-width: none; padding-top: 12px;
  }
  nav.bottom a {
    flex-direction: row; justify-content: flex-start; gap: 12px;
    padding: 12px 20px; font-size: 0.9rem;
  }
  nav.bottom a[aria-current=page] { background: rgba(23,107,78,.07); }
  .top-inner, main, footer.pagefoot { max-width: 760px; }
  .btn { max-width: 320px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ── App-only additions (not in design mockups) ── */
img.ph { object-fit: cover; width: 100%; }
.choices .choice input[type=radio] { position: absolute; opacity: 0; }
.choices .choice:has(input:checked) { border-color: var(--accent); background: rgba(23,107,78,.05); }
.choices .choice { position: relative; }
.sheet {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(26,36,30,.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-body {
  background: var(--surface); width: 100%; max-width: 480px;
  border-radius: 14px 14px 0 0; padding: 8px 16px 24px;
  animation: sheetUp .2s ease-out;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) {
  .sheet { align-items: center; }
  .sheet-body { border-radius: 14px; }
}
.sheet[hidden] { display: none; }

/* ── Inventory table (list page) ── */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.inv-table { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
.inv-table th, .inv-table td { padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: top; }
.inv-table thead th { white-space: nowrap; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.inv-table th[data-sort] { cursor: pointer; user-select: none; }
.inv-table th[data-sort]:hover { color: var(--accent); }
.inv-table th[data-sort].asc::after  { content: " ▲"; color: var(--accent); }
.inv-table th[data-sort].desc::after { content: " ▼"; color: var(--accent); }
.inv-table .filters th { padding: 4px 6px; }
.inv-table .filters input { min-height: 32px; padding: 4px 8px; font-size: 0.8rem; border-radius: 6px; min-width: 90px; }
.inv-table tbody tr { cursor: pointer; }
.inv-table tbody tr:hover { background: rgba(23,107,78,.04); }
.inv-table tbody tr:last-child td { border-bottom: none; }

/* Desktop: the inventory table escapes the 760px column and uses the full width */
@media (min-width: 900px) {
  .table-wrap {
    width: calc(100vw - 264px); /* viewport minus nav rail, paddings, scrollbar */
    margin-left: calc((100% - (100vw - 264px)) / 2);
  }
}
[hidden] { display: none !important; }
