/* ── reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f4f4f6;
  color: #1a1a2e;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

/* ── layout ────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.page-wrap { min-height: 100vh; display: flex; flex-direction: column; }

/* ── topbar ────────────────────────────────────────────────── */
.topbar {
  background: #1a1a2e;
  color: #fff;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .logo {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.5px;
  display: flex; align-items: center; gap: 8px;
}
.topbar .logo span { font-weight: 300; opacity: 0.7; font-size: 12px; }
.topbar .spacer { flex: 1; }
.topbar .user-info { font-size: 13px; opacity: 0.8; }
.topbar a.logout-btn {
  font-size: 12px; padding: 4px 12px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 4px;
  color: #fff;
  transition: background 0.2s;
}
.topbar a.logout-btn:hover { background: rgba(255,255,255,0.1); }

/* ── sidebar (admin) ────────────────────────────────────────── */
.admin-layout { display: flex; flex: 1; }
.sidebar {
  width: 220px;
  background: #fff;
  border-right: 1px solid #e8e8ec;
  padding: 24px 0;
  flex-shrink: 0;
}
.sidebar a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 24px;
  font-size: 13px;
  color: #444;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}
.sidebar a:hover, .sidebar a.active {
  color: #4f46e5;
  background: #f0efff;
  border-left-color: #4f46e5;
}
.sidebar .section-label {
  font-size: 11px;
  color: #aaa;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 16px 24px 6px;
}

/* ── main content ────────────────────────────────────────────── */
.main-content { flex: 1; padding: 32px; overflow-x: auto; }
.page-title {
  font-size: 20px; font-weight: 600;
  margin-bottom: 24px;
  display: flex; align-items: baseline; gap: 8px;
}
.page-title .sub { font-size: 13px; font-weight: 400; color: #888; }

/* ── card ────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border: 1px solid #e8e8ec;
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}
.card-title {
  font-size: 14px; font-weight: 600;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f2;
  display: flex; align-items: center; gap: 6px;
}

/* ── stat cards ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: #fff;
  border: 1px solid #e8e8ec;
  border-radius: 10px;
  padding: 20px;
}
.stat-card .label { font-size: 12px; color: #888; margin-bottom: 6px; }
.stat-card .label .cn { color: #aaa; font-size: 11px; }
.stat-card .value { font-size: 28px; font-weight: 600; color: #1a1a2e; }
.stat-card.accent { border-left: 4px solid #4f46e5; }
.stat-card.green  { border-left: 4px solid #22c55e; }
.stat-card.amber  { border-left: 4px solid #f59e0b; }
.stat-card.blue   { border-left: 4px solid #3b82f6; }

/* ── table ───────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
thead tr { background: #f8f8fb; }
th {
  padding: 10px 14px; text-align: left;
  font-weight: 500; color: #555;
  border-bottom: 1px solid #e8e8ec;
  white-space: nowrap;
}
th .cn { font-size: 11px; color: #aaa; display: block; font-weight: 400; }
td {
  padding: 12px 14px;
  border-bottom: 1px solid #f0f0f2;
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafafa; }

/* ── badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-pending    { background: #fef3c7; color: #92400e; }
.badge-confirmed  { background: #dbeafe; color: #1e40af; }
.badge-production { background: #ede9fe; color: #5b21b6; }
.badge-shipped    { background: #d1fae5; color: #065f46; }
.badge-completed  { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.badge-cancelled  { background: #fee2e2; color: #991b1b; }

/* ── form elements ───────────────────────────────────────────── */
.form-row { margin-bottom: 16px; }
.form-row label {
  display: block; font-size: 12px; color: #555;
  margin-bottom: 5px; font-weight: 500;
}
.form-row label .cn { color: #aaa; font-weight: 400; }
.form-control {
  width: 100%; padding: 8px 12px;
  border: 1px solid #ddd; border-radius: 6px;
  font-size: 13px; font-family: inherit;
  transition: border-color 0.2s;
  background: #fff;
}
.form-control:focus {
  outline: none; border-color: #4f46e5;
  box-shadow: 0 0 0 3px rgba(79,70,229,0.1);
}
select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* ── buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 18px; border-radius: 6px;
  font-size: 13px; font-weight: 500;
  border: none; transition: all 0.15s;
}
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; }
.btn-secondary { background: #f4f4f6; color: #444; border: 1px solid #e0e0e4; }
.btn-secondary:hover { background: #eaeaec; }
.btn-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-success { background: #22c55e; color: #fff; }
.btn-success:hover { background: #16a34a; }

/* ── filter bar ─────────────────────────────────────────────── */
.filter-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; margin-bottom: 20px;
}
.filter-bar .form-control { width: auto; min-width: 140px; }

/* ── modal ────────────────────────────────────────────────────  */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: #fff; border-radius: 12px;
  width: 680px; max-width: 95vw;
  max-height: 90vh; overflow-y: auto;
  padding: 28px 32px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(8px);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; padding-bottom: 12px;
  border-bottom: 1px solid #f0f0f2;
}
.modal-title { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none; border: none; font-size: 20px;
  color: #999; cursor: pointer; line-height: 1;
}
.modal-close:hover { color: #333; }

/* ── detail grid ─────────────────────────────────────────────── */
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}
.detail-item .key {
  font-size: 11px; color: #aaa; margin-bottom: 3px;
}
.detail-item .val {
  font-size: 13px; color: #1a1a2e; font-weight: 500;
}

/* ── bilingual label ─────────────────────────────────────────── */
.bilingual { display: flex; flex-direction: column; }
.bilingual .en { font-size: 13px; color: #1a1a2e; }
.bilingual .cn { font-size: 11px; color: #aaa; }

/* ── login page ─────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 60%, #0f3460 100%);
}
.login-box {
  background: #fff; border-radius: 16px;
  padding: 40px 40px 32px;
  width: 380px; max-width: 94vw;
  box-shadow: 0 24px 64px rgba(0,0,0,0.3);
}
.login-logo {
  text-align: center; margin-bottom: 28px;
}
.login-logo .brand { font-size: 22px; font-weight: 700; color: #1a1a2e; }
.login-logo .tagline { font-size: 12px; color: #888; margin-top: 4px; }
.login-box h2 { font-size: 16px; font-weight: 600; margin-bottom: 20px; color: #333; }
.login-error { color: #dc2626; font-size: 12px; margin-top: 8px; min-height: 18px; }
.login-footer { text-align: center; margin-top: 20px; font-size: 12px; color: #bbb; }

/* ── toast ───────────────────────────────────────────────────── */
#toast {
  position: fixed; bottom: 24px; right: 24px;
  background: #1a1a2e; color: #fff;
  padding: 10px 20px; border-radius: 8px;
  font-size: 13px; z-index: 9999;
  opacity: 0; transform: translateY(8px);
  transition: all 0.2s; pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.error { background: #dc2626; }
#toast.success { background: #16a34a; }

/* ── pagination ──────────────────────────────────────────────── */
.pagination { display: flex; gap: 6px; margin-top: 16px; justify-content: flex-end; }
.pagination button {
  padding: 5px 11px; border-radius: 5px; border: 1px solid #e0e0e4;
  background: #fff; font-size: 12px; color: #444;
}
.pagination button.active { background: #4f46e5; color: #fff; border-color: #4f46e5; }
.pagination button:hover:not(.active) { background: #f0efff; }

/* ── responsive ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main-content { padding: 16px; }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { padding: 20px; }
}
