/* ============================================================
   MediGuard — Design System CSS
   Fidèle au Figma : #00478d, Manrope + Inter
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@700;800&family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600&family=DM+Sans:wght@300;400;500;600;700&display=swap');

:root {
  --blue: #00478d;
  --blue-dark: #003d7a;
  --blue-light: #005eb8;
  --blue-bg: #d6e3ff;
  --green: #10b981;
  --green-text: #047857;
  --green-bg: #ecfdf5;
  --red: #ba1a1a;
  --red-bg: #ffdad6;
  --red-dark: #93000a;
  --orange: #f59e0b;
  --gray-50: #f8f9fa;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #424752;
  --gray-800: #191c1d;
  --sidebar-w: 233px;
  --header-h: 64px;
  --radius: 8px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0, 71, 141, .08);
  --shadow-md: 0 4px 16px rgba(0, 71, 141, .12);
  /* Extended palette – new pages */
  --blue-primary: #1a56db;
  --blue-primary-dark: #1e40af;
  --blue-card: #1d4ed8;
  --card-border: #e5e7eb;
  --page-bg: #f4f6f9;
  --card-radius: 12px;
  --badge-red-bg: #fee2e2;
  --badge-red: #dc2626;
  --badge-green-bg: #d1fae5;
  --badge-green: #059669;
  --badge-orange-bg: #fef3c7;
  --badge-orange: #d97706;
  --badge-gray-bg: #f3f4f6;
  --badge-gray: #374151;
  --alert-red-bg: #fff1f2;
  --alert-orange-bg: #fffbeb;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

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

img {
  max-width: 100%;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  width: var(--sidebar-w);
  background: #f8fafc;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 200;
  transition: transform .3s;
}

.sidebar-brand {
  padding: 32px 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 72px;
  height: 72px;
  border-radius: 10px;
  object-fit: contain;
}

.brand-name {
  font-family: 'Manrope', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
  letter-spacing: -.5px;
}

.sidebar-nav {
  flex: 1;
  padding: 4px 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius);
  color: var(--gray-500);
  font-size: 14px;
  font-weight: 400;
  transition: all .15s;
  position: relative;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.nav-link:hover {
  background: #fff;
  color: var(--gray-800);
}

.nav-link.active {
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  box-shadow: var(--shadow);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  right: -1px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  background: var(--blue);
  border-radius: 3px 0 0 3px;
}

.nav-badge {
  margin-left: auto;
  background: var(--red-bg);
  color: var(--red);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
}

.sidebar-user {
  padding: 16px 20px 20px;
  border-top: 1px solid var(--gray-200);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #f3f4f5;
  padding: 10px 14px;
  border-radius: var(--radius);
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: var(--blue-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  color: var(--blue);
  flex-shrink: 0;
  overflow: hidden;
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-800);
  line-height: 1.3;
}

.user-role {
  font-size: 10px;
  color: var(--gray-700);
}

/* ---- Main ---- */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---- Topbar ---- */
.topbar {
  height: var(--header-h);
  background: rgba(248, 250, 252, .85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  width: 256px;
  height: 34px;
  background: var(--gray-100);
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 14px 0 38px;
  font-size: 13.5px;
  color: var(--gray-700);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.search-wrap input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 71, 141, .08);
  background: #fff;
}

.search-wrap .ico-search {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--gray-600);
  transition: background .15s;
}

.icon-btn:hover {
  background: var(--gray-100);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.topbar-sep {
  width: 1px;
  height: 24px;
  background: var(--gray-200);
  margin: 0 6px;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--gray-200);
  overflow: hidden;
  margin-left: 4px;
}

.topbar-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---- Page content ---- */
.page {
  padding: 32px;
  flex: 1;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
}

.page-title {
  font-family: 'Manrope', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1.2;
}

.page-sub {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-700);
  margin-top: 5px;
}

.page-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-light) 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0, 71, 141, .2);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(0, 71, 141, .3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #e7e8e9;
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-200);
}

