/* ── ISO Audit — App-specific styles ──────────────────────────── */

/* ── Audit control cards ─────────────────────────────────────── */
.ctrl-card {
    background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 8px;
    padding: 16px; margin-bottom: 12px; transition: border-color 0.15s;
}
.ctrl-card:hover { border-color: var(--ct-accent); }
.ctrl-card-header {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.ctrl-id {
    font-weight: 700; font-size: 0.85em; color: var(--ct-accent);
    background: var(--ct-accent-tint); padding: var(--ct-s1) var(--ct-s2); border-radius: 4px; white-space: nowrap;
}
.ctrl-title { font-weight: 600; font-size: 0.9em; color: var(--ct-ink); flex: 1; }
.ctrl-hds {
    display: inline-block; font-size: 0.7em; font-weight: 700; padding: var(--ct-s1) var(--ct-s2); border-radius: var(--ct-r-pill);
    background: var(--ct-low-tint); color: var(--ct-low-ink); white-space: nowrap;
}
.ctrl-desc { font-size: 0.82em; color: var(--ct-ink-2); line-height: 1.4; margin-bottom: var(--ct-s3); }

/* ── Status buttons ──────────────────────────────────────────── */
.status-bar { display: flex; flex-wrap: wrap; gap: var(--ct-s2); margin-bottom: var(--ct-s3); }
.status-btn {
    padding: var(--ct-s1) var(--ct-s3); border: 2px solid var(--ct-line); border-radius: 6px;
    cursor: pointer; font-size: 0.78em; font-weight: 600; background: var(--ct-surface);
    color: var(--ct-ink-2); transition: all 0.15s; user-select: none;
}
.status-btn:hover { border-color: var(--ct-accent); color: var(--ct-ink); }
/* Active = base badge pattern: -tint background, -ink text, tone border
   (AA in both themes — no more solid fill + white). */
.status-btn[data-status="c"].active { background: var(--ct-low-tint); border-color: var(--ct-low); color: var(--ct-low-ink); }
.status-btn[data-status="ncmaj"].active { background: var(--ct-critical-tint); border-color: var(--ct-critical); color: var(--ct-critical-ink); }
.status-btn[data-status="ncmin"].active { background: var(--ct-high-tint); border-color: var(--ct-high); color: var(--ct-high-ink); }
.status-btn[data-status="ps"].active { background: var(--ct-medium-tint); border-color: var(--ct-medium); color: var(--ct-medium-ink); }
.status-btn[data-status="pp"].active { background: var(--ct-info-tint); border-color: var(--ct-info); color: var(--ct-info-ink); }
.status-btn[data-status="na"].active { background: var(--ct-surface-2); border-color: var(--ct-neutral); color: var(--ct-ink-2); }

/* ── Finding fields ──────────────────────────────────────────── */
.ctrl-field { display: flex; flex-direction: column; }
.ctrl-field label { font-size: 0.75em; font-weight: 600; color: var(--ct-ink-2); text-transform: uppercase; margin-bottom: var(--ct-s1); }
.ctrl-field textarea { min-height: 50px; font-size: 0.85em; resize: vertical; }
/* The grid is the socle's (.ct-form-grid); this only separates the gap block. */
.ecart-fields { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--ct-line); }
.ecart-fields .ctrl-field label { color: var(--ct-critical); }

/* ── Questions panel ─────────────────────────────────────────── */
.questions-panel { display: none; margin-top: 8px; }
.questions-panel.open { display: block; }
.question-item {
    display: flex; align-items: flex-start; gap: var(--ct-s2); padding: var(--ct-s2) 0;
    border-bottom: 1px solid var(--ct-line); font-size: 0.82em;
}
.question-item:last-child { border-bottom: none; }
.btn-copy-q {
    flex-shrink: 0; padding: var(--ct-s1) var(--ct-s2); border: 1px solid var(--ct-line);
    border-radius: 4px; cursor: pointer; font-size: 0.8em; background: var(--ct-surface);
}
.btn-copy-q:hover { background: var(--ct-accent-tint); }

