:root {
  --navy: #071326; --navy-2: #102a4c; --red: #e60012; --red-2: #b8000e;
  --bg: #f1f5f9; --card: #fff; --text: #1e293b; --muted: #64748b; --line: #e2e8f0;
  --green: #16a34a; --green-bg: #dcfce7; --amber: #d97706;
  --radius: 12px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Cairo', system-ui, sans-serif; background: var(--bg); color: var(--text);
  min-height: 100vh; padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='420' height='260' viewBox='0 0 420 260'%3E%3Cg transform='rotate(-22 210 130)' fill='none'%3E%3Ctext x='20' y='80' fill='%230a192f' fill-opacity='0.035' font-family='Arial' font-weight='900' font-size='30' letter-spacing='3'%3EALSAAD B2B%3C/text%3E%3Ctext x='35' y='125' fill='%23e60012' fill-opacity='0.03' font-family='Arial' font-weight='800' font-size='20' letter-spacing='4'%3EHYUNDAI %E2%80%A2 KIA%3C/text%3E%3C/g%3E%3C/svg%3E");
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

header.top {
  position: sticky; top: 0; z-index: 50; color: #fff;
  background: linear-gradient(135deg, #061020 0%, #0d213f 60%, #15325c 100%);
  border-bottom: 4px solid var(--red); padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.logo { font-weight: 800; font-size: 18px; white-space: nowrap; }
.logo span { color: var(--red); }
.top-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.who { font-size: 13px; opacity: .9; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
.pill { background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.22); padding: 1px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; }

.btn { border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; font-size: 14px; }
.btn-red { background: linear-gradient(135deg, var(--red), var(--red-2)); color: #fff; }
.btn-navy { background: linear-gradient(135deg, #0a192f, #173661); color: #fff; }
.btn-ghost { background: #fff; border: 1.5px solid #cbd5e1; color: var(--navy); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 14px 16px; }

/* login */
.login-card {
  max-width: 400px; margin: 40px auto; background: rgba(255,255,255,.97); border-radius: 16px;
  border-top: 5px solid var(--red); box-shadow: 0 12px 35px rgba(7,19,38,.12); padding: 26px 22px; text-align: center;
}
.login-card h1 { font-size: 22px; color: var(--navy); margin-bottom: 4px; }
.login-card p { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.field { text-align: right; margin-bottom: 14px; }
.field label { display: block; font-weight: 700; font-size: 13.5px; color: var(--navy); margin-bottom: 5px; }
.input, .field input, select.input, textarea.input {
  width: 100%; padding: 11px 13px; border: 1.5px solid #cbd5e1; border-radius: 10px; background: #fff; font-size: 16px;
}
.input:focus, .field input:focus { outline: none; border-color: var(--navy-2); box-shadow: 0 0 0 3px rgba(16,42,76,.12); }
.msg-err { color: var(--red); font-weight: 700; font-size: 13.5px; margin-top: 10px; min-height: 1em; }

/* summary cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-right: 4px solid var(--navy); border-radius: var(--radius); padding: 12px 14px; }
.card.red { border-right-color: var(--red); } .card.green { border-right-color: var(--green); } .card.amber { border-right-color: var(--amber); }
.card h4 { font-size: 12px; color: var(--muted); font-weight: 700; }
.card .val { font-size: 19px; font-weight: 800; color: var(--navy); }
.card .sub { font-size: 11.5px; color: var(--muted); }

/* tabs: top on desktop, bottom bar on phones */
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tab { flex: 1; border: 0; background: #e2e8f0; color: #334155; border-radius: 10px; padding: 10px; font-weight: 700; font-size: 13.5px; }
.tab.active { background: linear-gradient(135deg, #071326, #16325b); color: #fff; }
.tab .ico { display: block; font-size: 18px; line-height: 1.1; }
@media (max-width: 720px) {
  .tabs {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 60; margin: 0; gap: 0; background: #fff;
    border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0,0,0,.06); padding-bottom: env(safe-area-inset-bottom);
  }
  .tab { background: none; border-radius: 0; padding: 7px 2px 8px; font-size: 11px; color: var(--muted); }
  .tab.active { background: none; color: var(--red); }
}

/* catalog */
.filters { display: grid; grid-template-columns: 1fr; gap: 8px; margin-bottom: 8px; }
@media (min-width: 721px) { .filters { grid-template-columns: 2.4fr 1fr 1fr auto; } }
.filter-row { display: flex; gap: 8px; }
.filter-row > * { flex: 1; min-width: 0; }
.toggle { border: 1.5px solid #cbd5e1; background: #fff; color: #475569; border-radius: 10px; padding: 10px 12px; font-weight: 800; font-size: 13px; white-space: nowrap; }
.toggle.on { background: var(--green-bg); border-color: var(--green); color: #15803d; }
.strip { font-size: 12.5px; color: #475569; margin: 4px 2px 10px; }

.plist { display: grid; gap: 10px; }
.prod {
  background: #fff; border-radius: var(--radius); border-right: 4px solid var(--navy); box-shadow: 0 2px 8px rgba(7,19,38,.05);
  padding: 12px; display: grid; grid-template-columns: 72px 1fr; gap: 12px; align-items: start;
}
.prod.out { border-right-color: #94a3b8; background: #f8fafc; }
.thumb { width: 72px; height: 72px; border-radius: 10px; border: 1.5px solid var(--line); background: #fff; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; font-size: 24px; }
.thumb img { width: 100%; height: 100%; object-fit: contain; padding: 3px; }
.thumb.zoom { cursor: zoom-in; }
.thumb .n { position: absolute; bottom: 2px; left: 2px; background: rgba(7,19,38,.8); color: #fff; font-size: 10px; padding: 0 5px; border-radius: 4px; }
.pname { font-weight: 800; font-size: 15px; color: var(--navy); line-height: 1.45; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12.5px; color: #475569; }
.brand { color: #fff; padding: 1px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 800; }
.cat { background: #f1f5f9; border: 1px solid #cbd5e1; color: #334155; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.code { direction: ltr; unicode-bidi: isolate; font-family: ui-monospace, Menlo, monospace; font-weight: 700; background: #f1f5f9; border: 1px solid #cbd5e1; padding: 1px 7px; border-radius: 5px; font-size: 12.5px; color: #0f172a; }
.ok { color: #15803d; background: var(--green-bg); padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.no { color: #b91c1c; background: #fee2e2; padding: 1px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 700; }
.buy { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.price { font-size: 18px; font-weight: 800; color: var(--red); white-space: nowrap; }
.price.ask { font-size: 14px; color: var(--muted); }
.stepper { display: flex; align-items: center; border: 1.5px solid #cbd5e1; border-radius: 10px; overflow: hidden; background: #fff; }
.stepper button { border: 0; background: #f1f5f9; width: 36px; height: 38px; font-size: 18px; font-weight: 800; color: var(--navy); }
.stepper input { width: 46px; height: 38px; border: 0; text-align: center; font-weight: 800; font-size: 16px; -moz-appearance: textfield; }
.stepper input::-webkit-outer-spin-button, .stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.buy-ctl { display: flex; gap: 8px; align-items: center; }
.in-cart { font-size: 11.5px; color: #15803d; font-weight: 800; }
@media (min-width: 721px) {
  .prod { grid-template-columns: 80px 1fr auto; align-items: center; }
  .thumb { width: 80px; height: 80px; }
  .buy { grid-column: auto; border: 0; padding: 0; }
}
.more { display: block; margin: 14px auto 4px; }
.empty { background: #fff; border-radius: var(--radius); padding: 22px; text-align: center; color: var(--muted); font-weight: 700; }

/* cart bar & sheets */
.cartbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 55; color: #fff;
  background: linear-gradient(135deg, #061020, #102a4c); padding: 10px 16px; padding-bottom: calc(10px + env(safe-area-inset-bottom));
  display: flex; align-items: center; justify-content: space-between; gap: 10px; box-shadow: 0 -4px 18px rgba(0,0,0,.2);
}
.cartbar b { color: #ffccd0; font-size: 17px; }
@media (max-width: 720px) { .cartbar { bottom: calc(56px + env(safe-area-inset-bottom)); padding-bottom: 10px; } body.has-cart { padding-bottom: calc(132px + env(safe-area-inset-bottom)); } }
@media (min-width: 721px) { body.has-cart { padding-bottom: 80px; } }

.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(7,19,38,.6); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: #fff; width: 100%; max-width: 760px; max-height: 90vh; overflow-y: auto; border-radius: 16px 16px 0 0; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
@media (min-width: 721px) { .overlay { align-items: center; padding: 16px; } .sheet { border-radius: 16px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.sheet-head h3 { color: var(--navy); font-size: 17px; }
.x { border: 0; background: #f1f5f9; width: 36px; height: 36px; border-radius: 9px; font-size: 16px; font-weight: 800; }
.line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: center; }
.line .nm { font-weight: 800; color: var(--navy); font-size: 14px; }
.line .sm { font-size: 12px; color: var(--muted); }
.line .rm { border: 0; background: none; color: var(--red); font-weight: 800; font-size: 13px; }
.total-row { display: flex; justify-content: space-between; font-size: 18px; font-weight: 800; color: var(--red); margin: 14px 0; }
.warn { background: #fffbeb; border: 1px solid #fde68a; border-right: 4px solid #f59e0b; color: #92400e; padding: 9px 12px; border-radius: 8px; font-size: 13px; font-weight: 700; margin: 8px 0; }
.good { background: #f0fdf4; border: 1px solid #bbf7d0; border-right: 4px solid var(--green); color: #166534; padding: 12px; border-radius: 8px; font-weight: 700; margin: 8px 0; }

/* lightbox */
.lb { background: #fff; border-radius: 16px; width: 100%; max-width: 820px; overflow: hidden; display: flex; flex-direction: column; max-height: 92vh; margin: auto; }
.lb-head { background: var(--navy); color: #fff; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; align-items: center; }
.lb-stage { position: relative; background: #f8fafc; display: flex; align-items: center; justify-content: center; min-height: 280px; padding: 12px; }
.lb-stage img { max-width: 100%; max-height: 60vh; object-fit: contain; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); border: 0; background: rgba(7,19,38,.8); color: #fff; width: 40px; height: 40px; border-radius: 50%; font-size: 18px; }
.lb-thumbs { display: flex; gap: 8px; padding: 10px; overflow-x: auto; justify-content: center; }
.lb-thumbs img { width: 54px; height: 54px; object-fit: contain; border: 2px solid #cbd5e1; border-radius: 8px; padding: 2px; background: #fff; }
.lb-thumbs img.on { border-color: var(--red); }

/* panels, tables */
.panel { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin-bottom: 14px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.panel-head h3 { color: var(--navy); font-size: 16px; }
.tbl-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: right; font-size: 13px; vertical-align: middle; }
th { background: var(--navy); color: #fff; font-weight: 700; white-space: nowrap; position: sticky; top: 0; }
tr:nth-child(even) td { background: #f8fafc; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 700; white-space: nowrap; }
.b-green { background: var(--green-bg); color: #15803d; } .b-red { background: #fee2e2; color: #b91c1c; }
.b-amber { background: #fef3c7; color: #92400e; } .b-blue { background: #dbeafe; color: #1d4ed8; } .b-gray { background: #f1f5f9; color: #475569; }

/* mobile cards instead of wide tables */
.rows { display: grid; gap: 8px; }
.rowcard { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fff; }
.rowcard .top { display: flex; justify-content: space-between; gap: 8px; align-items: center; }
.rowcard .d { font-size: 12px; color: var(--muted); }

.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; margin: 10px 0; }
.step { text-align: center; font-size: 10.5px; font-weight: 700; padding: 6px 2px; border-radius: 7px; background: #f1f5f9; color: var(--muted); border: 1px solid var(--line); line-height: 1.35; }
.step.done { background: var(--green-bg); color: #15803d; border-color: #86efac; }
.step.cur { background: var(--navy); color: #fff; border-color: var(--navy); }

.toast { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(140px + env(safe-area-inset-bottom)); background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }

@media print {
  header.top, .tabs, .cartbar, .no-print { display: none !important; }
  body { padding: 0; background: #fff; }
  body::before { display: none; }
}

.line .stepper { justify-self: start; }
.only-narrow { display: none; }
@media (max-width: 720px) { .only-wide { display: none; } .only-narrow { display: grid; } }
@media print { .only-wide { display: block !important; } .only-narrow { display: none !important; } }
