/*
 * Palanquée — système de design (voir DESIGN.md).
 * Direction « Pétrole immersif » (V3) : instrument de précision, calme et désirable.
 * Bi-surface bureau (clair teinté) / terrain (sombre pétrole). Profondeur par
 * surfaces étagées + hairline, jamais par ombres décoratives. Accent rationné,
 * jamais mêlé au feu. Feu tricolore vert/orange/rouge = langage central, jamais
 * la couleur seule (pastille + icône + mot).
 */

:root {
  --display: 'General Sans', sans-serif;
  --body: 'Instrument Sans', sans-serif;
  --data: 'Geist', sans-serif;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-full: 9999px;
}

/* Surface BUREAU (clair teinté « brume marine ») — écrans admin */
[data-surface="bureau"] {
  --bg: #DEEAE9; --surface: #FFFFFF; --raise: #FFFFFF; --s3: #FFFFFF;
  --line: #D3E2E1; --line-soft: rgba(16,58,60,.08);
  --ink: #103A3C; --ink-2: rgba(16,58,60,.62); --muted: rgba(16,58,60,.62); --ink-3: rgba(16,58,60,.42);
  --accent: #0E6E78; --accent-weak: rgba(14,110,120,.10);
  --green: #1C8F4E; --orange: #B5710A; --red: #BE3A2F;
  --cg-bg: rgba(28,143,78,.12); --co-bg: rgba(181,113,10,.13); --cr-bg: rgba(190,58,47,.10);
  --shadow: 0 1px 2px rgba(16,58,60,.06), 0 0 0 1px var(--line-soft);
  --shadow-pop: 0 8px 28px rgba(16,58,60,.14), 0 0 0 1px var(--line-soft);
}
/* Surface TERRAIN (sombre pétrole haut-contraste) — cockpit, plein soleil */
[data-surface="terrain"] {
  --bg: #07211F; --surface: #0C2A28; --raise: #123532; --s3: #163E39;
  --line: #1E4A45; --line-soft: rgba(255,255,255,.08);
  --ink: #E6F2F0; --ink-2: rgba(230,242,240,.66); --muted: rgba(230,242,240,.66); --ink-3: rgba(230,242,240,.42);
  --accent: #34D1C2; --accent-weak: rgba(52,209,194,.15);
  --green: #2BD66A; --orange: #FFB02E; --red: #FF6B6B;
  --cg-bg: rgba(43,214,106,.15); --co-bg: rgba(255,176,46,.16); --cr-bg: rgba(255,107,107,.16);
  --shadow: 0 0 0 1px var(--line-soft);
  --shadow-pop: 0 10px 30px rgba(0,0,0,.5), 0 0 0 1px var(--line-soft);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
/* L'attribut hidden doit toujours l'emporter (sinon display:flex/inline-flex le masque mal). */
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--body);
  line-height: 1.55; font-size: 16px; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }

/* Header / nav — marque à gauche, nav, action à droite */
.app-header {
  display: flex; align-items: center; gap: 24px;
  padding: 13px 24px; background: var(--surface);
  box-shadow: 0 1px 0 var(--line-soft);
}
.brand { font-family: var(--display); font-weight: 700; font-size: 20px; color: var(--ink); letter-spacing: -.02em; }
.app-nav { display: flex; gap: 18px; flex: 1; }
.app-nav a { color: var(--ink-2); font-weight: 600; font-size: 15px; }
.app-nav a:hover { color: var(--ink); text-decoration: none; }
.app-nav a.active { color: var(--accent); }
.app-main { max-width: 1000px; margin: 0 auto; padding: 36px 24px 80px; }

h1 { font-family: var(--display); font-weight: 700; font-size: 38px; letter-spacing: -.025em; line-height: 1.05; }
h2 { font-family: var(--display); font-weight: 600; font-size: 18px; margin-top: 28px; letter-spacing: -.01em; }
.page-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 22px; }
.page-head .count { color: var(--ink-3); font-family: var(--data); font-variant-numeric: tabular-nums; font-size: 18px; }
.muted { color: var(--muted); }
.num { font-family: var(--data); font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Chips de conformité — teinte douce + icône + mot (jamais la couleur seule) */
.chip { display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-sm);
        padding: 4px 10px; font-weight: 600; font-size: 13px; white-space: nowrap; line-height: 1.3; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.chip-green  { background: var(--cg-bg); color: var(--green); }  .chip-green .dot  { background: var(--green); }
.chip-orange { background: var(--co-bg); color: var(--orange); } .chip-orange .dot { background: var(--orange); }
.chip-red    { background: var(--cr-bg); color: var(--red); }    .chip-red .dot    { background: var(--red); }
/* Blocage légal dur (CACI/licence) : rouge plein, distinct du souple overridable. */
.chip-hard   { background: var(--red); color: #fff; } .chip-hard .dot { background: #fff; }
.chip-neutral{ background: var(--accent-weak); color: var(--ink-2); }

/* Cartes KPI (accueil jour-J) */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; }
.kpi { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow);
       padding: 16px; display: flex; flex-direction: column; gap: 7px; min-height: 124px; }
