/* ── Staff Dashboard ──────────────────────────────────────────────────────
   Reuses the base.css design tokens (dark/light aware). */

.staff-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--sp-4);
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}

.staff-title {
    font-family: var(--font-display, 'Rajdhani', sans-serif);
    font-size: 1.6rem;
    margin: 0;
}

.staff-subtitle {
    color: var(--text-muted);
    margin: 0.15rem 0 0;
    font-size: 0.9rem;
}

.staff-year-nav {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.staff-year {
    font-family: var(--font-display, 'Rajdhani', sans-serif);
    font-size: 1.3rem;
    color: var(--gold);
    min-width: 4.5rem;
    text-align: center;
}

/* Module navigation now lives in the shared top tab bar (partials/main_nav.html,
   base.css .tab-group/.tab-dropdown) — no separate staff sub-nav. */

.staff-badge {
    display: inline-block;
    background: #c0392b;
    color: #fff;
    border-radius: var(--r-full);
    font-size: 0.7rem;
    min-width: 1.2rem;
    text-align: center;
    padding: 0 0.3rem;
    margin-left: 0.2rem;
}

/* ── Cards & grids ── */
.staff-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.staff-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--sp-4);
}

.staff-card h3 {
    margin: 0 0 var(--sp-2);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}

.staff-stat {
    font-family: var(--font-display, 'Rajdhani', sans-serif);
    font-size: 1.9rem;
    color: var(--text-primary);
}

.staff-stat small { font-size: 0.9rem; color: var(--text-muted); }

.staff-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.staff-section > h2 {
    margin: 0 0 var(--sp-3);
    font-size: 1.05rem;
    font-family: var(--font-display, 'Rajdhani', sans-serif);
}

/* ── Toolbar (search / filters) ── */
.staff-toolbar {
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: var(--sp-3);
}

.staff-toolbar input[type="search"],
.staff-toolbar input[type="text"],
.staff-toolbar select {
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}

.staff-toolbar .spacer { flex: 1; }

/* La barre de validation d'une étape du bilan.
   Elle vivait tout en bas d'un écran de plusieurs milliers de pixels, sous
   huit listes : le relecteur ne la voyait qu'après avoir tout déroulé, et le
   libellé « Valider la section » ne disait pas de quelle section il parlait.
   Collée au bas de la fenêtre, elle est là du premier au dernier pixel. */
.staff-actionbar {
    position: sticky;
    bottom: 0;
    z-index: 5;
    display: flex;
    gap: var(--sp-2);
    flex-wrap: wrap;
    align-items: center;
    margin-top: var(--sp-4);
    padding: var(--sp-3);
    background: var(--bg-raised);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-md);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, 0.35);
}
.staff-actionbar .spacer { flex: 1; }
.staff-actionbar-state { font-size: 0.85rem; color: var(--text-muted); }
.staff-actionbar-state.is-validated { color: var(--success, #4ca76a); }
.staff-hint { flex: 1; color: var(--text-muted); font-size: 0.85rem; }
.staff-hint a { color: var(--gold); }

.staff-workload-kinds,
.staff-workload-reviewers {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: var(--sp-3);
}

.staff-workload-detail {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--sp-4);
}

.staff-workload-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.staff-workload-list li {
    display: flex;
    justify-content: space-between;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--border-subtle);
}

@media (max-width: 760px) {
    .staff-workload-detail { grid-template-columns: 1fr; }
}

/* Validation technologies : garde l'autocomplétion pays compacte dans la
   barre de filtres, tout en lui laissant la largeur nécessaire sur mobile. */
.staff-tech-country-filter { width: min(220px, 100%); }
.staff-tech-country-filter .pr-country-input { width: 100%; font-size: 0.85rem; }

/* Panneau externe intégré (TechPanel). Hauteur pleine fenêtre : c'est un outil
   dense, un cadre court y ferait défiler deux barres l'une dans l'autre. */
.staff-embed-frame {
    border: 1px solid var(--border-mid);
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--bg-surface);
}
.staff-embed-frame iframe {
    display: block;
    width: 100%;
    height: calc(100vh - 210px);
    min-height: 520px;
    border: 0;
}

