@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&family=Source+Serif+4:opsz,wght@8..60,600&display=swap');

:root {
  --ink: #14212b;
  --muted: #5a6b78;
  --line: #d5dde5;
  --bg: #eef2f5;
  --panel: #ffffff;
  --side: #12353a;
  --side-2: #0c2629;
  --accent: #1f8a70;
  --accent-2: #166b57;
  --warn: #9a3412;
  --danger: #b42318;
  --ok: #0f766e;
  --radius: 14px;
  --shadow: 0 18px 40px rgba(18, 33, 43, 0.08);
  --font: "Outfit", system-ui, sans-serif;
  --display: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(31,138,112,.12), transparent 55%),
    radial-gradient(900px 400px at 100% 0%, rgba(18,53,58,.10), transparent 50%),
    var(--bg);
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.app-shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--side) 0%, var(--side-2) 100%);
  color: #e8f2f1;
  padding: 1.4rem 1rem 2rem;
  display: flex; flex-direction: column; gap: 1.25rem;
}
.sidebar .brand {
  font-family: var(--display);
  font-size: 1.35rem;
  line-height: 1.2;
  padding: 0 .4rem;
}
.sidebar .brand span { display: block; font-family: var(--font); font-size: .75rem; opacity: .7; margin-top: .35rem; font-weight: 500; }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.sidebar nav a {
  color: #d7e8e6; text-decoration: none; padding: .65rem .75rem; border-radius: 10px;
  font-weight: 500; font-size: .95rem;
}
.sidebar nav a:hover, .sidebar nav a.active { background: rgba(255,255,255,.08); text-decoration: none; }
.sidebar .who {
  margin-top: auto; padding: .85rem .75rem; border-radius: 12px;
  background: rgba(255,255,255,.06); font-size: .85rem;
}
.sidebar .who strong { display: block; margin-bottom: .2rem; }
.main { padding: 1.5rem 1.75rem 2.5rem; }
.topbar {
  display: flex; justify-content: space-between; align-items: end; gap: 1rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.topbar h1 {
  font-family: var(--display); font-size: 1.85rem; margin: 0; font-weight: 600;
}
.topbar p { margin: .35rem 0 0; color: var(--muted); }

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.2rem 1.3rem; box-shadow: var(--shadow); margin-bottom: 1rem;
}
.card h2 { margin: 0 0 .9rem; font-size: 1.05rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: sticky; top: 0; z-index: 5; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

label { display: block; font-weight: 600; font-size: .88rem; margin: .55rem 0 .28rem; }
input, select, textarea, button, .btn {
  font: inherit; border-radius: 10px; border: 1px solid var(--line);
  padding: .6rem .75rem; width: 100%; background: #fff; color: var(--ink);
}
textarea { min-height: 80px; resize: vertical; }
button, .btn {
  width: auto; display: inline-flex; align-items: center; justify-content: center;
  gap: .35rem; background: var(--accent); color: #fff; border: none;
  font-weight: 600; cursor: pointer; text-decoration: none; padding: .62rem 1rem;
}
button:hover, .btn:hover { background: var(--accent-2); text-decoration: none; }
.btn.ghost, button.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn.danger, button.danger { background: var(--danger); }
.btn.secondary, button.secondary { background: #334155; }

.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: .7rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }

.badge {
  display: inline-block; padding: .18rem .5rem; border-radius: 999px;
  font-size: .72rem; font-weight: 700; background: #e8eef2; color: var(--ink);
}
.badge.ok { background: #ccfbf1; color: var(--ok); }
.badge.off { background: #fee2e2; color: var(--danger); }
.badge.admin { background: #dbeafe; color: #1e3a8a; }

.flash { padding: .85rem 1rem; border-radius: 12px; margin-bottom: 1rem; font-weight: 500; }
.flash.ok { background: #ecfdf5; color: var(--ok); border: 1px solid #a7f3d0; }
.flash.err { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 1.5rem;
}
.login-card { width: min(420px, 100%); }
.login-card h1 { font-family: var(--display); margin: 0 0 .3rem; }
.muted { color: var(--muted); }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.stat {
  padding: 1rem; border-radius: 12px; background: #f7fafb; border: 1px solid var(--line);
}
.stat .n { font-size: 1.6rem; font-weight: 700; }
.stat .l { color: var(--muted); font-size: .85rem; }
.folder-select select { max-width: 320px; }

/* Modal sync */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 28, 36, .55);
  display: none; align-items: center; justify-content: center;
  z-index: 1000; padding: 1rem;
}
.modal-backdrop.open { display: flex; }
.modal-card {
  background: #fff; border-radius: 16px; width: min(440px, 100%);
  padding: 1.4rem 1.5rem; box-shadow: 0 24px 60px rgba(0,0,0,.25);
}
.modal-card h2 { margin: 0 0 .5rem; font-family: var(--display); font-size: 1.35rem; }
.modal-card .spin {
  width: 28px; height: 28px; border: 3px solid #d5dde5; border-top-color: var(--accent);
  border-radius: 50%; animation: spin 0.8s linear infinite; margin: .8rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.progress {
  height: 10px; background: #e8eef2; border-radius: 999px; overflow: hidden; margin: .8rem 0 .4rem;
}
.progress > span {
  display: block; height: 100%; width: 0%; background: linear-gradient(90deg, var(--accent), #2bb38f);
  transition: width .35s ease;
}
.progress.indeterminate > span {
  width: 40% !important;
  animation: indet 1.2s ease-in-out infinite;
}
@keyframes indet {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(280%); }
}
.modal-meta { color: var(--muted); font-size: .92rem; line-height: 1.45; }
.modal-actions { margin-top: 1rem; display: flex; gap: .5rem; justify-content: flex-end; }


/* Sélecteur de valeurs découverte X3 */
.discover-bar { display:flex; flex-wrap:wrap; gap:.6rem; align-items:end; margin:.8rem 0 1rem; }
.discover-bar .grow { flex:1; min-width:140px; }
.value-picker {
  max-height: 220px; overflow:auto; border:1px solid var(--line);
  border-radius: 10px; background:#fff; padding:.35rem;
}
.value-picker label.val-opt {
  display:flex; align-items:center; gap:.55rem;
  padding:.4rem .55rem; border-radius:8px; cursor:pointer; margin:0;
  font-size:.9rem;
}
.value-picker label.val-opt:hover { background:#f1f5f7; }
.value-picker label.val-opt input { width:auto; margin:0; }
.value-picker .val-count { margin-left:auto; color:var(--muted); font-size:.75rem; }
.filter-chip-row {
  display:flex; flex-wrap:wrap; gap:.4rem; margin:.5rem 0;
}
.filter-chip {
  display:inline-flex; align-items:center; gap:.35rem;
  background:#e8eef2; border-radius:999px; padding:.25rem .65rem;
  font-size:.82rem; font-weight:600;
}
.filter-chip button {
  border:0; background:transparent; padding:0; margin:0; cursor:pointer;
  color:var(--danger); font-size:1rem; line-height:1; width:auto;
}
.discover-meta { font-size:.85rem; color:var(--muted); margin:.4rem 0 0; }
#discover-samples { margin-top:1rem; }

/* Sync page tabs + compact import */
.sync-tabs {
  display: flex; gap: .35rem; margin: 1rem 0 .75rem; flex-wrap: wrap;
  border-bottom: 1px solid var(--line); padding-bottom: .35rem;
}
.sync-tabs a {
  text-decoration: none; color: var(--muted); font-weight: 600; font-size: .92rem;
  padding: .45rem .85rem; border-radius: 999px;
}
.sync-tabs a:hover { background: #eef3f6; color: var(--ink); }
.sync-tabs a.active { background: var(--ink); color: #fff; }
.sync-import-grid {
  display: grid; grid-template-columns: minmax(280px, 1fr) minmax(300px, 1.15fr);
  gap: 1.1rem; align-items: start;
}
@media (max-width: 900px) {
  .sync-import-grid { grid-template-columns: 1fr; }
}
.sync-col h2 { margin: 0 0 .7rem; font-size: 1rem; }
.sync-hint {
  font-size: .82rem; line-height: 1.4; margin: .7rem 0;
  padding: .55rem .7rem; background: #f7fafb; border-radius: 10px; border: 1px solid var(--line);
}
.discover-builder-box {
  border: 1px solid var(--line); border-radius: 12px; padding: .75rem;
  background: #f7fafb; min-height: 220px;
}
.sync-details > summary {
  cursor: pointer; font-weight: 600; color: var(--muted); font-size: .9rem;
}
.value-picker { max-height: 280px; }
.sync-import-card { margin-top: 0; }

.preset-box {
  margin: .75rem 0; padding: .65rem .75rem; border: 1px solid var(--line);
  border-radius: 12px; background: #fff;
}
.preset-row { display:flex; gap:.4rem; flex-wrap:wrap; align-items:center; }
.preset-row select, .preset-row input[type=text] { flex:1; min-width:140px; }
.column-picker {
  display:grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: .25rem; margin-top: .55rem;
}
