/* Jia Tungo · charte JIA Corporate */
:root {
  --brand-navy: #001975;
  --brand-navy-deep: #010d38;
  --brand-blue: #007be3;
  --brand-cyan: #00ceea;
  --brand-peach: #ffab8d;
  --brand-cream: #f8f3ea;

  --surface-100: #ffffff;
  --surface-200: #f8f3ea;
  --surface-300: #dde8ff;
  --text-body: #333333;
  --text-heading: #001975;
  --text-muted: #69727d;
  --border: #c1c1c1;
  --border-soft: #e4ddd0;

  --ok: #1f7a4d;
  --ok-bg: #e3f3ea;
  --warn: #8a5a00;
  --warn-bg: #fff1d6;
  --bad: #b3261e;
  --bad-bg: #fde7e5;

  --shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  --radius-card: 20px;
  --radius-field: 10px;
  --radius-pill: 30px;

  --s1: 0.44rem; --s2: 0.67rem; --s3: 1rem; --s4: 1.5rem; --s5: 2.25rem;

  --font-head: "Syne", "Trebuchet MS", system-ui, sans-serif;
  --font-body: "Montserrat", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --nav-h: 64px;
  --top-h: 56px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.5;
  color: var(--text-body);
  background: var(--surface-200);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
h1, h2, h3 { font-family: var(--font-head); color: var(--text-heading); margin: 0; }
h1 { font-size: 1.6rem; line-height: 1.15; font-weight: 600; }
h2 { font-size: 1.25rem; line-height: 1.2; font-weight: 600; }
h3 { font-size: 1.05rem; line-height: 1.25; font-weight: 600; }
p { margin: 0; }
a { color: var(--brand-navy); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--brand-blue); outline-offset: 2px; }

/* Barre du haut */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 var(--s3);
  background: var(--brand-navy);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px;
  background: var(--brand-cream); color: var(--brand-navy);
  display: grid; place-items: center;
  font-family: var(--font-head); font-weight: 700; font-size: 15px;
}
.brand-name { font-family: var(--font-head); font-size: 20px; font-weight: 500; }
.brand-name strong { font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.sync-chip {
  display: inline-flex; align-items: center; gap: 6px;
  border: 2px solid rgba(255,255,255,0.5); background: transparent; color: #fff;
  border-radius: var(--radius-pill); padding: 4px 12px; font-size: 13px; cursor: pointer;
}
.sync-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand-cyan); }
.sync-chip.offline .dot { background: var(--brand-peach); }
.sync-chip.pending { border-color: var(--brand-cyan); }
.icon-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
}
.icon-btn svg { width: 24px; height: 24px; }

.demo-banner {
  background: var(--surface-300); color: var(--brand-navy);
  font-size: 13px; padding: 6px var(--s3); text-align: center;
}

main { max-width: 760px; margin: 0 auto; padding: var(--s3); outline: none; }
main:focus, main:focus-visible { outline: none; }

/* Navigation du bas */
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: var(--surface-100);
  border-top: 1px solid var(--border-soft);
}
.bottomnav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 11.5px; color: var(--text-muted); text-decoration: none; font-weight: 500;
}
.bottomnav a svg { width: 24px; height: 24px; }
.bottomnav a.active { color: var(--brand-navy); }
.bottomnav a.active svg { stroke-width: 2.2; }

/* Blocs */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--s3); margin: var(--s2) 0 var(--s3); }
.page-head .sub { color: var(--text-muted); font-size: 14px; margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 4px; color: var(--text-muted); text-decoration: none; font-size: 14px; margin-bottom: var(--s2); }
.back svg { width: 18px; height: 18px; }

