/* ==========================================================================
   Ummu Zavaya IT Lab Portal - Modern Styling
   Color Theme: Emerald Green, Slate & Gold Accents
   ========================================================================== */

:root {
  /* Brand Palette */
  --primary: #059669;        /* Emerald 600 */
  --primary-hover: #047857;  /* Emerald 700 */
  --primary-light: #d1fae5;  /* Emerald 100 */
  --primary-dark: #064e3b;   /* Emerald 900 */
  --accent-gold: #d97706;    /* Amber 600 */
  --accent-gold-light: #fef3c7;

  /* Neutrals & Slate */
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;     /* Slate 900 */
  --bg-sidebar-active: #1e293b;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border-color: #e2e8f0;
  --border-focus: #10b981;

  /* Status Colors */
  --status-success: #10b981;
  --status-success-bg: #ecfdf5;
  --status-warning: #f59e0b;
  --status-warning-bg: #fffbeb;
  --status-orange: #ea580c;
  --status-orange-bg: #fff7ed;
  --status-danger: #ef4444;
  --status-danger-bg: #fef2f2;
  --status-info: #0284c7;
  --status-info-bg: #f0f9ff;

  /* Sizing & Radius */
  --sidebar-width: 260px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.05);

  /* Fonts */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-heading: 'Outfit', var(--font-sans);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  color: var(--text-main);
}

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

a:hover {
  text-decoration: underline;
}

/* Utilities */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--status-success); }
.text-warning { color: var(--status-warning); }
.text-orange { color: var(--status-orange); }
.text-danger { color: var(--status-danger); }
.bg-success { background-color: var(--status-success); }
.bg-warning { background-color: var(--status-warning); }
.bg-orange { background-color: var(--status-orange); }
.bg-danger { background-color: var(--status-danger); }
.py-4 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-5 { padding-top: 2.5rem; padding-bottom: 2.5rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 8px rgba(5, 150, 105, 0.25);
}

.btn-secondary {
  background-color: #ffffff;
  color: var(--text-main);
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-outline-danger {
  background-color: transparent;
  color: var(--status-danger);
  border-color: #fecaca;
}
.btn-outline-danger:hover {
  background-color: var(--status-danger-bg);
  border-color: var(--status-danger);
}

.btn-outline-light {
  background: rgba(255, 255, 255, 0.08);
  color: #cbd5e1;
  border: 1px solid rgba(255, 255, 255, 0.15);
}
.btn-outline-light:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

.btn-danger {
  background-color: var(--status-danger);
  color: #ffffff;
}
.btn-danger:hover {
  background-color: #dc2626;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-text-link {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0;
}
.btn-text-link:hover {
  text-decoration: underline;
}

/* Action Icon Buttons inside tables */
.btn-icon-action {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #ffffff;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  margin-left: 4px;
}
.btn-icon-action:hover {
  color: var(--primary);
  border-color: var(--primary);
  background-color: var(--primary-light);
}
.btn-icon-action.delete-action:hover {
  color: var(--status-danger);
  border-color: var(--status-danger);
  background-color: var(--status-danger-bg);
}

/* ==========================================================================
   AUTHENTICATION VIEW
   ========================================================================== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: linear-gradient(135deg, #064e3b 0%, #0f172a 100%);
  position: relative;
}

.auth-wrapper::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background-image: radial-gradient(rgba(16, 185, 129, 0.15) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem 1.35rem;
  position: relative;
  z-index: 1;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  margin-bottom: 1.15rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}

.brand-icon {
  width: 42px;
  height: 42px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #ffffff;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.25);
  flex-shrink: 0;
}

.brand-text h1 {
  font-size: 1.15rem;
  line-height: 1.2;
  color: var(--primary-dark);
}
.brand-text span {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.4px;
}

.form-title {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}
.form-subtitle {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1.25rem;
}
.form-group label {
  display: block;
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}
.form-group label i {
  color: var(--primary);
  margin-right: 0.35rem;
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}
.label-row label {
  margin-bottom: 0;
}

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text-main);
  background-color: #ffffff;
  transition: all 0.2s ease;
}

.form-control:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.input-hint {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}
.input-hint code {
  background: #f1f5f9;
  padding: 2px 4px;
  border-radius: 4px;
  color: var(--primary-dark);
  font-weight: 600;
}

.password-input-group {
  position: relative;
}
.password-input-group input {
  padding-right: 2.5rem;
}
.toggle-password-btn {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0.25rem;
}
.toggle-password-btn:hover {
  color: var(--text-main);
}

.auth-footer-notice {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: center;
}

.button-row {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

/* ==========================================================================
   APP SHELL LAYOUT (Sidebar + Main)
   ========================================================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.25s ease;
}

.sidebar-header {
  height: var(--header-height);
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-symbol {
  font-size: 1.6rem;
  color: #34d399; /* Emerald 400 */
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  display: block;
}

