:root {
  --bg: #f6f6f4; --card: #ffffff; --ink: #1d1d1b; --muted: #6b6b66; --line: #e3e3de;
  --accent: #111111; --accent-ink: #ffffff; --danger: #b42318; --ok: #1a7f37;
  --radius: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between;
       gap: 12px; padding: 12px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; letter-spacing: .02em; }
.link { color: var(--ink); text-decoration: none; font-size: 15px; margin-left: 14px; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.narrow { max-width: 420px; margin: 8vh auto 0; display: flex; flex-direction: column; gap: 12px; }
h1 { font-size: 22px; margin: 0 0 4px; }
label { font-size: 14px; color: var(--muted); }
input, select { font-size: 17px; padding: 14px; border: 1px solid var(--line); border-radius: 10px;
                background: #fff; width: 100%; }
.btn { font-size: 17px; padding: 14px 18px; border-radius: 10px; border: 1px solid var(--line);
       background: #fff; color: var(--ink); cursor: pointer; min-height: 48px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.error { color: var(--danger); margin: 0; }
.muted { color: var(--muted); }

/* ---- layout additions (Task 15-17) ---- */
.top-left { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.store-name { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; flex-shrink: 0; }
.badge { display: inline-block; min-width: 22px; padding: 1px 7px; border-radius: 999px; background: var(--accent);
         color: var(--accent-ink); font-size: 13px; text-align: center; }
.back { display: inline-block; color: var(--muted); text-decoration: none; margin: 4px 0 10px; font-size: 15px; }
.notice { background: #fff8e6; border: 1px solid #f1d58a; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; font-size: 15px; }
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { display: flex; flex-direction: column; gap: 6px; justify-content: center; min-height: 92px; padding: 16px;
        background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--ink); text-decoration: none; }
.tile-title { font-weight: 600; font-size: 17px; }
.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .grid { grid-template-columns: repeat(4, 1fr); } }
.pcard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
         color: var(--ink); text-decoration: none; display: flex; flex-direction: column; }
.pcard.dim { opacity: .55; }
.pimg { aspect-ratio: 1 / 1; background: #fafaf8; display: flex; align-items: center; justify-content: center; }
.pimg img { width: 100%; height: 100%; object-fit: contain; }
.pbody { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 4px; }
.ptitle { font-size: 14px; font-weight: 600; line-height: 1.3; }
.psku { font-size: 12px; color: var(--muted); font-family: ui-monospace, Menlo, monospace; }
.tag { font-size: 12px; color: var(--muted); }
.product { display: grid; gap: 16px; }
@media (min-width: 820px) { .product { grid-template-columns: 1fr 1fr; align-items: start; } }
.product-img { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); aspect-ratio: 1 / 1;
               display: flex; align-items: center; justify-content: center; overflow: hidden; }
.product-img img { width: 100%; height: 100%; object-fit: contain; }
.product-info h1 { font-size: 20px; }
.alert { border-radius: 10px; padding: 12px 14px; margin: 12px 0; font-size: 15px; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }
.error-box { background: #fdecea; border: 1px solid #f5c2bd; color: #7a1a12; }
.ok-box { background: #e9f6ec; border: 1px solid #b7e1c1; color: #135c26; }
.ok-box a { color: inherit; font-weight: 600; }
.sizes-head { display: flex; justify-content: space-between; align-items: center; margin: 16px 0 8px; font-weight: 600; }
.size-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.size-row.off .size { color: var(--muted); }
.size-label { display: flex; flex-direction: column; gap: 2px; }
.size { font-size: 17px; font-weight: 600; }
.reason { font-size: 12px; color: var(--muted); }
.seg { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-shrink: 0; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; }
.seg-opt span { display: block; min-width: 48px; padding: 12px 0; text-align: center; font-size: 16px; background: #fff; cursor: pointer; }
.seg-opt + .seg-opt span { border-left: 1px solid var(--line); }
.seg-opt input:checked + span { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg-opt.seg-off span { color: #c4c4be; background: #f4f4f1; cursor: not-allowed; }
.seg-opt input:focus-visible + span { outline: 2px solid #2563eb; outline-offset: -2px; }
.btn.small { min-height: 38px; padding: 8px 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.sticky-bar { position: sticky; bottom: 0; padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px)); background: var(--bg); margin-top: 8px; }
.list { padding: 4px 16px; }
.line { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line-img { width: 56px; height: 56px; flex-shrink: 0; background: #fafaf8; border-radius: 8px; overflow: hidden; }
.line-img img { width: 100%; height: 100%; object-fit: contain; }
.line-main { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.small-text { font-size: 13px; margin: 0; }
.center { text-align: center; }
.big-id { font-size: 26px; font-weight: 700; font-family: ui-monospace, Menlo, monospace; margin: 8px 0; }
@media (max-width: 480px) { .brand { display: none; } .link { margin-left: 12px; } }

/* ---- Refills (Task 18) ---- */
.refill { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); margin-bottom: 14px; }
.pending-card { border-color: #f1d58a; background: #fffcf2; }
.refill-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.rid { font-family: ui-monospace, Menlo, monospace; font-weight: 700; font-size: 16px; }
.rid-big { font-family: ui-monospace, Menlo, monospace; font-size: 22px; margin: 0; }
.pill { font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.pill-pending { background: #fff1c2; color: #7a5800; }
.pill-in_fulfillment { background: #e6effd; color: #1e4fa8; }
.pill-fulfilled { background: #e3f4e7; color: #1a6b31; }
.refill-row { text-decoration: none; color: var(--ink); }
.link-inline { font-weight: 600; text-decoration: underline; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 12px 0; }
.facts > div { display: flex; flex-direction: column; gap: 2px; font-size: 15px; }
.facts .muted { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.add-more { display: block; text-align: center; text-decoration: none; margin-bottom: 12px; }
.qty-cols { display: flex; gap: 14px; text-align: center; flex-shrink: 0; }
.qty-cols > div { display: flex; flex-direction: column; min-width: 34px; }
.qty-cols .muted { font-size: 11px; }
@media (max-width: 480px) { .top-right .link { margin-left: 10px; font-size: 14px; } }
.refill-row.is-pending { background: #fffcf2; margin: 0 -16px; padding: 12px 16px; }
.add-more { margin: 12px 0 0; }

/* ---- Warehouse (Task 19) ---- */
.whoami { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.whoami label { white-space: nowrap; }
.whoami input { width: auto; flex: 1; max-width: 260px; padding: 8px 10px; font-size: 15px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 12px; color: var(--muted); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.tab.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.table-wrap { padding: 0; overflow-x: auto; }
.wh-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.wh-table th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.wh-table td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.wh-table tr:last-child td { border-bottom: 0; }
.wh-table a { color: var(--ink); }
.wh-table .act { text-align: right; }
.h2 { font-size: 17px; margin: 18px 0 8px; }
@media (max-width: 720px) {
  .wh-table thead { display: none; }
  .wh-table tr { display: block; padding: 10px 12px; border-bottom: 1px solid var(--line); }
  .wh-table td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 0; border: 0; }
  .wh-table td::before { content: attr(data-l); color: var(--muted); font-size: 12px; }
  .wh-table td.act { padding-top: 8px; }
  .wh-table td.act::before { content: ""; }
  .wh-table td.act form, .wh-table td.act .btn { width: 100%; }
}

/* ---- In fulfillment (Task 20) ---- */
.ful { padding: 0; margin-bottom: 18px; overflow: hidden; }
.ful-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.ful-store { font-weight: 700; font-size: 17px; }
.ful-head a.mono { text-decoration: none; }
.slip-btn { text-decoration: none; display: inline-flex; align-items: center; }
.ful .table-wrap { border-radius: 0; }
.ful-foot { display: flex; justify-content: flex-end; align-items: flex-end; gap: 12px; padding: 14px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; background: #fafaf8; }
.ful-foot label { display: flex; flex-direction: column; gap: 4px; }
.ful-foot input { width: auto; padding: 10px; font-size: 15px; }
.qty-edit { display: inline-flex; align-items: center; gap: 8px; }
.qty-edit input { width: 64px; padding: 8px; font-size: 16px; text-align: center; }
.save-note { font-size: 12px; color: var(--muted); min-width: 40px; }
.save-note.ok { color: var(--ok); }
.save-note.edited { color: #9a6700; font-weight: 600; }
.save-note.bad { color: var(--danger); }
@media (max-width: 720px) { .ful-foot { justify-content: stretch; } .ful-foot > * { width: 100%; } }

/* ---- Ready to ship (Task 21) ---- */
.ship-form { display: grid; grid-template-columns: 2fr 1.4fr 0.7fr auto; gap: 12px; align-items: end; padding: 14px 16px; }
.ship-form label { display: flex; flex-direction: column; gap: 4px; }
.ship-form input { padding: 10px; font-size: 15px; }
.ship-status { padding: 0 16px 14px; }
.ok-text { color: var(--ok); font-weight: 600; }
@media (max-width: 720px) { .ship-form { grid-template-columns: 1fr; } }

.pill-shipped { background: #ede7fb; color: #5b3aa8; }

/* ---- Push to Shopify (Task 22) ---- */
.push-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.pick { display: flex; gap: 12px; align-items: flex-start; cursor: pointer; }
.pick input { width: 20px; height: 20px; margin-top: 4px; flex-shrink: 0; }
.pick.off { cursor: default; }
.push-actions, .err-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.err-actions { padding: 0 12px 12px; margin: 0; }
.push-actions a.btn, .err-actions a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.row-bad td { background: #fdecea; }
.row-warn td { background: #fff8e6; }
.err-cell { color: var(--danger); }
.pushing { background: #e6effd; border: 1px solid #b9cdf3; color: #1e4fa8; border-radius: 10px; padding: 12px 14px; font-weight: 600; }

.card-push { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 0 16px 14px; flex-wrap: wrap; }
.push-bar a.btn, .card-push a.btn { text-decoration: none; display: inline-flex; align-items: center; }

/* Live Stream: 0-5 buttons fit on a phone */
.seg-many .seg-opt span { min-width: 40px; }