.btn-danger {
  background: var(--red-bg);
  color: var(--red);
}

.btn-danger:hover {
  background: #ffc9c4;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-body {
  padding: 24px;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--gray-800);
}

/* ============================================================
   BADGES / STATUTS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.badge-on {
  background: var(--green-bg);
  color: var(--green-text);
}

.badge-on::before {
  background: var(--green);
}

.badge-off {
  background: #f1f5f9;
  color: var(--gray-500);
}

.badge-off::before {
  background: var(--gray-400);
}

.badge-alert {
  background: var(--red-bg);
  color: var(--red);
}

.badge-alert::before {
  background: var(--red);
}

.badge-ok {
  background: #f0fdf4;
  color: #15803d;
}

.badge-ok::before {
  background: #22c55e;
}

.badge-refused {
  background: var(--red-bg);
  color: var(--red-dark);
}

.badge-refused::before {
  background: var(--red-dark);
}

.badge-auto {
  background: #eff6ff;
  color: #1d4ed8;
}

.badge-auto::before {
  background: #3b82f6;
}

.badge-done {
  background: #f8fafc;
  color: var(--gray-500);
}

.badge-done::before {
  background: var(--gray-300);
}

/* ============================================================
   TABLE
   ============================================================ */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: #f3f4f5;
  padding: 11px 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  text-align: left;
  white-space: nowrap;
}

thead th:first-child {
  border-radius: 8px 0 0 0;
}

thead th:last-child {
  border-radius: 0 8px 0 0;
}

tbody tr {
  border-bottom: 1px solid #f8fafc;
  transition: background .1s;
}

tbody tr:hover {
  background: #fafbfc;
}

tbody td {
  padding: 13px 20px;
  font-size: 13.5px;
  color: var(--gray-600);
  vertical-align: middle;
}

.td-strong {
  font-weight: 600;
  color: var(--gray-800);
}

/* ============================================================
   UNIT CARDS (Flotte)
   ============================================================ */
.units-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.unit-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 22px 18px;
  position: relative;
  overflow: hidden;
  transition: box-shadow .2s, transform .2s;
}

.unit-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.unit-card .accent {
  position: absolute;
  left: 0;
  top: 20px;
  width: 4px;
  border-radius: 0 3px 3px 0;
}

.accent-blue {
  background: var(--blue);
  height: 130px;
}

.accent-gray {
  background: var(--gray-300);
  height: 120px;
}

.unit-id {
  display: inline-block;
  background: var(--blue-bg);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  padding: 2px 8px;
  border-radius: 3px;
  margin-bottom: 6px;
}

.unit-id.offline {
  background: var(--gray-100);
  color: var(--gray-500);
}

.unit-name {
  font-family: 'Manrope', sans-serif;
  font-size: 19px;
  font-weight: 700;
  color: var(--gray-800);
}

.unit-loc {
  font-size: 13px;
  color: var(--gray-700);
  margin-top: 2px;
}

.unit-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding-left: 12px;
}

.unit-statuses {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: flex-end;
}

.unit-links {
  padding-left: 12px;
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.unit-link {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--blue);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.unit-link.green {
  color: #008d26;
}

.unit-link:hover {
  opacity: .75;
}

.unit-offline-msg {
  font-size: 11.5px;
  color: var(--red);
  font-style: italic;
  margin-top: 4px;
  display: block;
  padding-left: 12px;
}

.card-add {
  background: rgba(241, 245, 249, .6);
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-decoration: none;
  color: var(--gray-500);
  text-align: center;
  padding: 24px;
  gap: 8px;
}

.card-add:hover {
  border-color: var(--blue);
  background: rgba(0, 71, 141, .04);
  color: var(--blue);
}

.card-add .plus-circle {
  width: 46px;
  height: 46px;
  background: #fff;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 4px;
}

.card-add strong {
  font-size: 14px;
  font-weight: 600;
}

.card-add small {
  font-size: 12px;
  color: var(--gray-400);
  line-height: 1.5;
}

/* Rapport sécurité */
.rapport-card {
  background: linear-gradient(143deg, var(--blue) 0%, var(--blue-light) 100%);
  border-radius: var(--radius-lg);
  padding: 28px 30px;
  color: #fff;
}

.rapport-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  opacity: .8;
  margin-bottom: 10px;
}

