/* Bihari Ji Enterprises — Distributor Order Portal */

:root {
  --navy: #0f2c4c;
  --navy-soft: #1d4266;
  --navy-deep: #0a1f36;
  --gold: #c8961e;
  --gold-soft: #e0b552;
  --ink: #16212c;
  --muted: #5b6b7b;
  --line: #dde4ec;
  --line-soft: #eaeff5;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ok: #17794a;
  --warn: #9a6300;
  --danger: #b3261e;

  --topbar-h: 62px;
  --sidebar-w: 268px;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 44, 76, .06), 0 1px 3px rgba(15, 44, 76, .08);
  --shadow-lg: 0 18px 48px rgba(10, 31, 54, .22);
  --font: "Segoe UI", Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Several elements below set `display`, which would otherwise beat the user
   agent's `[hidden] { display: none }` and leave them permanently visible. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

.muted { color: var(--muted); }
.ta-right { text-align: right; }
.ta-center { text-align: center; }

/* ── Topbar ─────────────────────────────────────────────────────────────── */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-text small {
  font-size: 11.5px;
  color: #a9bdd1;
  white-space: nowrap;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.price-badge {
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(224, 181, 82, .45);
  background: rgba(200, 150, 30, .16);
  color: var(--gold-soft);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  white-space: nowrap;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.icon-btn:hover { background: rgba(255, 255, 255, .12); }

.cart-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 14px;
  border: 0;
  border-radius: 9px;
  background: linear-gradient(150deg, var(--gold-soft), var(--gold));
  color: var(--navy-deep);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(200, 150, 30, .3);
}

.cart-btn:hover { filter: brightness(1.06); }
.cart-btn svg { width: 18px; height: 18px; }

.pill {
  display: grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--navy-deep);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.cart-total {
  padding-left: 9px;
  border-left: 1px solid rgba(10, 31, 54, .25);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  align-items: flex-start;
  min-height: calc(100vh - var(--topbar-h));
}

.sidebar {
  position: sticky;
  top: var(--topbar-h);
  width: var(--sidebar-w);
  flex: none;
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
  padding: 14px 14px 10px;
}

.search-wrap > svg {
  position: absolute;
  left: 25px;
  width: 17px;
  height: 17px;
  color: var(--muted);
  pointer-events: none;
}

.search-wrap input {
  width: 100%;
  padding: 10px 30px 10px 36px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}

.search-wrap input:focus {
  outline: none;
  border-color: var(--navy-soft);
  box-shadow: 0 0 0 3px rgba(29, 66, 102, .12);
}

.search-clear {
  position: absolute;
  right: 22px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: var(--line-soft);
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}

.cat-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 20px;
}

