/* GeoDesignWorks Dashboard v2 — design system */
:root {
  --bg: #0f1117;
  --surface: #181c27;
  --surface-2: #1e2333;
  --border: #252a38;
  --border-light: #2f3547;
  --text: #e6e8ee;
  --muted: #8b90a0;
  --muted-2: #6b7080;
  --brand: #6089f8;
  --brand-strong: #3b63f3;
  --accent: #a78bfa;
  --etsy: #f1641e;
  --ok: #34d399;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }
[x-cloak] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
img { display: block; max-width: 100%; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--brand); }

.center-screen {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 1rem; color: var(--muted);
}
.gradient-text {
  background: linear-gradient(135deg, var(--brand), var(--accent));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.muted { color: var(--muted); }
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border-light);
  border-top-color: var(--brand); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem; justify-content: center;
  padding: .55rem .9rem; border-radius: var(--radius-sm); border: 1px solid var(--border-light);
  background: var(--surface-2); color: var(--text); font-size: .85rem; font-weight: 500;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.btn:hover { border-color: var(--brand); background: var(--surface); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand-strong); border-color: var(--brand-strong); color: #fff; }
.btn-primary:hover { background: var(--brand); border-color: var(--brand); }
.btn-etsy { background: var(--etsy); border-color: var(--etsy); color: #fff; }
.btn-etsy:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: .35rem .6rem; font-size: .78rem; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: rgba(248,113,113,.08); }

/* ── Inputs ── */
.input, .select, textarea.input {
  width: 100%; padding: .55rem .75rem; background: var(--bg); color: var(--text);
  border: 1px solid var(--border-light); border-radius: var(--radius-sm); font-size: .88rem;
  font-family: inherit; outline: none; transition: border-color .15s;
}
.input:focus, .select:focus, textarea.input:focus { border-color: var(--brand); }
.field-label { font-size: .78rem; color: var(--muted); margin-bottom: .35rem; display: block; font-weight: 500; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card {
  width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 2.2rem; box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.5rem; margin: 0 0 .3rem; }
.login-card .sub { color: var(--muted); margin: 0 0 1.6rem; font-size: .85rem; }
.login-err { color: var(--danger); font-size: .82rem; margin-top: .6rem; min-height: 1rem; }

/* ── App layout ── */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { padding: 1.2rem 1.3rem; border-bottom: 1px solid var(--border); }
.brand .logo { font-size: 1.15rem; font-weight: 800; letter-spacing: -.02em; }
.brand .tag { font-size: .7rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.nav { padding: .8rem .6rem; display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .8rem; border-radius: var(--radius-sm);
  color: var(--muted); cursor: pointer; font-weight: 500; font-size: .88rem; border: none; background: none;
  text-align: left; width: 100%; transition: all .12s;
}
.nav-item .ico { font-size: 1.05rem; width: 1.3rem; text-align: center; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: linear-gradient(90deg, rgba(96,137,248,.16), rgba(96,137,248,.03)); color: var(--brand); box-shadow: inset 3px 0 0 var(--brand); }
.sidebar-foot { padding: .8rem 1rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--muted-2); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex-shrink: 0; border-bottom: 1px solid var(--border); background: rgba(15,17,23,.8);
  backdrop-filter: blur(8px); position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; padding: 0 1.5rem; gap: 1rem;
}
.content { padding: 1.5rem; max-width: 1400px; width: 100%; }

/* ── Connection pill ── */
.pill {
  display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .7rem; border-radius: 999px;
  font-size: .78rem; font-weight: 500; border: 1px solid var(--border-light); background: var(--surface);
}
.dot { width: 8px; height: 8px; border-radius: 50%; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--danger); }

