* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-main: #f8fafc;
    --bg-card: #ffffff;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

body {
    font-family: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 0;
    min-height: 100vh;
}

.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 24px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 32px;
}

header h1 {
    color: var(--text-primary);
    font-size: 1.875rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 20px;
}

/* Navigation */
.main-nav {
    display: inline-flex;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    gap: 4px;
}

.nav-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.nav-btn:hover {
    background: var(--bg-main);
    color: var(--text-primary);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: var(--shadow-sm);
}

/* Pages */
.page {
    display: none;
}

.page.active {
    display: block;
}

/* Sections */
section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

section h2 {
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

h3 {
    color: var(--text-primary);
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 12px;
}

/* Summary Cards */
.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.summary-card {
    background: linear-gradient(135deg, #f8fafc 0%, #ffffff 100%);
    padding: 24px;
    border-radius: var(--radius-md);
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.summary-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.summary-value {
    display: block;
    color: var(--text-primary);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* Forms */
.form-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

input[type="text"],
input[type="number"],
input[type="date"],
select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    background: var(--bg-card);
    color: var(--text-primary);
    transition: all 0.15s ease;
    flex: 1;
    min-width: 150px;
    height: 42px;
}

input:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--text-secondary);
    color: white;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.875rem;
    height: auto;
}

.btn-add-entry {
    margin-top: 12px;
    width: 100%;
    background: var(--bg-main);
    color: var(--text-secondary);
    border: 1px dashed var(--border);
}

.btn-add-entry:hover {
    background: var(--bg-card);
    border-color: var(--primary);
    color: var(--primary);
}

/* Subject List */
.subjects-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.subject-item {
    background: var(--bg-card);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s ease;
}

.subject-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
}

.subject-item > span {
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
}

.subject-item-actions {
    display: flex;
    gap: 6px;
}

.btn-edit,
.btn-delete,
.btn-thresholds {
    padding: 6px 12px;
    font-size: 0.8125rem;
    height: auto;
}

