/* =============================================================================
   Panel licences Origine - même charte que la base (sombre + or jaune)
   ============================================================================= */
:root {
  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --bg: #0c0c0e;
  --text: #f4f4f5;
  --muted: rgba(244, 244, 245, 0.62);
  --faint: rgba(244, 244, 245, 0.36);
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: #141416;
  --surface-soft: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.24);
  --gold: #e9b949;
  --gold-strong: #f6cd5c;
  --gold-soft: rgba(233, 185, 73, 0.16);
  --success: #4ade80;
  --success-soft: rgba(74, 222, 128, 0.14);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(1200px 600px at 10% -10%, rgba(233, 185, 73, 0.08), transparent 60%), var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

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

.label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
}

/* ---------- Boutons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-soft);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--line-strong); background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: scale(0.97); }
.btn--primary { background: var(--gold); border-color: var(--gold); color: #17130a; }
.btn--primary:hover { background: var(--gold-strong); border-color: var(--gold-strong); }
.btn--danger { color: var(--danger); }
.btn--danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn--ghost { background: transparent; }
.btn--icon { width: 36px; min-height: 36px; padding: 0; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- Champs ---------- */
.field { display: flex; flex-direction: column; gap: 8px; }
.input {
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.3);
  outline: none;
  transition: border-color 0.15s;
}
.input:focus { border-color: var(--gold); }
textarea.input { min-height: 80px; resize: vertical; }
.hint { font-size: 12px; color: var(--faint); }

/* ---------- Connexion ---------- */
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login__card {
  width: 100%;
  max-width: 380px;
  padding: 32px 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand__logo {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--gold);
  color: #17130a;
  font-weight: 800;
  font-size: 18px;
}
.brand__name { font-weight: 700; font-size: 17px; }
.brand__sub { font-size: 12px; color: var(--muted); }
.error { min-height: 18px; font-size: 13px; color: var(--danger); }

/* ---------- Mise en page ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
}
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.stat {
  flex: 1 1 140px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.stat__value { font-size: 26px; font-weight: 700; margin-top: 6px; }
.stat__value--gold { color: var(--gold); }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .input { flex: 1 1 220px; min-height: 40px; border-radius: 999px; }

.segmented {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}
.segmented button {
  border: 0;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}
.segmented button.is-active { background: var(--gold); color: #17130a; }

/* ---------- Tableau ---------- */
.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  padding: 14px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--faint);
  border-bottom: 1px solid var(--line);
}
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: rgba(255, 255, 255, 0.02); }

.client__name { font-weight: 600; }
.client__note { font-size: 12px; color: var(--muted); margin-top: 2px; max-width: 280px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.key {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 6px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.3);
  font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
}
.key button {
  border: 0;
  border-radius: 999px;
  background: var(--surface-soft);
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: var(--font);
  letter-spacing: 0;
}
.key button:hover { background: var(--gold-soft); color: var(--gold); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.chip::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip--on { background: var(--success-soft); color: var(--success); }
.chip--off { background: var(--danger-soft); color: var(--danger); }

.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12px; color: var(--faint); }

/* Interrupteur activer / désactiver */
.switch {
  position: relative;
  width: 44px; height: 24px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s;
}
.switch.is-on { background: var(--gold); }
.switch.is-on::after { transform: translateX(20px); background: #17130a; }

.status { display: flex; align-items: center; gap: 10px; }
.actions { display: flex; gap: 6px; justify-content: flex-end; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

/* ---------- Fenêtres (dialog) ---------- */
dialog {
  width: calc(100% - 32px);
  max-width: 460px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.65); }
.dialog__body { padding: 24px; display: flex; flex-direction: column; gap: 16px; }
.dialog__title { margin: 0; font-size: 18px; }
.dialog__actions { display: flex; gap: 10px; justify-content: flex-end; padding-top: 4px; }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  padding: 12px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  box-shadow: var(--shadow);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: calc(100% - 32px);
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast--error { color: var(--danger); }

/* ---------- Téléphone ---------- */
@media (max-width: 760px) {
  .topbar { padding: 14px 16px; }
  .container { padding: 16px; }
  .topbar .brand__sub { display: none; }

  .card { border: 0; background: transparent; }
  thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tr {
    margin-bottom: 12px;
    padding: 6px 0;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
  }
  td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 0;
    text-align: right;
  }
  td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--faint);
    text-align: left;
  }
  td.cell-client { display: block; text-align: left; padding-top: 12px; }
  td.cell-client::before { content: none; }
  .client__note { max-width: none; white-space: normal; }
  .actions { width: 100%; justify-content: stretch; padding-top: 4px; }
  .actions .btn { flex: 1; }
  td.cell-actions::before { content: none; }
}