/* ── Card action buttons ─────────────────────────────────────── */
.ctrl-actions { display: flex; gap: var(--ct-s2); margin-left: auto; }
.btn-questions, .btn-templates {
    padding: var(--ct-s1) var(--ct-s2); border: 1px solid var(--ct-line); border-radius: 4px;
    cursor: pointer; font-size: 0.75em; background: var(--ct-surface); color: var(--ct-ink-2);
}
.btn-questions:hover, .btn-templates:hover { background: var(--ct-accent-tint); color: var(--ct-accent); }

/* ── Filters bar ─────────────────────────────────────────────── */
.audit-filters-bar {
    padding: var(--ct-s3) 0; margin-bottom: 8px; border-bottom: 1px solid var(--ct-line);
}
.filter-select {
    padding: 4px 8px; border: 1px solid var(--ct-line); border-radius: 4px;
    font-size: 0.82em; background: var(--ct-surface);
}
.filter-search {
    padding: 4px 8px; border: 1px solid var(--ct-line); border-radius: 4px;
    font-size: 0.82em; flex: 1; min-width: 150px;
}
.filter-count { font-size: 0.8em; color: var(--ct-ink-2); margin-left: auto; }

/* ── Dashboard ───────────────────────────────────────────────── */
.dash-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.dash-card {
    background: var(--ct-surface); border: 1px solid var(--ct-line); border-radius: 8px;
    padding: 16px; text-align: center;
    display: flex; flex-direction: column;
}
/* Uniform chart area: the 3 cards in the row share the same height;
   each SVG (viewBox) fills the area regardless of its geometry
   (gauge, donut, radar). */
