/* ===== Kids Immediate Tool ===== */
:root {
  --bg: #fff; --fg: #111; --muted: #666; --border: #e5e5e5;
  --blue: #1f6feb; --red: #d11; --card-shadow: 0 2px 5px rgba(0,0,0,0.06);
  --radius: 14px;
}

/* ── Reset ── */
*, html, body { box-sizing: border-box; margin: 0; padding: 0; }
body {
  height: 100%; min-height: 100%; background: var(--bg); color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.tabpanes  { padding-bottom: 80px; min-height: calc(100vh - 80px); }
.tabpane   { display: none; }
.tabpane.active { display: block; padding-bottom: 100px; min-height: calc(100vh - 80px); }
.pane-title { font-size: 18px; font-weight: 800; margin: 16px 14px; }

/* ── Topbar / Filters ── */
.topbar {
  position: sticky; top: 0; background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 7px 8px; display: flex; align-items: center; gap: 6px; z-index: 8;
}
.filters {
  display: flex; flex-wrap: nowrap; gap: 4px; align-items: center;
  flex: 1; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none; -ms-overflow-style: none;
}
.filters::-webkit-scrollbar { display: none; }

.filters select {
  appearance: none; -webkit-appearance: none;
  font-size: 11px; padding: 4px 16px 4px 7px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: #fafafa; color: var(--fg); cursor: pointer;
  height: 26px; line-height: 18px; flex: 1 1 0;
  min-width: 0;
  transition: all .2s;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 5px center; background-size: 11px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.filters select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,235,.08); }
.count, .icon, #selectedCount, #savePhotosBtn { flex-shrink: 0; }

/* ── Grid ── */
#items, #orderItems {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 3px; padding: 3px; width: 100%; justify-items: stretch;
}

/* ── Card ── */
.card {
  position: relative; background: #fff; border-radius: var(--radius);
  box-shadow: var(--card-shadow); display: flex; flex-direction: column;
  gap: 4px; padding: 6px 6px 4px; transition: transform .18s;
  contain: layout paint; min-height: 0; align-self: start;
}
.img-wrap {
  width: 100%; aspect-ratio: 1/1; border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; border: 1px solid #f2f2f2;
}
.img-wrap .prod-img { width: 100%; height: 100%; object-fit: cover; display: block; will-change: transform; backface-visibility: hidden; }