.brand-sub {
  font-size: 0.65rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 1px;
  display: block;
}

.mobile-close-btn {
  display: none;
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1.25rem;
  cursor: pointer;
}

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

.nav-category {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  font-weight: 700;
  padding: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}
.nav-category:first-child {
  margin-top: 0;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-size: 0.875rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 0.25rem;
}

.nav-item i {
  font-size: 1rem;
  width: 20px;
  text-align: center;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.nav-item:hover {
  background: var(--bg-sidebar-active);
  color: #ffffff;
}
.nav-item:hover i {
  color: #34d399;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(5, 150, 105, 0.85) 0%, rgba(5, 150, 105, 0.5) 100%);
  color: #ffffff;
  font-weight: 600;
  border-left: 3px solid #34d399;
}
.nav-item.active i {
  color: #ffffff;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.sync-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #94a3b8;
  margin-bottom: 0.75rem;
}

.sync-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-success);
  box-shadow: 0 0 6px var(--status-success);
}

.btn-refresh {
  width: 100%;
}

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

/* Top Header */
.top-header {
  height: var(--header-height);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 90;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.mobile-menu-btn {
  display: none;
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem;
  font-size: 1.1rem;
  color: var(--text-main);
  cursor: pointer;
}

.page-title-group h2 {
  font-size: 1.3rem;
  line-height: 1.2;
}
.page-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  background: #f1f5f9;
  padding: 0.35rem 0.75rem 0.35rem 0.4rem;
  border-radius: 20px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  overflow: hidden;
}

.user-meta {
  display: flex;
  flex-direction: column;
}
.user-name {
  font-size: 0.75rem;
  font-weight: 600;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-admin {
  background: var(--accent-gold-light);
  color: var(--accent-gold);
}
.badge-super-admin {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border: 1px solid #f59e0b;
}
.badge-user {
  background: #e2e8f0;
  color: #475569;
}
.badge-current {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid #a7f3d0;
}
.badge-completed {
  background: var(--status-info-bg);
  color: var(--status-info);
  border: 1px solid #bae6fd;
}
.badge-terminated, .badge-not-working {
  background: var(--status-danger-bg);
  color: var(--status-danger);
  border: 1px solid #fecaca;
}
.badge-past {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #cbd5e1;
}
.badge-no-issue {
  background: var(--status-success-bg);
  color: var(--status-success);
  border: 1px solid #a7f3d0;
}
.badge-need-service {
  background: var(--status-warning-bg);
  color: var(--status-warning);
  border: 1px solid #fde68a;
}
.badge-need-maintenance {
  background: var(--status-orange-bg);
  color: var(--status-orange);
  border: 1px solid #fed7aa;
}

/* Main Content Area */
.page-content {
  flex: 1;
  padding: 1.75rem;
}

.tab-view {
  display: none;
}
.tab-view.active {
  display: block;
  animation: fadeIn 0.2s ease-in-out;
}

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

/* ==========================================================================
   CARDS & KPI STATS
   ========================================================================== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.stat-card {
  background: #ffffff;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  cursor: pointer;
  transition: all 0.2s ease;
}
.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
}

.stat-students .stat-icon { background: #ecfdf5; color: var(--primary); }
.stat-staff .stat-icon { background: #f0fdf4; color: #16a34a; }
.stat-batches .stat-icon { background: #eff6ff; color: #2563eb; }
.stat-devices .stat-icon { background: #faf5ff; color: #9333ea; }

.stat-info {
  display: flex;
  flex-direction: column;
}
.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1.2;
}
.stat-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.card-header h3 i {
  color: var(--primary);
}

.card-body {
  padding: 1.25rem;
}

/* Device Health Bars Widget */
.device-health-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.health-item {
  background: #f8fafc;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.health-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-bottom: 0.35rem;
}
.health-item .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}
.health-item strong {
  font-size: 1.25rem;
}

