/* ═══════════════════════════════════════
   wholesaler_os — Mobile-first PWA styles
   ═══════════════════════════════════════ */

/* ── Reset & base ────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-50:  #f0fdf4;
  --green-100: #dcfce7;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-800: #166534;
  --gray-50:   #f9fafb;
  --gray-100:  #f3f4f6;
  --gray-200:  #e5e7eb;
  --gray-400:  #9ca3af;
  --gray-500:  #6b7280;
  --gray-700:  #374151;
  --gray-900:  #111827;
  --red-600:   #dc2626;
  --amber-500: #f59e0b;
  --blue-600:  #2563eb;
  --radius:    12px;
  --shadow:    0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-md: 0 4px 6px rgba(0,0,0,.1), 0 2px 4px rgba(0,0,0,.08);
}

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  background: var(--gray-100);
  color: var(--gray-900);
  min-height: 100dvh;
  line-height: 1.5;
}

/* ── Layout shell ────────────────────────── */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: #fff;
}

/* ── Top bar ─────────────────────────────── */
.topbar {
  background: var(--green-700);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}
.topbar-title { font-size: 1.1rem; font-weight: 700; letter-spacing: .02em; }
.topbar-sub   { font-size: .75rem; opacity: .8; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.btn-icon {
  background: none; border: none; color: #fff;
  font-size: 1.4rem; cursor: pointer; padding: 4px;
  border-radius: 6px;
  transition: background .15s;
}
.btn-icon:active { background: rgba(255,255,255,.2); }

/* ── Main content ────────────────────────── */
main { flex: 1; padding: 16px; overflow-y: auto; }

/* ── Cards ───────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 12px;
}
.card-title {
  font-size: .75rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 12px;
}

/* ── Stat grid ───────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--green-50);
  border: 1px solid var(--green-100);
  border-radius: var(--radius);
  padding: 14px 12px;
  text-align: center;
}
.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--green-700);
  line-height: 1;
}
.stat-label {
  font-size: .72rem;
  color: var(--gray-500);
  margin-top: 4px;
}

/* ── Menu list ───────────────────────────── */
.menu-list { display: flex; flex-direction: column; gap: 2px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  color: var(--gray-900);
  transition: background .12s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.menu-item:active { background: var(--gray-100); }
.menu-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.menu-icon.green  { background: var(--green-100); }
.menu-icon.blue   { background: #dbeafe; }
.menu-icon.amber  { background: #fef3c7; }
.menu-icon.red    { background: #fee2e2; }
.menu-text { flex: 1; }
.menu-text strong { display: block; font-size: .95rem; font-weight: 600; }
.menu-text span   { font-size: .78rem; color: var(--gray-500); }
.menu-arrow { color: var(--gray-400); font-size: .9rem; }

/* ── Badge ───────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: .7rem;
  font-weight: 600;
}
.badge-green  { background: var(--green-100); color: var(--green-700); }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-gray   { background: var(--gray-200); color: var(--gray-500); }

/* ── Role chip ───────────────────────────── */
.role-chip {
  font-size: .68rem;
  padding: 2px 7px;
  border-radius: 99px;
  background: rgba(255,255,255,.25);
  white-space: nowrap;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 13px 20px;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
  text-decoration: none;
}
.btn:active { opacity: .8; transform: scale(.98); }
.btn-primary {
  background: var(--green-600);
  color: #fff;
  width: 100%;
}
.btn-primary:disabled { background: var(--gray-400); cursor: not-allowed; }
.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
}
.btn-lg { padding: 16px 20px; font-size: 1rem; border-radius: 12px; }

/* ── FAB (Floating Action Button) ────────── */
.fab {
  position: fixed;
  bottom: 24px;
  right: calc(50% - 224px); /* aligned with max-width container */
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--green-600);
  color: #fff;
  border: none;
  font-size: 1.6rem;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(22,163,74,.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s;
  z-index: 50;
}
.fab:active { transform: scale(.92); box-shadow: 0 2px 6px rgba(22,163,74,.3); }
@media (max-width: 480px) { .fab { right: 20px; } }

/* ── Forms ───────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-input {
  width: 100%;
  padding: 13px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(22,163,74,.15);
}
.form-input::placeholder { color: var(--gray-400); }

/* ── Alert ───────────────────────────────── */
.alert {
  padding: 11px 14px;
  border-radius: 10px;
  font-size: .85rem;
  margin-bottom: 14px;
}
.alert-error   { background: #fee2e2; color: #991b1b; }
.alert-success { background: var(--green-100); color: var(--green-800); }

/* ── Login page ──────────────────────────── */
.login-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 32px 24px;
  background: linear-gradient(160deg, var(--green-700) 0%, var(--green-800) 100%);
}
.login-logo {
  font-size: 3rem;
  margin-bottom: 8px;
}
.login-company {
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 4px;
}
.login-sub {
  color: rgba(255,255,255,.7);
  font-size: .82rem;
  margin-bottom: 32px;
}
.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 24px 20px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.login-box h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 20px;
}

/* ── Greeting section ────────────────────── */
.greeting {
  background: linear-gradient(135deg, var(--green-600), var(--green-700));
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-bottom: 16px;
}
.greeting-name { font-size: 1.2rem; font-weight: 700; }
.greeting-role { font-size: .78rem; opacity: .85; margin-top: 2px; }
.greeting-date { font-size: .72rem; opacity: .7; margin-top: 6px; }

/* ── Divider ─────────────────────────────── */
.section-header {
  font-size: .72rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 0 4px 8px;
}

/* ── Loading spinner ─────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--green-600);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 40px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ─────────────────────────── */
.empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-400);
}
.empty-icon { font-size: 3rem; margin-bottom: 8px; }
.empty-text { font-size: .9rem; }
