:root {
  color-scheme: light;
  --bg: #f5f5f7;
  --bg-elevated: #fbfbfd;
  --panel: #ffffff;
  --panel-soft: #f7f8fb;
  --soft: #eef2f7;
  --text: #14171f;
  --text-strong: #050816;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #e4e7ec;
  --line-strong: #d0d5dd;
  --blue: #0071e3;
  --blue-dark: #005bb8;
  --blue-soft: #e8f2ff;
  --green: #147a3f;
  --green-soft: #e9f7ee;
  --amber: #946200;
  --amber-soft: #fff4d8;
  --orange: #b45309;
  --orange-soft: #fff0df;
  --red: #b42318;
  --red-soft: #fee4e2;
  --purple: #5b44c4;
  --purple-soft: #eeeaff;
  --slate: #475467;
  --slate-soft: #eef2f6;
  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 18px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 16px 44px rgba(16, 24, 40, .08);
  --shadow-strong: 0 24px 70px rgba(16, 24, 40, .14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -20%, rgba(255, 255, 255, .9), transparent 34%),
    linear-gradient(180deg, #f8f8fa 0%, var(--bg) 38%, #f1f3f6 100%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

h1 {
  color: var(--text-strong);
  font-size: clamp(20px, 4.8vw, 26px);
  font-weight: 850;
  line-height: 1.05;
}

h2 {
  color: var(--text-strong);
  font-size: clamp(22px, 5.4vw, 30px);
  font-weight: 850;
  line-height: 1.08;
}

h3 {
  color: var(--text-strong);
  font-size: clamp(17px, 4.2vw, 20px);
  font-weight: 820;
  line-height: 1.16;
}

h4 {
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 820;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease, opacity .14s ease;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: not-allowed;
  opacity: .5;
  transform: none;
  box-shadow: none;
}

input,
textarea,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .92);
  padding: 12px 14px;
  color: var(--text-strong);
  outline: none;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
}

textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.45;
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(0, 113, 227, .72);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(0, 113, 227, .12), var(--shadow-sm);
}

main {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.hidden {
  display: none !important;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(228, 231, 236, .78);
  background: rgba(245, 245, 247, .86);
  backdrop-filter: blur(18px);
}

.topbar > div:nth-child(2) {
  min-width: 0;
}

.home-btn,
.orders-btn,
.cart-btn,
.ghost,
.small-btn,
.video-btn,
.primary,
.success,
.warning,
.danger,
.admin-login button,
.search-row button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: var(--radius);
  padding: 0 15px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.home-btn,
.orders-btn,
.cart-btn,
.ghost {
  border: 1px solid rgba(228, 231, 236, .95);
  background: rgba(255, 255, 255, .88);
  color: var(--text-strong);
  box-shadow: var(--shadow-sm);
}

.home-btn {
  border-radius: 999px;
}

.quick-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.quick-actions .orders-btn,
.quick-actions .cart-btn {
  min-height: 54px;
  border-radius: var(--radius-lg);
  font-size: 16px;
}

.cart-btn b {
  display: grid;
  min-width: 25px;
  height: 25px;
  place-items: center;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 6px 16px rgba(0, 113, 227, .22);
}

.primary,
.search-row button,
.admin-login button {
  background: var(--blue);
  color: #fff;
  box-shadow: 0 12px 28px rgba(0, 113, 227, .18);
}

.primary:hover,
.search-row button:hover,
.admin-login button:hover {
  background: var(--blue-dark);
}

.success {
  background: var(--green);
  color: #fff;
  box-shadow: 0 12px 28px rgba(20, 122, 63, .16);
}

.warning {
  background: var(--orange);
  color: #fff;
  box-shadow: 0 12px 28px rgba(180, 83, 9, .15);
}

.danger {
  background: var(--red);
  color: #fff;
  box-shadow: 0 12px 28px rgba(180, 35, 24, .15);
}

.small-btn {
  min-height: 40px;
  border: 1px solid rgba(0, 113, 227, .13);
  background: var(--blue-soft);
  color: var(--blue);
  padding: 0 13px;
  border-radius: 12px;
  box-shadow: none;
}

.remove-btn {
  border-color: rgba(180, 35, 24, .14);
  background: var(--red-soft);
  color: var(--red);
}

.link-btn {
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
}

.search-panel,
.card,
.summary-box,
.admin-login,
.admin-panel,
.notice,
.kpi {
  border: 1px solid rgba(228, 231, 236, .9);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .92);
  box-shadow: var(--shadow);
}

.search-panel {
  padding: 18px;
}

