:root {
  --bg: #f8fafc;
  --card: #ffffff;
  --accent: #2563eb;
  --accent2: #f43f5e;
  --accent-light: #dbeafe;
  --muted: #6b7280;
  --success: #16a34a;
  --success-light: #dcfce7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --holiday: #06b6d4;
  --holiday-light: #cffafe;
  --radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  font-family: "Segoe UI", Inter, system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: #1e293b;
  padding: 12px;
  line-height: 1.5;
}

.app {
  max-width: 1400px;
  margin: 0 auto;
}

header {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.brand {
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 15px;
}

.input-group {
  display: flex;
  flex-direction: column;
}

.input-group label {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 5px;
  color: var(--muted);
}

input, select {
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 15px 0;
}

button {
  background: var(--accent);
  color: white;
  border: 0;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
}

button:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

button.secondary {
  background: white;
  color: var(--accent);
  border: 1px solid var(--accent);
}

button.danger {
  background: var(--danger);
}

.view-selector {
  display: flex;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 15px;
}

.view-option {
  flex: 1;
  text-align: center;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s;
}

.view-option.active {
  background: var(--accent);
  color: white;
}

.student-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  align-items: end;
}

h3 {
  margin-top: 0;
  margin-bottom: 15px;
  color: var(--accent);
  display: flex;
  align-items: center;
  gap: 8px;
}

table {
  border-collapse: collapse;
  font-size: 14px;
  table-layout: fixed;
  width: 100%;
}

th, td {
  padding: 8px;
  text-align: center;
  border: 1px solid #e2e8f0;
  word-wrap: break-word;
  position: relative;
}

th {
  background: var(--accent-light);
  color: var(--accent);
  cursor: pointer;
  font-weight: 600;
  position: sticky;
  top: 0;
  user-select: none;
}

.resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  width: 5px;
  height: 100%;
  background: var(--accent);
  cursor: col-resize;
  opacity: 0;
  transition: opacity 0.2s;
}

th:hover .resize-handle {
  opacity: 0.5;
}

.resize-handle:hover, .resize-handle.active {
  opacity: 1 !important;
}

td {
  height: 36px;
}

.success {
  background: var(--success-light);
  color: var(--success);
}

.danger-cell {
  background: var(--danger-light);
  color: var(--danger);
}

.holiday {
  background: var(--holiday-light);
  color: var(--holiday);
}

.scroll-x {
  overflow-x: auto;
  margin: 0 -20px;
  padding: 0 20px;
}

.attendance-percentage {
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 20px;
  font-size: 12px;
}

.high-attendance {
  background: var(--success-light);
  color: var(--success);
}

.medium-attendance {
  background: var(--warning-light);
  color: var(--warning);
}

.low-attendance {
  background: var(--danger-light);
  color: var(--danger);
}

.stats-bar {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  flex-wrap: wrap;
  gap: 10px;
}

.stat-card {
  background: var(--accent-light);
  padding: 12px 16px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 120px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 12px;
  color: var(--muted);
}

.holiday-toggle {
  cursor: pointer;
  transition: all 0.2s;
}

.holiday-toggle:hover {
  transform: scale(1.1);
}

.action-buttons {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--muted);
}

.icon-btn:hover {
  background: #f1f5f9;
  color: var(--accent);
}

.student-row:hover {
  background: #f8fafc;
}

.today-highlight {
  background-color: #fffbeb;
  border: 2px solid #f59e0b;
}

@media (max-width: 768px) {
  .toolbar {
    flex-direction: column;
  }
  
  .toolbar button {
    width: 100%;
    justify-content: center;
  }
  
  .meta-grid {
    grid-template-columns: 1fr;
  }
  
  .student-form {
    grid-template-columns: 1fr;
  }
  
  header {
    padding: 15px;
  }
  
  .brand {
    font-size: 20px;
  }
  
  .card {
    padding: 15px;
  }
  
  .stats-bar {
    flex-direction: column;
    align-items: center;
  }
  
  .view-selector {
    flex-direction: column;
  }
}

@media print {
  body * {
    visibility: hidden;
  }
  #printable, #printable * {
    visibility: visible;
  }
  #printable {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
  }
  .no-print {
    display: none !important;
  }
}

.empty-state {
  text-align: center;
  padding: 30px;
  color: var(--muted);
}

.empty-state i {
  font-size: 48px;
  margin-bottom: 15px;
  color: #cbd5e1;
}

.month-selector {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

.month-selector select {
  width: auto;
  min-width: 120px;
}

.col-resizing {
  cursor: col-resize;
  user-select: none;
}

.notification {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  z-index: 1000;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.notification.success {
  background: var(--success);
}

.notification.error {
  background: var(--danger);
}