/* TrendScout — light theme, shared by every page.
   Linked AFTER each page's own <style>, so it redefines the colour tokens and restyles the shared
   components (shell, sidebar, toolbar, buttons, inputs, tables, cards, auth card) in one place.
   Contrast: body text 15:1, secondary 7:1, faint labels 5:1, white-on-accent buttons 5.2:1. */

:root {
  --bg: #f3f4f7;
  --surface: #ffffff;
  --surface-2: #f7f8fa;
  --surface-3: #eceef3;
  --border: #e1e4ea;
  --border-strong: #c9cfda;
  --text: #121722;
  --text-soft: #4a5568;
  --text-faint: #5d6879;
  --accent: #c2410c;
  --accent-hover: #a8370a;
  --accent-soft: #c2410c;
  --accent-tint: #fff1e8;
  --accent-ring: rgba(194, 65, 12, 0.22);
  --accent-2: #0b7a55;
  --accent-2-tint: #e4f5ee;
  --danger: #c81e3f;
  --danger-tint: #fdecef;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 6px 18px rgba(16, 24, 40, 0.09), 0 1px 3px rgba(16, 24, 40, 0.06);
  color-scheme: light;
}

body { background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
h1, h2, h3, .brand-name { font-family: 'Sora', sans-serif; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-tint); }

/* ---------- Sidebar ---------- */
.sidebar { width: 264px; background: var(--surface); border-right: 1px solid var(--border); }
.sidebar-header { padding: 18px 18px 14px; border-bottom: 1px solid var(--border); }
.brand-mark {
  width: 32px; height: 32px; border-radius: 8px;
  background: #ea580c; color: #fff;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.12);
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
.sidebar-scroll { padding: 12px 10px 16px; }
.sidebar-label { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; color: var(--text-faint); padding: 12px 12px 6px; }
.nav-link { gap: 10px; padding: 9px 12px; font-weight: 500; color: var(--text-soft); border-radius: var(--radius); }
.nav-link .nav-icon { width: 18px; height: 18px; flex: none; color: var(--text-faint); display: inline-flex; }
.nav-link .nav-icon svg { width: 18px; height: 18px; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .nav-icon { color: var(--text-soft); }
.nav-link.active { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.nav-link.active .nav-icon { color: var(--accent); }
.sidebar-footer { padding: 14px 16px; border-top: 1px solid var(--border); background: var(--surface); }
.user-avatar { background: var(--accent-tint); color: var(--accent); font-weight: 700; }
#userName { color: var(--text); }
button.link-btn { color: var(--text-soft); }
button.link-btn:hover { color: var(--accent); text-decoration: underline; }
.sidebar-toggle {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  box-shadow: var(--shadow-sm);
}
select#businessSelect {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: var(--radius); height: 38px; padding: 0 10px; font-weight: 500;
}

/* ---------- Page header + toolbar ---------- */
.hero { padding: 32px 32px 20px; max-width: none; }
.hero h1 { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; margin: 0 0 6px; color: var(--text); }
.hero p { color: var(--text-soft); font-size: 14px; line-height: 1.6; max-width: 680px; }

.toolbar {
  margin: 0 32px 20px; padding: 12px; max-width: none; gap: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
#keywordInput, select#marketSelect, select#categorySelect {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  height: 40px; padding: 0 12px; border-radius: var(--radius); font-size: 14px; font-weight: 500;
}
#keywordInput { flex: 1; min-width: 220px; max-width: none; }
#keywordInput::placeholder { color: #7a8494; font-weight: 400; }
select#marketSelect { min-width: 176px; }
select#categorySelect { flex: 1; min-width: 260px; max-width: 460px; }
#keywordInput:focus, select#marketSelect:focus, select#categorySelect:focus,
.field input:focus, .field select:focus, select#businessSelect:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring);
}

/* Primary buttons: solid accent, white label */
button#fetchBtn, button#searchBtn, button.primary, button.submit {
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  height: 40px; padding: 0 20px; border-radius: var(--radius);
  font-family: 'Inter', -apple-system, sans-serif; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow-sm); transform: none;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
button#fetchBtn:hover, button#searchBtn:hover, button.primary:hover, button.submit:hover {
  background: var(--accent-hover); border-color: var(--accent-hover); transform: none; box-shadow: var(--shadow-md);
}
button#fetchBtn:active, button#searchBtn:active, button.primary:active, button.submit:active { transform: none; }
button#fetchBtn:disabled, button#searchBtn:disabled, button.primary:disabled, button.submit:disabled {
  opacity: 0.55; box-shadow: none; transform: none;
}

