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

/* ==================== VARIABLES ==================== */
:root {
  --primary: #C41E24;
  --primary-dark: #9B1118;
  --primary-light: #E8434A;
  --secondary: #1A1A2E;
  --secondary-light: #2D2D44;
  --accent: #FF3B42;
  --white: #FFFFFF;
  --gray-50: #F8F9FA;
  --gray-100: #F1F3F5;
  --gray-200: #E9ECEF;
  --gray-300: #DEE2E6;
  --gray-400: #ADB5BD;
  --gray-500: #6C757D;
  --gray-600: #495057;
  --gray-700: #343A40;
  --gray-800: #212529;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --shadow-xl: 0 20px 60px rgba(0,0,0,0.15);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; }

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

/* ==================== BRAND LOGO IMAGE ==================== */
.brand-icon-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

/* ==================== PWA INSTALL BUTTONS ==================== */
.pwa-install-btn {
  margin-top: 16px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--white);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
}

.pwa-install-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.35);
  transform: translateY(-1px);
}

.pwa-install-btn-nav {
  padding: 8px 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(196,30,36,0.25);
  animation: pulse-install 2s ease-in-out infinite;
}

.pwa-install-btn-nav:hover {
  box-shadow: 0 4px 15px rgba(196,30,36,0.4);
  transform: translateY(-1px);
}

@keyframes pulse-install {
  0%, 100% { box-shadow: 0 2px 8px rgba(196,30,36,0.25); }
  50% { box-shadow: 0 2px 16px rgba(196,30,36,0.45); }
}

/* ==================== LOGIN PAGE ==================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--secondary) 0%, #0F0F1E 50%, var(--primary-dark) 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(196,30,36,0.15) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  border-radius: 50%;
  animation: pulse-glow 4s ease-in-out infinite;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(196,30,36,0.1) 0%, transparent 70%);
  bottom: -100px;
  left: -100px;
  border-radius: 50%;
  animation: pulse-glow 4s ease-in-out infinite reverse;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.1); opacity: 1; }
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  padding: 20px;
}

.login-card {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  box-shadow: var(--shadow-xl);
  animation: slideUp 0.6s ease-out;
}

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

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.login-logo .logo-icon {
  width: 72px;
  height: 72px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  color: white;
  box-shadow: 0 8px 32px rgba(196,30,36,0.3);
}

.login-logo h1 {
  font-size: 28px;
  font-weight: 800;
  color: var(--white);
  letter-spacing: -0.5px;
}

.login-logo p {
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  margin-top: 4px;
}

/* ==================== FORMS ==================== */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.7);
  margin-bottom: 8px;
  letter-spacing: 0.3px;
}

.dashboard-content .form-group label,
.modal .form-group label {
  color: var(--gray-600);
}

.form-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-md);
  color: var(--white);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
}

.form-input::placeholder { color: rgba(255,255,255,0.3); }

.form-input:focus {
  border-color: var(--primary);
  background: rgba(255,255,255,0.1);
  box-shadow: 0 0 0 3px rgba(196,30,36,0.2);
}

.dashboard-content .form-input,
.modal .form-input {
  background: var(--white);
  border: 1px solid var(--gray-300);
  color: var(--gray-800);
}

.dashboard-content .form-input::placeholder,
.modal .form-input::placeholder { color: var(--gray-400); }

.dashboard-content .form-input:focus,
.modal .form-input:focus {
  border-color: var(--primary);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(196,30,36,0.1);
}

.form-select {
  width: 100%;
  padding: 14px 16px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  color: var(--gray-800);
  font-size: 15px;
  font-family: inherit;
  transition: var(--transition);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236C757D' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
}

.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(196,30,36,0.1);
}

/* ==================== BUTTONS ==================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  box-shadow: 0 4px 15px rgba(196,30,36,0.3);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  box-shadow: 0 6px 20px rgba(196,30,36,0.4);
  transform: translateY(-1px);
}

.btn-primary:active { transform: translateY(0); }

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

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

.btn-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: var(--white);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #DC2626);
  color: var(--white);
}

.btn-sm {
  padding: 8px 16px;
  font-size: 13px;
  border-radius: var(--radius-sm);
}

.btn-full { width: 100%; }

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

.btn .spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

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

/* ==================== NAVBAR ==================== */
.navbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  height: 70px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-sm);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.nav-brand .brand-icon {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: white;
}

.nav-brand h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: -0.3px;
}

.nav-brand span {
  color: var(--primary);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-md);
}

.nav-user .avatar {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 14px;
  font-weight: 700;
}

.nav-user .user-info { line-height: 1.3; }
.nav-user .user-name { font-size: 14px; font-weight: 600; color: var(--gray-800); }
.nav-user .user-role { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.5px; }

