/* =====================================================================
   Asset Register — assets.haresh.net
   ===================================================================== */
:root {
  --bg: #f4f3f0;
  --surface: #ffffff;
  --surface-2: #f8f7f4;
  --border: #e2dfd8;
  --text: #1f2328;
  --muted: #6b6f76;
  --accent: #d9861c;          /* safety amber */
  --accent-strong: #b86e0f;
  --accent-soft: #fdf1df;
  --ok: #2f7d4f;  --ok-soft: #e4f3ea;
  --err: #b3362c; --err-soft: #fbe7e5;
  --info: #2f5f9e; --info-soft: #e5eef9;
  --sb-bg: #20242a;
  --sb-text: #c9ccd1;
  --sb-hover: #2c3138;
  --sb-w: 232px;
  --sb-w-collapsed: 64px;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 1px 3px rgba(0,0,0,.04);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --surface: #1d2024; --surface-2: #23272c; --border: #30353b;
    --text: #e7e8ea; --muted: #9aa0a8;
    --accent: #e9a03f; --accent-strong: #f2b45c; --accent-soft: #3a2c17;
    --ok: #6cc28f; --ok-soft: #1c3326; --err: #ef7d73; --err-soft: #3d1f1c; --info: #86b2ea; --info-soft: #1c2b40;
    --sb-bg: #101215; --sb-hover: #1e2227;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); }
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.req { color: var(--err); font-weight: 600; }
.intro { margin: 0 0 16px; max-width: 70ch; }

/* ---- App shell -------------------------------------------------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sb-w); z-index: 30;
  background: var(--sb-bg); color: var(--sb-text);
  display: flex; flex-direction: column; transition: width .18s ease, transform .2s ease;
}
.main { flex: 1; min-width: 0; margin-left: var(--sb-w); transition: margin-left .18s ease; }

.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; color: #fff; font-weight: 650; font-size: 15px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; flex: 1; overflow-y: auto; }
.nav-link {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px;
  color: var(--sb-text); white-space: nowrap; font-size: 14.5px;
}
.nav-link:hover { background: var(--sb-hover); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--sb-hover); color: #fff; box-shadow: inset 3px 0 0 var(--accent); }
.nav-link.disabled { opacity: .45; cursor: default; }
.nav-link.disabled:hover { background: none; color: var(--sb-text); }
.nav-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.soon { font-style: normal; font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; border: 1px solid currentColor; border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.as-button { width: 100%; background: none; border: 0; cursor: pointer; font: inherit; text-align: left; }
.sidebar-foot { padding: 10px; border-top: 1px solid rgba(255,255,255,.08); }
.who { font-size: 12.5px; padding: 4px 10px 8px; color: #9aa0a8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who strong { color: #e6e7e9; font-weight: 600; }
.collapse-btn {
  margin-top: 6px; width: 100%; display: flex; justify-content: flex-end; padding: 6px 10px;
  background: none; border: 0; color: #8b9098; cursor: pointer; border-radius: 8px;
}
.collapse-btn:hover { background: var(--sb-hover); color: #fff; }
.collapse-btn svg { transition: transform .18s ease; }

/* Collapsed (desktop) */
body.sb-collapsed .sidebar { width: var(--sb-w-collapsed); }
body.sb-collapsed .main { margin-left: var(--sb-w-collapsed); }
body.sb-collapsed .nav-text { display: none; }
body.sb-collapsed .brand { padding: 16px 18px; }
body.sb-collapsed .nav-link { justify-content: center; }
body.sb-collapsed .collapse-btn { justify-content: center; }
body.sb-collapsed .collapse-btn svg { transform: rotate(180deg); }

.topbar {
  position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.page-title { font-size: 20px; font-weight: 650; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-actions { display: flex; gap: 8px; }
.sb-toggle { display: none; }
.icon-btn { background: none; border: 0; color: var(--text); padding: 6px; border-radius: 8px; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); }
.content { padding: 24px 28px 48px; max-width: 1280px; }
.sb-overlay { display: none; }

/* Mobile: slide-in sidebar */
@media (max-width: 860px) {
  .sidebar { transform: translateX(-100%); width: var(--sb-w) !important; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  body.sb-open .sidebar { transform: none; }
  body.sb-collapsed .nav-text { display: inline; }
  body.sb-collapsed .nav-link { justify-content: flex-start; }
  .main, body.sb-collapsed .main { margin-left: 0; }
  .sb-toggle { display: inline-flex; }
  .collapse-btn { display: none; }
  body.sb-open .sb-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 25; }
  .topbar { padding: 10px 16px; }
  .page-title { font-size: 18px; }
  .content { padding: 16px 16px 40px; }
}

/* ---- Cards, tiles, grids ---------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-flush { padding: 0; overflow-x: auto; }
.card-title { font-size: 15.5px; font-weight: 650; margin-bottom: 8px; }
.card p:last-child { margin-bottom: 0; }
.card-muted { background: var(--surface-2); box-shadow: none; border-style: dashed; }
.card-link { display: block; color: inherit; transition: border-color .12s, transform .12s; }
.card-link:hover { border-color: var(--accent); text-decoration: none; }
.card-link-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.count { font-size: 13px; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 9px; }
.narrow { max-width: 460px; }

.tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.tile-label { font-size: 12.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.tile-value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; text-align: left; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + .card { margin-top: 16px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.settings-grid > .card { margin-bottom: 0; }
.setup-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.setup-list a { border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--text); background: var(--surface-2); }
.setup-list a:hover { border-color: var(--accent); text-decoration: none; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.split > .card { margin-bottom: 0; }
#form { position: sticky; top: 76px; }

@media (max-width: 1100px) { .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1340px) {
  .split { grid-template-columns: 1fr; }
  #form { position: static; }
}
@media (max-width: 640px) {
  .grid-2 { grid-template-columns: 1fr; }
  .tile-value { font-size: 22px; }
}

/* ---- Tables ------------------------------------------------------------ */
.table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); padding: 10px 14px; border-bottom: 1px solid var(--border); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--surface-2); }
.table tr.inactive td { color: var(--muted); }
.table tr.editing { background: var(--accent-soft) !important; }
.table th.num { text-align: right; }
.actions-col { width: 1%; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions > * { margin-left: 2px; }
.table td a[href^="tel:"] { white-space: nowrap; }
.table .btn-sm { padding: 6px 8px; }
form.inline { display: inline; }

/* Stack table rows as cards on phones */
@media (max-width: 640px) {
  .table.responsive thead { display: none; }
  .table.responsive tr { display: block; padding: 10px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .table.responsive td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 13px; text-align: left; }
  .table.responsive td.row-actions { justify-content: flex-end; padding-top: 8px; flex-wrap: wrap; }
}

/* ---- Forms ------------------------------------------------------------- */
.stack { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > span { font-size: 13.5px; font-weight: 600; }
.field small { font-size: 12.5px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=email], input[type=date], select, textarea {
  width: 100%; font: inherit; font-size: 16px; /* 16px stops iOS zoom */
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--accent) 45%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea { resize: vertical; }
.check { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 4px; }

/* ---- Buttons ----------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 600; line-height: 1; cursor: pointer;
  padding: 10px 16px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); white-space: nowrap;
}
.btn:hover { border-color: var(--muted); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #1b1305; }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-danger-ghost { background: transparent; border-color: transparent; color: var(--err); }
.btn-danger-ghost:hover { background: var(--err-soft); border-color: var(--err-soft); }
.btn-sm { padding: 6px 10px; font-size: 13px; }
.btn-block { width: 100%; padding: 12px 16px; }

/* ---- Badges & flashes -------------------------------------------------- */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.flash { position: relative; padding: 11px 38px 11px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14.5px; border: 1px solid transparent; }
.flash-success { background: var(--ok-soft); color: var(--ok); }
.flash-error { background: var(--err-soft); color: var(--err); }
.flash-info { background: var(--info-soft); color: var(--info); }
.flash-x { position: absolute; right: 8px; top: 6px; background: none; border: 0; font-size: 20px; line-height: 1; color: inherit; cursor: pointer; opacity: .6; }
.flash-x:hover { opacity: 1; }

/* ---- Login ------------------------------------------------------------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at top, color-mix(in srgb, var(--accent) 14%, var(--bg)), var(--bg) 60%); }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 28px; box-shadow: 0 10px 30px rgba(0,0,0,.08); }
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.login-title { font-size: 19px; font-weight: 700; }
.login-card .flash { padding-right: 14px; }


/* =====================================================================
   Phase 2 — assets & locations
   ===================================================================== */
.badge-warn { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.badge-sold { background: var(--info-soft); color: var(--info); border-color: transparent; }
.badge-info { background: var(--info-soft); color: var(--info); border-color: transparent; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13.5px; }
.copyable { cursor: copy; border-bottom: 1px dashed var(--border); }
.copyable.copied::after { content: ' copied'; color: var(--ok); font-family: var(--font); font-size: 12px; }
.pos { color: var(--ok); } .neg { color: var(--err); }
.section-title { font-size: 17px; font-weight: 650; margin-bottom: 4px; }
.tile-link { color: inherit; } .tile-link:hover { border-color: var(--accent); text-decoration: none; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: 0; }

/* Filters & list */
.filters { display: flex; flex-direction: column; gap: 10px; padding: 14px 16px; }
.filter-search { position: relative; }
.filter-search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-search input { padding-left: 38px; width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding-top: 9px; padding-bottom: 9px; }
.filter-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row select { width: auto; max-width: 100%; font-size: 14px; padding: 7px 9px; }
.list-summary { display: flex; gap: 8px; align-items: baseline; margin: 0 2px 10px; font-size: 14px; }
.items-table tr.clickable { cursor: pointer; }
.item-link { font-weight: 600; color: var(--text); }
.items-table tr.inactive .item-link { color: var(--muted); }
.dot-svc { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--info); vertical-align: middle; margin-left: 4px; }
.empty { text-align: center; padding: 36px 20px; }
.pager { display: flex; justify-content: center; align-items: center; gap: 12px; margin-top: 14px; }
@media (max-width: 640px) {
  .filter-row select { flex: 1 1 calc(50% - 8px); }
  .items-table td.item-cell { display: block; text-align: left; padding-bottom: 6px; }
  .items-table td.item-cell .item-link { font-size: 16px; }
}

/* Item form */
.item-form { max-width: 920px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.label-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 13.5px; font-weight: 600; }
.link-btn { background: none; border: 0; padding: 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--accent-strong); cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.money-input { position: relative; display: block; }
.money-input i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-style: normal; color: var(--muted); }
.money-input input { padding-left: 24px; text-align: right; font-variant-numeric: tabular-nums; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 2px; }
.chip { font: inherit; font-size: 12.5px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.check-lg { font-size: 15px; margin-bottom: 12px; }
.check-lg small { font-weight: 400; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 9px; padding: 3px; background: var(--surface-2); margin-bottom: 4px; }
.segmented label { cursor: pointer; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented span { display: block; padding: 7px 22px; border-radius: 7px; font-weight: 600; font-size: 14px; color: var(--muted); }
.segmented input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow), 0 0 0 1px var(--border); }
.segmented input:focus-visible + span { outline: 2px solid var(--accent); }
.sale-fields { margin-top: 14px; }
.quick-add { margin-top: 6px; padding: 10px; border: 1px dashed var(--accent); border-radius: 8px; background: var(--accent-soft); }
.qa-row { display: flex; gap: 6px; }
.qa-row input { flex: 1; min-width: 0; padding: 6px 9px; }
.quick-add .check { margin-top: 8px; font-weight: 400; }
.qa-err { color: var(--err); margin-top: 6px; }
.inline-warn { color: var(--err); margin: 8px 0 0; }
.save-bar { position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; padding: 12px 0; background: linear-gradient(transparent, var(--bg) 30%); pointer-events: none; }
.save-bar > * { pointer-events: auto; }
.danger-zone { max-width: 920px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  .save-bar .btn-primary { flex: 1; }
}

/* Item detail */
.item-hero { display: grid; grid-template-columns: 120px 1fr auto; gap: 20px; align-items: start; }
.item-photo { width: 120px; height: 120px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; overflow: hidden; }
.item-photo svg { width: 48px; height: 48px; fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-linejoin: round; opacity: .6; }
.item-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.item-name { font-size: 22px; font-weight: 700; }
.item-loc { display: flex; align-items: center; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.item-loc .nav-ico { width: 17px; height: 17px; color: var(--accent); }
.item-cost { min-width: 220px; border-left: 1px solid var(--border); padding-left: 20px; }
.cost-row { display: flex; justify-content: space-between; gap: 16px; padding: 3px 0; font-size: 14px; }
.cost-row span { color: var(--muted); }
.cost-row.total { border-top: 1px solid var(--border); margin-top: 4px; padding-top: 7px; font-size: 15px; }
.cost-row.total span { color: var(--text); font-weight: 600; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.detail-grid > .card { margin-bottom: 0; }
.detail-grid .span-all { grid-column: 1 / -1; }
.dl { margin: 0; }
.dl-row { display: grid; grid-template-columns: 120px 1fr; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.dl-row:last-child { border-bottom: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.prose { white-space: normal; max-width: 75ch; }
.meta { margin-top: 18px; }
@media (max-width: 860px) {
  .item-hero { grid-template-columns: 80px 1fr; }
  .item-photo { width: 80px; height: 80px; }
  .item-cost { grid-column: 1 / -1; border-left: 0; padding-left: 0; border-top: 1px solid var(--border); padding-top: 12px; }
  .item-name { font-size: 19px; }
}
@media (max-width: 640px) { .detail-grid { grid-template-columns: 1fr; } }

/* Locations */
.loc-layout { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 16px; align-items: start; }
.loc-tree-card { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow-y: auto; padding: 14px 12px; }
.loc-tree-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 6px; }
.loc-tree-head .card-title { margin: 0; }
.tree { list-style: none; margin: 0; padding: 0; }
.tree .tree { padding-left: 16px; border-left: 1px solid var(--border); margin-left: 12px; }
.tree-node { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 7px; color: var(--text); font-size: 14.5px; }
.tree-node:hover { background: var(--surface-2); text-decoration: none; }
.tree-node.active { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.tree-node.unassigned { margin-top: 8px; border-top: 1px solid var(--border); border-radius: 0 0 7px 7px; padding-top: 10px; color: var(--muted); font-style: italic; }
.tree-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-hint { margin: 10px 4px 0; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; align-items: baseline; font-size: 18px; font-weight: 650; margin-bottom: 4px; }
.crumbs a { color: var(--text); }
.crumbs a[aria-current] { color: var(--accent-strong); }
.loc-main > p { margin-top: 0; }
.move-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.move-to { display: flex; gap: 6px; }
.move-to select { width: auto; font-size: 14px; padding: 6px 8px; max-width: 240px; }
.loc-items { list-style: none; margin: 0; padding: 0; }
.loc-items li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.loc-items li:last-child { border-bottom: 0; }
.loc-items .check { padding-top: 2px; }
.loc-items a { color: var(--text); }
.pad { padding: 14px; margin: 0; }
.loc-forms { margin-top: 16px; }
.delete-loc { display: flex; gap: 8px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
@media (max-width: 860px) {
  .loc-layout { grid-template-columns: 1fr; }
  .loc-tree-card { position: static; max-height: none; }
  .move-to { width: 100%; }
  .move-to select { flex: 1; max-width: none; }
}


/* =====================================================================
   Phase 3 — files, photos, uploads
   ===================================================================== */
.thumb { width: 44px; height: 44px; border-radius: 7px; object-fit: cover; flex: none; background: var(--surface-2); border: 1px solid var(--border); }
.thumb-empty { display: inline-block; background: repeating-linear-gradient(135deg, var(--surface-2) 0 6px, var(--bg) 6px 12px); }
.item-cell-inner { display: flex; gap: 12px; align-items: center; }
.loc-items .thumb { width: 40px; height: 40px; }

.item-photo { color: var(--muted); text-decoration: none; }
.item-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.item-photo.placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.item-photo.placeholder:hover { border-color: var(--accent); color: var(--accent-strong); text-decoration: none; }
a.item-photo:not(.placeholder):hover { opacity: .92; }

.files-card { scroll-margin-top: 80px; }
.files-head { display: flex; justify-content: space-between; align-items: baseline; }
.files-sub { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 20px 0 10px; font-weight: 600; }
.files-empty { margin: 14px 0 0; }

.uploader { margin-top: 6px; }
.seg-sm span { padding: 6px 14px; font-size: 13px; }
.seg-sm { flex-wrap: wrap; }
.dropzone { margin-top: 10px; border: 2px dashed var(--border); border-radius: 10px; padding: 18px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; background: var(--surface-2); transition: border-color .12s, background .12s; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone > svg { width: 28px; height: 28px; color: var(--muted); }
.dz-buttons { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.dz-buttons label { cursor: pointer; }
.camera-btn { display: none; }
@media (pointer: coarse), (max-width: 860px) { .camera-btn { display: inline-flex; } }
.upload-progress { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.upload-progress li { display: grid; grid-template-columns: minmax(0, 1fr) 140px; gap: 2px 12px; align-items: center; font-size: 13.5px; }
.up-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-bar { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; }
.up-bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.up-msg { grid-column: 1 / -1; color: var(--muted); }
.upload-progress li.done .up-bar i { background: var(--ok); }
.upload-progress li.done .up-msg { color: var(--ok); }
.upload-progress li.failed .up-bar i { background: var(--err); width: 100% !important; }
.upload-progress li.failed .up-msg { color: var(--err); }
.upload-progress li.up-reload { display: block; }

.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; }
.g-item { position: relative; margin: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.g-item.is-primary { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.g-item > a { display: block; aspect-ratio: 4 / 3; background: var(--surface-2); }
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-noimg { display: flex !important; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--muted); }
.primary-tag { position: absolute; top: 8px; left: 8px; background: var(--accent); color: #1b1305; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.g-item figcaption { padding: 6px 8px; display: flex; flex-direction: column; gap: 4px; }
.g-cap { font-size: 13px; min-height: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-cap:empty { display: none; }
.g-actions { display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-start; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.doc-list li:last-child { border-bottom: 0; }
.doc-body { flex: 1; min-width: 180px; }
.doc-body > a { font-weight: 600; overflow-wrap: anywhere; }
.doc-body .badge { margin-right: 4px; }
.doc-actions { display: flex; gap: 2px; align-items: flex-start; flex-wrap: wrap; }
.file-ico { flex: none; width: 40px; height: 48px; border-radius: 6px; display: grid; place-items: center; font-size: 10.5px; font-weight: 700; letter-spacing: .03em; color: #fff; background: #6b7280; }
.file-ico-receipt { background: #2f7d4f; } .file-ico-manual { background: #2f5f9e; } .file-ico-warranty { background: #8a5a12; }
.file-ico-invoice { background: #7a3e8f; } .file-ico-photo { background: #b86e0f; }

.file-edit { position: relative; }
.file-edit summary { list-style: none; }
.file-edit summary::-webkit-details-marker { display: none; }
.file-edit[open] summary { background: var(--surface-2); border-color: var(--border); }
.file-edit-form { position: absolute; z-index: 20; right: 0; top: calc(100% + 4px); width: 240px; padding: 12px; display: flex; flex-direction: column; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.14); }
.gallery .file-edit-form { left: 0; right: auto; }
.file-edit-form input, .file-edit-form select { font-size: 14px; padding: 6px 8px; }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10,10,12,.92); display: flex; align-items: center; justify-content: center; }
.lightbox figure { margin: 0; max-width: 92vw; max-height: 86vh; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.lightbox img { max-width: 92vw; max-height: 80vh; object-fit: contain; border-radius: 4px; background: #222; }
.lightbox figcaption { color: #ddd; font-size: 14px; text-align: center; }
.lb-btn { position: absolute; background: rgba(255,255,255,.1); color: #fff; border: 0; width: 44px; height: 44px; border-radius: 50%; font-size: 28px; line-height: 1; cursor: pointer; }
.lb-btn:hover { background: rgba(255,255,255,.22); }
.lb-close { top: 14px; right: 14px; }
.lb-prev { left: 14px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 14px; top: 50%; transform: translateY(-50%); }
.lb-open { position: absolute; bottom: 14px; color: #bbb; }
body.lb-on { overflow: hidden; }
@media (max-width: 640px) {
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .upload-progress li { grid-template-columns: minmax(0, 1fr) 90px; }
  .items-table td.item-cell .thumb { width: 52px; height: 52px; }
  .lb-prev, .lb-next { top: auto; bottom: 10px; transform: none; }
}
