@import url("https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800&display=swap");

* {
  box-sizing: border-box;
  font-family: "Nunito", "Poppins", "Avenir Next", "Trebuchet MS", sans-serif;
}

:root {
  --bg: #eef1f7;
  --panel: #ffffff;
  --ink: #1f2a44;
  --muted: #6c7a93;
  --nav: #1f2a44;
  --nav-dark: #1a2338;
  --nav-accent: #2d3a5f;
  --accent: #4c7bd9;
  --success: #3e8e6c;
  --warn: #f2a93b;
  --danger: #d94b4b;
  --shadow: 0 14px 34px rgba(18, 30, 60, 0.18);
}

body {
  margin: 0;
  display: flex;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 20% -10%, #f7f8fd 0, #eef1f7 55%, #e9edf6 100%);
  color: var(--ink);
}

body:not(.is-admin) .sidebar {
  display: none;
}

body.company-locked .sidebar {
  display: none;
}

body.company-locked .topbar {
  display: none;
}

body.company-locked .content {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

body.company-locked .content .card {
  width: min(520px, calc(100vw - 32px));
}

.company-login-wrap {
  width: 100%;
}

.company-login-card h1 {
  margin: 0 0 6px;
}

.company-login-card p {
  margin: 0 0 14px;
  color: #5f6f8f;
}

.company-login-form {
  display: grid;
  gap: 12px;
}

.company-login-form label {
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.company-login-form input {
  border: 1px solid #ccd4e5;
  border-radius: 10px;
  padding: 10px 12px;
}

.company-login-form button {
  border: 0;
  border-radius: 10px;
  background: #1f2a44;
  color: #fff;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

.company-login-error {
  color: #b91c1c;
  background: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 80px;
  background: linear-gradient(180deg, var(--nav) 0%, var(--nav-dark) 100%);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 4px 0 18px rgba(12, 18, 38, 0.18);
}

.sidebar-logo {
  padding: 20px 0;
}

.sidebar nav {
  display: flex;
  flex-direction: column;
  width: 100%;
}

.nav-item {
  background: transparent;
  border: none;
  color: #dfe6f7;
  padding: 14px 0;
  cursor: pointer;
  text-align: center;
  font-size: 11px;
  transition: background 0.2s ease, color 0.2s ease;
}

.nav-item .material-icons {
  display: block;
  font-size: 22px;
  margin-bottom: 4px;
}

.nav-item.active,
.nav-item:hover {
  background: var(--nav-accent);
  color: #fff;
}

/* ===== MAIN ===== */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ===== TOP BAR ===== */
.topbar {
  background: linear-gradient(180deg, #2a3656 0%, #1f2a44 100%);
  color: #fff;
  padding: 12px 20px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  border-bottom: none;
  min-width: 0;
  box-shadow: 0 6px 16px rgba(16, 24, 40, 0.2);
}

.topbar-left {
  justify-self: start;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 20px;
  min-width: 0;
}

.topbar h1 {
  color: #fff;
  letter-spacing: 0.4px;
  justify-self: center;
}

.session-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.admin-pwd-btn {
  opacity: 0.6;
  border: 1px solid #d6dbe6;
  background: #f4f6fa;
}

.company-logout-btn {
  display: none;
  border: 1px solid #f1c6c6;
  background: #fff4f4;
  color: #7f1d1d;
}

body:not(.is-admin) .admin-pwd-btn {
  display: none;
}

.badge-user {
  background: #e9eefc;
  color: #1f2a44;
  max-width: 320px;
  width: 100%;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.audit-flag {
  font-size: 11px;
  color: #c00;
  font-weight: 600;
  cursor: help;
}

.audit-tooltip{
  position:absolute;
  z-index:9999;
  max-width:350px;
  max-height:260px;
  overflow:auto;
  padding:12px 14px;
  border-radius:10px;
  background:#3a3a3a;
  color:#fff;
  box-shadow:0 10px 25px rgba(0,0,0,.25);
  white-space:normal;
  line-height:1.35;
  font-size:13px;
}
.audit-head{display:flex;align-items:center;gap:8px;margin-bottom:6px;}
.audit-badge{font-weight:700;font-size:11px;padding:3px 8px;border-radius:999px;background:#777;}
.audit-ts{opacity:.9;font-variant-numeric:tabular-nums;}
.audit-meta{opacity:.9;margin-bottom:8px;}
.audit-sep{height:1px;background:rgba(255,255,255,.15);margin:8px 0;}
.audit-title{font-weight:700;margin:6px 0 4px;}
.audit-list{margin:0;padding-left:16px;}
.audit-list li{margin:2px 0;}
.audit-empty{opacity:.75;}

.audit--create .audit-badge{background:#2e7d32;}
.audit--update .audit-badge{background:#ed6c02;}
.audit--delete .audit-badge{background:#c62828;}

.cards {
  display: none;
  gap: 20px;
}

.card {
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.14);
  border: 1px solid #e6e9f0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card__top {
  display: flex;
  justify-content: center;
  align-items: center;
}

.card__name {
  font-size: 18px;
  font-weight: 800;
  color: #1f2937;
}

.badge {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}

.badge--ENTREE { background: #e7f6ea; color: #1b5e20; border-color: #cfead6; }
.badge--SORTIE { background: #e8f0ff; color: #1a3d8f; border-color: #d7e3ff; }
.badge--PAUSE  { background: #fff3e0; color: #8a4b10; border-color: #ffe1b8; }

.card__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 8px;
}

.card__actions button {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #d7dbe5;
  background: #f6f7fb;
  font-weight: 600;
}

.card__actions button[data-action="delete"] {
  background: #e74c3c;
  border-color: #d64535;
  color: #fff;
}

.card__actions button[data-action="edit"] {
  background: #f2f4f8;
}

.audit-flag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: #ffe7cc;
  color: #c06b00;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

#recap-export table {
  display: none;
}

.recap-cards {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.recap-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.12);
  border: 1px solid #e6e9f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.recap-card--total {
  background: #f7f9ff;
}

.recap-card__top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.recap-card__day {
  font-weight: 800;
  font-size: 16px;
}

.recap-card__date {
  color: #6c7a93;
  font-size: 12px;
}

.recap-card__total {
  font-weight: 800;
  font-size: 16px;
  color: #1f2a44;
  max-width: 320px;
  width: 100%;
}

.recap-card__row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

@media (min-width: 900px) {
  .recap-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .recap-card--total {
    grid-column: 1 / -1;
  }
}

/* Remuneration */
.remu-toolbar {
  gap: 12px;
}

.remu-toolbar label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.remu-month {
  display: flex;
  align-items: center;
  gap: 8px;
}

.remu-month span {
  color: #6c7a93;
  font-size: 12px;
}

.remu-cards {
  display: grid;
  gap: 16px;
  margin-top: 12px;
}

.remu-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.12);
  border: 1px solid #e6e9f0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.remu-card__top {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

.remu-card__name {
  font-weight: 800;
  font-size: 16px;
}

.remu-card__amount {
  font-weight: 800;
  font-size: 16px;
  color: #1f2a44;
  max-width: 320px;
  width: 100%;
}

.remu-card__row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}

.remu-cards + .remu-table {
  display: none;
}

.remu-table {
  display: none;
}

@media (min-width: 900px) {
  .remu-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.add-pointage-card {
  margin-top: 12px;
}

.add-pointage-card__top {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.add-pointage-card__title {
  font-weight: 800;
  font-size: 16px;
}

.add-pointage-card__sub {
  font-size: 12px;
  color: #6c7a93;
}

.add-pointage-card__btn {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #d7dbe5;
  background: #f6f7fb;
  font-weight: 600;
  padding: 8px 16px;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 1000;
}

.modal.is-open {
  display: block;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal__panel {
  position: relative;
  margin: 8vh auto 0;
  width: min(720px, 92vw);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.25);
  padding: 16px 18px 18px;
}

.modal__head {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.modal__head h2 {
  margin: 0;
  font-size: 18px;
}

.modal__close {
  background: #f2f4f8;
  border: 1px solid #d7dbe5;
  border-radius: 999px;
  width: 36px;
  height: 36px;
  cursor: pointer;
}

.modal__form {
  display: grid;
  gap: 10px;
}

.modal__form label {
  display: grid;
  gap: 6px;
  font-size: 13px;
}

.modal__form input,
.modal__form select {
  padding: 8px 10px;
  border: 1px solid #d7dbe5;
  border-radius: 10px;
  background: #fff;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #fff;
  border: 1px solid #d7dbe5;
  border-radius: 10px;
  padding: 8px 36px 8px 12px;
  font-weight: 600;
  color: #1f2a44;
  max-width: 320px;
  width: 100%;
  background-image:
    linear-gradient(45deg, transparent 50%, #4c5a78 50%),
    linear-gradient(135deg, #4c5a78 50%, transparent 50%),
    linear-gradient(to right, #e9edf6, #e9edf6);
  background-position:
    calc(100% - 18px) calc(50% - 2px),
    calc(100% - 12px) calc(50% - 2px),
    calc(100% - 32px) 50%;
  background-size: 6px 6px, 6px 6px, 1px 18px;
  background-repeat: no-repeat;
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.08);
}

select:focus {
  outline: none;
  border-color: #8fb2ff;
  box-shadow: 0 0 0 3px rgba(76, 123, 217, 0.18);
}

select:disabled {
  opacity: 0.6;
  background-color: #f4f6fa;
  box-shadow: none;
}

option {
  color: #1f2a44;
  max-width: 320px;
  width: 100%;
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}

.modal__actions button {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #d7dbe5;
  background: #f6f7fb;
  font-weight: 600;
}

.admin-section-cards {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin: 10px auto 14px;
  max-width: 980px;
  width: 100%;
}

.admin-static-card {
  background: #f5f7fb;
  border: 1px solid #e3e7f0;
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.12);
  max-width: 980px;
  width: 100%;
  margin: 10px auto 14px;
  padding: 14px 16px;
}

.admin-static-card h3 {
  margin: 0 0 10px;
}

.admin-static-card__row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.admin-rules-list {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 8px;
}

.admin-card {
  background: #f5f7fb;
  border: 1px solid #e3e7f0;
  border-radius: 14px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.12);
  overflow: hidden;
  max-width: 980px;
  width: 100%;
  margin: 10px auto 14px;
}

.admin-section-card {
  font-size: 18px;
  width: 100%;
  background: linear-gradient(180deg, #ffffff 0%, #f4f6fb 100%);
  border: none;
  padding: 16px 18px;
  text-align: center;
  font-weight: 800;
  color: #1f2a44;
  width: 100%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: inset 0 0 0 1px rgba(227, 231, 240, 0.6);
  position: relative;
  padding-right: 54px;
}

.admin-section-card::after {
  content: "+";
  font-weight: 900;
  color: #1f2a44;
  background: #e9eefc;
  border: 1px solid #c9d8ff;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  right: 16px;
}

.admin-card.active .admin-section-card::after {
  content: "–";
}

.admin-card__content {
  font-size: 14px;
  font-weight: 700;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding: 0 !important;
  border-top: 1px solid #e7ebf4;
  transition: max-height 0.35s ease, opacity 0.2s ease;
}

.admin-card.active .admin-card__content {
  font-size: 14px;
  font-weight: 700;
  max-height: 2400px;
  opacity: 1;
  padding: 14px 16px 18px !important;
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-top: 14px;
}

.dashboard-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 10px 22px rgba(16, 24, 40, 0.12);
  border: 1px solid #e7ebf4;
}

.dashboard-card--full {
  grid-column: 1 / -1;
}

.dashboard-card--wide {
  grid-column: span 2;
}

@media (min-width: 1024px) {
  .dashboard-card--wide {
    max-height: 360px;
  }
}

.dashboard-card__head h3 {
  margin: 0 0 10px 0;
}

.presence-list {
  display: grid;
  gap: 8px;
}

.presence-row {
  display: grid;
  grid-template-columns: 18px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #f6f8fd;
  border-radius: 10px;
}

.presence-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.presence-dot--green { background: #2e7d32; }
.presence-dot--orange { background: #ed6c02; }
.presence-dot--red { background: #c62828; }

.presence-status {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  opacity: 0.8;
}

.chart-wrap {
  overflow: visible;
  padding-bottom: 6px;
}

.chart-block {
  display: grid;
  grid-template-columns: 56px 1fr;
  grid-template-rows: 220px auto;
  gap: 8px;
  align-items: stretch;
}

.chart-scale {
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  justify-items: end;
  align-items: start;
  padding-right: 6px;
  padding-left: 4px;
  font-size: 12px;
  color: #516079;
  height: 100%;
}

.chart-scale__tick {
  display: flex;
  align-items: flex-start;
  height: 100%;
  width: 100%;
  position: relative;
}

.chart-scale__tick span {
  transform: translateY(-4px);
  padding-right: 6px;
  background: #fff;
}

.chart-plot {
  position: relative;
  height: 220px;
  border-left: 1px solid #e0e6f2;
  padding: 0 12px;
  overflow: visible;
  border-radius: 12px;
}

.chart-bars {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  align-items: stretch;
  height: 100%;
  overflow: visible;
  z-index: 1;
  width: 100%;
}

.chart-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}

.chart-stack {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 0;
  height: 100%;
  width: 100%;
}

.chart-segment {
  position: relative;
  width: clamp(10px, 3vw, 22px);
  max-width: 100%;
  margin: 0 auto;
  border-radius: 0;
}

.chart-segment--first,
.chart-segment--last {
  border-radius: 0;
}

.chart-segment--zero {
  height: 0 !important;
  min-height: 0;
}

.chart-segment::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  background: rgba(20, 24, 38, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
  max-width: 200px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 10;
}

.chart-segment:hover::after {
  opacity: 1;
}

.chart-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: repeat(6, 1fr);
  z-index: 0;
  pointer-events: none;
}

.chart-grid__line {
  border-top: 1px solid #e7ebf4;
}


.chart-labels {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 8px;
  width: 100%;
  grid-column: 2 / 3;
}

.chart-label {
  text-align: center;
}

.chart-bar__label {
  font-size: 12px;
  text-align: center;
  opacity: 0.8;
}

.chart-bar__value {
  font-size: 12px;
  text-align: center;
  font-weight: 700;
}

.late-list {
  display: grid;
  gap: 10px;
}

.late-row {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #f6f8fd;
}

.late-date {
  font-weight: 700;
}

.late-time {
  font-weight: 600;
  color: #c62828;
}

.late-empty {
  opacity: 0.8;
  font-weight: 600;
}


@media (max-width: 520px) {
  .modal__actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1024px) {
  #pointagesTable { display: none; }
  #pointagesCards {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media (min-width: 768px) and (max-width: 1024px) {
  #pointagesCards {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 1025px) {
  #pointagesTable { display: table; }
  #pointagesCards { display: none; }
}

/* Historique - timeline mobile */
.history-timeline {
  display: none;
  margin-top: 12px;
}

.timeline-group {
  margin-bottom: 16px;
}

.timeline-title {
  font-weight: 800;
  font-size: 16px;
  color: #1f2a44;
  margin: 12px 0 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.timeline-title::after {
  content: "";
  height: 2px;
  flex: 1;
  background: currentColor;
  border-radius: 999px;
  opacity: 0.6;
}

.timeline-list {
  position: relative;
  display: grid;
  gap: 12px;
}

.timeline-item {
  display: grid;
  grid-template-columns: 52px 14px 1fr;
  gap: 8px;
  align-items: start;
}

.timeline-item .timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #1f2a44;
  margin-top: 6px;
}

.timeline-time {
  font-weight: 700;
  color: #1f2a44;
  font-size: 14px;
}

.timeline-content {
  background: #fff;
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid #e6e9f0;
  box-shadow: 0 8px 18px rgba(16, 24, 40, 0.08);
  display: grid;
  gap: 8px;
}

.timeline-head {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
}

.timeline-name {
  font-weight: 700;
  font-size: 14px;
}

.timeline-status {
  font-size: 12px;
  color: #6c7a93;
}

.timeline-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.timeline-badge--ENTREE { background: #e7f6ea; color: #1b5e20; }
.timeline-badge--SORTIE { background: #e8f0ff; color: #1a3d8f; }
.timeline-badge--PAUSE  { background: #fff3e0; color: #8a4b10; }

.timeline-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.timeline-actions button {
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid #d7dbe5;
  background: #f6f7fb;
  font-weight: 600;
}

.timeline-item.is-deleted {
  opacity: 0.6;
}

.timeline-edit {
  display: grid;
  gap: 8px;
}

.timeline-edit input {
  padding: 8px 10px;
  border: 1px solid #d7dbe5;
  border-radius: 10px;
}

@media (max-width: 1024px) {
  #pointagesCards { display: none; }
  .history-timeline { display: block; }
}

.badge-user.admin-pwd-btn {
  font-size: 8px;
  padding: 1px 4px;
}

/* ===== CONTENT ===== */
.content {
  padding: 26px;
  overflow-x: hidden;
  width: 100%;
}

.card {
  background: var(--panel);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid #e4e8f3;
  max-width: 100%;
  overflow-x: hidden;
  width: 100%;
}

/* ===== POINTAGE ===== */
#app h1 {
  margin-top: 0;
}

#app input {
  width: 300px;
  padding: 8px;
  margin: 10px 0 20px 0;
}

.home-screen {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}

.home-panel {
  width: 100%;
}

#home-code-display {
  width: 100%;
  padding: 10px;
  font-size: clamp(16px, 4vw, 20px);
  letter-spacing: 4px;
  margin: 10px 0 16px 0;
  box-sizing: border-box;
}

#home-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(56px, 1fr));
  gap: clamp(8px, 2.5vw, 12px);
  justify-items: center;
}

#home-feedback {
  margin-top: 12px;
  font-weight: 600;
  font-size: clamp(12px, 3.2vw, 14px);
}

#collaborateurs {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
}

/* Admin form layout */
.admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px 16px;
  width: 100%;
}

.admin-grid label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.rule-label-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.rule-help {
  width: 22px;
  height: 22px;
  border: 1px solid #9fb0d4;
  border-radius: 999px;
  background: #eef3ff;
  color: #1f2a44;
  font-weight: 800;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.rule-help:focus-visible {
  outline: 2px solid #2f5ed9;
  outline-offset: 1px;
}

.rule-tooltip {
  position: absolute;
  z-index: 1000;
  max-width: min(340px, calc(100vw - 16px));
  background: #12203e;
  color: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.35;
  box-shadow: 0 12px 24px rgba(10, 18, 38, 0.35);
}

.rule-tooltip div + div {
  margin-top: 4px;
}

.admin-grid input,
.admin-grid select,
.admin-grid textarea {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
  max-width: 100%;
}

#collab-select {
  min-width: 0 !important;
  width: 100%;
  max-width: 100%;
}

.absence-calendar {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 12px;
  background: linear-gradient(180deg, #fafafa 0%, #f5f5f5 100%);
  min-height: 240px;
}

.absence-table {
  display: grid;
  grid-template-columns: 70px repeat(7, minmax(42px, 1fr));
  gap: 6px;
}

.absence-row {
  display: contents;
}

.absence-weeknum {
  border: 1px solid #ddd;
  background: #f0f2f5;
  border-radius: 6px;
  padding: 10px 6px;
  text-align: center;
  font-weight: 600;
}

.absence-day {
  border: 1px solid #ddd;
  background: #fff;
  border-radius: 6px;
  padding: 6px 4px;
  text-align: center;
  cursor: pointer;
  min-width: 42px;
  min-height: 48px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.absence-day.head {
  font-weight: 600;
  background: #f0f2f5;
  cursor: default;
}

.absence-day.empty {
  border: none;
  background: transparent;
  cursor: default;
}

.absence-day.selected {
  background: #ffecec;
  border-color: #ff8c8c;
  box-shadow: inset 0 0 0 1px #ff8c8c;
}

.absence-day.selected.type-CP {
  background: #e7f0ff;
  border-color: #8cb4ff;
  box-shadow: inset 0 0 0 1px #8cb4ff;
}

.absence-day.selected.type-RTT {
  background: #fff3e0;
  border-color: #ffb74d;
  box-shadow: inset 0 0 0 1px #ffb74d;
}

.absence-day .day-number {
  font-weight: 600;
}

.absence-day .day-check {
  font-size: 12px;
  color: #c00;
  line-height: 1;
  font-weight: 800;
}

.cal-nav {
  border: 1px solid #ccc;
  background: #f7f7f7;
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

#collaborateurs button {
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #ccc;
  background: white;
  cursor: pointer;
  font-size: 16px;
}

#collaborateurs button:hover {
  background: #f0f3ff;
}

#zone-pointage {
  margin-top: 20px;
}

#zone-pointage button {
  padding: clamp(10px, 2.2vw, 14px) clamp(18px, 3.4vw, 28px);
  border-radius: 12px;
  border: none;
  margin-right: 10px;
  font-weight: 800;
  cursor: pointer;
  font-size: clamp(13px, 2.4vw, 16px);
  min-height: 44px;
  min-width: 140px;
  box-shadow: 0 8px 16px rgba(18, 30, 60, 0.18);
}

#keypad,
#home-keypad {
  max-width: 320px;
}

#keypad .key,
#home-keypad .key {
  width: clamp(52px, 16vw, 72px);
  height: clamp(52px, 16vw, 72px);
  border-radius: 50%;
  border: 1px solid #d5dceb;
  background: #f7f9ff;
  font-weight: 800;
  font-size: clamp(14px, 4vw, 18px);
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(16, 24, 40, 0.15);
  justify-self: center;
}

#keypad .key:hover,
#home-keypad .key:hover {
  background: #eef1f7;
}

#keypad .key:active,
#home-keypad .key:active {
  transform: translateY(1px);
  box-shadow: inset 0 0 0 rgba(0,0,0,0);
}

#keypad .key[data-key="ok"],
#home-keypad .key[data-key="ok"] {
  background: #3e8e6c;
  border-color: #2f7a5a;
  color: #fff;
}