/* ── Page header ── */
.page-head { margin-bottom: 1.3rem; display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.page-head h2 { font-size: 1.4rem; margin: 0 0 .2rem; }
.page-head .desc { color: var(--muted); font-size: .85rem; }

/* ── Stat strip ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .9rem; margin-bottom: 1.3rem; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.1rem;
}
.stat .label { font-size: .76rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .value { font-size: 1.7rem; font-weight: 700; margin-top: .25rem; }
.stat .value.warn { color: var(--warn); }
.stat .value.danger { color: var(--danger); }
.stat .value.ok { color: var(--ok); }

/* ── Toolbar ── */
.toolbar { display: flex; gap: .7rem; align-items: center; margin-bottom: 1.1rem; flex-wrap: wrap; }
.toolbar .search { flex: 1; min-width: 200px; max-width: 360px; }
.chips { display: flex; gap: .4rem; flex-wrap: wrap; }
.chip {
  padding: .4rem .75rem; border-radius: 999px; border: 1px solid var(--border-light); background: var(--surface);
  color: var(--muted); font-size: .8rem; cursor: pointer; transition: all .12s; white-space: nowrap;
}
.chip:hover { color: var(--text); border-color: var(--brand); }
.chip.active { background: rgba(96,137,248,.15); color: var(--brand); border-color: var(--brand); }
.chip .n { opacity: .7; margin-left: .25rem; }

/* ── Product grid ── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 1rem; }
.product-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: all .15s; display: flex; flex-direction: column;
}
.product-card:hover { border-color: var(--brand); transform: translateY(-2px); box-shadow: var(--shadow); }
.thumb { aspect-ratio: 1; background: var(--surface-2); overflow: hidden; position: relative; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .noimg { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 2rem; }
.pc-body { padding: .8rem; display: flex; flex-direction: column; gap: .55rem; flex: 1; }
.pc-title {
  font-size: .85rem; font-weight: 500; line-height: 1.35; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.3em;
}
.pc-meta { display: flex; gap: .8rem; align-items: center; font-size: .76rem; color: var(--muted); flex-wrap: wrap; }
.pc-meta .price { color: var(--text); font-weight: 600; }
.pc-foot { display: flex; align-items: center; justify-content: space-between; margin-top: auto; padding-top: .5rem; border-top: 1px solid var(--border); }
.tagcount { font-size: .75rem; font-weight: 500; padding: .2rem .5rem; border-radius: 6px; }
.tagcount.ok { color: var(--ok); background: rgba(52,211,153,.1); }
.tagcount.warn { color: var(--warn); background: rgba(251,191,36,.1); }
.tagcount.danger { color: var(--danger); background: rgba(248,113,113,.12); }
.score-badge {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: var(--c, var(--brand));
  border: 2px solid var(--c, var(--brand)); background: color-mix(in srgb, var(--c) 12%, transparent);
}

/* ── Modal / drawer ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8,9,13,.7); backdrop-filter: blur(3px); z-index: 50;
  display: flex; justify-content: flex-end;
}
.drawer {
  width: 100%; max-width: 540px; height: 100%; background: var(--surface); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; box-shadow: var(--shadow); animation: slidein .2s ease;
}
@keyframes slidein { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 1.1rem 1.3rem; border-bottom: 1px solid var(--border); display: flex; gap: 1rem; align-items: center; }
.drawer-head img { width: 56px; height: 56px; border-radius: var(--radius-sm); object-fit: cover; flex-shrink: 0; }
.drawer-head .x { margin-left: auto; }
.drawer-body { padding: 1.3rem; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 1.3rem; }
.drawer-foot { padding: 1rem 1.3rem; border-top: 1px solid var(--border); display: flex; gap: .7rem; justify-content: flex-end; align-items: center; }
.char-counter { font-size: .74rem; color: var(--muted); text-align: right; margin-top: .3rem; }
.char-counter.over { color: var(--danger); }

/* ── Tag editor ── */
.tag-editor { display: flex; flex-wrap: wrap; gap: .45rem; padding: .6rem; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-sm); min-height: 48px; }
.tag-chip { display: inline-flex; align-items: center; gap: .4rem; padding: .3rem .3rem .3rem .6rem; background: var(--surface-2); border: 1px solid var(--border-light); border-radius: 6px; font-size: .8rem; }
.tag-chip.overlap { border-color: var(--warn); color: var(--warn); }
.tag-chip .rm { cursor: pointer; width: 18px; height: 18px; border-radius: 4px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.tag-chip .rm:hover { background: rgba(248,113,113,.15); color: var(--danger); }
.tag-add-row { display: flex; gap: .5rem; margin-top: .6rem; }

/* ── SEO panel ── */
.seo-panel { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; }
.seo-top { display: flex; align-items: center; gap: 1rem; margin-bottom: .8rem; }
.seo-ring { width: 52px; height: 52px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1rem; flex-shrink: 0; }
.seo-warn-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .4rem; }
.seo-warn-list li { font-size: .8rem; color: var(--warn); display: flex; gap: .5rem; align-items: flex-start; }
.seo-warn-list li.ok { color: var(--ok); }
.seo-warn-list li::before { content: "▸"; opacity: .7; }

/* ── Toasts ── */
.toast-stack { position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 100; display: flex; flex-direction: column; gap: .6rem; }
.toast {
  padding: .8rem 1.1rem; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border-light);
  box-shadow: var(--shadow); font-size: .85rem; min-width: 220px; animation: toastin .2s ease;
  border-left: 3px solid var(--brand);
}
.toast.success { border-left-color: var(--ok); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes toastin { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Empty / placeholder ── */
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty .big { font-size: 2.5rem; margin-bottom: .5rem; }
.placeholder-page { text-align: center; padding: 4rem 1rem; color: var(--muted); }
.placeholder-page .big { font-size: 3rem; margin-bottom: 1rem; }

@media (max-width: 720px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .content { padding: 1rem; }
}
