/* ============================================================
   9ja Shelves — Marketplace + Retail OS design system
   ============================================================ */
:root {
  --navy: #0A1F44;
  --navy-2: #13284f;
  --blue: #1E3A8A;
  --green: #00C281;
  --green-600: #00a06a;
  --green-glow: rgba(0, 194, 129, 0.35);
  --danger: #EF4444;
  --alert: #F59E0B;

  --bg: #F4F6FB;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;
  --text: #0F1B33;
  --text-2: #64748B;
  --border: #E5E9F2;
  --shadow-sm: 0 1px 3px rgba(16, 27, 51, .08);
  --shadow-md: 0 8px 24px rgba(16, 27, 51, .10);
  --shadow-lg: 0 18px 48px rgba(16, 27, 51, .16);

  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;

  --space: 16px;
  --maxw: 1200px;
  --header-h: 64px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0A1428;
    --surface: #0F1E3D;
    --surface-2: #13254a;
    --text: #EAF0FB;
    --text-2: #93A4C4;
    --border: rgba(255, 255, 255, .09);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, .4);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
    --shadow-lg: 0 18px 48px rgba(0, 0, 0, .55);
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 16px; }
::selection { background: var(--green-glow); }

/* ---------- Logo spinner ---------- */
.spinner-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  background: radial-gradient(circle at 50% 40%, var(--navy-2), var(--navy));
  transition: opacity .35s ease, visibility .35s ease;
}
.spinner-overlay.hide { opacity: 0; visibility: hidden; pointer-events: none; }
.spinner-overlay.inline { position: absolute; background: rgba(244,246,251,.7); }
@media (prefers-color-scheme: dark) { .spinner-overlay.inline { background: rgba(10,20,40,.7); } }
.spinner-box { position: relative; width: 116px; height: 116px; display: grid; place-items: center; }
.spinner-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 4px solid rgba(255,255,255,.12);
  border-top-color: var(--green);
  border-right-color: var(--green);
  animation: spin 1s linear infinite;
  box-shadow: 0 0 26px var(--green-glow);
}
.spinner-logo {
  width: 72px; height: 72px; object-fit: contain; border-radius: 16px;
  animation: pulse 1.6s ease-in-out infinite;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.4));
}
.spinner-text { color: #fff; font-weight: 800; letter-spacing: 3px; font-size: 14px; opacity: .85; }
.inline .spinner-text { color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { transform: scale(.9); opacity: .85; } 50% { transform: scale(1.05); opacity: 1; } }

/* ---------- Toast ---------- */
.toast-container { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 9998; display: flex; flex-direction: column; gap: 10px; width: min(92vw, 420px); }
.toast { background: var(--navy); color: #fff; padding: 14px 18px; border-radius: var(--r-md); box-shadow: var(--shadow-lg); font-weight: 600; font-size: 14px; display: flex; gap: 10px; align-items: center; animation: toastIn .25s ease; }
.toast.success { background: var(--green-600); }
.toast.error { background: var(--danger); }
@keyframes toastIn { from { transform: translateY(14px); opacity: 0; } }

/* ---------- Buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 700; font-size: 15px; padding: 12px 20px; border-radius: var(--r-md); transition: transform .12s ease, box-shadow .2s ease, background .2s ease; white-space: nowrap; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--green); color: #042e22; box-shadow: 0 6px 18px var(--green-glow); }
.btn-primary:hover { background: var(--green-600); box-shadow: 0 10px 26px var(--green-glow); }
.btn-navy { background: var(--navy); color: #fff; }
.btn-navy:hover { background: var(--navy-2); }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--green); color: var(--green-600); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { color: var(--text-2); padding: 8px 12px; }
.btn-ghost:hover { color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 26px; font-size: 16px; }
.btn-sm { padding: 8px 14px; font-size: 13px; border-radius: var(--r-sm); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; padding: 13px 14px; border: 1.5px solid var(--border); border-radius: var(--r-md);
  background: var(--surface); color: var(--text); transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 4px var(--green-glow); }
.textarea { min-height: 90px; resize: vertical; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--text-2); margin-top: 5px; }

/* ---------- Generic ---------- */
.container { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--space); }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-sm); }
.pad { padding: 20px; }
.muted { color: var(--text-2); }
.row { display: flex; align-items: center; gap: 12px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; }
.center { text-align: center; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.badge-green { background: rgba(0,194,129,.14); color: var(--green-600); }
.badge-amber { background: rgba(245,158,11,.15); color: #b45309; }
.badge-red { background: rgba(239,68,68,.14); color: var(--danger); }
.badge-navy { background: rgba(30,58,138,.12); color: var(--blue); }
.spon { background: linear-gradient(90deg,#FFD56B,#F59E0B); color: #4a2e00; }
.empty { text-align: center; padding: 60px 20px; color: var(--text-2); }
.empty .big { font-size: 48px; margin-bottom: 8px; }
.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; border-radius: var(--r-md); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================================================
   PUBLIC MARKETPLACE
   ============================================================ */
.pub-header { position: sticky; top: 0; z-index: 50; background: var(--navy); color: #fff; }
.pub-header .container { display: flex; align-items: center; gap: 16px; height: var(--header-h); }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 18px; color: #fff; }
.brand img { width: 38px; height: 38px; border-radius: 9px; }
.brand span b { color: var(--green); }
.search-bar { flex: 1; display: flex; max-width: 560px; background: rgba(255,255,255,.12); border-radius: 999px; padding: 4px 4px 4px 16px; }
.search-bar input { flex: 1; background: transparent; border: none; color: #fff; outline: none; }
.search-bar input::placeholder { color: rgba(255,255,255,.6); }
.search-bar button { background: var(--green); color: #042e22; border-radius: 999px; padding: 9px 18px; font-weight: 700; }
.pub-nav { display: flex; align-items: center; gap: 6px; }
.pub-nav a, .pub-nav button { color: #fff; padding: 9px 14px; border-radius: var(--r-md); font-weight: 600; font-size: 14px; display: inline-flex; gap: 7px; align-items: center; }
.pub-nav a:hover, .pub-nav button:hover { background: rgba(255,255,255,.1); }
.cart-link { position: relative; }
.cart-count { position: absolute; top: 0; right: 0; background: var(--green); color: #042e22; font-size: 11px; font-weight: 800; min-width: 18px; height: 18px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; }

.hero { background: linear-gradient(120deg, var(--navy), var(--blue)); color: #fff; padding: 46px 0 54px; position: relative; overflow: hidden; }
.hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 320px; height: 320px; background: radial-gradient(circle, var(--green-glow), transparent 70%); }
.hero h1 { font-size: clamp(26px, 4vw, 44px); font-weight: 900; max-width: 640px; line-height: 1.12; }
.hero p { margin-top: 12px; font-size: 17px; opacity: .9; max-width: 520px; }
.hero .cta { margin-top: 22px; display: flex; gap: 12px; flex-wrap: wrap; }

.section { padding: 26px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-head h2 { font-size: 20px; font-weight: 800; }
.chips { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 6px; -webkit-overflow-scrolling: touch; }
.chip { white-space: nowrap; padding: 8px 16px; border-radius: 999px; background: var(--surface); border: 1.5px solid var(--border); font-weight: 600; font-size: 14px; color: var(--text-2); transition: all .15s; }
.chip:hover { border-color: var(--green); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* Product grid + animated cards */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.p-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow-sm); transition: transform .18s ease, box-shadow .25s ease; display: flex; flex-direction: column; animation: cardIn .4s ease both; }
.p-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); }
@keyframes cardIn { from { opacity: 0; transform: translateY(14px); } }
.p-thumb { position: relative; aspect-ratio: 1/1; background: var(--surface-2); overflow: hidden; }
.p-thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.p-card:hover .p-thumb img { transform: scale(1.07); }
.p-thumb .ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 40px; color: var(--text-2); }
.p-thumb .spon-tag { position: absolute; top: 8px; left: 8px; font-size: 11px; }
.p-body { padding: 12px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.p-name { font-weight: 700; font-size: 14px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 36px; }
.p-shop { font-size: 12px; color: var(--text-2); display: flex; gap: 5px; align-items: center; }
.p-price { font-weight: 900; font-size: 18px; color: var(--green-600); margin-top: 2px; }
.p-actions { margin-top: 8px; }

/* shops strip */
.shops-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px,1fr)); gap: 14px; }
.shop-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; text-align: center; transition: transform .15s, box-shadow .2s; }
.shop-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.shop-logo { width: 60px; height: 60px; border-radius: 16px; margin: 0 auto 10px; object-fit: cover; background: var(--surface-2); display: grid; place-items: center; font-size: 26px; font-weight: 800; color: var(--green-600); }

/* storefront banner */
.store-banner { height: 200px; border-radius: var(--r-lg); background: linear-gradient(120deg, var(--navy), var(--blue)); position: relative; overflow: hidden; margin-top: 20px; }
.store-banner img { width: 100%; height: 100%; object-fit: cover; }
.store-meta { display: flex; gap: 16px; align-items: center; margin: -40px 0 10px; padding: 0 20px; position: relative; }
.store-meta .shop-logo { width: 90px; height: 90px; border: 4px solid var(--surface); box-shadow: var(--shadow-md); }

/* product detail */
.pdp { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; }
.pdp-img { aspect-ratio: 1/1; border-radius: var(--r-lg); overflow: hidden; background: var(--surface-2); }
.pdp-img img { width: 100%; height: 100%; object-fit: cover; }
.pdp h1 { font-size: 26px; font-weight: 800; }
.pdp .price { font-size: 32px; font-weight: 900; color: var(--green-600); margin: 12px 0; }

/* cart / checkout */
.line-item { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid var(--border); align-items: center; }
.line-item img, .line-item .ph { width: 64px; height: 64px; border-radius: var(--r-md); object-fit: cover; background: var(--surface-2); display: grid; place-items: center; }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--border); border-radius: 999px; overflow: hidden; }
.qty button { width: 32px; height: 32px; font-weight: 800; color: var(--text); }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.summary { position: sticky; top: 84px; }
.bank-box { background: var(--surface-2); border: 1.5px dashed var(--green); border-radius: var(--r-md); padding: 16px; }
.bank-box .num { font-size: 22px; font-weight: 900; letter-spacing: 1px; color: var(--text); }

.footer { background: var(--navy); color: rgba(255,255,255,.8); padding: 36px 0; margin-top: 40px; }
.footer a { color: rgba(255,255,255,.8); } .footer a:hover { color: var(--green); }

/* ============================================================
   OWNER APP (dashboard, etc.)
   ============================================================ */
.app-shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: var(--navy); color: #fff; padding: 18px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar .brand { margin-bottom: 22px; padding: 0 8px; }
.side-shop { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.07); padding: 10px; border-radius: var(--r-md); margin-bottom: 16px; }
.side-shop .shop-logo { width: 40px; height: 40px; border-radius: 10px; font-size: 16px; }
.side-shop .nm { font-weight: 700; font-size: 14px; }
.side-shop .pl { font-size: 11px; color: rgba(255,255,255,.6); text-transform: capitalize; }
.nav-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--r-md); color: rgba(255,255,255,.78); font-weight: 600; font-size: 15px; margin-bottom: 2px; width: 100%; }
.nav-item .ic { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--green); color: #042e22; box-shadow: 0 6px 16px var(--green-glow); }
.nav-sep { height: 1px; background: rgba(255,255,255,.1); margin: 12px 6px; }