.cat-group-title {
  margin: 14px 0 6px;
  padding: 0 8px;
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.cat-link {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  font-size: 13.5px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.cat-link:hover { background: var(--line-soft); }

.cat-link.active {
  background: var(--navy);
  color: #fff;
  font-weight: 600;
}

.cat-link .count {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cat-link.active .count { color: #a9bdd1; }

.main {
  flex: 1;
  min-width: 0;
  padding: 22px 24px 80px;
}

.main-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.main-head h1 {
  margin: 0 0 3px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -.2px;
}

.main-head p { margin: 0; font-size: 13px; }

.unlimited-note {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid #cfe6d8;
  border-radius: 999px;
  background: #eef8f2;
  color: var(--ok);
  font-size: 12.5px;
  font-weight: 600;
}

.unlimited-note svg { width: 16px; height: 16px; }

/* ── Product list ───────────────────────────────────────────────────────── */

.table-head,
.product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 150px 108px;
  align-items: center;
  gap: 14px;
}

.table-head {
  padding: 0 16px 8px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--muted);
}

.product-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.product-row {
  padding: 11px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.product-row.in-cart {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold) inset, var(--shadow-sm);
}

.p-name {
  min-width: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.p-cat {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.p-price {
  text-align: right;
  font-size: 15.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
  white-space: nowrap;
}

.p-price small {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .6px;
  color: var(--muted);
  text-transform: uppercase;
}

.qty {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  overflow: hidden;
  background: #fbfcfe;
}

.qty button {
  width: 34px;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--navy);
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
}

.qty button:hover { background: var(--line-soft); }
.qty button:disabled { color: #b7c2cd; cursor: not-allowed; }

.qty input {
  width: 100%;
  min-width: 0;
  height: 36px;
  border: 0;
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink);
  -moz-appearance: textfield;
}

.qty input::-webkit-outer-spin-button,
.qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty input:focus { outline: none; background: #fff; }

.add-btn {
  height: 36px;
  border: 1px solid var(--navy);
  border-radius: 9px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.add-btn:hover { background: var(--navy-soft); }

.add-btn.added {
  background: #eef8f2;
  border-color: #b7ddc7;
  color: var(--ok);
}

.sentinel { height: 1px; }

.empty-state {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
}

.load-note {
  padding: 14px;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

/* ── Drawer ─────────────────────────────────────────────────────────────── */

.drawer-backdrop,
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(10, 31, 54, .45);
  backdrop-filter: blur(1.5px);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  width: min(430px, 100vw);
  height: 100dvh;
  background: var(--bg);
  box-shadow: var(--shadow-lg);
  transform: translateX(101%);
  transition: transform .22s ease;
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--navy);
  color: #fff;
  border-bottom: 3px solid var(--gold);
}

.drawer-head h2 { margin: 0; font-size: 17px; font-weight: 700; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px 20px;
}

.cart-empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--muted);
}

.cart-empty svg { width: 38px; height: 38px; margin-bottom: 12px; color: #b7c2cd; }
.cart-empty p { margin: 0 0 4px; font-weight: 600; color: var(--ink); }
.cart-empty span { font-size: 13px; }

.cart-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cart-item {
  padding: 11px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.cart-item-top {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.cart-item-name {
  flex: 1;
  min-width: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.cart-item-name small {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}

.remove-btn {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.remove-btn:hover { background: #fdecea; color: var(--danger); }
.remove-btn svg { width: 15px; height: 15px; }

.cart-item-bot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 9px;
}

.cart-item-bot .qty { width: 128px; }
.cart-item-bot .qty button { width: 30px; height: 32px; }
.cart-item-bot .qty input { height: 32px; }

.cart-item-sub {
  text-align: right;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}

.cart-item-sub small {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

.checkout h3 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.field { margin-bottom: 11px; }

.field label {
  display: block;
  margin-bottom: 4px;
  font-size: 12.5px;
  font-weight: 600;
}

.field label span { color: var(--danger); }
.field label small { font-weight: 500; color: var(--muted); }

.field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  font: inherit;
  font-size: 14px;
  color: var(--ink);
}

.field input:focus {
  outline: none;
  border-color: var(--navy-soft);
  box-shadow: 0 0 0 3px rgba(29, 66, 102, .12);
}

.field input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(179, 38, 30, .1);
}

.form-error {
  margin: 8px 0 0;
  padding: 9px 11px;
  border: 1px solid #f2c9c6;
  border-radius: 8px;
  background: #fdecea;
  color: var(--danger);
  font-size: 13px;
}

.drawer-foot {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
}

.totals { margin: 0 0 12px; }

.totals > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 3px 0;
  font-size: 13.5px;
}

.totals dt { color: var(--muted); }

.totals dd {
  margin: 0;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.totals .grand {
  margin-top: 7px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}

.totals .grand dt { font-size: 14px; font-weight: 700; color: var(--ink); }
.totals .grand dd { font-size: 19px; font-weight: 800; color: var(--navy); }

.place-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 13px;
  border: 0;
  border-radius: 10px;
  background: var(--navy);
  color: #fff;
  font: inherit;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
}

.place-btn:hover:not(:disabled) { background: var(--navy-soft); }

.place-btn:disabled {
  background: #b7c2cd;
  cursor: not-allowed;
}

.spinner {
  display: none;
  width: 17px;
  height: 17px;
  border: 2.5px solid rgba(255, 255, 255, .35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

.place-btn.busy .spinner { display: block; }

@keyframes spin { to { transform: rotate(360deg); } }

.foot-note {
  margin: 9px 0 0;
  font-size: 11.5px;
  line-height: 1.4;
  text-align: center;
  color: var(--muted);
}

/* ── Result overlay ─────────────────────────────────────────────────────── */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 31, 54, .55);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}

.result-card {
  width: min(470px, 100%);
  padding: 30px 26px 24px;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.result-icon {
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  margin: 0 auto 16px;
  border-radius: 50%;
}

.result-icon svg { width: 30px; height: 30px; stroke-width: 2.4; }
.result-icon.ok { background: #eef8f2; color: var(--ok); }
.result-icon.warn { background: #fff6e6; color: var(--warn); }
.result-icon.err { background: #fdecea; color: var(--danger); }

.result-card h2 {
  margin: 0 0 6px;
  font-size: 21px;
  font-weight: 700;
}

.result-card > p {
  margin: 0 0 16px;
  font-size: 14px;
  color: var(--muted);
}

.order-no {
  margin: 0 0 18px;
  padding: 14px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  background: #fbfcfe;
}

.order-no span {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--muted);
}

.order-no strong {
  display: block;
  margin-top: 3px;
  font-size: 29px;
  font-weight: 800;
  letter-spacing: 1.5px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}

.result-steps {
  margin: 0 0 18px;
  padding: 14px 16px;
  border-radius: 10px;
  background: #fff6e6;
  border: 1px solid #f2dcae;
  text-align: left;
  font-size: 13.5px;
  color: #6b4a05;
}

.result-steps ol { margin: 8px 0 0; padding-left: 20px; }
.result-steps li { margin-bottom: 4px; }

.result-actions {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn:hover { background: var(--line-soft); }

.btn-primary {
  background: #1faa53;
  border-color: #1faa53;
  color: #fff;
}

.btn-primary:hover { background: #1b9449; }

.btn-dark {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.btn-dark:hover { background: var(--navy-soft); }

/* ── Responsive ─────────────────────────────────────────────────────────── */

.only-mobile { display: none; }

@media (max-width: 1000px) {
  .table-head,
  .product-row { grid-template-columns: minmax(0, 1fr) 104px 132px 96px; gap: 10px; }
}

@media (max-width: 820px) {
  .only-mobile { display: grid; }
  .price-badge { display: none; }
  .cart-btn-label { display: none; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 60;
    height: 100dvh;
    transform: translateX(-101%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open { transform: translateX(0); }

  .main { padding: 16px 14px 70px; }

  .table-head { display: none; }

  .product-row {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name  price"
      "qty   add";
    row-gap: 11px;
    padding: 13px 14px;
  }

  .p-name { grid-area: name; }
  .p-price { grid-area: price; }
  .qty { grid-area: qty; width: 138px; }
  .add-btn { grid-area: add; padding: 0 20px; }
}

@media (max-width: 420px) {
  .brand-text small { display: none; }
  .cart-total { display: none; }
  .main-head { align-items: flex-start; }
}
