/* GMAO – feuille de style principale */
:root {
  --bg: #f3f5f8; --surface: #fff; --border: #e3e7ee; --text: #1f2933; --muted: #6b7785;
  --side: #1e2530; --side-2: #2a3342; --side-text: #c4ccd7;
  --primary: #0f8f8a; --primary-d: #0b7471;
  --red: #e5484d; --orange: #f08c2e; --yellow: #e2a907; --green: #2f9e5b; --teal: #14a39b;
  --blue: #3b82f6; --purple: #8b5cf6; --grey: #8a94a3;
  --radius: 10px; --shadow: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.07);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 2px; line-height: 1.25; }
p { margin: 0; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.icon { flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }

/* --- Structure ---------------------------------------------------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 232px; flex: none; background: var(--side); color: var(--side-text); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand:hover { text-decoration: none; }
.brand-logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--primary); color: #fff; }
.brand-text { display: flex; flex-direction: column; font-weight: 800; font-size: 18px; line-height: 1.1; letter-spacing: .02em; }
.brand-text small { font-weight: 400; font-size: 11.5px; letter-spacing: 0; color: var(--side-text); }
.nav { display: flex; flex-direction: column; gap: 2px; padding: 12px 10px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; color: var(--side-text); font-weight: 500; }
.nav a:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.nav a.active { background: var(--primary); color: #fff; }
.nav .pill { margin-left: auto; background: var(--red); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; line-height: 18px; }
.nav-section { margin: 18px 12px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7d8794; }
.sidebar-foot { margin-top: auto; padding: 14px 20px; font-size: 11px; color: #6d7785; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: 60px; display: flex; align-items: center; gap: 16px; padding: 0 24px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title a { color: var(--muted); }
.topbar-search { margin-left: auto; display: flex; align-items: center; gap: 8px; width: min(320px, 40vw); padding: 0 10px;
  color: var(--muted); background: var(--bg); border: 1px solid var(--border); border-radius: 8px; }
.topbar-search input { width: 100%; padding: 8px 0; border: 0; outline: none; background: transparent; font: inherit; }
.user-menu { display: flex; align-items: center; gap: 4px; }
.topbar-search + .user-menu { margin-left: 0; }
.topbar-title + .user-menu { margin-left: auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 8px; border-radius: 8px; color: var(--text); }
.user-chip:hover { background: var(--bg); text-decoration: none; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta small { color: var(--muted); }
.avatar { display: grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--primary);
  color: #fff; font-weight: 700; font-size: 13px; }
.avatar-sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 20px; }
.icon-btn { display: inline-grid; place-items: center; padding: 7px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.menu-toggle { display: none; }
.content { width: 100%; max-width: 1440px; padding: 24px; }
.messages { padding: 16px 24px 0; }
.alert { margin-bottom: 8px; padding: 10px 14px; border: 1px solid; border-radius: 8px; }
.alert-success { background: #ecf8f1; border-color: #bfe6cf; color: #1d6b3e; }
.alert-error { background: #fdeeee; border-color: #f5c2c3; color: #9b2226; }
.alert-warning { background: #fff6e6; border-color: #f7d9a6; color: #8a5a00; }
.alert-info { background: #eef5ff; border-color: #c7dcfb; color: #1f4f99; }

/* --- Mise en page ------------------------------------------------------- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.title-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 4px; }
.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-detail { grid-template-columns: minmax(0, 2fr) minmax(300px, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--border); font-weight: 600; }
.card-head > .btn, .card-head > strong { margin-left: auto; }
.card-head .icon { color: var(--muted); }
.card-head .btn .icon { color: inherit; }
.card-head-dark { background: #2b3442; color: #fff; border-bottom: 0; font-size: 13px; letter-spacing: .02em; }
.card-body { padding: 16px; }
.card-empty { padding: 24px 16px; color: var(--muted); text-align: center; }

/* --- Tuiles et indicateurs ---------------------------------------------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; padding: 14px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 94px; padding: 10px;
  border-radius: 8px; color: #fff; font-weight: 600; font-size: 13px; text-align: center; transition: transform .12s, box-shadow .12s; }
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: 0 6px 14px rgba(0,0,0,.14); }
.tile-red { background: var(--red); } .tile-orange { background: var(--orange); } .tile-yellow { background: var(--yellow); }
.tile-green { background: var(--green); } .tile-teal { background: var(--teal); } .tile-blue { background: var(--blue); }
.tile-purple { background: var(--purple); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(96px, 1fr)); gap: 10px; padding: 14px; }
.kpi { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 12px; border-radius: 8px; color: #fff; }
.kpi small { font-size: 12px; font-weight: 500; opacity: .95; white-space: nowrap; }
.kpi strong { font-size: 26px; line-height: 1.1; }
a.kpi:hover { text-decoration: none; filter: brightness(1.06); }
.kpi-red { background: var(--red); } .kpi-orange { background: var(--orange); } .kpi-green { background: var(--green); }
.kpi-teal { background: var(--teal); } .kpi-blue { background: var(--blue); } .kpi-purple { background: var(--purple); }
.kpi-grey { background: var(--grey); }

/* --- Tableaux ----------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { padding: 10px 14px; background: #f8fafc; border-bottom: 1px solid var(--border); color: var(--muted); font-size: 12px;
  font-weight: 600; letter-spacing: .04em; text-align: left; text-transform: uppercase; white-space: nowrap; }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfc; }
.table .sub { display: block; color: var(--muted); font-size: 12px; }
.row-actions { white-space: nowrap; text-align: right; }
.ref { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; color: var(--muted); }
.late { color: var(--red); font-weight: 600; }
.done-row td { color: var(--muted); }
.done-row .task-title { text-decoration: line-through; }

/* --- Badges et progression ---------------------------------------------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-blue { background: #e8f0fe; color: #1d4fb8; } .badge-teal { background: #dff4f2; color: #0b6f69; }
.badge-orange { background: #fff0e0; color: #a2520a; } .badge-green { background: #e5f5eb; color: #1d7444; }
.badge-red { background: #fde8e9; color: #b4232a; } .badge-grey { background: #eef0f3; color: #55606e; }
.badge-purple { background: #f0eafe; color: #5b33c4; }
.progress { flex: 1; min-width: 70px; height: 8px; overflow: hidden; background: #e7ebf0; border-radius: 999px; }
.progress > span { display: block; height: 100%; background: var(--teal); border-radius: 999px; }
.progress-lg { height: 12px; margin-bottom: 8px; }
.progress-cell { display: flex; align-items: center; gap: 8px; min-width: 120px; }
.progress-cell small { width: 38px; color: var(--muted); text-align: right; }
.small-gap { margin-bottom: 12px; }

/* --- Boutons ------------------------------------------------------------ */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); font: inherit; font-weight: 600; white-space: nowrap; cursor: pointer; }
.btn:hover { background: #f5f7fa; text-decoration: none; }
.btn .icon { width: 16px; height: 16px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #cf3b40; }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; padding: 10px; }
.link-danger, .link-danger:hover { color: var(--red); }

/* --- Formulaires -------------------------------------------------------- */
.form-card { max-width: 860px; }
.form-card-wide { max-width: 1000px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.form-section { grid-column: 1 / -1; margin-top: 6px; padding-bottom: 6px; border-bottom: 1px solid var(--border);
  color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; }
.form-section:first-child { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 13px; font-weight: 600; }
.field .req { color: var(--red); }
.span-2 { grid-column: 1 / -1; }
.field-check { flex-direction: row; align-items: center; gap: 8px; }
.field-check > label { font-weight: 500; }
.field-checkboxselectmultiple > div { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 4px 12px;
  max-height: 220px; overflow: auto; padding: 10px; border: 1px solid #cfd6df; border-radius: 8px; }
.field-checkboxselectmultiple label { display: flex; align-items: center; gap: 6px; font-weight: 400; }
.help { color: var(--muted); }
.help ul { margin: 4px 0; padding-left: 18px; }
.error { color: var(--red); font-weight: 500; }
.has-error .input { border-color: var(--red); }
.input { width: 100%; padding: 8px 10px; border: 1px solid #cfd6df; border-radius: 8px; background: #fff; color: var(--text); font: inherit; }
.input:focus { border-color: var(--primary); outline: 2px solid rgba(15,143,138,.22); }
textarea.input { resize: vertical; }
.input-sm { width: auto; padding: 4px 8px; font-size: 13px; }
input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--primary); }
.form-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.form-actions-inline { display: flex; justify-content: flex-end; margin-top: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border); background: #fbfcfd; }
.inline-form .input { flex: 1; width: auto; min-width: 140px; }
.inline-form input[type=date] { flex: 0 0 auto; }
.upload-form input[type=file] { min-width: 0; padding: 6px; }
.inline-fields { display: flex; align-items: flex-end; gap: 10px; }
.inline-fields .field { flex: 1; }
.status-select { font-weight: 600; border-radius: 999px; padding: 3px 8px; }
.status-select.badge-grey { background: #eef0f3; } .status-select.badge-teal { background: #dff4f2; }
.status-select.badge-red { background: #fde8e9; } .status-select.badge-green { background: #e5f5eb; }

/* --- Filtres et onglets ------------------------------------------------- */
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: #fbfcfd; }
.filters .input { width: auto; min-width: 140px; }
.filters .grow { flex: 1; min-width: 200px; }
.filters .grow .input, .filters input.grow { width: 100%; }
.check-inline { display: flex; align-items: center; gap: 6px; font-weight: 500; white-space: nowrap; }
.tabs { gap: 4px; }
.tab { padding: 6px 12px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.tab:hover { background: var(--bg); text-decoration: none; }
.tab.active { background: var(--primary); color: #fff; }

/* --- Fiche projet ------------------------------------------------------- */
.dl { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; font-weight: 500; }
.description { white-space: pre-line; }
.people { display: flex; flex-wrap: wrap; gap: 6px; }
.person { display: inline-flex; align-items: center; gap: 8px; }
.people .person { padding: 2px 10px 2px 2px; background: var(--bg); border-radius: 999px; font-size: 13px; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { display: flex; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--border); }
.card-head + .timeline li:first-child { border-top: 0; }
.timeline .system { color: var(--muted); font-style: italic; }
.timeline .meta, .files .meta { color: var(--muted); font-size: 12px; }
.comment-form { border-bottom: 1px solid var(--border); }
.files { margin: 0; padding: 0; list-style: none; }
.files li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.files .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-ext { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 8px; background: #eef5ff; color: #1f4f99; font-size: 10.5px; font-weight: 700; }

/* --- Rôles -------------------------------------------------------------- */
.role-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; margin-bottom: 20px; }
.role-card p { margin: 4px 0 8px; font-size: 13px; }
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }
.matrix .section-row td { background: #f3f5f8; color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .05em; text-align: left; text-transform: uppercase; }
.matrix input[type=checkbox] { width: 18px; height: 18px; }
.new-role { margin-top: 20px; }

/* --- Pagination --------------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 6px; padding: 12px; border-top: 1px solid var(--border); }
.pagination a, .pagination span { padding: 5px 10px; border: 1px solid var(--border); border-radius: 6px; color: var(--text); }
.pagination .current { background: var(--primary); border-color: var(--primary); color: #fff; }

/* --- Connexion ---------------------------------------------------------- */
.login-page { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #1e2530 0%, #16444a 55%, #0f8f8a 100%); }
.login-card { width: 100%; max-width: 410px; padding: 32px; background: #fff; border-radius: 14px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.login-card .brand { padding: 0 0 22px; border: 0; color: var(--text); }
.login-card .brand-text small { color: var(--muted); }
.login-card h1 { margin-bottom: 4px; }
.login-card > p.muted { margin-bottom: 20px; }
.login-card .field { margin-bottom: 14px; }
.login-foot { margin-top: 16px; font-size: 12.5px; text-align: center; }

/* --- Responsive --------------------------------------------------------- */
.backdrop { display: none; }
@media (max-width: 1100px) {
  .grid-2, .grid-detail { grid-template-columns: 1fr; }
}
@media (max-width: 800px) {
  .sidebar { position: fixed; top: 0; bottom: 0; left: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  body.sidebar-open .sidebar { transform: none; }
  body.sidebar-open .backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.35); }
  .menu-toggle { display: inline-grid; }
  .topbar { gap: 8px; padding: 0 12px; }
  .topbar-search, .user-meta { display: none; }
  .topbar-title + .user-menu, .user-menu { margin-left: auto; }
  .content { padding: 16px; }
  .messages { padding: 12px 16px 0; }
  .form-grid { grid-template-columns: 1fr; }
  .table .hide-sm { display: none; }
  .inline-fields { flex-direction: column; align-items: stretch; }
}