.main { padding: 0 0 80px; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 30; background: var(--surface); border-bottom: 1px solid var(--border); height: var(--header-h); display: flex; align-items: center; gap: 14px; padding: 0 22px; }
.topbar h1 { font-size: 19px; font-weight: 800; }
.content { padding: 22px; max-width: 1100px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px,1fr)); gap: 16px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 18px; box-shadow: var(--shadow-sm); }
.stat .lbl { font-size: 13px; color: var(--text-2); font-weight: 600; }
.stat .val { font-size: 26px; font-weight: 900; margin-top: 6px; }
.stat .val.green { color: var(--green-600); } .stat .val.blue { color: var(--blue); }
.stat .ic { float: right; font-size: 26px; opacity: .9; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 14px; }
.quick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 22px; text-align: center; transition: transform .15s, box-shadow .2s; box-shadow: var(--shadow-sm); }
.quick:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.quick .ic { font-size: 34px; }
.quick .t { font-weight: 700; margin-top: 8px; font-size: 14px; }

.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-2); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.tbl td { padding: 12px; border-bottom: 1px solid var(--border); font-size: 14px; }
.tbl tr:hover td { background: var(--surface-2); }
.tbl .thumb { width: 42px; height: 42px; border-radius: 9px; object-fit: cover; background: var(--surface-2); display:grid; place-items:center; }

