/* ERP Dragon Royal — portail. Mêmes couleurs que la caisse (thème « Dragon Royal ») : contenu clair, barre noire, rouge dragon. */
:root {
  --bg: #eef2f7; --surface: #ffffff; --surface-2: #f5f7fb; --border: #e2e8f0; --border-strong: #cbd5e1;
  --text: #111827; --muted: #64748b; --accent: #dc2626; --accent-2: #b91c1c; --accent-ink: #ffffff;
  --side: #0b0e14; --ok: #15803d; --warn: #b45309; --danger: #b91c1c;
  --r: 14px; --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0e14; --surface: #141923; --surface-2: #1b2130; --border: #263042; --border-strong: #334155;
    --text: #e5e7eb; --muted: #94a3b8; --accent: #ef4444; --accent-2: #f87171; --side: #05070b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, sans-serif; min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
[hidden] { display: none !important; }

/* Barre du haut */
.barre { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--side); color: #f8fafc; }
.marque { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; font-size: 16px; letter-spacing: .01em; }
.marque img { width: 34px; height: 34px; border-radius: 9px; }
.menu { margin-left: auto; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.menu button { background: transparent; border: 1px solid rgba(255, 255, 255, .18); color: #f8fafc; border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 13.5px; }
.menu button:hover, .menu button.on { background: rgba(255, 255, 255, .12); }
.menu .moi { font-size: 13px; color: #cbd5e1; margin-right: 4px; }
.menu .court { display: none; }

main { max-width: 1080px; margin: 0 auto; padding: 22px 16px 60px; }
.attente { color: var(--muted); text-align: center; padding: 60px 0; }
h1 { font-size: 24px; margin: 4px 0 4px; letter-spacing: -.02em; }
h2 { font-size: 16px; margin: 26px 0 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 650; }
.sous { color: var(--muted); margin: 0 0 18px; }

/* Connexion */
.connexion { max-width: 380px; margin: 8vh auto 0; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 28px 24px; box-shadow: var(--shadow); text-align: center; }
.connexion img { width: 72px; height: 72px; border-radius: 18px; }
.connexion h1 { margin-top: 12px; }
.connexion form { display: grid; gap: 12px; margin-top: 18px; text-align: left; }
label { display: grid; gap: 5px; font-size: 13.5px; color: var(--muted); font-weight: 550; }
input[type=text], input[type=password], input[type=url], input[type=number], select {
  width: 100%; padding: 11px 12px; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.erreur { color: var(--danger); min-height: 1.2em; font-size: 14px; margin: 0; }
.aide { color: var(--muted); font-size: 13px; margin: 0; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 16px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); cursor: pointer; font-weight: 600; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.principal { background: linear-gradient(180deg, #e53935, #d32f2f); border-color: transparent; color: var(--accent-ink); }
.btn.principal:hover { filter: brightness(1.05); }
.btn.danger { color: var(--danger); }
.btn.petit { padding: 6px 10px; font-size: 13.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Tuiles */
.tuiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tuile { display: grid; gap: 6px; padding: 18px; min-height: 120px; border-radius: var(--r); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
  color: var(--text); text-decoration: none; position: relative; overflow: hidden; transition: transform .12s, border-color .12s; }
.tuile:hover { transform: translateY(-2px); border-color: var(--accent); }
.tuile .ic { width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; font-size: 22px; background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tuile b { font-size: 17px; }
.tuile small { color: var(--muted); }
.tuile .compte { position: absolute; top: 14px; right: 14px; font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 2px 8px; }
.vide { padding: 30px; text-align: center; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--r); }
.bandeau { padding: 12px 14px; border-radius: 12px; margin: 0 0 16px; background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); }
.bandeau.rouge { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.bandeau .btn { margin: 6px 0 0 2px; vertical-align: middle; }
.pied { margin-top: 26px; text-align: center; }
.carte + .aide { margin-top: 8px; }
#menu .pastille { display: inline-block; min-width: 18px; height: 18px; line-height: 18px; margin-left: 6px; padding: 0 5px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
#menu .pastille[hidden] { display: none; }

/* Administration */
.onglets { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 16px; }
.onglets button { border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 7px 14px; cursor: pointer; font-weight: 600; }
.onglets button.on { background: var(--text); color: var(--surface); border-color: var(--text); }
.carte { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.ligne { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: center; padding: 12px 14px; border-top: 1px solid var(--border); }
.ligne:first-child { border-top: 0; }
.ligne .qui b { display: block; }
.ligne .qui small { color: var(--muted); display: block; }
.ligne.ferme { opacity: .55; }
.badges { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 5px; }
.badge { font-size: 12px; border-radius: 999px; padding: 2px 8px; background: var(--surface-2); border: 1px solid var(--border); color: var(--muted); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, transparent); background: color-mix(in srgb, var(--ok) 8%, transparent); }
.badge.rouge { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, transparent); }
.badge.or { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.entete { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
table.journal { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.journal td, table.journal th { padding: 8px 10px; border-top: 1px solid var(--border); text-align: left; vertical-align: top; }
table.journal th { color: var(--muted); font-weight: 600; border-top: 0; }
.defile { overflow-x: auto; }

/* Fenêtre */
.fond { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .45); display: grid; place-items: center; padding: 16px; overflow-y: auto; }
.fenetre { width: min(560px, 100%); background: var(--surface); border-radius: 18px; padding: 22px; box-shadow: 0 20px 60px rgba(0, 0, 0, .3); max-height: calc(100vh - 32px); overflow-y: auto; }
.fenetre h3 { margin: 0 0 14px; font-size: 19px; }
.form { display: grid; gap: 12px; }
.deux { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.case { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: 14.5px; }
.case input { width: 18px; height: 18px; accent-color: var(--accent); }
.module { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.actions .gauche { margin-right: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.secret { font: 700 22px ui-monospace, Menlo, monospace; letter-spacing: 2px; text-align: center; padding: 14px; border-radius: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); user-select: all; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%) translateY(30px); opacity: 0; transition: .2s; z-index: 60;
  background: #111827; color: #f9fafb; padding: 10px 16px; border-radius: 12px; font-weight: 600; max-width: calc(100vw - 32px); pointer-events: none; }
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 560px) {
  .deux { grid-template-columns: 1fr; }
  .marque span, .menu .moi, .menu .long { display: none; }
  .menu .court { display: inline; }
  .menu { flex-wrap: nowrap; }
  .menu button { padding: 6px 10px; }
  .ligne { grid-template-columns: 1fr; }
  .ligne > .badge { justify-self: start; }
  main { padding-top: 16px; }
  .tuiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .tuile { min-height: 0; padding: 14px; gap: 4px; }
  .tuile .ic { width: 36px; height: 36px; font-size: 19px; }
  .tuile b { font-size: 15px; line-height: 1.25; }
  .tuile .compte { display: none; }
}
