/* Inventory App - Modern iOS-inspired style */
:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --sidebar: #ffffff;
  --text: #1c1c1e;
  --muted: #8e8e93;
  --accent: #007aff;
  --accent-soft: #e5f1ff;
  --danger: #ff3b30;
  --border: #e5e5ea;
  --hover: #f2f2f7;
  --r: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; font-size: 15px; }
header { background: rgba(255,255,255,.85); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top)); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 20; }
header h1 { margin: 0; font-size: 1.15rem; font-weight: 600; letter-spacing: -0.02em; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 7px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  transition: transform .1s, opacity .1s;
}
button:hover { opacity: .9; }
button:active { transform: scale(0.96); }
button.sec { background: var(--hover); color: var(--text); }
button.danger { background: var(--danger); }
button.sm { padding: 5px 9px; font-size: .8rem; }
.wrap { display: flex; min-height: calc(100vh - 56px); }
.side {
  width: 280px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}
.main { flex: 1; padding: 16px; overflow-y: auto; }
.search {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
  background: var(--card);
  padding: 8px 10px;
  border-radius: var(--r);
  box-shadow: var(--shadow);
  max-width: 560px;
}
.search input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: .95rem;
  outline: none;
  padding: 4px 0;
}
.search button { background: var(--hover); color: var(--text); }
.stats { font-size: .85rem; color: var(--muted); margin-bottom: 12px; }
.stats strong { color: var(--text); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.card, .row {
  background: var(--card);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 12px;
}
.card h3 { margin: 0 0 6px; font-size: 1rem; font-weight: 600; }
.meta { font-size: .8rem; color: var(--muted); margin: 2px 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.row .nm { font-weight: 600; }
.loc {
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 3px 0;
}
.loc:hover, .loc.on { background: var(--accent-soft); }
.loc .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.d0 { border-left: 3px solid #007aff; }
.d1 { border-left: 3px solid #34c759; }
.d2 { border-left: 3px solid #ff9500; }
.d3 { border-left: 3px solid #ff3b30; }
.d4 { border-left: 3px solid #af52de; }
.d5 { border-left: 3px solid #ff2d55; }
.nested { margin-left: 16px; list-style: none; padding: 0; }
ul.tree { list-style: none; padding: 0; margin: 0; }
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal.on { display: flex; }
.mbox {
  background: var(--card);
  border-radius: 16px;
  padding: 20px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0,0,0,.15);
}
.mbox form { flex: 1; overflow-y: auto; }
.mbox .mfoot { position: sticky; bottom: 0; background: var(--card); padding-top: 10px; display: flex; gap: 6px; justify-content: flex-end; }
.mbox h2 { margin: 0 0 14px; font-size: 1.15rem; font-weight: 600; }
.fg { margin-bottom: 12px; }
.fg label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 4px; font-weight: 500; }
.fg input, .fg textarea, .fg select {
  width: 100%;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f9f9f9;
  color: var(--text);
  font-size: .95rem;
}
.fg input[type=checkbox], .fg input[type=radio] { width: auto; padding: 0; }
.fg textarea { min-height: 60px; resize: vertical; }
.fr { display: flex; gap: 10px; }
.fr .fg { flex: 1; }
.photos { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.photos img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; }
.more-btn { display: none; }
.more-menu { display: contents; }
@media (max-width: 700px) {
  .wrap { flex-direction: column; }
  .side { width: 100%; max-height: 220px; overflow: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .search { max-width: 100%; }
  .more-btn { display: inline-block; }
  .more-menu { display: none; position: absolute; right: 8px; top: 50px; background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: 6px; z-index: 100; box-shadow: var(--shadow); }
  .more-menu.on { display: flex; flex-direction: column; gap: 4px; }
}
/* Theme: Light (default) */
body.theme-light { --bg:#f2f2f7; --card:#fff; --sidebar:#fff; --text:#1c1c1e; --muted:#8e8e93; --border:#e5e5ea; --hover:#f2f2f7; --accent-soft:#e5f1ff; }
/* Theme: Dark */
body.theme-dark { --bg:#000; --card:#1c1c1e; --sidebar:#1c1c1e; --text:#f2f2f7; --muted:#8e8e93; --border:#38383a; --hover:#2c2c2e; --accent-soft:#1a3a5c; }
body.theme-dark .fg input, body.theme-dark .fg textarea, body.theme-dark .fg select { background:#2c2c2e; }
body.theme-dark header { background:rgba(28,28,30,.9); }
/* Theme: Neutral */
body.theme-neutral { --bg:#e8e4df; --card:#f7f5f2; --sidebar:#f7f5f2; --text:#2c2a28; --muted:#8a847c; --border:#d9d4ce; --hover:#efece8; --accent-soft:#e0ddd8; }
body.theme-neutral .fg input, body.theme-neutral .fg textarea, body.theme-neutral .fg select { background:#f0ede9; }

/* Button style variants */
body.btn-gray button:not(.sec):not(.danger) { background: #8e8e93; }
body.btn-blue button:not(.sec):not(.danger) { background: #007aff; }
body.btn-dark button:not(.sec):not(.danger) { background: #1c1c1e; }
body.btn-gray button.sec, body.btn-blue button.sec, body.btn-dark button.sec { background: var(--hover); color: var(--text); }
.install-hint { background: var(--accent-soft); padding: 8px 12px; font-size: .8rem; text-align: center; display: none; }
.install-hint button { background: transparent; color: var(--accent); padding: 2px 6px; }
