:root {
  --primary: #1e40af;
  --primary-hover: #1d4ed8;
  --bg-main: #f8fafc;
  --card-bg: #ffffff;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --warning: #f59e0b;
  --danger: #dc2626;
  --radius: 10px;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
body { background-color: var(--bg-main); color: var(--text-main); font-size: 15px; line-height: 1.5; padding-bottom: 70px; }

.app-container { max-width: 1024px; margin: 0 auto; padding: 12px; transition: max-width 0.25s ease, padding 0.25s ease; }
.app-container.wide-mode { max-width: 98% !important; width: 98% !important; padding: 8px 12px !important; }

/* Header */
.app-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: #ffffff; border-radius: var(--radius); margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.05); }
.header-left { display: flex; align-items: center; gap: 12px; }
.school-logo { font-size: 28px; }
.header-title { font-size: 18px; font-weight: 700; color: var(--primary); letter-spacing: -0.5px; }
.header-subtitle { font-size: 12px; color: var(--text-muted); }
.header-right { display: flex; align-items: center; gap: 8px; }

.badge { display: inline-block; padding: 4px 8px; font-size: 12px; font-weight: 600; border-radius: 9999px; }
.badge-online { background: #dcfce7; color: #166534; }
.badge-offline { background: #fee2e2; color: #991b1b; }
.user-box { display: flex; align-items: center; gap: 8px; }
.user-name { font-weight: 600; font-size: 13px; color: var(--primary); }
.btn-logout { background: transparent; border: 1px solid var(--border); border-radius: 6px; padding: 4px 8px; font-size: 12px; cursor: pointer; color: var(--text-muted); }

/* Navigation Tabs */
.nav-tabs { display: flex; gap: 6px; margin-bottom: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tab-btn { flex: 1; padding: 10px 14px; background: #ffffff; border: 1px solid var(--border); border-radius: var(--radius); font-weight: 600; font-size: 14px; cursor: pointer; text-align: center; white-space: nowrap; transition: all 0.2s; color: var(--text-muted); }
.tab-btn.active { background: var(--primary); color: #ffffff; border-color: var(--primary); }

/* Cards */
.card { background: var(--card-bg); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; border: 1px solid var(--border); box-shadow: 0 1px 3px rgba(0,0,0,0.03); }
.section-title { font-size: 16px; font-weight: 700; color: #1e293b; margin-bottom: 12px; border-bottom: 1.5px solid #f1f5f9; padding-bottom: 6px; }
.help-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* Duty Banner */
.duty-banner-card { background: linear-gradient(135deg, #eff6ff 0%, #e0e7ff 100%); border: 1.5px solid #bfdbfe; }
.week-picker-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.deadline-tag { font-size: 12px; font-weight: 600; color: #b45309; background: #fef3c7; padding: 4px 8px; border-radius: 6px; }
.duty-assigned-box { background: #ffffff; padding: 12px; border-radius: 8px; font-size: 15px; font-weight: 600; color: #1e3a8a; border: 1px solid #cbd5e1; }

/* Stepper Controls (Mobile +/- buttons) */
.stepper-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.stepper-item { background: #f8fafc; padding: 10px; border-radius: 8px; border: 1px solid var(--border); text-align: center; }
.stepper-item label { display: block; font-size: 12px; font-weight: 600; margin-bottom: 6px; color: #334155; }
.stepper-control { display: flex; justify-content: center; align-items: center; gap: 6px; }
.btn-step { width: 34px; height: 34px; border-radius: 6px; border: 1px solid #cbd5e1; background: #ffffff; font-size: 18px; font-weight: bold; cursor: pointer; color: var(--primary); display: flex; align-items: center; justify-content: center; touch-action: manipulation; }
.btn-step:active { background: #e2e8f0; }
.step-val { width: 44px; height: 34px; text-align: center; font-size: 16px; font-weight: 700; border: 1px solid #cbd5e1; border-radius: 6px; }

/* Forms */
.form-group { margin-bottom: 12px; }
.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.flex-1 { flex: 1; min-width: 200px; }
.form-control { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; }
.form-control-inline { padding: 6px 10px; border: 1px solid #cbd5e1; border-radius: 6px; font-size: 14px; background: #ffffff; }

/* Checkboxes for GVCN */
.checkbox-days-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 10px 0; }
@media (min-width: 600px) { .checkbox-days-grid { grid-template-columns: repeat(6, 1fr); } }
.day-check { display: flex; align-items: center; gap: 6px; background: #f8fafc; padding: 8px; border-radius: 6px; border: 1px solid var(--border); font-weight: 600; font-size: 13px; cursor: pointer; }
.day-check input { width: 18px; height: 18px; accent-color: var(--danger); }
.gvcn-summary-line { font-size: 13px; font-weight: 600; margin-top: 8px; }

/* Buttons */
.btn { padding: 10px 16px; border-radius: 8px; font-size: 14px; font-weight: 600; cursor: pointer; border: none; transition: 0.15s; }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-primary { background: var(--primary); color: #ffffff; }
.btn-primary:active { background: var(--primary-hover); }
.btn-secondary { background: #e2e8f0; color: #1e293b; }
.btn-success { background: var(--success); color: #ffffff; }
.btn-warning { background: var(--warning); color: #ffffff; }
.btn-outline { background: #ffffff; border: 1.5px solid var(--border); color: #334155; }
.btn-block { width: 100%; }

/* Sticky bottom bar */
.form-action-bar { position: fixed; bottom: 0; left: 0; right: 0; background: #ffffff; padding: 10px 16px; display: flex; gap: 10px; box-shadow: 0 -2px 10px rgba(0,0,0,0.06); border-top: 1px solid var(--border); z-index: 100; max-width: 1024px; margin: 0 auto; }
.form-action-bar button { flex: 1; }

/* Quick Login Pills */
.pill-group { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { background: #f1f5f9; border: 1px solid #cbd5e1; border-radius: 9999px; padding: 4px 10px; font-size: 12px; font-weight: 600; cursor: pointer; }
.pill:hover { background: #e2e8f0; }

/* Tables & Excel-like Gridlines */
.table-responsive { overflow-x: auto; margin-top: 10px; border-radius: 6px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; text-align: left; }
.table th, .table td { padding: 6px 8px; border-bottom: 1px solid var(--border); }
.table th { background: #f1f5f9; font-weight: 600; color: #475569; }

/* Gridlines đặc biệt cho Bảng Chi Tiết 18 Cột Mẫu Trường (Excel Grid) */
.detail-18-table {
  width: 100%;
  border-collapse: collapse !important;
  border: 1.5px solid #94a3b8 !important;
  background-color: #ffffff;
}
.detail-18-table th,
.detail-18-table td {
  border: 1px solid #cbd5e1 !important; /* Đường lưới kẻ dọc và ngang rõ nét như Excel */
  padding: 4px 5px !important;
  vertical-align: middle !important;
  line-height: 1.25;
}
.detail-18-table thead th {
  border: 1px solid #94a3b8 !important;
  border-bottom: 2px solid #64748b !important;
  font-weight: 700 !important;
  color: #1e293b;
  font-size: 11.5px;
  text-align: center;
}
/* Dóng hàng nổi bật khi di chuột qua bất kỳ ô nào (Row tracking guide) */
.detail-18-table tbody tr:hover td {
  background-color: #e0f2fe !important;
  border-top: 1px solid #0284c7 !important;
  border-bottom: 1px solid #0284c7 !important;
}
/* Phân cách viền đậm hơn cho các cột mốc chính */
.detail-18-table th.col-sep,
.detail-18-table td.col-sep {
  border-right: 2px solid #64748b !important;
}
/* Màu nền xen kẽ để dóng hàng ngang dễ dàng */
.detail-18-table tbody tr:nth-child(even) td {
  background-color: #fbfcfe;
}
.detail-18-table tbody tr:nth-child(odd) td {
  background-color: #ffffff;
}
.ranking-table tr.top-1 { background: #fef9c3; font-weight: 700; }
.ranking-table tr.top-2 { background: #f1f5f9; }

/* QR Code Module Styles */
.qr-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; margin-top: 14px; }
.qr-card-item { background: #ffffff; border: 1.5px solid var(--border); border-radius: 8px; padding: 12px; text-align: center; position: relative; box-shadow: 0 1px 3px rgba(0,0,0,0.03); }
.qr-card-item:hover { border-color: var(--primary); }
.qr-class-title { font-size: 16px; font-weight: 700; color: var(--primary); margin: 6px 0 2px 0; }
.qr-grade-sub { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.qr-img-thumb { width: 140px; height: 140px; object-fit: contain; margin: 0 auto; display: block; border: 1px solid #f1f5f9; border-radius: 6px; }
.qr-actions-row { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.modal-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.5); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-content { background: #ffffff; border-radius: 12px; max-width: 500px; width: 100%; max-height: 90vh; overflow-y: auto; padding: 20px; box-shadow: 0 10px 25px rgba(0,0,0,0.2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
.modal-title { font-size: 17px; font-weight: 700; color: var(--primary); }
.btn-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); }
.qr-preview-img { width: 100%; max-width: 320px; height: auto; display: block; margin: 0 auto 16px auto; border-radius: 8px; border: 1px solid var(--border); box-shadow: 0 4px 8px rgba(0,0,0,0.08); }
.qr-status-badge { display: inline-block; padding: 2px 8px; border-radius: 9999px; font-size: 11px; font-weight: 700; }
.qr-status-active { background: #dcfce7; color: #15803d; }
.qr-status-regenerated { background: #fef3c7; color: #b45309; }
.qr-status-inactive { background: #fee2e2; color: #b91c1c; }
.alert-banner { padding: 12px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; line-height: 1.4; display: flex; align-items: center; gap: 10px; }
.alert-warning { background: #fffbeb; border: 1.5px solid #fde68a; color: #92400e; }
.alert-success { background: #ecfdf5; border: 1.5px solid #a7f3d0; color: #065f46; }
.alert-danger { background: #fef2f2; border: 1.5px solid #fecaca; color: #991b1b; }
