/* ---- Compta3 : styles ---- */
:root {
  --bg: #f4f6f9;
  --card: #ffffff;
  --ink: #1a2332;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #1d4ed8;
  --primary-ink: #ffffff;
  --ok: #15803d;
  --err: #b91c1c;
  --warn: #b45309;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.45;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0.4em 0 0.6em; }
h2 { font-size: 1.05rem; margin: 1em 0 0.5em; }

/* Barre de navigation */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: #0f172a; color: #fff; padding: 0 16px;
  position: sticky; top: 0; z-index: 50;
}
.brand { font-weight: 700; font-size: 1.05rem; padding: 12px 0; white-space: nowrap; }
.brand span { color: #60a5fa; }
.mainnav { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.mainnav a {
  color: #cbd5e1; padding: 12px 12px; white-space: nowrap; border-bottom: 3px solid transparent;
  display: flex; align-items: center; gap: 6px;
}
.mainnav a.active { color: #fff; border-bottom-color: #60a5fa; }
.mainnav a:hover { color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: 0.85rem; color: #94a3b8; }
.userbox .logout { color: #f87171; }

.container { max-width: 1100px; margin: 0 auto; padding: 16px; }
.container.narrow { max-width: 560px; }

/* Cartes et formulaires */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-bottom: 16px;
}
.form label { display: block; margin: 10px 0; font-weight: 600; font-size: 0.9rem; }
.form input, .form select, .form textarea {
  display: block; width: 100%; margin-top: 4px; padding: 10px;
  border: 1px solid var(--line); border-radius: 8px; font-size: 1rem; font-family: inherit;
  background: #fff; color: var(--ink);
}
.form textarea { min-height: 70px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }

.btn {
  display: inline-block; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 1rem; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); font-weight: 600; }
.btn-danger { background: #fff; border-color: var(--err); color: var(--err); }
.btn-sm { padding: 5px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: wait; }

/* Messages */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; border: 1px solid; }
.flash-ok { background: #f0fdf4; border-color: #bbf7d0; color: var(--ok); }
.flash-err { background: #fef2f2; border-color: #fecaca; color: var(--err); }
.flash-warn { background: #fffbeb; border-color: #fde68a; color: var(--warn); }

/* Tableaux */
.tablewrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--card); border-radius: var(--radius); }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
table.data th { background: #f8fafc; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.data tr.total td { font-weight: 700; background: #f8fafc; }

/* Pastilles */
.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill-supplier { background: #eff6ff; color: #1d4ed8; }
.pill-sale { background: #f0fdf4; color: #15803d; }
.pill-bank { background: #fdf4ff; color: #a21caf; }
.pill-unpaid { background: #fff7ed; color: #c2410c; }
.pill-paid { background: #f0fdf4; color: #15803d; }
.pill-muted { background: #f1f5f9; color: var(--muted); }

/* Tableau de bord */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .label { font-size: 0.78rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat .value { font-size: 1.25rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Zone d'upload */
.dropzone {
  border: 2px dashed #94a3b8; border-radius: var(--radius); background: #f8fafc;
  padding: 34px 16px; text-align: center; color: var(--muted); cursor: pointer;
}
.dropzone.dragover { border-color: var(--primary); background: #eff6ff; }
.dropzone .big { font-size: 1.05rem; color: var(--ink); font-weight: 600; }

.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; align-items: end; }
.filters label { font-size: 0.78rem; font-weight: 600; color: var(--muted); display: block; }
.filters select, .filters input { padding: 8px; border: 1px solid var(--line); border-radius: 8px; font-size: 0.9rem; background: #fff; }

.muted { color: var(--muted); }
.right { text-align: right; }
.mt { margin-top: 16px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Mobile */
@media (max-width: 640px) {
  .nlabel { display: none; }
  .mainnav a { padding: 12px 10px; font-size: 1.1rem; }
  .uname { display: none; }
  .container { padding: 10px; }
  h1 { font-size: 1.15rem; }
}
@media (min-width: 641px) { .nicon { display: none; } }

/* Impression (situations mensuelles) */
@media print {
  .topbar, .filters, .actions, .btn, .noprint { display: none !important; }
  body { background: #fff; }
  .card { border: none; padding: 0; }
}
