:root {
  --temu-orange: #ff6000;
  --temu-orange-hover: #e85500;
  --temu-orange-light: #fff4ed;
  --header-bg: #1a1a1a;
  --sidebar-bg: #ffffff;
  --page-bg: #f5f6f8;
  --card-bg: #ffffff;
  --text: #1f2329;
  --text-muted: #6b7280;
  --border: #e8eaed;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  --font: 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); color: var(--text); background: var(--page-bg); line-height: 1.5; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 50%, var(--temu-orange) 150%);
}
.login-wrap { width: 100%; max-width: 420px; padding: 24px; }
.login-brand { text-align: center; color: #fff; margin-bottom: 24px; }
.login-brand h1 { font-size: 1.75rem; margin-top: 12px; }
.login-brand p { opacity: 0.8; font-size: 0.9rem; }
.login-card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 32px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}
.login-card h2 { margin-bottom: 20px; font-size: 1.25rem; }
.login-foot { text-align: center; color: rgba(255,255,255,0.6); font-size: 0.75rem; margin-top: 16px; }

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--temu-orange);
  color: #fff;
  font-weight: 700;
  font-size: 1.5rem;
  border-radius: 10px;
}
.logo-mark.sm { width: 32px; height: 32px; font-size: 1rem; border-radius: 6px; }

/* App shell */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav { padding: 12px 8px; flex: 1; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 4px;
}
.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover { background: var(--page-bg); }
.nav-item.active { background: var(--temu-orange-light); color: var(--temu-orange); font-weight: 500; }
.nav-muted { opacity: 0.7; }
.badge {
  margin-left: auto;
  background: var(--page-bg);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
}
.badge-new { background: var(--temu-orange); color: #fff; }

.main-area { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.top-header {
  background: var(--header-bg);
  color: #fff;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.breadcrumb { font-size: 0.75rem; opacity: 0.7; display: block; }
.page-title { font-size: 1.1rem; font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.header-search { display: flex; gap: 8px; }
.header-search input {
  padding: 8px 12px;
  border: none;
  border-radius: var(--radius);
  min-width: 180px;
}
.header-user { font-size: 0.85rem; opacity: 0.9; }

.content { padding: 24px; flex: 1; }

/* Cards & stats */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h2 { font-size: 1rem; font-weight: 600; }
.card > .table-wrap, .card > .store-list-mini, .card > .log-list, .card > p { padding: 0 20px 16px; }
.card-head + .table-wrap { padding-top: 0; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-card.accent { border-color: var(--temu-orange); background: var(--temu-orange-light); }
.stat-label { font-size: 0.8rem; color: var(--text-muted); display: block; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--temu-orange); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
.btn-primary { background: var(--temu-orange); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--temu-orange-hover); }
.btn-secondary { background: #fff; color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--page-bg); }
.btn-ghost { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.3); }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.inline-form { display: inline; }

/* Forms */
label { display: block; margin-bottom: 14px; }
label span { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 4px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--temu-orange);
  box-shadow: 0 0 0 3px var(--temu-orange-light);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
  padding: 16px 20px !important;
}
.filter-bar label { margin: 0; min-width: 140px; }
.filter-bar .grow { flex: 1; min-width: 200px; }

.alert { padding: 10px 12px; border-radius: var(--radius); margin-bottom: 14px; font-size: 0.875rem; }
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-success { background: #ecfdf5; color: #166534; border: 1px solid #bbf7d0; margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius); }

.connect-card .connect-body { padding: 16px 20px 20px; }
.connect-lead { margin-bottom: 12px; font-size: 0.9rem; }
.connect-steps { margin: 0 0 16px 20px; font-size: 0.875rem; line-height: 1.7; }
.connect-steps a { color: var(--temu-orange); }
.connect-form { max-width: 560px; margin-top: 16px; }
.stores-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.stores-toolbar h2 { font-size: 1.1rem; }
.empty-state { padding: 32px 20px; text-align: center; color: var(--text-muted); }
.token-ok { color: #166534; display: block; }
.token-missing { color: #b45309; display: block; }
.btn-ghost-danger { background: transparent; border: 1px solid #fecaca; color: #b91c1c; }
.btn-ghost-danger:hover { background: #fef2f2; }
input.readonly { background: var(--page-bg); color: var(--text-muted); }
.copy-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0;
  padding: 10px 12px;
  background: var(--page-bg);
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.copy-box code { flex: 1; word-break: break-all; font-size: 0.8rem; }
.store-actions { padding: 0 20px 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
th { font-weight: 600; color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.03em; }
tr:hover td { background: #fafbfc; }
.empty { text-align: center; color: var(--text-muted); padding: 32px !important; }
code { font-size: 0.8rem; background: var(--page-bg); padding: 2px 6px; border-radius: 4px; }

.store-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  background: color-mix(in srgb, var(--c, var(--temu-orange)) 15%, white);
  border: 1px solid color-mix(in srgb, var(--c, var(--temu-orange)) 40%, white);
}
.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  background: var(--temu-orange-light);
  color: var(--temu-orange);
}

.store-list-mini { padding: 12px 20px 16px !important; }
.store-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.store-row:last-child { border-bottom: none; }
.store-row strong { display: block; }
.store-row small { color: var(--text-muted); font-size: 0.75rem; }
.store-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.store-dot.lg { width: 14px; height: 14px; }

.store-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 20px; }
.store-card .store-card-head {
  display: flex;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 3px solid;
  align-items: flex-start;
}
.store-form { padding: 16px 20px 20px; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }

.info-banner {
  background: var(--temu-orange-light);
  border: 1px solid color-mix(in srgb, var(--temu-orange) 30%, white);
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  font-size: 0.875rem;
}

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  text-transform: uppercase;
  font-weight: 600;
}
.tag-active { background: #dcfce7; color: #166534; }
.tag-pending { background: #fef9c3; color: #854d0e; }
.tag-inactive { background: #f3f4f6; color: #6b7280; }
.tag-success { background: #dcfce7; color: #166534; }
.tag-error { background: #fef2f2; color: #b91c1c; }

.log-list { list-style: none; padding: 12px 20px 16px !important; }
.log-list li {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.85rem;
  align-items: center;
}
.log-list time { color: var(--text-muted); font-size: 0.75rem; grid-column: 3; }

.link { color: var(--temu-orange); text-decoration: none; font-weight: 500; }
.link:hover { text-decoration: underline; }
.muted { color: var(--text-muted); font-size: 0.875rem; }

.pagination { display: flex; gap: 6px; padding: 16px 20px; }
.page-link {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text);
  font-size: 0.85rem;
}
.page-link.active { background: var(--temu-orange); color: #fff; border-color: var(--temu-orange); }

.detail-dl { display: grid; grid-template-columns: 140px 1fr; gap: 8px 16px; padding: 16px 20px; font-size: 0.875rem; }
.detail-dl dt { color: var(--text-muted); }
.detail-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.json-details { padding: 0 20px 16px; }
.json-details summary { cursor: pointer; color: var(--temu-orange); font-weight: 500; margin-bottom: 8px; }
.json-details pre {
  background: var(--page-bg);
  padding: 12px;
  border-radius: var(--radius);
  overflow: auto;
  font-size: 0.75rem;
  max-height: 400px;
}

.error-page { text-align: center; padding: 80px 24px; }
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  background: var(--header-bg);
  color: #fff;
  font-size: 0.875rem;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}
.toast.error { background: #b91c1c; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .top-header { flex-direction: column; align-items: flex-start; }
}