.btn-logout {
  padding: 10px 18px;
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  color: var(--gray-600);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239,68,68,0.05);
}

/* ==================== DASHBOARD ==================== */
.dashboard-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 32px;
}

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

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--gray-800);
}

.page-header p {
  color: var(--gray-500);
  font-size: 15px;
  margin-top: 4px;
}

/* ==================== STATS CARDS ==================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 24px;
  border: 1px solid var(--gray-200);
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
}

.stat-card:nth-child(1)::before { background: linear-gradient(90deg, var(--primary), var(--accent)); }
.stat-card:nth-child(2)::before { background: linear-gradient(90deg, var(--success), #34D399); }
.stat-card:nth-child(3)::before { background: linear-gradient(90deg, var(--warning), #FBBF24); }
.stat-card:nth-child(4)::before { background: linear-gradient(90deg, var(--info), #60A5FA); }

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

.stat-card .stat-value {
  font-size: 32px;
  font-weight: 800;
  color: var(--gray-800);
  line-height: 1;
}

.stat-card .stat-label {
  font-size: 13px;
  color: var(--gray-500);
  margin-top: 8px;
  font-weight: 500;
}

/* ==================== TABLE ==================== */
.table-container {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.table-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.table-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--gray-800);
}

.table-wrapper {
  overflow-x: auto;
}

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

thead th {
  padding: 14px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 700;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}

tbody td {
  padding: 16px 20px;
  font-size: 14px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
  white-space: nowrap;
}

tbody tr {
  transition: var(--transition);
}

tbody tr:hover {
  background: var(--gray-50);
}

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

/* ==================== BADGES ==================== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

.badge-success {
  background: rgba(16,185,129,0.1);
  color: #059669;
}

.badge-danger {
  background: rgba(239,68,68,0.1);
  color: #DC2626;
}

.badge-warning {
  background: rgba(245,158,11,0.1);
  color: #D97706;
}

/* ==================== MODAL ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  transform: scale(0.9) translateY(20px);
  transition: var(--transition);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

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

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--gray-100);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: var(--gray-500);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--gray-200);
  color: var(--gray-800);
}

.modal-body {
  padding: 28px;
}

.modal-footer {
  padding: 20px 28px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ==================== TOAST ==================== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 14px 20px;
  border-radius: var(--radius-md);
  color: var(--white);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toastIn 0.4s ease-out;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 300px;
  max-width: 450px;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }

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

/* ==================== EMPTY STATE ==================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-state .empty-icon {
  font-size: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--gray-500);
  font-size: 14px;
}

/* ==================== TABS (Admin) ==================== */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--gray-100);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 28px;
  width: fit-content;
}

.tab-btn {
  padding: 10px 24px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}

.tab-btn.active {
  background: var(--white);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.tab-btn:hover:not(.active) {
  color: var(--gray-700);
}

.tab-content { display: none; }
.tab-content.active { display: block; animation: fadeIn 0.3s ease; }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ==================== STATUS SELECT ==================== */
.status-select {
  padding: 6px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
  appearance: none;
  background: var(--white);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' fill='%236C757D' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

.status-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(196,30,36,0.15);
}

/* ==================== ACTION BUTTONS ==================== */
.action-btns {
  display: flex;
  gap: 6px;
}

.btn-icon {
  width: 34px;
  height: 34px;
  border: 1px solid var(--gray-300);
  background: var(--white);
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: var(--transition);
  color: var(--gray-500);
}

.btn-icon:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(196,30,36,0.05);
}

.btn-icon.danger:hover {
  border-color: var(--danger);
  color: var(--danger);
  background: rgba(239,68,68,0.05);
}

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

/* ---- Tablet (max 768px) ---- */
@media (max-width: 768px) {
  /* Login */
  .login-card {
    padding: 36px 24px;
    border-radius: var(--radius-lg);
  }
  .login-container { padding: 16px; }
  .login-logo .logo-icon { width: 60px; height: 60px; font-size: 28px; }
  .login-logo h1 { font-size: 24px; }

  /* Navbar */
  .navbar {
    padding: 0 16px;
    height: 56px;
    gap: 8px;
  }
  .nav-brand .brand-icon { width: 34px; height: 34px; font-size: 15px; }
  .nav-brand h2 { font-size: 17px; }
  .nav-user { display: none; }
  .btn-logout { padding: 8px 14px; font-size: 12px; }

  /* Dashboard */
  .dashboard-content { padding: 20px 16px; }

  /* Page header */
  .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    margin-bottom: 24px;
  }
  .page-header h1 { font-size: 22px; }
  .page-header p { font-size: 13px; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Stats */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 24px;
  }
  .stat-card { padding: 16px; }
  .stat-card .stat-value { font-size: 24px; }
  .stat-card .stat-label { font-size: 12px; }

  /* Tabs */
  .tabs { width: 100%; }
  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    font-size: 13px;
  }

  /* Tables → card layout on mobile */
  .table-container { border-radius: var(--radius-md); }
  .table-header {
    padding: 16px;
    flex-direction: column;
    align-items: stretch;
  }
  .table-header h3 { font-size: 16px; }
  .table-header .btn { width: 100%; justify-content: center; }

  table, thead, tbody, th, td, tr {
    display: block;
  }

  thead {
    position: absolute;
    left: -9999px;
    top: -9999px;
  }

  tbody tr {
    padding: 16px;
    border-bottom: 1px solid var(--gray-200);
    position: relative;
  }

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

  tbody td {
    padding: 6px 0 6px 45%;
    position: relative;
    text-align: left;
    white-space: normal;
    word-break: break-word;
    border-bottom: none;
    font-size: 14px;
    min-height: 36px;
    display: flex;
    align-items: center;
  }

  tbody td::before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 42%;
    padding-right: 10px;
    font-weight: 700;
    font-size: 12px;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.3px;
  }

  /* Modals */
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 95vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    margin: 0;
  }
  .modal-header { padding: 20px; }
  .modal-header h3 { font-size: 18px; }
  .modal-body { padding: 20px; }
  .modal-footer {
    padding: 16px 20px;
    flex-direction: column;
  }
  .modal-footer .btn { width: 100%; }

  /* Forms inside modals */
  .form-input, .form-select {
    padding: 12px 14px;
    font-size: 16px; /* prevent iOS zoom */
  }

  /* Status select in table */
  .status-select {
    font-size: 14px;
    padding: 8px 32px 8px 12px;
  }

  /* Action buttons */
  .action-btns { gap: 8px; }
  .btn-icon {
    width: 40px;
    height: 40px;
    font-size: 16px;
  }

  /* Toast */
  .toast-container {
    top: auto;
    bottom: 16px;
    left: 16px;
    right: 16px;
  }
  .toast {
    min-width: auto;
    max-width: 100%;
    font-size: 13px;
    padding: 12px 16px;
  }

  /* Empty state */
  .empty-state { padding: 40px 16px; }
  .empty-state .empty-icon { font-size: 48px; }
  .empty-state h3 { font-size: 16px; }
}

/* ---- Small phones (max 480px) ---- */
@media (max-width: 480px) {
  .login-card { padding: 28px 20px; }
  .login-logo { margin-bottom: 28px; }
  .login-logo .logo-icon { width: 56px; height: 56px; font-size: 24px; }
  .login-logo h1 { font-size: 22px; }
  .login-logo p { font-size: 13px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 20px; }
  .stat-card .stat-label { font-size: 11px; }

  .page-header h1 { font-size: 20px; }
  .dashboard-content { padding: 16px 12px; }

  .btn { padding: 12px 20px; font-size: 14px; }

  /* Navbar ultra compact */
  .navbar { padding: 0 12px; height: 52px; }
  .nav-brand .brand-icon { width: 30px; height: 30px; font-size: 13px; }
  .nav-brand h2 { font-size: 15px; }
  .btn-logout { padding: 7px 12px; font-size: 11px; }

  /* Table cards narrower */
  tbody td { padding: 5px 0 5px 40%; font-size: 13px; }
  tbody td::before { font-size: 11px; width: 38%; }

  /* Modal full screen on very small phones */
  .modal {
    max-height: 100vh;
    border-radius: 0;
    min-height: 100vh;
  }
  .modal-overlay { align-items: stretch; }
}

/* ---- Touch device optimizations ---- */
@media (hover: none) and (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-icon { min-width: 44px; min-height: 44px; }
  .btn-logout { min-height: 40px; }
  .tab-btn { min-height: 44px; }
  .status-select { min-height: 40px; }
  .form-input, .form-select { min-height: 48px; font-size: 16px; }

  /* Remove hover effects that don't work well on touch */
  .stat-card:hover { transform: none; box-shadow: var(--shadow-sm); }
  .btn-primary:hover { transform: none; }
  tbody tr:hover { background: transparent; }
}

/* ---- Safe area (notch phones) ---- */
@supports (padding: env(safe-area-inset-bottom)) {
  .modal-footer {
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .navbar {
    padding-left: calc(16px + env(safe-area-inset-left));
    padding-right: calc(16px + env(safe-area-inset-right));
  }
  .toast-container {
    bottom: calc(16px + env(safe-area-inset-bottom));
  }
}