/* ── Chips / Price ── */
.sizes { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.sizes .chip { border: 2px solid var(--blue); color: var(--blue); font-weight: 700; font-size: 13px; border-radius: 999px; padding: 3px 5px; }

.price { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0 2px; margin: 0 0 2px; font-size: 12px; }
.price .p-main { color: var(--red); font-weight: 800; }
.price .p-le   { color: #1f4ea8; font-weight: 700; font-size: 11.5px; }

.supplier-tag { text-align: center; font-size: 13px; color: #111; font-weight: 700; margin-top: -4px; }

/* ── Select Overlay ── */
.select-overlay { position: absolute; top: 8px; left: 8px; z-index: 6; }
.select-overlay input.select-cb { display: none; }
.select-overlay .select-check {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(255,255,255,.9); border: 1px solid var(--border);
  font-weight: 800; color: var(--blue); transform: scale(.9); opacity: .95;
}
.select-overlay input.select-cb:checked + .select-check { background: var(--blue); color: #fff; border-color: rgba(0,0,0,.06); }

/* ── Buttons ── */
.cta { display: flex; gap: 4px; align-items: center; }
.cta .share-story { flex: 1; }
.cta-secondary { display: flex; gap: 4px; margin-top: 4px; }

.share-story {
  background: #1f4ea8; color: #fff; border: 0;
  padding: 6px 8px; font-size: 13px; font-weight: 700; border-radius: 11px;
  width: 100%; text-align: center; cursor: pointer; display: block;
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: all .2s; position: relative; overflow: hidden; margin-top: 1px;
}
.share-story:hover  { background: #163b82; }
.share-story:active { transform: scale(0.97); }
.share-story::before {
  content: ''; position: absolute; top: 50%; left: 50%;
  width: 0; height: 0; border-radius: 50%;
  background: rgba(255,255,255,.4);
  transform: translate(-50%,-50%); transition: width .3s, height .3s;
}
.share-story:active::before { width: 200px; height: 200px; }

.copy-link-btn {
  background: #f0f4ff; border: 1.5px solid #c7d7ff; color: #1f4ea8;
  border-radius: 9px; padding: 4px 8px; font-size: 14px; cursor: pointer;
  flex-shrink: 0; width: 32px; text-align: center; line-height: 1;
}
.mark-arrived-btn {
  background: #f0fdf4; border: 1.5px solid #bbf7d0; color: #16a34a;
  border-radius: 9px; padding: 4px 8px; font-size: 11px; font-weight: 700;
  cursor: pointer; flex: 1; text-align: center;
}
.mark-arrived-btn:disabled { opacity: .5; }

#createCollage {
  display: inline-block; border: 1px solid var(--border); background: #fafafa;
  border-radius: 12px; padding: 6px 10px; cursor: pointer;
}

/* ── Dashboard Stats ── */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px; }
.stat {
  border-radius: var(--radius); padding: 16px 14px;
  position: relative; overflow: hidden;
}
.stat .v { font-size: 24px; font-weight: 900; margin-bottom: 2px; color: #fff !important; }
.stat .k { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: rgba(255,255,255,.8) !important; }

/* Calm, muted stat gradients */
.stat:has(#stat-boys)       { background: linear-gradient(135deg, #5b8dee, #3a6dcc); }
.stat:has(#stat-girls)      { background: linear-gradient(135deg, #c97dd4, #9b4faa); }
.stat:has(#stat-arrived)    { background: linear-gradient(135deg, #4db87a, #2d8f58); }
.stat:has(#stat-pending)    { background: linear-gradient(135deg, #e8a045, #c07828); }
.stat:has(#stat-total)      { background: linear-gradient(135deg, #8a7cc8, #6354a8); }
.stat:has(#stat-total-cost) { background: linear-gradient(135deg, #e06060, #b83c3c); }
.stat:has(#stat-winter)     { background: linear-gradient(135deg, #6ba3e8, #3f75c0); }
.stat:has(#stat-summer)     { background: linear-gradient(135deg, #e8855a, #c05c32); }

/* Fallback for browsers without :has() */
#stat-boys .v, #stat-boys .k, #stat-girls .v, #stat-girls .k,
#stat-arrived .v, #stat-arrived .k, #stat-pending .v, #stat-pending .k,
#stat-total .v, #stat-total .k, #stat-total-cost .v, #stat-total-cost .k,
#stat-winter .v, #stat-winter .k, #stat-summer .v, #stat-summer .k { color: #fff !important; }

/* ── Bottom Tabs ── */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; height: 62px; z-index: 20;
}
@supports (padding: max(0px)) {
  .tabs { padding-bottom: max(env(safe-area-inset-bottom), 0px); height: calc(62px + max(env(safe-area-inset-bottom), 0px)); }
}
.tab { flex: 1; border: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #666; gap: 3px; background: transparent; }
.tab.active { color: #000; font-weight: 700; }

/* ── Settings ── */
.settings { background: #f5f5f7; padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.settings .row {
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 16px; min-height: 54px;
}

/* ── Misc ── */
.empty  { padding: 26px; text-align: center; color: #777; }
.hidden { display: none; }
/* .smart-search and .view-toggle removed — unused */
#tab-order    { padding-left: max(env(safe-area-inset-left), 10px); }
#tab-dashboard { padding-top: calc(env(safe-area-inset-top) + 20px); }

.last-shared {
  font-size: 10px; color: #777; text-align: center; font-weight: 500;
  padding: 4px; min-height: 18px; height: 18px; line-height: 18px;
  display: block; white-space: nowrap;
  visibility: visible !important; opacity: 1 !important;
}

/* ── Loading Overlay ── */
body.loading { overflow: hidden; }
body.loading::before {
  content: ''; position: fixed; inset: 0;
  background: rgba(255,255,255,.95); z-index: 9999; backdrop-filter: blur(3px);
}
body.loading::after {
  content: ''; position: fixed; top: 50%; left: 50%;
  transform: translate(-50%,-50%);
  width: 50px; height: 50px; border-radius: 50%;
  border: 4px solid #f3f3f3; border-top-color: #8f6bf2;
  animation: spin 1s linear infinite; z-index: 10000;
}
@keyframes spin {
  from { transform: translate(-50%,-50%) rotate(0deg); }
  to   { transform: translate(-50%,-50%) rotate(360deg); }
}

/* ── Toast ── */
#toast-wrap {
  position: fixed; bottom: 80px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  padding: 10px 20px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: #fff; background: #333; opacity: 0; transform: translateY(10px);
  transition: opacity .25s, transform .25s; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.18);
}
.toast.toast-show    { opacity: 1; transform: translateY(0); }
.toast.toast-success { background: #2e7d32; }
.toast.toast-error   { background: #c62828; }
.toast.toast-info    { background: #1565c0; }

/* ── Confirm Dialog ── */
.confirm-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 10000; opacity: 0; transition: opacity .2s; }
.confirm-overlay.confirm-show { opacity: 1; }
.confirm-box { background: #fff; border-radius: 18px; padding: 24px 22px 18px; width: min(320px,90vw); box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.confirm-msg { font-size: 16px; font-weight: 600; text-align: center; margin-bottom: 20px; color: #111; }
.confirm-btns { display: flex; gap: 10px; }
.confirm-btns button { flex: 1; padding: 11px; border-radius: 12px; border: 0; font-size: 15px; font-weight: 700; cursor: pointer; }
.confirm-yes { background: #1f4ea8; color: #fff; }
.confirm-no  { background: #f0f0f0; color: #333; }

/* ── Stock Badge ── */
.stock-badge {
  position: absolute; top: 8px; right: 8px; background: #1f4ea8;
  color: #fff; font-size: 11px; font-weight: 800; border-radius: 999px;
  padding: 2px 7px; z-index: 5; line-height: 16px; min-width: 22px; text-align: center;
}

/* ── Sort Bar ── */
.sort-bar { display: flex; align-items: center; gap: 6px; padding: 6px 10px; background: #f5f5f7; border-bottom: 1px solid var(--border); overflow-x: auto; -webkit-overflow-scrolling: touch; }
.sort-bar::-webkit-scrollbar { display: none; }
.sort-label { font-size: 12px; color: var(--muted); font-weight: 600; flex-shrink: 0; }
.sort-btn { padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--border); background: #fff; font-size: 12px; font-weight: 600; color: #444; cursor: pointer; white-space: nowrap; flex-shrink: 0; transition: all .18s; }
.sort-btn.active { background: #1f4ea8; color: #fff; border-color: #1f4ea8; }

/* ── Pull-to-Refresh ── */
#ptr-indicator {
  position: fixed; top: 0; left: 50%; transform: translateX(-50%);
  background: #1f4ea8; color: #fff; font-size: 13px; font-weight: 700;
  padding: 8px 20px; border-radius: 0 0 20px 20px;
  opacity: 0; z-index: 9998; pointer-events: none; white-space: nowrap;
  transition: opacity .2s, transform .2s;
}

/* ── Size Chart ── */
.chart-wrap { margin: 0 14px 20px; background: #fff; border-radius: var(--radius); box-shadow: var(--card-shadow); padding: 14px 12px 10px; border: 1px solid var(--border); }
.chart-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 8px; }
.chart-title { font-size: 12px; font-weight: 800; color: #111; text-transform: uppercase; letter-spacing: .04em; flex-shrink: 0; }
.chart-filters { display: flex; gap: 4px; }
.chart-filter-btn { padding: 3px 9px; border-radius: 999px; border: 1.5px solid var(--border); background: #fff; font-size: 11px; font-weight: 600; color: #555; cursor: pointer; white-space: nowrap; transition: all .15s; }
.chart-filter-btn.active { background: #1f4ea8; color: #fff; border-color: #1f4ea8; }
.chart-inner { position: relative; height: 220px; width: 100%; }


/* ── Text Search Bar ── */
.search-bar {
  padding: 6px 8px 0;
}
.text-search-input {
  width: 100%; padding: 7px 12px; font-size: 14px;
  border: 1.5px solid var(--border); border-radius: 999px;
  background: #fafafa; color: var(--fg); outline: none;
  transition: border-color .2s;
  -webkit-appearance: none;
}
.text-search-input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(31,111,235,.08); }

/* ── Responsive ── */
@media (max-width: 600px) {
  #items, #orderItems { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; padding: 8px; }
  .card { font-size: 13px; padding: 3px; }
  .img-wrap { border-radius: 8px; }
  .sizes .chip { font-size: 11px; padding: 2px 6px; }
  .share-story, .save-photo-btn { font-size: 12px; padding: 5px; margin-bottom: 1px; }
}
/* ── Brand List (Sales Analytics) ── */
.brand-list {
  display: flex; flex-direction: column; gap: 10px;
  padding: 4px 2px 8px;
}
.brand-row { display: flex; flex-direction: column; gap: 4px; }
.brand-meta {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 6px;
}
.brand-name  { font-size: 13px; font-weight: 800; color: #111; }
.brand-stats { font-size: 11px; color: #666; text-align: right; flex-shrink: 0; }
.brand-stats strong { color: #111; }
.brand-bar-track {
  height: 8px; border-radius: 999px; background: #f0f0f0; overflow: hidden;
}
.brand-bar-fill {
  height: 100%; border-radius: 999px;
  transition: width .4s cubic-bezier(.4,0,.2,1);
}
.analytics-summary {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.as-card {
  border-radius: 10px; padding: 10px 12px;
  display: flex; flex-direction: column; gap: 2px;
}
.as-v {
  font-size: 16px; font-weight: 900; color: #fff; line-height: 1.1;
}
.as-v span { font-size: 11px; font-weight: 600; opacity: .8; }
.as-k {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: rgba(255,255,255,.8);
}
.as-k em { font-style: normal; background: rgba(255,255,255,.2); border-radius: 4px; padding: 0 4px; margin-left: 4px; }

.as-revenue { background: linear-gradient(135deg, #5b8dee, #3a6dcc); }
.as-cost    { background: linear-gradient(135deg, #e8a045, #c07828); }
.as-profit  { background: linear-gradient(135deg, #4db87a, #2d8f58); }
.as-orders  { background: linear-gradient(135deg, #8a7cc8, #6354a8); }

/* ===== Arrived Per-Size Checkboxes ===== */
.arrived-sizes-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px 0 2px;
    justify-content: center;
}

.arrived-size-label {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1.5px solid #d0d0d0;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    background: #fff;
    transition: all .2s;
    user-select: none;
}

.arrived-size-label input[type="checkbox"] {
    width: 14px;
    height: 14px;
    accent-color: #2e7d32;
    cursor: pointer;
}

.arrived-size-label:hover {
    border-color: #2e7d32;
    background: #f1f8e9;
}

.arrived-size-label.is-arrived {
    border-color: #2e7d32;
    background: #e8f5e9;
    color: #2e7d32;
    cursor: default;
}