:root {
  --g1: #0d9488;
  --g2: #2563eb;
  --bg: #070b14;
  --surface: rgba(255,255,255,.07);
  --surface2: rgba(255,255,255,.10);
  --border: rgba(255,255,255,.10);
  --text: #e5e7eb;
  --muted: rgba(229,231,235,.65);
  --accent: #35d0c4;
  --danger: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --radius: 16px;
  --shadow: 0 8px 32px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: "Rubik", system-ui, sans-serif; -webkit-tap-highlight-color: transparent; }

body {
  background:
    radial-gradient(900px 600px at 15% -5%, rgba(13,148,136,.18), transparent 55%),
    radial-gradient(700px 500px at 85% 5%, rgba(37,99,235,.18), transparent 50%),
    var(--bg);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

.app {
  max-width: 540px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── Header ── */
header {
  position: sticky; top: 0; z-index: 50;
  padding: 12px 16px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: linear-gradient(135deg, rgba(13,148,136,.14), rgba(37,99,235,.12));
  border-bottom: 1px solid var(--border);
}
.header-inner { display: flex; align-items: center; gap: 10px; }
.header-logo { height: 34px; width: auto; border-radius: 6px; }
.back-btn {
  width: 40px; height: 40px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--text); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s;
}
.back-btn:active { transform: scale(.94); }
.title-wrap { flex: 1; }
.title { font-size: 15px; font-weight: 800; letter-spacing: .3px; }
.subtitle { font-size: 11px; color: var(--muted); }
.counter-badge {
  padding: 5px 10px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(53,208,196,.15); color: var(--accent); border: 1px solid rgba(53,208,196,.2);
}

/* ── Screens ── */
main { flex: 1; padding: 14px; padding-bottom: 90px; }
.screen { display: none; }
.screen.active { display: block; animation: fadeUp .2s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── Overlay (name input / ocr) ── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.overlay-box {
  background: linear-gradient(180deg, rgba(20,28,50,.98), rgba(12,18,35,.98));
  border: 1px solid var(--border); border-radius: 20px;
  padding: 28px 22px; width: 100%; max-width: 380px; text-align: center;
}
.overlay-wide { max-width: 460px; max-height: 80vh; overflow-y: auto; text-align: right; }
.overlay-icon { font-size: 40px; margin-bottom: 10px; }
.overlay-logo { height: 60px; width: auto; margin-bottom: 14px; }
.overlay-box h2 { font-size: 20px; font-weight: 800; margin-bottom: 6px; }
.overlay-box p { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

/* ── Home Screen ── */
.home-greeting {
  font-size: 18px; margin-bottom: 16px; padding: 4px 0;
}

.action-tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
}
.tab-btn {
  flex: 1; padding: 10px 6px; border-radius: 12px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--border); background: rgba(255,255,255,.05);
  color: var(--muted); cursor: pointer; transition: all .15s;
}
.tab-btn.active {
  background: linear-gradient(135deg, rgba(13,148,136,.25), rgba(37,99,235,.2));
  color: var(--accent); border-color: rgba(53,208,196,.3);
}

.warehouses-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px;
}
.warehouse-card {
  border: 1px solid var(--border); border-radius: 18px;
  background:
    radial-gradient(160px 120px at 25% 25%, var(--wh-glow, rgba(13,148,136,.15)), transparent 55%),
    rgba(255,255,255,.05);
  box-shadow: var(--shadow); padding: 20px 12px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 110px; text-align: center; transition: transform .1s;
}
.warehouse-card:active { transform: scale(.97); }
.warehouse-card.disabled { opacity: .4; pointer-events: none; }
.warehouse-card .wh-icon { font-size: 32px; margin-bottom: 8px; }
.warehouse-card .wh-name { font-size: 17px; font-weight: 800; color: var(--accent); }

/* ── Search ── */
.search-row { margin-bottom: 10px; }
.search-box { position: relative; }
.search-box .search-icon {
  position: absolute; right: 12px; top: 50%; transform: translateY(-50%);
  font-size: 14px; pointer-events: none;
}
.search-box input {
  width: 100%; padding: 11px 12px 11px 40px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--text); outline: none; font-size: 14px;
}
.search-box input::placeholder { color: rgba(229,231,235,.4); }

/* ── Progress ── */
.count-top { margin-bottom: 10px; }
.current-date { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.count-progress { display: flex; align-items: center; gap: 10px; margin-top: 6px; }
.progress-bar {
  flex: 1; height: 6px; border-radius: 99px;
  background: rgba(255,255,255,.08); overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 99px; transition: width .3s ease;
  background: linear-gradient(90deg, var(--g1), var(--g2));
}
.progress-text { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* ── Item Cards ── */
.items-list { display: flex; flex-direction: column; gap: 10px; }
.item-card {
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: 16px; padding: 14px; box-shadow: var(--shadow);
  cursor: pointer; transition: transform .1s;
}
.item-card:active { transform: scale(.99); }
.item-card.counted { border-right: 3px solid var(--success); }
.item-card .item-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.item-card .item-name { font-size: 15px; font-weight: 700; line-height: 1.3; flex: 1; }
.item-card .item-sku { font-size: 11px; color: var(--muted); margin-top: 2px; }
.item-card .item-count-badge {
  padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(34,197,94,.12); color: #86efac; white-space: nowrap;
}
.item-card .item-stats {
  font-size: 12px; color: var(--muted); margin-top: 6px;
  display: flex; gap: 14px;
}
.item-card .item-stats strong { color: var(--text); font-weight: 800; }

/* ── Item Detail Panel ── */
.panel {
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 16px;
}
.item-name-large { font-size: 22px; font-weight: 900; margin-bottom: 4px; }
.item-meta { font-size: 12px; color: var(--muted); }
.summary-box {
  margin-top: 14px; padding: 14px; border-radius: 14px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(13,148,136,.12), rgba(37,99,235,.1));
  font-size: 14px; display: flex; flex-direction: column; gap: 6px;
}
.summary-box strong { font-weight: 900; }

.field-group { margin-top: 16px; display: flex; flex-direction: column; gap: 6px; }
.field-label { font-size: 13px; font-weight: 700; }
.field-input {
  width: 100%; padding: 12px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--text); outline: none; font-size: 16px;
}
.field-input:focus { border-color: var(--accent); }
.field-input::placeholder { color: rgba(229,231,235,.4); }
.hint { font-size: 11px; color: var(--muted); }

