/* CoopFinNetwork Admin - design 2 : fond clair, menu sombre, cartes blanches, une carte noire pour le graphique principal */
:root {
  --bg: #f3f3f5; --card: #ffffff; --card-2: #f7f7f8; --text: #0b0b0d; --muted: #6b7280; --line: #ececee;
  --ok: #16a34a; --warn: #f59e0b; --bad: #ef4444; --info: #3b82f6;
  --side: #0b0b0d; --side-line: #1c1c20; --side-text: #c9c9cf;
  --dark-card: #0b0b0d; --dark-card-text: #ffffff;
}
:root[data-theme="dark"] {
  --bg: #09090b; --card: #111114; --card-2: #17171a; --text: #f4f4f5; --muted: #8e8e98; --line: #202024;
  --side: #050506; --side-line: #17171a; --dark-card: #050506;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
.muted { color: var(--muted); }
.thin-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.thin-scroll::-webkit-scrollbar-thumb { background: #3a3a40; border-radius: 6px; }

/* Structure */
.sidebar { position: fixed; inset: 0 auto 0 0; width: 250px; background: var(--side); color: var(--side-text); display: flex; flex-direction: column; z-index: 40; transition: transform .2s; }
.sidebar .brand { display: flex; align-items: center; justify-content: space-between; padding: 1.25rem 1.25rem .75rem; }
.sidebar .brand img { height: 40px; width: auto; max-width: 150px; object-fit: contain; }
.sidebar .tag { font-size: .62rem; font-weight: 700; letter-spacing: .06em; border: 1px solid #34343a; border-radius: 8px; padding: .3rem .55rem; color: #fff; }
.sidebar nav { flex: 1; overflow-y: auto; padding: .25rem .75rem 1rem; }
.sidebar .grp { font-size: .62rem; letter-spacing: .09em; text-transform: uppercase; color: #6f6f78; padding: 1.1rem .6rem .4rem; font-weight: 600; }
.sidebar .item { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 10px; font-size: .82rem; font-weight: 500; color: var(--side-text); }
.sidebar .item:hover { background: #17171a; color: #fff; }
.sidebar .item.active { background: #fff; color: #000; font-weight: 600; }
.sidebar .item .chev { margin-left: auto; opacity: .45; }
.sidebar .item svg { flex-shrink: 0; }
.main { margin-left: 250px; min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 1rem; padding: .75rem 1.5rem; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.search { flex: 1; max-width: 520px; display: flex; align-items: center; gap: .6rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .55rem .9rem; color: var(--muted); font-size: .82rem; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; min-width: 0; }
.kbd { font-size: .68rem; border: 1px solid var(--line); border-radius: 6px; padding: .1rem .4rem; color: var(--muted); }
.icon-btn { position: relative; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 0; background: transparent; color: var(--text); }
.icon-btn:hover { background: var(--card); }
.icon-btn .dot { position: absolute; top: 2px; right: 0; background: var(--bad); color: #fff; font-size: .6rem; font-weight: 700; border-radius: 999px; padding: 0 .3rem; }
.pill { display: inline-flex; align-items: center; gap: .45rem; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: .4rem .8rem; font-size: .78rem; font-weight: 500; }
.pill i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.content { padding: 1.5rem; max-width: 1700px; }
.menu-btn { display: none; }

/* Cartes */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.03); }
.card-dark { background: var(--dark-card); color: var(--dark-card-text); border-radius: 16px; border: 1px solid #1c1c20; }
.card-h { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: 1.1rem 1.25rem .4rem; }
.card-h h3 { margin: 0; font-size: .95rem; font-weight: 700; }
.btn { display: inline-flex; align-items: center; gap: .4rem; border-radius: 10px; padding: .45rem .85rem; font-size: .78rem; font-weight: 600; border: 1px solid var(--line); background: var(--card); color: var(--text); }
.btn:hover { background: var(--card-2); }
.btn-dark { background: #0b0b0d; color: #fff; border-color: #0b0b0d; }
:root[data-theme="dark"] .btn-dark { background: #fff; color: #000; border-color: #fff; }
.btn-dark:hover { opacity: .9; background: #0b0b0d; }
.select { appearance: none; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .45rem 2rem .45rem .8rem; font-size: .78rem; font-weight: 500; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238e8e98' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .7rem center; }
.card-dark .select { background-color: #17171a; border-color: #2a2a2f; color: #fff; }
.input { width: 100%; background: var(--card); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .8rem; font-size: .82rem; outline: 0; }
.input:focus { border-color: #8e8e98; }

/* Statistiques */
.kpi { padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: .6rem; }
.kpi .top { display: flex; align-items: center; gap: .8rem; }
.kpi .ico { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: #0b0b0d; color: #fff; flex-shrink: 0; }
.kpi .lab { font-size: .72rem; color: var(--muted); }
.kpi .val { font-size: 1.35rem; font-weight: 800; letter-spacing: -.02em; }
.kpi .foot { display: flex; align-items: flex-end; justify-content: space-between; gap: .5rem; }
.trend { font-size: .76rem; font-weight: 700; }
.trend.up { color: var(--ok); } .trend.down { color: var(--bad); }
.spark { width: 110px; height: 34px; }

/* Graphiques */
.bars { position: relative; display: flex; align-items: flex-end; gap: 3px; height: 190px; padding-left: 38px; }
.bars .grid { position: absolute; inset: 0 0 0 38px; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.bars .grid i { display: block; border-top: 1px solid #25252a; position: relative; }
.bars .grid i span { position: absolute; left: -38px; top: -8px; font-size: .62rem; color: #8e8e98; font-style: normal; }
.bars .bar { flex: 1; background: #fff; border-radius: 2px 2px 0 0; min-height: 2px; position: relative; z-index: 1; opacity: .92; transition: opacity .15s; }
.bars .bar:hover { opacity: 1; background: #d4d4d8; }
.xlabels { display: flex; justify-content: space-between; padding: .5rem 0 0 38px; font-size: .64rem; color: #8e8e98; }
.legend-row { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: center; font-size: .75rem; padding: .32rem 0; }
.legend-row .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .55rem; }
.progress { height: 5px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > i { display: block; height: 100%; border-radius: 99px; background: #0b0b0d; }
:root[data-theme="dark"] .progress > i { background: #fff; }
.tooltip { position: fixed; z-index: 100; pointer-events: none; background: #fff; color: #000; font-size: .7rem; font-weight: 600; padding: .3rem .55rem; border-radius: 6px; transform: translate(-50%, -130%); opacity: 0; transition: opacity .1s; white-space: nowrap; box-shadow: 0 4px 14px rgba(0,0,0,.25); }

/* Tableaux */
.tbl { width: 100%; border-collapse: collapse; font-size: .78rem; }
.tbl th { text-align: left; font-size: .66rem; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); font-weight: 600; padding: .6rem 1.1rem; white-space: nowrap; }
.tbl td { padding: .7rem 1.1rem; border-top: 1px solid var(--line); white-space: nowrap; }
.tbl tbody tr:hover td { background: var(--card-2); }
.tbl tr.click { cursor: pointer; }
.id { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: .72rem; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: .35rem; font-size: .68rem; font-weight: 600; padding: .18rem .6rem; border-radius: 999px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-ok { color: var(--ok); background: rgba(22,163,74,.12); } .b-warn { color: #d97706; background: rgba(245,158,11,.14); }
.b-bad { color: var(--bad); background: rgba(239,68,68,.12); } .b-info { color: var(--info); background: rgba(59,130,246,.12); } .b-mute { color: var(--muted); background: var(--card-2); }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #0b0b0d; color: #fff; font-size: .62rem; font-weight: 700; flex-shrink: 0; }
.flag { width: 18px; height: 13px; border-radius: 2px; object-fit: cover; vertical-align: -2px; margin-right: .45rem; }
.method-ico { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: .55rem; font-weight: 800; margin-right: .5rem; vertical-align: middle; }
.status-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: .6rem; }
.method-get { color: var(--ok); font-weight: 700; } .method-post { color: var(--info); font-weight: 700; } .method-delete { color: var(--bad); font-weight: 700; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); font-size: .74rem; color: var(--muted); }

/* Fenetre */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(3px); z-index: 80; display: none; align-items: center; justify-content: center; padding: 1rem; }
.overlay.open { display: flex; }
.modal { width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; overflow-x: hidden; padding: 1.5rem; }
.dl > div { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--line); font-size: .8rem; }
.dl > div:first-child { border-top: 0; }
.dl dt { color: var(--muted); } .dl dd { margin: 0; text-align: right; word-break: break-all; }
.toggle { position: relative; width: 38px; height: 22px; border-radius: 99px; background: #d4d4d8; border: 0; transition: background .15s; flex-shrink: 0; }
.toggle::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle.on { background: #0b0b0d; } :root[data-theme="dark"] .toggle.on { background: var(--ok); }
.toggle.on::after { transform: translateX(16px); }

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); } .sidebar.open { transform: none; }
  .main { margin-left: 0; } .menu-btn { display: grid; }
  .content { padding: 1rem; } .topbar { padding: .6rem 1rem; }
  .hide-md { display: none !important; }
}

/* ---- Ajouts admin2 ---- */
.sidebar .side-foot { display: flex; align-items: center; gap: .7rem; padding: .9rem 1rem; border-top: 1px solid var(--side-line); }
.sidebar .brand img { max-width: 170px; height: 40px; object-fit: contain; }
.flex-1 { flex: 1 1 0%; }
.min-w-0 { min-width: 0; }

/* Pages reprises de l'ancienne admin : le contenu garde ses classes Tailwind, l'en-tete devient une carte normale */
.content.legacy { padding: 0; max-width: none; }
.content.legacy > header { position: static !important; background: transparent !important; box-shadow: none !important; border: 0 !important; }
.content.legacy > header > div { padding: 1.5rem 1.5rem .25rem !important; }
.content.legacy > header h2 { font-size: 1.5rem; font-weight: 800; letter-spacing: -.02em; }
.content.legacy > header p { color: var(--muted); }
.content.legacy > div { margin-top: .5rem; }
.legacy .toast { z-index: 100; }
.btn[disabled], button[disabled].btn { opacity: .45; cursor: default; }
.field-wrap { position: relative; }
tr.click { cursor: pointer; }
.empty { text-align: center; color: var(--muted); padding: 2.5rem 1rem; }
.tab-bar { display: inline-flex; gap: .25rem; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: .25rem; }
.tab-bar a, .tab-bar button { border: 0; background: transparent; color: var(--muted); padding: .4rem .85rem; border-radius: 9px; font-size: .78rem; font-weight: 600; cursor: pointer; }
.tab-bar .active { background: #0b0b0d; color: #fff; }
.card-flat { background: var(--card-2); border: 1px solid var(--line); border-radius: 12px; }

.sidebar .nav-badge { margin-left: auto; margin-right: .4rem; background: #f59e0b; color: #000; font-size: .62rem; font-weight: 800; border-radius: 999px; padding: .05rem .45rem; }
.sidebar .nav-badge[hidden] { display: none; }
.sidebar .item.active .nav-badge { background: #0b0b0d; color: #fff; }

/* Logo (blanc) pose sur une pastille sombre dans les pages claires */
.logo-chip { display: inline-flex; align-items: center; background: #050506; border-radius: 14px; padding: .6rem 1.1rem; }
.logo-chip img { height: 38px; width: auto; display: block; }
