/* ============================================================
   ABRI SOCIAL — Design System
   Police : Nunito (Google Fonts)
   Palette : Bleu nuit + Orange chaleureux
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;500;600;700;800&family=Playfair+Display:wght@700&display=swap');

:root {
  --sidebar-bg:      #0f2340;
  --sidebar-hover:   #1a3a5c;
  --sidebar-active:  #1e4a73;
  --sidebar-text:    #b8cfe8;
  --sidebar-text-active: #ffffff;
  --sidebar-accent:  #e8770a;
  --sidebar-width:   260px;

  --bg:              #f0f4f8;
  --surface:         #ffffff;
  --surface-2:       #f8fafc;
  --border:          #dde3ec;
  --border-light:    #eef1f6;

  --text-primary:    #1a2a3a;
  --text-secondary:  #4a6072;
  --text-muted:      #7a8fa0;
  --text-light:      #a0b0bf;

  --primary:         #1e6ab4;
  --primary-dark:    #155090;
  --primary-light:   #e8f1fa;
  --accent:          #e8770a;
  --accent-light:    #fef3e8;

  --success:         #16a34a;
  --success-light:   #dcfce7;
  --warning:         #d97706;
  --warning-light:   #fef3c7;
  --danger:          #dc2626;
  --danger-light:    #fee2e2;
  --info:            #0284c7;
  --info-light:      #e0f2fe;

  --radius:          10px;
  --radius-sm:       6px;
  --radius-lg:       16px;
  --shadow:          0 2px 12px rgba(15,35,64,0.08);
  --shadow-md:       0 4px 24px rgba(15,35,64,0.12);
  --shadow-lg:       0 8px 40px rgba(15,35,64,0.16);

  --transition:      0.2s ease;
  --font:            'Nunito', sans-serif;
  --font-display:    'Playfair Display', serif;
}

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

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--primary-dark); }

img { max-width: 100%; }

/* ============================================================ LAYOUT */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================================ SIDEBAR */

.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo .logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.sidebar-logo .logo-icon {
  width: 42px; height: 42px;
  background: var(--sidebar-accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.sidebar-logo .logo-text {
  display: flex; flex-direction: column;
}

.sidebar-logo .logo-name {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.sidebar-logo .logo-sub {
  font-size: 0.7rem;
  color: var(--sidebar-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

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

.sidebar-section-label {
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--sidebar-text);
  opacity: 0.5;
  padding: 16px 8px 6px;
  font-weight: 700;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 0.88rem;
  font-weight: 600;
  transition: all var(--transition);
  text-decoration: none;
}

.sidebar-nav a:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.sidebar-nav a.active {
  background: var(--sidebar-active);
  color: var(--sidebar-text-active);
  box-shadow: inset 3px 0 0 var(--sidebar-accent);
}

.sidebar-nav a .nav-icon {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-nav a .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 99px;
  min-width: 18px;
  text-align: center;
}

.sidebar-user {
  padding: 16px 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-user .user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--sidebar-active);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  color: #fff;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user .user-info { flex: 1; min-width: 0; }
.sidebar-user .user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .user-role {
  font-size: 0.68rem;
  color: var(--sidebar-text);
}
.sidebar-user .logout-btn {
  color: var(--sidebar-text);
  font-size: 1rem;
  opacity: 0.7;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.sidebar-user .logout-btn:hover { opacity: 1; color: var(--danger); }

/* ============================================================ MAIN CONTENT */

.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar .page-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.topbar .page-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-left: 8px;
}

.topbar-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar-search {
  position: relative;
}

.topbar-search input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 8px 16px 8px 36px;
  font-size: 0.82rem;
  font-family: var(--font);
  width: 220px;
  transition: all var(--transition);
  color: var(--text-primary);
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  width: 280px;
  box-shadow: 0 0 0 3px var(--primary-light);
}

.topbar-search .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.85rem;
  pointer-events: none;
}

.hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.4rem;
  color: var(--text-secondary);
  padding: 4px;
}

.page-body {
  padding: 28px;
  flex: 1;
}

/* ============================================================ CARDS */

.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-header h2, .card-header h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
}

.card-header .card-actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
}

.card-body {
  padding: 20px 24px;
}

/* ============================================================ STAT CARDS */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-card .stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  margin-bottom: 4px;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text-primary);
}

