:root {
  --bg: #f3f5f8;
  --surface: #ffffff;
  --text: #17212b;
  --muted: #5d6b7a;
  --line: #dde3ea;
  --accent: #0f3d5e;
  --accent-2: #1f6fa8;
  --accent-soft: #e4eef7;
  --high: #1e7f4f;
  --high-soft: #def3e7;
  --mid: #a5680a;
  --mid-soft: #fbefd6;
  --low: #6b7684;
  --low-soft: #eceff3;
  --danger: #b3261e;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e141b;
    --surface: #17202a;
    --text: #e6ebf0;
    --muted: #93a1b0;
    --line: #2a3644;
    --accent: #8cc4ef;
    --accent-2: #8cc4ef;
    --accent-soft: #1b3247;
    --high: #6fd39d;
    --high-soft: #173a29;
    --mid: #f0bc5e;
    --mid-soft: #3d2f14;
    --low: #9aa6b3;
    --low-soft: #232d38;
    --danger: #ff8a80;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
h1, h2, h3 { margin: 0; line-height: 1.2; }
h2 { font-size: 1.15rem; margin-bottom: .75rem; }
h3 { font-size: 1rem; margin: 1.25rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.error { color: var(--danger); margin: .5rem 0; }
[hidden] { display: none !important; }

/* --- en-tête ------------------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 0;
}
.top-row { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.brand { flex: 1; min-width: 0; }
.brand h1 { font-size: 1.3rem; color: var(--accent); }
.brand p { margin: 2px 0 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#profile-select {
  font: inherit; font-size: .9rem; padding: 6px 8px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); max-width: 45%;
}
.tabs {
  display: flex; gap: 4px; overflow-x: auto; max-width: 760px; margin: 10px auto 0;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 0 0 auto; font: inherit; font-size: .92rem; background: none; border: 0; color: var(--muted);
  padding: 8px 10px 10px; border-bottom: 3px solid transparent; cursor: pointer;
}
.tabs button.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs b { font-weight: 600; font-size: .78rem; background: var(--low-soft); color: var(--muted); border-radius: 99px; padding: 1px 7px; margin-left: 2px; }
.tabs b:empty { display: none; }
.tabs button.active b { background: var(--accent-soft); color: var(--accent); }
.filters {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 760px; margin: 0 auto; padding: 6px 0 8px;
}
.filters select { font: inherit; font-size: .85rem; margin-left: 4px; padding: 3px 6px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); }

/* --- liste --------------------------------------------------------------- */
main { max-width: 760px; margin: 0 auto; padding: 14px 16px 40px; }
.list { display: flex; flex-direction: column; gap: 12px; }
.empty { text-align: center; padding: 48px 12px; }
.banner {
  background: var(--accent-soft); color: var(--text); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 12px; font-size: .92rem;
  display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap;
}

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px; position: relative;
}
.card.is-new::before {
  content: ""; position: absolute; top: 14px; right: 14px; width: 9px; height: 9px;
  border-radius: 50%; background: var(--accent-2);
}
.card.flash { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.card-head { display: flex; gap: 12px; align-items: flex-start; padding-right: 14px; }
.score {
  flex: 0 0 auto; min-width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center;
  font-weight: 700; font-size: 1.05rem; background: var(--low-soft); color: var(--low);
  font-variant-numeric: tabular-nums;
}
.score.high { background: var(--high-soft); color: var(--high); }
.score.mid { background: var(--mid-soft); color: var(--mid); }
.score.pending { font-size: .7rem; font-weight: 600; text-align: center; line-height: 1.1; }
.card-title { min-width: 0; }
.card-title h3 { margin: 0; font-size: 1.02rem; overflow-wrap: anywhere; }
.meta { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 0; }
.tag { font-size: .78rem; padding: 2px 8px; border-radius: 99px; background: var(--low-soft); color: var(--muted); }
.tag.src { background: var(--accent-soft); color: var(--accent); }
.summary { margin: 10px 0 0; font-size: .95rem; }
.more { margin-top: 8px; font-size: .9rem; }
.more summary { cursor: pointer; color: var(--accent-2); font-weight: 500; padding: 4px 0; }
.more ul { margin: 6px 0; padding-left: 1.2rem; }
.pros li::marker { content: "✓  "; color: var(--high); }
.cons li::marker { content: "!  "; color: var(--mid); font-weight: 700; }
.desc { white-space: pre-line; color: var(--muted); font-size: .85rem; max-height: 22rem; overflow: auto; border-top: 1px solid var(--line); padding-top: 8px; }
.actions { display: flex; gap: 8px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.actions .open { flex: 1 1 auto; }

/* --- boutons, formulaires ------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: .92rem; font-weight: 600; text-decoration: none;
  padding: 9px 14px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 40px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #0e141b; } }
.btn.ghost { background: none; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small-btn { font-size: .85rem; padding: 8px 10px; }
.btn.on { background: var(--high-soft); color: var(--high); border-color: transparent; }
.icon-btn {
  font: inherit; font-size: 1.15rem; width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted); cursor: pointer;
  display: inline-grid; place-items: center; flex: 0 0 auto;
}
.icon-btn.on { color: var(--mid); border-color: var(--mid); background: var(--mid-soft); }
.top .icon-btn { border: 0; background: none; }
.link { background: none; border: 0; padding: 0; font: inherit; color: var(--accent-2); cursor: pointer; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; margin-top: 14px; box-shadow: var(--shadow);
}
label { display: block; margin: 0 0 12px; font-size: .9rem; font-weight: 500; }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 400; }
input:not([type=checkbox]), textarea {
  display: block; width: 100%; margin-top: 4px; font: inherit; font-size: 1rem; color: var(--text);
  background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px;
}
textarea { resize: vertical; font-size: .92rem; }
details > textarea { margin-top: 8px; }
details summary { cursor: pointer; font-size: .9rem; margin-bottom: 12px; }
.grid2 { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }
.row-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.hint { background: var(--mid-soft); border-radius: 10px; padding: 10px 12px; font-size: .9rem; }
.kv { width: 100%; border-collapse: collapse; font-size: .86rem; margin-bottom: 10px; }
.kv td, .kv th { text-align: left; padding: 6px 4px; border-bottom: 1px solid var(--line); vertical-align: top; }
.kv th { color: var(--muted); font-weight: 500; }
.ok { color: var(--high); font-weight: 600; }
.ko { color: var(--danger); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 99px; font-size: .9rem;
  z-index: 20; max-width: calc(100% - 32px); display: flex; gap: 12px; align-items: center;
}
.toast button { background: none; border: 0; color: inherit; font: inherit; font-weight: 700; text-decoration: underline; cursor: pointer; }

/* --- connexion ----------------------------------------------------------- */
.login-body { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; }
.login { width: 100%; max-width: 380px; padding: 24px 16px; text-align: center; }
.login form { text-align: left; margin-top: 24px; }
.login-logo { border-radius: 18px; }
.login h1 { margin-top: 12px; color: var(--accent); }
code { font-size: .9rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 3px 7px; overflow-wrap: anywhere; }
