:root {
  --bg: #f4f6f9; --card: #fff; --ink: #1d2433; --muted: #667085; --line: #e4e7ec;
  --brand: #0f5c4d; --brand-2: #138a72; --brand-soft: #e6f4f0; --accent: #e8a317;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7; --err: #b42318; --err-soft: #fee4e2;
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; }
h2 { font-size: 17px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

/* barre supérieure */
.top { background: var(--brand); color: #fff; display: flex; align-items: center; gap: 22px; padding: 0 22px; height: 56px; position: sticky; top: 0; z-index: 20; }
.top .brand { font-weight: 700; font-size: 16px; color: #fff; display: flex; align-items: center; gap: 9px; }
.top .brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); color: var(--brand); display: grid; place-items: center; font-weight: 800; }
.top nav { display: flex; gap: 4px; flex: 1; }
.top nav a { color: #d6ebe5; padding: 7px 12px; border-radius: 7px; font-weight: 500; }
.top nav a:hover, .top nav a.on { background: rgba(255,255,255,.12); color: #fff; text-decoration: none; }
.top .who { font-size: 13px; color: #d6ebe5; text-align: right; line-height: 1.25; }
.top .who b { color: #fff; }
.top .who a { color: #fff; opacity: .85; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 24px 22px 60px; }
.wrap.wide { max-width: none; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.crumb { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 20px; overflow-x: auto; }
.tabs a { padding: 10px 16px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.on { color: var(--brand); border-bottom-color: var(--brand); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; }
.g2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } .top nav { display: none; } }

.stat { padding: 16px 18px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #f9fafb; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #0c4b3f; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1d2433; }
.btn.danger { color: var(--err); border-color: #fecdca; }
.btn.danger:hover { background: var(--err-soft); }
.btn.sm { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

label { display: block; font-weight: 600; font-size: 13px; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #d0d5dd; border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(19,138,114,.15); }
.field { margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 4px 16px; }
.fields .full { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.t th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr:hover td { background: #fafcfb; }
table.t .r, table.t td.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.t tfoot td { font-weight: 700; background: #f8faf9; }
.scroll { overflow: auto; max-height: 70vh; border: 1px solid var(--line); border-radius: 8px; }
.scroll table.t th { position: sticky; top: 0; z-index: 1; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef2f6; color: #475467; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.err { background: var(--err-soft); color: var(--err); }

.alert { padding: 11px 15px; border-radius: 8px; margin-bottom: 14px; border: 1px solid; }
.alert.success { background: var(--ok-soft); border-color: #bbf7d0; color: #14532d; }
.alert.error { background: var(--err-soft); border-color: #fecdca; color: #7a271a; }
.alert.warning { background: var(--warn-soft); border-color: #fde68a; color: #78350f; }
.alert.info { background: #eff8ff; border-color: #b2ddff; color: #194185; }
.alert ul { margin: 6px 0 0 18px; padding: 0; }

.check { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); }
.check:last-child { border-bottom: 0; }
.check .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 13px; font-weight: 800; flex: none; }
.check .ic.ok { background: var(--ok-soft); color: var(--ok); }
.check .ic.err { background: var(--err-soft); color: var(--err); }
.check .ic.warn { background: var(--warn-soft); color: var(--warn); }

.steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.step { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fff; display: block; color: var(--ink); }
.step:hover { border-color: var(--brand-2); text-decoration: none; }
.step .n { width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 700; margin-bottom: 8px; }
.step.done .n { background: var(--ok); color: #fff; }
.step .s { font-size: 12.5px; color: var(--muted); }
@media (max-width: 900px) { .steps { grid-template-columns: 1fr 1fr; } }

/* écran de connexion */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.auth .side { background: linear-gradient(150deg, var(--brand) 0%, #0b3f35 100%); color: #e6f4f0; padding: 56px; display: flex; flex-direction: column; justify-content: center; }
.auth .side h1 { font-size: 32px; color: #fff; line-height: 1.2; margin-bottom: 14px; }
.auth .side li { margin: 8px 0; }
.auth .box { display: grid; place-items: center; padding: 30px; background: #fff; }
.auth form { width: 100%; max-width: 380px; }
@media (max-width: 900px) { .auth { grid-template-columns: 1fr; } .auth .side { display: none; } }

/* visionneuse d'états */
.viewer { display: grid; grid-template-columns: 250px minmax(0,1fr); gap: 18px; align-items: start; }
.viewer .nav { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; }
.viewer .nav a { display: block; padding: 5px 10px; border-radius: 6px; color: var(--ink); font-size: 13px; }
.viewer .nav a:hover { background: #f2f4f7; text-decoration: none; }
.viewer .nav a.on { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.viewer .nav .sep { font-size: 11px; text-transform: uppercase; color: var(--muted); padding: 10px 10px 4px; font-weight: 700; letter-spacing: .04em; }
.viewer .nav a.out { color: #98a2b3; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .sp { flex: 1; }
@media (max-width: 900px) { .viewer { grid-template-columns: 1fr; } .viewer .nav { position: static; max-height: 240px; } }
.doc.inline { border-radius: var(--radius); overflow: auto; }
.save-state { font-size: 12.5px; color: var(--muted); }
code { background: #f2f4f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