.stat-card .stat-label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-card .stat-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-card.blue   .stat-icon { background: var(--primary-light); color: var(--primary); }
.stat-card.orange .stat-icon { background: var(--accent-light);  color: var(--accent); }
.stat-card.green  .stat-icon { background: var(--success-light); color: var(--success); }
.stat-card.red    .stat-icon { background: var(--danger-light);  color: var(--danger); }
.stat-card.purple .stat-icon { background: #ede9fe; color: #7c3aed; }

/* ============================================================ TABLES */

.table-container {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-light);
  background: var(--surface);
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead th {
  background: var(--surface-2);
  padding: 12px 16px;
  text-align: left;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }

tbody tr:hover td { background: var(--surface-2); }

/* ============================================================ BADGES */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

.badge-blue    { background: var(--primary-light); color: var(--primary); }
.badge-orange  { background: var(--accent-light);  color: var(--accent); }
.badge-green   { background: var(--success-light); color: var(--success); }
.badge-red     { background: var(--danger-light);  color: var(--danger); }
.badge-yellow  { background: var(--warning-light); color: var(--warning); }
.badge-gray    { background: #f1f5f9; color: var(--text-muted); }
.badge-purple  { background: #ede9fe; color: #7c3aed; }

/* ============================================================ BUTTONS */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-dark); color: #fff; }

.btn-accent   { background: var(--accent); color: #fff; }
.btn-accent:hover:not(:disabled)   { background: #c96200; color: #fff; }

.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled)  { background: #15803d; color: #fff; }

.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; color: #fff; }

.btn-outline  {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 7px 10px;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg); color: var(--text-primary); }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }
.btn-icon { padding: 8px; width: 36px; height: 36px; }

/* ============================================================ FORMS */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full { grid-column: 1 / -1; }

label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

label .required { color: var(--danger); margin-left: 3px; }

.form-control {
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.875rem;
  color: var(--text-primary);
  background: var(--surface);
  transition: all var(--transition);
  width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-control::placeholder { color: var(--text-light); }

select.form-control { cursor: pointer; }

textarea.form-control {
  resize: vertical;
  min-height: 100px;
}

.form-control:disabled {
  background: var(--bg);
  color: var(--text-muted);
  cursor: not-allowed;
}

.form-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.form-error {
  font-size: 0.72rem;
  color: var(--danger);
}

/* Checkbox / radio */
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ============================================================ ALERTS */

.alert {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.855rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }

.alert-success { background: var(--success-light); color: #14532d; border: 1px solid #bbf7d0; }
.alert-danger  { background: var(--danger-light);  color: #7f1d1d; border: 1px solid #fecaca; }
.alert-warning { background: var(--warning-light); color: #78350f; border: 1px solid #fde68a; }
.alert-info    { background: var(--info-light);    color: #0c4a6e; border: 1px solid #bae6fd; }

/* ============================================================ MODALS */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,35,64,0.5);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform var(--transition);
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 800;
}

.modal-close {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--text-muted);
  transition: color var(--transition);
  padding: 4px;
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ============================================================ TABS */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  padding: 10px 20px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}

.tab-btn:hover { color: var(--text-primary); }

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ============================================================ PAGE HEADER */

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

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-header .page-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ============================================================ AVATAR */

.avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--border);
}

.avatar-placeholder {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 800;
  flex-shrink: 0;
}

.avatar-lg { width: 80px; height: 80px; font-size: 1.6rem; }
.avatar-sm { width: 32px; height: 32px; font-size: 0.7rem; }

/* ============================================================ BED GRID */

.bed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
}

.bed-card {
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  padding: 12px 10px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

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

.bed-card .bed-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bed-card .bed-icon { font-size: 1.8rem; margin: 6px 0; }

.bed-card .bed-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bed-card.libre   { border-color: #86efac; background: #f0fdf4; }
.bed-card.libre .bed-icon { opacity: 0.4; }
.bed-card.occupe  { border-color: #93c5fd; background: #eff6ff; }
.bed-card.urgence-occupe { border-color: #fca5a5; background: #fff1f2; }
.bed-card.maintenance { border-color: var(--border); background: var(--surface-2); opacity: 0.6; }

/* ============================================================ TIMELINE */

.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 9px; top: 0; bottom: 0;
  width: 2px;
  background: var(--border);
}

.timeline-item {
  position: relative;
  margin-bottom: 20px;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -23px;
  top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 2px var(--primary);
}

.timeline-item .tl-date {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.timeline-item .tl-content {
  background: var(--surface-2);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 12px 16px;
}

.timeline-item .tl-title {
  font-size: 0.875rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.timeline-item .tl-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.timeline-item .tl-author {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ============================================================ CALENDAR */

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 6px 0;
}

.calendar-day {
  min-height: 80px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 6px;
  background: var(--surface);
  cursor: pointer;
  transition: background var(--transition);
}

.calendar-day:hover { background: var(--primary-light); }

.calendar-day.today { border-color: var(--primary); background: var(--primary-light); }
.calendar-day.other-month { background: var(--surface-2); opacity: 0.5; }

.calendar-day .day-num {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.calendar-day.today .day-num {
  color: var(--primary);
}

.calendar-event {
  font-size: 0.65rem;
  font-weight: 600;
  padding: 2px 5px;
  border-radius: 3px;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: var(--primary-light);
  color: var(--primary);
}

.calendar-event.rdv    { background: #e0f2fe; color: #0369a1; }
.calendar-event.echeance { background: var(--warning-light); color: var(--warning); }
.calendar-event.reunion { background: #f3e8ff; color: #7c3aed; }

/* ============================================================ FILTERS */

.filters-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.filters-bar .form-control {
  width: auto;
  min-width: 140px;
}

/* ============================================================ EMPTY STATE */

.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  font-size: 3rem;
  opacity: 0.3;
  margin-bottom: 16px;
}

.empty-state p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ============================================================ PROFILE */

.profile-header {
  background: linear-gradient(135deg, var(--sidebar-bg), #1e4a73);
  border-radius: var(--radius-lg);
  padding: 28px;
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
  color: #fff;
}

.profile-header .profile-meta h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
}

.profile-header .profile-ref {
  font-size: 0.78rem;
  opacity: 0.7;
  margin-top: 2px;
}

.profile-header .profile-badges {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  flex-wrap: wrap;
}

/* ============================================================ DOCUMENT CARDS */

.doc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  background: var(--surface);
  transition: all var(--transition);
}

.doc-card:hover { border-color: var(--primary); box-shadow: var(--shadow); }

.doc-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}

.doc-icon.pdf  { background: #fee2e2; color: #dc2626; }
.doc-icon.img  { background: #e0f2fe; color: #0284c7; }

.doc-info { flex: 1; min-width: 0; }
.doc-name { font-size: 0.875rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 0.72rem; color: var(--text-muted); margin-top: 2px; }

.doc-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ============================================================ PROGRESS BARS */

.progress-bar {
  height: 8px;
  border-radius: 99px;
  background: var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--primary);
  transition: width 0.6s ease;
}

.progress-fill.green  { background: var(--success); }
.progress-fill.orange { background: var(--accent); }
.progress-fill.red    { background: var(--danger); }

/* ============================================================ FLASH MESSAGES */

#flash-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 380px;
}

.flash-msg {
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.855rem;
  font-weight: 600;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

.flash-msg.success { background: #fff; border-left: 4px solid var(--success); color: var(--text-primary); }
.flash-msg.error   { background: #fff; border-left: 4px solid var(--danger);  color: var(--text-primary); }
.flash-msg.info    { background: #fff; border-left: 4px solid var(--info);    color: var(--text-primary); }

/* ============================================================ LOGIN PAGE */

.login-page {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, var(--sidebar-bg) 0%, #1e4a73 100%);
}

.login-visual {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #fff;
  text-align: center;
}

.login-visual .brand-logo {
  width: 80px; height: 80px;
  background: rgba(255,255,255,0.15);
  border-radius: 24px;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.5rem;
  margin: 0 auto 24px;
  border: 2px solid rgba(255,255,255,0.2);
}

.login-visual h1 {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-visual p {
  font-size: 1rem;
  opacity: 0.75;
  max-width: 320px;
}

.login-panel {
  width: 420px;
  background: var(--surface);
  padding: 48px 40px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  box-shadow: -20px 0 60px rgba(0,0,0,0.3);
}

.login-panel h2 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.login-panel .login-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.login-panel .form-group {
  margin-bottom: 16px;
}

/* ============================================================ MOBILE SIDEBAR OVERLAY */

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

/* ============================================================ RESPONSIVE */

@media (max-width: 900px) {
  :root { --sidebar-width: 260px; }

  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.open { display: block; }

  .hamburger { display: flex; }

  .main-content { margin-left: 0; }

  .page-body { padding: 16px; }

  .topbar { padding: 0 16px; }

  .login-page { flex-direction: column; }
  .login-visual { flex: 0; padding: 40px 20px 20px; }
  .login-visual h1 { font-size: 1.8rem; }
  .login-panel { width: 100%; padding: 32px 24px; }
}

@media (max-width: 600px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
}

/* ============================================================ UTILS */

.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8   { margin-bottom: 8px; }
.mb-16  { margin-bottom: 16px; }
.mb-24  { margin-bottom: 24px; }
.mt-8   { margin-top: 8px; }
.mt-16  { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.fw-bold { font-weight: 700; }
.text-right { text-align: right; }
.w-100 { width: 100%; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }