:root {
  --bg: #0f0f17;
  --card: #1a1a2e;
  --border: rgba(255,255,255,.08);
  --accent: #7c3aed;
  --accent2: #a78bfa;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --green: #22c55e;
  --blue: #3b82f6;
  --orange: #f97316;
  --red: #ef4444;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  line-height: 1.5;
}

a { color: var(--accent2); text-decoration: none; }
button, input, select, textarea { font-family: inherit; }
button, a, input, select, textarea { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent2); outline-offset: 3px; }

/* --- Login page --- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 100%;
  max-width: 360px;
}
.login-card h1 {
  font-size: 1.4rem;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.login-card p.sub { color: var(--muted); font-size: .85rem; margin-bottom: 24px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .8rem; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--text);
  font-size: .9rem;
}
.field input:focus { outline: none; border-color: var(--accent); }
button.primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 11px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
}
button.primary:hover { background: #6d28d9; }
.error-msg { color: var(--red); font-size: .82rem; margin-top: 10px; min-height: 1em; }

/* --- Dashboard layout --- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  flex-shrink: 0;
}
.brand { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.brand-name {
  font-weight: 700;
  font-size: 1.05rem;
  background: linear-gradient(135deg, #fff, var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.brand-sub { font-size: .72rem; color: var(--muted); }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  font-size: .88rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  width: 100%;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  text-align: left;
}
.nav-link:hover { color: var(--text); background: rgba(255,255,255,.03); }
.nav-link.active {
  color: var(--accent2);
  background: rgba(124,58,237,.12);
  border-left-color: var(--accent);
}
.nav-link .badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: .68rem;
  padding: 1px 7px;
  border-radius: 10px;
}
.nav-logout { margin-top: 24px; }

.content { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1200px; }
.content h1 { font-size: 1.5rem; margin-bottom: 24px; }

/* --- Cards / stats --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; padding: 18px 20px; }
.stat-card .label { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 8px; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.orange { color: var(--orange); }
.stat-card .value.blue { color: var(--blue); }

/* --- Panels / tables --- */
.panel { display: none; }
.panel.active { display: block; }

.card { background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; margin-bottom: 24px; }
.card-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-header h2 { font-size: 1rem; font-weight: 600; }
.table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 640px; }
.card p, .stat-card, .modal-header h2 { overflow-wrap: anywhere; }

table { width: 100%; border-collapse: collapse; font-size: .85rem; }
th { text-align: left; padding: 10px 20px; background: rgba(255,255,255,.03); color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; }
td { padding: 12px 20px; border-top: 1px solid var(--border); }
tr:hover td { background: rgba(255,255,255,.02); }

.pill { font-size: .7rem; font-weight: 700; padding: 3px 9px; border-radius: 20px; display: inline-block; }
.pill.delivered, .pill.completed { background: rgba(34,197,94,.15); color: var(--green); }
.pill.pending, .pill.processing { background: rgba(249,115,22,.15); color: var(--orange); }
.pill.failed, .pill.rejected { background: rgba(239,68,68,.15); color: var(--red); }
.pill.refunded { background: rgba(59,130,246,.15); color: var(--blue); }
.pill.awaiting_payment { background: rgba(59,130,246,.15); color: var(--blue); }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.toolbar input, .toolbar select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 10px;
  color: var(--text);
  font-size: .82rem;
}
.toolbar .spacer { flex: 1; }

.btn-sm {
  border: none;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: .78rem;
  font-weight: 600;
  cursor: pointer;
  margin-right: 6px;
}
.btn-sm.approve { background: rgba(34,197,94,.15); color: var(--green); }
.btn-sm.reject { background: rgba(239,68,68,.15); color: var(--red); }
.btn-sm.edit { background: rgba(124,58,237,.15); color: var(--accent2); }
.btn-sm.muted-btn { background: var(--bg); color: var(--muted); border: 1px solid var(--border); }

