:root {
  --purple: #38215c;
  --purple-deep: #2a1846;
  --purple-soft: #4b2f78;
  --lav: #c9aed9;
  --lav-bg: #f3edf8;
  --yellow: #f7d346;
  --red: #e6413c;
  --ink: #221733;
  --muted: #7b6f8c;
  --card: #ffffff;
  --ok: #2e9e5b;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--lav-bg);
  color: var(--ink);
  min-height: 100vh;
}
h1, h2, h3, h4, .btn, .chip, .tab, .topbar {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, sans-serif;
}

.hidden { display: none !important; }

/* ---- login ---- */
.login {
  position: fixed; inset: 0; z-index: 100;
  background:
    radial-gradient(120% 70% at 50% -10%, rgba(247, 211, 70, 0.14), transparent 55%),
    linear-gradient(160deg, var(--purple-deep), var(--purple) 60%, var(--purple-soft));
  display: flex; align-items: flex-start; justify-content: center;
  padding: 24px; overflow-y: auto;
}
.login-card {
  text-align: center; color: #fff; width: 100%; max-width: 400px;
  padding: 18px 0 30px;
}
.jar-logo { width: 68px; color: var(--yellow); filter: drop-shadow(0 4px 10px rgba(0,0,0,0.35)); }
.brand-kicker {
  color: var(--lav); font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 2.5px; margin: 12px 0 2px;
}
.login-card h1 {
  font-size: 2.35rem; font-weight: 800; letter-spacing: 0.5px; line-height: 1.15;
}
.brand-sub { color: var(--lav); font-size: 0.9rem; margin: 4px 0 20px; }
.login-mosaic {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px;
  margin-bottom: 14px;
}
.login-mosaic img {
  width: 100%; aspect-ratio: 0.92; object-fit: cover; border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  background: var(--purple-soft);
}
.brand-tagline {
  color: var(--yellow); font-family: "Poppins", sans-serif; font-weight: 800;
  text-transform: uppercase; letter-spacing: 2px; font-size: 0.88rem;
  margin: 4px 0 22px;
}
.login-card input {
  width: 100%; padding: 14px; border-radius: var(--radius); border: none;
  font-size: 1rem; margin-bottom: 12px; text-align: center;
}
.login-card .btn.primary {
  width: 100%; padding: 14px; font-size: 1rem;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}
.brand-foot {
  color: rgba(201, 174, 217, 0.75); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 1.5px; margin-top: 26px;
}
.err { color: var(--yellow); margin-top: 10px; }