.btn-edit {
    background: var(--bg-main);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-edit:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-thresholds {
    background: var(--bg-main);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-thresholds:hover {
    background: var(--warning);
    color: white;
    border-color: var(--warning);
}

.btn-delete {
    background: var(--bg-main);
    color: var(--danger);
    border: 1px solid var(--border);
}

.btn-delete:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}

/* Weekly Schedule */
.schedule-days {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 14px;
}

.schedule-day {
    background: var(--bg-card);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.schedule-day.today {
    border-color: var(--primary);
    background: linear-gradient(135deg, #eef2ff 0%, #ffffff 100%);
}

.schedule-day h3 {
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.schedule-entries {
    margin-bottom: 12px;
}

.schedule-entry {
    background: var(--bg-main);
    padding: 12px;
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.schedule-entry:hover {
    border-color: var(--border);
}

.schedule-entry-info {
    flex: 1;
}

.schedule-entry-subject {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.schedule-entry-hours {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.schedule-entry-form {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.schedule-entry-form select,
.schedule-entry-form input {
    flex: 1;
    min-width: 80px;
    height: 36px;
    font-size: 0.875rem;
}

/* Attendance Marking */
.date-selector {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.date-selector label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.attendance-recommendations {
    margin-bottom: 24px;
}

.attendance-item {
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.attendance-item:hover {
    box-shadow: var(--shadow-sm);
}

.attendance-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.attendance-item-subject {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.attendance-item-hours {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.hours-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0;
}

.hours-control button {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    color: var(--text-secondary);
}

.hours-control button:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.hours-control input {
    width: 70px;
    text-align: center;
    font-weight: 500;
}

.status-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.status-btn {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    cursor: pointer;
    font-weight: 500;
    transition: all 0.15s ease;
    font-size: 0.875rem;
}

.status-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.status-btn.present {
    border-color: var(--success);
    color: var(--success);
}

.status-btn.present.active {
    background: var(--success);
    color: white;
}

.status-btn.absent {
    border-color: var(--danger);
    color: var(--danger);
}

.status-btn.absent.active {
    background: var(--danger);
    color: white;
}

.status-btn.cancelled {
    border-color: var(--warning);
    color: var(--warning);
}

.status-btn.cancelled.active {
    background: var(--warning);
    color: white;
}

.status-btn.extra {
    border-color: var(--primary);
    color: var(--primary);
}

.status-btn.extra.active {
    background: var(--primary);
    color: white;
}

.extra-class-section {
    margin-top: 28px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

/* Attendance History */
.attendance-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.attendance-history-item {
    background: var(--bg-card);
    padding: 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.15s ease;
}

.attendance-history-item:hover {
    box-shadow: var(--shadow-sm);
}

.attendance-history-info {
    flex: 1;
}

.attendance-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.attendance-history-subject {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
}

.attendance-history-date {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

.attendance-history-details {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8125rem;
    font-weight: 500;
}

.status-badge.present {
    background: #d1fae5;
    color: #065f46;
}

.status-badge.absent {
    background: #fee2e2;
    color: #991b1b;
}

.status-badge.cancelled {
    background: #fef3c7;
    color: #92400e;
}

.status-badge.extra {
    background: #dbeafe;
    color: #1e40af;
}

.attendance-history-hours {
    color: var(--text-muted);
    font-size: 0.8125rem;
}

/* Subject Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.dashboard-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: all 0.2s ease;
}

.dashboard-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.dashboard-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.dashboard-card.red::before {
    background: var(--danger);
}

.dashboard-card.yellow::before {
    background: var(--warning);
}

.dashboard-card.green::before {
    background: var(--success);
}

.dashboard-card-title {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 18px;
    color: var(--text-primary);
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 14px;
}

.dashboard-stat {
    text-align: center;
}

.dashboard-stat-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 6px;
    font-weight: 500;
}

.dashboard-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.dashboard-attendance {
    text-align: center;
    margin-top: 18px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
}

.dashboard-attendance-label {
    display: block;
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-bottom: 10px;
    font-weight: 500;
}

.dashboard-attendance-value {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 1.125rem;
    font-weight: 600;
}

.dashboard-card.red .dashboard-attendance-value {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.dashboard-card.yellow .dashboard-attendance-value {
    color: var(--warning);
    background: rgba(245, 158, 11, 0.1);
}

.dashboard-card.green .dashboard-attendance-value {
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-card);
    padding: 28px;
    border-radius: var(--radius-lg);
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.modal-content .threshold-form {
    text-align: left;
}

.modal-content p {
    margin-bottom: 24px;
    font-size: 1rem;
    color: var(--text-primary);
}

.modal-content h3 {
    margin-bottom: 20px;
    font-size: 1.125rem;
}

.threshold-form {
    margin-bottom: 20px;
}

.threshold-form .form-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 16px;
}

.threshold-form label {
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.threshold-form input[type="number"] {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
}

.threshold-info {
    font-size: 0.8125rem;
    color: var(--text-muted);
    margin-top: 12px;
    line-height: 1.6;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Reports */
.report-preview {
    margin-top: 20px;
    padding: 20px;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 16px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .main-nav {
        flex-wrap: wrap;
        width: 100%;
    }

    .nav-btn {
        flex: 1;
        min-width: 100px;
        font-size: 0.875rem;
        padding: 8px 12px;
    }

    section {
        padding: 20px;
    }

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

    .form-group {
        flex-direction: column;
    }

    .form-group input,
    .form-group select,
    .form-group button {
        width: 100%;
    }

    .subjects-list {
        grid-template-columns: 1fr;
    }

    .schedule-days {
        grid-template-columns: 1fr;
    }

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

@media (max-width: 480px) {
    .summary-grid {
        grid-template-columns: 1fr;
    }

    .summary-value {
        font-size: 1.75rem;
    }

    .dashboard-stat-value {
        font-size: 1.25rem;
    }
}