#keypad .key[data-key="clear"],
#home-keypad .key[data-key="clear"] {
  background: #f2a93b;
  border-color: #e0962b;
  color: #fff;
}

#btn-entree { background: #3e8e6c; color: white; }
#btn-pause { background: #f2a93b; color: white; }
#btn-finpause { background: #3f6ecb; color: white; }
#btn-sortie { background: #d94b4b; color: white; }

.pointage-screen {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 180px);
  min-height: 0;
  align-items: center;
  text-align: center;
}

.pointage-auth {
  max-width: 360px;
  width: 100%;
}

.pointage-auth p {
  margin: 0 0 8px 0;
}

#code-display {
  width: 100%;
  padding: 8px 10px;
  font-size: clamp(14px, 3vw, 16px);
  letter-spacing: 4px;
  margin: 6px 0 8px 0;
  box-sizing: border-box;
}

#keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(48px, 1fr));
  gap: clamp(6px, 2vw, 10px);
  margin-top: 6px;
  justify-items: center;
}

#selected-collab {
  margin: 8px 0 0 0;
  font-weight: 600;
}

.pointage-actions h2 {
  margin: 4px 0;
}

.pointage-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.pointage-status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 12px;
  background: #eef1f7;
  font-weight: 600;
  font-size: clamp(14px, 2.6vw, 18px);
  margin-left: 4px;
}

