/* ============================================================
   Vault — mobile-first, warm-light + emerald. Scales up to desktop.
   Shares its palette/type/shape language with css/wizard.css
   (see that file's header comment for the canonical token list) —
   gold is kept only as a secondary "value" highlight (melt
   numbers, spot prices, the brand mark), never for actions.
   ============================================================ */

:root {
  --bg: #f6f5f2;
  --bg-raised: #ffffff;
  --bg-input: #ffffff;
  --bg-sunken: #ece9e2;
  --border: #e7e4de;
  --border-dashed: #cbc7bf;
  --text: #191817;
  --muted: #8a867e;
  --accent: #1f6f54;
  --accent-dark: #14503c;
  --accent-tint: #e9f2ee;
  --gold: #b8892f;
  --gold-dim: #cbb27e;
  --green: #1f6f54;
  --green-tint: #e9f2ee;
  --blue: #2f6fd6;
  --blue-tint: rgba(47,111,214,.1);
  --red: #c9403f;
  --red-tint: rgba(201,64,63,.1);
  --radius: 12px;
  --nav-h: 62px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
body.nav-hidden { padding-bottom: 0; }

.mono { font-family: "Spline Sans Mono", ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .03em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.small { font-size: .8rem; }
.error { color: var(--red); font-size: .9rem; margin-top: .6rem; }

/* ---------- views & header ---------- */
.view { max-width: 900px; margin: 0 auto; padding: 0 14px 24px; }
.view[hidden], [hidden] { display: none !important; }

.demo-banner {
  background: var(--gold); color: #fff; font-weight: 600; font-size: .82rem;
  text-align: center; padding: 8px 14px;
}

.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 2px 10px;
  padding-top: calc(14px + env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 10;
  background: var(--bg);
}
.brand { font-size: 1.3rem; font-weight: 700; letter-spacing: .02em; }
.brand-gem { color: var(--gold); }
.header-title { font-weight: 600; font-size: 1.05rem; }
.spot-ticker { font-size: .78rem; white-space: nowrap; }
.spot-ticker b { color: var(--gold); font-weight: 600; }

/* ---------- buttons & inputs ---------- */
.btn {
  font: inherit; border: none; border-radius: var(--radius);
  padding: 12px 18px; cursor: pointer; color: var(--text);
  background: var(--bg-sunken); min-height: 44px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 8px 20px -10px rgba(20,80,60,.5); }
.btn-primary:disabled { background: var(--accent-tint); color: var(--gold-dim); box-shadow: none; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-back { color: var(--accent); font-weight: 600; padding-left: 4px; }
.btn-sm { padding: 8px 12px; min-height: 38px; font-size: .9rem; }
.btn-lg { padding: 16px; font-size: 1.05rem; }
.btn-block { display: block; width: 100%; }

input, select, textarea {
  font: inherit; color: var(--text);
  background: var(--bg-input); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 12px 14px; width: 100%;
  min-height: 46px; appearance: none; -webkit-appearance: none;
  font-size: 16px; /* prevents iOS zoom-on-focus */
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
}
input[type="checkbox"] {
  width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); padding: 0;
}
input[type="file"] { padding: 10px; font-size: .9rem; }
select {
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238a867e' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- login ---------- */
#view-login { display: flex; min-height: 100vh; align-items: center; justify-content: center; }
.login-box { width: min(340px, 90vw); text-align: center; margin: 0 auto; padding-top: 10vh; word-break: break-word; }
.login-logo { font-size: 3rem; color: var(--gold); }
.login-box h1 { letter-spacing: .05em; margin-bottom: 2px; }
.login-box form { display: flex; flex-direction: column; gap: 10px; margin-top: 24px; }

/* ---------- dashboard ---------- */
.toolbar { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.filter-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filter-row select { min-height: 42px; padding: 8px 28px 8px 12px; font-size: .88rem; }

.piece-list { display: flex; flex-direction: column; gap: 10px; }

.piece-card {
  display: flex; gap: 12px; padding: 10px;
  background: var(--bg-raised); border-radius: var(--radius);
  border: 1px solid var(--border); cursor: pointer;
  box-shadow: 0 1px 2px rgba(25,24,23,.04);
}
.piece-card:active { background: var(--bg-sunken); }
.piece-thumb {
  width: 72px; height: 72px; flex: none; border-radius: 8px;
  background: var(--bg-sunken); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  color: var(--gold-dim); font-size: 1.6rem;
}
.piece-thumb img { width: 100%; height: 100%; object-fit: cover; }
.piece-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.piece-top { display: flex; justify-content: space-between; align-items: center; }
.stock { font-weight: 700; color: var(--accent); }
.piece-mid { font-size: .88rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.piece-prices { display: flex; gap: 12px; font-size: .85rem; }

.status {
  font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: 3px 8px; border-radius: 20px;
}
.status-InStock { background: var(--green-tint); color: var(--green); }
.status-Listed { background: var(--blue-tint); color: var(--blue); }
.status-Sold { background: var(--bg-sunken); color: var(--muted); }

/* ---------- detail ---------- */
.detail-body { display: flex; flex-direction: column; gap: 16px; }
.detail-gallery { display: flex; gap: 8px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.detail-gallery img { height: 190px; border-radius: var(--radius); flex: none; }
.detail-refphoto { display: flex; flex-direction: column; gap: 6px; }
.detail-refphoto img { height: 90px; width: 90px; object-fit: cover; border-radius: var(--radius); }
.detail-prices {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; text-align: center;
}
.detail-prices > div {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 6px;
  display: flex; flex-direction: column; gap: 2px; font-size: 1rem;
  box-shadow: 0 1px 2px rgba(25,24,23,.04);
}
.detail-prices .muted { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.detail-prices .melt { color: var(--gold); }
.detail-specs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; font-size: .95rem;
}
.detail-specs .muted { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; }
.detail-body h3 { font-size: .85rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-top: 4px; }
.stone-row-view {
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; font-size: .92rem;
  box-shadow: 0 1px 2px rgba(25,24,23,.04);
}
.notes { white-space: pre-wrap; font-size: .95rem; }
.detail-tag {
  align-self: center; text-align: center; background: #fff; color: #000;
  padding: 12px 16px 10px; border-radius: 10px; margin-top: 4px;
  border: 1px solid var(--border); box-shadow: 0 10px 24px -12px rgba(25,24,23,.25);
}
.detail-tag .mono { font-weight: 700; margin-top: 4px; }
.detail-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.status-quick-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.status-quick-btn {
  min-height: 46px; border-radius: var(--radius); font: inherit; font-size: .88rem; font-weight: 700;
  cursor: pointer; background: var(--bg-raised); border: 1.5px solid var(--border); color: var(--muted);
}
.status-quick-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.status-quick-btn:disabled { opacity: .6; cursor: default; }

/* ---------- scan ---------- */
.scan-wrap {
  position: relative; border-radius: var(--radius); overflow: hidden;
  background: #000; aspect-ratio: 1; max-height: 55vh; margin-bottom: 12px;
}
#scan-video { width: 100%; height: 100%; object-fit: cover; }
.scan-frame {
  position: absolute; inset: 15%; border: 2px solid rgba(31,111,84,.85);
  border-radius: 14px; pointer-events: none;
}
.scan-manual { display: flex; gap: 8px; margin-top: 14px; }
.scan-manual input { flex: 1; }

/* ---------- batch tags ---------- */
.tags-toolbar { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tags-list { display: flex; flex-direction: column; gap: 6px; }
.tag-pick {
  display: flex; align-items: center; gap: 12px; padding: 12px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); cursor: pointer; min-height: 48px;
  box-shadow: 0 1px 2px rgba(25,24,23,.04);
}
.tag-pick.picked { border-color: var(--accent); }
.tag-pick .mono { font-weight: 700; }
.tag-pick .muted { font-size: .85rem; margin-left: auto; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255,255,255,.9); backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--border);
}
.bottom-nav button {
  flex: 1; font: inherit; font-size: .68rem; letter-spacing: .04em;
  background: none; border: none; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.bottom-nav button.active { color: var(--accent); }
.nav-ico { font-size: 1.25rem; line-height: 1; }
.nav-add .nav-ico {
  background: var(--accent); color: #fff; border-radius: 50%;
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; box-shadow: 0 6px 16px -6px rgba(20,80,60,.6);
}

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 14px);
  background: var(--accent-dark); color: #fff; font-weight: 600;
  padding: 12px 20px; border-radius: 30px; z-index: 50;
  max-width: 88vw; text-align: center; box-shadow: 0 6px 22px rgba(25,24,23,.35);
}
.toast-error { background: var(--red); color: #fff; }

/* ============================================================
   Desktop scale-up
   ============================================================ */
@media (min-width: 760px) {
  body { padding-bottom: 0; }
  .bottom-nav {
    position: sticky; top: 0; left: 0; right: 0; bottom: auto; height: 60px; width: 100%;
    border: none; border-bottom: 1px solid var(--border);
    background: rgba(255,255,255,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    align-items: center; justify-content: flex-end; gap: 6px;
    padding: 0 max(24px, calc((100% - 900px) / 2 + 14px));
    z-index: 30;
  }
  .bottom-nav button { flex: none; flex-direction: row; gap: 7px; font-size: .85rem;
    padding: 8px 14px; border-radius: 10px; }
  .bottom-nav button.active { background: var(--accent-tint); }
  .app-header { padding-top: 14px; top: 60px; }

  .filter-row { grid-template-columns: repeat(4, 1fr); }

  /* card list becomes a denser grid */
  .piece-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .piece-card:hover { border-color: var(--accent); }

  .detail-prices { grid-template-columns: repeat(4, 1fr); }
  .detail-specs { grid-template-columns: repeat(3, 1fr); }
  .scan-wrap { max-width: 480px; margin-left: auto; margin-right: auto; }
}

/* ============================================================
   Print — tags only, at physical size (~1.5in x 1in each)
   ============================================================ */
.print-area { display: none; }

@media print {
  body > *:not(.print-area) { display: none !important; }
  body { background: #fff; padding: 0; }
  .print-area {
    display: flex; flex-wrap: wrap; gap: 0.08in; align-content: flex-start;
  }
  .print-tag {
    width: 1.5in; height: 1in;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    border: 1px dashed #bbb; /* cut guide */
    page-break-inside: avoid; break-inside: avoid;
    background: #fff; color: #000;
  }
  .print-tag-num {
    font-family: "Spline Sans Mono", ui-monospace, Menlo, monospace;
    font-size: 9pt; font-weight: 700; margin-bottom: 2pt; color: #000;
  }
  .print-tag svg { width: 0.62in; height: 0.62in; }
}
