/* AOBAOSI · Fittings Bestand — v2 */
:root {
  --ink: #0B1A2C;
  --deep-blue: #0B2E5C;
  --blue: #1E4FA8;
  --sky: #A8C5EE;
  --pale: #E8F0FA;
  --paler: #F4F8FD;
  --warm-white: #FAFAF7;
  --cream: #F4EFE5;
  --gray-900: #111827;
  --gray-700: #3F4A5B;
  --gray-500: #6B7686;
  --gray-300: #D6DCE4;
  --gray-200: #E8ECF1;
  --gray-100: #F4F6F9;
  --red: #E30613;
  --green: #16A34A;
  --amber: #F59E0B;
  --shadow-sm: 0 2px 8px rgba(15,44,92,.08);
  --shadow: 0 8px 28px rgba(15,44,92,.10);
  --shadow-lg: 0 20px 60px rgba(15,44,92,.18);
  --radius: 14px;
  --radius-sm: 10px;
}
* { box-sizing: border-box; }
html, body { margin:0; padding:0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--warm-white);
  color: var(--ink);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
  overscroll-behavior-y: contain;
}
.hidden { display: none !important; }
.dim { color: var(--gray-500); }
.small { font-size: 12px; }

/* ---------- PIN Gate ---------- */
.pin-gate {
  position: fixed; inset: 0;
  background: linear-gradient(160deg, var(--deep-blue) 0%, var(--blue) 100%);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  padding: 24px;
}
.pin-card {
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px;
  width: 100%;
  max-width: 320px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.pin-logo { width: 160px; height: auto; margin-bottom: 8px; }
.pin-card h2 { margin: 8px 0 4px; font-size: 22px; color: var(--ink); }
.pin-card input {
  width: 100%;
  padding: 14px;
  margin: 18px 0 12px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 8px;
  border: 2px solid var(--gray-300);
  border-radius: 12px;
  font-family: -apple-system, BlinkMacSystemFont, ui-monospace, monospace;
  background: var(--paler);
}
.pin-card input:focus { outline: 0; border-color: var(--blue); background: #fff; }
.pin-card .btn { width: 100%; padding: 14px; font-size: 16px; }
.pin-error { color: var(--red); margin-top: 12px; font-size: 13px; font-weight: 600; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: linear-gradient(180deg, var(--deep-blue) 0%, #0a2650 100%);
  color: #fff;
  box-shadow: 0 2px 14px rgba(11,26,44,.30);
}
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.logo-aobaosi { height: 20px; filter: brightness(0) invert(1) drop-shadow(0 1px 2px rgba(0,0,0,.20)); }
.logo-aobaosi { /* keep the red mark visible */
  filter: none;
}
/* Actually keep original AOBAOSI (red on transparent) — looks great on dark */
.brand-divider {
  width: 1px; height: 20px;
  background: rgba(255,255,255,.25);
}
.logo-keg { height: 26px; filter: brightness(0) invert(1); opacity: .95; }
.controls { display: flex; align-items: center; gap: 6px; }

.icon-btn, .pill-btn {
  background: rgba(255,255,255,.10);
  border: 1px solid rgba(255,255,255,.20);
  color: #fff;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .1s, background .15s;
}
.icon-btn { width: 38px; height: 38px; }
.pill-btn { min-width: 46px; height: 38px; padding: 0 10px; font-weight: 700; font-size: 12px; letter-spacing: .05em; }
.icon-btn:hover, .pill-btn:hover { background: rgba(255,255,255,.20); }
.icon-btn:active, .pill-btn:active { transform: scale(0.94); }

/* ---------- Main ---------- */
#main { max-width: 760px; margin: 0 auto; padding: 14px 12px 32px; }

.hint {
  background: var(--pale);
  border-left: 3px solid var(--blue);
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.hint p { margin: 0; font-size: 14px; }
.hint-warn { background: #FEF5E6; border-left-color: var(--amber); }

.status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 14px;
  background: var(--paler);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  margin-bottom: 12px;
  font-size: 12px;
}

.loader {
  display: flex; align-items: center; gap: 12px;
  padding: 32px;
  color: var(--gray-700);
  justify-content: center;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--gray-300);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Totals strip ---------- */
.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.totals-box {
  background: linear-gradient(160deg, var(--deep-blue), var(--blue));
  color: #fff;
  padding: 14px 10px;
  border-radius: var(--radius);
  text-align: center;
  box-shadow: var(--shadow);
}
.totals-num {
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.02em;
}
.totals-label {
  font-size: 10px;
  margin-top: 6px;
  color: var(--sky);
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
}

/* ---------- Type grid (5 big cards) ---------- */
.type-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
.type-card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s, border-color .15s;
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}
.type-card:active { transform: scale(0.97); }
.type-card:hover { box-shadow: var(--shadow); }
.type-card.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--pale), var(--shadow);
}
.type-card .fitting-img {
  height: 68px;
  width: auto;
  max-width: 60px;
  margin: 0 auto 6px;
  display: block;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.08));
}
.type-card .letter {
  color: var(--blue);
  font-weight: 800;
  font-size: 22px;
  line-height: 1;
}
.type-card .card-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 2px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
}
.type-card .card-stats {
  margin-top: 8px;
  display: flex;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
}
.type-card .stat-in { color: var(--green); }
.type-card .stat-out { color: var(--red); }
.type-card .card-qty {
  font-size: 12px;
  color: var(--blue);
  font-weight: 700;
  margin-top: 4px;
}

