:root {
  color-scheme: dark;
  --bg: #08090b;
  --surface: #111317;
  --surface-2: #17191e;
  --line: #292c33;
  --text: #f5f5f5;
  --muted: #969aa4;
  --red: #e1393e;
  --red-dark: #921f24;
  --green: #33bd7a;
  --amber: #e7a33a;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 80% 0, #1b1114 0, var(--bg) 33rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 250px; padding: 28px 18px;
  display: flex; flex-direction: column; background: #0c0d10ee;
  border-right: 1px solid var(--line); backdrop-filter: blur(16px); z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; color: white; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 42px; height: 42px; background: var(--red); font-weight: 900; transform: skew(-7deg); }
.brand b, .brand small { display: block; letter-spacing: .1em; }
.brand small { margin-top: 3px; color: var(--muted); font-size: .65rem; }
nav { display: grid; gap: 7px; }
nav a { padding: 13px 14px; border-radius: 8px; color: var(--muted); text-decoration: none; font-weight: 650; transition: .2s; }
nav a span { display: inline-block; width: 26px; font-size: 1.1rem; }
nav a:hover, nav a.active { color: white; background: var(--surface-2); }
nav a.active { box-shadow: inset 3px 0 var(--red); }
.connection { margin-top: auto; display: flex; align-items: center; gap: 9px; padding: 12px; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--line); }
.connection i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 12px var(--green); }

