:root {
    /* THÈME CLAIR (Très lisible, haute définition, moderne) */
    --bg: #f8fafc;
    --paper: #ffffff;
    --paper-hover: #f8fafc;
    --text: #0f172a;
    --muted: #475569;
    --border: #cbd5e1;
    --chip: #f1f5f9;
    --ok: #16a34a;
    --warn: #d97706;
    --danger: #dc2626;
    --accent: #0284c7;
    --accent-bg: #e0f2fe;
    --card-shadow: 0 4px 12px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.05);
    --header-bg: rgba(255, 255, 255, 0.96);
    --footer-bg: #f8fafc;
    --timer-bg: #f1f5f9;
    --timer-border: #cbd5e1;
    --tech-border: rgba(0, 0, 0, 0.08);
    --tech-text: #1e293b;
    --qty-bg: #e2e8f0;
    --qty-text: #0f172a;
    --qty-border: #cbd5e1;

    /* Financial Row - Thème Clair */
    --fin-bg: #f8fafc;
    --fin-border: #cbd5e1;
    --fin-label: #475569;
    --fin-cost: #0284c7;
    --fin-fc-low: #15803d;
    --fin-fc-med: #b45309;
    --fin-fc-high: #b91c1c;
    --fin-margin: #6d28d9;
  }

  [data-theme="dark"] {
    --bg: #0b0e12;
    --paper: #12161c;
    --paper-hover: #161c24;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #263242;
    --chip: #1e293b;
    --ok: #22c55e;
    --warn: #facc15;
    --danger: #ef4444;
    --accent: #38bdf8;
    --accent-bg: rgba(56, 189, 248, 0.15);
    --card-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    --header-bg: rgba(11, 14, 18, 0.94);
    --footer-bg: #0f141b;
    --timer-bg: #1a222d;
    --timer-border: #263242;
    --tech-border: rgba(255, 255, 255, 0.08);
    --tech-text: #e2e8f0;
    --qty-bg: #1e293b;
    --qty-text: #38bdf8;
    --qty-border: #334155;

    /* Financial Row - Thème Sombre */
    --fin-bg: #151b23;
    --fin-border: #263242;
    --fin-label: #94a3b8;
    --fin-cost: #38bdf8;
    --fin-fc-low: #4ade80;
    --fin-fc-med: #fbbf24;
    --fin-fc-high: #f87171;
    --fin-margin: #c084fc;
  }

  * { box-sizing: border-box; margin: 0; padding: 0; }
  html, body {
    background: var(--bg);
    color: var(--text);
    font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, "Helvetica Neue", Arial, sans-serif;
    scroll-behavior: smooth;
    transition: background-color .2s, color .2s;
  }
  img { max-width: 100%; display: block; }
  button { cursor: pointer; font-family: inherit; }
  input { font-family: inherit; }

  .container { max-width: 1240px; margin: 0 auto; padding: 12px 16px; }

  /* HEADER */
  header {
    position: sticky;
    top: 0;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    z-index: 50;
    box-shadow: 0 2px 4px rgba(0,0,0,0.03);
  }
  .head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 0;
  }
  .brand {
    display: flex;
    align-items: center;
    gap: 12px;
  }
  .logo {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--paper);
    object-fit: cover;
  }
  .ttl {
    font-size: 19px;
    font-weight: 800;
    letter-spacing: .3px;
    color: var(--text);
  }
  .ttl span { color: var(--accent); }

  /* SEARCH BAR */
  .search-box {
    display: flex;
    align-items: center;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 7px 14px;
    gap: 8px;
    min-width: 260px;
    max-width: 380px;
    flex: 1;
    transition: border-color .2s, box-shadow .2s;
  }
  .search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
  }
  .search-box input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 14px;
    width: 100%;
  }
  .search-box input::placeholder { color: var(--muted); }
  .search-clear {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 16px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
  }
  .search-clear.visible { display: flex; }
  .search-clear:hover { color: var(--text); }

  .header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .btn-theme {
    padding: 7px 12px;
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    transition: all .2s;
  }
  .btn-theme:hover { background: var(--paper-hover); border-color: #94a3b8; }
  .btn-nav-destock {
    background: #0284c7;
    color: #ffffff;
    font-weight: 700;
    padding: 7px 14px;
    border-radius: 8px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    border: 1px solid #0284c7;
    white-space: nowrap;
    transition: background .2s;
  }
  .btn-nav-destock:hover {
    background: #0369a1;
  }

  /* NAVIGATION TABS */
  nav {
    position: sticky;
    top: 63px;
    z-index: 40;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    overflow-x: auto;
    white-space: nowrap;
    scrollbar-width: thin;
  }
  .tabs { display: flex; gap: 4px; padding: 0 8px; }
  .tab {
    padding: 12px 14px;
    text-decoration: none;
    color: var(--muted);
    font-weight: 700;
    font-size: 14px;
    border-bottom: 3px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color .2s, border-color .2s;
    user-select: none;
  }
  .tab:hover { color: var(--text); }
  .tab.active { color: var(--text); }

  /* Tab active indicators */
  .tab[data-color].active { border-bottom-color: currentColor; }
  .tab[data-color="#ef476f"] { color: #ef476f; }
  .tab[data-color="#22a699"] { color: #22a699; }
  .tab[data-color="#ffb703"] { color: #d97706; }
  .tab[data-color="#64b5f6"] { color: #0284c7; }
  .tab[data-color="#b088f9"] { color: #9333ea; }
  .tab[data-color="#f97316"] { color: #ea580c; }
  .tab[data-color="#06b6d4"] { color: #0891b2; }
  .tab[data-color="#10b981"] { color: #16a34a; }
  .tab[data-color="#eab308"] { color: #ca8a04; }
  .tab[data-color="#fb7185"] { color: #e11d48; }

  /* STATS & SEARCH SUMMARY */
  .search-info {
    margin-top: 14px;
    font-size: 14px;
    color: var(--muted);
    display: none;
  }
  .search-info.visible { display: block; }
  .search-info strong { color: var(--accent); }

  /* SECTIONS & GRID */
  .section-wrap { scroll-margin-top: 120px; }
  .section-title {
    font-size: 22px;
    font-weight: 800;
    margin: 28px 0 16px;
    text-transform: uppercase;
    letter-spacing: .5px;
    display: flex;
    align-items: center;
    gap: 10px;
  }
  .section-count {
    font-size: 13px;
    font-weight: 800;
    background: var(--chip);
    color: var(--muted);
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
  }
  .grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(310px, 100%), 1fr));
    gap: 20px;
    padding-bottom: 32px;
  }

  /* CARDS */
  .card {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    transition: transform .15s ease, border-color .15s ease;
  }
  .card:hover {
    border-color: #94a3b8;
  }
  .hero-wrap {
    position: relative;
    width: 100%;
    height: 195px;
    background: var(--chip);
    overflow: hidden;
  }
  .hero {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-bottom: 2px solid var(--border);
    cursor: zoom-in;
    transition: transform .25s ease;
  }
  .hero:hover { transform: scale(1.03); }
  .gallery-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(15, 23, 42, 0.8);
    border: 1px solid rgba(255,255,255,0.1);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    backdrop-filter: blur(4px);
    pointer-events: none;
  }

  .body {
    padding: 16px 14px 12px;
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .row-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
  }
  .name {
    font-size: 17px;
    font-weight: 800;
    letter-spacing: .2px;
    line-height: 1.25;
    color: var(--text);
  }
  .price {
    font-weight: 800;
    font-size: 14.5px;
    font-variant-numeric: tabular-nums;
    background: var(--accent-bg);
    border: 1.5px solid var(--accent);
    padding: 4px 12px;
    border-radius: 999px;
    white-space: nowrap;
    color: var(--accent);
    box-shadow: 0 1px 3px rgba(2, 132, 199, 0.12);
  }

  /* FINANCIAL / FOOD COST ROW */
  .financial-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 6px;
    margin: 8px 0 12px;
    padding: 7px 10px;
    background: var(--fin-bg);
    border: 1px solid var(--fin-border);
    border-radius: 8px;
    font-size: 11.5px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
  }
  .fin-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.25;
    flex: 1;
    text-align: center;
  }
  .fin-item:not(:last-child) {
    border-right: 1px solid var(--fin-border);
    padding-right: 6px;
  }
  .fin-label {
    font-size: 9.5px;
    color: var(--fin-label);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    margin-bottom: 2px;
  }
  .fin-val {
    font-weight: 800;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
  }
  .fin-item.cost .fin-val { color: var(--fin-cost); }
  .fin-item.fc-low .fin-val { color: var(--fin-fc-low); }
  .fin-item.fc-med .fin-val { color: var(--fin-fc-med); }
  .fin-item.fc-high .fin-val { color: var(--fin-fc-high); }
  .fin-item.margin .fin-val { color: var(--fin-margin); }

  /* TIMER */
  .timer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 6px 0 10px;
    padding: 7px 10px;
    background: var(--timer-bg);
    border-radius: 8px;
    border: 1px solid var(--timer-border);
  }
  .timer {
    font-weight: 800;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: .5px;
    font-variant-numeric: tabular-nums;
    color: var(--text);
  }
  .timer .dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
  }
  .timer[data-state="run"] .dot {
    background: var(--warn);
    box-shadow: 0 0 0 0 rgba(217, 119, 6, .8);
    animation: pulse 1.3s infinite;
  }
  .timer[data-state="done"] .dot {
    background: var(--ok);
    animation: none;
  }
  @keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(217, 119, 6, .8); }
    70% { box-shadow: 0 0 0 10px rgba(217, 119, 6, 0); }
    100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); }
  }

  .meta {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
  }
  .chip {
    background: var(--chip);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 12px;
    color: var(--text);
  }

  /* TECH RECIPE LIST */
  .tech {
    margin-top: 10px;
    border-top: 1px dashed var(--border);
    padding-top: 10px;
    color: var(--tech-text);
    font-size: 13.5px;
    list-style: none;
    flex: 1;
  }
  .tech li {
    margin: 4px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    border-bottom: 1px dotted var(--tech-border);
    padding-bottom: 3px;
    line-height: 1.35;
  }
  .tech li span:first-child {
    color: var(--tech-text);
    font-weight: 600;
  }
  .tech li .item-qty {
    font-weight: 800;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
    color: var(--qty-text);
    background: var(--qty-bg);
    border: 1px solid var(--qty-border);
    padding: 2px 8px;
    border-radius: 6px;
    white-space: nowrap;
  }

  /* CARD FOOTER */
  .footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-top: 1px solid var(--border);
    background: var(--footer-bg);
  }
  .badge {
    padding: 6px 14px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 12px;
    border: 1px solid transparent;
    user-select: none;
    letter-spacing: .4px;
    transition: transform .1s, opacity .15s;
  }
  .badge:active { transform: scale(0.96); }
  .badge.todo { background: var(--danger); color: #fff; }
  .badge.prog { background: var(--warn); color: #fff; }
  .badge.ready { background: var(--ok); color: #fff; }

  /* LIGHTBOX */
  .lightbox {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    flex-direction: column;
    padding: 16px;
  }
  .lightbox.visible { display: flex; }
  #lightbox-img {
    max-width: 92%;
    max-height: 84%;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.2);
    box-shadow: 0 0 30px rgba(0,0,0,.8);
    object-fit: contain;
  }
  .lb-counter {
    margin-top: 12px;
    color: #cbd5e1;
    font-size: 14px;
    font-weight: 700;
  }
  .lb-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: none;
    font-size: 26px;
    padding: 12px 18px;
    border-radius: 10px;
    backdrop-filter: blur(6px);
    transition: background .2s;
  }
  .lb-btn:hover { background: rgba(255, 255, 255, 0.3); }
  .prev { left: 4%; }
  .next { right: 4%; }
  .close {
    top: 20px;
    right: 24px;
    transform: none;
    font-size: 24px;
    padding: 8px 14px;
  }

  @media (max-width: 768px) {
    .head { flex-direction: column; align-items: stretch; }
    .search-box { min-width: 100%; }
    .prev { left: 2%; }
    .next { right: 2%; }
  }