.rapport-title {
  font-family: 'Manrope', sans-serif;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  margin-bottom: 16px;
}

.rapport-num {
  font-family: 'Manrope', sans-serif;
  font-size: 38px;
  font-weight: 800;
}

.rapport-num-label {
  font-size: 13px;
  opacity: .8;
  display: block;
  margin-top: 2px;
}

/* ============================================================
   STATS BAR (Logs)
   ============================================================ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  border-top: 3px solid transparent;
}

.stat-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  margin-bottom: 6px;
}

.stat-value {
  font-family: 'Manrope', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--gray-800);
}

/* ============================================================
   FILTERS BAR
   ============================================================ */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-bar input[type="text"] {
  height: 36px;
  border: 1px solid var(--gray-200);
  border-radius: 7px;
  padding: 0 12px;
  font-size: 13px;
  background: #fff;
  color: var(--gray-800);
  outline: none;
  transition: border-color .2s;
}

.filter-bar select:focus,
.filter-bar input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 71, 141, .07);
}

.filter-bar input[type="text"] {
  flex: 1;
  min-width: 200px;
}

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.pag-btn {
  width: 36px;
  height: 36px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  background: var(--gray-100);
  color: var(--gray-700);
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.pag-btn:hover {
  background: var(--gray-200);
}

.pag-btn.active {
  background: var(--blue);
  color: #fff;
}

.pag-dots {
  padding: 0 4px;
  color: var(--gray-400);
  font-size: 14px;
}

/* ============================================================
   FORM
   ============================================================ */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 18px;
}

.form-label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--gray-700);
}

.form-control {
  height: 44px;
  border: 1.5px solid var(--gray-200);
  border-radius: 9px;
  padding: 0 14px;
  font-size: 14px;
  color: var(--gray-800);
  outline: none;
  transition: border-color .2s, box-shadow .2s;
  background: #fff;
  width: 100%;
}

.form-control:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 71, 141, .1);
}

.form-control.error {
  border-color: var(--red);
}

textarea.form-control {
  height: auto;
  padding: 12px 14px;
  resize: vertical;
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
  padding-right: 36px;
}

/* ============================================================
   AUTH PAGES
   ============================================================ */
.auth-body {
  background: #f8f9fa;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'Poppins', sans-serif;
}

