:root {
  --navy: #102a43;
  --navy-2: #163b5c;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --border: #dbe5f0;
  --border-strong: #c7d6e6;
  --text: #1f2937;
  --muted: #64748b;
  --green: #16a34a;
  --green-soft: #eaf8ef;
  --orange: #f59e0b;
  --orange-soft: #fff7e6;
  --red: #dc2626;
  --red-soft: #fff0f0;
  --slate: #475569;
  --shadow: 0 16px 42px rgba(15, 42, 67, 0.10);
  --shadow-soft: 0 8px 28px rgba(15,42,67,.06);
}

* { box-sizing: border-box; }
html { min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.auth-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at 85% 10%, rgba(37,99,235,.13), transparent 31%),
    radial-gradient(circle at 15% 85%, rgba(16,42,67,.08), transparent 28%),
    linear-gradient(135deg, #eef4fb 0%, #f9fbfe 55%, #edf3f9 100%);
}
.auth-card {
  width: min(480px, 100%);
  background: rgba(255,255,255,.97);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow);
}
.brand-line { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  flex: 0 0 auto;
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  border-radius: 17px;
  background: linear-gradient(145deg, var(--navy), var(--navy-2));
  color: #fff;
  font-weight: 850;
  letter-spacing: .05em;
  box-shadow: 0 10px 24px rgba(16,42,67,.20);
}
.brand-mark-small { width: 48px; height: 48px; border-radius: 14px; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 6px; color: var(--navy); letter-spacing: -.02em; }
h2 { margin-bottom: 0; color: var(--navy); letter-spacing: -.015em; }
h3 { margin-bottom: 8px; color: var(--navy); }
.eyebrow {
  margin-bottom: 4px;
  color: var(--blue);
  font-size: .74rem;
  font-weight: 850;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.muted { color: var(--muted); }
.auth-intro { color: var(--muted); margin: 20px 0 0; line-height: 1.55; }
.auth-form { display: grid; gap: 17px; margin-top: 26px; }
.auth-form label { display: grid; gap: 7px; font-weight: 680; font-size: .93rem; }
input, select {
  width: 100%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 13px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:focus, select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(37,99,235,.10);
}
.btn {
  border: 0;
  border-radius: 11px;
  min-height: 40px;
  padding: 9px 14px;
  font-weight: 760;
  transition: transform .15s ease, filter .15s ease, background .15s ease, opacity .15s ease;
}
.btn:hover { filter: brightness(.98); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: wait; opacity: .58; }
.btn-wide { width: 100%; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-secondary { background: #eaf1ff; color: var(--blue-dark); }
.btn-ghost { background: #eef2f7; color: var(--slate); }
.btn-success { background: var(--green); color: #fff; }
.btn-danger { background: var(--red-soft); color: var(--red); border: 1px solid #fecaca; }
.btn-warning { background: var(--orange-soft); color: #9a6500; border: 1px solid #fde2aa; }
.btn-sm { min-height: 34px; padding: 7px 10px; font-size: .84rem; }
.message { min-height: 20px; margin-bottom: 0; color: var(--red); font-size: .89rem; }
.message.success { color: var(--green); }
.text-button {
  justify-self: center;
  border: 0;
  background: transparent;
  color: var(--blue);
  padding: 2px 6px;
  font-weight: 760;
}
.text-button:hover { text-decoration: underline; }
.security-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: .83rem;
}
.security-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-weight: 900;
}

.admin-view { padding: 26px; max-width: 1640px; margin: 0 auto; }
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 22px 24px;
  margin-bottom: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
}
.topbar-brand { display: flex; align-items: center; gap: 14px; }
.topbar-brand p { margin-bottom: 0; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }
.admin-identity {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 300px;
  color: var(--slate);
  font-size: .9rem;
  margin-right: 6px;
  overflow: hidden;
}
.admin-identity span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-dot { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(22,163,74,.10); }

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.summary-card {
  position: relative;
  overflow: hidden;
  padding: 19px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: 0 7px 24px rgba(15,42,67,.05);
}
.summary-card::after {
  content: "";
  position: absolute;
  right: -18px;
  top: -18px;
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: rgba(100,116,139,.07);
}
.summary-card-attente::after { background: rgba(245,158,11,.12); }
.summary-card-ok::after { background: rgba(22,163,74,.10); }
.summary-label { color: var(--muted); font-size: .86rem; font-weight: 650; }
.summary-value { margin-top: 8px; color: var(--navy); font-size: 1.85rem; line-height: 1; font-weight: 850; }
.summary-hint { margin-top: 8px; color: #94a3b8; font-size: .76rem; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-soft);
}
.pending-panel { border-top: 3px solid #f2b84b; }
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.users-heading { align-items: flex-end; }
.refresh-info { margin: 7px 0 0; color: #94a3b8; font-size: .79rem; }
.toolbar { display: grid; justify-items: end; gap: 10px; max-width: 100%; }
.search-input { width: min(420px, 100%); }
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.filter-tab {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--slate);
  border-radius: 999px;
  min-height: 34px;
  padding: 6px 11px;
  font-size: .8rem;
  font-weight: 750;
}
.filter-tab:hover { background: #f8fafc; }
.filter-tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  min-width: 30px;
  font-weight: 820;
  font-size: .76rem;
  white-space: nowrap;
}
.badge-warning { background: var(--orange-soft); color: #9a6500; }
.badge-success { background: var(--green-soft); color: #157a39; }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-neutral { background: #eef2f7; color: var(--slate); }

.cards-list { display: grid; gap: 12px; }
.request-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px;
  border: 1px solid #fde2aa;
  background: linear-gradient(135deg, #fffdf7, #fffaf0);
  border-radius: 15px;
}
.request-meta { display: grid; gap: 6px; }
.request-meta strong { color: var(--navy); font-size: .96rem; }
.request-meta-grid { display: flex; gap: 14px; flex-wrap: wrap; }
.request-meta span { color: var(--muted); font-size: .84rem; }
.request-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.empty-state { padding: 24px; text-align: center; color: var(--muted); background: #f8fafc; border-radius: 14px; }

.table-wrap { width: 100%; overflow-x: auto; border: 1px solid #edf2f7; border-radius: 14px; }
table { width: 100%; min-width: 1320px; border-collapse: collapse; background: #fff; }
th, td { padding: 12px 11px; border-bottom: 1px solid #e8eef5; text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: .74rem; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; position: sticky; top: 0; z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfdff; }
td { font-size: .88rem; }
.user-name { font-weight: 800; color: var(--navy); }
.actions-cell { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.role-select { width: auto; min-width: 122px; padding: 7px 9px; }
.results-info { padding: 12px 2px 0; color: var(--muted); font-size: .8rem; text-align: right; }

.admin-footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 18px;
  color: #94a3b8;
  font-size: .78rem;
}
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 430px;
  margin: 0;
  padding: 12px 15px;
  border-radius: 12px;
  color: #fff;
  background: var(--navy);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity .2s ease, transform .2s ease;
  z-index: 50;
}
.toast.visible { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15,23,42,.48);
  backdrop-filter: blur(3px);
  z-index: 100;
}
.modal-card {
  width: min(430px, 100%);
  background: #fff;
  border-radius: 20px;
  padding: 26px;
  box-shadow: 0 26px 70px rgba(15,23,42,.24);
  text-align: center;
}
.modal-icon {
  width: 50px;
  height: 50px;
  display: grid;
  place-items: center;
  margin: 0 auto 15px;
  border-radius: 50%;
  background: var(--orange-soft);
  color: #a16b00;
  font-weight: 900;
  font-size: 1.3rem;
}
.modal-actions { display: flex; justify-content: center; gap: 9px; margin-top: 22px; }

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { justify-content: flex-start; }
  .users-heading { align-items: flex-start; flex-direction: column; }
  .toolbar { width: 100%; justify-items: stretch; }
  .filter-tabs { justify-content: flex-start; }
  .search-input { width: 100%; }
}

@media (max-width: 760px) {
  .admin-view { padding: 14px; }
  .topbar, .panel { border-radius: 16px; padding: 17px; }
  .topbar-brand { align-items: flex-start; }
  .topbar-actions { width: 100%; }
  .admin-identity { width: 100%; max-width: none; margin-bottom: 4px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .summary-card { padding: 15px; }
  .request-card { flex-direction: column; align-items: stretch; }
  .request-actions .btn { flex: 1; }
  .filter-tabs { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 3px; }
  .filter-tab { flex: 0 0 auto; }

  .table-wrap { border: 0; overflow: visible; }
  table, thead, tbody, tr, th, td { display: block; }
  table { min-width: 0; }
  thead { display: none; }
  tbody { display: grid; gap: 12px; }
  tbody tr {
    display: grid;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 15px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 5px 18px rgba(15,42,67,.04);
  }
  tbody tr:hover { background: #fff; }
  td {
    display: grid;
    grid-template-columns: minmax(105px, 38%) 1fr;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid #edf2f7;
    align-items: center;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: .72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .035em;
  }
  td:last-child { border-bottom: 0; }
  .actions-cell { justify-content: flex-start; }
  .results-info { text-align: center; }
  .toast { left: 14px; right: 14px; bottom: 14px; max-width: none; }
}

@media (max-width: 520px) {
  .auth-view { padding: 14px; }
  .auth-card { padding: 23px 20px; border-radius: 19px; }
  .brand-mark { width: 50px; height: 50px; border-radius: 15px; }
  .summary-grid { grid-template-columns: 1fr; }
  .topbar-actions .btn { flex: 1; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}
