/* ============================================================
   ZERO-COMMISSION MULTI-STORE MARKETPLACE — design system
   Light-first, one primary blue action colour, green success,
   amber warning, red error (per product blueprint Appendix B).
   ============================================================ */
:root {
  --primary: #2456e6;
  --primary-dark: #1a3fb0;
  --primary-soft: #e8eefc;
  --ink: #16202e;
  --muted: #64748b;
  --line: #e4e8ef;
  --bg: #f4f6fa;
  --card: #ffffff;
  --success: #15803d; --success-bg: #e5f5ec;
  --warn: #b45309;    --warn-bg: #fdf3e2;
  --danger: #dc2626;  --danger-bg: #fdecec;
  --info: #475569;    --info-bg: #edf1f6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(22,32,46,.06), 0 8px 24px -18px rgba(22,32,46,.25);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); color: var(--ink); background: var(--bg);
  font-size: 15px; line-height: 1.55; min-height: 100vh; display: flex; flex-direction: column;
}
img { max-width: 100%; display: block; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.25; margin: 0 0 .5rem; }
h2 { font-size: 1.25rem; } h3 { font-size: 1.05rem; }
p { margin: .35rem 0; }
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.tiny { font-size: .75rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.skip-link { position: absolute; left: -999px; top: 0; background: #fff; padding: 8px 14px; z-index: 99; }
.skip-link:focus { left: 8px; top: 8px; }

/* ---------- top navigation (public + customer) ---------- */
.topnav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40; }
.topnav-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 58px; }
.topnav-links { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.topnav-links a { color: var(--ink); font-weight: 500; }
.topnav-links a.is-active { color: var(--primary); }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.06rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-mark { background: var(--primary); color: #fff; width: 30px; height: 30px; border-radius: 9px; display: inline-flex; align-items: center; justify-content: center; font-size: .95rem; }
.cart-pill { background: var(--primary); color: #fff; border-radius: 99px; font-size: .72rem; padding: 1px 7px; vertical-align: 2px; }

/* ---------- app shell (store / rider / admin) ---------- */
.app { display: flex; min-height: 100vh; flex: 1; }
.sidebar { width: 232px; background: #101a2c; color: #dbe4f0; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; flex-shrink: 0; }
.sidebar .brand { color: #fff; padding: 16px; }
.sidebar-foot { margin-top: auto; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }
.whoami { display: flex; flex-direction: column; font-size: .78rem; margin-bottom: 10px; color: #9fb0c8; }
.whoami strong { color: #fff; font-size: .84rem; }
.sidenav { padding: 6px 10px 16px; overflow-y: auto; }
.sidenav-link { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px; color: #c7d2e2; font-size: .9rem; margin-bottom: 2px; }
.sidenav-link:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.sidenav-link.is-active { background: var(--primary); color: #fff; }
.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: #fff; border-bottom: 1px solid var(--line); padding: 10px 20px; display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; }
.topbar-title { font-size: 1.02rem; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.content { flex: 1; padding: 20px 0 34px; }
.app-main .content { padding: 20px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; cursor: pointer; font-size: 1rem; }

/* ---------- bottom nav (mobile PWA feel) ---------- */
.bottomnav { display: none; position: fixed; bottom: 0; left: 0; right: 0; background: #fff; border-top: 1px solid var(--line); z-index: 45; padding-bottom: env(safe-area-inset-bottom); }
.bottomnav-link { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .68rem; color: var(--muted); padding: 7px 2px 8px; }
.bottomnav-link.is-active { color: var(--primary); font-weight: 600; }
.bottomnav-link span[aria-hidden] { font-size: 1.15rem; }
@media (max-width: 860px) {
  .bottomnav { display: flex; }
  .sidebar { display: none; }
  .app { display: block; }
  .app-main .content { padding: 14px 12px 90px; }
  .content { padding-bottom: 90px; }
  .only-mobile { display: inline-flex !important; }
  .topnav-links { display: none; }
  body { padding-bottom: 0; }
}
.only-mobile { display: none; }

/* ---------- cards / grids ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 14px; }
.card-tight { padding: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }
.split { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
@media (max-width: 900px) { .split { grid-template-columns: 1fr; } }

/* ---------- kpi ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
@media (max-width: 900px) { .kpi-grid { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; display: block; color: inherit; }
.kpi:hover { text-decoration: none; border-color: var(--primary); }
.kpi .kpi-label { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.kpi .kpi-value { font-size: 1.5rem; font-weight: 800; margin-top: 2px; }
.kpi .kpi-sub { color: var(--muted); font-size: .76rem; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 9px 16px; font-size: .9rem; font-weight: 600; cursor: pointer; font-family: inherit; line-height: 1.2; min-height: 40px; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger-outline { background: #fff; border-color: #f3c1c1; color: var(--danger); }
.btn-success { background: var(--success); color: #fff; }
.btn-sm { padding: 6px 12px; min-height: 32px; font-size: .82rem; }
.btn-lg { padding: 13px 22px; font-size: 1rem; }
.btn-block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.link-danger { color: var(--danger); }

/* ---------- forms ---------- */
label { font-weight: 600; font-size: .84rem; display: block; margin-bottom: 4px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  padding: 9px 12px; font-size: .92rem; font-family: inherit; color: var(--ink); min-height: 40px;
}
.textarea { min-height: 90px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: 14px; }
.field .hint { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 620px) { .form-grid { grid-template-columns: 1fr; } }
.req::after { content: " *"; color: var(--danger); }
.err-summary { background: var(--danger-bg); border: 1px solid #f3c1c1; color: var(--danger); border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 14px; font-size: .88rem; }

/* ---------- badges & chips ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 3px 10px; font-size: .74rem; font-weight: 700; white-space: nowrap; }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.chip { display: inline-block; border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 6px 14px; font-size: .84rem; color: var(--ink); cursor: pointer; }
.chip:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.chip.is-active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table.table { width: 100%; border-collapse: collapse; font-size: .88rem; min-width: 560px; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafbfd; }
.table td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: #f8fafd; }

/* ---------- store & product cards ---------- */
.store-card { display: flex; gap: 14px; align-items: center; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.store-card:hover { border-color: var(--primary); }
.store-logo { width: 54px; height: 54px; border-radius: 12px; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-weight: 800; color: var(--primary); font-size: 1.2rem; overflow: hidden; flex-shrink: 0; }
.store-logo img { width: 100%; height: 100%; object-fit: cover; }
.store-card-body { flex: 1; min-width: 0; }
.store-card-body h3 { margin: 0; font-size: .98rem; }
.product-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; transition: box-shadow .15s; }
.product-card:hover { box-shadow: var(--shadow); border-color: #cdd6e4; }
.product-img { aspect-ratio: 4/3; background: #eef2f7; display: flex; align-items: center; justify-content: center; color: #b6c2d2; font-size: 2rem; overflow: hidden; }
.product-img img { width: 100%; height: 100%; object-fit: cover; }
.product-card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.product-card-body h3 { font-size: .92rem; margin: 0; }
.price { font-weight: 800; font-size: 1.02rem; }
.price-mrp { color: var(--muted); text-decoration: line-through; font-weight: 400; font-size: .82rem; margin-left: 6px; }
.cat-tile { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 14px; font-weight: 600; color: var(--ink); display: flex; align-items: center; gap: 10px; }
.cat-tile:hover { border-color: var(--primary); color: var(--primary); text-decoration: none; }
.cat-tile .em { font-size: 1.3rem; }

/* ---------- banner / hero ---------- */
.hero { background: linear-gradient(120deg, #101a2c 0%, #1c2f52 100%); color: #fff; border-radius: var(--radius); padding: 34px 28px; }
.hero h1 { font-size: 1.7rem; margin-bottom: 6px; }
.hero p { color: #c3cfe2; max-width: 560px; }
.loc-banner { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- flash / toast ---------- */
.flash { border-radius: var(--radius-sm); padding: 11px 16px; margin: 0 0 14px; font-size: .9rem; font-weight: 500; border: 1px solid; }
.flash-success { background: var(--success-bg); color: var(--success); border-color: #bfe5cd; }
.flash-error { background: var(--danger-bg); color: var(--danger); border-color: #f3c1c1; }
.flash-info { background: var(--info-bg); color: var(--info); border-color: #d4dce6; }
.toast { position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px); background: #101a2c; color: #fff; padding: 11px 20px; border-radius: 99px; font-size: .88rem; opacity: 0; pointer-events: none; transition: all .25s; z-index: 90; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 9px 16px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tab:hover { color: var(--primary); text-decoration: none; }
.tab.is-active { color: var(--primary); border-bottom-color: var(--primary); }
.tab .count { background: var(--primary-soft); color: var(--primary); border-radius: 99px; padding: 0 7px; font-size: .74rem; margin-left: 4px; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: -2px; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; left: 0; top: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--primary); border: 3px solid var(--primary-soft); }
.timeline .dot.done { background: var(--success); border-color: var(--success-bg); }

/* ---------- misc ---------- */
.empty { text-align: center; padding: 42px 20px; color: var(--muted); }
.empty .em { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager-link { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 5px 11px; font-size: .84rem; }
.pager-link:hover { border-color: var(--primary); text-decoration: none; }
.pager-cur { background: var(--primary); color: #fff; border-color: var(--primary); }
.pager-cur:hover { color: #fff; }
.footer { background: #fff; border-top: 1px solid var(--line); margin-top: auto; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; padding: 16px; font-size: .8rem; color: var(--muted); flex-wrap: wrap; }
.footer-links a { margin-left: 14px; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; accent-color: var(--primary); }
.inline-form { display: inline; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.w-100 { width: 100%; }
.otp-box { font-size: 2rem; font-weight: 800; letter-spacing: .35em; background: var(--primary-soft); color: var(--primary); border-radius: var(--radius-sm); padding: 12px 18px 12px 26px; display: inline-block; }
.notice { background: var(--warn-bg); border: 1px solid #f2ddb5; color: var(--warn); border-radius: var(--radius-sm); padding: 11px 16px; font-size: .88rem; }
.notice-blue { background: var(--primary-soft); border: 1px solid #c9d8f8; color: var(--primary-dark); border-radius: var(--radius-sm); padding: 11px 16px; font-size: .88rem; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; }
.chat-msg { max-width: 72%; padding: 9px 14px; border-radius: 14px; margin-bottom: 8px; font-size: .9rem; }
.chat-them { background: #eef1f6; border-bottom-left-radius: 4px; }
.chat-me { background: var(--primary); color: #fff; border-bottom-right-radius: 4px; margin-left: auto; }
.chat-row { display: flex; }
.chat-meta { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.chat-me .chat-meta { color: #cfe0ff; }
.progress-steps { display: flex; gap: 6px; flex-wrap: wrap; }
dialog { border: 0; border-radius: var(--radius); box-shadow: 0 24px 60px -12px rgba(0,0,0,.35); padding: 22px; width: min(480px, 92vw); }
dialog::backdrop { background: rgba(16,26,44,.5); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }

/* ---------- print (invoice) ---------- */
@media print {
  .topnav, .bottomnav, .sidebar, .topbar, .footer, .toast, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #ccc; }
  .print-area, .print-area .content { padding: 0; }
}
