/* Validation Interface — feuille de style unique, aucune dépendance. */

:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #16191d;
  --ink-soft: #656d78;
  --line: #e2e5ea;
  --line-soft: #eef0f3;
  --accent: #2f5fd8;
  --accent-ink: #ffffff;
  --ok: #1f8a52;
  --ok-bg: #e6f4ec;
  --ko: #c0392b;
  --ko-bg: #fbeae8;
  --warn: #a06b00;
  --warn-bg: #fdf3e0;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 8px 24px rgba(16, 20, 28, .05);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14171b;
    --panel: #1c2026;
    --ink: #e8eaee;
    --ink-soft: #9aa3ae;
    --line: #2b313a;
    --line-soft: #23282f;
    --accent: #6c92f0;
    --accent-ink: #10131a;
    --ok: #56c98a;
    --ok-bg: #17301f;
    --ko: #ef8579;
    --ko-bg: #331c19;
    --warn: #d6a94a;
    --warn-bg: #2e2618;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; }

/* Le display:none de l'attribut `hidden` vient de la feuille du navigateur :
   n'importe quelle règle d'auteur posant un display le neutralise
   (.centered, les cellules de tableau…). On le rend prioritaire, sinon
   masquer une vue ne la masque pas. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 20px; margin: 0 0 4px; }
h2 { font-size: 14px; margin: 0; font-weight: 600; }
.muted { color: var(--ink-soft); }
.spacer { flex: 1; }
.num { text-align: right; }

/* ---------- Connexion ---------- */

.centered {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card { width: 100%; max-width: 340px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  margin: 16px 0 6px;
}

input[type=text], input[type=password], input[type=date], input[type=time],
input[type=search], select, textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

textarea { resize: vertical; }

/* ---------- Boutons ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 7px 13px;
  border-radius: 7px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
}

.btn:hover { border-color: var(--ink-soft); }
.btn:disabled { opacity: .5; cursor: default; }

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.btn.ghost { background: transparent; }
.btn.block { width: 100%; margin-top: 20px; padding: 9px; }

.btn.ok  { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 40%, var(--line)); }
.btn.ko  { color: var(--ko); border-color: color-mix(in srgb, var(--ko) 40%, var(--line)); }
.btn.tiny { padding: 4px 9px; font-size: 12px; }

/* ---------- Barre du haut ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  height: 52px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand { font-size: 14px; letter-spacing: -.01em; }

.tabs { display: flex; gap: 2px; }

.tab {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: inherit;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.tab:hover { background: var(--line-soft); color: var(--ink); }
.tab.active { background: var(--line-soft); color: var(--ink); font-weight: 600; }

.who { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--line-soft);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .04em;
}

.badge.manager { background: var(--warn-bg); color: var(--warn); }

/* ---------- Panneaux ---------- */

.tabpanel { padding: 20px; max-width: 1400px; margin: 0 auto; }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 14px;
}

.toolbar.wrap { flex-wrap: wrap; }
.toolbar label { margin: 0; display: flex; flex-direction: column; gap: 4px; }
.toolbar input, .toolbar select { width: auto; }
.search { min-width: 220px; }

.segmented {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow: hidden;
}

.segmented button {
  border: 0;
  background: var(--panel);
  color: var(--ink-soft);
  font: inherit;
  padding: 7px 14px;
  cursor: pointer;
}

.segmented button + button { border-left: 1px solid var(--line); }
.segmented button.active { background: var(--accent); color: var(--accent-ink); font-weight: 600; }

/* ---------- Tableaux ---------- */

.table-wrap {
  overflow-x: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-soft);
  font-weight: 600;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  background: var(--panel);
  position: sticky;
  top: 0;
}

td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  max-width: 320px;
  overflow-wrap: anywhere;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--line-soft); }

td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
td.actions { white-space: nowrap; }
td.actions .btn + .btn { margin-left: 6px; }

td.desc { min-width: 320px; max-width: 520px; line-height: 1.45; }
td.nowrap { white-space: nowrap; }

.sub { font-size: 11px; color: var(--ink-soft); margin-top: 3px; }
.sub.comment { font-style: italic; max-width: 260px; }

a { color: var(--accent); }

.tag {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--line-soft);
  color: var(--ink-soft);
}

.detail-row td { background: var(--line-soft); padding: 0; }

.detail-row pre {
  margin: 0;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.5;
  overflow-x: auto;
  color: var(--ink-soft);
}

.more {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  padding: 16px 0 4px;
}

.pill {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.pill.validated { background: var(--ok-bg); color: var(--ok); }
.pill.rejected  { background: var(--ko-bg); color: var(--ko); }
.pill.pending   { background: var(--line-soft); color: var(--ink-soft); }
.pill.out_of_scope { background: var(--warn-bg); color: var(--warn); }

.empty { text-align: center; color: var(--ink-soft); padding: 40px; }

/* ---------- Tuiles + graphique ---------- */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: var(--shadow);
}

.tile-label { font-size: 12px; color: var(--ink-soft); }
.tile-value { font-size: 26px; font-weight: 600; font-variant-numeric: tabular-nums; }

.legend { font-size: 12px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw-ok { background: var(--ok); }
.sw-ko { background: var(--ko); margin-left: 8px; }

.chart {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 190px;
  padding-top: 8px;
  overflow-x: auto;
}

.bar-col {
  flex: 1 0 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.bar-stack {
  width: 100%;
  max-width: 34px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
  flex: 1;
}

.bar { width: 100%; border-radius: 3px; min-height: 0; }
.bar-ok { background: var(--ok); }
.bar-ko { background: var(--ko); }

.bar-label {
  font-size: 10px;
  color: var(--ink-soft);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  white-space: nowrap;
}

/* ---------- Dialogue ---------- */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  padding: 24px;
  width: min(480px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}

dialog::backdrop { background: rgba(10, 12, 16, .45); }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }

.error {
  color: var(--ko);
  background: var(--ko-bg);
  padding: 8px 10px;
  border-radius: 7px;
  font-size: 13px;
  margin: 14px 0 0;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 99px;
  font-size: 13px;
  z-index: 20;
  box-shadow: var(--shadow);
}