.dash-chart { flex: 1; min-height: 210px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.dash-chart svg { flex: 1; min-height: 0; width: 100%; max-height: 230px; display: block; }
.dash-card h3 { font-size: 0.9em; color: var(--ct-ink); margin-bottom: 8px; }
/* (.dash-card-full removed — unused) */

/* (gauge-value/grade/label removed — gauge uses inline SVG styles) */

/* ── KPI boxes ───────────────────────────────────────────────── */

/* ── NC table ────────────────────────────────────────────────── */

/* (timer-bar and ecart-card removed — unused) */

/* ── Document review ─────────────────────────────────────────── */
.doc-item {
    display: flex; align-items: flex-start; gap: var(--ct-s3); padding: var(--ct-s3) 0;
    border-bottom: 1px solid var(--ct-line);
}
.doc-item:last-child { border-bottom: none; }
.doc-ref { font-weight: 600; font-size: 0.85em; color: var(--ct-accent); white-space: nowrap; min-width: 50px; }
.doc-label { flex: 1; font-size: 0.85em; }
.doc-status-btns { display: flex; gap: 4px; }
.doc-status-btn {
    padding: var(--ct-s1) var(--ct-s2); border: 1px solid var(--ct-line); border-radius: 4px;
    cursor: pointer; font-size: 0.72em; font-weight: 600; background: var(--ct-surface);
}
.doc-status-btn[data-ds="recu"].active { background: var(--ct-low-tint); border-color: var(--ct-low); color: var(--ct-low-ink); }
.doc-status-btn[data-ds="incomplet"].active { background: var(--ct-high-tint); border-color: var(--ct-high); color: var(--ct-high-ink); }
.doc-status-btn[data-ds="manquant"].active { background: var(--ct-critical-tint); border-color: var(--ct-critical); color: var(--ct-critical-ink); }
.doc-status-btn[data-ds="na"].active { background: var(--ct-surface-2); border-color: var(--ct-neutral); color: var(--ct-ink-2); }
.doc-obs { width: 100%; min-height: 28px; resize: vertical; font-size: var(--ct-text-meta); }
.doc-cat-head {
    display: flex; align-items: center; gap: var(--ct-s2);
    margin-bottom: var(--ct-s2); padding-bottom: var(--ct-s2);
    border-bottom: 2px solid var(--ct-accent);
}
.doc-cat-head h3 { margin: 0; font-size: 0.95em; color: var(--ct-ink); }
.doc-status-cycle { cursor: pointer; user-select: none; }
.doc-status-empty {
    display: inline-block; padding: var(--ct-s1) var(--ct-s2); border-radius: var(--ct-r-sm);
    font-size: var(--ct-text-label); border: 1px dashed var(--ct-line); color: var(--ct-ink-2);
}

/* ── Planning ────────────────────────────────────────────────── */
/* The parameters are a socle form (.ct-tprm-form + .ct-form-grid). Slots and
   separators sit on the spacing scale and on theme tokens: the old hex
   backgrounds stayed light in the dark theme. */
.planning-day { margin-bottom: var(--ct-s5); }
.planning-day-head {
    margin-bottom: var(--ct-s3); padding-bottom: var(--ct-s2);
    border-bottom: 2px solid var(--ct-accent);
    font-weight: 700; color: var(--ct-ink);
}
.planning-lunch {
    display: flex; align-items: center; gap: var(--ct-s3);
    margin: var(--ct-s2) 0; padding: var(--ct-s2) var(--ct-s3);
    background: var(--ct-surface-2); border: 1px dashed var(--ct-line);
    border-radius: var(--ct-r-md); font-size: 0.82em; color: var(--ct-ink-2);
}
.planning-slot {
    display: flex; align-items: center; gap: var(--ct-s3);
    padding: var(--ct-s2) var(--ct-s3); margin-bottom: var(--ct-s2);
    border-radius: var(--ct-r-lg); border-left: 4px solid var(--ct-info);
    background: var(--ct-info-tint); font-size: 0.85em;
    transition: box-shadow 0.15s;
}
.planning-slot[data-kind="annex"] { border-left-color: var(--ct-low); background: var(--ct-low-tint); }
/* A ring rather than a drop shadow: the card shadow is "none" in dark mode. */
.planning-slot:hover { box-shadow: inset 0 0 0 1px var(--ct-line-hover); }
.slot-time { font-weight: 700; font-family: var(--ct-font-mono); white-space: nowrap; min-width: 110px; }
.slot-domain { flex: 1; min-width: 0; }
.planning-exports {
    display: flex; gap: var(--ct-s3); justify-content: center;
    margin-top: var(--ct-s5); padding-top: var(--ct-s4); border-top: 1px solid var(--ct-line);
}

/* ── Journal ─────────────────────────────────────────────────── */
.journal-entry {
    display: flex; flex-wrap: wrap; align-items: center; gap: var(--ct-s1) var(--ct-s3);
    padding: var(--ct-s2) 0; border-bottom: 1px solid var(--ct-line); font-size: 0.82em;
}
.journal-time { font-family: monospace; font-size: 0.85em; color: var(--ct-ink-2); white-space: nowrap; }
.journal-type {
    font-size: 0.72em; font-weight: 600; padding: var(--ct-s1) var(--ct-s2); border-radius: var(--ct-r-sm);
    white-space: nowrap;
}
/* Grows beside the time and type; the author wraps below it on a phone. */
.journal-text { flex: 1 1 12em; min-width: 0; }

/* ── Meta fields (dashboard) ─────────────────────────────────── */
.meta-grid { margin-bottom: 16px; }
.meta-field { display: flex; flex-direction: column; }
.meta-field label { font-size: 0.75em; font-weight: 600; color: var(--ct-ink-2); text-transform: uppercase; margin-bottom: var(--ct-s1); }
.meta-field input, .meta-field select { padding: var(--ct-s1) var(--ct-s2); border: 1px solid var(--ct-line); border-radius: 4px; font-size: 0.85em; }

/* ── Search overlay ──────────────────────────────────────────── */
.search-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--ct-scrim); z-index: 500; justify-content: center; align-items: flex-start;
    padding-top: 10vh;
}
.search-overlay.open { display: flex; }
.search-panel {
    background: var(--ct-surface); border-radius: 12px; width: 100%; max-width: 600px;
    max-height: 80vh; display: flex; flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.search-header { display: flex; gap: 8px; padding: 16px 16px 8px; }
.search-input {
    flex: 1; padding: var(--ct-s3) var(--ct-s4); border: 2px solid var(--ct-line); border-radius: 8px;
    font-size: 1em; outline: none; transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--ct-accent); }