.auth-topbar {
  height: 73px;
  background: #fff;
  border-bottom: 1px solid rgba(102, 102, 102, .2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
}

.auth-brand {
  font-family: 'Manrope', sans-serif;
  font-size: 20px;
  font-weight: 700;
  color: var(--blue);
}

.auth-topbar-actions {
  display: flex;
  gap: 12px;
}

.auth-btn-filled {
  height: 40px;
  padding: 0 22px;
  border-radius: 8px;
  background: #111;
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  border: 1px solid #111;
  transition: opacity .2s;
}

.auth-btn-filled:hover {
  opacity: .8;
}

.auth-btn-outline {
  height: 40px;
  padding: 0 22px;
  border-radius: 8px;
  background: transparent;
  color: #111;
  font-size: 14px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  border: 1px solid #111;
  transition: background .2s;
}

.auth-btn-outline:hover {
  background: #f5f5f5;
}

.auth-page {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 16px;
}

.auth-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 4px 28px rgba(0, 71, 141, .09);
  padding: 52px 46px;
  width: 100%;
  max-width: 548px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.auth-logo {
  width: 90px;
  height: 90px;
  border-radius: 18px;
  object-fit: contain;
}

.auth-title {
  font-size: 26px;
  font-weight: 600;
  color: #333;
  text-align: center;
  line-height: 1.3;
}

.auth-sub {
  font-size: 15px;
  color: #555;
  text-align: center;
  margin-top: -12px;
}

.auth-sub a {
  color: var(--blue);
  text-decoration: underline;
}

.auth-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.auth-field label {
  font-size: 14.5px;
  color: #666;
  display: block;
  margin-bottom: 6px;
}

.auth-field input {
  width: 100%;
  height: 54px;
  border: 1.5px solid rgba(102, 102, 102, .3);
  border-radius: 12px;
  padding: 0 16px;
  font-size: 15px;
  color: #111;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.auth-field input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(0, 71, 141, .1);
}

.auth-forgot {
  text-align: right;
  font-size: 13.5px;
  color: #111;
  text-decoration: underline;
  cursor: pointer;
  margin-top: -8px;
}

.auth-forgot:hover {
  color: var(--blue);
}

.auth-submit {
  height: 60px;
  border-radius: 30px;
  background: var(--blue);
  color: #fff;
  font-size: 18px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  width: 100%;
  transition: background .2s, box-shadow .2s;
  font-family: 'Poppins', sans-serif;
}

.auth-submit:hover {
  background: var(--blue-light);
  box-shadow: 0 6px 20px rgba(0, 71, 141, .25);
}

.auth-divider {
  width: 100%;
  height: 1.5px;
  background: rgba(102, 102, 102, .15);
  border-radius: 2px;
}

.auth-signup {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.auth-signup p {
  font-size: 16px;
  font-weight: 500;
  color: #333;
}

.auth-signup-btn {
  height: 60px;
  border-radius: 30px;
  border: 1.5px solid #111;
  background: transparent;
  color: #111;
  font-size: 18px;
  font-weight: 500;
  cursor: pointer;
  width: 100%;
  transition: background .2s;
  font-family: 'Poppins', sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.auth-signup-btn:hover {
  background: #f5f5f5;
}

/* ============================================================
   ALERT MESSAGES
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.alert-error {
  background: var(--red-bg);
  color: var(--red);
}

.alert-success {
  background: var(--green-bg);
  color: var(--green-text);
}

.alert-info {
  background: #eff6ff;
  color: #1d4ed8;
}

.alert-warn {
  background: #fffbeb;
  color: #92400e;
}

/* ============================================================
   MISC
   ============================================================ */
.section-title {
  font-family: 'Manrope', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: #0c4a6e;
  margin-bottom: 14px;
}

.back-link {
  font-size: 13px;
  color: var(--gray-500);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 10px;
  transition: color .15s;
}

.back-link:hover {
  color: var(--blue);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.three-col {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
}

.divider {
  width: 100%;
  height: 1px;
  background: var(--gray-100);
  margin: 8px 0;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .units-grid {
    grid-template-columns: 1fr 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .main {
    margin-left: 0;
  }

  .units-grid,
  .two-col,
  .three-col {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .page {
    padding: 20px;
  }
}

/* ============================================================
   INVENTAIRE PAGE
   ============================================================ */
.inv-page {
  padding: 28px 32px;
  flex: 1;
}

.inv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.inv-title {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #111827;
}

.inv-alert-badge {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius);
  padding: 8px 22px;
  text-align: center;
}

.inv-alert-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--blue-primary);
}

.inv-alert-count {
  font-size: 30px;
  font-weight: 800;
  color: var(--blue-primary);
  line-height: 1.1;
}

.filter-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-left: 3px solid var(--blue-primary);
  border-radius: var(--card-radius);
  padding: 18px 20px;
  margin-bottom: 20px;
}

.filter-card-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--blue-primary);
  margin-bottom: 14px;
}

.filter-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
  margin-bottom: 14px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group-label {
  font-size: 11px;
  color: #6b7280;
  font-weight: 500;
}