.search-panel label,
.field label {
  display: block;
  margin-bottom: 8px;
  color: var(--slate);
  font-size: 13px;
  font-weight: 780;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 86px;
  gap: 10px;
}

.result-area {
  margin-top: 14px;
}

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin: 24px 0 12px;
}

.eyebrow {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
}

.desc {
  margin-top: 8px;
  color: var(--muted);
  line-height: 1.46;
  overflow-wrap: anywhere;
}

.product-list,
.stack,
.summary-grid {
  display: grid;
  gap: 11px;
}

.card {
  padding: 15px;
}

.product-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
}

.product-main {
  min-width: 0;
}

.code {
  color: var(--text-strong);
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
}

.price {
  margin-top: 6px;
  color: var(--text-strong);
  font-size: 19px;
  font-weight: 880;
}

.featured-result {
  border-color: rgba(0, 113, 227, .42);
  background: linear-gradient(180deg, #ffffff 0%, #f7fbff 100%);
  box-shadow: 0 20px 58px rgba(0, 113, 227, .13);
}

.result-label {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  padding: 0 9px;
  margin-bottom: 8px;
  background: var(--blue);
  color: #fff;
  font-size: 12px;
  font-weight: 850;
}

.meta-row,
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 12px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 29px;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 850;
}

.available { background: var(--green-soft); color: var(--green); }
.held { background: var(--amber-soft); color: var(--amber); }
.awaiting_payment { background: var(--blue-soft); color: var(--blue); }
.pending { background: var(--blue-soft); color: var(--blue); }
.cod_approved { background: var(--blue-soft); color: var(--blue); }
.deposited { background: var(--purple-soft); color: var(--purple); }
.paid { background: var(--green-soft); color: var(--green); }
.issue { background: var(--orange-soft); color: var(--orange); }
.price_issue { background: var(--orange-soft); color: var(--orange); }
.cancelled { background: var(--red-soft); color: var(--red); }
.sold,
.exported { background: var(--slate-soft); color: var(--slate); }

.video-btn {
  min-height: 36px;
  border-radius: 999px;
  padding: 0 13px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  box-shadow: 0 12px 24px rgba(17, 24, 39, .16);
}

.notice {
  padding: 13px;
  box-shadow: none;
}

.notice.soft {
  background: var(--slate-soft);
}

.cart-warning {
  background: var(--blue-soft);
  border-color: rgba(0, 113, 227, .2);
}

.empty-state {
  text-align: center;
  padding: 20px;
}

.summary-box {
  margin-top: 14px;
  padding: 16px;
}

.summary-line {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.summary-line:last-child {
  border-bottom: 0;
}

.summary-line span {
  min-width: 0;
}

.summary-line strong {
  color: var(--text-strong);
  font-size: 16px;
  font-weight: 850;
  text-align: right;
}

.checkout-grid {
  display: grid;
  gap: 12px;
}

.checkout-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 6px;
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}

.checkout-steps span {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 830;
  text-align: center;
}

.checkout-steps span.active {
  background: var(--blue-soft);
  color: var(--blue);
}

.choice-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.choice {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 13px;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.choice input {
  width: auto;
  min-height: auto;
  box-shadow: none;
}

.choice:has(input:checked) {
  border-color: rgba(0, 113, 227, .58);
  background: var(--blue-soft);
}

.qr-box {
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed #c8ced8;
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, #fff, #f8fafc);
  text-align: center;
  color: var(--muted);
}

.qr-box img {
  width: min(270px, 80vw);
  max-height: 270px;
  object-fit: contain;
}

.success-screen {
  min-height: calc(100vh - 120px);
  display: grid;
  place-items: center;
  padding: 18px 0;
}

.success-card {
  width: min(540px, 100%);
}

.admin-login {
  padding: 20px;
}

.admin-login p {
  margin: 8px 0 14px;
  color: var(--muted);
}

.admin-panel {
  padding: 14px;
  box-shadow: none;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 14px 0;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  white-space: nowrap;
  min-height: 40px;
  border-radius: 999px;
  padding: 0 15px;
  background: var(--slate-soft);
  color: var(--slate);
  font-weight: 850;
}

.tab.active {
  background: var(--text-strong);
  color: #fff;
  box-shadow: 0 12px 26px rgba(17, 24, 39, .14);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--soft);
}

.segmented button {
  min-height: 42px;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 850;
}

.segmented button.active {
  color: var(--text-strong);
  background: #fff;
  box-shadow: 0 2px 10px rgba(15, 23, 42, .08);
}

.form-grid {
  display: grid;
  gap: 11px;
}

.checkline {
  display: flex;
  gap: 9px;
  align-items: center;
  color: var(--slate);
  font-weight: 760;
}