.alert-list-container {
  max-height: 220px;
  overflow-y: auto;
}

.alert-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-size: 0.825rem;
}
.alert-item.service-urgent {
  background: var(--status-orange-bg);
  border-left: 3px solid var(--status-orange);
}
.alert-item.broken-urgent {
  background: var(--status-danger-bg);
  border-left: 3px solid var(--status-danger);
}

/* Recent Batches List Widget */
.recent-batches-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 310px;
  overflow-y: auto;
}

.dash-batch-card {
  padding: 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #f8fafc;
}
.dash-batch-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.35rem;
}
.dash-batch-title {
  font-weight: 600;
  font-size: 0.9rem;
}
.dash-batch-progress {
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 0.25rem;
}

/* ==========================================================================
   TOOLBARS, SEARCH & FILTERS
   ========================================================================== */
.section-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
}

.toolbar-left, .toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.search-box {
  position: relative;
  min-width: 280px;
}
.search-box i.fa-magnifying-glass {
  position: absolute;
  left: 0.85rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-light);
  font-size: 0.85rem;
}
.search-box input {
  width: 100%;
  padding: 0.55rem 2.2rem 0.55rem 2.3rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}
.search-box input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}
.clear-search-btn {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 0;
}
.clear-search-btn:hover {
  color: var(--text-main);
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.filter-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.filter-group select {
  padding: 0.5rem 0.75rem;
  font-size: 0.825rem;
  min-width: 130px;
}

.table-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
  padding: 0 0.25rem;
}
.count-badge {
  background: #e2e8f0;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 600;
  color: #475569;
}

/* ==========================================================================
   DATA TABLES
   ========================================================================== */
.table-card {
  box-shadow: var(--shadow-sm);
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
  vertical-align: middle;
}

.data-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Table Avatar thumbnail */
.table-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background-color: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  border: 1px solid var(--border-color);
}

/* ==========================================================================
   BATCHES VIEW (Card Grid)
   ========================================================================== */
.batches-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1.25rem;
}

.batch-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
}
.batch-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.batch-card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #f8fafc;
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
}

