/* ============================================================
   PayGfad ERP - Unified Design System v4.0
   Merged from style.css + erp.css — single source of truth
   ============================================================ */

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

/* ========================================
   CSS VARIABLES / CUSTOM PROPERTIES
   ======================================== */
:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --secondary: #1e3a5f;
  --secondary-dark: #0f2744;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;
  --surface: #ffffff;
  --bg: #f3f4f6;
  --text: #111827;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 0.75rem;
  --radius-lg: 1.25rem;
  --sidebar-width: 260px;
  --purple: #7c3aed;
  --purple-light: #ede9fe;
  --orange: #ea580c;
  --orange-light: #fff7ed;
  --teal: #0d9488;
  --teal-light: #f0fdfa;
  --indigo: #4f46e5;
  --indigo-light: #eef2ff;
  --rose: #e11d48;
  --rose-light: #fff1f2;
  --stat-icon-size: 44px;
  --card-hover-shadow: 0 8px 20px -4px rgba(0,0,0,0.12);
}

/* ========================================
   BASE / RESET
   ======================================== */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  scroll-behavior: smooth;
}

html { scroll-behavior: smooth; }

#app {
  min-height: 100vh;
  min-height: 100dvh;
}

img {
  content-visibility: auto;
}

/* Input number - hide arrows */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] { -moz-appearance: textfield; }

/* Focus ring accessible */
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ========================================
   LAYOUT
   ======================================== */
.app-layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.main-content main {
  flex: 1;
  overflow-y: auto;
}

.page-content {
  padding: 1.25rem 1.5rem;
  max-width: 1600px;
  animation: fadeInPage 0.2s ease forwards;
}

.page-content > * {
  animation: fadeInUp 0.3s ease forwards;
}
.page-content > .modal-backdrop {
  animation: none !important;
  transform: none !important;
}

/* ========================================
   SIDEBAR
   ======================================== */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--secondary) 0%, var(--secondary-dark) 100%);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 50;
  overflow-y: auto;
  position: relative;
  scrollbar-width: none;
  -ms-overflow-style: none;
  contain: layout style;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-header {
  padding: 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.logo-container img {
  height: 36px;
  width: auto;
  background: white;
  padding: 3px;
  border-radius: 8px;
}

.logo-text {
  font-size: 1.3rem;
  font-weight: 800;
  color: white;
  letter-spacing: -0.02em;
}

.sidebar nav {
  flex: 1;
  padding: 0.5rem 0.75rem;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: auto;
}

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

.nav-group { margin-bottom: 0.25rem; }

.nav-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
  padding: 0.875rem 0.875rem 0.35rem;
  margin-top: 0.25rem;
}
.nav-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin-left: 0.25rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.875rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  cursor: pointer;
  margin-bottom: 2px;
  background: none;
  border: none;
  width: 100%;
  text-align: left;
  position: relative;
}
.nav-item:hover {
  background: rgba(255,255,255,0.1);
  color: white;
  transform: translateX(3px);
}
.nav-item:focus-visible {
  outline: 2px solid #6ee7b7;
  outline-offset: -2px;
}
.nav-item i {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}
.nav-item.active {
  background: rgba(16,185,129,0.2) !important;
  color: #6ee7b7 !important;
  font-weight: 600 !important;
  border-left: 3px solid #10b981 !important;
  padding-left: calc(0.875rem - 3px) !important;
}

.nav-item-logout {
  color: rgba(252,165,165,0.8) !important;
}
.nav-item-logout:hover {
  background: rgba(239,68,68,0.2) !important;
  color: #fca5a5 !important;
}

/* ========================================
   TOPBAR
   ======================================== */
.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1rem;
  background: white;
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 30;
  animation: slideDown 0.3s cubic-bezier(0.4,0,0.2,1);
  min-height: 56px;
  flex-shrink: 0;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.topbar-logo img { height: 28px; }
.topbar-logo span {
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--secondary);
}

.menu-btn {
  background: none;
  border: none;
  padding: 0.5rem;
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--text);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.menu-btn:hover { background: var(--bg); }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.topbar-profile-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.375rem 0.625rem;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.topbar-profile-btn:hover { background: var(--bg); }

.topbar-username {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
}

.notif-btn {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1.5px solid var(--border);
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.95rem;
  transition: all 0.2s;
}
.notif-btn:hover { background: var(--bg); color: var(--text); }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 16px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
}

.topbar-search {
  display: none;
}

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.2;
}

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