.status-line { color: var(--text-soft); font-size: 13px; margin: 0 0 16px; padding: 0 32px; max-width: none; min-height: 18px; }
.status-line.error { color: var(--danger); }
.status-line.ok { color: var(--accent-2); }
.status-line:empty { display: none; }

/* ---------- eBay results table ---------- */
.table-wrap { padding: 0 32px; margin: 0 0 48px; }
table.results {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm); border-collapse: separate; border-spacing: 0;
  /* Thumbnail + price + four sold-count columns + eight 68px logo columns are fixed (~1100px); this keeps the Title
     column readable (>=300px) and lets .table-wrap scroll sideways on narrow screens instead of squeezing it. */
  min-width: 1420px;
}
table.results th {
  background: var(--surface-2); color: var(--text-faint);
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  padding: 11px 14px; border-bottom: 1px solid var(--border);
}
table.results td { padding: 10px 14px; border-bottom: 1px solid var(--border); font-size: 13px; vertical-align: middle; }
table.results tbody tr:hover { background: var(--surface-2); }
table.results tbody tr:last-child td { border-bottom: none; }
/* Product photo: large enough to recognise the item at a glance (was 44px). The first column is 100px =
   72px photo + the cell's 14px padding on each side. */
table.results th:nth-child(1), table.results td:nth-child(1) { width: 100px; }
.r-thumb { width: 72px; height: 72px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); object-fit: cover; }
.r-title { font-weight: 500; color: var(--text); }
.r-title-link:hover { color: var(--accent); text-decoration: underline; }
table.results td.r-sold, table.results td.r-price {
  font-family: 'Inter', -apple-system, sans-serif; font-variant-numeric: tabular-nums; font-weight: 600;
}
table.results td.r-sold { color: var(--accent-2); }
table.results td.r-price { color: var(--text); }
/* Everything in the results table is centre-aligned. The header cells (and the price/sold cells in the page's own
   stylesheet) set text-align: right, and the headers do it inline — hence !important. */
table.results th, table.results td { text-align: center !important; }
/* ...except the Title column (its header and the titles), which reads better left-aligned. */
table.results th:nth-child(2), table.results td.r-title { text-align: left !important; }

/* "Search on …" logo buttons — the marketplace's own icon, one shared hover */
col.mk-col { width: 68px; }
table.results th.mk-head { text-align: center; letter-spacing: 0.06em; }
table.results th:nth-child(8), table.results td:nth-child(n+8) { padding-left: 8px; padding-right: 8px; }
button.mk-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; padding: 0; border-radius: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-soft); font-size: 15px; font-weight: 700; line-height: 1;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s, opacity 0.15s;
}
button.mk-btn img { width: 32px; height: 32px; object-fit: contain; border-radius: 6px; display: block; }
button.mk-btn:hover { border-color: var(--accent); background: var(--accent-tint); box-shadow: 0 0 0 3px var(--accent-ring); }
button.mk-btn:disabled { cursor: default; box-shadow: none; }
button.mk-btn.busy { opacity: 0.5; animation: mk-pulse 0.9s ease-in-out infinite; }
@keyframes mk-pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { button.mk-btn.busy { animation: none; } }

/* ---------- Empty states ---------- */
.empty-state { color: var(--text-faint); padding: 56px 20px; max-width: none; font-size: 14px; }
.empty-state a { color: var(--accent); }
.empty-initial {
  background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-lg);
  padding: 64px 24px; display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.empty-initial .empty-icon {
  width: 48px; height: 48px; border-radius: 12px; background: var(--accent-tint); color: var(--accent);
  display: flex; align-items: center; justify-content: center; margin-bottom: 8px;
}
.empty-initial .empty-icon svg { width: 24px; height: 24px; }
.empty-initial h2 { margin: 0; font-size: 16px; font-weight: 600; color: var(--text); }
.empty-initial p { margin: 0; max-width: 460px; font-size: 13.5px; line-height: 1.6; color: var(--text-soft); }

