:root {
    --navy: #1b365d;
    --navy-dark: #132743;
    --navy-light: #2c4a70;
    --bg: #f4f6f9;
    --white: #ffffff;
    --border: #d5dce5;
    --text: #1f2937;
    --muted: #5b6778;
    --success-bg: #e7f6ec;
    --success-border: #2e8540;
    --danger-bg: #fdeaea;
    --danger-border: #c53030;
    --pink-bg: #fce4ec;
    --pink-border: #d81b60;
    --amber-bg: #fff6db;
    --amber-border: #b7791f;
    --blue-bg: #e8f1fb;
    --blue-border: #2b6cb0;
}

* { box-sizing: border-box; }
html, body {
    margin: 0;
    padding: 0;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--navy-light); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 10px 0; color: var(--navy-dark); font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.hidden { display: none !important; }
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-20 { margin-top: 20px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.mb-4 { margin-bottom: 4px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
.section-space { padding: 28px 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.inline-form { display: inline; }

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 3px;
    border: 1px solid transparent;
    cursor: pointer;
    text-align: center;
    line-height: 1.4;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn-primary:hover { background: var(--navy-dark); }
.btn-outline { background: var(--white); color: var(--navy); border-color: var(--border); }
.btn-outline:hover { background: #eef2f7; }
.btn-outline-light { background: transparent; color: var(--white); border-color: rgba(255,255,255,0.7); }
.btn-outline-light:hover { background: rgba(255,255,255,0.12); }
.btn-danger { background: #b91c1c; color: var(--white); border-color: #b91c1c; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }
.btn-block { display: block; width: 100%; }
.btn-link-danger { background: none; border: none; color: #b91c1c; cursor: pointer; font-weight: bold; }

/* Cards & Tables */
.card { background: var(--white); border: 1px solid var(--border); border-radius: 3px; }
.card-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #f9fafc;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}
.card-header h3 { margin: 0; font-size: 16px; }
.card-body { padding: 16px; }

.table-responsive { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th { background: #f1f4f8; color: var(--navy-dark); font-weight: 600; border-top: 1px solid var(--border); }
.data-table tbody tr:hover { background: #fafbfd; }

.info-kv-table { width: 100%; border-collapse: collapse; }
.info-kv-table th, .info-kv-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.info-kv-table th { width: 180px; color: var(--muted); font-weight: 600; }

/* Forms */
.classic-form .form-group { margin-bottom: 12px; }
.classic-form label { display: block; font-size: 13px; font-weight: 600; color: var(--navy-dark); margin-bottom: 4px; }
.form-control {
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: var(--white);
    border: 1px solid #bfc8d4;
    border-radius: 3px;
}
.form-control:focus { outline: none; border-color: var(--navy); }
.form-control-sm { padding: 5px 8px; font-size: 13px; }
.form-row-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.form-row-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.checkbox-label { display: inline-flex !important; align-items: center; gap: 6px; font-weight: 500 !important; cursor: pointer; }
.checkbox-grid-sm { display: grid; grid-template-columns: repeat(2, minmax(110px, 1fr)); gap: 4px; }
.filter-inline-form { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.inline-edit-box { display: flex; flex-direction: column; gap: 6px; min-width: 220px; padding: 8px; background: #f8fafc; border: 1px solid var(--border); border-radius: 3px; }

/* Alerts & Badges */
.alert { padding: 10px 14px; border-radius: 3px; border: 1px solid var(--border); margin-bottom: 14px; font-size: 14px; }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: #1d5c2b; }
.alert-error { background: var(--danger-bg); border-color: var(--danger-border); color: #8c1d1d; }
.alert-warning { background: var(--amber-bg); border-color: var(--amber-border); color: #7c4d0f; }
.alert-info { background: var(--blue-bg); border-color: var(--blue-border); color: #1e4e8c; }

.tag { display: inline-block; padding: 2px 7px; font-size: 12px; background: #edf2f7; border: 1px solid #d5dce5; border-radius: 2px; color: var(--navy-dark); }
.tag-important { background: var(--danger-bg); border-color: var(--danger-border); color: #8c1d1d; font-weight: 600; }
.badge { display: inline-block; padding: 2px 8px; font-size: 12px; font-weight: 600; border-radius: 2px; background: #e5e7eb; }
.badge-green { background: var(--success-bg); color: #1d5c2b; border: 1px solid var(--success-border); }
.badge-red { background: var(--danger-bg); color: #8c1d1d; border: 1px solid var(--danger-border); }
.grade-box { display: inline-block; min-width: 28px; text-align: center; padding: 3px 7px; font-weight: 700; background: #eef3fa; border: 1px solid var(--navy-light); color: var(--navy-dark); border-radius: 3px; }

/* Attendance colors (explicit school rules) */
.att-pill { display: inline-block; padding: 3px 8px; font-size: 12px; font-weight: 600; border-radius: 2px; border: 1px solid #cbd5e1; }
.att-green { background: var(--success-bg) !important; border-color: var(--success-border) !important; color: #14532d; }
.att-red { background: var(--danger-bg) !important; border-color: var(--danger-border) !important; color: #7f1d1d; }
.att-white { background: var(--white) !important; border-color: #cbd5e1 !important; color: #334155; }
.att-pink { background: var(--pink-bg) !important; border-color: var(--pink-border) !important; color: #880e4f; }
.att-amber { background: var(--amber-bg) !important; border-color: var(--amber-border) !important; color: #78350f; }
.att-blue { background: var(--blue-bg) !important; border-color: var(--blue-border) !important; color: #1e3a8a; }
.att-legend { display: flex; flex-wrap: wrap; gap: 8px; }

/* Grids */
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.kpi-card { background: var(--white); border: 1px solid var(--border); border-radius: 3px; padding: 14px 16px; }
.kpi-val { font-size: 26px; font-weight: 700; color: var(--navy); }
.kpi-label { font-size: 13px; color: var(--muted); }
.quick-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* Public Header & Footer */
.public-header { background: var(--white); border-bottom: 2px solid var(--navy); }
.topbar-strip { background: var(--navy-dark); color: #e2e8f0; font-size: 12px; padding: 5px 0; }
.topbar-strip-inner { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.header-main { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; gap: 16px; flex-wrap: wrap; }
.brand-link { display: flex; align-items: center; gap: 12px; color: var(--navy-dark); text-decoration: none; }
.brand-link:hover { text-decoration: none; }
.brand-logo { width: 46px; height: 46px; object-fit: contain; }
.brand-name { font-size: 19px; font-weight: 700; color: var(--navy); }
.brand-sub { font-size: 12px; color: var(--muted); letter-spacing: 0.5px; }
.public-nav { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.public-nav a:not(.btn) { color: var(--navy-dark); font-weight: 600; font-size: 14px; padding: 4px 2px; }
.public-nav a:not(.btn):hover { color: var(--navy); }
.nav-toggle { display: none; background: var(--white); border: 1px solid var(--border); padding: 6px 10px; border-radius: 3px; cursor: pointer; font-weight: 600; }

.hero-banner { background: var(--navy); color: var(--white); padding: 38px 0; border-bottom: 4px solid var(--navy-dark); }
.hero-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; align-items: center; }
.hero-kicker { display: inline-block; font-size: 12px; letter-spacing: 1px; background: rgba(255,255,255,0.15); padding: 3px 8px; margin-bottom: 10px; }
.hero-text h1 { color: var(--white); font-size: 30px; margin-bottom: 10px; }
.hero-text p { color: #e2e8f0; font-size: 16px; margin-bottom: 18px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.hero-info-box { background: var(--white); color: var(--text); padding: 18px; border-radius: 3px; border-left: 4px solid #c53030; }
.hero-info-box h3 { color: var(--navy); margin-bottom: 8px; }

.home-two-col { display: grid; grid-template-columns: 1.5fr 1fr; gap: 24px; align-items: start; }
.section-head { display: flex; justify-content: space-between; align-items: baseline; border-bottom: 2px solid var(--navy); padding-bottom: 6px; margin-bottom: 14px; }
.section-head h2 { margin: 0; font-size: 20px; }

.news-list { display: flex; flex-direction: column; gap: 14px; }
.news-card { display: flex; overflow: hidden; }
.news-thumb { width: 180px; min-height: 130px; object-fit: cover; flex-shrink: 0; border-right: 1px solid var(--border); }
.news-meta { font-size: 12px; color: var(--muted); display: flex; gap: 10px; margin-bottom: 6px; align-items: center; }
.article-hero-img { width: 100%; max-height: 360px; object-fit: cover; border-bottom: 1px solid var(--border); }
.prose p { margin-bottom: 12px; }

.event-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 12px; }
.event-list li { display: flex; gap: 12px; align-items: center; border-bottom: 1px solid var(--border); padding-bottom: 10px; }
.event-list li:last-child { border-bottom: none; padding-bottom: 0; }
.event-date-box { background: var(--navy); color: var(--white); text-align: center; padding: 5px 8px; border-radius: 3px; min-width: 56px; }
.ev-day { display: block; font-size: 18px; font-weight: 700; line-height: 1.1; }
.ev-month { font-size: 11px; }

.simple-link-list { list-style: none; padding: 0; margin: 0; }
.simple-link-list li { padding: 7px 0; border-bottom: 1px solid var(--border); }
.simple-link-list li:last-child { border-bottom: none; }

.gallery-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.gallery-item { margin: 0; background: var(--white); border: 1px solid var(--border); border-radius: 3px; overflow: hidden; }
.gallery-item img { width: 100%; height: 180px; object-fit: cover; display: block; }
.gallery-item figcaption { padding: 8px 10px; font-size: 13px; color: var(--navy-dark); font-weight: 500; }

.contact-strip { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.public-footer { background: var(--navy-dark); color: #d8e1ec; margin-top: 40px; padding-top: 28px; }
.public-footer h4 { color: var(--white); margin-bottom: 10px; }
.footer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; padding-bottom: 24px; }
.footer-links { list-style: none; padding: 0; margin: 0; }
.footer-links li { margin-bottom: 5px; }
.footer-links a { color: #cbd5e1; }
.footer-bottom { background: #0d1b30; padding: 10px 0; font-size: 13px; color: #94a3b8; }

/* Auth / Login (Classic institutional box) */
.auth-body { background: #e9eef5; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-wrapper { width: 100%; max-width: 440px; }
.auth-topbar { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 10px; color: var(--muted); }
.auth-card { background: var(--white); border: 1px solid var(--border); border-top: 4px solid var(--navy); border-radius: 3px; padding: 26px; box-shadow: 0 2px 8px rgba(19, 39, 67, 0.08); }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-logo { width: 58px; height: 58px; margin-bottom: 8px; }
.auth-brand h1 { font-size: 20px; margin-bottom: 4px; }
.auth-subtitle { font-size: 17px; margin-bottom: 12px; }
.auth-links { text-align: right; margin-top: 10px; font-size: 13px; }
.auth-alt-divider { text-align: center; border-top: 1px solid var(--border); margin: 18px 0 12px; padding-top: 10px; font-size: 12px; color: var(--muted); }
.auth-alt-methods { display: flex; flex-direction: column; gap: 8px; }
.auth-footer { text-align: center; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* App Shell (Sidebar + Topbar) */
.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 245px; background: var(--navy-dark); color: #e2e8f0; flex-shrink: 0; display: flex; flex-direction: column; }
.sidebar-header { padding: 14px 16px; border-bottom: 1px solid rgba(255,255,255,0.12); display: flex; justify-content: space-between; align-items: center; }
.sidebar-brand { display: flex; align-items: center; gap: 10px; color: var(--white); text-decoration: none; }
.sidebar-logo { width: 34px; height: 34px; background: var(--white); border-radius: 3px; padding: 2px; }
.sidebar-school { font-weight: 700; font-size: 14px; }
.sidebar-role { font-size: 12px; color: #cbd5e1; }
.sidebar-close { display: none; background: none; border: none; color: var(--white); font-size: 22px; cursor: pointer; }
.sidebar-nav { padding: 10px 0; flex: 1; }
.sidebar-nav a { display: block; padding: 9px 16px; color: #dbe4f0; font-size: 14px; border-left: 3px solid transparent; }
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); text-decoration: none; color: var(--white); }
.sidebar-nav a.active { background: var(--navy); border-left-color: #93c5fd; color: var(--white); font-weight: 600; }
.sidebar-section { padding: 12px 16px 4px; font-size: 11px; text-transform: uppercase; color: #94a3b8; letter-spacing: 0.6px; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid rgba(255,255,255,0.12); font-size: 13px; }
.sidebar-ext-link { color: #cbd5e1; }

.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.app-topbar { background: var(--white); border-bottom: 1px solid var(--border); padding: 10px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.topbar-left { display: flex; align-items: center; gap: 10px; }
.page-heading { font-size: 18px; margin: 0; }
.mobile-menu-btn { display: none; background: var(--white); border: 1px solid var(--border); padding: 5px 9px; border-radius: 3px; cursor: pointer; font-size: 16px; }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.user-chip { text-align: right; line-height: 1.2; }
.user-name { display: block; font-weight: 600; font-size: 13px; color: var(--navy-dark); }
.user-date { font-size: 11px; color: var(--muted); }
.notif-bell { position: relative; color: var(--navy); padding: 4px; display: inline-flex; }
.badge-count { position: absolute; top: -4px; right: -6px; background: #c53030; color: var(--white); font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 10px; }
.app-content { padding: 20px; flex: 1; }
.welcome-strip { background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--navy); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; border-radius: 3px; }

/* Timetable */
.timetable-days-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.timetable-day-col .card-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.tt-slot-card { display: block; padding: 9px 10px; border: 1px solid var(--border); border-radius: 3px; background: var(--white); color: var(--text); }
.tt-slot-card:hover { border-color: var(--navy); text-decoration: none; }
.tt-slot-top { display: flex; justify-content: space-between; gap: 6px; font-size: 12px; margin-bottom: 3px; }
.tt-num { font-weight: 600; color: var(--navy); }
.tt-subj { font-weight: 700; font-size: 14px; color: var(--navy-dark); }
.tt-att-text { font-size: 11px; margin-top: 4px; }

/* Calendar */
.calendar-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.calendar-grid-table { width: 100%; border-collapse: collapse; background: var(--white); table-layout: fixed; }
.calendar-grid-table th, .calendar-grid-table td { border: 1px solid var(--border); padding: 6px; vertical-align: top; height: 92px; }
.calendar-grid-table th { height: auto; background: #f1f4f8; text-align: center; font-weight: 600; color: var(--navy-dark); }
.cal-empty { background: #f8fafc; }
.cal-today { background: #eef5ff; }
.cal-day-num { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
.cal-event-pill { font-size: 11px; background: #e8eff8; border-left: 3px solid var(--navy); padding: 2px 4px; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-type-vaheaeg { background: #e7f6ec; border-left-color: #2e8540; }
.cal-type-kontrolltoo { background: #fdeaea; border-left-color: #c53030; }
.cal-more { font-size: 11px; color: var(--muted); }

/* Messages */
.message-list { display: flex; flex-direction: column; gap: 10px; }
.message-item { border: 1px solid var(--border); padding: 10px 12px; border-radius: 3px; background: #fcfdff; }
.msg-unread { border-left: 4px solid var(--navy); background: #f0f5fc; }
.msg-head { display: flex; justify-content: space-between; gap: 10px; }
.msg-body { margin: 6px 0; font-size: 14px; }

/* Certificate Print Sheet */
.certificate-sheet { background: var(--white); border: 2px solid var(--navy); padding: 32px; max-width: 820px; margin: 0 auto; }
.cert-header { display: flex; align-items: center; gap: 16px; border-bottom: 2px solid var(--navy); padding-bottom: 14px; margin-bottom: 18px; }
.cert-logo { width: 64px; height: 64px; }
.cert-subtitle { font-size: 15px; font-weight: 700; color: var(--muted); letter-spacing: 1px; }
.cert-meta-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.cert-meta-table th, .cert-meta-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); text-align: left; }
.cert-meta-table th { color: var(--muted); width: 170px; }
.cert-grade-val { font-size: 16px; color: var(--navy); }
.cert-footer { display: flex; justify-content: space-between; margin-top: 28px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); }

/* Responsive (iPad & Mobile) */
@media (max-width: 1024px) {
    .timetable-days-grid { grid-template-columns: repeat(2, 1fr); }
    .hero-grid, .home-two-col, .grid-2 { grid-template-columns: 1fr; }
    .form-row-4 { grid-template-columns: repeat(2, 1fr); }
    .form-row-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .nav-toggle { display: inline-block; }
    .public-nav { display: none; width: 100%; flex-direction: column; align-items: flex-start; padding-top: 10px; border-top: 1px solid var(--border); }
    .public-nav.open { display: flex; }
    .news-card { flex-direction: column; }
    .news-thumb { width: 100%; height: 180px; border-right: none; border-bottom: 1px solid var(--border); }
    .gallery-grid, .footer-grid, .timetable-days-grid, .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }

    .sidebar { position: fixed; left: -260px; top: 0; bottom: 0; z-index: 1000; transition: left 0.2s ease; }
    .sidebar.open { left: 0; }
    .sidebar-close, .mobile-menu-btn { display: inline-block; }
    .app-content { padding: 12px; }
}

@media print {
    .sidebar, .app-topbar, .no-print { display: none !important; }
    .app-main, .app-content { margin: 0; padding: 0; }
    .certificate-sheet { border: 1px solid #000; box-shadow: none; }
}