.kpi .lbl { font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.kpi .big { font-family: var(--data); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 34px; line-height: 1; letter-spacing: -.01em; }
.kpi .act { margin-top: auto; font-size: 13px; font-weight: 600; color: var(--accent); }

/* Tables — profondeur par surface + hairline (shadow-as-border), denses mais respirables */
table { width: 100%; border-collapse: collapse; background: var(--surface);
        border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 13px 16px; font-size: 14px; }
th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; border-bottom: 1px solid var(--line); }
tbody td { border-bottom: 1px solid var(--line-soft); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--accent-weak); }
td.n { font-family: var(--data); font-variant-numeric: tabular-nums; color: var(--ink-2); }
td.exp { color: var(--red); font-weight: 600; }
.row-link td:first-child a { font-weight: 600; color: var(--ink); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-family: var(--body);
       font-weight: 600; font-size: 15px; border-radius: var(--r-sm); padding: 10px 18px; min-height: 44px;
       cursor: pointer; border: 1px solid transparent; }
.btn-sm { min-height: 36px; padding: 7px 13px; font-size: 13px; }
/* Terrain : cibles tactiles 44px minimum (DESIGN.md — DP en extérieur, gants,
   parfois âgés). S'applique à tout ce qu'on touche dans le cockpit. */
[data-surface="terrain"] .btn-sm,
[data-surface="terrain"] .btn-mini,
.cockpit .btn-sm, .cockpit .btn-mini,
.cockpit .composer-add select { min-height: 44px; }
.cockpit .btn-mini { padding: 8px 12px; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(14,110,120,.25); }
.btn-primary:hover { text-decoration: none; filter: brightness(1.05); }
.btn-ghost { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line); color: var(--ink); }
.btn-ghost:hover { text-decoration: none; box-shadow: inset 0 0 0 1px var(--accent); }

/* Cartes détail */
.card { background: var(--surface); border-radius: var(--r-md); box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 16px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 16px; font-size: 15px; }
.kv dt { color: var(--muted); }

/* Flash */
.flash { padding: 12px 16px; border-radius: var(--r-md); margin-bottom: 16px; font-weight: 500; }
.flash-notice { background: var(--cg-bg); color: var(--green); }
.flash-alert { background: var(--cr-bg); color: var(--red); }

/* États vides (vide instructif — UX.4) */
.empty { text-align: center; padding: 48px 24px; color: var(--muted); background: var(--surface);
         border-radius: var(--r-md); box-shadow: var(--shadow); }
.empty p { margin-bottom: 12px; }

