/* ============================================================
   VitexEnergy Admin — mobile-first control panel
   Big tap targets, one column, nothing to learn.
   ============================================================ */

:root {
  --navy:      #0B2545;
  --navy-2:    #13335B;
  --sun:       #F5B82E;
  --sun-2:     #D69E1F;
  --green:     #10B981;
  --green-2:   #047857;
  --red:       #DC2626;
  --red-soft:  #FEF2F2;

  --bg:        #F4F6F8;
  --surface:   #FFFFFF;
  --line:      #E3E8EE;
  --line-soft: #EFF2F6;
  --text:      #0B2545;
  --muted:     #64748B;

  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --shadow: 0 1px 2px rgba(11,37,69,.06), 0 8px 24px rgba(11,37,69,.06);
  --shadow-up: 0 -4px 24px rgba(11,37,69,.08);

  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* , *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;               /* 16px stops iOS zooming on focus */
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -0.02em; }
img { max-width: 100%; display: block; }
input, select, textarea, button { font-family: inherit; font-size: 1rem; }
button { cursor: pointer; border: none; background: none; color: inherit; }

.muted { color: var(--muted); }
.small { font-size: .88rem; }
[hidden] { display: none !important; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 1.3rem;
  border-radius: var(--r-md);
  font-weight: 600;
  font-size: .96rem;
  transition: transform .15s ease, opacity .15s ease, background .15s ease;
  min-height: 48px;
}
.btn:active { transform: scale(.985); }
.btn svg { width: 19px; height: 19px; flex-shrink: 0; }
.btn-block { display: flex; width: 100%; }
.btn-lg { min-height: 54px; font-size: 1.02rem; }

.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-soft { background: rgba(11,37,69,.06); color: var(--navy); }
.btn-ghost { background: transparent; color: var(--muted); border: 1.5px solid var(--line); }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1.5px solid rgba(220,38,38,.18); }

.link-btn {
  display: block;
  margin: 1.4rem auto 0;
  color: var(--muted);
  font-size: .88rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn { color: var(--sun-2); font-weight: 700; font-size: .98rem; padding: .5rem .2rem; }

.icon-btn {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: rgba(255,255,255,.10);
  color: #fff;
  transition: background .15s;
}
.icon-btn:active { background: rgba(255,255,255,.22); }
.icon-btn svg { width: 20px; height: 20px; }

/* ---------- centred screens (setup / login) ---------- */
.screen {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background: linear-gradient(160deg, var(--navy) 0%, #061629 100%);
}
.card-center {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border-radius: 22px;
  padding: 2rem 1.6rem 1.8rem;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
  text-align: center;
}
.card-center h1 { font-size: 1.4rem; margin-bottom: .4rem; }
.card-center .muted { font-size: .93rem; margin: 0 0 1.6rem; }
.card-center form { text-align: left; }

.brand-mark {
  width: 58px; height: 58px;
  margin: 0 auto 1.1rem;
  border-radius: 18px;
  display: grid; place-items: center;
  font-size: 1.7rem;
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-2) 100%);
  box-shadow: 0 10px 26px rgba(245,184,46,.4);
}

/* ---------- form fields ---------- */
.field { display: block; margin-bottom: 1.15rem; }
.field .label {
  display: block;
  font-size: .84rem;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--navy);
  margin-bottom: .45rem;
}
.field .label em { font-style: normal; font-weight: 500; color: var(--muted); font-size: .8rem; }
.field .label em.req { color: var(--sun-2); }
.field .hint { display: block; font-size: .8rem; color: var(--muted); margin-top: .4rem; }

