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

:root {
    --primary: #1a56db;
    --primary-dark: #1342b0;
    --primary-light: #e8effc;
    --accent: #0ea5e9;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #f59e0b;
    --gold: #f5b81b;
    --gold-bright: #ffd766;
    --gold-soft: rgba(245, 184, 27, 0.14);
    --gray-50: #f8fafc;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --gray-900: #0f172a;
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --font: 'Noto Sans', 'Noto Sans Sinhala', 'Noto Sans Tamil', 'Nirmala UI', 'Iskoola Pota', 'Latha', 'Sinhala Sangam MN', 'Tamil Sangam MN', 'Kalyani', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
    font-family: var(--font);
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.6;
    min-height: 100vh;
}

/* Layout */
.app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--gray-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width 0.25s ease;
}

.sidebar.collapsed {
    width: 62px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    padding: 12px 10px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    gap: 4px;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    padding: 8px 6px;
}

.sidebar.collapsed .sidebar-brand {
    padding: 8px 0;
    justify-content: center;
}

.sidebar.collapsed .brand-text {
    display: none;
}

.brand-icon {
    width: 38px;
    height: 38px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; white-space: nowrap; overflow: hidden; }
.brand-title { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }
.brand-sub { font-size: 11px; color: var(--gray-400); margin-top: 1px; }

.sidebar-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--gray-400);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: all 0.15s;
}
.sidebar-toggle:hover {
    background: rgba(255,255,255,0.08);
    color: #fff;
}

.sidebar.collapsed .sidebar-toggle {
    display: flex;
}

.sidebar-nav {
    padding: 12px 8px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--gray-300);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    transition: background 0.25s ease, color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
    animation: navIn 0.45s cubic-bezier(.22,.61,.36,1) backwards;
}

/* Stagger the menu items as the sidebar opens. */
.sidebar-nav .nav-item:nth-of-type(1) { animation-delay: .04s; }
.sidebar-nav .nav-item:nth-of-type(2) { animation-delay: .08s; }
.sidebar-nav .nav-item:nth-of-type(3) { animation-delay: .12s; }
.sidebar-nav .nav-item:nth-of-type(4) { animation-delay: .16s; }
.sidebar-nav .nav-item:nth-of-type(5) { animation-delay: .20s; }
.sidebar-nav .nav-item:nth-of-type(6) { animation-delay: .24s; }
.sidebar-nav .nav-item:nth-of-type(7) { animation-delay: .28s; }
.sidebar-nav .nav-item:nth-of-type(8) { animation-delay: .32s; }
.sidebar-nav .nav-item:nth-of-type(9) { animation-delay: .36s; }
.sidebar-nav .nav-item:nth-of-type(10) { animation-delay: .40s; }
.sidebar-nav .nav-item:nth-of-type(11) { animation-delay: .44s; }
.sidebar-nav .nav-item:nth-of-type(12) { animation-delay: .48s; }

@keyframes navIn {
    from { opacity: 0; transform: translateX(-10px); }
    to   { opacity: 1; transform: translateX(0); }
}

.nav-item i { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.nav-item span { overflow: hidden; }
.sidebar.collapsed .nav-item span { display: none; }
.sidebar.collapsed .nav-item { justify-content: center; padding: 10px 0; }

/* Golden hover effect with a sliding indicator, glow and shine sweep. */
.nav-item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 22%;
    bottom: 22%;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--gold-bright), var(--gold));
    box-shadow: 0 0 8px rgba(245, 184, 27, 0.6);
    transform: scaleY(0);
    transform-origin: center;
    transition: transform 0.25s ease;
}
.nav-item::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 55%;
    background: linear-gradient(105deg, transparent, rgba(255, 215, 102, 0.28), transparent);
    transform: translateX(-130%) skewX(-12deg);
    pointer-events: none;
}
.nav-item:hover {
    background: radial-gradient(circle at 28% 50%, var(--gold-soft), rgba(245, 184, 27, 0.05));
    color: var(--gold-bright);
    transform: translateX(4px);
    box-shadow: inset 0 0 0 1px rgba(245, 184, 27, 0.35), 0 0 12px rgba(245, 184, 27, 0.10);
}
.nav-item:hover i { color: var(--gold-bright); }
.nav-item:hover::before { transform: scaleY(1); }
.nav-item:hover::after { animation: navShine 0.7s cubic-bezier(.4,0,.2,1); }