/* ---------- Grouped list ---------- */
.grouped { display: flex; flex-direction: column; gap: 14px; }
.group {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.group-head {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: linear-gradient(180deg, var(--paler), #fff);
  border-bottom: 1px solid var(--gray-200);
}
.group-head img { height: 34px; width: auto; }
.group-letter {
  font-weight: 800;
  color: var(--blue);
  font-size: 22px;
  line-height: 1;
}
.group-title { font-weight: 700; font-size: 15px; }
.group-sub { color: var(--gray-500); font-size: 12px; margin-left: auto; text-align: right; }

.rows { list-style: none; margin: 0; padding: 0; }
.row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-top: 1px solid var(--gray-200);
  transition: background .1s;
}
.row:first-child { border-top: 0; }
.row:hover { background: var(--paler); }
.row:active { background: var(--pale); }
.row .len {
  font-weight: 800;
  font-size: 16px;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Mono", Menlo, monospace;
}
.row .len-unit {
  font-size: 11px;
  color: var(--gray-500);
  font-weight: 500;
  margin-top: -2px;
}
.row .name {
  font-size: 13px;
  color: var(--gray-900);
  line-height: 1.35;
}
.row .sku {
  font-size: 10px;
  color: var(--gray-500);
  margin-top: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  letter-spacing: .02em;
}
/* ---------- Mobile top-bar layout fix ---------- */
.brand { flex: 1 1 auto; min-width: 0; overflow: hidden; }
.logo-aobaosi { max-width: 42vw; object-fit: contain; flex-shrink: 1; }
.logo-keg { max-width: 42vw; object-fit: contain; flex-shrink: 1; }
.controls { flex-shrink: 0; }

@media (max-width: 480px) {
  .topbar { padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top)); gap: 6px; }
  .brand { gap: 8px; }
  .logo-aobaosi { height: 16px; max-width: 34vw; }
  .logo-keg { height: 20px; max-width: 34vw; }
  .brand-divider { height: 16px; }
  .icon-btn { width: 34px; height: 34px; font-size: 14px; }
  .pill-btn { min-width: 40px; height: 34px; padding: 0 8px; font-size: 11px; }
  .controls { gap: 4px; }
}

@media (max-width: 380px) {
  .brand-divider { display: none; }
  .logo-aobaosi { height: 14px; max-width: 30vw; }
  .logo-keg { height: 18px; max-width: 30vw; }
}
