:root {
  --bg: #f4ecdc; --fg: #031a37; --muted: #6e7686; --line: #e2d6bf; --surface: #fbf6ec;
  --accent: #031a37; --accent-fg: #f4ecdc; --accent-soft: #8b9271; --danger: #b42318; --radius: 14px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #031a37; --fg: #f4ecdc; --muted: #8592a8; --line: #13304f; --surface: #0a2546;
    --accent: #f4ecdc; --accent-fg: #031a37; --accent-soft: #c9cbb1; --danger: #f97066; }
}
* { box-sizing: border-box; margin: 0; }
body { font: 15px/1.5 "Inter", system-ui, -apple-system, "Segoe UI", sans-serif; letter-spacing: -.005em;
  background: var(--bg); color: var(--fg); -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
header, main { max-width: 760px; margin: 0 auto; padding: 0 24px; }
header { display: flex; justify-content: space-between; align-items: center; height: 72px; }
header h1 { display: flex; align-items: center; gap: 10px; font-size: 1.1rem; font-weight: 700; letter-spacing: -.03em; }
header h1 .logo { width: 30px; height: 30px; }
.header-actions { display: flex; align-items: center; gap: 14px; font-size: .85rem; color: var(--muted); }
.header-actions button.link { padding: 0; display: inline-flex; }
main { padding-bottom: 80px; }

/* Contrôles */
button, .button { font: inherit; font-weight: 500; border: 0; border-radius: 999px; padding: 10px 18px; cursor: pointer;
  background: var(--accent); color: var(--accent-fg); text-decoration: none; display: inline-block; text-align: center;
  transition: opacity .15s, background .15s; }
button:hover, .button:hover { opacity: .85; }
button.ghost { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }
button.link { background: none; color: var(--muted); padding: 0; }
button.link:hover { color: var(--fg); }
button.danger { color: var(--danger); box-shadow: none; padding-inline-start: 0; }
label { display: block; margin-bottom: 18px; font-size: .78rem; color: var(--muted); }
input, textarea, select { display: block; width: 100%; margin-top: 6px; padding: 8px 0; font: inherit; font-size: 1rem; color: var(--fg);
  background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; transition: border-color .15s; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--fg); }
textarea { resize: vertical; }
.error { color: var(--danger); font-size: .85rem; margin-bottom: 14px; }

/* Connexion */
.narrow { max-width: 340px; margin: 12vh auto 0; }
#auth h2 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.03em; margin-bottom: 32px; }
#login-form button, #oidc-btn { width: 100%; margin-top: 8px; padding: 12px; }
.sep { text-align: center; color: var(--muted); font-size: .8rem; margin: 20px 0 12px; }
#oidc-btn { background: transparent; color: var(--fg); box-shadow: inset 0 0 0 1px var(--line); }

/* Résumé */
.stats { display: flex; gap: 48px; padding: 24px 0 40px; }
.stat .v { font-size: 2.2rem; font-weight: 600; letter-spacing: -.04em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .l { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* Barre d'outils */
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 8px; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 999px; background: var(--line); }
.seg button { background: transparent; color: var(--muted); padding: 6px 12px; font-size: .82rem; }
.seg button.active { background: var(--surface); color: var(--fg); box-shadow: 0 1px 2px rgb(3 26 55 / .08); }

/* Tableau */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 8px; text-align: left; white-space: nowrap; }
th:first-child, td:first-child { padding-inline-start: 0; } th:last-child, td:last-child { padding-inline-end: 0; }
th { font-size: .72rem; font-weight: 500; color: var(--muted); cursor: pointer; user-select: none; border-bottom: 1px solid var(--line); }
th.sorted { color: var(--fg); }
th.sorted::after { content: ' ↓'; } th.sorted.asc::after { content: ' ↑'; }
td { border-bottom: 1px solid var(--line); }
tbody tr { cursor: pointer; transition: opacity .15s; }
tbody:hover tr { opacity: .55; } tbody tr:hover { opacity: 1; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
td.name { white-space: normal; font-weight: 500; }
td.name small { display: block; font-weight: 400; font-size: .8rem; color: var(--muted); margin-top: 2px; }
.tag { font-size: .72rem; color: var(--muted); margin-left: 8px; font-weight: 400; }
.tag::before { content: '· '; }
td:not(.name):not(.rate) { color: var(--muted); }
td.rate { font-weight: 600; font-size: 1.02rem; }
.muted { color: var(--muted); text-align: center; padding: 64px 0; }

/* Modale */
dialog { margin: auto; border: 0; border-radius: 20px; padding: 32px; width: min(440px, 92vw); background: var(--surface); color: var(--fg);
  box-shadow: 0 24px 64px rgb(3 26 55 / .22); }
dialog::backdrop { background: rgb(3 26 55 / .35); backdrop-filter: blur(4px); }
dialog h2 { font-size: 1.25rem; font-weight: 600; letter-spacing: -.02em; margin-bottom: 28px; }
dialog[open] { animation: pop .18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.actions { display: flex; gap: 8px; margin-top: 12px; align-items: center; } .spacer { flex: 1; }

@media (max-width: 600px) {
  header, main { padding: 0 18px; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; padding: 12px 0 28px; } .stat .v { font-size: clamp(1.3rem, 7vw, 1.7rem); }
  th:nth-child(3), td:nth-child(3), th:nth-child(4), td:nth-child(4) { display: none; }
  #add-btn { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom)); width: 56px; height: 56px;
    padding: 0; font-size: 0; box-shadow: 0 8px 24px rgb(3 26 55 / .25); z-index: 5; }
  #add-btn::before { content: '+'; font-size: 1.6rem; font-weight: 300; }
  .toolbar { display: block; } .seg { display: flex; width: 100%; } .seg button { flex: 1; padding: 8px 0; }
  dialog { padding: 24px; }
}

/* Identité */
header h1 .dot { color: var(--accent-soft); }
td.rate, .stat:last-child .v { color: var(--accent); }
th.sorted { color: var(--accent); }
.seg button.active { background: var(--accent); color: var(--accent-fg); box-shadow: none; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.stat .v { font-weight: 700; }
tbody tr:hover td.name { color: var(--accent); }
::selection { background: var(--accent); color: var(--accent-fg); }
select { appearance: none; cursor: pointer; }
[dir="rtl"] .num { text-align: left; }
[dir="rtl"] th, [dir="rtl"] td { text-align: right; } [dir="rtl"] th.num, [dir="rtl"] td.num { text-align: left; }
@media (max-width: 600px) { #add-btn { right: auto; inset-inline-end: 20px; } #username { display: none; } }