@keyframes navShine {
    0%   { transform: translateX(-130%) skewX(-12deg); }
    100% { transform: translateX(320%) skewX(-12deg); }
}

.nav-item.active {
    background: var(--primary);
    color: #fff;
    font-weight: 600;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}
.nav-item.active::before { transform: scaleY(1); }
.nav-item.active:hover {
    background: var(--primary-dark);
    color: #fff;
    transform: translateX(0);
}

.nav-divider {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--gray-500);
    padding: 14px 12px 4px;
    margin-top: 6px;
    border-top: 1px solid rgba(255,255,255,0.06);
    overflow: hidden;
}
.sidebar.collapsed .nav-divider span { display: none; }
.sidebar.collapsed .nav-divider { padding: 14px 0 4px; text-align: center; }

/* Main Content */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: #fff;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 10;
}

.page-title { font-size: 20px; font-weight: 700; color: var(--gray-900); letter-spacing: -0.3px; }

/* Animated gradient heading for the programme dashboard */
.tc-page-index .page-title {
    position: relative;
    padding-bottom: 5px;
    background: linear-gradient(90deg, #1a56db, #7c3aed 30%, #f5b81b 60%, #0ea5e9 85%, #1a56db);
    background-size: 220% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    animation: titleGradient 7s linear infinite, titleIn 0.6s cubic-bezier(.22,.61,.36,1) backwards;
}
.tc-page-index .page-title::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: 0;
    height: 3px;
    width: 0;
    border-radius: 3px;
    background: linear-gradient(90deg, #1a56db, #7c3aed, #f5b81b);
    box-shadow: 0 0 8px rgba(245, 184, 27, 0.5);
    animation: titleBar 0.9s ease 0.15s forwards;
}
@keyframes titleGradient {
    0%   { background-position: 0% center; }
    100% { background-position: 220% center; }
}
@keyframes titleIn {
    from { opacity: 0; transform: translateY(-10px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes titleBar {
    from { width: 0; }
    to   { width: 100%; }
}

.topbar-info { display: flex; align-items: center; gap: 12px; }

.admin-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary-light);
    color: var(--primary);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
}

.lang-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 3px;
}
.lang-link {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Nirmala UI', 'Noto Sans Sinhala', 'Noto Sans Tamil', 'Noto Sans', 'Iskoola Pota', 'Latha', 'Sinhala Sangam MN', 'Tamil Sangam MN', 'Segoe UI', sans-serif;
    text-decoration: none;
    color: var(--gray-600);
    white-space: nowrap;
    transition: all 0.15s;
    letter-spacing: 0.3px;
}
.lang-link:hover { color: var(--gray-800); }
.lang-link.active {
    background: var(--primary);
    color: #fff;
}

/* Sign-in level badge (provincial vs zone) */
.level-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}
.level-badge.is-provincial {
    background: #ede9fe;
    color: #6d28d9;
}
.level-badge.is-zone {
    background: #dcfce7;
    color: #15803d;
}
.level-badge.is-national {
    background: #dbeafe;
    color: #1d4ed8;
}

/* Content Area */
.content-area {
    padding: 28px 32px;
    flex: 1;
}

.app-footer {
    padding: 16px 32px;
    border-top: 1px solid var(--gray-200);
    color: var(--gray-400);
    font-size: 13px;
    text-align: center;
    background: #fff;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: #fff;
    padding: 22px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border: 1px solid var(--gray-200);
    transition: box-shadow 0.15s;
}
.stat-card:hover { box-shadow: var(--shadow-md); }

