:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e6e8ef;
  --text: #0f172a;
  --muted: #64748b;
  --subtle: #94a3b8;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #eff4ff;
  --accent-line: #c7d7fe;
  --ink: #0b1220;
  --success: #12b76a;
  --success-soft: #ecfdf3;
  --success-text: #027a48;
  --danger: #f04438;
  --danger-soft: #fef3f2;
  --danger-text: #b42318;
  --warning-soft: #fffaeb;
  --warning-text: #b54708;
  --radius: 14px;
  --shadow: 0 2px 18px rgba(15, 23, 42, .06);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ── En-tête ── */
.topbar {
  background: var(--ink);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; font-size: 18px; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; }
.brand small { color: #93c5fd; font-weight: 500; font-size: 12px; margin-left: 2px; }
.topbar .spacer { flex: 1; }
.topbar .who { color: #aeb8c8; font-size: 13.5px; }
.topbar .btn-ghost { color: #dbe4f3; border-color: #26324a; }
.topbar .btn-ghost:hover { background: #1a2436; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 60px; }

/* ── Onglets ── */
.tabs { display: flex; gap: 6px; background: #e9ecf3; padding: 5px; border-radius: 12px; width: fit-content; margin-bottom: 20px; }
.tab {
  border: 0; background: transparent; color: #475467; padding: 9px 18px; border-radius: 9px; cursor: pointer;
  font-weight: 600; display: flex; align-items: center; gap: 8px;
}
.tab[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(15, 23, 42, .1); }
.tab .ico { font-size: 17px; }

/* ── Cartes ── */
.grid { display: grid; grid-template-columns: 340px 1fr; gap: 20px; align-items: start; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 20px; }
.card h2 { font-size: 16px; margin: 0 0 4px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.stack > * + * { margin-top: 20px; }

/* ── Boutons ── */
.btn {
  border: 1px solid transparent; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }
.btn-ghost { background: transparent; color: var(--muted); border-color: var(--border); padding: 7px 12px; }
.btn-danger { background: var(--surface); color: var(--danger-text); border-color: #fecdca; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-big { padding: 16px 22px; font-size: 17px; border-radius: 14px; width: 100%; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .spacer { flex: 1; }

/* ── Champs ── */
label.field { display: block; font-size: 12px; font-weight: 600; color: #475467; margin: 14px 0 6px; }
input[type=text], input[type=password], select {
  width: 100%; padding: 10px 12px; border: 1px solid #d0d5dd; border-radius: 10px; background: #fff; color: var(--text);
}
input:focus, select:focus { outline: 2px solid var(--accent-line); border-color: var(--accent); }
.check { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: #475467; font-size: 14px; }

/* ── Connexion ── */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 10% -10%, #dbe7ff, transparent), var(--bg); }
.login { width: 100%; max-width: 400px; }
.login .brand { color: var(--text); justify-content: center; font-size: 26px; margin-bottom: 6px; }
.login .brand img { width: 40px; height: 40px; }
.login .sub { text-align: center; color: var(--muted); margin: 0 0 18px; }
.login .btn-primary { width: 100%; margin-top: 18px; padding: 12px; }
.login .foot { color: var(--subtle); font-size: 12px; text-align: center; margin-top: 14px; }

/* ── Messages ── */
.msg { border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 12px; }
.msg-error { background: var(--danger-soft); color: var(--danger-text); }
.msg-ok { background: var(--success-soft); color: var(--success-text); }
.msg-warn { background: var(--warning-soft); color: var(--warning-text); }

/* ── QR code ── */
.qr-box { text-align: center; }
.qr-box img { width: 100%; max-width: 260px; aspect-ratio: 1; image-rendering: pixelated; border-radius: 12px; border: 1px solid var(--border); }
.qr-box .expires { color: var(--muted); font-size: 13px; margin-top: 8px; }
.qr-box .url { font-size: 12px; color: var(--subtle); word-break: break-all; margin-top: 4px; user-select: all; }
.qr-empty { border: 2px dashed var(--border); border-radius: 12px; padding: 40px 10px; color: var(--muted); }
.qr-actions { display: flex; gap: 8px; margin-top: 14px; }
.qr-actions select { flex: 1; }
.links { list-style: none; padding: 0; margin: 12px 0 0; font-size: 13px; }
.links li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-top: 1px solid var(--border); }
.links li span { flex: 1; color: #475467; }
.links li.current span { color: var(--accent); font-weight: 600; }

/* ── Dépôt ── */
.drop {
  border: 2px dashed var(--accent-line); background: var(--accent-soft); border-radius: 14px; padding: 26px 16px; text-align: center;
  color: #1e3a8a; transition: background .15s, border-color .15s;
}
.drop.over { background: #dfe9ff; border-color: var(--accent); }
.drop .big { font-size: 34px; line-height: 1; }
.drop p { margin: 8px 0 12px; }

.queue { list-style: none; margin: 14px 0 0; padding: 0; }
.queue li { padding: 9px 0; border-top: 1px solid var(--border); font-size: 13.5px; }
.queue .line { display: flex; gap: 10px; align-items: center; }
.queue .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.queue .state { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.queue .state.ok { color: var(--success-text); }
.queue .state.err { color: var(--danger-text); white-space: normal; }
.bar { height: 5px; background: #eef1f6; border-radius: 9px; margin-top: 6px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 9px; transition: width .2s; }
.queue li.done .bar > i { background: var(--success); }
.queue li.failed .bar > i { background: var(--danger); }

/* ── Explorateur ── */
.path { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; color: var(--muted); margin-bottom: 12px; }
.path b { color: var(--text); }
table.files { width: 100%; border-collapse: collapse; font-size: 14px; }
table.files th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--subtle); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.files td { padding: 9px 10px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
table.files tr:hover td { background: #fafbfd; }
table.files .n { display: flex; align-items: center; gap: 10px; min-width: 0; }
table.files .n a, table.files .n span.t { color: var(--text); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.files .n a:hover { color: var(--accent); }
table.files .ico { font-size: 19px; width: 24px; text-align: center; flex: none; }
table.files td.s, table.files td.d { color: var(--muted); white-space: nowrap; font-size: 13px; }
table.files .pending { color: var(--warning-text); font-size: 12px; margin-left: 6px; }
.empty { color: var(--muted); text-align: center; padding: 30px 10px; }
.drop-overlay { outline: 3px dashed var(--accent); outline-offset: -3px; border-radius: var(--radius); }

.arrivals { list-style: none; padding: 0; margin: 0; font-size: 13.5px; }
.arrivals li { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--border); align-items: baseline; }
.arrivals li:first-child { border-top: 0; }
.arrivals .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.arrivals .via { color: var(--subtle); font-size: 12px; white-space: nowrap; }
.arrivals .new { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: #dcfce7; } to { background: transparent; } }
.badge { font-size: 11px; padding: 2px 7px; border-radius: 99px; background: #f1f3f7; color: #475467; white-space: nowrap; }
.badge-ok { background: var(--success-soft); color: var(--success-text); }

.notice { background: var(--warning-soft); color: var(--warning-text); border-radius: var(--radius); padding: 16px 18px; }

/* ── Fenêtre de dialogue ── */
dialog { border: 0; border-radius: 16px; padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(15, 23, 42, .25); }
dialog::backdrop { background: rgba(15, 23, 42, .4); }
dialog h3 { margin: 0 0 8px; font-size: 17px; }
dialog p { color: var(--muted); margin: 0 0 12px; }
dialog .row-actions { margin-top: 18px; }

/* ── Page d'envoi du téléphone ── */
.phone { max-width: 520px; margin: 0 auto; padding: 18px 16px 50px; }
.phone .head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.phone .head .brand { color: var(--text); font-size: 20px; }
.phone h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
.phone .lead { color: var(--muted); margin: 0 0 18px; }
.phone .summary { display: flex; justify-content: space-between; font-size: 14px; color: #475467; margin: 16px 0 4px; }
.phone .tip { color: var(--subtle); font-size: 12.5px; margin-top: 16px; text-align: center; }
.phone .dead { text-align: center; padding: 40px 10px; }
.phone .dead .big { font-size: 46px; }

@media (max-width: 860px) {
  .grid { grid-template-columns: 1fr; }
  main { padding: 16px 12px 50px; }
  .topbar { padding: 10px 14px; }
  .topbar .who { display: none; }
  table.files thead { display: none; }
  table.files, table.files tbody, table.files tr, table.files td { display: block; width: 100%; }
  table.files tr { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; padding: 10px 4px; border-bottom: 1px solid #f0f2f6; }
  table.files td { padding: 0; border: 0; width: auto; }
  table.files td.d { display: none; }
  table.files td:last-child { grid-column: 1 / -1; }
  table.files .row-actions { justify-content: flex-start; }
  .tabs { width: 100%; }
  .tab { flex: 1; justify-content: center; padding: 9px 8px; }
}