/* POS */
.pos { display: grid; grid-template-columns: 1fr 360px; gap: 18px; align-items: start; }
.pos-cart { position: sticky; top: 84px; }
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar { display: flex; align-items: center; gap: 8px; }
.bar .track { flex: 1; height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.bar .fill { height: 100%; background: var(--green); border-radius: 999px; }

/* image picker */
.img-picker { border: 2px dashed var(--border); border-radius: var(--r-md); padding: 16px; text-align: center; cursor: pointer; transition: border-color .15s; }
.img-picker:hover { border-color: var(--green); }
.img-picker img { width: 110px; height: 110px; object-fit: cover; border-radius: var(--r-md); margin: 0 auto 8px; }

/* modal */
.modal-overlay { position: fixed; inset: 0; background: rgba(10,20,40,.55); backdrop-filter: blur(4px); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; animation: fade .2s ease; }
@keyframes fade { from { opacity: 0; } }
.modal { background: var(--surface); border-radius: var(--r-lg); width: min(560px, 100%); max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow-lg); animation: cardIn .25s ease; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.modal-head h3 { font-size: 18px; font-weight: 800; }
.modal-body { padding: 20px; }
.modal-foot { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; position: sticky; bottom: 0; background: var(--surface); }

/* auth */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.auth-aside { background: linear-gradient(150deg, var(--navy), var(--blue)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.auth-aside::after { content:""; position:absolute; bottom:-100px; left:-60px; width:340px; height:340px; background: radial-gradient(circle,var(--green-glow),transparent 70%); }
.auth-aside .brand { font-size: 24px; margin-bottom: 24px; }
.auth-aside h2 { font-size: 30px; font-weight: 900; line-height: 1.15; max-width: 420px; }
.auth-aside ul { margin-top: 22px; list-style: none; display: flex; flex-direction: column; gap: 12px; }
.auth-aside li { display: flex; gap: 10px; align-items: center; opacity: .92; }
.auth-aside li .ic { color: var(--green); font-weight: 900; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: min(420px, 100%); }
.auth-card h1 { font-size: 26px; font-weight: 900; }
.auth-card .sub { color: var(--text-2); margin: 6px 0 22px; }
.auth-switch { text-align: center; margin-top: 16px; color: var(--text-2); font-size: 14px; }
.auth-switch a { color: var(--green-600); font-weight: 700; }

/* mobile bottom nav (owner) */
.bottom-nav { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 920px) {
  .pdp { grid-template-columns: 1fr; }
  .pos { grid-template-columns: 1fr; }
  .pos-cart { position: static; }
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-aside { display: none; }
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding-bottom: 76px; }
  .checkout-grid { grid-template-columns: 1fr !important; }
  .bottom-nav {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 60;
    background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px;
    justify-content: space-around; box-shadow: 0 -4px 20px rgba(0,0,0,.08);
  }
  .bottom-nav a { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; color: var(--text-2); padding: 6px 10px; border-radius: var(--r-md); flex:1; }
  .bottom-nav a .ic { font-size: 20px; }
  .bottom-nav a.active { color: var(--green-600); }
}
@media (max-width: 620px) {
  .field-row { grid-template-columns: 1fr; }
  .pub-nav .label-hide { display: none; }
  .search-bar { order: 3; flex-basis: 100%; max-width: none; }
  .pub-header .container { flex-wrap: wrap; height: auto; padding-top: 10px; padding-bottom: 10px; gap: 10px; }
  .product-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .content { padding: 16px; }
  .hero { padding: 32px 0 38px; }
}