.bottom-actions { margin-top: 20px; display: flex; flex-direction: column; gap: 10px; }
.primary-btn {
  background: linear-gradient(135deg, var(--g1), var(--g2));
  color: #fff; border-radius: 999px; padding: 13px; border: 1px solid rgba(255,255,255,.12);
  font-size: 15px; font-weight: 800; cursor: pointer;
  box-shadow: 0 10px 28px rgba(13,148,136,.15), 0 10px 28px rgba(37,99,235,.1);
  transition: transform .1s;
}
.primary-btn:active { transform: scale(.98); }
.secondary-btn {
  background: rgba(255,255,255,.06); color: var(--text);
  border-radius: 999px; padding: 13px; border: 1px solid var(--border);
  font-size: 14px; font-weight: 700; cursor: pointer;
}
.secondary-btn:active { transform: scale(.98); }

/* ── Live Screen ── */
.live-top { margin-bottom: 10px; }
.live-header-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.live-title { font-size: 18px; font-weight: 800; }
.refresh-btn {
  padding: 8px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--accent); cursor: pointer;
}
.refresh-btn:active { transform: scale(.96); }
.refresh-btn.spinning { animation: spin .6s ease; }
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

.live-summary {
  display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; margin-bottom: 12px;
}
.live-stat {
  text-align: center; padding: 10px 6px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
}
.live-stat .stat-val { font-size: 20px; font-weight: 900; color: var(--accent); }
.live-stat .stat-label { font-size: 10px; color: var(--muted); margin-top: 2px; }

.filter-row {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  font-size: 12px; color: var(--muted); margin-bottom: 10px;
  padding: 8px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: rgba(255,255,255,.04);
}
.filter-row span { font-weight: 700; color: rgba(229,231,235,.8); }
.filter-row label { display: flex; align-items: center; gap: 5px; }
.filter-row input { accent-color: var(--accent); }

/* ── Live Item Card ── */
.live-card {
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow);
}
.live-card.counted { border-right: 3px solid var(--success); }
.live-card .lc-row { display: flex; justify-content: space-between; align-items: center; }
.live-card .lc-name { font-size: 14px; font-weight: 700; }
.live-card .lc-total { font-size: 16px; font-weight: 900; color: var(--accent); }
.live-card .lc-details { font-size: 11px; color: var(--muted); margin-top: 4px; display: flex; gap: 12px; }

/* ── Withdraw ── */
.withdraw-top { margin-bottom: 10px; }
.ocr-btn {
  width: 100%; padding: 12px; border-radius: 999px; font-size: 14px; font-weight: 700;
  border: 1px solid rgba(249,115,22,.3); background: rgba(249,115,22,.1);
  color: #fdba74; cursor: pointer; margin-top: 8px;
}
.ocr-btn:active { transform: scale(.98); }

.withdraw-card {
  background: rgba(255,255,255,.05); border: 1px solid var(--border);
  border-radius: 14px; padding: 12px 14px;
}
.withdraw-card .wc-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.withdraw-card .wc-name { font-size: 14px; font-weight: 700; flex: 1; }
.withdraw-card .wc-sku { font-size: 11px; color: var(--muted); }
.withdraw-card .wc-current { font-size: 11px; color: var(--muted); margin-top: 4px; }
.withdraw-card .wc-input {
  width: 80px; padding: 8px; border-radius: 10px; text-align: center;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--text); font-size: 14px; font-weight: 700; outline: none;
}
.withdraw-card .wc-input:focus { border-color: var(--warning); }

.withdraw-bar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  backdrop-filter: blur(14px); background: rgba(12,18,35,.92);
  border-top: 1px solid var(--border);
  max-width: 540px; margin: 0 auto;
}
.withdraw-bar span { font-size: 13px; font-weight: 700; }
.withdraw-bar .primary-btn { padding: 10px 20px; font-size: 14px; }

/* ── OCR Results ── */
.ocr-results { max-height: 50vh; overflow-y: auto; margin-bottom: 14px; }
.ocr-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.ocr-row .ocr-name { flex: 1; font-size: 13px; font-weight: 600; }
.ocr-row .ocr-qty {
  width: 60px; padding: 6px; border-radius: 8px; text-align: center;
  border: 1px solid var(--border); background: rgba(255,255,255,.06);
  color: var(--text); font-size: 14px; font-weight: 700; outline: none;
}

/* ── Toast ── */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(34,197,94,.9); color: #fff; z-index: 200;
  animation: toastIn .3s ease, toastOut .3s ease 1.8s forwards;
  white-space: nowrap;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* ── Responsive ── */
@media (max-width: 380px) {
  .warehouse-card .wh-name { font-size: 15px; }
  .item-card .item-name { font-size: 14px; }
  .tab-btn { font-size: 12px; padding: 8px 4px; }
}