.pointage-status span {
  opacity: 0.7;
  font-size: clamp(12px, 2.2vw, 14px);
}

.pointage-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: center;
}

@media (max-height: 720px) {
  .pointage-screen { gap: 8px; max-height: calc(100vh - 150px); }
  .pointage-auth { max-width: 320px; }
  #keypad .key { width: clamp(44px, 14vw, 64px); height: clamp(44px, 14vw, 64px); }
  .pointage-buttons { gap: 6px; }
  #zone-pointage { margin-top: 8px; }
}

button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* STATUT */
#statut {
  padding: 4px 10px;
  border-radius: 8px;
  background: #e0e0e0;
}


@media (max-width: 1024px) {
  .content { padding: 20px; }
  .card { padding: 20px; }
  .admin-grid {
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
  #app input { width: 100%; }
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "left"
      "right";
    row-gap: 8px;
  }
  .topbar h1 { font-size: 22px; justify-self: center; grid-area: title; }
  .topbar-left { justify-self: center; grid-area: left; }
  .topbar-right { justify-self: center; gap: 12px; grid-area: right; }
  .content { padding: 16px; }
  .card { padding: 16px; }
  .admin-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  body { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex-direction: row;
    align-items: stretch;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    min-height: 86px;
    border-top: 2px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 -10px 24px rgba(12, 18, 38, 0.3);
  }
  .sidebar-logo { padding: 16px 12px; }
  .sidebar nav {
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-item {
    padding: 12px 12px;
    font-size: 11px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 72px;
    white-space: normal;
    line-height: 1.1;
  }
  .nav-item .material-icons {
    margin: 0;
    font-size: 20px;
  }
  .topbar { row-gap: 8px; }
  body { padding-bottom: 92px; }
  .content { padding: 16px; }
  .card { padding: 16px; }
  #collaborateurs { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .absence-calendar { overflow-x: auto; }
  .absence-table { min-width: 520px; }
}

@media (max-width: 768px) {
  .admin-schedule table {
    width: 100%;
    table-layout: fixed;
  }
  .admin-schedule thead {
    display: none;
  }
  .admin-schedule tbody tr {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
      "day day"
      "start"
      "end";
    gap: 8px;
    margin-bottom: 10px;
    padding: 8px;
    border: 1px solid #e6e9f0;
    border-radius: 10px;
    background: #fff;
  }
  .admin-schedule tbody td {
    border: none !important;
    padding: 0 !important;
  }
  .admin-schedule tbody td:nth-child(1) { grid-area: day; font-weight: 800; }
  .admin-schedule tbody td:nth-child(2) { grid-area: start; }
  .admin-schedule tbody td:nth-child(3) { grid-area: end; }
  .admin-schedule input[type="time"] {
    width: 100% !important;
  }
}

@media (max-width: 480px) {
  .topbar h1 { font-size: 16px; }
  .badge-user { font-size: 10px; padding: 4px 8px; }
  .nav-item { font-size: 10px; }
  .admin-grid label { font-size: 12px; }
  .admin-grid input,
  .admin-grid select,
  .admin-grid textarea {
    padding: 6px 8px;
    font-size: 12px;
  }
}

@media (max-width: 640px) {
  .admin-grid label { font-size: 13px; }
  .admin-grid input,
  .admin-grid select,
  .admin-grid textarea {
    padding: 6px 8px;
    font-size: 13px;
  }
}