.search-scope {
    padding: var(--ct-s2) var(--ct-s3); border: 1px solid var(--ct-line); border-radius: 8px;
    font-size: 0.82em; background: var(--ct-surface); cursor: pointer;
}
.search-count { font-size: 0.78em; color: var(--ct-ink-2); padding: 0 16px 8px; }
.search-results {
    flex: 1; overflow-y: auto; padding: 0 16px; min-height: 60px;
}
.search-result-item {
    display: flex; gap: var(--ct-s3); padding: var(--ct-s3) var(--ct-s2); border-bottom: 1px solid var(--ct-line);
    cursor: pointer; border-radius: 6px; transition: background 0.1s;
}
.search-result-item:hover { background: var(--ct-neutral-tint); }
.search-result-id {
    font-weight: 700; font-size: 0.82em; color: var(--ct-accent);
    background: var(--ct-accent-tint); padding: var(--ct-s1) var(--ct-s2); border-radius: 4px; white-space: nowrap;
    align-self: flex-start;
}
.search-result-content { flex: 1; min-width: 0; }
.search-result-title { font-weight: 600; font-size: 0.88em; color: var(--ct-ink); }
.search-result-match {
    font-size: 0.8em; color: var(--ct-ink-2); margin-top: var(--ct-s1);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-result-match mark { background: var(--ct-medium-tint); color: var(--ct-medium-ink); padding: 0 var(--ct-s1); border-radius: var(--ct-r-sm); }
.search-no-results {
    text-align: center; padding: var(--ct-s8); color: var(--ct-ink-2); font-size: 0.9em;
}
.search-footer {
    text-align: center; padding: var(--ct-s3); font-size: 0.75em; color: var(--ct-ink-2);
    border-top: 1px solid var(--ct-line);
}

/* ── Enhanced dashboard ─────────────────────────────────────── */
.dash-charts-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; margin-bottom: 16px; }
/* The radar is denser than gauge/donut: SVG cap raised for legibility
   — the row aligns on it, the other two center themselves. */
.dash-radar-card .dash-chart svg { max-height: 300px; }
.dash-card-wide { grid-column: 1 / -1; }
/* Dashboard pieces: on the spacing scale and theme tokens. A bar segment's
   geometry is computed and stays inline; its colour comes from its status. */
.dash-empty { text-align: center; color: var(--ct-ink-2); padding: var(--ct-s5); }
.dash-legend { display: flex; flex-wrap: wrap; gap: var(--ct-s2); justify-content: center; margin-top: var(--ct-s2); }
.dash-legend-item { font-size: var(--ct-text-label); }
.dash-legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: var(--ct-s1); }
.hds-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--ct-s4); }
.domain-bars { display: flex; flex-direction: column; gap: var(--ct-s2); }
.domain-bar-row { display: flex; align-items: center; gap: var(--ct-s2); font-size: var(--ct-text-meta); }
.domain-bar-label { min-width: 160px; font-weight: 600; }
.domain-bar-track { flex: 1; height: 16px; background: var(--ct-surface-2); border-radius: var(--ct-r-lg); overflow: hidden; position: relative; }
.domain-bar-seg { position: absolute; top: 0; height: 100%; }
.domain-bar-seg[data-s="c"] { background: var(--ct-low); }
.domain-bar-seg[data-s="ncmaj"] { background: var(--ct-critical); }
.domain-bar-seg[data-s="ncmin"] { background: var(--ct-high); }
.domain-bar-seg[data-s="ps"] { background: var(--ct-medium); }
.domain-bar-seg[data-s="pp"] { background: var(--ct-info); }
.domain-bar-score { min-width: 40px; text-align: right; font-weight: 600; }
.search-more { text-align: center; padding: var(--ct-s2); font-size: var(--ct-text-label); color: var(--ct-ink-2); }
.audit-report-text { white-space: pre-wrap; font-size: var(--ct-text-data); line-height: 1.6; padding: var(--ct-s2); }
.radar-svg { display: block; margin: 0 auto; }

