:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --field: #efeee9;
  --text: #17171a;
  --muted: #8a8a90;
  --line: #e7e5df;
  --accent: #1f6f5c;
  --accent-soft: #e3f0ec;
  --danger: #c2413b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 8px 32px rgba(0, 0, 0, .06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121214;
    --surface: #1b1b1f;
    --field: #26262b;
    --text: #f1f1f2;
    --muted: #8d8d95;
    --line: #2c2c32;
    --accent: #4fb89c;
    --accent-soft: #1b3330;
    --danger: #e5635d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 32px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; margin: 0; }

body {
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

/* ---------- Éléments communs ---------- */

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: .95rem;
}
.brand::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}
.brand small { color: var(--muted); font-weight: 500; }

input, select {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--field);
  border: 2px solid transparent;
  border-radius: 12px;
  transition: border-color .15s, background .15s;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%238a8a90' stroke-width='2'%3E%3Cpath d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  padding-right: 40px;
  cursor: pointer;
}
input::placeholder { color: var(--muted); }
input:focus, select:focus { outline: none; border-color: var(--accent); background-color: var(--surface); }

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

.btn {
  height: 52px;
  padding: 0 22px;
  border-radius: 12px;
  font-weight: 600;
  background: var(--text);
  color: var(--bg);
  transition: transform .1s, opacity .15s;
}
.btn:hover { opacity: .88; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.block { width: 100%; }

.btn-ghost {
  height: 38px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.btn-ghost:hover { background: var(--field); color: var(--text); }

.error { color: var(--danger); font-size: .9rem; text-align: center; margin-top: 14px; min-height: 1.2em; }

/* ---------- Page de pointage ---------- */

.kiosk {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 16px;
}
.kiosk-head {
  width: 100%;
  max-width: 420px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.admin-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.back-link {
  display: inline-block;
  margin-top: 20px;
  color: var(--muted);
  font-size: .9rem;
  text-decoration: none;
}
.back-link:hover { color: var(--text); }
.login-box { text-align: left; }
.login-box .back-link { display: block; text-align: center; }

.kiosk-body {
  flex: 1;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 0;
}

.hello {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 500;
  color: var(--accent);
  margin-bottom: 14px;
}

.clock {
  font-size: clamp(4rem, 18vw, 6rem);
  font-weight: 300;
  letter-spacing: -.04em;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.clock span { color: var(--muted); font-size: .4em; letter-spacing: 0; margin-left: 4px; }
.today { text-align: center; color: var(--muted); margin: 12px 0 44px; }
.today::first-letter { text-transform: uppercase; }

.fields { display: grid; gap: 12px; margin-bottom: 20px; }
.fields .pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.status {
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Confirmation */
.done { text-align: center; animation: rise .35s ease-out; }
.check {
  width: 84px;
  height: 84px;
  margin: 0 auto 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
}
.done h1 { font-size: 1.4rem; font-weight: 600; }
.done .time { font-size: 4rem; font-weight: 300; letter-spacing: -.03em; margin: 8px 0; font-variant-numeric: tabular-nums; }
.done p { color: var(--muted); margin-bottom: 36px; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- Admin : connexion ---------- */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}
.login-box { width: 100%; max-width: 360px; }
.login-box .brand { margin-bottom: 40px; }
.login-box h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; margin-bottom: 6px; }
.login-box p { color: var(--muted); margin-bottom: 28px; }
.login-box input { margin-bottom: 12px; }

/* ---------- Admin : tableau de bord ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner, .container { max-width: 880px; margin: 0 auto; padding: 0 16px; }
.topbar-inner { height: 64px; display: flex; align-items: center; justify-content: space-between; }

.container { padding-top: 36px; padding-bottom: 64px; }

.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.head h1 { font-size: 1.9rem; font-weight: 600; letter-spacing: -.03em; }
.head h1::first-letter { text-transform: uppercase; }
.head .count { color: var(--muted); margin-top: 4px; }

.stepper { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  color: var(--muted);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--field); color: var(--text); }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar select { width: auto; height: 42px; font-size: .92rem; flex: 1 1 180px; max-width: 240px; }
.toolbar .btn { height: 42px; font-size: .92rem; margin-left: auto; }

.seg { display: inline-flex; background: var(--field); border-radius: 12px; padding: 4px; }
.seg button {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  font-size: .9rem;
  font-weight: 500;
  color: var(--muted);
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }

.list {
  list-style: none;
  padding: 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.list li {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}
.list li:first-child { border-top: none; }

.avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: .85rem;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.who { flex: 1; min-width: 0; }
.who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span { color: var(--muted); font-size: .88rem; }
.when { text-align: right; }
.when b { display: block; font-size: 1.1rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.when span { color: var(--muted); font-size: .8rem; }
.when b { white-space: nowrap; }
.when b span { font-size: inherit; color: var(--muted); font-weight: 400; }
.when .arrow { margin: 0 4px; }
.when .missing { color: var(--danger); font-weight: 500; }

@media (max-width: 560px) {
  .list li { flex-wrap: wrap; gap: 6px 10px; padding: 14px 16px; }
  .avatar { display: none; }
  .who { flex: 1 1 100%; }
  .who b, .who span { display: inline; }
  .who span::before { content: " · "; }
  .when { flex: 1; text-align: left; }
  .when b { font-size: 1rem; }
}

.actions { display: flex; gap: 2px; flex: none; }
.actions .icon-btn { opacity: 0; }
.list li:hover .icon-btn, .actions .icon-btn:focus-visible, .actions .needed { opacity: 1; }
.del:hover { color: var(--danger); background: var(--field); }
.edit.needed { color: var(--danger); }
@media (hover: none) { .actions .icon-btn { opacity: 1; } }

.when .fixed { color: var(--accent); font-weight: 500; }

.empty { padding: 56px 18px !important; justify-content: center; color: var(--muted); }

/* ---------- Fenêtre « Sites » ---------- */

dialog {
  width: min(420px, calc(100% - 32px));
  margin: auto;
  border: none;
  border-radius: 18px;
  padding: 28px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .2);
}
dialog::backdrop { background: rgba(0, 0, 0, .35); backdrop-filter: blur(2px); }
dialog h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 4px; }
dialog .hint { color: var(--muted); font-size: .9rem; margin-bottom: 20px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; }

.field-label { display: block; font-size: .85rem; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
#depart-input { font-size: 1.4rem; font-variant-numeric: tabular-nums; height: 60px; }
.hint.small { font-size: .82rem; margin: 10px 0 0; }
.dialog-actions { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; }
.dialog-actions .btn { margin-left: auto; height: 46px; }

.sites { list-style: none; padding: 0; margin-bottom: 16px; max-height: 280px; overflow-y: auto; }
.sites li { display: flex; align-items: center; justify-content: space-between; padding: 8px 0 8px 4px; border-bottom: 1px solid var(--line); }
.sites li.none { color: var(--muted); border: none; padding: 8px 0; }
.sites .del { opacity: 1; }
.add-site { display: flex; gap: 8px; }
.add-site input { height: 46px; }
.add-site .btn { height: 46px; }
