/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
       background: #f5f7fa; color: #333; font-size: 14px; }
a { color: #4a90e2; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== Mode Badge ===== */
.badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; }
.badge-admin { background: #e8f4fd; color: #2980b9; }
.badge-elective { background: #eafaf1; color: #27ae60; }
.section-title { font-size: 16px; font-weight: 600; color: #555; margin-bottom: 0.75rem; padding-left: 4px; border-left: 3px solid #4a90e2; }

/* ===== Navbar ===== */
.navbar { background: #2c3e50; color: #fff; padding: 0 24px;
          display: flex; align-items: center; justify-content: space-between; height: 56px;
          box-shadow: 0 2px 8px rgba(0,0,0,.2); position: sticky; top: 0; z-index: 100; }
.nav-brand { font-size: 18px; font-weight: 700; color: #fff; }
.nav-links { display: flex; align-items: center; gap: 16px; }
.nav-links a { color: #ccc; font-size: 14px; }
.nav-links a:hover { color: #fff; text-decoration: none; }
.nav-user { color: #aaa; font-size: 13px; }
.btn-link { background: none; border: none; color: #ccc; cursor: pointer; font-size: 14px; padding: 0; }
.btn-link:hover { color: #fff; }

/* ===== Container ===== */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 16px; }

/* ===== Alerts ===== */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }

/* ===== Page Header ===== */
.page-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h2 { font-size: 22px; color: #2c3e50; }
.page-header p { color: #666; font-size: 13px; }

/* ===== Buttons ===== */
.btn { display: inline-flex; align-items: center; justify-content: center; padding: 8px 16px;
       border-radius: 6px; border: none; cursor: pointer; font-size: 14px; font-weight: 500;
       transition: all .2s; text-decoration: none; }
.btn:hover { opacity: .88; text-decoration: none; }
.btn-primary { background: #4a90e2; color: #fff; }
.btn-secondary { background: #6c757d; color: #fff; }
.btn-success { background: #28a745; color: #fff; }
.btn-danger { background: #dc3545; color: #fff; }
.btn-outline { background: #fff; color: #4a90e2; border: 1px solid #4a90e2; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-lg { padding: 12px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== Card ===== */
.card { background: #fff; border-radius: 8px; padding: 20px; margin-bottom: 20px;
        box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.card h3 { font-size: 16px; margin-bottom: 14px; color: #2c3e50; }

/* ===== Table ===== */
.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px;
         overflow: hidden; box-shadow: 0 1px 4px rgba(0,0,0,.08); }
.table th { background: #f8f9fa; padding: 12px 14px; text-align: left; font-weight: 600;
            color: #555; border-bottom: 2px solid #e9ecef; font-size: 13px; }
.table td { padding: 11px 14px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: #f8f9fa; }

/* ===== Forms ===== */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 5px; font-weight: 500; color: #555; font-size: 13px; }
input[type=text], input[type=password], input[type=date], input[type=email],
input[type=number], select, textarea {
    padding: 8px 12px; border: 1px solid #ddd; border-radius: 6px; font-size: 14px;
    width: 100%; transition: border-color .2s; background: #fff; }
input:focus, select:focus { outline: none; border-color: #4a90e2; box-shadow: 0 0 0 3px rgba(74,144,226,.15); }
.form-inline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.form-inline input, .form-inline select { width: auto; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; align-items: end; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.select-sm { padding: 4px 8px; font-size: 12px; width: auto; }

/* ===== Login Page ===== */
.login-page { background: linear-gradient(135deg, #2c3e50 0%, #4a90e2 100%);
              min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-container { background: #fff; border-radius: 12px; padding: 40px; width: 380px;
                   box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.login-header { text-align: center; margin-bottom: 28px; }
.login-icon { font-size: 48px; margin-bottom: 8px; }
.login-header h1 { font-size: 22px; color: #2c3e50; }
.login-header p { color: #888; font-size: 13px; margin-top: 4px; }
.login-form .form-group { margin-bottom: 16px; }
.login-form input { width: 100%; }
.login-hint { text-align: center; margin-top: 16px; color: #999; }

/* ===== Dashboard Class Grid ===== */
.class-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.class-card { background: #fff; border-radius: 10px; padding: 20px;
              box-shadow: 0 2px 8px rgba(0,0,0,.08); transition: transform .2s, box-shadow .2s; }
.class-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,.12); }
.class-card-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.class-card-header h3 { font-size: 16px; color: #2c3e50; }
.class-card-body { color: #666; font-size: 13px; margin-bottom: 14px; }
.class-card-actions { display: flex; gap: 8px; }
.grade-badge { background: #4a90e2; color: #fff; padding: 3px 8px; border-radius: 4px; font-size: 12px; }

/* ===== Admin Grid ===== */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 16px; }
.admin-card { background: #fff; border-radius: 10px; padding: 24px 16px; text-align: center;
              box-shadow: 0 2px 8px rgba(0,0,0,.08); transition: all .2s; color: #333; }
.admin-card:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.12);
                    text-decoration: none; background: #4a90e2; color: #fff; }
.admin-card-icon { font-size: 36px; margin-bottom: 10px; }
.admin-card-title { font-size: 14px; font-weight: 600; }

/* ===== Attendance ===== */
.attendance-toolbar { display: flex; align-items: center; justify-content: space-between;
                      background: #fff; padding: 14px 16px; border-radius: 8px; margin-bottom: 12px;
                      box-shadow: 0 1px 4px rgba(0,0,0,.08); flex-wrap: wrap; gap: 10px; }
.attendance-actions { display: flex; gap: 10px; }
.attendance-stats { display: flex; gap: 20px; padding: 10px 16px; background: #f8f9fa;
                    border-radius: 6px; margin-bottom: 12px; }
.stat-item { font-size: 14px; font-weight: 600; }
.stat-item.present { color: #28a745; }
.stat-item.absent { color: #dc3545; }
.stat-item.leave { color: #fd7e14; }
.attendance-list { background: #fff; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.08); overflow: hidden; }
.attendance-row { display: flex; align-items: center; justify-content: space-between;
                  padding: 12px 16px; border-bottom: 1px solid #f0f0f0; }
.attendance-row:last-child { border-bottom: none; }
.attendance-row:hover { background: #f8f9fa; }
.student-info { display: flex; align-items: center; gap: 10px; min-width: 160px; }
.student-no { background: #e9ecef; color: #666; width: 26px; height: 26px; border-radius: 50%;
              display: flex; align-items: center; justify-content: center; font-size: 12px; }
.student-name { font-weight: 500; }
.status-buttons { display: flex; gap: 8px; }
.status-label { display: flex; align-items: center; gap: 4px; padding: 6px 12px; border-radius: 20px;
                cursor: pointer; border: 2px solid #e9ecef; transition: all .15s; font-size: 13px; }
.status-label input[type=radio] { display: none; }
.status-label:has(input:checked).出勤 { background: #d4edda; border-color: #28a745; color: #155724; }
.status-label:has(input:checked).缺勤 { background: #f8d7da; border-color: #dc3545; color: #721c24; }
.status-label:has(input:checked).请假 { background: #fff3cd; border-color: #fd7e14; color: #856404; }
.status-label:hover { border-color: #adb5bd; }

/* ===== Stats ===== */
.stats-row { display: flex; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.stat-card { background: #fff; border-radius: 8px; padding: 16px 20px; text-align: center;
             box-shadow: 0 1px 4px rgba(0,0,0,.08); min-width: 100px; flex: 1; }
.stat-card.present { border-top: 3px solid #28a745; }
.stat-card.absent { border-top: 3px solid #dc3545; }
.stat-card.leave { border-top: 3px solid #fd7e14; }
.stat-card.total { border-top: 3px solid #4a90e2; }
.stat-num { font-size: 28px; font-weight: 700; color: #2c3e50; }
.stat-label { font-size: 12px; color: #888; margin-top: 4px; }
.progress-bar { background: #e9ecef; border-radius: 4px; height: 8px; width: 80px;
                display: inline-block; vertical-align: middle; margin-right: 6px; overflow: hidden; }
.progress-fill { background: #28a745; height: 100%; border-radius: 4px; transition: width .3s; }

/* ===== Badges ===== */
.badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 600; }
.badge-present { background: #d4edda; color: #155724; }
.badge-absent { background: #f8d7da; color: #721c24; }
.badge-leave { background: #fff3cd; color: #856404; }
.badge-admin { background: #cce5ff; color: #004085; }
.badge-teacher { background: #d4edda; color: #155724; }

/* ===== Modal ===== */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5);
         align-items: center; justify-content: center; z-index: 1000; }
.modal-overlay.active { display: flex; }
.modal-content { background: #fff; border-radius: 10px; padding: 28px; width: 420px;
                 max-width: 95vw; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-content h3 { margin-bottom: 18px; font-size: 18px; }

/* ===== Misc ===== */
.text-muted { color: #888; }
.empty-state { text-align: center; padding: 40px; color: #888; }
.class-selector { display: flex; flex-wrap: wrap; gap: 8px; }

/* ===== Footer ===== */
.site-footer { text-align: center; padding: 16px; font-size: 12px; color: #aaa;
               border-top: 1px solid #e8e8e8; margin-top: 32px; background: #fff; }
.footer-sep { margin: 0 8px; }
.login-page .site-footer { position: fixed; bottom: 0; left: 0; width: 100%;
                            margin-top: 0; background: transparent; border-top: none; color: rgba(255,255,255,.5); }
