:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --border: #dfe3e8;
  --text: #1c2430;
  --muted: #5f6b7a;
  --accent: #1f4e79;
  --accent-hover: #173c5e;
  --accent-soft: #e6eef6;
  --ok: #1d7a46;
  --ok-soft: #e3f3ea;
  --warn: #8a5a00;
  --warn-soft: #fdf1d8;
  --danger: #b3261e;
  --danger-soft: #fbe6e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c;
    --surface: #1a2029;
    --surface-2: #222a35;
    --border: #2e3846;
    --text: #e6eaf0;
    --muted: #98a3b3;
    --accent: #6fa8dc;
    --accent-hover: #8dbbe4;
    --accent-soft: #1f3247;
    --ok: #6fcf97;
    --ok-soft: #173326;
    --warn: #f2c26b;
    --warn-soft: #3a2e14;
    --danger: #f28b82;
    --danger-soft: #3d1d1b;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.55; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ----- Structure ----- */
.topbar { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar-inner { max-width: 1080px; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 16px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 650; text-decoration: none; color: var(--text); margin-right: auto; }
.brand img { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; align-items: center; }
.nav a, .nav button { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px; background: none; border: 0; cursor: pointer; }
.nav a:hover, .nav button:hover, .nav a.active { color: var(--text); background: var(--surface-2); }
@media (max-width: 640px) {
  .topbar-inner { gap: 8px; }
  .brand-text { display: none; }
  .nav { overflow-x: auto; scrollbar-width: none; min-width: 0; }
  .nav a, .nav button { padding: 6px 8px; font-size: 0.88rem; white-space: nowrap; }
}
main { max-width: 1080px; margin: 0 auto; padding: 24px 16px 64px; }
.page-head { display: flex; align-items: flex-start; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin: 0; flex: 1 1 auto; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.stack > * + * { margin-top: 16px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card { margin-top: 16px; }

/* ----- Boutons et champs ----- */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface); padding: 8px 14px; border-radius: 8px; cursor: pointer; text-decoration: none; color: var(--text); font-weight: 500; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn.small { padding: 4px 10px; font-size: 0.85rem; }

label.field { display: block; }
label.field > span { display: block; font-weight: 550; margin-bottom: 4px; }
label.field > small { display: block; color: var(--muted); margin-top: 4px; font-size: 0.82rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="date"], input[type="search"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.error-box { background: var(--danger-soft); color: var(--danger); padding: 10px 14px; border-radius: 8px; }
.info-box { background: var(--accent-soft); padding: 10px 14px; border-radius: 8px; }

/* ----- Connexion ----- */
.login { max-width: 380px; margin: 12vh auto 0; padding: 0 16px; }
.login .brand { justify-content: center; margin: 0 0 20px; font-size: 1.2rem; }

/* ----- Liste des réunions ----- */
.meeting-list { list-style: none; margin: 0; padding: 0; }
.meeting-item { display: flex; gap: 16px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); text-decoration: none; color: inherit; }
.meeting-item:last-child { border-bottom: 0; }
.meeting-item:hover { background: var(--surface-2); }
.meeting-date { width: 58px; text-align: center; flex: none; }
.meeting-date .d { font-size: 1.35rem; font-weight: 650; line-height: 1; }
.meeting-date .m { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.meeting-main { flex: 1; min-width: 0; }
.meeting-main .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-card { padding: 0; overflow: hidden; }
.empty { padding: 48px 16px; text-align: center; color: var(--muted); }

.badge { display: inline-block; font-size: 0.78rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--accent-soft); color: var(--accent); }

/* ----- Dépôt de fichier ----- */
.dropzone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px 16px; text-align: center; cursor: pointer; background: var(--surface-2); transition: border-color 0.15s, background 0.15s; }
.dropzone.over, .dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { display: block; font-size: 1.05rem; margin-bottom: 4px; }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width 0.3s; }

/* ----- Détail ----- */
.meta { display: flex; gap: 6px 18px; flex-wrap: wrap; color: var(--muted); font-size: 0.9rem; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 20px 0 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 550; white-space: nowrap; }
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }

.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 10px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li .dot { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--border); flex: none; display: grid; place-items: center; font-size: 0.75rem; }
.steps li.done { color: var(--text); }
.steps li.done .dot { background: var(--ok); border-color: var(--ok); color: #fff; }
.steps li.current { color: var(--text); font-weight: 600; }
.steps li.current .dot { border-color: var(--accent); border-top-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.report h2 { margin-top: 28px; padding-bottom: 6px; border-bottom: 1px solid var(--border); color: var(--accent); }
.report h2:first-child { margin-top: 0; }
.report h3 { margin-top: 18px; }
.report ul { padding-left: 22px; margin: 6px 0; }
.report li + li { margin-top: 4px; }
.report .synthese { font-size: 1.02rem; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.tbl th, table.tbl td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.table-wrap { overflow-x: auto; }
@media (max-width: 560px) {
  table.stack-mobile thead { display: none; }
  table.stack-mobile tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--border); }
  table.stack-mobile td { display: flex; gap: 10px; border: 0; padding: 2px 0; }
  table.stack-mobile td::before { content: attr(data-label); flex: 0 0 96px; color: var(--muted); font-size: 0.8rem; padding-top: 2px; }
  table.stack-mobile td:first-child { font-weight: 600; }
  table.stack-mobile td:first-child::before { display: none; }
}
.tbd { color: var(--warn); font-style: italic; }

.chunk { display: grid; grid-template-columns: 82px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.chunk:last-child { border-bottom: 0; }
.chunk .ts { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--accent); background: none; border: 0; padding: 2px 0; cursor: pointer; text-align: left; align-self: start; }
.chunk .ts:hover { text-decoration: underline; }
.chunk p { margin: 0; white-space: pre-wrap; }
.chunk.playing { background: var(--accent-soft); margin: 0 -12px; padding: 10px 12px; border-radius: 8px; }
@media (max-width: 560px) { .chunk { grid-template-columns: 1fr; gap: 4px; } }

.player { position: sticky; bottom: 0; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px; margin: 24px -16px -64px; }
.player audio { width: 100%; }

dialog { border: 1px solid var(--border); border-radius: var(--radius); padding: 0; background: var(--surface); color: var(--text); width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25); }
dialog::backdrop { background: rgba(10, 15, 25, 0.45); }
dialog form { padding: 20px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #1c2430; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ----- Impression (PDF) ----- */
@media print {
  :root { color-scheme: light; --text: #000; --muted: #444; --accent: #1f4e79; --border: #ccc; --surface: #fff; --bg: #fff; }
  .topbar, .tabs, .toolbar, .player, .no-print, #toast { display: none !important; }
  main { padding: 0; max-width: none; }
  .card { border: 0; box-shadow: none; padding: 0; }
  .report h2 { break-after: avoid; }
  table.tbl tr { break-inside: avoid; }
}