/* ---------- AliExpress product grid ---------- */
.grid { max-width: none; padding: 0 32px; margin: 0 0 48px; gap: 18px; }
.pcard {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.pcard:hover { transform: translateY(-2px); border-color: var(--border-strong); box-shadow: var(--shadow-md); }
.pcard-img-wrap { background: var(--surface-2); }
.badge { backdrop-filter: none; font-weight: 600; letter-spacing: 0.01em; }
.badge-volume { background: var(--accent); color: #fff; }
.badge-discount { background: var(--accent-2); color: #fff; }
.pcard-title { color: var(--text); font-weight: 500; }
.pcard-meta { color: var(--text-soft); }
.pcard-price { font-family: 'Inter', -apple-system, sans-serif; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text); }
.pcard-rating { color: #b45309; }
button.import-btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 9px; font-family: 'Inter', -apple-system, sans-serif; font-weight: 600; font-size: 13px;
}
button.import-btn:hover { background: var(--accent); border-color: var(--accent); color: #fff; }
button.import-btn.done { background: var(--accent-2); border-color: var(--accent-2); color: #fff; }
button#loadMoreBtn {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: var(--radius); height: 40px; padding: 0 28px;
  font-family: 'Inter', -apple-system, sans-serif; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-sm);
}
button#loadMoreBtn:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Toast ---------- */
#toast { background: #171c27; border: none; color: #fff; box-shadow: var(--shadow-md); }
#toast.error { background: var(--danger); border: none; color: #fff; }

/* ---------- Team page ---------- */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); max-width: 1100px; }
.panel h2 { font-size: 15px; font-weight: 600; color: var(--text); }
.field label { color: var(--text-faint); font-weight: 600; }
.field input:not([type="checkbox"]), .field select, select.role-select {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text); border-radius: var(--radius);
}
.field input:not([type="checkbox"]), .field select { height: 38px; padding: 0 11px; font-size: 13.5px; }
/* The checkbox labels sit inside .field, whose labels are small uppercase captions — undo that for them. */
.field .tool-check { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 500; color: var(--text); }
button.mini-btn { white-space: nowrap; }
/* The actions cell is itself display:flex, which pulls it out of the table row (its bottom border no longer lines up). */
td.row-actions { display: table-cell; white-space: nowrap; }
td.row-actions .mini-btn + .mini-btn { margin-left: 6px; }
.toggle-visibility { color: var(--text-faint); }
.toggle-visibility:hover { color: var(--text); background: var(--surface-3); }
.tool-checks { background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius); }
table.team th { color: var(--text-faint); font-weight: 600; letter-spacing: 0.06em; border-bottom: 1px solid var(--border); background: var(--surface-2); }
table.team td { border-bottom: 1px solid var(--border); color: var(--text); }
table.team tbody tr:hover { background: var(--surface-2); }
.role-admin { background: var(--accent-tint); color: var(--accent); }
.role-manager { background: var(--accent-2-tint); color: var(--accent-2); }
.role-staff { background: var(--surface-3); color: var(--text-soft); }
button.mini-btn { background: var(--surface); border: 1px solid var(--border-strong); color: var(--text-soft); border-radius: var(--radius); }
button.mini-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
button.mini-btn.danger:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-tint); }

/* ---------- Sign-in / reset-password ---------- */
body::before, body::after { display: none; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  box-shadow: var(--shadow-md); padding: 36px 32px;
}
.card h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
p.sub { color: var(--text-soft); }
.card label { text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: 600; color: var(--text); }
input[type="email"], input[type="password"], input[type="text"] {
  background: var(--surface); border: 1px solid var(--border-strong); color: var(--text);
  border-radius: var(--radius); height: 44px; padding: 0 14px; font-size: 14.5px;
}
input[type="email"]:focus, input[type="password"]:focus, input[type="text"]:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); outline: none;
}
.password-wrap input { padding-right: 44px; }
.forgot-link, .back-link { color: var(--text-soft); }
.forgot-link:hover, .back-link:hover { color: var(--accent); text-decoration: underline; }
button.submit { width: 100%; height: 44px; margin-top: 6px; font-size: 14.5px; }
.card .error { background: var(--danger-tint); border: 1px solid #f4c3cc; color: #9f1239; }
.card .notice { background: var(--accent-2-tint); border: 1px solid #b5e3cf; color: #0a5c41; }

/* ---------- Small screens (re-stated here: this file loads after each page's own media rules) ---------- */
@media (max-width: 860px) {
  .sidebar { width: 264px; box-shadow: var(--shadow-md); }
  .hero { padding: 60px 16px 14px; }
  .toolbar { margin: 0 16px 16px; }
  .status-line { padding: 0 16px; }
  .table-wrap { padding: 0 16px; }
  .grid { padding: 0 16px; gap: 12px; }
  .panel { margin: 0 16px 24px; }
  #keywordInput, select#marketSelect, select#categorySelect { flex: 1 1 100%; max-width: none; min-width: 0; }
  button#fetchBtn, button#searchBtn { flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
  .pcard:hover { transform: none; }
}
