:root {
  --primary: #1e3a8a;
  --primary-light: #3b82f6;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #f8fafc;
  --card: #ffffff;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e2e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

html { font-size: 16px; }
body { background: var(--bg); color: var(--text); line-height: 1.6; min-height: 100vh; display: flex; flex-direction: column; }

/* Header - Mobile First */
header { 
  background: var(--primary); 
  color: white; 
  padding: 1rem; 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.logo { 
  font-size: 1.1rem; 
  font-weight: 700; 
  display: flex; 
  align-items: center; 
  gap: 8px;
  flex: 1;
}

.logo img { 
  height: 35px; 
  width: auto; 
}

nav { 
  display: flex;
  gap: 5px;
}

nav a { 
  color: white; 
  text-decoration: none; 
  font-weight: 500; 
  opacity: 0.9; 
  transition: 0.2s;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  font-size: 0.9rem;
  white-space: nowrap;
}

nav a:hover { 
  opacity: 1; 
  background: rgba(255,255,255,0.1);
}

/* Container */
.container { 
  max-width: 1200px; 
  margin: 0 auto; 
  padding: 1rem; 
  width: 100%;
}

/* Cards */
.card { 
  background: var(--card); 
  border-radius: 12px; 
  padding: 1.25rem; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
  margin-bottom: 1.5rem; 
}

.card-header { 
  display: flex; 
  justify-content: space-between; 
  align-items: center; 
  margin-bottom: 1rem; 
  padding-bottom: 1rem; 
  border-bottom: 2px solid var(--border);
  flex-wrap: wrap;
  gap: 1rem;
}

.card-title { 
  font-size: 1.1rem; 
  font-weight: 700; 
  color: var(--primary); 
}

/* Buttons - Touch Friendly */
.btn { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  padding: 0.75rem 1.5rem; 
  border-radius: 8px; 
  font-weight: 600; 
  cursor: pointer; 
  border: none; 
  text-decoration: none; 
  transition: 0.2s; 
  font-size: 0.95rem;
  min-height: 44px; /* Touch target minimum */
  text-align: center;
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-warning { background: var(--warning); color: #000; }
.btn-sm { padding: 0.5rem 1rem; font-size: 0.85rem; min-height: 38px; }
.btn-block { width: 100%; display: block; }

.btn:hover { opacity: 0.9; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Forms */
.form-group { margin-bottom: 1rem; }
label { display: block; margin-bottom: 0.5rem; font-weight: 500; font-size: 0.9rem; }

input, select, textarea { 
  width: 100%; 
  padding: 0.75rem; 
  border: 1px solid var(--border); 
  border-radius: 8px; 
  font-size: 1rem; /* Prevents zoom on iOS */
  transition: 0.2s;
  min-height: 44px;
  -webkit-appearance: none;
}

input:focus, select:focus, textarea:focus { 
  outline: none; 
  border-color: var(--primary-light); 
  box-shadow: 0 0 0 3px rgba(59,130,246,0.2); 
}

.form-row { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1rem; 
}

/* Tables - Responsive */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table { 
  width: 100%; 
  border-collapse: collapse; 
  margin-top: 1rem;
  min-width: 600px; /* Force scroll on mobile */
}

th, td { 
  padding: 0.75rem; 
  text-align: left; 
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

th { 
  background: #f1f5f9; 
  font-weight: 600; 
  color: var(--text-light);
  white-space: nowrap;
}

tr:hover { background: #f8fafc; }

/* Stats Grid */
.stats-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1rem; 
  margin-bottom: 2rem; 
}

.stat-card { 
  background: var(--card); 
  padding: 1.25rem; 
  border-radius: 12px; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
  border-left: 4px solid var(--primary); 
}

.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card.danger { border-left-color: var(--danger); }

.stat-value { 
  font-size: 1.75rem; 
  font-weight: 700; 
  color: var(--primary); 
  margin-bottom: 0.25rem; 
}

.stat-label { 
  color: var(--text-light); 
  font-size: 0.85rem; 
}

/* Notification Box */
.notif-box { 
  padding: 1rem; 
  border-radius: 8px; 
  margin: 1rem 0; 
  text-align: center; 
  font-weight: 500;
}

.notif-box.warning { background: #fef3c7; color: #92400e; border: 2px solid var(--warning); }
.notif-box.success { background: #d1fae5; color: #065f46; border: 2px solid var(--success); }
.notif-box.danger { background: #fee2e2; color: #991b1b; border: 2px solid var(--danger); }

/* User Grid */
.user-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 1rem; 
}

.user-card { 
  background: var(--card); 
  padding: 1.25rem; 
  border-radius: 12px; 
  box-shadow: 0 2px 8px rgba(0,0,0,0.05); 
  border-left: 4px solid var(--primary); 
  cursor: pointer; 
  transition: 0.2s; 
  text-decoration: none; 
  color: inherit; 
  display: flex; 
  align-items: center; 
  gap: 1rem; 
  min-height: 80px;
}

.user-card:hover { 
  transform: translateY(-2px); 
  box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}

.user-avatar { 
  width: 50px; 
  height: 50px; 
  background: #e2e8f0; 
  border-radius: 50%; 
  display: flex; 
  align-items: center; 
  justify-content: center; 
  font-size: 1.5rem;
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-info h3 { margin-bottom: 0.25rem; color: var(--text); font-size: 1rem; }
.user-info p { color: var(--text-light); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Flash Messages */
.flash { 
  padding: 1rem; 
  border-radius: 8px; 
  margin-bottom: 1.5rem; 
  font-weight: 500; 
}

.flash.success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.flash.error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* Footer */
footer { 
  background: #0f172a; 
  color: #94a3b8; 
  text-align: center; 
  padding: 1.5rem 1rem; 
  margin-top: auto; 
  font-size: 0.85rem; 
}

/* Utility */
.text-center { text-align: center; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-2 { margin-top: 1rem; }

/* ========== MOBILE RESPONSIVE ========== */
@media (max-width: 768px) {
  html { font-size: 14px; }
  
  header {
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  
  .logo {
    font-size: 1rem;
    justify-content: center;
    width: 100%;
  }
  
  nav {
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }
  
  nav a {
    font-size: 0.85rem;
    padding: 0.4rem 0.6rem;
  }
  
  .container {
    padding: 0.75rem;
  }
  
  .card {
    padding: 1rem;
  }
  
  /* Make buttons full width on mobile */
  .btn {
    width: 100%;
    margin-bottom: 0.5rem;
  }
  
  .btn-sm {
    width: auto;
    margin-bottom: 0;
  }
  
  /* Stack form rows */
  .form-row {
    grid-template-columns: 1fr;
  }
  
  /* Stats grid - 2 columns on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }
  
  .stat-card {
    padding: 1rem;
  }
  
  .stat-value {
    font-size: 1.5rem;
  }
  
  /* User grid - 1 column */
  .user-grid {
    grid-template-columns: 1fr;
  }
  
  /* Card header stack */
  .card-header {
    flex-direction: column;
    align-items: flex-start;
  }
  
  .card-header .btn {
    width: 100%;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  table {
    font-size: 0.8rem;
  }
  
  th, td {
    padding: 0.5rem;
  }
  
  .user-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.25rem;
  }
  
  .notif-box {
    font-size: 0.9rem;
    padding: 0.75rem;
  }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
  header {
    padding: 0.5rem;
  }
  
  .container {
    padding: 0.5rem;
  }
  
  .card {
    padding: 0.75rem;
  }
}