:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #172033;
  --muted: #667085;
  --line: #e5eaf1;
  --primary: #1769e0;
  --primary-strong: #0f56be;
  --success: #138a55;
  --danger: #c73a3a;
  --warning: #a56410;
  --shadow: 0 14px 40px rgba(20, 43, 84, .08);
  --radius: 18px;
}
* { box-sizing: border-box; }
html { direction: rtl; }
body {
  margin: 0;
  font-family: Tahoma, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
}
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.94); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner { min-height: 70px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 12px; background: var(--primary); color: #fff; font-size: 14px; }
.nav-actions { display: flex; gap: 10px; align-items: center; }
.page { padding: 32px 0 56px; }
.page-heading { margin-bottom: 22px; display: flex; align-items: end; justify-content: space-between; gap: 18px; flex-wrap: wrap; }
.page-heading h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.25; }
.page-heading p { margin: 7px 0 0; color: var(--muted); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 22px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.metric { padding: 18px; }
.metric-label { color: var(--muted); font-size: 14px; }
.metric-value { margin-top: 7px; font-size: 26px; font-weight: 800; }
.btn { border: 0; border-radius: 12px; min-height: 44px; padding: 0 17px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; font-weight: 700; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-soft { background: #eef4ff; color: #174f9d; }
.btn-danger { background: #fff0f0; color: var(--danger); }
.btn-link { color: var(--primary); padding-inline: 4px; }
.form-grid { display: grid; gap: 16px; }
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: grid; gap: 7px; }
.field label { font-weight: 700; font-size: 14px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 46px; border: 1px solid #d8dee8; border-radius: 12px; background: #fff; color: var(--text); padding: 10px 12px; outline: none;
}
.input:focus { border-color: #8bb7ef; box-shadow: 0 0 0 4px #eaf3ff; }
.checkbox-row { display: flex; align-items: center; gap: 9px; font-weight: 700; }
.alert { border-radius: 13px; padding: 13px 15px; margin-bottom: 18px; border: 1px solid; }
.alert-success { background: #edf9f2; border-color: #bde5ce; color: #12653f; }
.alert-error { background: #fff1f1; border-color: #f1caca; color: #9b2d2d; }
.alert-info { background: #eef5ff; border-color: #cbdffd; color: #204f8e; }
.table-wrap { overflow: auto; border-radius: 14px; border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; min-width: 700px; background: #fff; }
th, td { padding: 13px 14px; text-align: right; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { background: #f8fafc; color: #475467; font-size: 13px; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px; font-size: 12px; font-weight: 800; background: #f0f3f7; color: #45546b; }
.status-good { background: #eaf8f0; color: #147649; }
.status-warn { background: #fff5e6; color: #986016; }
.status-bad { background: #fff0f0; color: #ac3333; }
.store-card { padding: 20px; display: grid; gap: 14px; }
.store-card-head { display: flex; justify-content: space-between; gap: 14px; align-items: start; }
.store-card h3 { margin: 0; font-size: 20px; }
.store-meta { color: var(--muted); font-size: 13px; }
.empty { text-align: center; padding: 42px 18px; color: var(--muted); }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(460px, 100%); padding: 28px; }
.auth-card h1 { margin: 0 0 7px; font-size: 28px; }
.auth-card .lead { margin: 0 0 22px; color: var(--muted); }
.pairing-code { font-size: clamp(36px, 8vw, 62px); font-weight: 900; letter-spacing: 8px; direction: ltr; text-align: center; padding: 14px; border: 2px dashed #9fc2ef; border-radius: 16px; background: #f3f8ff; }
.section-title { margin: 0 0 14px; font-size: 19px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Storefront */
.storefront { background: #f7f8fb; min-height: 100vh; }
.store-hero { background: linear-gradient(135deg, #1769e0, #1f7be8); color: #fff; padding: 34px 0 70px; }
.store-hero-inner { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.store-identity { display: flex; align-items: center; gap: 15px; }
.store-logo { width: 68px; height: 68px; border-radius: 20px; background: rgba(255,255,255,.16); display: grid; place-items: center; overflow: hidden; font-weight: 900; }
.store-logo img { width: 100%; height: 100%; object-fit: cover; }
.store-identity h1 { margin: 0; font-size: clamp(24px, 5vw, 38px); }
.store-identity p { margin: 5px 0 0; color: rgba(255,255,255,.82); }
.store-main { margin-top: -38px; padding-bottom: 100px; }
.catalog-shell { background: #fff; border: 1px solid #e6eaf0; border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.catalog-tools { padding: 16px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.search { flex: 1 1 260px; }
.category-chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }
.chip { white-space: nowrap; border: 1px solid #dce3ec; border-radius: 999px; padding: 7px 12px; background: #fff; cursor: pointer; }
.chip.active { background: #eaf3ff; border-color: #9ac4f6; color: #145fbf; font-weight: 800; }
.products { padding: 18px; display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 15px; }
.product { border: 1px solid #e7ebf1; border-radius: 17px; overflow: hidden; display: grid; background: #fff; min-width: 0; }
.product-media { aspect-ratio: 4/3; background: #f3f5f8; display: grid; place-items: center; color: #9ba7b7; font-weight: 800; overflow: hidden; }
.product-media img { width: 100%; height: 100%; object-fit: cover; }
.product-body { padding: 13px; display: grid; gap: 8px; }
.product h3 { margin: 0; font-size: 16px; line-height: 1.45; }
.product-desc { color: var(--muted); font-size: 12px; min-height: 19px; }
.product-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.price { font-weight: 900; color: #135fbe; }
.add-btn { min-width: 42px; height: 38px; border: 0; border-radius: 11px; background: #edf5ff; color: #135fbe; font-weight: 900; cursor: pointer; }
.add-btn:disabled { opacity: .45; cursor: not-allowed; }
.cart-bar { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); width: min(720px, calc(100% - 28px)); z-index: 40; }
.cart-button { width: 100%; min-height: 58px; border: 0; border-radius: 18px; background: #172033; color: #fff; padding: 0 18px; display: flex; align-items: center; justify-content: space-between; gap: 14px; box-shadow: 0 16px 40px rgba(10,20,40,.26); cursor: pointer; }
.cart-count { min-width: 30px; height: 30px; border-radius: 10px; background: #fff; color: #172033; display: grid; place-items: center; font-weight: 900; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(16,24,40,.5); display: none; place-items: end center; z-index: 50; padding: 18px; }
.modal-backdrop.open { display: grid; }
.cart-sheet { width: min(720px, 100%); max-height: 92vh; overflow: auto; border-radius: 24px 24px 16px 16px; background: #fff; padding: 20px; }
.cart-sheet h2 { margin-top: 0; }
.cart-line { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--line); }
.qty-controls { display: flex; gap: 6px; align-items: center; direction: ltr; }
.qty-controls button { width: 30px; height: 30px; border: 1px solid #dbe1e8; border-radius: 9px; background: #fff; cursor: pointer; }
.order-summary { margin-top: 14px; display: grid; gap: 7px; }
.summary-row { display: flex; justify-content: space-between; gap: 16px; }
.summary-row.total { font-weight: 900; font-size: 18px; padding-top: 10px; border-top: 1px solid var(--line); }
.checkout-fields { margin-top: 18px; display: grid; gap: 12px; }
.notice { padding: 11px 13px; border-radius: 12px; background: #f7f8fa; color: var(--muted); font-size: 13px; }
.order-success { text-align: center; padding: 26px 12px; }
.order-success strong { display: block; font-size: 26px; margin: 8px 0; }

@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .products { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 700px) {
  .container { width: min(100% - 22px, 1180px); }
  .page { padding-top: 22px; }
  .grid-2, .grid-3, .grid-4, .form-grid.two { grid-template-columns: 1fr; }
  .topbar-inner { min-height: 62px; }
  .nav-actions .hide-mobile { display: none; }
  .products { grid-template-columns: repeat(2, minmax(0,1fr)); padding: 12px; gap: 10px; }
  .product-body { padding: 10px; }
  .store-hero { padding-top: 24px; }
  .store-logo { width: 56px; height: 56px; border-radius: 16px; }
  .catalog-tools { padding: 12px; }
}