.filter-select {
  border: 1px solid var(--card-border);
  border-radius: 7px;
  padding: 7px 28px 7px 10px;
  font-size: 13px;
  font-family: inherit;
  color: #111827;
  background: var(--page-bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E") no-repeat right 8px center;
  appearance: none;
  cursor: pointer;
  outline: none;
  min-width: 160px;
}

.filter-select:focus {
  border-color: var(--blue-primary);
}

.filter-refresh {
  width: 34px;
  height: 34px;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  background: var(--page-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  margin-left: auto;
  flex-shrink: 0;
  transition: background 0.15s;
}

.filter-refresh:hover {
  background: #e5e7eb;
}

.filter-refresh svg {
  width: 14px;
  height: 14px;
}

.filter-search-wrap {
  position: relative;
}

.filter-search-wrap svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 14px;
  height: 14px;
  color: #9ca3af;
}

.filter-search {
  width: 100%;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  padding: 9px 12px 9px 32px;
  font-size: 13px;
  font-family: inherit;
  background: var(--page-bg);
  color: #111827;
  outline: none;
  transition: border-color 0.15s;
}

.filter-search:focus {
  border-color: var(--blue-primary);
}

.filter-search::placeholder {
  color: #9ca3af;
}

.med-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.med-item {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: box-shadow 0.15s;
}

.med-item:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
}

.med-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.med-icon-wrap svg {
  width: 20px;
  height: 20px;
}

.med-icon-red {
  background: #fee2e2;
  color: #dc2626;
}

.med-icon-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.med-icon-orange {
  background: #fef3c7;
  color: #d97706;
}

.med-icon-gray {
  background: #f3f4f6;
  color: #6b7280;
}

.med-info {
  flex: 1;
  min-width: 0;
}

.med-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 2px;
  color: #111827;
}

.med-sub {
  font-size: 12px;
  color: #6b7280;
  margin-bottom: 10px;
}

.btn-order {
  background: var(--blue-primary);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 6px 18px;
  font-size: 11.5px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-order:hover {
  background: var(--blue-primary-dark);
}

.btn-restock {
  background: transparent;
  color: #6b7280;
  border: 1px solid var(--card-border);
  border-radius: 7px;
  padding: 6px 18px;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-restock:hover {
  background: var(--page-bg);
  color: #111827;
}

.badge-optimal {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--green);
}

.badge-optimal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
}

.med-qty-wrap {
  text-align: right;
  flex-shrink: 0;
  min-width: 90px;
}

.med-qty {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -1px;
  line-height: 1;
}

.qty-red {
  color: #ef4444;
}

.qty-orange {
  color: var(--orange);
}

.qty-normal {
  color: #111827;
}

.med-qty-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  margin-top: 3px;
}

.fab {
  position: fixed;
  bottom: 32px;
  right: 32px;
  width: 48px;
  height: 48px;
  background: var(--blue-primary);
  border-radius: 50%;
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(29, 86, 219, .35);
  transition: background 0.15s, transform 0.15s;
  z-index: 20;
}

.fab:hover {
  background: var(--blue-primary-dark);
  transform: scale(1.07);
}

.fab svg {
  width: 22px;
  height: 22px;
}

/* ============================================================
   DETAIL UNITE PAGE
   ============================================================ */
.detail-content {
  padding: 24px 28px;
  display: grid;
  gap: 20px;
}

.top-row {
  display: grid;
  grid-template-columns: 1fr 1fr 280px;
  gap: 16px;
}

.metric-card {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--blue-primary);
}

.metric-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
}

.metric-main {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.metric-value {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
  color: #111827;
  letter-spacing: -2px;
}

.metric-unit {
  font-size: 20px;
  font-weight: 400;
  color: #6b7280;
  margin-left: 2px;
  margin-bottom: 6px;
}

.metric-icon {
  width: 52px;
  height: 52px;
  border: 2px solid #e5e7eb;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  flex-shrink: 0;
}

.metric-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: #6b7280;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-green {
  background: var(--green);
}

