:root {
  --bg: #0f1216;
  --card: #171c23;
  --card-2: #1e242d;
  --line: #2a323d;
  --text: #e8edf4;
  --muted: #94a1b2;
  --accent: #4ea1ff;
  --free: #2ecc71;
  --busy: #f39c12;
  --dead: #7f8c8d;
  --danger: #e74c3c;
  --radius: 16px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa; --card: #ffffff; --card-2: #eef2f7; --line: #dfe5ee;
    --text: #131820; --muted: #5d6b7e;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg); color: var(--text); min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.wrap { max-width: 720px; margin: 0 auto; padding: 16px; }

header.top {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 4px;
}
header.top h1 { font-size: 1.25rem; margin: 0; letter-spacing: -0.02em; }
.sub { color: var(--muted); font-size: 0.8rem; margin: 2px 0 18px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.machine { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 auto; }
.icon {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 12px;
  background: var(--card-2); display: grid; place-items: center; font-size: 1.3rem;
}
.name { font-weight: 600; font-size: 1rem; line-height: 1.25; overflow-wrap: anywhere; }
.state { font-size: 0.8rem; color: var(--muted); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dead); flex: 0 0 8px; }
.dot.free { background: var(--free); box-shadow: 0 0 0 3px rgba(46,204,113,.18); }
.dot.busy { background: var(--busy); box-shadow: 0 0 0 3px rgba(243,156,18,.18); }

button {
  font: inherit; cursor: pointer; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card-2); color: var(--text); padding: 10px 14px; transition: .15s;
}
button:hover { filter: brightness(1.12); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #06121f; font-weight: 600; }
button.ghost { background: transparent; }
button.small { padding: 7px 11px; font-size: .85rem; }
button.watching { background: rgba(78,161,255,.15); border-color: var(--accent); color: var(--accent); }

.badge {
  font-size: .72rem; padding: 3px 9px; border-radius: 999px;
  background: var(--card-2); color: var(--muted); border: 1px solid var(--line);
}
.badge.free { color: var(--free); border-color: rgba(46,204,113,.4); }
.badge.busy { color: var(--busy); border-color: rgba(243,156,18,.4); }

.watchline {
  margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--line);
  font-size: .82rem; color: var(--accent); display: flex; justify-content: space-between; gap: 8px;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card-2);
  cursor: pointer; user-select: none; font-size: .9rem;
}
.chip input { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; }
.chip.on { border-color: var(--accent); color: var(--accent); background: rgba(78,161,255,.12); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none;
  align-items: flex-end; justify-content: center; z-index: 50; backdrop-filter: blur(3px);
}
.modal.open { display: flex; }
.sheet {
  background: var(--card); border: 1px solid var(--line); border-bottom: none;
  border-radius: 20px 20px 0 0; padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  width: 100%; max-width: 720px; animation: up .18s ease-out;
}
@keyframes up { from { transform: translateY(16px); opacity: .6 } to { transform: none; opacity: 1 } }
@media (min-width: 640px) {
  .modal { align-items: center; }
  .sheet { border-radius: 20px; border-bottom: 1px solid var(--line); margin: 16px; }
}
.sheet h2 { margin: 0 0 4px; font-size: 1.05rem; }
.sheet p { color: var(--muted); font-size: .85rem; margin: 0 0 16px; }
.sheet .actions { display: flex; gap: 10px; margin-top: 18px; }
.sheet .actions button { flex: 1; }

.foot { color: var(--muted); font-size: .78rem; text-align: center; margin: 22px 0 8px; line-height: 1.6; }
.foot a { color: var(--muted); }
.err { color: var(--danger); font-size: .82rem; margin-top: 10px; min-height: 1.1em; }
.ok { color: var(--free); }
.hide { display: none !important; }
.spin { display: inline-block; animation: sp 1s linear infinite; }
@keyframes sp { to { transform: rotate(360deg) } }

/* page de connexion */
.login {
  min-height: 100svh; display: grid; place-items: center; padding: 20px;
}
.login .card { width: 100%; max-width: 360px; text-align: center; padding: 28px 22px; }
.login h1 { font-size: 1.4rem; margin: 14px 0 6px; }
.login p { color: var(--muted); font-size: .85rem; margin: 0 0 22px; }
input[type=password], input[type=text] {
  font: inherit; width: 100%; padding: 13px 14px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card-2); color: var(--text);
  text-align: center; margin-bottom: 12px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.login button { width: 100%; }
.logo { font-size: 2.6rem; line-height: 1; }
