:root {
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #e5e7eb;
  background: #0b1020;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: #0b1020; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  padding: calc(16px + env(safe-area-inset-top)) 18px 16px;
  background: rgba(11,16,32,.94); backdrop-filter: blur(14px); border-bottom: 1px solid #25304a;
}
h1 { margin: 0; font-size: clamp(22px, 4vw, 34px); }
.topbar p { margin: 3px 0 0; color: #94a3b8; }
main { max-width: 1200px; margin: 0 auto; padding: 18px; }
.card { background: #121a2d; border: 1px solid #25304a; border-radius: 18px; box-shadow: 0 8px 30px rgba(0,0,0,.18); }
.toolbar { display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 14px; margin-bottom: 18px; }
input, textarea {
  width: 100%; border: 1px solid #34415f; border-radius: 12px; padding: 13px 14px;
  background: #0e1629; color: #f8fafc; outline: none;
}
input:focus, textarea:focus { border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96,165,250,.14); }
button { border: 0; border-radius: 12px; padding: 12px 16px; font-weight: 700; }
.primary { background: #2563eb; color: white; }
.secondary { background: #24304a; color: #e5e7eb; }
.danger { background: #7f1d1d; color: #fee2e2; }
.iconBtn { background: transparent; color: #cbd5e1; font-size: 22px; padding: 8px; }
.hidden { display: none !important; }
.empty { text-align: center; padding: 50px 24px; color: #cbd5e1; }
.emptyIcon { font-size: 56px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 14px; }
.componentCard { overflow: hidden; display: grid; grid-template-columns: 140px 1fr; min-height: 170px; }
.thumb { width: 100%; height: 100%; min-height: 170px; object-fit: cover; background: #0e1629; }
.componentBody { padding: 14px; min-width: 0; }
.titleRow, .footerRow { display: flex; align-items: center; gap: 10px; }
.titleRow { justify-content: space-between; }
.componentName { margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.qtyBadge, .locationBadge { border-radius: 999px; background: #1e3a5f; padding: 4px 9px; font-size: 12px; white-space: nowrap; }
.locationBadge { background: #24304a; }
.meta, .part { color: #93c5fd; font-size: 13px; margin: 8px 0; }
.part { color: #c4b5fd; }
.description { color: #cbd5e1; font-size: 14px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.footerRow { justify-content: space-between; margin-top: 12px; }
.editBtn { padding: 8px 11px; font-size: 13px; }
dialog { width: min(760px, calc(100vw - 20px)); max-height: calc(100vh - 20px); border: 1px solid #34415f; border-radius: 20px; background: #10182a; color: #f8fafc; padding: 0; }
dialog::backdrop { background: rgba(0,0,0,.72); backdrop-filter: blur(3px); }
.dialogForm { padding: 18px; display: grid; gap: 14px; overflow-y: auto; max-height: calc(100vh - 22px); }
.dialogHeader { display: flex; justify-content: space-between; align-items: flex-start; }
.dialogHeader h2 { margin: 0; }
.muted { color: #94a3b8; margin: 4px 0 0; }
.photoPicker { min-height: 220px; border: 1px dashed #475569; border-radius: 16px; overflow: hidden; display: grid; place-items: center; background: #0e1629; cursor: pointer; }
.photoPicker input { display: none; }
.photoPicker img { width: 100%; max-height: 340px; object-fit: contain; }
#photoPlaceholder { text-align: center; display: grid; gap: 5px; color: #cbd5e1; }
.camera { font-size: 40px; }
.twoCol { display: grid; grid-template-columns: 1fr 160px; gap: 12px; }
label { display: grid; gap: 7px; color: #cbd5e1; font-size: 14px; }
.actions { display: flex; align-items: center; gap: 10px; padding-top: 4px; }
.spacer { flex: 1; }
.aiRow { display: grid; gap: 9px; }
.aiRow button { width: 100%; }
.aiButton { background: linear-gradient(135deg,#4f46e5,#2563eb); color: white; }
.aiButton:disabled { opacity: .65; cursor: wait; }
.aiStatus { min-height: 1.25em; font-size: 13px; }
.aiStatus.ok { color: #86efac; }
.aiStatus.warn { color: #fde68a; }
.aiStatus.error { color: #fca5a5; }
.duplicatePanel { display: flex; gap: 12px; align-items: center; justify-content: space-between; border: 1px solid #7c3aed; background: #1d1733; border-radius: 14px; padding: 12px; }
.duplicatePanel .muted { margin-top: 3px; }
.duplicatePanel button { width: auto; flex: 0 0 auto; }
@media (max-width: 650px) { .duplicatePanel { align-items: stretch; flex-direction: column; } .duplicatePanel button { width: 100%; } }
@media (max-width: 650px) {
  .toolbar { grid-template-columns: 1fr; }
  .componentCard { grid-template-columns: 110px 1fr; }
  .twoCol { grid-template-columns: 1fr; }
  .actions { flex-wrap: wrap; }
}
@media (min-width: 900px) {
  main { padding: 24px; }
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.photoActions { display: flex; flex-wrap: wrap; gap: 10px; }
.photoActions button { flex: 1 1 150px; }
.photoPicker video { width: 100%; max-height: 440px; object-fit: contain; background: #000; }
.cameraStatus { min-height: 1.2em; margin: -6px 0 0; font-size: 13px; }
.visuallyHidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0,0,0,0) !important; white-space: nowrap !important; border: 0 !important; opacity: 0 !important; pointer-events: none !important; }

/* v0.4 inventory / backup controls */
.statsBar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 12px; margin: -6px 0 8px;
}
.statsBar > span {
  display: flex; align-items: baseline; gap: 5px; padding: 7px 10px;
  border-radius: 12px; background: #0e1629; border: 1px solid #25304a;
}
.statsBar strong { font-size: 16px; color: #f8fafc; }
.statsBar small { color: #94a3b8; font-size: 11px; white-space: nowrap; }
.backupActions { margin-left: auto; display: flex; gap: 8px; }
.compactBtn { padding: 8px 10px; font-size: 12px; }
.backupStatus { min-height: 1.1em; margin: 0 4px 12px; font-size: 12px; }
.backupStatus.ok { color: #86efac; }
.backupStatus.error { color: #fca5a5; }
.locationInputRow { display: grid; grid-template-columns: 1fr auto; gap: 7px; }
.miniBtn { padding: 0 11px; min-width: 42px; }
.fieldHint { color: #64748b; font-size: 11px; }

@media (max-width: 650px) {
  .statsBar { gap: 7px; }
  .statsBar > span { flex: 1 1 auto; justify-content: center; }
  .backupActions { width: 100%; margin-left: 0; }
  .backupActions button { flex: 1; }
}

@media (min-width: 720px) {
  .componentCard { grid-template-columns: 128px 1fr; min-height: 158px; }
  .thumb { min-height: 158px; }
  .componentBody { padding: 12px 14px; }
  .description { -webkit-line-clamp: 2; }
}

/* v0.5 cloud sync */
.statusRow { display:flex; align-items:center; gap:10px; flex-wrap:wrap; margin: -8px 2px 10px; }
.cloudBadge { display:inline-flex; align-items:center; border:1px solid #475569; border-radius:999px; padding:5px 10px; color:#cbd5e1; font-size:12px; white-space:nowrap; }
.cloudBadge.cloudReady { border-color:#166534; background:#052e16; color:#bbf7d0; }
#cloudStatus { margin:0; }
#cloudStatus.ok { color:#86efac; }
#cloudStatus.warn { color:#fde68a; }
#cloudStatus.error { color:#fca5a5; }