/* ========================================
   BUTTONS
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
  text-decoration: none;
  line-height: 1.4;
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  box-shadow: 0 4px 12px rgba(16,185,129,0.3);
}
.btn-primary:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16,185,129,0.4);
}

.btn-secondary {
  background: white;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg);
  border-color: #d1d5db;
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  color: white;
  box-shadow: 0 4px 12px rgba(239,68,68,0.25);
}
.btn-danger:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(239,68,68,0.35);
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  box-shadow: 0 4px 12px rgba(16,185,129,0.25);
}
.btn-success:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(16,185,129,0.35);
}

.btn-warning {
  background: var(--warning);
  color: white;
  border: none;
}
.btn-warning:hover { background: #d97706; }

.btn-active {
  background: var(--primary-light) !important;
  border-color: var(--primary) !important;
  color: var(--primary) !important;
}

.btn-icon {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  transition: all 0.15s;
  text-decoration: none;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.btn-icon-primary { border-color: var(--primary); color: var(--primary); }
.btn-icon.btn-icon-primary:hover { background: var(--primary-light); }
.btn-icon.btn-icon-danger { border-color: #fca5a5; color: #dc2626; }
.btn-icon.btn-icon-danger:hover { background: #fee2e2; }

/* Transition douce sur les boutons */
.btn, .btn-icon, .nav-item, .stat-card, .card-hover {
  will-change: transform;
}

/* ========================================
   CARDS
   ======================================== */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
  contain: layout style;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  background: linear-gradient(135deg, #f9fafb 0%, #ffffff 100%);
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.card-body {
  padding: 1.5rem;
}
.card-body:not(.p-0) {
  padding: 1.25rem 1.5rem;
}
.card-body.p-0 { padding: 0 !important; }

.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-hover-shadow);
}

/* ========================================
   STAT CARDS
   ======================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: white !important;
  border-radius: var(--radius-lg) !important;
  padding: 1.25rem !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04) !important;
  border: 1px solid var(--border) !important;
  position: relative !important;
  overflow: hidden !important;
  transition: transform 0.2s cubic-bezier(0.4,0,0.2,1), box-shadow 0.2s cubic-bezier(0.4,0,0.2,1) !important;
  color: var(--text) !important;
  will-change: transform;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  contain: layout style;
}
.stat-card::after { display: none !important; }
.stat-card:hover {
  transform: translateY(-3px) !important;
  box-shadow: var(--card-hover-shadow) !important;
}

.stat-card-icon {
  width: var(--stat-icon-size);
  height: var(--stat-icon-size);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  margin-bottom: 0.875rem;
  background: rgba(255,255,255,0.2);
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.stat-icon-green { background: #d1fae5; color: #059669; }
.stat-icon-blue { background: #dbeafe; color: #2563eb; }
.stat-icon-purple { background: var(--purple-light); color: var(--purple); }
.stat-icon-orange { background: var(--orange-light); color: var(--orange); }
.stat-icon-teal { background: var(--teal-light); color: var(--teal); }
.stat-icon-indigo { background: var(--indigo-light); color: var(--indigo); }
.stat-icon-rose { background: var(--rose-light); color: var(--rose); }
.stat-icon-red { background: #fee2e2; color: #dc2626; }
.stat-icon-cyan { background: #ecfeff !important; color: #0891b2 !important; }

.stat-value,
.stat-card-value {
  font-size: 1.6rem !important;
  font-weight: 800 !important;
  color: var(--text) !important;
  line-height: 1.1 !important;
  margin-bottom: 0.25rem !important;
}

.stat-label,
.stat-card-label {
  font-size: 0.78rem !important;
  color: var(--text-muted) !important;
  font-weight: 500 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
  opacity: 1 !important;
}

.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  margin-top: 0.5rem;
  padding: 2px 6px;
  border-radius: 999px;
}
.trend-up { color: #059669; background: #d1fae5; }
.trend-down { color: #dc2626; background: #fee2e2; }

.stat-card-green, .stat-card-blue, .stat-card-amber,
.stat-card-rose, .stat-card-purple, .stat-card-cyan {
  background: white !important;
  color: var(--text) !important;
}

/* ========================================
   TABLES
   ======================================== */
table {
  width: 100%;
  border-collapse: collapse;
}

.table {
  width: 100%;
  border-collapse: collapse;
}
.table thead tr {
  background: #f9fafb;
  border-bottom: 2px solid var(--border);
}
.table th {
  padding: 0.75rem 1rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}