main { margin-left: 250px; min-height: 100vh; padding: 0 4vw 60px; }
header { min-height: 110px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); }
h1, h2, h3, p { margin: 0; }
h1 { font-size: clamp(1.55rem, 3vw, 2.2rem); }
.eyebrow { color: var(--red); font-size: .68rem; font-weight: 800; letter-spacing: .2em; margin-bottom: 6px; }
.header-tools, .account { display: flex; align-items: center; gap: 14px; }
.clock { text-align: right; color: var(--muted); text-transform: capitalize; }
.clock span, .clock strong { display: block; }
.clock strong { color: white; margin-top: 3px; font-size: 1.15rem; }
.account { padding-left: 14px; border-left: 1px solid var(--line); }
.account span { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .82rem; font-weight: 700; }
.account button { padding: 7px 10px; font-size: .75rem; }
.page { display: none; animation: fade .25s ease; padding-top: 34px; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } }
.section-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 24px; }
.section-heading h2 { font-size: 1.25rem; }
.section-heading p, .panel p { color: var(--muted); margin-top: 6px; font-size: .88rem; }
.primary, .secondary, .danger { border: 0; border-radius: 7px; padding: 11px 16px; color: white; font-weight: 750; }
.primary { background: var(--red); box-shadow: 0 7px 25px #e1393e25; }
.primary:hover { background: #ef474c; }
.secondary { background: var(--surface-2); border: 1px solid var(--line); }
.danger { padding: 7px 10px; background: #3a171a; color: #ff8b90; }

.quota-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; margin-bottom: 20px; }
.quota-card, .panel { background: linear-gradient(145deg, #15171b, #0e1013); border: 1px solid var(--line); border-radius: 13px; }
.quota-card { padding: 24px; position: relative; overflow: hidden; }
.quota-card::after { content: ""; position: absolute; width: 120px; height: 120px; right: -45px; top: -45px; border: 1px solid #ffffff0c; border-radius: 50%; }
.card-head, .card-count, .panel-title > div, .availability-row, .history-top, .member-card, .actions { display: flex; align-items: center; }
.card-head { justify-content: space-between; margin-bottom: 28px; }
.card-head h3 { letter-spacing: .12em; }
.status { padding: 6px 9px; border-radius: 20px; font-size: .65rem; font-weight: 800; letter-spacing: .08em; }
.status.disponible { color: var(--green); background: #33bd7a16; }
.status.presque { color: var(--amber); background: #e7a33a16; }
.status.atteint { color: #ff7176; background: #e1393e20; }
.card-count { justify-content: space-between; align-items: end; }
.card-count strong { font-size: 2.6rem; line-height: 1; }
.card-count strong small { color: var(--muted); font-size: 1rem; }
.card-count > span { color: var(--muted); font-size: .8rem; }
.progress { height: 7px; margin: 17px 0 13px; border-radius: 10px; overflow: hidden; background: #272a30; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, var(--red-dark), var(--red)); border-radius: inherit; }
.remaining { font-size: .82rem; color: var(--muted); }
.remaining b { color: white; }
.panel { padding: 22px; }
.panel-title { margin-bottom: 15px; }
.panel-title > div { gap: 12px; }
.icon-box { display: grid; place-items: center; width: 38px; height: 38px; color: var(--red); background: #e1393e12; border: 1px solid #e1393e30; border-radius: 8px; }
.availability-list { display: grid; gap: 8px; }
.availability-row { justify-content: space-between; gap: 15px; background: #0b0d10; border: 1px solid #22252b; border-radius: 8px; padding: 13px 15px; }
.availability-row b { font-size: .85rem; }
.availability-row span { color: var(--muted); font-size: .82rem; }
.availability-row time { color: white; font-weight: 650; }
.empty { padding: 24px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 9px; }

.form-panel { max-width: 760px; }
.form-panel > label, .field > label { display: block; margin: 4px 0 10px; font-weight: 700; }
.type-picker { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.type-picker input { position: absolute; opacity: 0; }
.type-picker span { display: block; padding: 18px; background: #0c0e11; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.type-picker input:checked + span { border-color: var(--red); box-shadow: inset 0 0 0 1px var(--red); }
.type-picker small, .field small { display: block; color: var(--muted); margin-top: 5px; }
.field { margin-bottom: 24px; }
.field em { color: var(--muted); font-weight: 400; }
.participant-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.participant-picker input { position: absolute; opacity: 0; }
.participant-picker span { display: block; padding: 8px 12px; background: #0c0e11; border: 1px solid var(--line); border-radius: 20px; cursor: pointer; }
.participant-picker input:checked + span { background: #e1393e20; border-color: var(--red); }
textarea, input, select { width: 100%; color: white; background: #0b0d10; border: 1px solid var(--line); border-radius: 8px; padding: 12px; outline: none; }
textarea:focus, input:focus, select:focus { border-color: var(--red); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.filters { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.history-list { display: grid; gap: 10px; }
.history-item { padding: 18px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.history-top { justify-content: space-between; gap: 10px; }
.history-title { display: flex; align-items: center; gap: 10px; }
.type-badge { padding: 5px 8px; background: #e1393e16; color: #ff777c; border-radius: 5px; font-size: .72rem; font-weight: 800; }
.history-meta { color: var(--muted); font-size: .8rem; }
.participants { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; }
.participants span { padding: 4px 8px; border-radius: 4px; background: #22252a; font-size: .75rem; }
.notes { margin-top: 12px; color: #c7c9ce; white-space: pre-wrap; font-size: .86rem; }
.actions { gap: 6px; }
.actions .secondary { padding: 7px 10px; }

.inline-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.inline-form .primary { grid-column: 2; }
.admin-check { display: flex; align-items: center; gap: 9px; padding: 0 5px; color: var(--muted); }
.admin-check input { width: auto; accent-color: var(--red); }
.member-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.member-card { justify-content: space-between; gap: 12px; padding: 17px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; }
.member-info { min-width: 0; }
.member-info b { display: block; overflow: hidden; text-overflow: ellipsis; }
.member-info small { color: var(--muted); }
.hidden { display: none !important; }
#toast { position: fixed; right: 24px; bottom: 24px; z-index: 30; max-width: 380px; padding: 13px 16px; background: #20232a; border: 1px solid #3b3f48; border-radius: 8px; box-shadow: 0 15px 40px #0009; opacity: 0; pointer-events: none; transform: translateY(10px); transition: .2s; }
#toast.show { opacity: 1; transform: none; }
#toast.error { border-color: var(--red); }
.login-screen { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 20px; background: radial-gradient(circle at 50% 20%, #261316, #07080a 55%); }
.login-screen.hidden { display: none; }
.login-card { width: min(420px, 100%); padding: 32px; background: #111317; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 30px 90px #000b; }
.login-card .brand-mark { margin-bottom: 22px; }
.login-card h2 { margin-bottom: 7px; font-size: 1.8rem; }
.login-card > p:not(.eyebrow, .login-error) { color: var(--muted); margin-bottom: 25px; }
.login-card label { display: block; margin: 14px 0 7px; font-size: .82rem; font-weight: 700; }
.login-card .primary { width: 100%; margin-top: 20px; }
.login-error { min-height: 20px; margin-top: 12px; color: #ff777c; font-size: .8rem; text-align: center; }

@media (max-width: 850px) {
  .sidebar { position: fixed; inset: auto 0 0; width: auto; height: 67px; padding: 8px; border: 0; border-top: 1px solid var(--line); }
  .brand, .connection { display: none; }
  nav { display: grid; grid-template-columns: repeat(4, 1fr); }
  nav a { padding: 7px 3px; text-align: center; font-size: .66rem; }
  nav a span { display: block; width: auto; font-size: 1rem; margin-bottom: 3px; }
  nav a.active { box-shadow: inset 0 -2px var(--red); }
  main { margin-left: 0; padding: 0 18px 90px; }
  header { min-height: 88px; }
  .quota-grid, .member-grid { grid-template-columns: 1fr; }
  .filters { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr 1fr; }
  .inline-form .primary { grid-column: auto; }
}
@media (max-width: 540px) {
  .clock span { display: none; }
  .clock { display: none; }
  .account { padding: 0; border: 0; }
  .account span { display: none; }
  .section-heading { align-items: stretch; flex-direction: column; }
  .section-heading .primary { width: 100%; }
  .type-picker { grid-template-columns: 1fr; }
  .inline-form { grid-template-columns: 1fr; }
  .history-top { align-items: flex-start; flex-direction: column; }
  .actions { width: 100%; }
  .actions button { flex: 1; }
  .availability-row { align-items: flex-start; flex-direction: column; }
}