/* ── Stacked bars ───────────────────────────────────────────── */
.stacked-row { margin-bottom: var(--ct-s2); }
.stacked-label { font-size: 0.78em; font-weight: 600; margin-bottom: var(--ct-s1); color: var(--ct-ink); }
.stacked-track {
    display: flex; height: 18px; background: var(--ct-surface-2); border-radius: 4px; overflow: hidden;
}
.stacked-seg { height: 100%; transition: width 0.3s; }

/* ── HDS focus ──────────────────────────────────────────────── */
.hds-bar-row { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 0.82em; }
.hds-bar-label { min-width: 100px; font-weight: 600; }
.hds-bar-track { flex: 1; height: 14px; background: var(--ct-surface-2); border-radius: 4px; overflow: hidden; }
.hds-bar-fill { height: 100%; border-radius: 4px; }
.hds-bar-count { min-width: 30px; text-align: right; font-weight: 600; font-size: 0.9em; }

/* ── Report button ──────────────────────────────────────────── */
.btn-report {
    padding: var(--ct-s2) var(--ct-s4); border: 1px solid var(--ct-accent); border-radius: 6px;
    background: var(--ct-accent-tint); color: var(--ct-accent); cursor: pointer; font-size: 0.82em;
    font-weight: 600; transition: all 0.15s;
}
.btn-report:hover { background: var(--ct-accent); color: var(--ct-onaccent); }

/* ── Images / evidence ───────────────────────────────────────── */
.img-section { margin-top: var(--ct-s3); padding-top: 8px; border-top: 1px solid var(--ct-line); }
.img-section-header { font-size: 0.8em; font-weight: 600; color: var(--ct-ink-2); margin-bottom: var(--ct-s2); }
.img-thumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.img-thumb {
    position: relative; width: 100px; height: 75px; border-radius: 6px; overflow: hidden;
    border: 1px solid var(--ct-line); cursor: pointer; transition: box-shadow 0.15s;
}
.img-thumb:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.15); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb-del {
    position: absolute; top: 2px; right: 2px; width: 18px; height: 18px;
    background: var(--ct-critical); color: var(--ct-onaccent); border: none; border-radius: 50%; opacity: 0.9;
    font-size: 0.7em; cursor: pointer; display: flex; align-items: center; justify-content: center;
    opacity: 0; transition: opacity 0.15s;
}
.img-thumb:hover .img-thumb-del { opacity: 1; }
.img-add-btn {
    width: 100px; height: 75px; border: 2px dashed var(--ct-line); border-radius: 6px;
    background: none; cursor: pointer; font-size: 0.75em; color: var(--ct-ink-2);
    display: flex; align-items: center; justify-content: center; text-align: center;
    transition: all 0.15s;
}
.img-add-btn:hover { border-color: var(--ct-accent); color: var(--ct-accent); }

/* Image overlay (fullscreen) */
.img-overlay {
    display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--ct-scrim-deep); z-index: 600; justify-content: center; align-items: center;
    cursor: pointer;
}
.img-overlay.open { display: flex; }
.img-overlay-content { text-align: center; max-width: 90vw; max-height: 90vh; }
.img-overlay-content img { max-width: 90vw; max-height: 85vh; object-fit: contain; border-radius: 4px; }
.img-overlay-name { color: var(--ct-onsolid); opacity: 0.7; font-size: 0.82em; margin-top: 8px; }


/* ── Responsive ──────────────────────────────────────────────── */
/* Three charts side by side become unreadable well before 768px.
   Intermediate step aligned with the KPIs dropping to ~5 per row:
   2 charts per row (full-width radar below), then 1 per row
   under 768px. */
@media (max-width: 1024px) {
    .dash-charts-grid { grid-template-columns: 1fr 1fr; }
    .dash-radar-card { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
    .dash-grid { grid-template-columns: 1fr; }
    .hds-grid { grid-template-columns: 1fr; }
    .dash-charts-grid { grid-template-columns: 1fr; }
    .dash-radar-card { grid-column: auto; }
    .audit-filters-bar { flex-direction: column; align-items: stretch; }
    .search-panel { max-width: 95%; }
    .search-header { flex-direction: column; }
}

/* Audit picker (suite): the audit currently open */
#audit-picker tr[aria-current="true"] > td { background: var(--ct-accent-tint); }
