/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  min-height: 100vh;
}

/* === Header & Nav === */
header {
  background: #ffffff;
  padding: 0 24px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #e2e8f0;
  height: 56px;
  gap: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.logo {
  height: 28px;
  flex-shrink: 0;
}

nav {
  display: flex;
  gap: 4px;
  align-items: center;
  flex: 1;
}

nav a {
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all 0.15s;
}

nav a:hover { color: #1e293b; background: #f1f5f9; }

nav a.active {
  color: #0f172a;
  background: #f1f5f9;
  font-weight: 600;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  flex-shrink: 0;
}

.refresh-indicator {
  font-size: 11px;
  color: #94a3b8;
  font-variant-numeric: tabular-nums;
}

/* === Buttons === */
.btn {
  padding: 7px 14px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: #0f172a; color: #ffffff; }
.btn-primary:hover { background: #1e293b; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary { background: #f1f5f9; color: #334155; border: 1px solid #e2e8f0; }
.btn-secondary:hover { background: #e2e8f0; }

.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-ghost { background: transparent; color: #64748b; border: 1px solid #e2e8f0; }
.btn-ghost:hover { background: #f8fafc; color: #334155; }

.btn-sm { padding: 5px 10px; font-size: 12px; }

/* === Stats Bar === */
.stats-bar {
  display: flex;
  gap: 24px;
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

.stat { text-align: center; padding: 4px 12px; }
.stat-number { font-size: 28px; font-weight: 700; color: #0f172a; line-height: 1.2; }
.stat-number.blue { color: #2563eb; }
.stat-label { font-size: 11px; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.5px; }

/* === Cards === */
.cards-grid {
  padding: 20px 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}

.card {
  background: #ffffff;
  border-radius: 10px;
  padding: 18px;
  border: 1px solid #e2e8f0;
  transition: all 0.15s;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.card:hover { border-color: #cbd5e1; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.card.urgent { border-color: #ef4444; box-shadow: 0 0 0 1px #fecaca; }
.card.prepared { border-color: #22c55e; box-shadow: 0 0 0 1px #bbf7d0; }

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 14px;
}

.card-qty {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
  color: #0f172a;
}

.card.urgent .card-qty { color: #dc2626; }
.card.prepared .card-qty { color: #16a34a; }

.card-badges {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card-items {
  font-size: 14px;
  font-weight: 500;
  color: #1e293b;
  line-height: 1.6;
}

.card-meta {
  font-size: 13px;
  color: #94a3b8;
}

.card-meta strong { color: #475569; }

.card-actions {
  margin-top: 14px;
  display: flex;
  gap: 8px;
}

/* === Badges === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-account {
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-account img { width: 12px; height: 12px; }

.badge-0 { background: #f5f3ff; color: #7c3aed; border: 1px solid #ede9fe; }
.badge-1 { background: #ecfeff; color: #0891b2; border: 1px solid #cffafe; }
.badge-2 { background: #f0fdf4; color: #059669; border: 1px solid #dcfce7; }
.badge-3 { background: #fff1f2; color: #e11d48; border: 1px solid #ffe4e6; }

.badge-status { text-transform: uppercase; }
.badge-ready_to_ship { background: #f0fdf4; color: #15803d; }
.badge-shipped { background: #eff6ff; color: #1d4ed8; }
.badge-delivered { background: #f0fdf4; color: #15803d; }
.badge-cancelled { background: #fef2f2; color: #dc2626; }
.badge-not_delivered { background: #fef2f2; color: #dc2626; }
.badge-pending { background: #fffbeb; color: #b45309; }
.badge-default { background: #f1f5f9; color: #64748b; }

/* === Delivery Time === */
.delivery-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  background: #f0fdf4;
  color: #15803d;
  margin-top: 4px;
}

.delivery-tag.urgent {
  background: #fef2f2;
  color: #dc2626;
}

/* === Section Headers === */
.section-header {
  padding: 16px 24px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header h2 {
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.section-count {
  background: #f1f5f9;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
}

/* === Photo === */
.photo-link {
  color: #2563eb;
  font-size: 12px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.photo-link:hover { text-decoration: underline; }

.photo-thumb {
  max-width: 100%;
  max-height: 180px;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 10px;
}

/* === Empty State === */
.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: #94a3b8;
}

.empty-state h2 {
  font-size: 18px;
  margin-bottom: 6px;
  color: #64748b;
  font-weight: 500;
}

.empty-state p { font-size: 14px; }

/* === Table (History) === */
.table-wrap { padding: 0 24px 24px; overflow-x: auto; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; }

th {
  text-align: left;
  padding: 8px 10px;
  font-size: 11px;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

td {
  padding: 10px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 13px;
  vertical-align: top;
}

tr:hover td { background: #f8fafc; }

.td-qty {
  font-size: 24px;
  font-weight: 800;
  color: #0f172a;
  text-align: center;
  min-width: 50px;
}

.td-items { color: #334155; line-height: 1.6; }
.td-items span { display: block; }
.td-buyer { font-size: 12px; }
.td-amount { font-weight: 600; white-space: nowrap; }
.td-date { white-space: nowrap; font-size: 12px; color: #94a3b8; }

/* === Toolbar === */
.toolbar {
  padding: 12px 24px;
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #1e293b;
  font-size: 13px;
}

.search-input:focus { outline: none; border-color: #94a3b8; }
.search-input::placeholder { color: #94a3b8; }

.results-info { font-size: 12px; color: #94a3b8; }

/* === Pagination === */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 20px;
}

.pagination button {
  padding: 6px 14px;
  background: #ffffff;
  color: #334155;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.pagination button:hover { background: #f1f5f9; }
.pagination button:disabled { opacity: 0.3; cursor: not-allowed; }
.pagination .page-info { font-size: 12px; color: #94a3b8; }

/* === Forms (Settings) === */
.container { max-width: 700px; margin: 0 auto; padding: 32px 24px; }

.form-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.form-group { margin-bottom: 14px; }

.form-group label {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.form-group input {
  width: 100%;
  padding: 8px 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  color: #1e293b;
  font-size: 14px;
}

.form-group input:focus { outline: none; border-color: #94a3b8; }

.account-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}

.account-info h3 { font-size: 15px; margin-bottom: 2px; color: #0f172a; }
.account-info p { font-size: 12px; color: #94a3b8; }
.status-ok { color: #16a34a; font-weight: 600; font-size: 12px; }
.status-err { color: #dc2626; font-weight: 600; font-size: 12px; }
.account-actions { display: flex; gap: 6px; align-items: center; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 16px;
  font-size: 13px;
}

.alert-success { background: #f0fdf4; color: #15803d; border: 1px solid #dcfce7; }
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }

/* === Modal === */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  padding: 24px;
  max-width: 440px;
  width: 90%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.modal h3 {
  font-size: 16px;
  color: #0f172a;
  margin-bottom: 16px;
}

.modal-loader {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.92);
  border-radius: 12px;
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #e2e8f0;
  border-top-color: #0f172a;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* === Mobile Bottom Nav === */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #ffffff;
  border-top: 1px solid #e2e8f0;
  padding: 6px 0;
  z-index: 900;
  justify-content: space-around;
}

.bottom-nav a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 10px;
  font-weight: 500;
  padding: 4px 6px;
}

.bottom-nav a.active { color: #0f172a; }

.bottom-nav-icon { font-size: 18px; }

/* === Responsive === */
@media (max-width: 768px) {
  header {
    height: auto;
    padding: 8px 12px;
    gap: 8px;
  }

  nav { display: none; }

  .header-right {
    margin-left: auto;
    gap: 6px;
  }

  .header-right .btn { font-size: 11px; padding: 5px 8px; }
  .header-right .btn[onclick="changePassword()"],
  .header-right .btn[onclick="logout()"] { display: none; }

  .bottom-nav { display: flex; }

  body { padding-bottom: 60px; }

  .stats-bar { justify-content: center; padding: 8px 14px; gap: 12px; }
  .stat-number { font-size: 22px; }
  .stat-label { font-size: 10px; }

  .cards-grid { padding: 10px; grid-template-columns: 1fr; gap: 10px; }
  .card { padding: 14px; }
  .card-qty { font-size: 48px; }

  .card-actions { flex-direction: column; }
  .card-actions .btn { width: 100%; justify-content: center; padding: 10px; font-size: 14px; }

  .section-header { padding: 10px 10px 0; }

  .toolbar { padding: 10px 12px; flex-direction: column; }
  .search-input { min-width: unset; }
  .table-wrap { padding: 0 8px 16px; }
  th, td { padding: 6px 5px; font-size: 11px; }
  .td-qty { font-size: 18px; min-width: 36px; }
}