.stat-value { font-size: 32px; font-weight: 800; color: var(--primary); letter-spacing: -1px; line-height: 1.2; }
.stat-label { font-size: 13px; color: var(--gray-500); margin-top: 4px; font-weight: 500; }
.stat-card.highlight .stat-value { color: var(--danger); }

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

.card-wide { grid-column: 1 / -1; }

.card {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
    transition: box-shadow 0.15s;
}

.card:hover { box-shadow: var(--shadow-md); }

.card h2, .card h4 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--gray-800);
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    background: var(--gray-50);
    text-align: left;
    padding: 12px 14px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
}

th.num {
    text-align: center;
    width: 80px;
}

td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }

.text-center { text-align: center !important; }
.text-right { text-align: right !important; }
.vacancy { font-weight: 700; color: var(--danger); }

/* Medium Grid */
.medium-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.medium-col h3 {
    font-size: 14px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--gray-200);
}

/* Filters */
.filters {
    background: #fff;
    padding: 20px 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
}

.filter-group select,
.filter-group input[type="text"] {
    padding: 9px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font);
    min-width: 170px;
    background: #fff;
    color: var(--gray-800);
    transition: border-color 0.15s;
}

.filter-group select:focus,
.filter-group input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

.filter-checkbox label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    cursor: pointer;
    padding-top: 16px;
    color: var(--gray-600);
}

.filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    padding-top: 16px;
}

button, .btn, .btn-sm, .btn-link, input[type="submit"] {
    padding: 9px 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s;
}