.checkline input {
  width: auto;
  min-height: auto;
  box-shadow: none;
}

.address-field {
  position: relative;
}

.suggest-list {
  display: none;
  position: absolute;
  z-index: 50;
  left: 0;
  right: 0;
  top: calc(100% + 5px);
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-strong);
  padding: 6px;
}

.suggest-list.show {
  display: block;
}

.suggest-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: #fff;
  color: var(--text);
  padding: 11px 12px;
  border-radius: 10px;
}

.suggest-item:hover {
  background: var(--soft);
}

.order-mini {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  padding: 13px;
  box-shadow: var(--shadow-sm);
}

.customer-group {
  border-color: rgba(0, 113, 227, .18);
}

.approved-block {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.approved-block h4 {
  margin-bottom: 8px;
}

.filters {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
  margin: 12px 0;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.admin-table th,
.admin-table td {
  border-bottom: 1px solid var(--line);
  padding: 11px 9px;
  text-align: left;
  vertical-align: top;
}

.admin-table th {
  color: var(--slate);
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
}

.table-wrap {
  overflow-x: auto;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.kpi {
  padding: 15px;
  box-shadow: var(--shadow-sm);
}

.kpi span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 760;
}

.kpi b {
  display: block;
  margin-top: 6px;
  color: var(--text-strong);
  font-size: 28px;
  line-height: 1;
}

.announcement-banner {
  width: min(1040px, calc(100% - 24px));
  margin: 12px auto 0;
  display: grid;
  gap: 4px;
  border: 1px solid rgba(0, 113, 227, .16);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, .9);
  color: var(--text);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}

.announcement-banner span {
  color: var(--slate);
  line-height: 1.4;
}

.announcement-banner.info {
  background: var(--blue-soft);
}

.announcement-banner.warning {
  background: var(--amber-soft);
  border-color: rgba(154, 103, 0, .22);
}

.video-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 14, 24, .48);
  display: grid;
  place-items: center;
  padding: 16px;
}

.video-dialog {
  width: min(560px, 100%);
  max-height: 88vh;
  overflow: auto;
  background: #fff;
  border: 1px solid rgba(228, 231, 236, .8);
  border-radius: var(--radius-xl);
  padding: 16px;
  box-shadow: var(--shadow-strong);
}

.video-frame {
  display: grid;
  place-items: center;
  min-height: 230px;
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 18px;
  z-index: 90;
  display: none;
  max-width: 540px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  background: rgba(17, 24, 39, .94);
  color: #fff;
  padding: 13px 15px;
  box-shadow: var(--shadow-strong);
}

.toast.show {
  display: block;
}

.toast.admin-toast {
  top: 50%;
  bottom: auto;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 32px));
  padding: 22px 24px;
  text-align: center;
  font-size: 22px;
  font-weight: 850;
  line-height: 1.35;
}

.toast.success {
  background: rgba(20, 122, 63, .96);
}

.toast.warning {
  background: rgba(148, 98, 0, .96);
}

.toast.error {
  background: rgba(180, 35, 24, .96);
}

.toast-sub {
  margin-top: 4px;
  color: rgba(255, 255, 255, .84);
  font-size: 13px;
  line-height: 1.35;
}

.toast-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.toast-actions button {
  min-height: 40px;
  border-radius: 12px;
  background: #fff;
  color: #111827;
  font-weight: 850;
}

.compact-money-field {
  margin-top: 10px;
}

.compact-money-field input {
  max-width: 190px;
}

.customer-suggest {
  display: grid;
  gap: 3px;
  text-align: left;
}

.customer-suggest span,
.history-address strong {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 650;
}

footer {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 12px 16px 28px;
  text-align: center;
}

@media (min-width: 760px) {
  main {
    padding: 24px;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
    padding: 14px 24px;
  }

  .quick-actions {
    grid-column: auto;
    display: flex;
    gap: 10px;
  }

  .quick-actions .orders-btn,
  .quick-actions .cart-btn {
    min-height: 46px;
    border-radius: 999px;
    font-size: 15px;
  }

  .form-grid.two,
  .checkout-grid.two {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .card {
    padding: 17px;
  }
}

@media (max-width: 520px) {
  main {
    padding: 12px;
  }

  .choice-grid,
  .filters,
  .product-card {
    grid-template-columns: 1fr;
  }

  .summary-line {
    align-items: flex-start;
  }

  .summary-line strong {
    font-size: 15px;
  }

  .search-row {
    grid-template-columns: 1fr 78px;
  }

  .checkout-steps {
    grid-template-columns: 1fr;
  }
}