.table tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s cubic-bezier(0.4,0,0.2,1);
}
.table td {
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  vertical-align: middle;
}

.table-container {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 3px rgba(0,0,0,0.07);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: fadeIn 0.3s ease-out;
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  flex-wrap: wrap;
  background: white;
}

.table-title {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.table-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

thead tr {
  background: #f9fafb;
  border-bottom: 2px solid var(--border);
}

th {
  padding: 0.875rem 1.25rem;
  text-align: left;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #f3f4f6;
  transition: background 0.15s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover {
  background: #f0fdf4 !important;
  cursor: pointer;
}
tbody tr:focus-within {
  background: #f0fdf4;
  box-shadow: inset 0 0 0 1px var(--primary);
}

tbody td {
  padding: 0.875rem 1rem;
  color: var(--text);
  vertical-align: middle;
}

td {
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  vertical-align: middle;
}

.td-actions { display: flex; gap: 0.375rem; white-space: nowrap; }

/* ========================================
   BADGES
   ======================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 600;
  line-height: 1.3;
  transition: all 0.2s ease;
}
.badge:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 1px;
}
.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}
.badge-success { background: #dcfce7; color: #166534; }
.badge-success .badge-dot { background: #16a34a; animation: blink 2.5s infinite; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-warning .badge-dot { background: #ca8a04; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-danger .badge-dot { background: #dc2626; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-info .badge-dot { background: #3b82f6; }
.badge-purple { background: var(--purple-light); color: #5b21b6; }
.badge-purple .badge-dot { background: var(--purple); }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-gray .badge-dot { background: #9ca3af; }
.badge-orange { background: var(--orange-light); color: #9a3412; }
.badge-orange .badge-dot { background: var(--orange); }

/* ========================================
   FORMS
   ======================================== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1rem;
}

.form-group { margin-bottom: 1rem; }
.form-group:last-child { margin-bottom: 0; }

.form-label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.375rem;
}
.form-label .required { color: var(--danger); margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: white;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  box-sizing: border-box;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}
.form-input.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}
.form-textarea { resize: vertical; min-height: 80px; }

.form-input-icon { position: relative; }
.form-input-icon i {
  position: absolute;
  left: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.875rem;
}
.form-input-icon .form-input { padding-left: 2.5rem; }

select.form-input {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1rem;
  padding-right: 2.25rem;
  -webkit-appearance: none;
  appearance: none;
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
}

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.form-select {
  width: 100%;
  padding: 0.6rem 2.25rem 0.6rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  background-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16,185,129,0.12);
}

.form-row {
  display: grid;
  gap: 1rem;
}
.form-row-2 { grid-template-columns: repeat(2, 1fr); }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }

/* ========================================
   MODALS
   ======================================== */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(3px);
}
.modal-backdrop.active { display: flex; }
.modal-backdrop .modal-backdrop { z-index: 1100; }

.modal {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-sm { max-width: 420px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.modal-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  transition: background 0.15s;
}
.modal-close:hover { background: var(--bg); color: var(--text); }

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  flex-shrink: 0;
  background: white;
}

/* ========================================
   ALERTS
   ======================================== */
.alert {
  border-radius: var(--radius-lg);
  border: 1px solid;
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert i { flex-shrink: 0; margin-top: 1px; }

.alert-success { background: #f0fdf4; border-color: #a7f3d0; color: #065f46; }
.alert-success i { color: #10b981; }

.alert-error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ========================================
   TOAST NOTIFICATIONS
   ======================================== */
#toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
  width: calc(100% - 2rem);
}

.toast {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: var(--radius);
  background: white;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  border-left: 4px solid;
  min-width: 280px;
  max-width: 400px;
  animation: slideIn 0.3s ease;
  transform: translateZ(0);
  backface-visibility: hidden;
}

.toast-success { border-color: var(--primary); }
.toast-success .toast-icon { color: var(--primary); }
.toast-error { border-color: var(--danger); }
.toast-error .toast-icon { color: var(--danger); }
.toast-warning { border-color: var(--warning); }
.toast-warning .toast-icon { color: var(--warning); }
.toast-info { border-color: var(--info); }
.toast-info .toast-icon { color: var(--info); }

.toast-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 0.7rem;
  color: white;
}
.toast-message { flex: 1; font-size: 0.875rem; color: var(--text); }

/* ========================================
   TABS
   ======================================== */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}
.tab-btn {
  padding: 0.65rem 1.25rem;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

.profile-tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  padding: 0 1.5rem;
  background: var(--bg);
}
.profile-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.875rem 1.25rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}
.profile-tab:hover {
  color: var(--text);
  background: rgba(16,185,129,0.05);
}
.profile-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: white;
}
.profile-tab-content { min-height: 200px; }