.muted { color: var(--muted); }
.empty-row td { text-align: center; color: var(--muted); padding: 30px; }
.pagination { display: flex; gap: 8px; align-items: center; padding: 14px 20px; }
.pagination button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  font-size: .8rem;
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* --- Modale fiche produit --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h2 { font-size: 1.05rem; font-weight: 600; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-body label { font-size: .78rem; color: var(--muted); display: block; margin-bottom: 4px; }
.modal-body input, .modal-body textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 10px;
  color: var(--text);
  font-size: .85rem;
  font-family: inherit;
}
.modal-body input:disabled, .modal-body textarea:disabled { opacity: .5; cursor: not-allowed; }
.modal-row { display: flex; gap: 10px; }
.modal-row > div { flex: 1; min-width: 0; }
.discount-rule { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.discount-rule select { max-width: 100%; min-height: 40px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 6px; }
.discount-heading { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.modal-actions { display: flex; gap: 8px; flex-wrap: wrap; padding-top: 8px; border-top: 1px solid var(--border); margin-top: 4px; }

/* --- Responsive (mobile/tablet) --- */
.product-editor { max-width: 880px; margin: 0 auto; padding: 28px 20px; }
.product-back { display: inline-flex; align-items: center; min-height: 44px; margin-bottom: 12px; }
.product-editor h1 { font-size: 1.3rem; overflow-wrap: anywhere; }
.user-pricing { padding: 18px; border: 1px solid var(--border); border-radius: 12px; }
.user-pricing h2 { font-size: .95rem; font-weight: 600; }
.user-pricing > p { font-size: .82rem; margin-bottom: 16px; }
.user-price-row { display: flex; align-items: center; gap: 10px; padding: 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.user-price-row input:first-child { flex: 1; min-width: 0; }
.user-price-row input[type="number"] { width: 100px; }
.user-price-row > span { white-space: nowrap; color: var(--muted); }
.user-price-row .btn-sm { margin-right: 0; min-height: 44px; }
.visibility-notice { padding: 12px; background: rgba(249,115,22,.1); border-radius: 8px; color: var(--orange); }
@media (max-width: 900px) {
  .login-card { padding: 28px 22px; }

  .layout { flex-direction: column; }

  .sidebar {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    padding: 12px;
    gap: 6px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .brand { grid-column: 1 / -1; padding: 0 4px 10px; margin-bottom: 4px; }
  .nav-link {
    justify-content: center;
    text-align: center;
    min-width: 0;
    min-height: 48px;
    padding: 10px 8px;
    border-radius: 8px;
    border-left: none;
    border: 1px solid var(--border);
  }
  .nav-link.active { border-color: var(--accent); }
  .nav-logout { grid-column: 1 / -1; margin-top: 4px; }

  .content { width: 100%; padding: 20px 16px; max-width: 100%; }
  .content h1 { font-size: 1.2rem; margin-bottom: 16px; }

  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 24px; }
  .stat-card { padding: 14px 16px; }
  .stat-card .value { font-size: 1.25rem; }

  .card-header { flex-wrap: wrap; gap: 8px; padding: 14px 16px; }

  .toolbar { padding: 14px 16px; }
  .toolbar input, .toolbar select, .toolbar textarea { width: 100% !important; min-width: 0; font-size: 16px; min-height: 44px; }
  .toolbar .btn-sm { width: 100%; margin-right: 0; }
  .toolbar .spacer { display: none; }
  .btn-sm, .pagination button { min-height: 44px; }
  th, td { padding: 12px 14px; }
  td { overflow-wrap: anywhere; }
  td input:not([type="checkbox"]), td select { font-size: 16px; min-height: 44px; }
  input[type="checkbox"] { width: 20px; height: 20px; vertical-align: middle; }

  .field input, .modal-body input, .modal-body textarea { font-size: 16px; min-height: 44px; }
  .modal-overlay { padding: 12px; }
  .modal-box { max-height: calc(100dvh - 24px); }
  .modal-header, .modal-body { padding: 16px; }
  .modal-close { min-width: 44px; min-height: 44px; flex-shrink: 0; }
  .modal-actions .btn-sm { flex: 1 1 160px; margin-right: 0; }

  .pagination { flex-wrap: wrap; justify-content: center; text-align: center; }
  .pagination span { flex-basis: 100%; order: -1; }
}

@media (max-width: 480px) {
  .product-editor { padding: 16px 12px; }
  .user-pricing { padding: 12px; }
  .user-price-row { flex-wrap: wrap; gap: 8px; }
  .user-price-row input:first-child { flex-basis: 100%; }
  .user-price-row input[type="number"] { flex: 1; min-width: 0; }
  .sidebar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: 16px 12px; }
  .stat-card { padding: 14px 12px; }
  .modal-row { flex-direction: column; }
}

@media (max-width: 350px) {
  .stat-grid { grid-template-columns: minmax(0, 1fr); }
}
