:root {
    --primary: #1e5aa8;
    --primary-dark: #0d3c78;
    --accent: #f0a500;
    --success: #2ecc71;
    --danger: #e74c3c;
    --warning: #f39c12;
    --bg: #f5f7fa;
    --card-bg: #ffffff;
    --text: #2c3e50;
    --muted: #7f8c8d;
    --border: #dfe6e9;
}

* { box-sizing: border-box; }

body {
    font-family: "Cairo", "Segoe UI", "Tahoma", "Arial", sans-serif;
    direction: rtl;
    background: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* ===== Top bar ===== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    gap: 16px;
    flex-wrap: wrap;
}
.topbar-right, .topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar .logo { font-size: 24px; }
.topbar .school-name { font-weight: 700; font-size: 18px; }
.topbar .year-badge {
    background: rgba(255,255,255,0.15);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
}
.topbar .year-badge-warn { background: var(--danger); }
.topbar .user-name { font-size: 14px; }
.btn-logout {
    background: rgba(255,255,255,0.15);
    color: white;
    padding: 6px 14px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    transition: background .2s;
}
.btn-logout:hover { background: rgba(255,255,255,0.28); }

/* ===== License banner ===== */
.license-banner {
    background: #fff3cd;
    color: #856404;
    padding: 10px 20px;
    text-align: center;
    border-bottom: 1px solid #ffeeba;
    font-size: 14px;
}
.license-banner a { color: var(--primary); font-weight: 700; }

/* ===== Content ===== */
.content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}
h1, h2, h3 { color: var(--primary-dark); }

/* ===== Alert ===== */
.alert {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.alert-error, .alert-danger { background: #fde2e1; color: #721c24; border: 1px solid #f5c6cb; }
.alert-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }

/* ===== Login page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}
.login-card {
    background: white;
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 400px;
    padding: 36px 32px;
}
.login-card .brand {
    text-align: center;
    margin-bottom: 24px;
}
.login-card .brand .logo { font-size: 48px; display: block; margin-bottom: 8px; }
.login-card .brand h1 { font-size: 22px; margin: 0; color: var(--primary-dark); }
.login-card .brand p { color: var(--muted); font-size: 14px; margin: 6px 0 0; }

/* ===== Forms ===== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 14px;
    color: var(--text);
}
.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    transition: border-color .2s, box-shadow .2s;
    background: white;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,90,168,0.1);
}

/* ===== Buttons ===== */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background .2s, transform .1s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--muted); color: white; }
.btn-secondary:hover { background: #5d6d7e; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--success); color: white; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ===== Icon grid (dashboard) ===== */
.icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 20px;
}
.icon-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 28px 16px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: all .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.icon-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 30px rgba(30,90,168,0.15);
    border-color: var(--primary);
}
.icon-card .icon { font-size: 44px; line-height: 1; }
.icon-card .label { font-size: 16px; font-weight: 600; }

/* ===== Tables ===== */
.table-card {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
table {
    width: 100%;
    border-collapse: collapse;
}
table th, table td {
    padding: 12px 16px;
    text-align: right;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
table th {
    background: #f8fafc;
    font-weight: 700;
    color: var(--primary-dark);
}
table tr:hover { background: #f8fafc; }

/* ===== Page header ===== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header h1 { margin: 0; font-size: 24px; }
.page-header .actions { display: flex; gap: 8px; }

/* ===== Permissions grid (checkbox grid) ===== */
.perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 8px;
    margin-top: 8px;
}
.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    background: #f8fafc;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
}
.perm-item input { margin: 0; }

/* ===== Misc ===== */
.muted { color: var(--muted); font-size: 13px; }
.text-center { text-align: center; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-3 { margin-bottom: 16px; }

/* ===== Topbar home link ===== */
.topbar .home-link {
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border-radius: 8px;
    padding: 4px 10px;
    transition: background .2s;
}
.topbar .home-link:hover {
    background: rgba(255,255,255,0.15);
}
.topbar .home-link:active {
    background: rgba(255,255,255,0.25);
}

/* ===== Site Footer ===== */
.site-footer {
    text-align: center;
    padding: 24px 16px 16px;
    margin-top: 48px;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 13px;
    line-height: 1.9;
    background: linear-gradient(to bottom, transparent, rgba(30, 90, 168, 0.03));
}
.site-footer .company {
    font-weight: 700;
    color: var(--primary);
    font-size: 14px;
    display: inline-block;
    padding: 4px 12px;
    background: rgba(30, 90, 168, 0.06);
    border-radius: 20px;
    margin-bottom: 6px;
}
.site-footer .company strong {
    color: var(--primary-dark);
    letter-spacing: 0.5px;
}
.site-footer .powered {
    font-size: 12px;
    color: var(--muted);
    margin-top: 6px;
}
.site-footer .powered .sep {
    color: var(--border);
    margin: 0 8px;
}
.site-footer .powered a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.site-footer .powered a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}
.site-footer .powered .dev-name {
    color: var(--primary-dark);
}
.site-footer .powered .phone {
    direction: ltr;
    display: inline-block;
    font-family: monospace;
    letter-spacing: 0.5px;
}

/* ===== Login Page Footer ===== */
.login-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 16px 12px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    line-height: 1.9;
    z-index: 10;
}
.login-footer .company {
    font-weight: 700;
    color: rgba(255, 255, 255, 0.95);
    font-size: 13px;
    letter-spacing: 0.3px;
}
.login-footer .powered {
    margin-top: 4px;
    color: rgba(255, 255, 255, 0.6);
}
.login-footer .powered .sep {
    margin: 0 8px;
    color: rgba(255, 255, 255, 0.3);
}
.login-footer .powered a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}
.login-footer .powered a:hover {
    color: #ffc93c;
    text-decoration: underline;
}
.login-footer .powered .phone {
    direction: ltr;
    display: inline-block;
    font-family: monospace;
    letter-spacing: 0.5px;
}

/* ===== Login Brand Improvements ===== */
.login-card .brand .welcome {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    margin: 8px 0 0;
    line-height: 1.6;
}
.login-card .brand .app-name {
    color: var(--primary);
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin: 4px 0 0;
}