/* Forms (auth) */
/* Cloche de notifications + badge non-lus */
.notif-bell { position: relative; font-size: 18px; text-decoration: none; line-height: 1; padding: 4px; }
.notif-badge { position: absolute; top: -4px; right: -6px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 700; line-height: 1; padding: 2px 4px; border-radius: 999px; min-width: 14px; text-align: center; }
.notif-list { list-style: none; padding: 0; margin: 0; }
.notif-item { border-bottom: 1px solid var(--line, #e4e9e8); }
.notif-item.is-unread { background: var(--accent-weak, #eef4f3); }
.notif-link { display: flex; flex-direction: column; gap: 3px; padding: 12px 14px; text-decoration: none; color: inherit; }
.notif-titre { font-weight: 600; }
.notif-item.is-unread .notif-titre::before { content: "● "; color: var(--accent, #1a7f74); font-size: 11px; }
.notif-corps { font-size: 14px; color: var(--ink-2, #5a6360); }
.notif-meta { font-size: 12px; color: var(--ink-3, #8a938f); }

/* Galerie / album : grille de vignettes */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 8px; }
.media-tile { margin: 0; border-radius: var(--r-sm); overflow: hidden; background: var(--surface, #fff); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.media-tile a { display: block; aspect-ratio: 1; }
.media-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.media-tile .media-video { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--ink-2, #5a6360); background: var(--accent-weak, #eef4f3); font-weight: 600; }
.media-tile figcaption { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 5px 8px; font-size: 12px; color: var(--ink-2, #5a6360); }

.auth-card { max-width: 380px; margin: 48px auto; }
/* Page d'authentification : aucun chrome applicatif, formulaire centré. */
.app-main-auth { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.app-main-auth .auth-card { margin: 0; width: 100%; padding: 32px; border-radius: var(--r-lg);
  background: var(--surface, #fff); box-shadow: 0 1px 3px rgba(0,0,0,.06), 0 8px 30px rgba(0,0,0,.06); }
.app-main-auth .auth-card h1 { margin-top: 0; }
.app-main-auth .auth-card .brand-mark { display: block; font-family: var(--display, inherit); font-weight: 700;
  font-size: 22px; letter-spacing: -.01em; margin-bottom: 4px; }
.field { margin-bottom: 14px; display: flex; flex-direction: column; gap: 5px; }
.field label { font-weight: 600; font-size: 14px; }
.field input { font: inherit; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--line); border: none; border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-height: 44px; }
.field input:focus { box-shadow: inset 0 0 0 2px var(--accent); outline: none; }
.field.check label { font-weight: 400; display: flex; align-items: flex-start; gap: 8px; }
.field.check input { margin-top: 3px; }
.field.check input { min-height: 0; width: auto; }

/* Form membre / sortie */
.card input[type="text"], .card input[type="date"], .card input[type="time"], .card input[type="number"], .card select, .card textarea {
  font: inherit; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--line); border: none;
  border-radius: var(--r-sm); background: var(--surface); color: var(--ink); min-height: 44px; }
.card input:focus, .card select:focus, .card textarea:focus { box-shadow: inset 0 0 0 2px var(--accent); outline: none; }
.card textarea { min-height: 0; width: 100%; resize: vertical; }
.card .field input { width: 100%; }
.validite-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.validite-row select { min-width: 180px; }
.validite-row .del { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.actions { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.actions form { margin: 0; }

/* Cockpit — surface terrain (instrument jour J) */
.cockpit { background: var(--bg); color: var(--ink); border-radius: var(--r-lg);
           padding: 20px 22px 24px; box-shadow: var(--shadow); }
.cockpit-h2 { color: var(--ink-3); margin: 26px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; }

/* Verdict dominant du cockpit (glançable en 1 s) */
.verdict { display: flex; align-items: center; gap: 14px; padding: 15px 18px; border-radius: var(--r-md);
           font-family: var(--display); font-weight: 600; font-size: 19px; letter-spacing: -.01em; margin-bottom: 16px; }
.verdict .vic { font-size: 24px; line-height: 1; }
.verdict small { display: block; font-family: var(--body); font-weight: 400; font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.verdict-good { background: var(--cg-bg); color: var(--green); box-shadow: inset 0 0 0 1px var(--cg-bg); }
.verdict-bad  { background: var(--cr-bg); color: var(--red); box-shadow: inset 0 0 0 1px var(--cr-bg); }

.cockpit-alertes { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.cockpit-alerte { display: flex; align-items: baseline; gap: 10px; margin: 0; padding: 9px 13px;
  border-radius: var(--r-md); font-size: 14px; font-weight: 500; }
.cockpit-alerte-rouge  { background: var(--cr-bg); color: var(--red); }
.cockpit-alerte-orange { background: var(--co-bg); color: var(--orange); }

.cockpit-strip { display: flex; gap: 30px; flex-wrap: wrap; padding: 16px 18px;
                 background: var(--raise); border-radius: var(--r-md); box-shadow: var(--shadow); }
.cockpit-strip .metric { display: flex; flex-direction: column; gap: 3px; }
.cockpit-strip .k { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--ink-3); font-weight: 600; }
.cockpit-strip .v { font-family: var(--data); font-variant-numeric: tabular-nums; font-weight: 600; font-size: 24px; letter-spacing: -.01em; line-height: 1.1; }
.cockpit-strip .note-maree .v, .cockpit-strip .v[style] { font-family: var(--body); }

.pal { background: var(--s3); border-radius: var(--r-md); box-shadow: var(--shadow);
       padding: 14px 16px; margin-top: 12px; border-left: 3px solid transparent; }
.pal-green  { border-left-color: var(--green); }
.pal-orange { border-left-color: var(--orange); }
.pal-red    { border-left-color: var(--red); }
.pal-hd { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pal-hd strong { font-size: 16px; }
.pal-depth { margin-left: auto; font-family: var(--data); font-variant-numeric: tabular-nums; color: var(--muted); }
.pal-members { color: var(--muted); font-size: 14px; margin-top: 6px; }
.reasons { list-style: none; margin-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.reasons li { font-size: 13px; font-weight: 600; }
.reasons .r-bloquante { color: var(--red); }
.reasons .r-avertissement { color: var(--orange); }
/* Micro-récompense : flash bref de la bordure quand une palanquée passe au vert. */
@keyframes pal-pulse-green { 0% { box-shadow: var(--shadow); } 30% { box-shadow: 0 0 0 2px var(--green); } 100% { box-shadow: var(--shadow); } }
.pal-justgreen { animation: pal-pulse-green 1.6s ease-out 1; }

/* Composer */
.pal-roster { list-style: none; margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.pal-roster li { display: flex; align-items: center; justify-content: space-between; font-size: 14px; }
.btn-mini { font: inherit; font-size: 12px; line-height: 1; padding: 5px 9px; min-height: 28px;
            box-shadow: inset 0 0 0 1px var(--line); border: none; background: var(--surface); color: var(--muted);
            border-radius: var(--r-sm); cursor: pointer; }
.composer-add { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.composer-add select { font: inherit; padding: 8px 10px; min-height: 40px; box-shadow: inset 0 0 0 1px var(--line); border: none;
                       border-radius: var(--r-sm); background: var(--surface); color: var(--ink); }
.composer-add form, .composer-add { margin: 0; }
.valider-box { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.valider-box textarea { font: inherit; padding: 10px 12px; box-shadow: inset 0 0 0 1px var(--line); border: none;
                        border-radius: var(--r-sm); background: var(--surface); color: var(--ink); width: 100%; }

/* ---- Responsive / mobile-first (UX.12, priorité) ---- */
.app-header { flex-wrap: wrap; }
.app-nav { flex-wrap: wrap; row-gap: 6px; }

@media (max-width: 720px) {
  body { padding: 0; }
  .app-header { gap: 12px 16px; padding: 12px 16px; }
  .app-main { padding: 22px 16px 64px; }
  h1 { font-size: 28px; }
  .page-head { flex-wrap: wrap; }
  table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  th, td { padding: 10px 10px; }
  td.n { white-space: nowrap; }
  td .chip { white-space: normal; padding: 4px 8px; }
  .btn-sm { min-height: 40px; }
  .cockpit-strip { gap: 16px; }
  .kv { grid-template-columns: 1fr; gap: 2px 0; }
  .kv dt { margin-top: 8px; }
}

/* Graphe de marée (SVG rendu serveur) — couleurs héritées via variables CSS */
.maree-card { background: var(--raise); border-radius: var(--r-md); box-shadow: var(--shadow);
              padding: 8px 6px 4px; margin-top: 14px; }
.graphe-maree { display: block; width: 100%; height: auto; }

/* Assistant pas-à-pas (wizard) */
.wizard-bar { display: flex; align-items: center; gap: 16px; margin-bottom: 18px; }
.wizard-step-label { font-family: var(--display); font-weight: 600; font-size: 14px; color: var(--ink-2); letter-spacing: -.01em; }
.wizard-dots { display: flex; gap: 6px; margin-left: auto; }
.wizard-dots span { width: 26px; height: 4px; border-radius: var(--r-full); background: var(--line); }
.wizard-dots span.is-current { background: var(--accent); }
.wizard-step[hidden] { display: none; }

/* Command palette (⌘K) */
.cmdk-trigger { display: inline-flex; align-items: center; gap: 8px; background: var(--bg);
  box-shadow: inset 0 0 0 1px var(--line); color: var(--ink-2); border: none; cursor: pointer;
  font: inherit; font-size: 13px; padding: 7px 11px; border-radius: var(--r-sm); }
.cmdk-trigger:hover { box-shadow: inset 0 0 0 1px var(--accent); color: var(--ink); }
.cmdk-trigger kbd { font-family: var(--data); font-size: 11px; background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--line); border-radius: 4px; padding: 1px 6px; }

.cmdk-overlay { position: fixed; inset: 0; z-index: 100; display: none; justify-content: center;
  align-items: flex-start; padding: 12vh 16px 16px; background: rgba(16,58,60,.34); }
.cmdk-overlay.is-open { display: flex; }
.cmdk { width: min(580px, 94vw); background: var(--surface); border-radius: var(--r-lg);
  box-shadow: var(--shadow-pop); overflow: hidden; }
.cmdk-input { width: 100%; font: inherit; font-size: 17px; padding: 16px 18px; border: none;
  background: var(--surface); color: var(--ink); border-bottom: 1px solid var(--line-soft); }
.cmdk-input:focus { outline: none; }
.cmdk-list { max-height: 52vh; overflow-y: auto; padding: 8px; }
.cmdk-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3);
  font-weight: 600; padding: 10px 10px 4px; }
.cmdk-item { display: block; padding: 10px 12px; border-radius: var(--r-sm); color: var(--ink);
  font-weight: 500; font-size: 14.5px; }
.cmdk-item:hover, .cmdk-item.is-active { background: var(--accent-weak); color: var(--ink); text-decoration: none; }
.cmdk-item[hidden] { display: none; }

@media (max-width: 720px) { .cmdk-trigger span { display: none; } }

/* Hub d'administration */
.admin-hub { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.admin-tile { display: flex; flex-direction: column; gap: 6px; text-decoration: none; color: var(--ink); }
.admin-tile:hover { box-shadow: var(--shadow-pop); text-decoration: none; }
.admin-tile strong { font-size: 16px; }
