/* Portail PHB — palette du site (encre #0C1B33, bleu #2563EB, ciel #38BDF8) */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #0c1b33;
  --text: #1c2638;
  --muted: #5b6475;
  --line: #dde2ec;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --sky: #38bdf8;
  --danger: #b42318;
  --ok-bg: #e8f5ee; --ok-ink: #135c35;
  --err-bg: #fdecea; --err-ink: #8a1c12;
  --todo: #fff6db;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(12, 27, 51, .06), 0 4px 16px rgba(12, 27, 51, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220; --surface: #131c2e; --ink: #e8eefc; --text: #d6deee; --muted: #93a0b8;
    --line: #26324a; --accent: #4f8bff; --accent-ink: #06122b; --danger: #ff6b5b;
    --ok-bg: #12301f; --ok-ink: #9be0b6; --err-bg: #3a1714; --err-ink: #ffb4aa; --todo: #3a3214;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
a { color: var(--accent); }
h1, h2 { color: var(--ink); line-height: 1.25; }
h1 { font-size: 1.5rem; margin: .4em 0 .6em; }
h2 { font-size: 1.1rem; margin: 0 0 .8em; }
code, .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .92em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.nowrap { white-space: nowrap; }

/* En-tête */
.topbar {
  display: flex; align-items: center; gap: 12px 20px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 1.05rem; }
.brand img { border-radius: 8px; background: #fff; padding: 2px; }
.mainnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.mainnav a { padding: 8px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; white-space: nowrap; }
.mainnav a[aria-current="page"] { background: var(--bg); color: var(--ink); font-weight: 600; }
.who { display: flex; align-items: center; gap: 12px; margin-left: auto; font-size: .9rem; }
.who a { color: var(--text); text-decoration: none; }
.who form { margin: 0; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; text-decoration: underline; }
@media (max-width: 640px) {
  .mainnav { order: 3; flex-basis: 100%; }
  .brand span { display: none; }
}

main.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px 16px 40px; flex: 1; }
main.narrow { max-width: 820px; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 18px 16px; }

/* Boutons, champs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: .875rem; }
:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }

label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 500; color: var(--ink); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }
input, select, textarea {
  width: 100%; font: inherit; font-weight: 400; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
input[type="checkbox"] { width: 20px; min-height: 20px; }
textarea { resize: vertical; line-height: 1.45; }
.hint { font-weight: 400; color: var(--muted); font-size: .8rem; }
.todo { background: var(--todo); }

.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2, .grid3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid2 { grid-template-columns: 1fr 1fr; }
  .grid3 { grid-template-columns: 1fr 1fr 1fr; }
  .span2 { grid-column: span 2; }
  .span3 { grid-column: span 3; }
}
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
form.inline { display: inline; }

.notice { padding: 10px 14px; border-radius: 10px; background: var(--ok-bg); color: var(--ok-ink); }
.notice.err { background: var(--err-bg); color: var(--err-ink); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin: 0 0 18px; box-shadow: var(--shadow); }
.panel.highlight { border-color: var(--accent); }
.empty { color: var(--muted); padding: 30px 0; text-align: center; }

/* Connexion */
body.auth main { flex: 1; }
.auth-card { width: calc(100% - 32px); max-width: 420px; margin: 8vh auto 24px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); }
.auth-card h1 { margin-top: 0; }

/* Tableau de bord */
.hello { font-size: 1.35rem; }
.feature {
  display: flex; align-items: center; gap: 16px; padding: 18px; margin-bottom: 26px;
  border-radius: var(--radius); background: var(--ink); color: #fff; text-decoration: none;
}
.feature .muted { color: #b9c6e0; display: block; font-size: .9rem; }
.feature strong { font-size: 1.1rem; }
@media (prefers-color-scheme: dark) { .feature { background: #1b2a4a; } }
.ico { width: 26px; height: 26px; flex: none; color: var(--accent); }
.ico.big { width: 40px; height: 40px; color: var(--sky); }
.ico.tiny { width: 15px; height: 15px; vertical-align: -2px; color: currentColor; }
.group h2 { font-size: .8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.tiles { list-style: none; margin: 0 0 26px; padding: 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.tile {
  display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; height: 100%;
  padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line);
  color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
.tile .ico { grid-row: span 2; margin-top: 2px; }
.tile .t { font-weight: 600; color: var(--ink); }
.tile .d { color: var(--muted); font-size: .875rem; }
a.tile:hover { border-color: var(--accent); }
.tile.off { opacity: .6; }

/* Visionneuse */
body.viewer { height: 100vh; overflow: hidden; }
body.viewer .foot { display: none; }
.viewbar { display: flex; align-items: center; gap: 10px; padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.viewbar strong { flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appframe { flex: 1; width: 100%; border: 0; background: #fff; }

/* Tableaux */
.subnav { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.subnav a { padding: 6px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); border: 1px solid var(--line); }
.subnav a[aria-current="page"] { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { color: var(--muted); font-weight: 600; font-size: .8rem; }
table.list tr:last-child td { border-bottom: 0; }
table.list td.url { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.list .btn { margin: 2px 0; }
tr.dim td { opacity: .55; }
.searchbar { display: flex; gap: 8px; margin-bottom: 14px; }

/* Rapport */
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: .85rem; margin-right: 6px; }
.items { list-style: none; margin: 0 0 14px; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.item { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 12px; background: var(--bg); }
.item-head { display: flex; justify-content: space-between; align-items: center; }
.photos { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.thumbs { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs li { position: relative; }
.thumbs img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); display: block; }
.thumbs.ro img { width: 64px; height: 64px; }
.thumb-x { position: absolute; top: -8px; right: -8px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--danger); color: #fff; font-size: 18px; line-height: 1; cursor: pointer; }
.filebtn { position: relative; overflow: hidden; }
.filebtn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; }
.actionbar {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end;
  padding: 12px 16px; margin: 0 -16px; background: var(--surface); border-top: 1px solid var(--line);
}
.actionbar .status { flex: 1 1 100%; margin: 0; font-size: .9rem; color: var(--muted); }
.actionbar .status.err { color: var(--err-ink); }
.actionbar .status:empty { display: none; }
fieldset.rel { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
fieldset.rel legend { font-weight: 600; color: var(--ink); padding: 0 6px; }
.reco { display: grid; gap: 8px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
@media (min-width: 640px) { .reco { grid-template-columns: 160px 1fr; } .reco > label:nth-child(3) { grid-column: 2; } .reco > button { grid-column: 2; justify-self: start; } }
@media (max-width: 640px) {
  table.list.cards thead { display: none; }
  table.list.cards tr { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.list.cards tr:last-child { border-bottom: 0; }
  table.list.cards td { display: inline; border: 0; padding: 0; }
  table.list.cards td:first-child { display: block; font-weight: 600; color: var(--ink); }
  table.list.cards td:not(:first-child):not(:last-child) + td:not(:last-child)::before { content: " · "; color: var(--muted); }
  table.list.cards td:last-child { display: flex; flex-wrap: wrap; gap: 6px; padding-top: 10px; }
  table.list.cards td.url { display: block; max-width: none; }
}
