:root {
  --bg: #0b0f14;
  --panel: #131a23;
  --panel-2: #1a232e;
  --line: #253141;
  --text: #e6edf3;
  --muted: #94a6ba;
  --accent: #34d399;
  --accent-dim: #0f3d31;
  --info: #38bdf8;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 80% -10%, #10231c 0%, var(--bg) 55%);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

button, input, select, textarea { font: inherit; color: inherit; }

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 9px;
  padding: 8px 13px;
  transition: border-color 0.15s, background 0.15s, transform 0.05s;
}
button:hover:not(:disabled) { border-color: #3a4b60; background: #202b38; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06231b; font-weight: 650; }
button.primary:hover:not(:disabled) { background: #4ade80; border-color: #4ade80; }
button.ghost { background: transparent; }
button.danger { border-color: #4a2a2f; color: var(--danger); background: transparent; }
button.small { padding: 5px 9px; font-size: 13px; border-radius: 7px; }

input, select, textarea {
  background: #0d141c;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 10px;
  width: 100%;
  outline: none;
}
input:focus, select:focus, textarea:focus { border-color: #3f5a78; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.12); }
textarea { resize: vertical; min-height: 160px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; line-height: 1.45; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; min-width: 140px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.login h1 { margin: 0 0 6px; font-size: 22px; letter-spacing: -0.02em; }
.login p.sub { margin: 0 0 20px; color: var(--muted); font-size: 14px; }
.login .error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 10px; }
.brand-mark { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; letter-spacing: -0.02em; }
.brand-mark span.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 12px var(--accent); }

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 18px;
  padding: 12px 20px;
  background: rgba(11, 15, 20, 0.86);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.tabs button { border: 0; background: transparent; padding: 6px 14px; border-radius: 8px; color: var(--muted); font-size: 14px; }
.tabs button.active { background: var(--panel-2); color: var(--text); box-shadow: inset 0 0 0 1px var(--line); }
.topbar .spacer { flex: 1; }
.stat-inline { display: flex; gap: 16px; color: var(--muted); font-size: 13px; }
.stat-inline b { color: var(--text); font-weight: 600; }

main { padding: 18px 20px 80px; max-width: 1500px; margin: 0 auto; }

.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px; margin-bottom: 14px;
}
.scrape-bar {
  border-color: #1c6b52;
  background: linear-gradient(180deg, rgba(52, 211, 153, 0.07), rgba(19, 26, 35, 0) 70%), var(--panel);
}
.scrape-bar label { margin-bottom: 5px; }
.scrape-bar button.primary { align-self: flex-end; padding: 9px 16px; }
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  border-radius: 999px; padding: 5px 12px; font-size: 13px;
}
.chip.active { background: var(--accent-dim); border-color: #1c6b52; color: #a7f3d0; }

/* ---------- grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; display: flex; flex-direction: column;
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.card:hover { transform: translateY(-2px); border-color: #34455a; }
.card .thumb { position: relative; aspect-ratio: 1 / 1; background: #0d141c; }
.card .thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.card .thumb .badges { position: absolute; inset: 8px 8px auto 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.badge {
  font-size: 11px; padding: 3px 7px; border-radius: 6px; background: rgba(6, 12, 18, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08); color: #d7e3ef; backdrop-filter: blur(4px);
}
.badge.hot { color: #a7f3d0; border-color: #1c6b52; }
.badge.season { color: #fde68a; border-color: #7a5b12; }
.card .body { padding: 11px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.card .title { font-size: 13.5px; line-height: 1.35; height: 3.9em; overflow: hidden; }
.card .prices { display: flex; align-items: baseline; gap: 8px; }
.card .prices .price { font-size: 17px; font-weight: 700; color: #f0fdf4; }
.card .prices .was { font-size: 12px; color: var(--muted); text-decoration: line-through; }
.card .meta { display: flex; gap: 10px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.card .score { height: 4px; background: #0d141c; border-radius: 4px; overflow: hidden; }
.card .score i { display: block; height: 100%; background: linear-gradient(90deg, #22c55e, #a3e635); }
.card .actions { display: flex; gap: 6px; margin-top: auto; }
.card .actions button { flex: 1; font-size: 12.5px; padding: 7px 8px; }

/* ---------- drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(3, 6, 10, 0.6); z-index: 40; display: flex; justify-content: flex-end; }
.drawer {
  width: min(760px, 100%); height: 100%; overflow-y: auto;
  background: var(--panel); border-left: 1px solid var(--line); padding: 18px 20px 60px;
  box-shadow: var(--shadow);
}
.drawer header { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 14px; }
.drawer header h2 { margin: 0; font-size: 17px; line-height: 1.35; }
.drawer section { border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
.drawer h3 { margin: 0 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pill-price { font-size: 26px; font-weight: 700; }
.pricing-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.pricing-table td { padding: 5px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.06); }
.pricing-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
.pricing-table tr.total td { border-bottom: 0; font-weight: 700; color: #a7f3d0; }
.spec-list { display: flex; flex-wrap: wrap; gap: 6px; }
.spec { font-size: 12px; border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px; color: var(--muted); }
.spec b { color: var(--text); font-weight: 600; }
.notice { border: 1px solid #7a5b12; background: rgba(251, 191, 36, 0.08); color: #fde68a; border-radius: 9px; padding: 9px 11px; font-size: 13px; margin-bottom: 10px; }
.notice.err { border-color: #7f2a34; background: rgba(248, 113, 113, 0.08); color: #fecaca; }
.notice.ok { border-color: #1c6b52; background: rgba(52, 211, 153, 0.08); color: #a7f3d0; }

#depop-url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

/* ---------- email ---------- */
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.check input { width: auto; }
.mail-layout { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 14px; align-items: start; }
.mail-list {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel);
  overflow-y: auto; max-height: 72vh; min-height: 200px;
}
.mail-item {
  display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: transparent; padding: 11px 13px; border-radius: 0;
}
.mail-item:hover { background: var(--panel-2); }
.mail-item.active { background: rgba(52, 211, 153, 0.08); box-shadow: inset 3px 0 0 var(--accent); }
.mail-item .from { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.mail-item.unread .from { color: var(--text); }
.mail-item .subject { display: block; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.mail-item.unread .subject { color: var(--text); font-weight: 600; }
.mail-item .meta { display: flex; gap: 8px; align-items: center; margin-top: 4px; font-size: 11.5px; color: var(--muted); }
.mail-item .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); display: inline-block; }
.mail-reader { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); padding: 16px; min-height: 320px; }
.mail-reader h2 { font-size: 18px; margin: 4px 0 10px; line-height: 1.35; }
.mail-meta { display: grid; grid-template-columns: 74px 1fr; gap: 4px 10px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.mail-meta b { color: var(--text); font-weight: 600; }
.mail-html { width: 100%; height: 480px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.mail-text {
  white-space: pre-wrap; font-size: 13.5px; line-height: 1.55; background: #0d141c;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px; max-height: 480px; overflow: auto;
}
.mail-attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.attachment { font-size: 12px; border: 1px solid var(--line); border-radius: 7px; padding: 4px 9px; color: var(--info); }
.attachment:hover { border-color: #3a4b60; text-decoration: none; }
.modal-backdrop { position: fixed; inset: 0; background: rgba(3, 6, 10, 0.72); z-index: 70; display: grid; place-items: center; padding: 20px; }
.modal {
  width: min(660px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 14px; padding: 18px; box-shadow: var(--shadow); max-height: 92vh; overflow-y: auto;
}
.modal h3 { margin: 0 0 12px; font-size: 16px; }

@media (max-width: 900px) {
  .mail-layout { grid-template-columns: 1fr; }
  .mail-html { height: 380px; }
}

/* ---------- AI image tools ---------- */
.ai-grid { display: grid; grid-template-columns: 160px 1fr; gap: 14px; align-items: start; }
.ai-figure { margin: 0; }
.ai-figure img {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; border-radius: 10px;
  border: 1px solid var(--line); background: #0d141c; display: block;
}
.ai-figure figcaption { font-size: 11.5px; color: var(--muted); margin-top: 6px; text-align: center; }
.ai-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-thumb {
  padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden;
  width: 64px; height: 64px; background: #0d141c; line-height: 0;
}
.ai-thumb img { width: 100%; height: 100%; object-fit: cover; }
.ai-thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(52, 211, 153, 0.25); }
.ai-thumb:hover { border-color: #3a4b60; }

@media (max-width: 560px) {
  .ai-grid { grid-template-columns: 1fr; }
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.04); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.title-cell { max-width: 420px; }
.status { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status.draft { color: #bae6fd; border-color: #164e63; }
.status.exported { color: #fde68a; border-color: #7a5b12; }
.status.published { color: #a7f3d0; border-color: #1c6b52; }
.status.error { color: #fecaca; border-color: #7f2a34; }
.platform { font-size: 11.5px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.platform.ebay { color: #93c5fd; }
.platform.depop { color: #fca5a5; }

/* ---------- panels / settings ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.panel h3 { margin: 0 0 12px; font-size: 15px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr)); gap: 14px; align-items: start; }
.muted { color: var(--muted); }
.small-text { font-size: 12.5px; color: var(--muted); }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------- misc ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #0f1a15; border: 1px solid #1c6b52; color: #a7f3d0;
  padding: 10px 16px; border-radius: 10px; z-index: 60; box-shadow: var(--shadow); font-size: 14px;
}
.toast.err { border-color: #7f2a34; color: #fecaca; background: #1a0f12; }
.spinner {
  width: 15px; height: 15px; border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
[hidden] { display: none !important; }
.skeleton {
  background: linear-gradient(90deg, #131a23 25%, #1a232e 37%, #131a23 63%);
  background-size: 400% 100%; animation: pulse 1.4s ease infinite;
  border-radius: var(--radius); min-height: 260px;
}
@keyframes pulse { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: 10px; }
  .stat-inline { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
  .two-col { grid-template-columns: 1fr; }
  main { padding: 14px 12px 70px; }
  .drawer { width: 100%; }
}
