/* ScanHome Dashboard — feuille de style minimale */
:root {
  --bg: #0f1115;
  --surface: #181b22;
  --surface-2: #20242e;
  --border: #2b303c;
  --text: #e7e9ee;
  --muted: #9aa0ad;
  --accent: #4f8cff;
  --accent-d: #3a6fd6;
  --danger: #ff5d5d;
  --ok: #34d17b;
  --warn: #f0b429;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--accent); }
.loading { padding: 60px; text-align: center; color: var(--muted); }

/* ---- Auth ---- */
.auth-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; width: 100%; max-width: 380px;
}
.auth-card h1 { font-size: 22px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; }
.auth-toggle { text-align: center; margin-top: 16px; color: var(--muted); }
.auth-toggle a { cursor: pointer; }

/* ---- Layout ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; padding: 18px 0;
}
.brand { font-weight: 700; font-size: 17px; padding: 4px 20px 18px; }
.brand span { color: var(--accent); }
.nav-item {
  padding: 10px 20px; cursor: pointer; color: var(--muted);
  border-left: 3px solid transparent; user-select: none;
}
.nav-item:hover { color: var(--text); background: var(--surface-2); }
.nav-item.active { color: var(--text); border-left-color: var(--accent); background: var(--surface-2); }
.nav-spacer { flex: 1; }
.nav-user { padding: 14px 20px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.main { flex: 1; padding: 28px 34px; overflow: auto; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.page-head h2 { font-size: 20px; }

/* ---- Composants ---- */
label { display: block; margin-bottom: 4px; color: var(--muted); font-size: 13px; }
input, select, textarea {
  width: 100%; padding: 9px 11px; margin-bottom: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 14px; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
button {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--accent-d); }
button:disabled { opacity: .55; cursor: not-allowed; }
button.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
button.ghost:hover { background: var(--surface-2); }
button.danger { background: var(--danger); }
.btn-row { display: flex; gap: 10px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px; margin-bottom: 16px;
}
.empty { color: var(--muted); padding: 40px; text-align: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.kv { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px solid var(--border); }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--muted); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted);
}
.badge.draft    { background: #2b303c; color: #b9c0ce; }
.badge.scanning { background: #1f3a5c; color: #8ec5ff; }
.badge.ready    { background: #14422c; color: #6fe6a6; }
.badge.listed   { background: #3d3413; color: #f0cf6b; }
.badge.sold     { background: #14422c; color: #6fe6a6; }
.badge.archived { background: #2b303c; color: #8b909c; }
.badge.sent     { background: #1f3a5c; color: #8ec5ff; }
.badge.paid     { background: #14422c; color: #6fe6a6; }
.badge.overdue  { background: #4a1d1d; color: #ff9b9b; }
.badge.cancelled{ background: #2b303c; color: #8b909c; }

.toast {
  position: fixed; bottom: 22px; right: 22px; padding: 12px 18px;
  border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); box-shadow: 0 8px 28px rgba(0,0,0,.4); max-width: 360px;
}
.toast.err { border-color: var(--danger); }
.toast.ok  { border-color: var(--ok); }
.err-msg { color: var(--danger); margin-bottom: 12px; font-size: 13px; }
.modal-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal { background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; width: 100%; max-width: 480px; max-height: 90vh; overflow: auto; }
.modal h3 { margin-bottom: 16px; }
.muted { color: var(--muted); }
.back { cursor: pointer; color: var(--accent); margin-bottom: 14px; display: inline-block; }
@media (max-width: 720px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; padding: 8px; }
  .grid2 { grid-template-columns: 1fr; }
  .main { padding: 18px; }
}

/* ---- Builder 3D ---- */
.builder-body { overflow: hidden; }
#builder { display: flex; flex-direction: column; height: 100vh; }
#b-topbar {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
#b-title { font-weight: 700; font-size: 15px; }
#b-title b { color: var(--accent); }
.b-spacer { flex: 1; }
.b-btn {
  background: var(--accent); color: #fff; border: none; border-radius: 8px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.b-btn:hover { background: var(--accent-d); }
.b-btn.ghost { background: transparent; border: 1px solid var(--border); color: var(--text); }
.b-btn.ghost:hover { background: var(--surface-2); }
.b-btn.ghost.active { background: var(--accent); border-color: var(--accent); color: #fff; }
#b-main { display: flex; flex: 1; min-height: 0; }
#b-catalog {
  width: 190px; background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 12px; flex-shrink: 0;
}
.b-catalog-title {
  font-size: 12px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); margin-bottom: 10px; font-weight: 700;
}
.cat-item {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; margin-bottom: 6px; cursor: pointer;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; color: var(--text); font-size: 13px; text-align: left;
}
.cat-item:hover { border-color: var(--accent); }
.cat-item .ic { font-size: 17px; }
.b-hint { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }
#b-canvas-wrap { flex: 1; position: relative; min-width: 0; background: #0b0d12; }
#b-canvas { display: block; width: 100%; height: 100%; }
#b-status {
  position: absolute; top: 12px; left: 12px; padding: 6px 12px;
  background: rgba(24,27,34,.92); border: 1px solid var(--border);
  border-radius: 8px; font-size: 12px; color: var(--muted);
}

/* ---- Abonnement / plans ---- */
.badge.active, .badge.trialing { background: #14422c; color: #6fe6a6; }
.badge.past_due, .badge.unpaid, .badge.incomplete { background: #4a1d1d; color: #ff9b9b; }
.badge.canceled { background: #2b303c; color: #8b909c; }
.plan-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.plan-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 22px 20px; position: relative;
  display: flex; flex-direction: column;
}
.plan-card.featured { border-color: var(--accent); }
.plan-tag {
  position: absolute; top: -10px; right: 16px; background: var(--accent);
  color: #fff; font-size: 11px; font-weight: 700; padding: 3px 10px;
  border-radius: 20px; text-transform: uppercase; letter-spacing: .04em;
}
.plan-name { font-size: 17px; font-weight: 700; }
.plan-price { font-size: 30px; font-weight: 700; margin: 6px 0 14px; }
.plan-price span { font-size: 13px; font-weight: 400; color: var(--muted); }
.plan-feats { list-style: none; margin: 0 0 18px; flex: 1; }
.plan-feats li { padding: 5px 0; font-size: 13px; border-bottom: 1px solid var(--border); }
.plan-feats li:last-child { border-bottom: none; }
.plan-card button { width: 100%; }
@media (max-width: 720px) { .plan-grid { grid-template-columns: 1fr; } }
