/* Storage Boxes — styled after the home panel: navy surfaces, amber accent, pills, glowing tiles. */
:root {
  --ink: #0E151C; --slate: #18222D; --slate-hi: #22303E; --line: #243240;
  --text: #E7EEF5; --muted: #8398AB;
  --amber: #FFB23F; --amber-soft: #FFD79A; --amber-deep: #A6641A;
  --blue: #5AA9FF; --blue-soft: #A9D1FF; --blue-deep: #12253A;
  --red: #FF6B5A; --green: #8FE3A3;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 14px; --gap: 10px; --nav-h: 66px;
  --sab: min(env(safe-area-inset-bottom, 0px), 30px); /* home-indicator strip; iOS 26 reports a much bigger bottom inset in an installed web app, so it is capped (same fix as the JOYA panel) */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; width: 100%; max-width: 100%; overflow-x: hidden; }
#app, #stage, .sheet-panel { max-width: 100vw; }
.tile .name, .hero .label, .row .t, .note, .suggest .reason { overflow-wrap: anywhere; }
body {
  background: var(--ink); color: var(--text); font: 16px/1.4 var(--font);
  font-variant-numeric: tabular-nums; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
svg { width: 22px; height: 22px; stroke: currentColor; stroke-width: 1.8; fill: none; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.hidden { display: none !important; }
h1 { font-size: 24px; margin: 0; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 18px; margin: 0; }
.muted, .hint { color: var(--muted); font-size: 14px; }
.hint { margin: 0 2px 12px; }
.error { color: var(--red); font-size: 14px; margin: 0 0 12px; }

/* Inputs */
label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 12px; font-weight: 600; }
input[type=email], input[type=password], input[type=text], input[type=number], input[type=search], textarea, select {
  display: block; width: 100%; min-height: 46px; margin-top: 5px; padding: 10px 13px; font: inherit; font-weight: 500; color: var(--text);
  background: var(--slate); border: 1px solid var(--slate-hi); border-radius: 12px; -webkit-appearance: none; appearance: none;
}
select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 20px, calc(100% - 13px) 20px; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 36px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; color: var(--text); font-weight: 500; font-size: 15px; }
input[type=checkbox] { width: 22px; height: 22px; margin: 0; accent-color: var(--amber); flex: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; min-width: 44px; padding: 10px 16px;
  font: inherit; font-weight: 600; color: var(--text); background: var(--slate); border: 1px solid var(--slate-hi); border-radius: 12px; cursor: pointer;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary { background: var(--amber-deep); border-color: #7f4f18; color: #FFF3E0; width: 100%; }
.btn.primary:not(:disabled):active { background: #8f5616; }
.btn.danger { color: var(--red); border-color: rgba(255,107,90,.45); }
.btn.danger.primary { background: #7a2e25; border-color: #9a3a2e; color: #ffe1dc; }
.btn.sm { width: auto; min-height: 40px; padding: 6px 14px; font-size: 15px; border-radius: 99px; }
.btn.block { display: flex; width: 100%; margin-top: 10px; }
.btn.link { background: none; border: none; color: var(--amber); padding: 6px 8px; }
.btn.link.danger { color: var(--red); }
.btn:disabled { opacity: .5; cursor: default; }
.btn:not(:disabled):active { transform: scale(.98); background: var(--slate-hi); }
.ib { width: 44px; height: 44px; display: flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--muted); border-radius: 12px; cursor: pointer; position: relative; flex: none; }
.ib svg { width: 26px; height: 26px; }
.ib:active { background: var(--slate-hi); color: var(--text); }
.ib input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.cam-btn { position: relative; overflow: hidden; }
.cam-btn input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }

/* Pills */
.pills { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 0 0 10px; }
#site-pills { padding: 0 12px 8px; }
.pills::-webkit-scrollbar { display: none; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 99px; background: var(--slate); border: 1px solid var(--slate-hi); font: inherit; font-size: 15px; font-weight: 600; color: var(--text); white-space: nowrap; cursor: pointer; flex: none; }
.pill.on { background: var(--amber-deep); border-color: #7f4f18; color: #FFF3E0; }
.pill small { font-weight: 500; color: var(--muted); font-size: .85em; }
.pill.on small { color: var(--amber-soft); }
.pill:disabled { opacity: .5; }
.pill svg { width: 16px; height: 16px; }
.chip { display: inline-flex; align-items: center; font-size: 13px; padding: 4px 10px; border-radius: 99px; background: var(--slate-hi); border: 1px solid #2c3d4e; font-weight: 500; }
.chip.ai { border-style: dashed; color: var(--amber-soft); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 800; letter-spacing: .06em; padding: 3px 8px; border-radius: 99px; background: rgba(255,107,90,.18); color: var(--red); border: 1px solid rgba(255,107,90,.45); }

/* Login */
.screen { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 360px; background: var(--slate); padding: 28px 22px 22px; border-radius: 20px; border: 1px solid var(--slate-hi); box-shadow: 0 20px 60px -20px #000; }
.login-card .logo { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 18px; display: flex; align-items: center; justify-content: center; background: linear-gradient(155deg,#3A2A14 0%,#2A2013 60%,#241C12 100%); border: 1px solid #5C421F; box-shadow: 0 6px 22px -8px rgba(255,178,63,.45); color: var(--amber); }
.login-card .logo svg { width: 34px; height: 34px; }
.login-card h1 { text-align: center; margin-bottom: 20px; }

/* Shell */
#app { display: flex; flex-direction: column; min-height: 100%; }
#bar { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 6px; padding: 8px 10px 4px; padding-top: calc(8px + env(safe-area-inset-top)); background: var(--ink); }
#bar h1 { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 6px; }
#searchbar { position: sticky; top: calc(56px + env(safe-area-inset-top)); z-index: 6; display: flex; align-items: center; gap: 6px; padding: 4px 12px 8px; background: var(--ink); }
.field { position: relative; display: flex; align-items: center; flex: 1; min-width: 0; }
.field .lead { position: absolute; left: 13px; color: var(--muted); width: 20px; height: 20px; pointer-events: none; }
.field input { margin: 0; padding-left: 42px; padding-right: 40px; border-radius: 99px; height: 44px; min-height: 44px; }
.field .clr, .field .go { position: absolute; right: 4px; width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.field .go { background: var(--amber-deep); color: #FFF3E0; }
.field.big { margin-bottom: 8px; }
.field.big input { height: 52px; font-size: 17px; }
.field.big .lead { color: var(--amber); }
#site-pills { padding-top: 0; }
#stage { flex: 1; padding: 6px 16px; padding-bottom: calc(var(--nav-h) + 20px + var(--sab)); }
.rowhead { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; margin-bottom: 10px; }

/* Tab bar */
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; padding: 4px 8px calc(4px + var(--sab)); background: rgba(14,21,28,.92); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.tab-btn { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 52px; border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 12px; font-weight: 600; border-radius: 12px; cursor: pointer; }
.tab-btn svg { width: 26px; height: 26px; stroke-width: 1.6; }
.tab-btn.on { background: var(--slate); color: var(--text); }
.tab-btn.on svg { stroke: var(--amber); }
.tab-btn:active { background: var(--slate-hi); }

/* Sections */
.sec { margin-bottom: 18px; }
.sec h3, .sec-h { margin: 6px 2px 8px; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; display: flex; align-items: center; justify-content: space-between; }
.sec h3 small { color: var(--amber-soft); font-weight: 600; text-transform: none; letter-spacing: 0; font-size: 12px; }
.state { text-align: center; color: var(--muted); padding: 28px 8px; font-size: 15px; }
.state .btn { width: auto; margin-top: 12px; }
.state.err { color: var(--red); }
.list { display: flex; flex-direction: column; gap: var(--gap); }
.card { background: var(--slate); border: 1px solid var(--slate-hi); border-radius: var(--radius); padding: 12px 14px; }
.card.press, .tile.press, .row.press { transform: scale(.975); background: var(--slate-hi); }

/* Box tiles */
.tgrid { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--gap); }
.tile {
  position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; min-height: 132px; padding: 12px;
  background: linear-gradient(155deg,#14273D,#0F1C2B); border: 1px solid #2A4A6E; border-radius: var(--radius); color: inherit; text-decoration: none; cursor: pointer;
  box-shadow: 0 0 0 1px rgba(90,169,255,.08), 0 6px 22px -10px rgba(90,169,255,.4);
}
.tile::before { content: ""; position: absolute; top: -30px; left: -30px; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(circle, rgba(90,169,255,.22), rgba(90,169,255,0) 70%); pointer-events: none; }
.tile .num { font-size: 40px; font-weight: 800; line-height: 1; letter-spacing: -.03em; color: var(--blue-soft); }
.tile .tag { position: absolute; right: 10px; top: 10px; }
.tile .name { font-weight: 600; font-size: 15px; line-height: 1.2; margin-top: 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile .name.empty { color: var(--muted); font-weight: 400; }
.tile .val { font-size: 12px; color: var(--muted); margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .matches { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tile .matches .chip { font-size: 11px; padding: 2px 7px; }
.tile.full { background: linear-gradient(155deg,#3A2A14 0%,#2A2013 60%,#241C12 100%); border-color: #5C421F; box-shadow: 0 0 0 1px rgba(255,178,63,.10), 0 6px 22px -10px rgba(255,178,63,.45); }
.tile.full::before { background: radial-gradient(circle, rgba(255,178,63,.25), rgba(255,178,63,0) 70%); }
.tile.full .num { color: var(--amber-soft); }

/* Rows */
.row { display: flex; align-items: center; gap: 12px; min-height: 58px; cursor: pointer; color: inherit; text-decoration: none; }
.row .lead-num { min-width: 46px; height: 46px; padding: 0 6px; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800; border-radius: 12px; background: var(--blue-deep); color: var(--blue-soft); border: 1px solid #2A4A6E; flex: none; }
.row .lead-ico { width: 46px; height: 46px; display: flex; align-items: center; justify-content: center; border-radius: 12px; background: var(--slate-hi); color: var(--amber); flex: none; }
.row .info { flex: 1; min-width: 0; }
.row .t { font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .t.empty { color: var(--muted); font-weight: 400; }
.row .s { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .chev { color: var(--muted); opacity: .7; }
.row .end { color: var(--muted); font-size: 13px; text-align: right; flex: none; }
.crop { width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--slate-hi); display: block; flex: none; }
.crop.none { background: transparent; border: 1px dashed var(--line); }
.crop.big { width: 120px; height: 120px; border-radius: 16px; margin: 0 auto 12px; }

/* Places */
.site { margin-bottom: 14px; padding: 6px 14px 12px; }
.site-head { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.site-head h2 { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.site-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--slate-hi); color: var(--amber); display: flex; align-items: center; justify-content: center; flex: none; }
/* Locations hang under their site as a tree: vertical line from the site icon, a tick into each row. */
.locs { margin: 2px 0 0 17px; padding-left: 12px; border-left: 2px solid var(--slate-hi); }
.loc-row { display: flex; align-items: center; gap: 8px; min-height: 46px; position: relative; }
.loc-row::before { content: ""; width: 10px; height: 2px; background: var(--slate-hi); margin-left: -12px; flex: none; }
.loc-ico { width: 28px; height: 28px; border-radius: 8px; background: rgba(255,178,63,.12); color: var(--amber); display: flex; align-items: center; justify-content: center; flex: none; cursor: pointer; }
.loc-ico svg { width: 17px; height: 17px; }
.loc-row .name { flex: 1; min-width: 0; font-weight: 500; cursor: pointer; overflow-wrap: anywhere; padding: 6px 0; }
.locs .add-loc { margin: 6px 0 2px; }
.count { color: var(--muted); font-size: 13px; white-space: nowrap; }
.btn.mini { min-height: 36px; min-width: 40px; padding: 4px 10px; font-size: 13px; border-radius: 99px; }
.btn.mini.danger { border-color: transparent; }
.add-loc { margin-top: 8px; }

/* Box page */
.hero { display: flex; gap: 14px; align-items: flex-start; padding: 4px 0 14px; }
.hero .bignum { min-width: 108px; height: 108px; padding: 0 10px; display: flex; align-items: center; justify-content: center; font-size: 56px; font-weight: 900; letter-spacing: -.04em; border-radius: 22px; background: linear-gradient(155deg,#14273D,#0F1C2B); border: 1px solid #2A4A6E; color: var(--blue-soft); box-shadow: 0 0 0 1px rgba(90,169,255,.1), 0 10px 30px -12px rgba(90,169,255,.6); flex: none; }
.hero.full .bignum { background: linear-gradient(155deg,#3A2A14 0%,#2A2013 60%,#241C12 100%); border-color: #5C421F; color: var(--amber-soft); box-shadow: 0 0 0 1px rgba(255,178,63,.1), 0 10px 30px -12px rgba(255,178,63,.6); }
.hero .info { flex: 1; min-width: 0; padding-top: 4px; }
.hero .label { font-size: 22px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.hero .label.empty { color: var(--muted); font-weight: 400; }
.hero .where { color: var(--muted); margin-top: 6px; font-size: 14px; }
.hero .tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.note { white-space: pre-wrap; background: var(--slate); border: 1px solid var(--slate-hi); border-radius: 12px; padding: 10px 12px; font-size: 15px; margin-bottom: 12px; }
.acts { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 18px; }
.acts .btn { flex-direction: column; gap: 4px; padding: 8px 2px; font-size: 11px; font-weight: 600; min-height: 60px; color: var(--muted); }
.acts .btn svg { width: 22px; height: 22px; color: var(--text); }
.acts .btn.danger svg { color: var(--red); }
.acts .btn.on { background: var(--amber-deep); border-color: #7f4f18; color: #FFF3E0; }
.acts .btn.on svg { color: #FFF3E0; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-tile { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--slate); border: 1px solid var(--slate-hi); cursor: pointer; padding: 0; }
.photo-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-tile .overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; text-align: center; padding: 6px; }
.photo-tile .badge { position: absolute; right: 6px; bottom: 6px; font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: rgba(0,0,0,.65); color: #fff; }
.photo-tile .badge.err { background: var(--red); }
.photo-tile.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--amber); font-weight: 600; font-size: 13px; border-style: dashed; border-color: #2c3d4e; }
.photo-tile.add svg { width: 28px; height: 28px; }
.photo-tile.add input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; }
.photo-full { width: 100%; max-height: 55vh; object-fit: contain; border-radius: 12px; background: #000; margin-bottom: 12px; }
.item-row .src { font-size: 10px; font-weight: 700; color: var(--amber-soft); border: 1px dashed #5C421F; border-radius: 6px; padding: 1px 5px; }

/* Checklist */
.check-row { display: grid; grid-template-columns: 28px 46px 1fr 60px 36px; grid-template-areas: "cb crop name name name" ". . qty where rm"; gap: 8px; align-items: center; padding-bottom: 10px; margin-bottom: 10px; border-bottom: 1px solid var(--line); }
.check-row input[type=checkbox] { grid-area: cb; }
.check-row .crop { grid-area: crop; }
.check-row input[type=text] { grid-area: name; margin: 0; }
.check-row input[type=number] { grid-area: qty; margin: 0; }
.check-row .btn.where { grid-area: where; justify-self: start; min-height: 40px; padding: 0 12px; font-size: 13px; }
.check-row .btn[data-remove] { grid-area: rm; min-height: 40px; padding: 0; }
.check-row.off input[type=text], .check-row.off input[type=number], .check-row.off .crop { opacity: .4; }

/* Suggestions */
.suggest { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.suggest .reason { font-size: 14px; margin-top: 6px; color: var(--amber-soft); }

/* Labels */
.label-row { display: flex; align-items: center; gap: 12px; min-height: 58px; cursor: pointer; }
.label-row .printed { font-size: 12px; color: var(--muted); }
.label-row .printed.no { color: var(--red); }

/* Sheet */
.sheet { position: fixed; inset: 0; z-index: 30; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.55); }
.sheet-panel { position: absolute; left: 0; right: 0; bottom: 0; max-height: 92%; overflow: auto; background: var(--slate); border-radius: 22px 22px 0 0; padding: 8px 16px calc(16px + var(--sab)); box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: up .2s ease-out; border-top: 1px solid var(--slate-hi); }
.sheet-panel .grip { width: 40px; height: 4px; border-radius: 2px; background: var(--slate-hi); margin: 4px auto 14px; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-panel h2 { margin: 0 0 14px; }
.sheet-panel p.msg { margin: 0 0 14px; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 8px; }
.sheet-actions.three { grid-template-columns: 1fr 1fr 1fr; }
.sheet-panel .card { background: var(--ink); }

.spinner { width: 20px; height: 20px; border: 3px solid var(--slate-hi); border-top-color: var(--amber); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: middle; }
@keyframes spin { to { transform: rotate(360deg); } }
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 24px); transform: translateX(-50%); background: var(--text); color: var(--ink); padding: 10px 16px; border-radius: 99px; font-size: 14px; font-weight: 600; z-index: 40; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 90vw; }

@media (min-width: 600px) { .tgrid { grid-template-columns: repeat(3, 1fr); } #stage { max-width: 860px; margin: 0 auto; width: 100%; } }
input[type=search]::-webkit-search-cancel-button, input[type=search]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }

/* Item thumbnails on box tiles and match chips */
.tile .thumbs { display: flex; gap: 4px; align-items: center; margin-top: 10px; }
.tile .thumbs img { width: 30px; height: 30px; border-radius: 8px; object-fit: cover; border: 1px solid rgba(255,255,255,.12); background: var(--slate-hi); }
.tile .thumbs .more { font-size: 11px; color: var(--muted); font-weight: 600; }
.chip img { width: 18px; height: 18px; border-radius: 5px; object-fit: cover; margin: -2px 5px -2px -4px; }

/* Unsaved-changes strip inside a sheet */
.discard { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 10px; padding: 10px 12px; border-radius: 12px; background: rgba(255,178,63,.12); border: 1px solid rgba(255,178,63,.4); color: var(--amber-soft); font-weight: 600; font-size: 14px; }
.discard span { flex: 1; }
