/*
 * Thème Prism, d'après la charte de labskincreations.com :
 * vert anis #BDCD41, quasi-noir #001001, gris, police Alte Haas Grotesk.
 * Le vert de marque est trop clair pour du texte sur blanc (contraste 1,75:1) :
 * il sert aux fonds et accents (avec texte foncé), --lime-ink sert aux liens.
 */
@font-face {
    font-family: 'Alte Haas Grotesk';
    src: url("../fonts/AlteHaasGroteskRegular-bkXlTLj.woff2") format('woff2');
    font-weight: 400;
    font-display: swap;
}
@font-face {
    font-family: 'Alte Haas Grotesk';
    src: url("../fonts/AlteHaasGroteskBold-e8dIGED.woff2") format('woff2');
    font-weight: 700;
    font-display: swap;
}

:root {
    --lime: #bdcd41;          /* vert LabSkin */
    --lime-soft: #f3f6dc;     /* fonds légers */
    --lime-softer: #f9fbee;
    --lime-ink: #5c6a0c;      /* liens et texte vert sur blanc (6:1) */
    --lime-mark: #7a8a12;     /* barres de graphique (3,8:1) */
    --ink: #001001;           /* texte principal */
    --ink-2: #545452;         /* texte secondaire */
    --ink-3: #808080;         /* texte discret */
    --line: #e4e4df;
    --surface: #ffffff;
    --page: #f5f5f2;
    --sidebar: #1d1f1a;
    --sidebar-w: 236px;
    --radius: 10px;

    --bs-body-font-family: 'Alte Haas Grotesk', 'Helvetica Neue', Arial, sans-serif;
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--page);
    --bs-link-color: var(--lime-ink);
    --bs-link-color-rgb: 92, 106, 12;
    --bs-link-hover-color: var(--ink);
    --bs-link-hover-color-rgb: 0, 16, 1;
    --bs-border-color: var(--line);
    --bs-border-radius: 8px;
    --bs-secondary-color: var(--ink-2);
    --bs-focus-ring-color: rgba(189, 205, 65, .45);
}