input[type="text"], input[type="url"], input[type="tel"], input[type="email"],
input[type="password"], input[type="number"], input[type="search"], select, textarea {
  width: 100%;
  padding: .85rem 1rem;
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  min-height: 50px;
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}
textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.4'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 18px;
  padding-right: 2.8rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(11,37,69,.10);
}
input::placeholder, textarea::placeholder { color: #A9B4C2; }
input[type="number"] { -moz-appearance: textfield; }
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.input-wrap { position: relative; }
.input-wrap input { padding-right: 3rem; }
.eye {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  color: var(--muted); border-radius: 10px;
}
.eye svg { width: 20px; height: 20px; }

.form-error {
  background: var(--red-soft);
  color: var(--red);
  border: 1px solid rgba(220,38,38,.2);
  border-radius: var(--r-md);
  padding: .75rem .9rem;
  font-size: .88rem;
  margin: 1rem 0 0;
}

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.stack > .field:last-of-type { margin-bottom: 1.4rem; }

.accordion {
  border: 1.5px solid var(--line);
  border-radius: var(--r-md);
  padding: .85rem 1rem;
  background: var(--surface);
}
.accordion.tight { margin-top: .8rem; }
.accordion summary {
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  color: var(--muted);
  list-style: none;
}
.accordion summary::-webkit-details-marker { display: none; }
.accordion summary::before { content: '▸ '; }
.accordion[open] summary::before { content: '▾ '; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: linear-gradient(135deg, var(--navy) 0%, #0E2C54 100%);
  color: #fff;
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: .75rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.topbar-brand { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.topbar-brand strong { display: block; font-size: 1rem; letter-spacing: -0.01em; }
.topbar-brand small { display: block; font-size: .76rem; color: rgba(255,255,255,.65); }
.brand-dot {
  width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 12px;
  display: grid; place-items: center;
  font-size: 1.15rem;
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-2) 100%);
}
.topbar-actions { display: flex; gap: .45rem; }

/* ---------- views ---------- */
.view { padding-bottom: calc(96px + var(--safe-bottom)); }
.wrap { max-width: 720px; margin: 0 auto; padding: 1.1rem 1rem 0; }
.view-title { font-size: 1.25rem; margin-bottom: .3rem; }
.view-title + .muted { margin: 0 0 1.4rem; }

/* stats */
.stats-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; margin-bottom: 1.1rem; }
.stat-chip {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: .8rem .5rem;
  text-align: center;
  font-size: .74rem;
  color: var(--muted);
  box-shadow: var(--shadow);
}
.stat-num { display: block; font-size: 1.4rem; font-weight: 800; color: var(--navy); line-height: 1.1; }

/* search */
.search-wrap { position: relative; margin-bottom: .9rem; }
.search-wrap input { padding-left: 2.9rem; padding-right: 2.6rem; }
.search-icon {
  position: absolute; left: 1rem; top: 50%; transform: translateY(-50%);
  width: 19px; height: 19px; color: var(--muted); pointer-events: none;
}
.clear-search {
  position: absolute; right: .5rem; top: 50%; transform: translateY(-50%);
  width: 34px; height: 34px; border-radius: 50%;
  color: var(--muted); font-size: .9rem;
}

/* category chips */
.chips {
  display: flex; gap: .45rem;
  overflow-x: auto;
  padding-bottom: .9rem;
  margin: 0 -1rem 0;
  padding-left: 1rem; padding-right: 1rem;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  padding: .5rem .9rem;
  border-radius: 999px;
  background: var(--surface);
  border: 1.5px solid var(--line);
  font-size: .86rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.chip.active { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip .n { opacity: .6; font-weight: 500; }

/* ---------- product list ---------- */
.product-list { display: flex; flex-direction: column; gap: .7rem; }

.product-row {
  display: grid;
  grid-template-columns: 74px 1fr auto;
  gap: .85rem;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-lg);
  padding: .7rem;
  box-shadow: var(--shadow);
}
.product-row .thumb {
  width: 74px; height: 74px;
  border-radius: var(--r-md);
  object-fit: cover;
  background: var(--bg);
}
.product-row .thumb-empty {
  width: 74px; height: 74px;
  border-radius: var(--r-md);
  background: var(--bg);
  display: grid; place-items: center;
  color: #B6C0CC;
}
.product-row .thumb-empty svg { width: 26px; height: 26px; }
.product-info { min-width: 0; }
.product-info h3 {
  font-size: .97rem;
  font-weight: 700;
  margin-bottom: .2rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-meta { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; font-size: .78rem; color: var(--muted); }
.product-price { font-weight: 800; color: var(--navy); font-size: .95rem; }
.tag {
  font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  padding: .16rem .45rem; border-radius: 6px; text-transform: uppercase;
}
.tag-cat { background: rgba(11,37,69,.07); color: var(--navy); }
.tag-star { background: rgba(245,184,46,.18); color: #8A6410; }
.tag-out { background: var(--red-soft); color: var(--red); }

.row-actions { display: flex; flex-direction: column; gap: .35rem; }
.row-btn {
  width: 40px; height: 36px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: rgba(11,37,69,.05);
  color: var(--navy);
}
.row-btn svg { width: 17px; height: 17px; }
.row-btn.star.on { background: rgba(245,184,46,.2); color: var(--sun-2); }
.row-btn.del { background: var(--red-soft); color: var(--red); }

/* skeleton + empty */
.skeleton-row {
  height: 94px;
  border-radius: var(--r-lg);
  background: linear-gradient(90deg, #EDF1F5 0%, #F7F9FB 50%, #EDF1F5 100%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

.empty {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--muted);
}
.empty .big { font-size: 2.4rem; display: block; margin-bottom: .6rem; }
.empty strong { display: block; color: var(--text); margin-bottom: .3rem; font-size: 1.05rem; }

/* ---------- bottom tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--line);
  box-shadow: var(--shadow-up);
  padding: .4rem .5rem calc(.4rem + var(--safe-bottom));
}
.tab {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; gap: .15rem;
  padding: .45rem .3rem;
  font-size: .7rem; font-weight: 600;
  color: var(--muted);
  border-radius: 12px;
}
.tab svg { width: 22px; height: 22px; }
.tab.active { color: var(--navy); }
.tab-add {
  flex: 0 0 auto;
  width: 58px; height: 58px;
  margin-top: -22px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sun) 0%, var(--sun-2) 100%);
  color: var(--navy);
  box-shadow: 0 8px 22px rgba(245,184,46,.45);
  justify-content: center;
}
.tab-add svg { width: 26px; height: 26px; }
.tab-add:active { transform: scale(.94); }

/* ---------- product sheet ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  display: flex; flex-direction: column;
  animation: slideUp .25s ease;
}
@keyframes slideUp { from { transform: translateY(18px); opacity: .4; } to { transform: none; opacity: 1; } }

.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: .8rem;
  padding: calc(.7rem + env(safe-area-inset-top, 0px)) .8rem .7rem;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
}
.sheet-head h2 { font-size: 1.02rem; font-weight: 700; }
.sheet-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 1.2rem 1rem;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.sheet-spacer { height: calc(2rem + var(--safe-bottom)); }
.sheet-body .btn-block + .btn-block { margin-top: .7rem; }

/* photo box */
.photo-box {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--r-lg);
  border: 2px dashed var(--line);
  background: var(--surface);
  overflow: hidden;
  display: grid; place-items: center;
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-empty { text-align: center; color: #A9B4C2; font-size: .86rem; }
.photo-empty svg { width: 40px; height: 40px; margin: 0 auto .4rem; display: block; }
.photo-progress {
  position: absolute; inset: auto 0 0 0;
  background: rgba(11,37,69,.9);
  color: #fff;
  padding: .5rem .8rem;
  font-size: .78rem;
  display: flex; align-items: center; gap: .7rem;
}
.photo-progress .bar {
  flex: 1; height: 6px; border-radius: 3px;
  background: rgba(255,255,255,.25);
  overflow: hidden;
  position: relative;
}
.photo-progress .bar::after {
  content: ''; position: absolute; inset: 0 auto 0 0;
  width: var(--pct, 0%);
  background: var(--sun);
  transition: width .2s ease;
}
.photo-actions { display: flex; gap: .6rem; margin-top: .7rem; }
.photo-actions .btn { flex: 1; }

/* toggles */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--r-md);
  padding: .9rem 1rem;
  margin-bottom: .8rem;
  box-shadow: var(--shadow);
}
.toggle-row strong { display: block; font-size: .94rem; }
.toggle-row small { color: var(--muted); font-size: .78rem; line-height: 1.35; display: block; }

.switch { position: relative; flex-shrink: 0; width: 52px; height: 31px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; z-index: 2; }
.switch span {
  position: absolute; inset: 0;
  background: #CBD5E1;
  border-radius: 999px;
  transition: background .2s;
}
.switch span::after {
  content: '';
  position: absolute; top: 3px; left: 3px;
  width: 25px; height: 25px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0,0,0,.2);
  transition: transform .2s;
}
.switch input:checked + span { background: var(--green); }
.switch input:checked + span::after { transform: translateX(21px); }

/* specs */
.specs-list { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .7rem; }
.spec-row { display: grid; grid-template-columns: 1fr 1fr 42px; gap: .45rem; align-items: center; }
.spec-row input { min-height: 46px; padding: .6rem .75rem; font-size: .92rem; }
.spec-del {
  width: 42px; height: 46px;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--red-soft);
  color: var(--red);
  font-size: 1.1rem;
}

/* danger zone */
.danger-zone {
  margin-top: 2.5rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.danger-zone h3 { font-size: .82rem; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); margin-bottom: .5rem; }
.danger-zone p { margin: 0 0 .8rem; word-break: break-all; }

/* ---------- confirm dialog ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(6,22,41,.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 1.5rem;
}
.dialog {
  background: var(--surface);
  border-radius: 20px;
  padding: 1.6rem 1.4rem 1.2rem;
  max-width: 380px; width: 100%;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: scale(.94); opacity: 0; } to { transform: none; opacity: 1; } }
.dialog h3 { font-size: 1.1rem; margin-bottom: .5rem; }
.dialog p { color: var(--muted); font-size: .92rem; margin: 0 0 1.3rem; }
.dialog-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%; bottom: calc(96px + var(--safe-bottom));
  transform: translate(-50%, 10px);
  z-index: 90;
  background: var(--navy);
  color: #fff;
  padding: .8rem 1.2rem;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: 0 10px 30px rgba(11,37,69,.35);
  opacity: 0;
  transition: opacity .2s, transform .2s;
  max-width: calc(100vw - 2rem);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green-2); }

/* ---------- larger screens ---------- */
@media (min-width: 700px) {
  .product-list { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
  .stats-row { max-width: 520px; }
  .tabbar { max-width: 720px; margin: 0 auto; border-radius: 20px 20px 0 0; border: 1px solid var(--line); border-bottom: 0; }
}