/* ========================================
   SEARCH BAR
   ======================================== */
.search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: white;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.45rem 0.875rem;
  min-width: 220px;
  transition: border-color 0.2s;
}
.search-bar:focus-within { border-color: var(--primary); }
.search-bar i { color: var(--text-muted); font-size: 0.875rem; }
.search-bar input {
  border: none;
  outline: none;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text);
  background: none;
  flex: 1;
  min-width: 0;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  text-align: center;
  color: #9ca3af;
}
.empty-state i {
  font-size: 2.5rem;
  color: #d1d5db;
  margin-bottom: 1rem;
}
.empty-state h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.empty-state p {
  font-size: 0.875rem;
  color: #9ca3af;
  margin-bottom: 1.5rem;
}

/* ========================================
   PROGRESS BAR
   ======================================== */
.progress {
  height: 6px;
  background: var(--border);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 0.4rem;
}
.progress-bar {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  transition: width 0.5s ease;
}
.progress-bar.danger { background: var(--danger); }
.progress-bar.warning { background: var(--warning); }

/* ========================================
   INFO ROW (modals)
   ======================================== */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.4rem 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 0.875rem;
}
.info-row:last-child { border-bottom: none; }
.info-row span { color: var(--text-muted); }
.info-row strong { color: var(--text); }
.info-row:hover {
  background: #f9fafb;
  border-radius: 4px;
  padding-left: 4px;
  padding-right: 4px;
}

/* ========================================
   AVATAR
   ======================================== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.avatar-sm { width: 28px; height: 28px; font-size: 0.75rem; }
.avatar-lg { width: 48px; height: 48px; font-size: 1.1rem; }
.avatar-xl {
  width: 72px !important;
  height: 72px !important;
  font-size: 2rem !important;
  border-radius: 1.25rem !important;
}
.avatar-green { background: var(--primary-light); color: var(--primary); }
.avatar-blue { background: #dbeafe; color: #2563eb; }
.avatar-purple { background: var(--purple-light); color: var(--purple); }

/* ========================================
   INVOICE
   ======================================== */
