/* Feuille de style unique de l'application. Couleurs définies en variables ci-dessous. */
:root {
  /* Charte REITO FOODS (palette officielle)
     Principales : bleu #0733C4 (+ teintes 75 % #455CCA, 50 % #7E8FDA, 25 % #B6BFE0, 10 % #E4E8F8),
                   noir #272727 (+ #535353, #888888, #C2C2C2, #E6E6E6), gris clairs #EFEFEF → #FDFDFD.
     Secondaires (avec parcimonie) : rose #EBB9C5, rouge foncé #A41000. */
  --brand: #0733C4;
  --brand-dark: #05279A;    /* survol des boutons (bleu assombri) */
  --brand-ink: #B6BFE0;     /* texte secondaire sur fond bleu */
  --pink: #EBB9C5;
  --bg: #F6F6F6;
  --surface: #FFFFFF;
  --surface-2: #EFEFEF;
  --border: #E6E6E6;
  --text: #272727;
  --muted: #535353;
  --accent: var(--brand);
  --accent-soft: #E4E8F8;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --warn: #a16207;
  --warn-soft: #fef3c7;
  --danger: #A41000;
  --danger-soft: #F7E3E8;   /* rose #EBB9C5 éclairci */
  --info-soft: #E4E8F8;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  font-size: 15px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

/* --- Mise en page --- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--brand); color: #fff; padding: 1.1rem .75rem;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.sidebar .brand { display: block; padding: .25rem .6rem 1.1rem; }
.sidebar .brand img { width: 130px; height: auto; display: block; }
.sidebar a { display: flex; justify-content: space-between; align-items: center; color: #E4E8F8; padding: .5rem .6rem; border-radius: 8px; }
.sidebar a:hover, .sidebar a.active { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.sidebar .section { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-ink); margin: 1rem .6rem .3rem; }
.sidebar .badge-accent { background: var(--pink); color: var(--text); }
.sidebar form button { background: none; border: 0; color: #E4E8F8; padding: .5rem .6rem; cursor: pointer; font: inherit; }
.main { flex: 1; min-width: 0; padding: 1.5rem 2rem 4rem; }
.topbar { display: none; }
.page-head { display: flex; flex-wrap: wrap; gap: .75rem; justify-content: space-between; align-items: flex-start; margin-bottom: 1.25rem; }
.actions { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

@media (max-width: 860px) {
  .layout { display: block; }
  .sidebar { display: none; position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; }
  .sidebar.open { display: block; }
  .topbar { display: flex; align-items: center; justify-content: space-between; background: var(--brand); color: #fff; padding: .6rem 1rem; position: sticky; top: 0; z-index: 40; }
  .topbar img { height: 38px; width: auto; display: block; }
  .topbar button { background: none; border: 1px solid rgba(255,255,255,.5); color: #fff; border-radius: 6px; padding: .3rem .6rem; font: inherit; }
  .main { padding: 1rem 1rem 4rem; }
}

/* --- Composants --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.stat { font-size: 1.8rem; font-weight: 700; }
.stat-label { color: var(--muted); font-size: .85rem; }

.btn {
  display: inline-flex; align-items: center; gap: .35rem; border: 1px solid var(--border); background: var(--surface);
  color: var(--text); padding: .45rem .85rem; border-radius: 8px; font: inherit; font-size: .92rem; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-danger { color: var(--danger); border-color: #f3b4b4; }
.btn-small { padding: .2rem .55rem; font-size: .82rem; }
.btn-link { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; font: inherit; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 999px; font-size: .78rem; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-info { background: var(--info-soft); color: var(--brand); }
.dot { display: inline-block; width: .6rem; height: .6rem; border-radius: 50%; margin-right: .35rem; vertical-align: middle; }

.messages { list-style: none; padding: 0; margin: 0 0 1rem; }
.messages li { padding: .65rem .9rem; border-radius: 8px; margin-bottom: .5rem; background: var(--info-soft); }
.messages .success { background: var(--ok-soft); }
.messages .error { background: var(--danger-soft); }
.messages .warning { background: var(--warn-soft); }
.alert { padding: .75rem 1rem; border-radius: 8px; background: var(--warn-soft); margin-bottom: 1rem; }
.alert-danger { background: var(--danger-soft); }

/* --- Formulaires --- */
label { font-size: .88rem; font-weight: 600; display: block; margin-bottom: .2rem; }
input[type=text], input[type=email], input[type=url], input[type=number], input[type=date], input[type=datetime-local],
input[type=password], input[type=search], select, textarea {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px; font: inherit; background: #fff; color: var(--text);
}
textarea { min-height: 5rem; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid #7E8FDA; border-color: var(--accent); }
input[type=checkbox] { width: 1.05rem; height: 1.05rem; vertical-align: middle; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: .9rem 1.1rem; }
.form-grid > div { min-width: 0; }
.form-grid .full { grid-column: 1 / -1; }
.helptext { display: block; color: var(--muted); font-size: .8rem; margin-top: .2rem; }
.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .2rem 0; font-size: .85rem; }
.inline-form { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.inline-form > * { flex: 1 1 160px; }
.inline-form .btn { flex: 0 0 auto; }

/* --- Tableaux --- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: .55rem .7rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-2); font-weight: 600; font-size: .82rem; color: var(--muted); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tr.row-ignored td { opacity: .55; }
tr.row-dup td { background: #fffbeb; }
tr.row-opp td { background: var(--danger-soft); }

/* --- Filtres --- */
.filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; margin-bottom: 1rem; }
.filters select[multiple] { min-height: 2.4rem; height: auto; }
details.filters-box > summary { cursor: pointer; font-weight: 600; margin-bottom: .75rem; }

/* --- Pipeline (kanban) --- */
.kanban { display: flex; gap: .75rem; overflow-x: auto; padding-bottom: 1rem; align-items: flex-start; }
.kanban-col { flex: 0 0 240px; background: var(--surface-2); border-radius: var(--radius); padding: .6rem; min-height: 120px; }
.kanban-col.drag-over { outline: 2px dashed var(--accent); }
.kanban-col h3 { margin: 0 0 .5rem; font-size: .88rem; display: flex; justify-content: space-between; align-items: center; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .6rem; margin-bottom: .45rem; cursor: grab; font-size: .86rem; }
.kanban-card:active { cursor: grabbing; }
.kanban-card.dragging { opacity: .4; }
.kanban-card .meta { color: var(--muted); font-size: .78rem; }
.kanban-more { font-size: .8rem; display: block; text-align: center; padding: .25rem; }

/* --- Fiche --- */
.fiche-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 1rem; }
.fiche-head .tags { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .5rem; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .35rem; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin: 1.25rem 0 1rem; overflow-x: auto; }
.tabs a { padding: .55rem .9rem; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--text); }
.tabs .count { font-size: .75rem; background: var(--surface-2); border-radius: 999px; padding: 0 .4rem; margin-left: .25rem; }
dl.info { display: grid; grid-template-columns: minmax(130px, 200px) 1fr; gap: .45rem 1rem; margin: 0; }
dl.info dt { color: var(--muted); font-size: .88rem; }
dl.info dd { margin: 0; word-break: break-word; }
.empty { color: var(--muted); font-style: italic; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline > li { border-left: 3px solid var(--border); padding: .2rem 0 1rem 1rem; position: relative; }
.timeline > li::before { content: ""; position: absolute; left: -7px; top: .45rem; width: 11px; height: 11px; border-radius: 50%; background: var(--accent); }
.timeline > li.systeme::before { background: #C2C2C2; }
.timeline > li.etape::before { background: #7E8FDA; }
.timeline .body { white-space: pre-wrap; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: .6rem .8rem; margin-top: .3rem; }
.timeline .comments { margin: .4rem 0 0 1rem; font-size: .88rem; }
.timeline .comment { border-left: 2px solid var(--border); padding: .2rem .6rem; margin-bottom: .3rem; white-space: pre-wrap; }

.tree { list-style: none; padding-left: 1.1rem; margin: .25rem 0; border-left: 1px dashed var(--border); }
.tree li { margin: .3rem 0; }

.pagination { display: flex; gap: .5rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: .75rem 0; border-top: 1px solid var(--border); margin-top: 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; z-index: 5; }

.login-wrap { max-width: 400px; margin: 10vh auto; padding: 0 1rem; }
.login-logo { width: 150px; height: auto; display: block; margin: 0 auto 1.25rem; border-radius: 6px; }
.qr svg { width: 220px; height: 220px; display: block; margin: .5rem auto; background: #fff; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 4px; font-size: .88em; word-break: break-all; }
.split { grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr); }
@media (max-width: 860px) { .split { grid-template-columns: 1fr; } dl.info { grid-template-columns: 1fr; } dl.info dt { margin-top: .4rem; } }