/* ---- chrome ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: linear-gradient(135deg, var(--purple-deep), var(--purple) 70%, var(--purple-soft));
  color: #fff;
  display: flex; align-items: center; gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 16px 12px;
  font-weight: 700; font-size: 1.1rem; letter-spacing: 0.3px;
  box-shadow: 0 2px 10px rgba(42, 24, 70, 0.25);
}
.home-btn {
  background: none; border: none; padding: 2px; cursor: pointer;
  display: flex; align-items: center; flex-shrink: 0; border-radius: 8px;
}
.home-btn:active { transform: scale(0.9); }
.jar-mini { width: 22px; color: var(--yellow); flex-shrink: 0; }
#topbar-title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-brand {
  margin-left: auto; color: var(--lav); font-size: 0.68rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1.8px; flex-shrink: 0;
}

main {
  padding: 16px 14px calc(86px + var(--safe-bottom));
  max-width: 720px; margin: 0 auto;
}

.tabs {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  display: flex; background: #fff;
  border-top: 1px solid #e2d9ec;
  padding-bottom: var(--safe-bottom);
}
.tab {
  flex: 1; border: none; background: none; padding: 10px 0 8px;
  font-size: 0.72rem; font-weight: 600; color: var(--muted); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tab-ico { font-size: 1.35rem; }
.tab.active { color: var(--purple); }

/* ---- buttons ---- */
.btn {
  border: none; border-radius: var(--radius); padding: 12px 18px;
  font-size: 0.95rem; font-weight: 700; cursor: pointer;
  background: #e8e0f1; color: var(--purple);
}
.btn.primary { background: var(--yellow); color: var(--purple-deep); }
.btn.danger { background: #fbe3e2; color: var(--red); }
.btn.small { padding: 8px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn { transition: transform 0.1s ease, box-shadow 0.15s ease, filter 0.15s ease; }
.btn:active { transform: scale(0.97); }
@media (hover: hover) {
  .btn:hover { filter: brightness(1.05); }
  .card:hover { box-shadow: 0 4px 14px rgba(42, 24, 70, 0.16); transform: translateY(-1px); }
  .card { transition: box-shadow 0.15s ease, transform 0.15s ease; }
}

.fab {
  position: fixed; right: 18px; bottom: calc(78px + var(--safe-bottom)); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%;
  background: var(--yellow); color: var(--purple-deep);
  font-size: 2rem; font-weight: 700; border: none; cursor: pointer;
  box-shadow: 0 4px 14px rgba(42, 24, 70, 0.35);
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

/* ---- cards & lists ---- */
.card {
  background: var(--card); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(42, 24, 70, 0.08);
  cursor: pointer;
}
.card .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card .row1-chips { display: flex; align-items: center; gap: 5px; flex-shrink: 0; }
.card h3 { font-size: 1.02rem; }
.card .sub { color: var(--muted); font-size: 0.85rem; margin-top: 3px; }
.card-line { display: flex; align-items: center; gap: 8px; margin-top: 8px; flex-wrap: wrap; }
.card.has-cover { display: grid; grid-template-columns: 64px 1fr; gap: 12px; align-items: center; }
.cover { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: var(--lav-bg); }

.chip {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 0.72rem; font-weight: 700; letter-spacing: 0.3px; text-transform: uppercase;
  background: #e8e0f1; color: var(--purple);
}
.chip.inquiry { background: #efe9f7; color: var(--purple-soft); }
.chip.quoted { background: #fdf3cd; color: #8a6d00; }
.chip.deposit { background: #ffe9c7; color: #925c00; }
.chip.progress { background: #dceafd; color: #1d5fae; }
.chip.ready { background: #d9f2e2; color: var(--ok); }
.chip.delivered { background: #e4e4e4; color: #555; }
.chip.sold { background: #1d7a45; color: #fff; }
.chip.money { background: #d9f2e2; color: var(--ok); }
.chip.owe { background: #fbe3e2; color: var(--red); }
.chip.pri-high { background: #fbdada; color: #b4131b; }
.chip.pri-med { background: #fdf0cd; color: #8a6d00; }
.chip.pri-low { background: #e9e9ef; color: #666; }
.chip.src-artjar { background: #e8ddf7; color: #5b2d91; }
.chip.src-b2b { background: #d9e7fb; color: #1d5fae; }
.chip.src-etsy { background: #fde4cf; color: #b45309; }
.chip.src-frameworks { background: #d9f2e2; color: #1d7a45; }
.chip.src-comics { background: #fbdfdf; color: #b91c1c; }
.chip.src-vinyl { background: #fbe0f0; color: #a02c6e; }

.cat-row { display: flex; gap: 10px; margin-bottom: 10px; }
.cat-row .btn { flex: 1; padding: 13px 8px; }
.cat-row .btn.on { background: var(--purple); color: #fff; }
.sold-area { background: #eefaf2; }

.filters { display: flex; gap: 8px; margin-bottom: 14px; overflow-x: auto; }
.filters .btn { white-space: nowrap; }
.filters .btn.on { background: var(--purple); color: #fff; }

.empty { text-align: center; color: var(--muted); padding: 40px 20px; line-height: 1.5; }

/* ---- detail view ---- */
.back { background: none; border: none; color: var(--purple); font-weight: 700; font-size: 0.95rem; cursor: pointer; padding: 0 0 12px; }
.section { background: #fff; border-radius: var(--radius); padding: 14px; margin-bottom: 14px; box-shadow: 0 1px 4px rgba(42,24,70,0.08); }
.section h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); margin-bottom: 10px; display: flex; justify-content: space-between; align-items: center; }
.field { margin-bottom: 10px; }
.field label { display: block; font-size: 0.75rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #ddd2ea; border-radius: 10px;
  font-size: 0.95rem; font-family: inherit; background: #fdfcfe; color: var(--ink);
}
.field textarea { min-height: 70px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.status-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.status-steps .btn { flex: 1 0 30%; }
.status-steps .btn.on { background: var(--purple); color: #fff; }

.seg { display: flex; gap: 6px; }
.seg .btn { flex: 1; }
.seg .btn.on { background: var(--ok); color: #fff; }

/* ---- photos ---- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 10px; cursor: pointer; background: var(--lav-bg); display: block; }
.photo-grid img.is-cover { outline: 3px solid var(--yellow); outline-offset: -3px; }
.ph-tile { min-width: 0; }
.ph-cap { font-size: 0.7rem; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pv-cap {
  width: 100%; max-width: 480px; padding: 10px 14px; border-radius: 10px; border: none;
  font-size: 0.95rem; text-align: center; font-family: inherit;
}
.photo-add {
  aspect-ratio: 1; border: 2px dashed var(--lav); border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem; color: var(--purple-soft); cursor: pointer; background: none;
}

/* ---- links ---- */
.link-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid #f0eaf6; }
.link-item:last-child { border-bottom: none; }
.link-item a { color: var(--purple); font-weight: 600; text-decoration: none; word-break: break-all; flex: 1; }
.link-item a small { display: block; color: var(--muted); font-weight: 400; }
.icon-btn { background: none; border: none; font-size: 1.05rem; cursor: pointer; color: var(--muted); padding: 4px; }

/* ---- sessions ---- */
.session-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid #f0eaf6; font-size: 0.9rem; gap: 8px; }
.check-row { display: flex !important; align-items: center; gap: 8px; font-size: 0.95rem !important; font-weight: 600 !important; color: var(--ink) !important; text-transform: none !important; cursor: pointer; }
.check-row input { width: 18px; height: 18px; accent-color: var(--purple); }
.session-item:last-child { border-bottom: none; }
.pkg { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.pkg .big { font-size: 1.6rem; font-weight: 800; color: var(--purple); }
.pkg .big.low { color: var(--red); }

/* ---- home ---- */
.hello { margin: 4px 2px 16px; }
.hello h2 { font-size: 1.5rem; font-weight: 800; color: var(--purple-deep); }
.hello p { color: var(--muted); font-size: 0.92rem; margin-top: 2px; }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat {
  background: linear-gradient(150deg, var(--purple), var(--purple-soft));
  color: #fff; border-radius: var(--radius); padding: 16px 14px; cursor: pointer;
  box-shadow: 0 3px 10px rgba(42, 24, 70, 0.22);
}
.stat-num { font-family: "Poppins", sans-serif; font-size: 2.1rem; font-weight: 800; line-height: 1; }
.stat-label { font-weight: 700; font-size: 0.85rem; margin-top: 4px; }
.stat-sub { color: var(--lav); font-size: 0.75rem; margin-top: 4px; }
.stat-sub.warn { color: var(--yellow); font-weight: 700; }
.due-banner {
  background: #fdf3cd; color: #8a6d00; font-weight: 700; font-size: 0.88rem;
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 14px; cursor: pointer;
}
.due-banner.bday { background: #fbe4f1; color: #a02c6e; }
.quick-grid { display: grid; grid-template-columns: 1fr; gap: 8px; }
.quick-grid .btn { width: 100%; text-align: center; padding: 13px; }
.home-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 4px; }
.home-strip img {
  width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px;
  box-shadow: 0 2px 8px rgba(42, 24, 70, 0.15);
}
@media (min-width: 480px) { .quick-grid { grid-template-columns: repeat(3, 1fr); } }

/* ---- ideas ---- */
.idea-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.idea { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: 0 1px 4px rgba(42,24,70,0.08); }
.idea img { width: 100%; aspect-ratio: 1; object-fit: cover; cursor: pointer; display: block; }
.idea .pad { padding: 10px; font-size: 0.85rem; }
.idea .pad a { color: var(--purple); font-weight: 700; word-break: break-all; text-decoration: none; }
.idea .note-text { white-space: pre-wrap; }
.idea .meta { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 0.75rem; padding: 0 10px 8px; }
.add-row { display: flex; gap: 8px; margin-bottom: 14px; }
.add-row .btn { flex: 1; }

/* ---- overlay / modals ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 10, 35, 0.65);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: #fff; width: 100%; max-width: 720px;
  border-radius: 18px 18px 0 0; padding: 20px 16px calc(20px + var(--safe-bottom));
  max-height: 88vh; overflow-y: auto;
}
.sheet h3 { margin-bottom: 14px; }
.sheet-actions { display: flex; gap: 10px; margin-top: 14px; }
.sheet-actions .btn { flex: 1; }
.photo-view { align-items: center; padding: 16px; }
.photo-view img { max-width: 100%; max-height: 82vh; border-radius: 12px; }
.photo-view .pv-wrap { display: flex; flex-direction: column; gap: 12px; align-items: center; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + var(--safe-bottom)); z-index: 60;
  background: var(--purple-deep); color: #fff; padding: 10px 18px;
  border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  box-shadow: 0 4px 14px rgba(0,0,0,0.3);
}

@media (min-width: 640px) {
  .photo-grid { grid-template-columns: repeat(4, 1fr); }
  .idea-grid { grid-template-columns: repeat(3, 1fr); }
  .overlay { align-items: center; }
  .sheet { border-radius: 18px; }
}