.invoice-preview {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  background: white;
}
.invoice-lines-table { width: 100%; border-collapse: collapse; }
.invoice-lines-table th {
  padding: 0.5rem 0.75rem;
  background: #f9fafb;
  border: 1px solid var(--border);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.invoice-lines-table td {
  padding: 0.6rem 0.75rem;
  border: 1px solid #f3f4f6;
  font-size: 0.875rem;
}
.invoice-lines-table input {
  border: none;
  background: transparent;
  width: 100%;
  font-family: inherit;
  font-size: 0.875rem;
  color: var(--text);
  outline: none;
  padding: 0;
}
.invoice-lines-table input:focus { background: #f0fdf4; border-radius: 4px; padding: 2px 4px; }

/* ========================================
   KANBAN BOARD
   ======================================== */
.kanban-column {
  background: #f8fafc;
  border-radius: 12px;
  padding: 1rem;
  min-height: 300px;
}
.kanban-card {
  background: white;
  border-radius: 8px;
  padding: 0.875rem;
  margin-bottom: 0.625rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
}
.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

/* ========================================
   QUICK ACTIONS
   ======================================== */
.quick-action-btn { box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.quick-action-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(0,0,0,0.1); }
.quick-action-btn:active { transform: translateY(-1px); }

/* ========================================
   RECENT ITEMS
   ======================================== */
.recent-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  transition: background 0.2s ease;
}
.recent-item:hover { background: var(--bg); }
.recent-item:last-child { border-bottom: none; }

/* ========================================
   PROFILE AVATAR SECTION
   ======================================== */
.profile-avatar-section {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  background: linear-gradient(135deg, #ecfdf5, #d1fae5);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  border: 1px solid #a7f3d0;
}

/* ========================================
   PROFIT / LOSS INDICATOR
   ======================================== */
.amount-positive { color: #059669; font-weight: 600; }
.amount-negative { color: #dc2626; font-weight: 600; }

/* ========================================
   LOGIN PAGE
   ======================================== */
.login-page {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 50%, #a7f3d0 100%);
  padding: 1rem;
  box-sizing: border-box;
  margin: 0;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.12);
  margin: auto;
  animation: slideUpIn 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.login-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}
.login-logo-inner {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(16,185,129,0.35);
}
.login-logo-inner img {
  height: 48px;
  border-radius: 8px;
}

/* ========================================
   PWA INSTALL BANNER
   ======================================== */
#pwa-install-banner {
  display: none;
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  box-shadow: 0 10px 30px rgba(0,0,0,0.15);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  z-index: 1000;
  max-width: 380px;
  width: calc(100% - 2rem);
  border: 1px solid var(--border);
}
#pwa-install-banner.show { display: flex; align-items: center; gap: 1rem; }

/* ========================================
   UTILITY CLASSES
   ======================================== */
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.8rem; }
.font-mono { font-family: 'SF Mono', 'Fira Code', monospace; }
.mt-4 { margin-top: 1rem; }
.p-0 { padding: 0; }

/* ========================================
   SCROLLBAR
   ======================================== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

.table-scroll::-webkit-scrollbar { height: 4px; }
.table-scroll::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }
.modal-body::-webkit-scrollbar { width: 4px; }
.modal-body::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }

/* ========================================
   ANIMATIONS / KEYFRAMES
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.96) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slideUpIn {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes fadeInPage {
  from { opacity: 0.6; }
  to { opacity: 1; }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

@keyframes skeletonPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ========================================
   MEDIA QUERIES
   ======================================== */

/* Safe touch targets for mobile */
@media (max-width: 768px) {
  .nav-item { min-height: 44px; }
  .btn { min-height: 40px; }
}

/* Topbar: tablet + desktop */
@media (min-width: 1025px) {
  .topbar {
    display: flex !important;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    justify-content: flex-end;
    gap: 1rem;
    height: 56px;
    min-height: 56px;
  }
  .menu-btn { display: none !important; }
  .topbar-logo { display: none !important; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .topbar {
    display: flex !important;
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 30;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
    justify-content: space-between;
    height: 56px;
    min-height: 56px;
  }
  .menu-btn { display: flex !important; }
  .topbar-logo { display: flex !important; }
  .hide-md { display: none !important; }
}

/* Topbar search desktop */
@media (min-width: 1024px) {
  .topbar-search {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.875rem;
    width: 250px;
    flex-shrink: 0;
  }
  .topbar-search input {
    border: none;
    background: none;
    outline: none;
    font-size: 0.85rem;
    color: var(--text);
    font-family: inherit;
    width: 100%;
  }
  .topbar-search i {
    color: var(--text-muted);
    font-size: 0.85rem;
    flex-shrink: 0;
  }
}

/* Card hover desktop */
@media (min-width: 769px) {
  .card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s ease;
  }
}

/* Stat card desktop height */
@media (min-width: 769px) {
  .stat-card { min-height: 130px; }
}

/* Desktop large screen */
@media (min-width: 1280px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr)) !important;
  }
  .page-content { padding: 2rem 2.5rem; }
  :root { --sidebar-width: 275px; }
}

@media (min-width: 1440px) {
  .page-content { padding: 2rem 3rem; }
}

/* Sidebar mobile hidden */
@media (max-width: 1024px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-width);
    max-width: 85vw;
    display: none;
    z-index: 50;
    box-shadow: none;
  }
  .menu-btn { display: flex !important; }
  .topbar-logo { display: flex !important; }
}