body { font-size: 15px; -webkit-font-smoothing: antialiased; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
.text-secondary { color: var(--ink-2) !important; }
.text-muted, .form-text { color: var(--ink-3) !important; }
.icon { flex-shrink: 0; vertical-align: -.2em; }

/* ---------- Boutons ---------- */
.btn { --bs-btn-font-weight: 700; --bs-btn-padding-x: .9rem; display: inline-flex; align-items: center; gap: .4rem; letter-spacing: .02em; }
.btn-sm { --bs-btn-padding-x: .6rem; }
.btn-primary {
    --bs-btn-bg: var(--lime); --bs-btn-border-color: var(--lime); --bs-btn-color: var(--ink);
    --bs-btn-hover-bg: #a9b934; --bs-btn-hover-border-color: #a9b934; --bs-btn-hover-color: var(--ink);
    --bs-btn-active-bg: #97a62b; --bs-btn-active-border-color: #97a62b; --bs-btn-active-color: var(--ink);
    --bs-btn-disabled-bg: var(--lime); --bs-btn-disabled-border-color: var(--lime); --bs-btn-disabled-color: var(--ink);
    --bs-btn-focus-shadow-rgb: 189, 205, 65;
}
.btn-outline-primary, .btn-light {
    --bs-btn-color: var(--ink); --bs-btn-bg: var(--surface); --bs-btn-border-color: #d3d3cc;
    --bs-btn-hover-bg: var(--lime-soft); --bs-btn-hover-border-color: var(--lime); --bs-btn-hover-color: var(--ink);
    --bs-btn-active-bg: var(--lime-soft); --bs-btn-active-border-color: var(--lime); --bs-btn-active-color: var(--ink);
}
.btn-outline-secondary {
    --bs-btn-color: var(--ink-2); --bs-btn-border-color: #d3d3cc; --bs-btn-bg: var(--surface);
    --bs-btn-hover-bg: #f0f0eb; --bs-btn-hover-color: var(--ink); --bs-btn-hover-border-color: #c5c5bd;
    --bs-btn-active-bg: var(--lime); --bs-btn-active-color: var(--ink); --bs-btn-active-border-color: var(--lime);
}
.btn-outline-danger { --bs-btn-bg: var(--surface); }
.btn-icon { padding: .375rem .55rem; }

/* ---------- Mise en page : barre latérale + contenu ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); flex-shrink: 0; background: var(--sidebar); color: #c9cbc4;
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; padding: 1.25rem .9rem;
}
.sidebar .brand { display: flex; align-items: center; gap: .75rem; padding: 0 .5rem 1.25rem; color: #fff; text-decoration: none; }
.sidebar .brand img { width: 52px; height: auto; }
.sidebar .brand span { font-weight: 700; letter-spacing: .14em; text-transform: uppercase; font-size: .95rem; line-height: 1.1; }
.sidebar .brand small { display: block; color: var(--lime); letter-spacing: .04em; font-size: .66rem; font-weight: 400; white-space: nowrap; margin-top: .2rem; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar .section { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; color: #7d8076; padding: 1.1rem .75rem .4rem; }
.sidebar .nav-link {
    display: flex; align-items: center; gap: .7rem; color: #d8dad2; padding: .55rem .75rem; border-radius: 8px;
    font-size: .95rem; text-decoration: none; transition: background .15s, color .15s;
}
.sidebar .nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar .nav-link.active { background: var(--lime); color: var(--ink); font-weight: 700; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 1020; background: rgba(245, 245, 242, .92); backdrop-filter: blur(6px);
    display: flex; align-items: center; gap: 1rem; padding: .75rem 2rem; border-bottom: 1px solid var(--line);
}
.topbar .search { position: relative; flex: 1; max-width: 560px; }
.topbar .search .icon { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: var(--ink-3); }
.topbar .search input { padding-left: 2.4rem; border-radius: 999px; background: var(--surface); }
.topbar .menu-toggle { display: none; }
.content { padding: 1.5rem 2rem 3rem; }

@media (max-width: 991.98px) {
    .sidebar { position: fixed; z-index: 1040; left: 0; transform: translateX(-100%); transition: transform .2s; }
    .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0, 0, 0, .3); }
    .topbar .menu-toggle { display: inline-flex; }
    .topbar, .content { padding-left: 1rem; padding-right: 1rem; }
}

/* ---------- En-tête de page ---------- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 1rem; margin-bottom: 1.5rem; }
.page-header .eyebrow { font-size: .75rem; letter-spacing: .14em; text-transform: uppercase; color: var(--lime-ink); font-weight: 700; margin-bottom: .2rem; }
.page-header .eyebrow a { color: inherit; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: .01em; margin: 0; }
.page-header .subtitle { color: var(--ink-2); margin-top: .25rem; }
.page-header .actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.count-pill { display: inline-block; font-size: .8rem; font-weight: 700; background: var(--lime-soft); color: var(--lime-ink); border-radius: 999px; padding: .15rem .6rem; vertical-align: middle; margin-left: .4rem; }

/* ---------- Cartes / panneaux ---------- */
.card, .panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(0, 16, 1, .04); }
.panel { padding: 1.25rem 1.4rem; margin-bottom: 1.25rem; }
.panel-title {
    display: flex; align-items: center; gap: .5rem; font-size: .78rem; font-weight: 700; letter-spacing: .12em;
    text-transform: uppercase; color: var(--ink-2); margin: 0 0 1rem;
}
.panel-title .icon { color: var(--lime-ink); }
.panel-title .ms-auto { text-transform: none; letter-spacing: 0; font-weight: 400; }
details.panel > summary { list-style: none; cursor: pointer; margin: 0; }
details.panel > summary::after { content: '+'; margin-left: auto; font-size: 1.1rem; color: var(--ink-3); }
details.panel[open] > summary { margin-bottom: 1rem; }
details.panel[open] > summary::after { content: '−'; }