/* ── Tables ── */
.staff-table-wrap { overflow-x: auto; }

.staff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.staff-table th,
.staff-table td {
    text-align: left;
    padding: 0.55rem 0.7rem;
    border-bottom: 1px solid var(--border-subtle);
    vertical-align: top;
}

.staff-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.staff-table tbody tr:hover { background: var(--bg-hover); }
.staff-table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.staff-pagination {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    justify-content: flex-end;
    margin-top: var(--sp-3);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ── Status badges ── */
.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: var(--r-full);
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-not_started { background: rgba(128,128,128,0.18); color: var(--text-secondary); }
.badge-in_progress { background: rgba(52,152,219,0.18); color: #5dade2; }
.badge-waiting_review { background: rgba(243,156,18,0.18); color: #f5b041; }
.badge-completed, .badge-done, .badge-closed { background: rgba(39,174,96,0.18); color: #2ecc71; }
.badge-pending, .badge-open { background: rgba(128,128,128,0.18); color: var(--text-secondary); }
.badge-in_review { background: rgba(243,156,18,0.18); color: #f5b041; }
.badge-critical { background: rgba(192,57,43,0.2); color: #e74c3c; }
.badge-warning { background: rgba(243,156,18,0.18); color: #f5b041; }
.badge-info { background: rgba(52,152,219,0.18); color: #5dade2; }
.badge-secret { background: rgba(155,89,182,0.2); color: #bb8fce; }
.badge-auto { background: rgba(52,152,219,0.15); color: #5dade2; }
.badge-manual { background: rgba(213,182,84,0.18); color: var(--gold); }

/* Advanced treaty statuses (TreatyStatusEnum / PartyStatusEnum) */
.badge-draft { background: rgba(128,128,128,0.18); color: var(--text-secondary); }
.badge-published { background: rgba(52,152,219,0.18); color: #5dade2; }
.badge-active, .badge-signed { background: rgba(39,174,96,0.18); color: #2ecc71; }
.badge-cancelled, .badge-rejected, .badge-refused, .badge-revoked { background: rgba(192,57,43,0.18); color: #e74c3c; }
.badge-modification_requested { background: rgba(243,156,18,0.18); color: #f5b041; }

/* ── Country selection cards (bilans) ── */
.country-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: var(--sp-3);
}

.country-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--sp-3);
    cursor: pointer;
    transition: border-color 0.15s ease;
}

.country-card:hover { border-color: var(--border-gold); }
.country-card h4 { margin: 0 0 var(--sp-1); font-size: 1rem; }
.country-card .continent { color: var(--text-muted); font-size: 0.8rem; }
.bilan-batch-check { float:right; display:flex; align-items:center; gap:var(--sp-1); color:var(--text-muted); font-size:.75rem; cursor:pointer; }
.bilan-batch-check input { accent-color:var(--gold); }
.batch-results { display:grid; gap:var(--sp-2); padding:0; list-style:none; }
.batch-results li { padding:var(--sp-2) var(--sp-3); border-left:3px solid var(--border-mid); background:var(--bg-raised); }
.batch-results li.ok { border-color:var(--success); }
.batch-results li.error { border-color:var(--danger); }

.progress-bar {
    height: 6px;
    border-radius: var(--r-full);
    background: var(--bg-overlay);
    margin-top: var(--sp-2);
    overflow: hidden;
}

.progress-bar > div { height: 100%; background: var(--gold); border-radius: var(--r-full); }

.continent-group h3 {
    margin: var(--sp-5) 0 var(--sp-3);
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Wizard ── */
.wizard-steps {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}

.wizard-step {
    padding: var(--sp-2) var(--sp-3);
    border-radius: var(--r-sm);
    border: 1px solid var(--border-subtle);
    background: var(--bg-raised);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
}

.wizard-step.active { border-color: var(--border-gold); color: var(--gold); }
.wizard-step.validated::after { content: " ✓"; color: #2ecc71; }

textarea.staff-textarea {
    width: 100%;
    min-height: 260px;
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    padding: var(--sp-3);
    font-family: monospace;
    font-size: 0.85rem;
    resize: vertical;
}

/* ── Diff cards (preview) ── */
.diff-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--sp-3);
}

.diff-card {
    background: var(--bg-raised);
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    padding: var(--sp-3);
}

.diff-card h4 { margin: 0 0 var(--sp-2); font-size: 0.85rem; color: var(--text-muted); text-transform: uppercase; }
.diff-card .current { color: var(--text-secondary); }
.diff-card .arrow { text-align: center; color: var(--text-faint); margin: 0.1rem 0; }
.diff-card .projected { font-size: 1.2rem; font-weight: 600; }
.diff-card .delta-pos { color: #2ecc71; }
.diff-card .delta-neg { color: #e74c3c; }
.diff-card .delta-zero { color: var(--text-muted); }
.diff-card details { margin-top: var(--sp-2); font-size: 0.8rem; color: var(--text-muted); }
.diff-card details pre { white-space: pre-wrap; word-break: break-word; }

/* ── Forms ── */
.staff-form {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: var(--sp-3);
}

.staff-field { display: flex; flex-direction: column; gap: 0.3rem; }
.staff-field label { font-size: 0.8rem; color: var(--text-muted); }

.staff-field input,
.staff-field select,
.staff-field textarea {
    background: var(--bg-raised);
    color: var(--text-primary);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-sm);
    padding: 0.45rem 0.6rem;
    font-size: 0.9rem;
}

.staff-field textarea { min-height: 70px; resize: vertical; }

/* ── Modal ── */
.staff-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--sp-4);
}

.staff-modal {
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-lg);
    width: min(560px, 100%);
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.staff-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-subtle);
}

.staff-modal-header h3 { margin: 0; font-size: 1.05rem; }
.staff-modal-body { padding: var(--sp-4); overflow-y: auto; }
.staff-modal-footer {
    padding: var(--sp-3) var(--sp-4);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    justify-content: flex-end;
    gap: var(--sp-2);
}

/* ── Alerts list ── */
.alert-item {
    display: flex;
    gap: var(--sp-3);
    align-items: baseline;
    padding: var(--sp-3);
    border-bottom: 1px solid var(--border-subtle);
}

.alert-item:last-child { border-bottom: none; }
.alert-item .msg { flex: 1; }
.alert-item a { color: var(--gold); }

/* ── Skeletons & empty states ── */
.skeleton {
    background: linear-gradient(90deg, var(--bg-raised) 25%, var(--bg-overlay) 50%, var(--bg-raised) 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 1.4s infinite;
    border-radius: var(--r-md);
}

.skeleton-card { height: 90px; margin-bottom: var(--sp-3); }
.skeleton-row { height: 38px; margin-bottom: var(--sp-2); }

@keyframes skeleton-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.staff-empty {
    text-align: center;
    color: var(--text-muted);
    padding: var(--sp-8) var(--sp-4);
}

.staff-empty .icon { font-size: 2rem; margin-bottom: var(--sp-2); }

.login-hero {
    text-align: center;
    padding: var(--sp-12) var(--sp-4);
}

/* Warnings inside extraction review */
.staff-warning {
    background: rgba(243,156,18,0.1);
    border: 1px solid rgba(243,156,18,0.35);
    border-radius: var(--r-sm);
    padding: var(--sp-3);
    margin: var(--sp-3) 0;
    font-size: 0.88rem;
}

.unmatched-lines {
    font-family: monospace;
    font-size: 0.8rem;
    white-space: pre-wrap;
    color: var(--text-muted);
    max-height: 180px;
    overflow-y: auto;
}

/* ── Notation stat labels/values (growth, stability, tech panels) ── */
.staff-stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--sp-1);
}

.staff-stat-value {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.badge-success {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
}

.badge-warning {
    background: rgba(241, 196, 15, 0.15);
    color: #f1c40f;
    border: 1px solid rgba(241, 196, 15, 0.3);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
}

.badge-danger {
    background: rgba(231, 76, 60, 0.15);
    color: #e74c3c;
    border: 1px solid rgba(231, 76, 60, 0.3);
    padding: 2px 8px;
    border-radius: var(--r-sm);
    font-size: 0.85rem;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .staff-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .diff-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
    .diff-cards { grid-template-columns: 1fr; }
    .staff-header { flex-direction: column; align-items: flex-start; }
}


/* ── Gestion Staff (technologies) ──────────────────────────────────────────
   Le markup porté du TechPanel utilisait `.tab-panel`, qui appartient à
   `tabs.js` : celui-ci retire `active` de tous les panneaux à chaque
   activation d'onglet, et le panneau injecté se cachait aussitôt. Ici il n'y a
   qu'un panneau, toujours visible — d'où sa propre classe. */
.staff-techs-panel { display: block; }

/* ── Arbitrage ligne à ligne ───────────────────────────────────────────────
   Le bouton qui fait exister une arme suggérée était un `btn-sm` sans couleur,
   posé sous un champ texte de 90 pixels, dans la dernière colonne d'un tableau
   replié par défaut. Une dotation a été approuvée sans qu'il soit vu une seule
   fois : le pays a touché son enveloppe, et ses deux armes n'ont jamais
   existé. Un bouton qui décide de l'existence d'un objet du jeu ne se distingue
   pas d'un lien secondaire. */
.line-tech { min-width: 230px; }

.line-tech-create {
    display: block;
    width: 100%;
    margin-bottom: var(--sp-2);
    padding: 10px 12px;
    min-height: var(--pr-touch-target);
    font-weight: 600;
    text-align: center;
    white-space: normal;   /* un nom d'arme long tient sur deux lignes */
}

.line-tech-ref {
    width: 100%;
    font-size: 0.8rem;
}

/* L'état de la ligne se lit sans lire la colonne : une arme sans technologie
   est ce qui bloque le versement, elle doit se voir depuis le haut du tableau. */
.line-pending { box-shadow: inset 3px 0 0 var(--gold); }
.line-pending > td:first-child { background: var(--gold-glow); }
.line-settled { opacity: 0.82; }

.line-todo-note {
    margin: 0 0 var(--sp-2);
    padding: 10px 12px;
    border: 1px solid var(--border-gold);
    border-radius: var(--r-md);
    background: var(--gold-glow);
    color: var(--text-secondary);
    font-size: 0.83rem;
    line-height: 1.45;
}

/* Ce que l'approbation va créer, listé dans la modale de versement : signer
   une création sans la voir est exactement ce qui a produit le trou. */
.grant-pending-list {
    margin: var(--sp-2) 0;
    padding-left: 1.1rem;
    font-size: 0.86rem;
    line-height: 1.6;
}
.grant-pending-list .empty-note { display: inline; margin-left: 6px; }

/* ── Staff › Assistance ────────────────────────────────────────────────────
   Deux volets : la file à gauche, le ticket à droite. Les archivés restent
   listés — sans eux, personne ne peut voir qu'une question revient pour la
   troisième fois. */
.asst-split {
    display: grid;
    grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
    gap: var(--sp-3);
    align-items: start;
}
.asst-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-subtle);
    border-radius: var(--r-md);
    background: var(--bg-surface);
    color: var(--text-secondary);
    font-family: var(--font-body);
    text-align: left;
    cursor: pointer;
    margin-bottom: var(--sp-2);
}
.asst-row.is-closed { opacity: 0.62; }
.asst-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.asst-row-title { font-weight: 600; color: var(--text-primary); font-size: 0.86rem;
                  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asst-row-meta { font-size: 0.72rem; color: var(--text-faint); }
.asst-row .nav-count { margin-left: auto; }

.asst-head {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding-bottom: var(--sp-2);
    border-bottom: 1px solid var(--border-subtle);
    margin-bottom: var(--sp-3);
}
.asst-head > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.asst-head .btn { margin-left: auto; }
.asst-messages {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    max-height: 460px;
    overflow-y: auto;
    margin-bottom: var(--sp-3);
}
.asst-reply { display: flex; gap: var(--sp-2); align-items: flex-end; }
.asst-reply textarea {
    flex: 1;
    padding: 10px 12px;
    background: var(--bg-surface);
    border: 1px solid var(--border-mid);
    border-radius: var(--r-md);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.88rem;
    resize: vertical;
}

@media (max-width: 900px) {
    .asst-split { grid-template-columns: minmax(0, 1fr); }
}