.batch-title-area {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.batch-number {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.batch-card-body {
  padding: 1.25rem;
  flex: 1;
}

.batch-meta-row {
  display: flex;
  gap: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.85rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px dashed var(--border-color);
}

.batch-section-block {
  margin-bottom: 0.85rem;
}
.batch-section-block h5 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.batch-section-block p {
  font-size: 0.825rem;
  color: var(--text-main);
  background: #f8fafc;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  white-space: pre-line;
}

.batch-card-footer {
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
}

/* ==========================================================================
   DEVICES SUMMARY PILLS
   ========================================================================== */
.device-pill-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat-pill {
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--border-color);
  background: #ffffff;
}
.stat-pill.pill-ok { color: var(--status-success); border-color: #a7f3d0; background: #ecfdf5; }
.stat-pill.pill-service { color: var(--status-warning); border-color: #fde68a; background: #fffbeb; }
.stat-pill.pill-maint { color: var(--status-orange); border-color: #fed7aa; background: #fff7ed; }
.stat-pill.pill-broken { color: var(--status-danger); border-color: #fecaca; background: #fef2f2; }

/* ==========================================================================
   MODALS
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
}

.modal-dialog {
  background: #ffffff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 550px;
  display: flex;
  flex-direction: column;
  animation: modalPop 0.2s ease-out;
}

.modal-dialog.modal-sm { max-width: 420px; }
.modal-dialog.modal-md { max-width: 620px; }
.modal-dialog.modal-lg { max-width: 820px; }

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.96); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-header h3 {
  font-size: 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.modal-header h3 i {
  color: var(--primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
}
.modal-close-btn:hover {
  color: var(--text-main);
}

.modal-body {
  padding: 1.5rem;
}

.modal-scrollable {
  max-height: calc(85vh - 140px);
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #f8fafc;
  border-bottom-left-radius: var(--radius-lg);
  border-bottom-right-radius: var(--radius-lg);
}

/* Form Grid helpers */
.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
}

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

.form-section-title {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: var(--primary-dark);
  border-bottom: 2px solid var(--primary-light);
  padding-bottom: 0.35rem;
  margin-top: 1.25rem;
  margin-bottom: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.form-section-title:first-child {
  margin-top: 0;
}

/* Checkbox Grid for Print Field Selector */
.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-top: 1rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background: #f8fafc;
  cursor: pointer;
  font-size: 0.85rem;
  user-select: none;
  transition: all 0.15s ease;
}
.checkbox-label:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}
.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.field-counter-bar {
  display: flex;
  justify-content: flex-end;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.field-counter-bar strong {
  color: var(--primary);
}

/* Alert Boxes */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}
.alert-info {
  background: var(--status-info-bg);
  border: 1px solid #bae6fd;
  color: #0369a1;
}
.alert-info i {
  color: var(--status-info);
  font-size: 1rem;
  margin-top: 2px;
}

/* Photo Upload & Preview Component */
.photo-upload-container {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  background: #f8fafc;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
  margin-top: 0.35rem;
}

.photo-preview-box {
  width: 78px;
  height: 78px;
  border-radius: var(--radius-md);
  border: 2px solid var(--border-color);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.photo-preview-box img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-box i {
  font-size: 2rem;
  color: var(--text-light);
}

.photo-inputs-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.file-upload-btn-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.file-upload-label {
  cursor: pointer;
  margin-bottom: 0;
  background: #ffffff;
}
.file-upload-label:hover {
  background: #f1f5f9;
}

.hidden-file-input {
  display: none !important;
}

.url-divider {
  display: flex;
  align-items: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  margin: 0.15rem 0;
}
.url-divider::before, .url-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border-color);
}
.url-divider span {
  padding: 0 0.5rem;
}

/* View Profile Modal Styling */
.profile-view-header {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.25rem;
}

.profile-large-photo {
  width: 90px;
  height: 90px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 2px solid var(--border-color);
  background-color: #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  color: var(--text-light);
}

.profile-meta h3 {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.profile-details-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.detail-item {
  display: flex;
  flex-direction: column;
}
.detail-item label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.03em;
  margin-bottom: 0.15rem;
}
.detail-item span, .detail-item p {
  font-size: 0.875rem;
  color: var(--text-main);
  font-weight: 500;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */
.toast-container {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 280px;
  max-width: 380px;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: #ffffff;
  animation: slideInRight 0.25s ease-out;
  transition: opacity 0.3s ease;
}

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

.toast.toast-success { background: #065f46; border-left: 4px solid #34d399; }
.toast.toast-error { background: #991b1b; border-left: 4px solid #f87171; }
.toast.toast-warning { background: #92400e; border-left: 4px solid #fbbf24; }
.toast.toast-info { background: #075985; border-left: 4px solid #38bdf8; }

/* ==========================================================================
   PRINT / PDF EXPORT CONTAINER (A4 LANDSCAPE)
   ========================================================================== */
.print-container {
  display: none;
}

@media print {
  @page {
    size: A4 landscape;
    margin: 8mm 10mm;
  }

  /* Hide entire web UI */
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 11pt !important;
  }

  .auth-wrapper,
  .app-layout,
  .toast-container,
  .modal-backdrop {
    display: none !important;
  }

  /* Show only print container */
  .print-container {
    display: block !important;
    width: 100% !important;
  }

  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 8px;
    margin-bottom: 12px;
    border-bottom: 2px solid #000000;
  }

  .print-brand h2 {
    font-size: 16pt;
    font-weight: 800;
    margin-bottom: 2px;
    color: #000000;
  }
  .print-brand h3 {
    font-size: 12pt;
    font-weight: 600;
    color: #333333;
  }

  .print-meta {
    text-align: right;
    font-size: 9pt;
    line-height: 1.4;
  }

  .print-table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin-bottom: 15px;
  }

  .print-table th, .print-table td {
    border: 1px solid #333333 !important;
    padding: 6px 8px !important;
    font-size: 9.5pt !important;
    vertical-align: top !important;
  }

  .print-table th {
    background-color: #f0f0f0 !important;
    font-weight: bold !important;
    text-align: left !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-table tr {
    page-break-inside: avoid;
  }

/* ==========================================================================
   IT TIMETABLE & GROUP ALLOCATION STYLES
   ========================================================================== */

/* Day Badges */
.day-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 700;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.day-mon { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.day-tue { background: #ede9fe; color: #6d28d9; border: 1px solid #ddd6fe; }
.day-wed { background: #ccfbf1; color: #0f766e; border: 1px solid #99f6e4; }
.day-thu { background: #ffedd5; color: #c2410c; border: 1px solid #fed7aa; }
.day-fri { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.day-sat { background: #fae8ff; color: #a21caf; border: 1px solid #f5d0fe; }
.day-sun { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }

/* Participant Pills in Timetable Table */
.participants-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-width: 320px;
}

.participant-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1e293b;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  line-height: 1.2;
}

.participant-pill i {
  font-size: 0.65rem;
  color: var(--primary);
}

/* ==========================================================================
   RESPONSIVE DESIGN (Tablets & Mobile Phones)
   ========================================================================== */
@media (max-width: 992px) {
  .sidebar {
    transform: translateX(-100%);
  }

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

  .mobile-close-btn {
    display: block;
  }

  .sidebar-backdrop {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 95;
  }

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

  .mobile-menu-btn {
    display: inline-flex;
  }

  /* Completely hide subtitle descriptions on tablets and mobile screens */
  .page-subtitle {
    display: none !important;
  }

  .header-left {
    flex: 1;
    min-width: 0;
    gap: 0.65rem;
  }

  .page-title-group {
    min-width: 0;
    flex: 1;
  }

  .page-title-group h2 {
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
    margin: 0;
  }

  .header-right {
    gap: 0.5rem;
    flex-shrink: 0;
  }

  .form-row-3, .form-row-4 {
    grid-template-columns: 1fr 1fr;
  }

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

@media (max-width: 640px) {
  .page-content {
    padding: 1rem;
  }

  .top-header {
    padding: 0 0.75rem;
    height: 58px;
    gap: 0.5rem;
  }

  .header-left {
    flex: 1;
    min-width: 0;
    gap: 0.5rem;
  }

  .mobile-menu-btn {
    padding: 0.35rem 0.55rem;
    font-size: 1rem;
    flex-shrink: 0;
  }

  .page-title-group {
    flex: 1;
    min-width: 0;
  }

  .page-title-group h2 {
    font-size: 1.05rem;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
    line-height: 1.2;
  }

  /* Completely hide all subtitles on mobile */
  .page-subtitle {
    display: none !important;
  }

  .user-pill {
    padding: 0.2rem 0.4rem;
    gap: 0.3rem;
    flex-shrink: 0;
  }

  /* Hide long email inside user pill on mobile to prevent crowding out the header title */
  .user-meta .user-name {
    display: none !important;
  }

  .user-meta .badge {
    padding: 1px 6px;
    font-size: 0.65rem;
  }

  .header-right {
    gap: 0.35rem;
  }

  .header-right .btn-sm {
    padding: 0.3rem 0.55rem;
  }

  .hide-mobile {
    display: none;
  }

  .form-row-2, .form-row-3, .form-row-4, .profile-details-grid {
    grid-template-columns: 1fr;
  }

  .device-health-bars {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .section-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-left, .toolbar-right {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }

  .search-box {
    min-width: 100%;
  }

  .filter-group {
    width: 100%;
    justify-content: space-between;
  }

  .filter-group select {
    flex: 1;
  }

  .btn {
    width: 100%;
  }

  .btn-icon-action {
    width: 36px;
    height: 36px;
  }
}