/* ---------- Barre de filtres ---------- */
.filters { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; margin-bottom: 1rem; display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.filters .form-control, .filters .form-select { width: auto; min-width: 9rem; max-width: 15rem; }
.filters .grow { flex: 1 1 14rem; max-width: none; }
.filters .form-check { margin: 0 .5rem; }
.filters .reset { margin-left: auto; color: var(--ink-3); font-size: .875rem; }

/* ---------- Tableaux ---------- */
.table-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
.table { --bs-table-hover-bg: var(--lime-softer); margin: 0; font-size: .9rem; }
.table > thead th {
    position: sticky; top: 0; z-index: 1; background: #fafaf7; font-size: .72rem; font-weight: 700; letter-spacing: .08em;
    text-transform: uppercase; color: var(--ink-2); white-space: nowrap; border-bottom: 1px solid var(--line); padding: .7rem .75rem;
}
.table > tbody td { padding: .6rem .75rem; vertical-align: middle; border-color: #efefea; }
.table > tbody tr:last-child td { border-bottom: 0; }
.table .mono { font-variant-numeric: tabular-nums; color: var(--ink-2); white-space: nowrap; }
.table a.row-link { color: var(--ink); font-weight: 700; }
.table a.row-link:hover { color: var(--lime-ink); }
.table .clip { max-width: 22rem; }
.empty { text-align: center; color: var(--ink-3); padding: 3rem 1rem !important; }

/* ---------- Badges ---------- */
.tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; padding: .2rem .5rem; border-radius: 6px; background: #efefea; color: var(--ink-2); white-space: nowrap; }
.tag-se { background: var(--lime-soft); color: var(--lime-ink); }
.tag-nhs { background: #fcebd9; color: #8a4b0f; }
.tag-dark { background: var(--ink); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: .25rem; }

/* ---------- Formulaires ---------- */
.form-label { font-size: .85rem; font-weight: 700; color: var(--ink-2); margin-bottom: .3rem; }
.form-control, .form-select { border-color: #d6d6cf; }
.form-control:focus, .form-select:focus { border-color: var(--lime); box-shadow: 0 0 0 .2rem rgba(189, 205, 65, .3); }
.form-check-input:checked { background-color: var(--lime-mark); border-color: var(--lime-mark); }
.form-check-input:focus { border-color: var(--lime); box-shadow: 0 0 0 .2rem rgba(189, 205, 65, .3); }
.required::after { content: ' *'; color: #b42318; }
.choice-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.choice-pills .form-check { padding: 0; margin: 0; }
.choice-pills .form-check-input { position: absolute; opacity: 0; pointer-events: none; }
.choice-pills .form-check-label {
    display: inline-block; padding: .35rem .8rem; border: 1px solid #d6d6cf; border-radius: 999px; cursor: pointer;
    background: var(--surface); font-size: .875rem; user-select: none; transition: all .12s;
}
.choice-pills .form-check-label:hover { border-color: var(--lime); }
.choice-pills .form-check-input:checked + .form-check-label { background: var(--lime); border-color: var(--lime); color: var(--ink); font-weight: 700; }
.choice-pills .form-check-input:focus-visible + .form-check-label { box-shadow: 0 0 0 .2rem rgba(189, 205, 65, .45); }
.form-actions {
    position: sticky; bottom: 0; z-index: 10; display: flex; gap: .5rem; align-items: center; margin: 0 -2rem -3rem; padding: .9rem 2rem;
    background: rgba(255, 255, 255, .95); border-top: 1px solid var(--line); backdrop-filter: blur(6px);
}
.instance-row { border: 1px solid #efefea; background: #fcfcfa; border-radius: 8px; padding: .75rem .75rem 0; margin-bottom: .75rem; }

/* ---------- Listes de définitions ---------- */
.dl-grid { display: grid; grid-template-columns: minmax(8rem, max-content) 1fr; gap: .55rem 1.25rem; margin: 0; }
.dl-grid dt { font-weight: 400; color: var(--ink-3); font-size: .85rem; padding-top: .1rem; }
.dl-grid dd { margin: 0; }

/* ---------- Alertes ---------- */
.alert { border-radius: var(--radius); border: 0; }
.alert-success { background: var(--lime-soft); color: #3f4a06; }

/* ---------- Tableau de bord ---------- */
.kpi { display: flex; flex-direction: row; gap: 1rem; align-items: center; padding: 1.25rem 1.4rem; color: var(--ink); text-decoration: none !important; transition: border-color .15s, transform .15s; }
.kpi:hover { border-color: var(--lime); transform: translateY(-1px); }
.kpi .kpi-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--lime-soft); color: var(--lime-ink); display: flex; align-items: center; justify-content: center; }
.kpi .value { font-size: 1.9rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .label { color: var(--ink-2); font-size: .875rem; margin-top: .3rem; }
.quick-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; margin-bottom: 1.5rem; }
.quick-actions a { display: flex; align-items: center; gap: .6rem; padding: .85rem 1rem; border: 1px dashed #c8cdb0; border-radius: var(--radius); color: var(--ink); font-weight: 700; background: var(--lime-softer); }
.quick-actions a:hover { border-style: solid; border-color: var(--lime); background: var(--lime-soft); text-decoration: none; }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: .35rem; }
.bars li { display: grid; grid-template-columns: 3rem 1fr 3.5rem; align-items: center; gap: .6rem; font-size: .85rem; border-radius: 4px; }
.bars li:hover { background: var(--lime-softer); }
.bars a { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.bars .track { height: 12px; }
.bars .bar { height: 100%; background: var(--lime-mark); border-radius: 0 4px 4px 0; min-width: 2px; }
.bars .n { text-align: right; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- Grille d'une boîte de congélation ---------- */
.box-legend { display: flex; gap: 1rem; font-size: .8rem; color: var(--ink-2); }
.box-legend span::before { content: ''; display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; border: 1px solid #d6d6cf; }
.box-legend .l-filled::before { background: var(--lime-soft); border-color: var(--lime); }
.box-legend .l-conflict::before { background: #fde2e2; border-color: #e8a0a0; }
.box-wrap { overflow-x: auto; }
.box-grid { border-collapse: separate; border-spacing: 4px; table-layout: fixed; width: 100%; min-width: 860px; }
.box-grid th { text-align: center; color: var(--ink-3); font-weight: 700; font-size: .8rem; width: 2rem; }
.box-grid td {
    height: 5.6rem; padding: .35rem .4rem 1.1rem; vertical-align: top; font-size: .72rem; line-height: 1.2; position: relative;
    background: #fbfbf9; border: 1px solid #e9e9e4; border-radius: 8px;
}
.box-grid td.filled { background: var(--lime-soft); border-color: #d9e29a; }
.box-grid td.filled a { color: var(--ink); }
.box-grid td.filled a:hover { color: var(--lime-ink); }
.box-grid td.conflict { background: #fde2e2; border-color: #e8a0a0; }
.box-grid td .pos { position: absolute; bottom: 3px; right: 6px; color: var(--ink-3); font-size: .66rem; font-weight: 700; }
.box-grid td a.add { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: transparent; border-radius: 8px; text-decoration: none; }
.box-grid td:hover a.add { color: var(--lime-ink); background: var(--lime-softer); }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rack-card .list-group-item { display: flex; align-items: center; gap: .6rem; border-color: #f0f0eb; padding: .45rem 1rem; }
.fill-meter { flex: 0 0 64px; height: 6px; border-radius: 3px; background: #ececE6; overflow: hidden; }
.fill-meter > div { height: 100%; background: var(--lime-mark); }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.photo-card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; color: var(--ink); text-decoration: none !important; transition: border-color .15s, box-shadow .15s, transform .15s; }
.photo-card:hover { border-color: var(--lime); box-shadow: 0 6px 18px rgba(0, 16, 1, .08); transform: translateY(-2px); }
.photo-card .thumb { height: 220px; display: flex; align-items: center; justify-content: center; padding: .5rem; background: #fff; }
.photo-card .thumb img { max-width: 100%; max-height: 100%; }
.photo-card .name { font-size: .72rem; padding: .5rem .6rem; border-top: 1px solid #f0f0eb; word-break: break-all; color: var(--ink-2); }
.folder-list .list-group-item { display: flex; justify-content: space-between; gap: .5rem; align-items: center; border-color: #f0f0eb; font-size: .875rem; }
.folder-list .list-group-item.active { background: var(--lime); border-color: var(--lime); color: var(--ink); font-weight: 700; }
.folder-list .list-group-item .n { color: var(--ink-3); font-size: .78rem; font-variant-numeric: tabular-nums; }
.folder-list .list-group-item.active .n { color: var(--ink); }
.viewer-shell { position: relative; }
#viewer { width: 100%; height: calc(100vh - 230px); min-height: 420px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.viewer-toolbar { position: absolute; z-index: 5; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 4px; }
.viewer-toolbar .btn { background: rgba(255, 255, 255, .95); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.scene-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .75rem; }
.scene-tabs a { padding: .3rem .8rem; border-radius: 999px; border: 1px solid #d6d6cf; background: var(--surface); color: var(--ink-2); font-size: .82rem; }
.scene-tabs a.active { background: var(--lime); border-color: var(--lime); color: var(--ink); font-weight: 700; }
.scene-tabs a:hover { text-decoration: none; border-color: var(--lime); }

/* ---------- Pagination ---------- */
.pagination { --bs-pagination-color: var(--ink-2); --bs-pagination-active-bg: var(--lime); --bs-pagination-active-border-color: var(--lime); --bs-pagination-active-color: var(--ink); --bs-pagination-hover-bg: var(--lime-softer); --bs-pagination-focus-box-shadow: 0 0 0 .2rem rgba(189, 205, 65, .35); }

/* ---------- Recherche globale ---------- */
.search-group h2 { font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-2); margin: 1.5rem 0 .6rem; display: flex; align-items: center; gap: .5rem; }

@media print {
    .sidebar, .topbar, .no-print, .form-actions { display: none !important; }
    .content { padding: 0; }
    .box-grid td { height: 4rem; }
}

/* ---------- Correctifs ---------- */
.form-control, .form-select { background-color: var(--surface); }
.form-control:disabled, .form-control[readonly] { background-color: #f0f0eb; }
.choice-pills .required::after { content: none; }
.box-grid thead th:not(:first-child) { width: auto; }
.box-grid th:first-child, .box-grid tbody th { width: 1.75rem; }

/* ---------- Utilisateur connecté ---------- */
.user-box { margin-top: auto; display: flex; align-items: center; gap: .25rem; padding: .75rem .25rem 0; border-top: 1px solid rgba(255, 255, 255, .08); }
.user-box .user-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: .6rem; color: #fff; padding: .4rem .5rem; border-radius: 8px; text-decoration: none; font-size: .88rem; line-height: 1.15; }
.user-box .user-name:hover { background: rgba(255, 255, 255, .06); }
.user-box .user-name small { display: block; color: #8d9086; font-size: .72rem; }
.user-box .avatar { flex: 0 0 34px; height: 34px; border-radius: 50%; background: var(--lime); color: var(--ink); font-weight: 700; font-size: .75rem; display: flex; align-items: center; justify-content: center; }
.user-box .logout { color: #8d9086; padding: .5rem; border-radius: 8px; }
.user-box .logout:hover { color: #fff; background: rgba(255, 255, 255, .06); }

/* ---------- Page de connexion ---------- */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--sidebar); padding: 1rem; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px; padding: 2rem; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-card h1 { font-size: 1.3rem; font-weight: 700; margin: 0 0 1.25rem; }
.login-brand { display: flex; align-items: center; gap: .9rem; margin: -2rem -2rem 1.5rem; padding: 1.25rem 2rem; background: var(--lime); border-radius: 14px 14px 0 0; }
.login-brand img { width: 52px; }
.login-brand span { font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--ink); }
.login-brand small { display: block; letter-spacing: .04em; font-size: .72rem; color: #3f4a06; }

/* ---------- Sécurisation du compte ---------- */
.secure-banner { display: flex; align-items: center; gap: .75rem; padding: .65rem 2rem; background: #fff4d6; border-bottom: 1px solid #f0d58a; color: #5a4300; font-size: .9rem; }
.secure-banner .icon { color: #a86e00; }
.security-status.ok { border-left: 4px solid var(--lime); }
.security-status.todo { border-left: 4px solid #e0a52a; }
.security-status.locked { border-left: 4px solid #b42318; }
.steps { margin: 0 0 .75rem; padding-left: 1.25rem; }
.steps li { margin-bottom: .3rem; }
.steps li.done { color: var(--ink-3); text-decoration: line-through; }
.steps li.done::marker { content: '✓  '; color: var(--lime-ink); }
.key-list li { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .6rem 0; border-bottom: 1px solid #f0f0eb; }
.entropy-meter { display: flex; align-items: center; gap: .75rem; margin-top: -.5rem; }
.entropy-meter .track { flex: 1; height: 6px; border-radius: 3px; background: #ececE6; overflow: hidden; }
.entropy-meter .bar { height: 100%; width: 0; background: #e0a52a; transition: width .15s, background .15s; }
.entropy-meter .bar.ok { background: var(--lime-mark); }
.tag-danger { background: #fde2e2; color: #8a1c1c; }
.key-icon { width: 76px; height: 76px; margin: 0 auto; border-radius: 50%; background: var(--lime-soft); color: var(--lime-ink); display: flex; align-items: center; justify-content: center; }
