/* JokairLab — feuille de style unique, mobile-first, sans framework */
:root {
  --bg: #0f172a; --bg2: #1e293b; --card: #ffffff; --page: #f1f5f9; --text: #0f172a; --muted: #64748b;
  --line: #e2e8f0; --accent: #e11d48; --accent2: #2563eb; --ok: #16a34a; --warn: #d97706; --crit: #dc2626;
  --radius: 10px; --shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.1);
}
* { box-sizing: border-box; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--page); color: var(--text); line-height: 1.45; }
a { color: var(--accent2); text-decoration: none; } a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; } h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; } h3 { font-size: 1rem; margin: 1rem 0 .4rem; }
h1 small, h2 small { font-weight: 400; color: var(--muted); font-size: .8em; }
p { margin: .4rem 0; } .muted { color: var(--muted); } .small { font-size: .85rem; } .right { text-align: right; } .center { text-align: center; }
.nowrap { white-space: nowrap; } .mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; } .hidden { display: none !important; }

/* Barre du haut */
.topbar { background: var(--bg); color: #fff; display: flex; align-items: center; justify-content: space-between; padding: .6rem 1rem; flex-wrap: wrap; gap: .5rem; }
.brand { color: #fff; font-size: 1.25rem; letter-spacing: .02em; display: flex; align-items: center; gap: .5rem; }
.brand strong { color: var(--accent); } .brand:hover { text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 5px; background: linear-gradient(135deg, var(--accent), #7c3aed); display: inline-block; }
.nav { display: flex; gap: .25rem .9rem; flex-wrap: wrap; align-items: center; font-size: .95rem; }
.nav a { color: #cbd5e1; } .nav a.active, .nav a:hover { color: #fff; text-decoration: none; }
.nav .muted { color: #94a3b8; }
button.link { background: none; border: 0; color: #cbd5e1; cursor: pointer; font: inherit; padding: 0; } button.link:hover { color: #fff; }
form.inline { display: inline; }

.container { max-width: 1100px; margin: 0 auto; padding: 1rem; }
.container.wide { max-width: 1500px; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 2rem 1rem; }

/* Cartes et grilles */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; }
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 720px) { .grid.cols2 { grid-template-columns: 1fr 1fr; } .grid.cols3 { grid-template-columns: repeat(3, 1fr); } .grid.cols4 { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: .8rem 1rem; }
.stat .n { font-size: 1.7rem; font-weight: 700; } .stat .l { color: var(--muted); font-size: .85rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; }
.toolbar .spacer { flex: 1; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 1rem; }
.tabs a { padding: .5rem .8rem; border-radius: var(--radius) var(--radius) 0 0; color: var(--muted); }
.tabs a.active { background: var(--card); color: var(--text); font-weight: 600; box-shadow: var(--shadow); } .tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .count { background: var(--accent); color: #fff; border-radius: 999px; font-size: .7rem; padding: 0 .4rem; margin-left: .3rem; }

/* Tableaux */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #f8fafc; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* Badges */
.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #e2e8f0; color: #334155; white-space: nowrap; }
.badge.ok { background: #dcfce7; color: #166534; } .badge.warn { background: #fef3c7; color: #92400e; } .badge.crit { background: #fee2e2; color: #991b1b; }
.badge.info { background: #dbeafe; color: #1e40af; } .badge.muted { background: #f1f5f9; color: var(--muted); }
.badge.s-basemap { background: #ede9fe; color: #5b21b6; } .badge.s-tuning { background: #fef3c7; color: #92400e; } .badge.s-validated { background: #dcfce7; color: #166534; }
.badge.s-maintenance { background: #dbeafe; color: #1e40af; } .badge.s-paused { background: #f1f5f9; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .3rem; }
.dot.ok { background: var(--ok); } .dot.warning { background: var(--warn); } .dot.critical { background: var(--crit); } .dot.muted { background: #cbd5e1; }

/* Formulaires */
label { display: block; font-size: .85rem; color: #334155; font-weight: 600; margin: .6rem 0 .2rem; }
label .opt { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], select, textarea {
  width: 100%; padding: .55rem .65rem; border: 1px solid #cbd5e1; border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: 2px solid #bfdbfe; border-color: var(--accent2); }
textarea { min-height: 90px; resize: vertical; }
input[type=file] { font: inherit; }
.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; margin: .5rem 0; }
.check input { width: auto; }
.form-row { display: grid; gap: 0 1rem; grid-template-columns: 1fr; }
@media (min-width: 640px) { .form-row.c2 { grid-template-columns: 1fr 1fr; } .form-row.c3 { grid-template-columns: repeat(3, 1fr); } .form-row.c4 { grid-template-columns: repeat(4, 1fr); } }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; align-items: center; }
.btn { display: inline-block; padding: .5rem .9rem; border-radius: 8px; border: 1px solid transparent; background: var(--accent2); color: #fff; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; line-height: 1.2; }
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn.primary { background: var(--accent); } .btn.secondary { background: #fff; color: var(--text); border-color: #cbd5e1; }
.btn.danger { background: #fff; color: var(--crit); border-color: #fecaca; } .btn.sm { padding: .3rem .6rem; font-size: .85rem; }
.btn.ghost { background: transparent; color: var(--accent2); }
.help { font-size: .8rem; color: var(--muted); margin-top: .2rem; }

/* Flash */
.flash { padding: .7rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; font-weight: 500; }
.flash.success { background: #dcfce7; color: #166534; } .flash.error { background: #fee2e2; color: #991b1b; } .flash.info { background: #dbeafe; color: #1e40af; }

/* Alertes d'analyse */
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { padding: .45rem .6rem; border-left: 4px solid var(--line); margin-bottom: .35rem; background: #f8fafc; border-radius: 0 8px 8px 0; font-size: .92rem; cursor: pointer; }
.alert-list li.critical { border-color: var(--crit); } .alert-list li.warning { border-color: var(--warn); } .alert-list li.info { border-color: var(--accent2); }
.alert-list li:hover { background: #f1f5f9; }

/* Fil de discussion */
.thread { display: flex; flex-direction: column; gap: .6rem; }
.msg { max-width: 85%; padding: .6rem .8rem; border-radius: 12px; background: #fff; box-shadow: var(--shadow); }
.msg.mine { align-self: flex-end; background: #dbeafe; }
.msg.tuner:not(.mine) { background: #fff1f2; }
.msg .meta { font-size: .75rem; color: var(--muted); margin-bottom: .2rem; }
.msg.event { align-self: center; max-width: 100%; background: transparent; box-shadow: none; color: var(--muted); font-size: .85rem; text-align: center; }
.msg.event a { color: var(--accent2); }
.msg.instruction { border: 2px solid var(--accent); background: #fff; align-self: stretch; max-width: 100%; }
.msg.instruction.done { border-color: var(--ok); opacity: .8; }
.msg .body { white-space: pre-wrap; word-break: break-word; }

/* Graphique */
.chart-layout { display: grid; gap: 1rem; grid-template-columns: 1fr; }
@media (min-width: 1000px) { .chart-layout { grid-template-columns: 1fr 260px; } }
.chart-box { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: .5rem; min-height: 320px; }
.chart-side { font-size: .85rem; }
.chan-list { list-style: none; padding: 0; margin: 0; max-height: 60vh; overflow: auto; }
.chan-list li { display: flex; align-items: center; gap: .4rem; padding: .2rem 0; border-bottom: 1px dashed var(--line); }
.chan-list .sw { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.chan-list .val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; min-width: 4.5em; text-align: right; }
.chan-list .unit { color: var(--muted); font-size: .75rem; min-width: 3em; }
.presets { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .5rem; }
.presets button { font-size: .8rem; }
.u-legend { display: none; }

/* Fiche véhicule */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem 1rem; font-size: .92rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.big-instruction { border: 2px solid var(--accent); background: #fff1f2; border-radius: var(--radius); padding: .8rem 1rem; margin-bottom: 1rem; }
.reminder { display: flex; justify-content: space-between; gap: .5rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); font-size: .9rem; }
.reminder.due { color: var(--crit); font-weight: 600; }
.dropzone { border: 2px dashed #cbd5e1; border-radius: var(--radius); padding: 1.2rem; text-align: center; color: var(--muted); cursor: pointer; }
.dropzone.over { border-color: var(--accent2); background: #eff6ff; }
.login-box { max-width: 420px; margin: 3rem auto; }
.prose h2, .prose h3, .prose h4 { margin-top: 1.2rem; } .prose ul, .prose ol { padding-left: 1.4rem; } .prose code { background: #f1f5f9; padding: 0 .3rem; border-radius: 4px; }
pre.code { background: #0f172a; color: #e2e8f0; padding: .8rem; border-radius: 8px; overflow: auto; font-size: .85rem; }
@media (max-width: 640px) { .hide-sm { display: none; } h1 { font-size: 1.3rem; } .container { padding: .7rem; } .msg { max-width: 95%; } }
@media print { .topbar, .footer, .actions, .tabs { display: none; } }