/* Profile page responsive */
@media (max-width: 900px) {
  div[style*="grid-template-columns:300px 1fr"],
  div[style*="grid-template-columns: 300px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  div[style*="grid-template-columns:1fr 1fr"],
  div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Kanban 4 cols → 2 cols */
  div[style*="grid-template-columns:repeat(4,1fr)"],
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

/* Tablet: modal fullscreen, grids responsive */
@media (max-width: 768px) {
  .topbar { display: flex; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .form-row-2, .form-row-3 { grid-template-columns: 1fr !important; }
  .table-header { flex-direction: column; align-items: stretch; }
  .td-actions { gap: 0.25rem; }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
  }
  .page-header > div:last-child {
    width: 100%;
    justify-content: flex-end;
  }
  .page-title { font-size: 1.35rem !important; }
  .page-content { padding: 0.75rem !important; }

  /* Modals fullscreen */
  .modal-backdrop { padding: 0 !important; align-items: flex-start !important; }
  .modal {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .modal-sm, .modal-lg, .modal-xl {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .modal-header { flex-shrink: 0; background: white; z-index: 2; }
  .modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .modal-footer {
    flex-shrink: 0;
    background: white;
    z-index: 2;
    padding-bottom: max(0.875rem, env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  }

  /* Dashboard grid responsive */
  .dashboard-grid-2 { grid-template-columns: 1fr !important; }
  .dashboard-table-sm td,
  .dashboard-table-sm th {
    padding: 0.5rem 0.75rem !important;
    font-size: 0.8rem !important;
  }
}

/* Mobile: stats grid + login card */
@media (max-width: 640px) {
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
  .stats-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 0.75rem !important;
  }
  .stat-card { padding: 0.875rem !important; }
  .stat-value { font-size: 1.25rem !important; }
  .stat-label { font-size: 0.7rem !important; }
  div[style*="grid-template-columns:repeat(auto-fill,minmax(300px"],
  div[style*="grid-template-columns:repeat(auto-fill,minmax(320px"] {
    grid-template-columns: 1fr !important;
  }
}

/* Kanban 4 cols → 1 col */
@media (max-width: 600px) {
  div[style*="grid-template-columns:repeat(4,1fr)"],
  div[style*="grid-template-columns: repeat(4, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
}

/* Mobile small */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 0.5rem !important;
  }
  .stat-card { padding: 0.75rem !important; }
  .stat-value { font-size: 1.1rem !important; }
  .stat-label { font-size: 0.65rem !important; }
  .stat-card-value { font-size: 1.3rem !important; }
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 0.75rem !important;
  }
  .page-header > div:last-child { width: 100%; }
  .page-header .btn { flex: 1; justify-content: center; }
  .page-title { font-size: 1.4rem !important; }
  .btn { padding: 0.5rem 0.875rem; font-size: 0.8rem; }
  .page-content { padding: 0.5rem 0.5rem; }

  .hide-sm, .hide-sm-show { display: none !important; }

  /* Notif button small */
  .notif-btn {
    width: 32px;
    height: 32px;
    min-height: 32px;
    border-radius: 6px;
    font-size: 0.85rem;
  }
  .notif-badge {
    width: 14px;
    height: 14px;
    font-size: 0.55rem;
    top: -3px;
    right: -3px;
  }
}

@media (min-width: 481px) {
  .hide-sm-show { display: flex !important; }
}

/* Login card short screens */
@media (max-height: 700px) {
  .login-card { padding: 1.5rem; }
  .login-logo { margin-bottom: 1rem; }
}
@media (max-height: 580px) {
  .login-card { padding: 1.25rem; }
  .login-logo { margin-bottom: 0.75rem; }
  .login-logo img { height: 48px !important; }
}

/* Responsive grids */
@media (max-width: 1200px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
  }
}

@media (max-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) !important;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

/* ========================================
   PWA SAFE AREA
   ======================================== */
@supports (padding: max(0px)) {
  .page-content {
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
  }
  .topbar {
    padding-top: 0.5rem;
    padding-left: max(0.875rem, env(safe-area-inset-left));
    padding-right: max(0.875rem, env(safe-area-inset-right));
  }
}

@media (display-mode: standalone) {
  .login-page {
    height: 100vh;
    height: 100dvh;
    min-height: auto;
  }
  .nav-item, .btn, .stat-card, .badge {
    -webkit-user-select: none;
    user-select: none;
  }
  * { -webkit-tap-highlight-color: transparent; }
  .modal-backdrop { padding: 0 !important; align-items: flex-start !important; }
  .modal {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .modal-sm, .modal-lg, .modal-xl {
    position: fixed !important;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100vw !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    max-width: 100vw !important;
    border-radius: 0 !important;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }
  .modal-header { flex-shrink: 0; background: white; z-index: 2; }
  .modal-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .modal-footer {
    flex-shrink: 0;
    background: white;
    z-index: 2;
    padding-bottom: max(0.875rem, env(safe-area-inset-bottom)) !important;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
  }
}

@media all and (display-mode: standalone) {
  body {
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .topbar {
    height: calc(60px + env(safe-area-inset-top));
    padding-top: env(safe-area-inset-top);
  }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
  .sidebar, .topbar, #toast-container,
  .btn, .btn-icon, .modal-backdrop, #pwa-install-banner { display: none !important; }
  .page-content { padding: 0 !important; }
  .stat-card { break-inside: avoid; }
  table { break-inside: auto; }
  tr { break-inside: avoid; }
}