.card {
  background: var(--surface-100);
  border-radius: var(--radius-card);
  padding: var(--s3);
  margin-bottom: var(--s3);
}
.card > h2, .card > h3 { margin-bottom: var(--s2); }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--s2); margin-bottom: var(--s2); }
.card-head a { font-size: 13px; font-weight: 600; text-transform: uppercase; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: var(--s3); }
.kpi { background: var(--surface-100); border-radius: 16px; padding: 14px; }
.kpi .v { font-family: var(--font-head); font-size: 1.9rem; font-weight: 600; color: var(--brand-navy); line-height: 1.1; }
.kpi .l { font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.kpi.hero { grid-column: span 2; background: var(--brand-navy); }
.kpi.hero .v { color: #fff; font-size: 2.4rem; }
.kpi.hero .l { color: #c9d3f5; }
.kpi.hero .extra { color: var(--brand-cyan); font-size: 13px; margin-top: 6px; }
@media (min-width: 620px) { .kpis { grid-template-columns: repeat(4, 1fr); } .kpi.hero { grid-column: span 2; } }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 110px 1fr 44px; align-items: center; gap: 10px; font-size: 14px; }
.bar-track { height: 10px; background: var(--surface-200); border-radius: 6px; overflow: hidden; }
.bar-track { display: block; }
.bar-fill { display: block; height: 100%; background: var(--brand-blue); border-radius: 6px; }
.bar-row .n { text-align: right; font-weight: 600; color: var(--brand-navy); }

/* Listes */
.list { list-style: none; margin: 0; padding: 0; }
.list li + li { border-top: 1px solid var(--border-soft); }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 2px; text-decoration: none; color: inherit; min-height: 56px;
}
.row .avatar {
  flex: none; width: 42px; height: 42px; border-radius: 12px;
  background: var(--surface-300); color: var(--brand-navy);
  display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; font-size: 15px;
}
.row .avatar svg { width: 24px; height: 24px; }
.row .main { flex: 1; min-width: 0; }
.row .t, .row .m { display: block; }
.row .t { font-weight: 600; color: var(--brand-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .m { font-size: 13px; color: var(--text-muted); }
.row .chev { color: var(--border); }
.row .chev svg { width: 20px; height: 20px; }
.empty { color: var(--text-muted); font-size: 14px; padding: var(--s3) 0; text-align: center; }

/* Badges */
.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 20px; background: var(--surface-300); color: var(--brand-navy); white-space: nowrap; }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
.badge.mute { background: #eceae5; color: var(--text-muted); }

/* Alertes */
.alert { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; margin-bottom: 8px; text-decoration: none; color: inherit; }
.alert svg { flex: none; width: 22px; height: 22px; margin-top: 1px; }
.alert.bad { background: var(--bad-bg); color: var(--bad); }
.alert.warn { background: var(--warn-bg); color: var(--warn); }
.alert.info { background: var(--surface-300); color: var(--brand-navy); }
.alert .t { font-weight: 600; }
.alert .m { font-size: 13px; opacity: 0.9; }

/* Filtres */
.search { position: relative; margin-bottom: var(--s2); }
.search input { width: 100%; padding: 12px 14px 12px 42px; border: 1px solid var(--border); border-radius: var(--radius-field); background: var(--surface-100); }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--text-muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: var(--s3); scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { text-decoration: none; flex: none; border: 2px solid var(--brand-navy); background: transparent; color: var(--brand-navy); border-radius: var(--radius-pill); padding: 5px 14px; font-size: 14px; font-weight: 500; cursor: pointer; }
.chip.on { background: var(--brand-navy); color: #fff; }

/* Boutons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-head); font-weight: 600; font-size: 15px; text-transform: uppercase; letter-spacing: 0.02em;
  border: 3px solid var(--brand-navy); border-radius: var(--radius-pill);
  padding: 9px 26px; background: transparent; color: var(--brand-navy);
  text-decoration: none; cursor: pointer; min-height: 48px;
}
.btn.primary { background: var(--brand-navy); color: #fff; }
.btn.block { width: 100%; }
.btn svg { width: 20px; height: 20px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: var(--s3); }
.btn-row .btn { flex: 1 1 160px; }
.fab {
  position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 15;
  width: 58px; height: 58px; border-radius: 50%; border: none;
  background: var(--brand-navy); color: #fff; box-shadow: var(--shadow);
  display: grid; place-items: center; text-decoration: none;
}
.fab svg { width: 28px; height: 28px; }
@media (min-width: 800px) { .fab { right: calc(50% - 360px); } }

/* Formulaires */
.form { display: grid; gap: 14px; }
.field label { display: block; font-size: 14px; font-weight: 600; color: var(--brand-navy); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--text-muted); margin-top: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; min-height: 48px;
  border: 1px solid var(--border); border-radius: var(--radius-field); background: var(--surface-100);
}
.field textarea { min-height: 84px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { margin: 0; border: 2px solid var(--border); border-radius: 12px; padding: 10px 14px; font-weight: 500; color: var(--text-body); cursor: pointer; min-height: 46px; display: inline-flex; align-items: center; gap: 6px; }
.seg input:checked + label { border-color: var(--brand-navy); background: var(--surface-300); color: var(--brand-navy); font-weight: 600; }
.seg input:focus-visible + label { outline: 3px solid var(--brand-blue); outline-offset: 2px; }

/* Fiche */
.profile { display: flex; gap: 14px; align-items: center; }
.profile .big-avatar { width: 64px; height: 64px; border-radius: 18px; background: var(--brand-navy); color: #fff; display: grid; place-items: center; font-family: var(--font-head); font-weight: 600; font-size: 22px; flex: none; }
.profile .big-avatar svg { width: 34px; height: 34px; }
.facts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: var(--s3); }
.facts div span { display: block; font-size: 12.5px; color: var(--text-muted); }
.facts div b { font-weight: 600; color: var(--brand-navy); }
.code-tag { font-family: var(--font-head); font-weight: 700; letter-spacing: 0.04em; font-size: 15px; background: var(--surface-200); color: var(--brand-navy); padding: 3px 10px; border-radius: 8px; }

/* Chronologie */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline li { position: relative; padding: 0 0 16px 28px; }
.timeline li::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: -6px; width: 2px; background: var(--border-soft); }
.timeline li:last-child::before { display: none; }
.timeline li::after { content: ""; position: absolute; left: 2px; top: 5px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-100); border: 3px solid var(--brand-blue); }
.timeline li.ev-deces::after, .timeline li.ev-vol::after { border-color: var(--bad); }
.timeline li.ev-mise_bas::after, .timeline li.ev-transfert::after { border-color: var(--ok); }
.timeline .d { font-size: 12.5px; color: var(--text-muted); }
.timeline .t { font-weight: 600; color: var(--brand-navy); }
.timeline .n { font-size: 14px; }

/* Arbre de la chaîne */
.tree, .tree ul { list-style: none; margin: 0; padding: 0; }
.tree ul { margin-left: 14px; padding-left: 16px; border-left: 2px solid var(--surface-300); }
.tree li { margin: 8px 0; }
.node { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-200); text-decoration: none; color: inherit; }
.node.root { background: var(--brand-navy); color: #fff; }
.node.root .m { color: #c9d3f5; }
.node.root .t { color: #fff; }
.node.due { background: var(--warn-bg); }
.node.late { background: var(--bad-bg); }
.node .gen { font-family: var(--font-head); font-weight: 700; font-size: 12px; border-radius: 8px; padding: 2px 7px; background: var(--surface-100); color: var(--brand-navy); }
.node.root .gen { background: var(--brand-cyan); color: var(--brand-navy-deep); }
.node .t { font-weight: 600; color: var(--brand-navy); font-size: 14.5px; }
.node .m { font-size: 12.5px; color: var(--text-muted); }

.chain-stats { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--text-muted); }
.chain-stats b { color: var(--brand-navy); font-size: 15px; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--border-soft); }
th { font-size: 12.5px; color: var(--text-muted); font-weight: 600; }
td.n, th.n { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 600; color: var(--brand-navy); }

/* Scanner */
.scan-box { position: relative; background: var(--brand-navy-deep); border-radius: var(--radius-card); overflow: hidden; aspect-ratio: 1; max-width: 420px; margin: 0 auto var(--s3); display: grid; place-items: center; color: #c9d3f5; text-align: center; padding: 20px; }
.scan-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid var(--brand-cyan); border-radius: 18px; pointer-events: none; }

/* Menu Plus */
.menu-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-item { background: var(--surface-100); border-radius: 18px; padding: 16px; text-decoration: none; color: var(--brand-navy); display: grid; gap: 8px; min-height: 110px; }
.menu-item svg { width: 28px; height: 28px; color: var(--brand-blue); }
.menu-item b { font-family: var(--font-head); font-weight: 600; font-size: 16px; }
.menu-item span { font-size: 13px; color: var(--text-muted); }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px); transform: translate(-50%, 20px); background: var(--brand-navy-deep); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; max-width: 90vw; box-shadow: var(--shadow); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.muted { color: var(--text-muted); }
.small { font-size: 13px; }
.mt { margin-top: var(--s3); }
.label-print { display: none; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* Impression (rapport PDF, étiquette) */
@media print {
  body { background: #fff; padding: 0; }
  .topbar, .bottomnav, .demo-banner, .fab, .no-print, .toast { display: none !important; }
  main { max-width: none; padding: 0; }
  .card { padding: 0; margin-bottom: 18px; break-inside: avoid; }
  .print-head { display: block !important; margin-bottom: 16px; }
}
.print-head { display: none; }

/* Pas encore connecté : seul l'écran de connexion */
.no-session .bottomnav, .no-session .topbar-actions { display: none !important; }