button:hover, .btn:hover { background: var(--primary-dark); transform: translateY(-1px); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-link { background: transparent; color: var(--primary); padding: 6px 0; }
.btn-link:hover { background: transparent; text-decoration: underline; transform: none; }

.btn-danger { background: var(--danger); }
.btn-danger:hover { background: #b91c1c; }

.btn-success { background: var(--success); }
.btn-success:hover { background: #15803d; }

.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }

/* Links */
.school-link { color: var(--primary); text-decoration: none; font-weight: 500; }
.school-link:hover { text-decoration: underline; }

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header h2 { font-size: 18px; font-weight: 700; color: var(--gray-800); }

/* School Summary Stats */
.school-summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.summary-stat {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    padding: 20px 24px;
    text-align: center;
    transition: box-shadow 0.15s;
}
.summary-stat:hover { box-shadow: var(--shadow-md); }

.stat-val {
    display: block;
    font-size: 32px;
    font-weight: 800;
    letter-spacing: -1px;
    line-height: 1.2;
}
.stat-lbl {
    display: block;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-top: 4px;
}
.stat-sub {
    display: block;
    font-size: 12px;
    color: var(--gray-400);
    margin-top: 4px;
}

.stat-shortage { border-color: #fecaca; }
.stat-shortage .stat-val { color: var(--danger); }
.stat-shortage .stat-lbl { color: var(--danger); }

.stat-surplus { border-color: #bbf7d0; }
.stat-surplus .stat-val { color: var(--success); }
.stat-surplus .stat-lbl { color: var(--success); }

.stat-net { border-color: var(--gray-300); }
.stat-net .stat-val { color: var(--primary); }
.stat-net .stat-lbl { color: var(--primary); }

/* Alert note */
.alert-note {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 14px;
    color: var(--gray-700);
    line-height: 1.6;
}
.alert-note strong { color: var(--primary); }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.status-short { background: #fef2f2; color: var(--danger); }
.status-excess { background: #f0fdf4; color: var(--success); }
.status-ok { background: #f8fafc; color: var(--gray-400); }
.status-mixed { background: #fffbeb; color: #d97706; }

/* School info */
.school-info {
    background: #fff;
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.info-grid div { font-size: 14px; color: var(--gray-700); }
.info-grid strong { color: var(--gray-500); font-weight: 600; }

/* Medium badges */
.medium-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin: 1px 2px;
    line-height: 1.4;
}
.medium-sinhala { background: #e8effc; color: #1a56db; }
.medium-tamil { background: #fef2f2; color: #dc2626; }
.medium-english { background: #f0fdf4; color: #16a34a; }

/* Search Summary */
.search-summary {
    background: var(--primary-light);
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 14px;
    border-left: 4px solid var(--primary);
    color: var(--gray-700);
}

/* No data / Error */
.no-data, .error {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.no-data p { font-size: 15px; }

.error p { color: var(--danger); font-weight: 600; margin-bottom: 12px; }

/* Urgent rows */
.urgent-row td:first-child {
    font-weight: 700;
    color: var(--danger);
}

/* Excess Teacher Cards */
.excess-card {
    background: #fff;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 16px;
    overflow: hidden;
    transition: box-shadow 0.15s;
}
.excess-card:hover { box-shadow: var(--shadow-md); }

.excess-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: #f0fdf4;
    border-bottom: 1px solid #bbf7d0;
}

.excess-card-title {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.excess-card-title .school-link {
    font-size: 15px;
    font-weight: 600;
}
.excess-meta {
    font-size: 12px;
    color: var(--gray-400);
}

.excess-card-stat {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.excess-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 4px 12px;
    background: var(--success);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    border-radius: 20px;
}

.excess-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--success);
    letter-spacing: 0.5px;
}

.excess-card-body {
    padding: 0;
}
.excess-card-body table {
    border: none;
    margin: 0;
}
.excess-card-body th {
    background: #fafafa;
    font-size: 11px;
}
.excess-card-body td {
    padding: 9px 14px;
}

.excess-value {
    font-weight: 700;
    color: var(--success);
}

.excess-cat {
    font-size: 11px;
    color: var(--gray-400);
    font-weight: 400;
}

/* Simulation Styles */
.sim-intro { font-size: 14px; color: var(--gray-500); margin-bottom: 14px; }
.sim-form { margin-bottom: 16px; }

.sim-results {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
    margin-top: 16px;
}

.sim-results h3 { color: var(--gray-800); font-weight: 700; margin-bottom: 16px; }

.sim-grid {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    margin-bottom: 24px;
}

.sim-card {
    background: #fff;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 18px 28px;
    text-align: center;
    min-width: 130px;
}

.sim-card.arrow { border: none; font-size: 28px; color: var(--primary); min-width: auto; padding: 0; }
.sim-card.sim-after { border-color: var(--success); background: #f0fdf4; }

.sim-label { display: block; font-size: 12px; color: var(--gray-400); margin-bottom: 4px; font-weight: 500; }
.sim-value { display: block; font-size: 38px; font-weight: 800; color: var(--gray-800); letter-spacing: -1px; }
.sim-card.sim-after .sim-value { color: var(--success); }
.sim-desc { display: block; font-size: 12px; color: var(--gray-400); margin-top: 4px; }

.sim-impact table { margin-bottom: 16px; border: 1px solid var(--gray-200); border-radius: var(--radius-sm); overflow: hidden; }
.sim-improved { color: var(--success); font-weight: 600; }
.sim-filled { color: var(--success); font-weight: 700; }

.sim-summary {
    display: flex;
    gap: 16px;
    margin-top: 16px;
}

.summary-box {
    flex: 1;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
}

.summary-pct { display: block; font-size: 30px; font-weight: 800; color: var(--primary); margin-bottom: 4px; letter-spacing: -1px; }
.summary-box span:last-child { font-size: 13px; color: var(--gray-500); }

/* Login Page */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-100);
    padding: 20px;
}

.login-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--gray-200);
}

.login-box h2 {
    font-size: 24px;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.login-box .login-sub {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 28px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 5px;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-family: var(--font);
    transition: border-color 0.15s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

.login-box button { width: 100%; justify-content: center; padding: 11px; font-size: 15px; }

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }

/* Collapsible Panel */
.panel {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
    margin-bottom: 24px;
    transition: box-shadow 0.15s;
}
.panel:hover { box-shadow: var(--shadow-md); }

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid var(--gray-200);
    transition: background 0.15s;
}
.panel-header:hover { background: var(--gray-50); }

.panel-header h2, .panel-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-toggle {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 14px;
    transition: all 0.15s;
    flex-shrink: 0;
}
.panel-toggle:hover {
    background: var(--primary);
    color: #fff;
}

.panel-body {
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.25s ease, padding 0.25s ease;
    max-height: 10000px;
    opacity: 1;
}
.panel-body.collapsed {
    max-height: 0 !important;
    padding: 0 !important;
    opacity: 0;
}

/* when panel body is inside the card, keep padding on the body content */
.panel-body .panel-inner {
    padding: 20px 24px;
}

.panel-body.collapsed .panel-inner {
    padding: 0;
}

/* Filters inside panel */
.panel .filters {
    margin-bottom: 0;
    border: none;
    box-shadow: none;
    border-radius: 0;
    padding: 20px 24px;
}

.panel .table-container {
    border: none;
    box-shadow: none;
    border-radius: 0;
}

/* Export Toolbar */
.export-toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
}
.filters .export-toolbar {
    margin: 12px 0 0;
    padding-top: 12px;
    border-top: 1px solid var(--gray-200);
    width: 100%;
}

/* Print-only header */
.print-header { display: none; }

/* Print Styles */
@media print {
    @page { margin: 20mm 15mm; }

    .sidebar, .topbar, .topbar-info, .app-footer, .filters, .export-toolbar,
    .panel-toggle, .sidebar-toggle, .filter-actions, .btn-sm, .btn-link,
    .sim-form, .no-data, .admin-badge, .level-badge, .search-summary, .tabs {
        display: none !important;
    }
    .print-header {
        display: block !important;
        text-align: center;
        margin-bottom: 24px;
        padding-bottom: 18px;
        border-bottom: 3px double #000;
    }
    .print-header-office {
        font-size: 18px;
        font-weight: 700;
        color: #000;
        margin-bottom: 4px;
    }
    .print-header-title {
        font-size: 22px;
        font-weight: 800;
        color: #000;
        letter-spacing: 1px;
        margin-bottom: 14px;
    }
    .print-header-body {
        padding: 8px 0;
        margin-bottom: 4px;
    }
    .print-header-subject {
        font-size: 24px;
        font-weight: 800;
        color: #000;
        margin-bottom: 10px;
    }
    .print-header-info {
        display: flex;
        justify-content: center;
        gap: 24px;
        flex-wrap: wrap;
        font-size: 13px;
        color: #333;
    }
    .print-info-item {
        white-space: nowrap;
    }
    .print-info-label {
        font-weight: 600;
        color: #555;
    }

    .prov-letterhead {
        margin-bottom: 6px;
        line-height: 1.45;
    }
    .prov-letterhead .pl-tag {
        font-size: 13px;
        font-weight: 700;
        color: #000;
    }
    .prov-letterhead .pl-council {
        font-size: 17px;
        font-weight: 800;
        color: #000;
    }
    .prov-letterhead .pl-ministry {
        font-size: 12.5px;
        color: #111;
        margin-top: 2px;
    }
    .prov-letterhead .pl-contact {
        font-size: 11px;
        color: #333;
        margin-top: 3px;
    }
    .prov-letterhead .pl-si { font-family: 'Noto Sans Sinhala', sans-serif; }
    .prov-letterhead .pl-ta { font-family: 'Noto Sans Tamil', sans-serif; }

    .app { display: block; }
    .main-content { display: block; }
    .content-area { padding: 0 !important; }
    .card, .panel, .excess-card, .school-info, .stat-card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
        break-inside: avoid;
    }
    .panel-body { max-height: none !important; opacity: 1 !important; overflow: visible !important; }
    .table-container { border: 1px solid #ddd !important; }
    th { background: #f5f5f5 !important; }
    .stats-grid { grid-template-columns: repeat(4, 1fr); }
    .school-summary-grid { grid-template-columns: repeat(3, 1fr); }
    .dashboard-grid { grid-template-columns: 1fr 1fr; }
    .medium-grid { grid-template-columns: repeat(3, 1fr); }
    .page-header { margin-bottom: 12px !important; }
    h2, h3 { margin-top: 16px; }
}

/* Admin Styles */
.admin-toolbar {
    display: flex;
    gap: 12px;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.admin-edit-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.admin-edit-form input,
.admin-edit-form select {
    padding: 6px 10px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: var(--font);
}

.admin-edit-form input:focus,
.admin-edit-form select:focus {
    outline: none;
    border-color: var(--primary);
}

.inline-form { display: inline; }

.vac-edit-input {
    width: 60px;
    padding: 4px 6px;
    text-align: center;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 13px;
    font-family: var(--font);
}

.vac-edit-input:focus { outline: none; border-color: var(--primary); }

.vac-edit-btn {
    padding: 4px 10px;
    font-size: 12px;
    border-radius: 4px;
}

/* ===== FLASH MESSAGES ===== */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.flash-success { background: #f0fdf4; color: var(--success); border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: var(--danger); border: 1px solid #fecaca; }

/* Clickable stat */
.stat-click {
    cursor: pointer;
    transition: opacity 0.15s;
}
.stat-click:hover { opacity: 0.7; }

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.modal-overlay.show { display: flex; }

.modal-box {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: 0 25px 80px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 680px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.2s ease;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--gray-200);
    flex-shrink: 0;
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-800);
    margin: 0;
}
.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-500);
    font-size: 16px;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--danger); color: #fff; }

.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-body .table-wrap { margin-bottom: 0; }
.modal-body table { margin-bottom: 0; }

@media (max-width: 768px) {
    .modal-box { max-width: 100%; max-height: 90vh; }
    .modal-header { padding: 14px 16px; }
    .modal-body { padding: 14px 16px; }
}

/* Table scroll wrapper (mobile) */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.table-wrap table {
    min-width: 600px;
}

/* Responsive */
@media (max-width: 768px) {
    .app { flex-direction: column; }

    /* Sidebar as overlay */
    .sidebar {
        position: fixed;
        top: 0;
        left: -280px;
        width: 280px !important;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        display: flex;
        flex-direction: column;
        box-shadow: 4px 0 30px rgba(0,0,0,0.3);
    }
    .sidebar.mobile-open { left: 0; }
    .sidebar.collapsed { width: 280px !important; left: -280px; }
    .sidebar.collapsed.mobile-open { left: 0; }
    .sidebar.collapsed .brand-text { display: flex; }
    .sidebar.collapsed .nav-item { justify-content: flex-start; padding: 10px 12px; }
    .sidebar.collapsed .nav-item span { display: inline; }
    .sidebar.collapsed .nav-divider span { display: inline; }
    .sidebar.collapsed .nav-divider { padding: 14px 12px 4px; text-align: left; }
    .sidebar.collapsed .sidebar-brand { justify-content: flex-start; padding: 8px 12px; }

    .sidebar-header { padding: 12px 16px; }
    .sidebar-nav { flex-direction: column; padding: 8px 12px; gap: 2px; }
    .nav-item { font-size: 14px; padding: 10px 12px; }
    .nav-divider { display: block; }

    /* Hamburger in topbar */
    .hamburger {
        display: flex !important;
        width: 36px;
        height: 36px;
        border: none;
        background: var(--gray-100);
        border-radius: 8px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        color: var(--gray-600);
        font-size: 16px;
        margin-right: 12px;
        flex-shrink: 0;
        transition: background 0.15s;
    }
    .hamburger:hover { background: var(--gray-200); }

    .sidebar-toggle { display: none; }

    /* Backdrop */
    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    .sidebar-backdrop.show { display: block; }

    .main-content { padding: 0; width: 100%; }
    .topbar { padding: 10px 16px; }
    .content-area { padding: 16px; }
    .app-footer { padding: 12px 16px; }

    .page-title { font-size: 17px; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .stat-card { padding: 14px; }
    .stat-value { font-size: 22px; }

    .dashboard-grid { grid-template-columns: 1fr; }
    .medium-grid { grid-template-columns: 1fr; }
    .filter-form { flex-direction: column; align-items: stretch; }
    .filter-group select,
    .filter-group input[type="text"] { min-width: 100%; }
    .filters { padding: 14px 16px; }
    .filter-group label { font-size: 10px; }
    .filter-group select,
    .filter-group input[type="text"] { padding: 7px 10px; font-size: 13px; }

    .sim-grid { flex-direction: column; }
    .sim-summary { flex-direction: column; }
    .school-summary-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr 1fr; }
    .admin-toolbar { flex-direction: column; align-items: stretch; }

    .card { padding: 16px; margin-bottom: 16px; }
    .card h2, .card h4 { font-size: 14px; }
    th { font-size: 11px; padding: 8px 10px; }
    td { font-size: 13px; padding: 8px 10px; }

    .excess-card-header { flex-direction: column; gap: 8px; align-items: flex-start; }

    /* Table scroll on mobile */
    .card table:not(.no-scroll),
    .panel-inner table:not(.no-scroll) { min-width: 550px; }

    .school-summary-grid { margin-bottom: 16px; }
    .summary-stat { padding: 14px 16px; }
    .stat-val { font-size: 24px; }

    .page-header { flex-direction: column; gap: 8px; align-items: flex-start; margin-bottom: 16px; }

    .admin-edit-form { flex-direction: column; align-items: stretch; }
    .admin-edit-form input[type="text"] { min-width: 0 !important; width: 100% !important; }

    .export-toolbar { flex-wrap: wrap; }
}

/* === LARGE SCREENS (laptops / desktops) — use the space: bigger text & wider layout === */
@media (min-width: 1440px) {
    .sidebar { width: 280px; }
    .sidebar-nav { padding: 16px 10px; }
    .nav-item { font-size: 15px; padding: 12px 14px; }
    .nav-divider { font-size: 11px; padding: 16px 14px 6px; }

    .topbar { padding: 20px 40px; }
    .page-title { font-size: 24px; }
    .content-area { padding: 32px 40px; }
    .app-footer { padding: 18px 40px; font-size: 14px; }

    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 20px; margin-bottom: 32px; }
    .stat-card { padding: 26px 28px; }
    .stat-value { font-size: 38px; }
    .stat-label { font-size: 14px; }

    .dashboard-grid { gap: 28px; }
    .card { padding: 28px; margin-bottom: 28px; }
    .card h2, .card h4 { font-size: 18px; margin-bottom: 18px; }

    table { font-size: 15px; }
    th { font-size: 13px; padding: 14px 16px; }
    td { padding: 13px 16px; }

    .filters { padding: 20px 24px; }
    .filter-group label { font-size: 12px; }
    .filter-group select,
    .filter-group input[type="text"] { padding: 10px 14px; font-size: 15px; }
}

@media (min-width: 1900px) {
    .sidebar { width: 300px; }
    .content-area { padding: 40px 48px; }
    .card { padding: 32px; }
    table { font-size: 16px; }
    th { font-size: 14px; }
    td { font-size: 15px; padding: 14px 18px; }
    .page-title { font-size: 26px; }
    .stat-value { font-size: 42px; }
    .stat-label { font-size: 15px; }
}
