:root {
  --marine: #0B2A5B;
  --marine-800: #0d3269;
  --marine-700: #12407f;
  --accent: #C8A24B;
  --accent-soft: #f3ead2;
  --ink: #1a2233;
  --muted: #6b7686;
  --line: #e4e8ef;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --good: #1f7a4d;
  --good-bg: #e7f4ee;
  --warn: #b06a00;
  --warn-bg: #fbf0dd;
  --danger: #b42318;
  --danger-bg: #fbe9e7;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16,24,40,.05), 0 6px 20px rgba(16,24,40,.05);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
.muted { color: var(--muted); }
.error { color: var(--danger); font-size: 14px; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 18px; margin: 0; }
h3 { font-size: 15px; margin: 0; }
a { color: var(--marine-700); }

/* Buttons */
button { font: inherit; cursor: pointer; border-radius: 9px; border: 1px solid transparent; transition: background .12s, border-color .12s; }
.btn-primary { background: var(--marine); color: #fff; border-color: var(--marine); padding: 10px 18px; font-weight: 600; }
.btn-primary:hover { background: var(--marine-700); }
.btn-primary:disabled { opacity: .55; cursor: default; }
.btn-ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); padding: 8px 14px; font-weight: 500; }
.btn-ghost:hover { border-color: #c1c9d6; background: #fbfcfe; }
.btn-ghost:disabled { opacity: .5; cursor: default; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-danger { color: var(--danger); border-color: #f0c8c3; background: #fff; }
.btn-danger:hover { background: var(--danger-bg); }

/* Brand */
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; flex: none; background: var(--accent); color: var(--marine); display: grid; place-items: center; font-weight: 800; letter-spacing: .5px; object-fit: cover; }
img.brand-mark { border: 1px solid rgba(255,255,255,.25); }
.brand-txt { display: flex; flex-direction: column; line-height: 1.2; }
.brand-txt .muted { font-size: 12px; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px; background: linear-gradient(160deg,#0B2A5B 0%, #12407f 100%); }
.login-card { background: var(--panel); width: 100%; max-width: 380px; padding: 30px; border-radius: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 10px; }
.brand-lg .brand-mark { width: 48px; height: 48px; font-size: 18px; }
.login-card label { font-weight: 600; font-size: 14px; margin-top: 8px; }
.login-card input { padding: 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; }
.login-card input:focus { outline: 2px solid var(--marine); border-color: var(--marine); }
.login-card .btn-primary { margin-top: 10px; }

/* Shell layout */
.shell { display: grid; grid-template-columns: 250px 1fr; min-height: 100vh; }
.sidebar { background: var(--marine); color: #dfe6f2; display: flex; flex-direction: column; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.sidebar .brand { padding: 4px 8px 18px; }
.sidebar .brand-txt strong { color: #fff; font-size: 15px; }
.sidebar .brand-txt .muted { color: #9fb2d4; }
.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav button { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 9px; background: transparent; color: #cdd8ec; border: none; text-align: left; font-weight: 500; }
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button.active { background: rgba(255,255,255,.14); color: #fff; }
.nav button.active .badge { background: var(--accent); color: var(--marine); }
.nav svg { width: 18px; height: 18px; flex: none; opacity: .9; }
.nav .badge { margin-left: auto; background: rgba(255,255,255,.16); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 999px; }
.sidebar-foot { padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12); }
.sidebar-foot .btn-ghost { background: transparent; color: #cdd8ec; border-color: rgba(255,255,255,.2); }
.sidebar-foot .btn-ghost:hover { background: rgba(255,255,255,.08); color: #fff; }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 16px 26px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.view { padding: 24px 26px; max-width: 1180px; width: 100%; }

@media (max-width: 820px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { border: none; }
}

/* Cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.section-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 26px 0 12px; }
.section-title:first-child { margin-top: 0; }

/* Stat cards (dashboard) */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .n { font-size: 30px; font-weight: 800; color: var(--marine); line-height: 1; letter-spacing: -.02em; }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 8px; }
.stat.alert .n { color: var(--danger); }

/* Task cards (atelier) */
.tasks { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.task-card { text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 14px; display: flex; flex-direction: column; gap: 6px; }
.task-card:hover { border-color: var(--marine); }
.task-card.active { border-color: var(--marine); background: #f4f8ff; box-shadow: inset 0 0 0 1px var(--marine); }
.task-card .ic { width: 30px; height: 30px; border-radius: 8px; background: var(--accent-soft); color: var(--marine); display: grid; place-items: center; }
.task-card .ic svg { width: 17px; height: 17px; }
.task-card .t { font-weight: 700; }
.task-card .d { font-size: 12.5px; color: var(--muted); }

/* Forms */
.field { margin-bottom: 14px; }
.field-label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field-label .muted { font-weight: 400; }
textarea, input.txt, select { width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 9px; font: inherit; background: #fff; }
textarea { resize: vertical; }
textarea:focus, input.txt:focus, select:focus { outline: 2px solid var(--marine); border-color: var(--marine); }
#input { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 13.5px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1; min-width: 180px; }
.actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.hint { font-size: 13px; }
code { background: #eef1f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* Upload */
.drop { border: 1.5px dashed #c3ccdb; border-radius: 10px; padding: 14px; text-align: center; color: var(--muted); font-size: 14px; cursor: pointer; background: #fbfcfe; }
.drop:hover { border-color: var(--marine); color: var(--marine); }
.file-tag { display: inline-flex; align-items: center; gap: 8px; background: var(--good-bg); color: var(--good); padding: 4px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; }

/* KPI + chart */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin: 4px 0 16px; }
.kpi { background: linear-gradient(180deg,#fff,#f7f9fc); border: 1px solid var(--line); border-radius: 11px; padding: 14px; }
.kpi .v { font-size: 22px; font-weight: 800; color: var(--marine); letter-spacing: -.01em; }
.kpi .k { font-size: 12.5px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.kpi .h { font-size: 12px; color: var(--muted); margin-top: 4px; }
.chart { margin: 8px 0 18px; }
.chart .ct { font-weight: 700; margin-bottom: 10px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 10px; margin: 6px 0; font-size: 13px; }
.bar-track { background: #eef1f6; border-radius: 6px; height: 20px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg,var(--marine),var(--marine-700)); border-radius: 6px; }
.bar-val { font-variant-numeric: tabular-nums; color: var(--muted); }

/* Output (markdown) */
.output { min-height: 120px; }
.streaming { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 13px; color: var(--muted); }
.output h1, .output h2, .output h3 { color: var(--marine); margin: 18px 0 8px; line-height: 1.25; }
.output h1 { font-size: 20px; } .output h2 { font-size: 17px; } .output h3 { font-size: 15px; }
.output h1:first-child, .output h2:first-child { margin-top: 0; }
.output p { margin: 8px 0; }
.output ul, .output ol { margin: 8px 0; padding-left: 22px; }
.output li { margin: 3px 0; }
.output table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13.5px; display: block; overflow-x: auto; }
.output th, .output td { border: 1px solid var(--line); padding: 7px 10px; text-align: left; vertical-align: top; }
.output th { background: #f0f3f8; color: var(--marine); font-weight: 700; }
.output tr:nth-child(even) td { background: #fafbfd; }

/* Lists (historique / actions) */
.list { display: flex; flex-direction: column; gap: 8px; }
.item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.item:hover { border-color: #c9d2e0; }
.item .grow { flex: 1; min-width: 0; }
.item .ttl { font-weight: 600; }
.item .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.pill { font-size: 12px; font-weight: 700; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.pill.pnl { background: var(--accent-soft); color: #7a5a12; }
.pill.compte_rendu { background: #e7eefb; color: var(--marine-700); }
.pill.ordre_du_jour { background: #eaf6ee; color: var(--good); }
.pill.note_cadrage { background: #f0e9fb; color: #5b3aa6; }
.pill.todo { background: #eef1f6; color: var(--muted); }
.pill.doing { background: var(--warn-bg); color: var(--warn); }
.pill.done { background: var(--good-bg); color: var(--good); }
.pill.overdue { background: var(--danger-bg); color: var(--danger); }

/* Action columns */
.cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 820px) { .cols { grid-template-columns: 1fr; } }
.col h3 { margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }

/* Toast / status */
.status { font-size: 13px; color: var(--muted); }
.saved { color: var(--good); font-weight: 600; }
.empty { text-align: center; color: var(--muted); padding: 30px; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(16,24,40,.45); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: #fff; border-radius: 14px; max-width: 820px; width: 100%; max-height: 88vh; overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: #fff; }
.modal-body { padding: 20px; }