.status-card {
  background: var(--blue-card);
  border-radius: var(--card-radius);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: #fff;
}

.status-card-title {
  font-size: 15px;
  font-weight: 700;
}

.status-card-body {
  font-size: 13px;
  line-height: 1.55;
  opacity: 0.88;
}

.status-card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.btn-white {
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-white:hover {
  background: rgba(255, 255, 255, .28);
}

.btn-white-solid {
  background: #fff;
  border: none;
  color: var(--blue-card);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}

.btn-white-solid:hover {
  opacity: 0.9;
}

.bottom-row {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title-new {
  font-size: 15px;
  font-weight: 700;
  color: #111827;
}

.badge-crit {
  background: var(--badge-red-bg);
  color: var(--badge-red);
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.alerts-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.alert-item {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 13px 14px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.alert-item.alert-red {
  border-left: 3px solid #ef4444;
  background: var(--alert-red-bg);
}

.alert-item.alert-orange {
  border-left: 3px solid var(--orange);
  background: var(--alert-orange-bg);
}

.alert-icon-wrap {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.alert-icon-wrap svg {
  width: 16px;
  height: 16px;
}

.alert-icon-red {
  background: #fee2e2;
  color: #ef4444;
}

.alert-icon-orange {
  background: #fef3c7;
  color: var(--orange);
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 3px;
}

.alert-desc {
  font-size: 12px;
  color: #6b7280;
  line-height: 1.45;
}

.alert-time {
  font-size: 11px;
  color: #ef4444;
  font-weight: 600;
  margin-top: 5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.alert-time.orange-time {
  color: var(--orange);
}

.table-card-new {
  background: #fff;
  border: 1px solid var(--card-border);
  border-radius: var(--card-radius);
  overflow: hidden;
}

.table-header-bar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--card-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.table-actions {
  display: flex;
  gap: 8px;
}

.table-icon-btn {
  width: 30px;
  height: 30px;
  border: 1px solid var(--card-border);
  border-radius: 6px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #6b7280;
  transition: background 0.15s;
}

.table-icon-btn:hover {
  background: var(--page-bg);
}

.table-icon-btn svg {
  width: 14px;
  height: 14px;
}

.table-new {
  width: 100%;
  border-collapse: collapse;
}

.table-new thead th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: #6b7280;
  padding: 11px 20px;
  background: #fafafa;
  border-bottom: 1px solid var(--card-border);
}

.table-new tbody tr {
  border-bottom: 1px solid var(--card-border);
  transition: background 0.12s;
}

.table-new tbody tr:last-child {
  border-bottom: none;
}

.table-new tbody tr:hover {
  background: #fafbff;
}

.table-new tbody td {
  padding: 13px 20px;
  font-size: 13px;
  vertical-align: middle;
}

.td-date {
  font-weight: 500;
  color: #111827;
}

.td-date span {
  display: block;
  color: #6b7280;
  font-weight: 400;
  font-size: 12px;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.chip-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chip-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.chip-gray {
  background: #f3f4f6;
  color: #6b7280;
}

.chip-red {
  background: #fee2e2;
  color: #dc2626;
}

.chip-name {
  font-size: 13px;
  font-weight: 500;
}

.status-badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.badge-autorise {
  background: var(--badge-green-bg);
  color: var(--badge-green);
}

.badge-alerte {
  background: var(--badge-orange-bg);
  color: var(--badge-orange);
}

.badge-refuse {
  background: var(--badge-red-bg);
  color: var(--badge-red);
}

.badge-complete {
  background: var(--badge-gray-bg);
  color: var(--badge-gray);
}

.table-footer-new {
  padding: 14px 20px;
  border-top: 1px solid var(--card-border);
  display: flex;
  justify-content: flex-end;
}

.link-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-primary);
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: inherit;
  transition: opacity 0.15s;
  text-decoration: none;
}

.link-btn:hover {
  opacity: 0.75;
}

.link-btn svg {
  width: 14px;
  height: 14px;
}