/* ============ Global Styles ============ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ============ Header Styles ============
   Matches the "smarkai" catalog template's own header styling (see
   wwwroot/templates/smarkai/style.css) - this is what paints before
   header-footer-template.js's applyCompanyUiSettings() has resolved which
   branding actually applies, and SmarkAI is the universal default now (a
   company only gets something else, e.g. VIGNAN'S for company 4, by
   explicitly configuring it). Keeping these in sync avoids a flash of
   unstyled/wrong-branded content between initial paint and that async
   resolution. */
#headerContainer {
    position: sticky;
    top: 0;
    z-index: 1001;
    background: #ffffff;
}

.smarkui-navbar {
    background: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    border-bottom: 1px solid #eceef5;
    flex-shrink: 0;
}

.navbar-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    min-height: 120px;
    gap: 15px;
}

/* Logo and Header Title */
.header-logo-section {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    cursor: pointer;
    transition: opacity 0.3s;
}

.header-logo-section:hover {
    opacity: 0.9;
}

.header-logo {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.header-title {
    font-size: 24px;
    font-weight: 700;
    color: #1f2233;
    margin: 0;
    line-height: 1.2;
    letter-spacing: 0.5px;
}

.header-subtitle {
    font-size: 14px;
    color: #666;
    margin: 0;
    font-weight: 500;
}

/* ============ Sidebar Menu Styles ============ */
/* Sidebar Toggle Buttons */
.sidebar-toggle {
    display: block;
    background: none;
    border: none;
    font-size: 24px;
    color: #1f2233;
    cursor: pointer;
    padding: 8px;
    transition: all 0.3s;
}

.sidebar-toggle-left {
    margin-right: 15px;
}

.sidebar-toggle:hover {
    color: #2e2a8f;
    transform: scale(1.1);
}

/* Dynamic Sidebar (Left Side) */
#dynamicSidebarMenu {
    position: fixed;
    left: -280px;
    top: 120px;
    width: 280px;
    height: calc(100vh - 120px);
    background: white;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    transition: left 0.3s ease;
    z-index: 1002;
    overflow-y: auto;
}

#dynamicSidebarMenu.active {
    left: 0;
}

#dynamicSidebarOverlay {
    position: fixed;
    top: 120px;
    left: 0;
    width: 100%;
    height: calc(100vh - 120px);
    background: rgba(0, 0, 0, 0.5);
    display: none;
    z-index: 1001;
}

#dynamicSidebarOverlay.active {
    display: block;
}

/* Sidebar Header */
.sidebar-header {
    padding: 20px;
    background: #003B7A;
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header-minimal {
    padding: 10px 15px;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

/* Sidebar search box */
.sidebar-search-wrap {
    padding: 10px 12px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.sidebar-search-input {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid #ccc;
    border-radius: 20px;
    font-size: 13px;
    outline: none;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.sidebar-search-input:focus {
    border-color: #003B7A;
    background: #fff;
}

/* Active page highlight */
.sidebar-nav-link.active {
    background: #e6f0ff;
    color: #003B7A;
    font-weight: 700;
    border-left: 3px solid #003B7A;
    padding-left: 17px;
}

.sidebar-tree-child-link.active {
    background: #e6f0ff;
    color: #003B7A;
    font-weight: 700;
}

.sidebar-title {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
}

.sidebar-close {
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    line-height: 1;
    transition: all 0.3s;
    border-radius: 4px;
}

.sidebar-close:hover {
    background: rgba(0, 0, 0, 0.05);
    color: #003B7A;
}

.sidebar-nav {
    padding: 0;
    margin: 0;
    list-style: none;
}

.sidebar-nav-item {
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: #333;
    text-decoration: none;
    transition: all 0.3s;
}

.sidebar-nav-link:hover {
    background: #e6f7ff;
    color: #003B7A;
    padding-left: 30px;
}

.sidebar-nav-icon {
    margin-right: 12px;
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.sidebar-nav-text {
    font-size: 15px;
    font-weight: 500;
}

.sidebar-section-title {
    padding: 15px 20px 10px;
    font-size: 12px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 10px 0 0;
}

.sidebar-tree-parent {
    border-bottom: 1px solid #f0f0f0;
}

.sidebar-tree-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.sidebar-tree-toggle:hover {
    background: #e6f7ff;
    color: #003B7A;
}

.sidebar-tree-arrow {
    font-size: 11px;
    color: #aaa;
    transition: transform 0.2s;
    margin-left: 8px;
}

.sidebar-tree-parent.open > .sidebar-tree-toggle .sidebar-tree-arrow,
.sidebar-tree-parent.active > .sidebar-tree-toggle .sidebar-tree-arrow {
    transform: rotate(90deg);
}

.sidebar-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    background: #fafbff;
}

.sidebar-tree-parent.open > .sidebar-tree-children,
.sidebar-tree-parent.active > .sidebar-tree-children {
    display: block;
}

.sidebar-tree-child {
    border-top: 1px solid #eef0f8;
}

.sidebar-tree-child-link {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 50px;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.sidebar-tree-child-link:hover {
    background: #eef0ff;
    color: #003B7A;
}

.sidebar-tree-child-link.active-child {
    background: #eef0ff;
    color: #003B7A;
    font-weight: 700;
    border-left: 3px solid #003B7A;
    padding-left: 47px;
}

/* Sidebar Tree Structure */
.sidebar-tree-parent {
    margin: 0;
    padding: 0;
}

.sidebar-tree-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 15px 20px;
    background: none;
    border: none;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    text-align: left;
    transition: background 0.3s, color 0.3s;
}

.sidebar-tree-toggle:hover {
    background: #f5f7ff;
    color: #003B7A;
}

.sidebar-tree-arrow {
    font-size: 12px;
    color: #999;
    transition: transform 0.2s;
    margin-left: auto;
}

.sidebar-nav-item.sidebar-tree-parent.open .sidebar-tree-arrow {
    transform: rotate(90deg);
}

.sidebar-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    background: #fafbff;
}

.sidebar-nav-item.sidebar-tree-parent.open .sidebar-tree-children {
    display: block;
}

.sidebar-tree-child {
    border-top: 1px solid #eef0f8;
}

.sidebar-tree-child-link {
    display: flex;
    align-items: center;
    padding: 12px 20px 12px 50px;
    color: #555;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.3s, color 0.3s;
}

.sidebar-tree-child-link:hover {
    background: #e6f7ff;
    color: #003B7A;
}

.sidebar-tree-child-link.active-child {
    background: #e6f7ff;
    color: #003B7A;
    font-weight: 600;
    border-left: 3px solid #003B7A;
    padding-left: 47px;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
}

.brand-link {
    font-size: 24px;
    font-weight: 700;
    color: white;
    text-decoration: none;
    transition: color 0.3s;
}

.brand-link:hover {
    color: rgba(255, 255, 255, 0.8);
}

.brand-subtitle {
    font-size: 12px;
    color: #999;
    font-weight: 500;
    margin: 0;
}

.navbar-menu {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    flex: 1;
    justify-content: flex-end;
}

.navbar-nav {
    list-style: none;
    display: flex;
    gap: 30px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
}

.nav-item {
    position: relative;
}

.nav-link {
    color: #1f2233;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    padding: 8px 0;
    border-bottom: 3px solid transparent;
}

.nav-link:hover {
    color: #2e2a8f;
    border-bottom-color: #2e2a8f;
    opacity: 1;
}

/* ============ Auth Links Styles ============ */
.navbar-auth {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
    padding-left: 20px;
    border-left: 1px solid #e5e7f0;
    flex-wrap: wrap;
}

.login-links {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.greeting-link {
    color: #1f2233;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    padding: 8px 16px;
    border-radius: 5px;
}

.auth-link {
    color: #1f2233;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    padding: 8px 16px;
    border-radius: 5px;
}

.auth-link:hover {
    color: #2e2a8f;
    background-color: #f0effa;
}

.auth-link.btn-login {
    background: #2e2a8f;
    color: white;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    border-radius: 5px;
}

.auth-link.btn-login:hover {
    color: white;
    background: #211f6b;
    box-shadow: 0 4px 12px rgba(46, 42, 143, 0.3);
    transform: translateY(-1px);
}

.auth-link.btn-logout {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    padding: 10px 20px;
    border: none;
    cursor: pointer;
}

.auth-link.btn-logout:hover {
    color: white;
    background: linear-gradient(135deg, #c82333 0%, #dc3545 100%);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.user-menu {
    position: relative;
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: 30px;
    padding-left: 30px;
    border-left: 1px solid rgba(255, 255, 255, 0.3);
}

.greeting-text {
    color: white;
    font-weight: 600;
    font-size: 16px;
}

.greeting-link {
    color: #1f2233;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 5px;
}

.greeting-link:hover {
    color: #2e2a8f;
    background-color: #f0effa;
    text-decoration: underline;
}

.user-menu-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    padding: 8px 12px;
    border-radius: 5px;
}

.user-menu-toggle:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.2);
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
    min-width: 200px;
    margin-top: 5px;
    z-index: 200;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 12px 20px;
    color: #666;
    text-decoration: none;
    transition: all 0.3s;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
    color: #003B7A;
}

.dropdown-item.logout {
    color: #dc3545;
    border-top: 1px solid #e0e0e0;
}

.dropdown-item.logout:hover {
    background-color: #fff5f5;
}

/* ============ Main Content Area ============ */
.page-content {
    flex: 1;
    background: #f5f5f5;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    min-height: auto;
}

.page-content .container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 900px;
    width: 100%;
    padding: 30px;
    margin: 0 auto;
}

.page-main-content .container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 900px;
    width: 100%;
    padding: 30px;
    margin: 0 auto;
}

.container {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    max-width: 900px;
    width: 100%;
    padding: 30px;
    margin: 0 auto;
}

.container.profile-container-wrapper {
    max-width: 1100px;
}

h1 {
    color: #333;
    text-align: center;
    margin-bottom: 30px;
    font-size: 2em;
}

/* ============ Footer Styles ============ */
.smarkui-footer {
    background: white;
    border-top: 1px solid #e0e0e0;
    padding: 20px 0;
    flex-shrink: 0;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
}

.footer-section {
    display: flex;
    align-items: center;
}

.footer-copyright {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.footer-links {
    list-style: none;
    display: flex;
    gap: 20px;
    margin: 0;
    padding: 0;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links li a {
    color: #666;
    text-decoration: none;
    font-size: 13px;
    transition: color 0.3s;
}

.footer-links li a:hover {
    color: #003B7A;
}

/* ============ Tabs ============ */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    border-bottom: 2px solid #e0e0e0;
}

.tab {
    padding: 12px 24px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #666;
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.tab:hover {
    color: #003B7A;
}

.tab.active {
    color: #003B7A;
    border-bottom-color: #003B7A;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

/* ============ Forms ============ */
.form-group {
    margin-bottom: 20px;
}

/* Modal-edited rich-text fields (SmEditor Pattern B - see skill_smeditor.md): a read-only preview
   + an Edit button that opens the page's shared #editorModal. Used by AddQuestion.html (Solution /
   Statement / Assertion / Reason / Options) and AddTest.html (Instructions). */
.aq-medit { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.aq-medit-preview {
    width: 100%; box-sizing: border-box; min-height: 42px; max-height: 110px; overflow: auto;
    border: 1px solid #d9e2ec; border-radius: 6px; padding: 9px 12px;
    background: #f8fafc; color: #3b4a5a; font-size: 13px; line-height: 1.5;
    white-space: pre-wrap; word-break: break-word;
}
.aq-medit-preview:empty::before { content: attr(data-empty); color: #9aa5b1; font-style: italic; }

.form-section-group {
    margin-bottom: 35px;
    padding-bottom: 25px;
    border-bottom: 1px solid #e0e0e0;
}

.form-section-group:last-of-type {
    border-bottom: none;
}

.form-section-header {
    color: #003B7A;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 20px 0;
}

.form-help {
    display: block;
    font-size: 12px;
    color: #999;
    margin-top: 5px;
}

.input-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
}

label .required {
    color: #dc3545;
    font-weight: 700;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: border-color 0.3s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #003B7A;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select.country-select {
    cursor: pointer;
}

button[type="submit"], .btn-update-profile {
    width: 100%;
    padding: 14px;
    background: #003B7A;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 20px;
}

button[type="submit"]:hover, .btn-update-profile:hover {
    background: #002a5c;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 59, 122, 0.4);
}

button[type="submit"]:active, .btn-update-profile:active {
    transform: translateY(0);
}

/* ============ Results & Feedback ============ */
.result {
    margin-top: 20px;
    padding: 15px;
    border-radius: 5px;
    display: none;
}

.result.success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.result.error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.result.show {
    display: block;
    animation: slideDown 0.3s;
}

.result-title {
    font-weight: 600;
    margin-bottom: 10px;
}

.result-data {
    background: rgba(255, 255, 255, 0.5);
    padding: 10px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============ Loading ============ */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.show {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #003B7A;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

/* ============ Modals ============ */
.modal {
    display: none;
    position: fixed;
    z-index: 1003;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s;
    overflow-y: auto;
}

.modal.show {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px 0;
}

.modal-content {
    background-color: white;
    padding: 40px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 400px;
    min-width: 350px;
    animation: slideDown 0.3s;
    margin: 20px auto;
    position: relative;
}

.modal-content.success {
    border-top: 5px solid #28a745;
}

.modal-content.error {
    border-top: 5px solid #dc3545;
}

.modal-icon {
    font-size: 70px;
    margin-bottom: 20px;
    font-weight: bold;
    line-height: 1;
    display: block;
}

.modal-icon.success-icon {
    color: #28a745;
}

.modal-icon.error-icon {
    color: #dc3545;
}

.modal-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
}

.modal-content.success .modal-title {
    color: #28a745;
}

.modal-content.error .modal-title {
    color: #dc3545;
}

.modal-message {
    font-size: 16px;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.6;
}

.modal-button {
    background: #003B7A;
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 120px;
}

.modal-button:hover {
    background: #002a5c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 59, 122, 0.4);
}

.modal-button:active {
    transform: translateY(0);
}

/* ============ Animations ============ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ============ Profile Styles ============ */
.profile-card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    padding: 0;
    margin-top: 20px;
}

.profile-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.profile-section {
    padding: 30px;
    border-bottom: 2px solid #f0f0f0;
}

.profile-section:last-child {
    border-bottom: none;
}

.profile-section-title {
    color: #003B7A;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 20px 0;
    padding-bottom: 10px;
    border-bottom: 2px solid #e0e0e0;
}

.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.profile-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-item-full {
    grid-column: 1 / -1;
}

.profile-item label {
    font-size: 11px;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.profile-item span {
    font-size: 14px;
    color: #333;
    font-weight: 500;
    word-break: break-word;
}

.user-key {
    font-family: 'Courier New', monospace;
    font-size: 11px;
    color: #003B7A;
    background: #e6f7ff;
    padding: 6px 10px;
    border-radius: 5px;
    display: inline-block;
}

.timestamp {
    font-size: 14px;
    color: #666;
}

.status-badge {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.status-active {
    background: #d4edda;
    color: #28a745;
}

.status-badge.status-inactive {
    background: #f8d7da;
    color: #dc3545;
}

.btn-change-password {
    margin-top: 20px;
    padding: 12px 24px;
    background: #003B7A;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-block;
}

.btn-change-password:hover {
    background: #002a5c;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 59, 122, 0.4);
}

.btn-change-password:active {
    transform: translateY(0);
}

.error-message {
    text-align: center;
    padding: 40px 30px;
    color: #dc3545;
    background: #fff5f5;
    border-radius: 10px;
    margin-top: 20px;
}

.error-message p {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.error-message pre {
    font-size: 12px;
    text-align: left;
    background: #f5f5f5;
    padding: 15px;
    border-radius: 5px;
    margin-top: 15px;
    max-height: 300px;
    overflow: auto;
    border: 1px solid #e0e0e0;
}

/* ============ Responsive Design ============ */
/* Medium screens (tablets) */
@media (max-width: 1200px) {
    .navbar-container {
        padding: 10px 15px;
    }

    .navbar-auth {
        margin-left: 15px;
        padding-left: 15px;
        gap: 6px;
    }

    .login-links {
        gap: 6px;
    }

    .auth-link.btn-login {
        font-size: 12px;
        padding: 5px 10px;
    }
}

/* Small screens (mobile) */
@media (max-width: 768px) {
    .navbar-container {
        height: auto;
        min-height: 70px;
        padding: 10px 15px;
        flex-wrap: wrap;
    }

    .brand-link {
        font-size: 20px;
    }

    .navbar-nav {
        gap: 15px;
    }

    .nav-link {
        font-size: 14px;
    }

    .brand-subtitle {
        display: none;
    }

    .navbar-auth {
        border-left: none;
        padding-left: 0;
        margin-left: 0;
        width: 100%;
        justify-content: center;
        padding-top: 10px;
    }

    .login-links {
        width: 100%;
        justify-content: center;
    }

    .auth-link.btn-login {
        font-size: 12px;
        padding: 5px 10px;
    }

    .navbar-auth {
        margin-left: 15px;
        padding-left: 15px;
        gap: 10px;
    }

    .user-menu {
        margin-left: 15px;
        padding-left: 15px;
        gap: 10px;
    }

    .greeting-text {
        font-size: 14px;
    }

    .auth-link {
        padding: 6px 12px;
        font-size: 13px;
    }

    .auth-link.btn-login {
        padding: 8px 16px;
    }

    .user-menu-toggle {
        font-size: 12px;
        padding: 6px 10px;
    }

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

    .profile-section {
        padding: 25px;
    }

    /* Adjust dynamic sidebar for mobile */
    #dynamicSidebarMenu {
        top: 70px;
        height: calc(100vh - 70px);
    }

    #dynamicSidebarOverlay {
        top: 70px;
        height: calc(100vh - 70px);
    }
}

@media (max-width: 600px) {
    .input-row {
        grid-template-columns: 1fr;
    }

    .tabs {
        flex-direction: column;
    }

    h1 {
        font-size: 1.5em;
    }

    .navbar-nav {
        gap: 10px;
    }

    .navbar-auth {
        flex-direction: column;
        gap: 5px;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
    }

    .user-menu {
        flex-direction: column;
        gap: 5px;
        margin-left: 0;
        padding-left: 0;
        border-left: none;
        align-items: stretch;
    }

    .greeting-text {
        font-size: 14px;
        text-align: center;
        margin-right: 0;
    }

    .auth-link {
        width: 100%;
        padding: 10px;
        text-align: center;
        border-radius: 5px;
    }

    .auth-link.btn-login {
        padding: 10px;
        font-size: 15px;
    }

    .user-menu-toggle {
        padding: 10px;
        font-size: 15px;
    }

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

    .profile-section {
        padding: 20px;
    }

    .profile-section-title {
        font-size: 16px;
    }

    .profile-item label {
        font-size: 11px;
    }

    .profile-item span {
        font-size: 14px;
    }

    .user-key {
        font-size: 11px;
        padding: 6px 10px;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 15px;
    }

    .footer-links {
        gap: 15px;
    }

    .footer-links li a {
        font-size: 13px;
    }

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

    .role-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
}

/* ============ Left Tree Menu Styles ============ */
.page-layout {
    display: flex;
    flex: 1;
    background: #f5f5f5;
    min-height: 0;
    overflow: hidden;
}

.left-tree-menu {
    width: 240px;
    flex-shrink: 0;
    background: white;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.08);
    overflow-y: auto;
    padding: 20px 0;
    align-self: stretch;
}

.tree-section-title {
    padding: 10px 20px 6px;
    font-size: 11px;
    font-weight: 700;
    color: #aaa;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.tree-parent {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tree-parent-item {
    border-bottom: 1px solid #f0f0f0;
}

.tree-parent-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    user-select: none;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
}

.tree-parent-link:hover,
.tree-parent-link.active-parent {
    background: #f5f7ff;
    color: #003B7A;
}

.tree-parent-icon {
    margin-right: 10px;
    font-size: 16px;
    width: 18px;
    text-align: center;
}

.tree-parent-arrow {
    font-size: 11px;
    color: #aaa;
    transition: transform 0.2s;
}

.tree-parent-item.open > .tree-parent-link .tree-parent-arrow {
    transform: rotate(90deg);
}

.tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
    display: none;
    background: #fafbff;
}

.tree-parent-item.open > .tree-children {
    display: block;
}

.tree-child-item {
    border-top: 1px solid #eef0f8;
}

.tree-child-link {
    display: flex;
    align-items: center;
    padding: 10px 20px 10px 44px;
    color: #555;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}

.tree-child-link:hover {
    background: #eef0ff;
    color: #003B7A;
}

.tree-child-link.active-child {
    background: #eef0ff;
    color: #003B7A;
    font-weight: 700;
    border-left: 3px solid #003B7A;
    padding-left: 41px;
}

.tree-child-icon {
    margin-right: 8px;
    font-size: 13px;
}

.page-main-content {
    flex: 1;
    padding: 30px 20px;
    min-width: 0;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.page-main-content .container {
    max-width: 900px;
    width: 100%;
}

@media (max-width: 768px) {
    .left-tree-menu {
        display: none;
    }
    .page-layout {
        flex-direction: column;
    }
    .page-main-content {
        padding: 20px 15px;
    }
}

/* ============ List Search Bar ============ */
.list-search-bar {
    display: flex;
    align-items: center;
    background: #f5f7ff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    padding: 0 14px;
    margin-bottom: 20px;
    transition: border-color 0.3s;
}

.list-search-bar:focus-within {
    border-color: #003B7A;
    background: #fff;
}

.list-search-icon {
    font-size: 18px;
    color: #aaa;
    margin-right: 10px;
    flex-shrink: 0;
}

.list-search-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 0;
    font-size: 15px;
    color: #333;
    outline: none;
    width: 100%;
}

.list-search-input::placeholder {
    color: #bbb;
}

.list-search-no-results {
    text-align: center;
    color: #999;
    padding: 30px 0;
    font-size: 15px;
}

/* ============ List Filter Bar ============ */
.list-filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.list-filter-label {
    font-size: 14px;
    font-weight: 600;
    color: #555;
    white-space: nowrap;
    margin: 0;
}

.list-filter-select {
    flex: 1;
    max-width: 320px;
    padding: 10px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    background: #f5f7ff;
    cursor: pointer;
    transition: border-color 0.3s;
}

.list-filter-select:focus {
    outline: none;
    border-color: #003B7A;
    background: #fff;
}

/* ============ Company Card Styles ============ */
.company-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    background: white;
    transition: box-shadow 0.2s;
}

.company-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.company-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f0f0f0;
}

.company-name {
    font-size: 20px;
    font-weight: 700;
    color: #333;
}

.company-code {
    font-size: 14px;
    color: #003B7A;
    font-weight: 600;
    background: #f5f7ff;
    padding: 4px 12px;
    border-radius: 4px;
}

.company-actions {
    display: flex;
    gap: 10px;
}

.company-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
}

.info-label {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.info-value {
    font-size: 14px;
    color: #333;
    font-weight: 500;
}

@media (max-width: 600px) {
    .company-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .company-info {
        grid-template-columns: 1fr;
    }
}

/* ============ Role Management Styles ============ */
.permission-category {
    margin-bottom: 25px;
    border: 1px solid #e0e0e0;
    border-radius: 5px;
    padding: 15px;
    background: #f9f9f9;
}

.permission-category-title {
    color: #003B7A;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 15px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.category-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.permission-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-left: 28px;
}

.permission-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 3px;
    cursor: pointer;
    transition: all 0.2s;
}

.permission-item:hover {
    background: #f5f7ff;
    border-color: #003B7A;
}

.permission-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.permission-item span {
    font-size: 14px;
    color: #333;
}

.role-card {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 15px;
    background: white;
    transition: box-shadow 0.2s;
}

.role-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.role-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.role-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.role-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-view {
    background: #003B7A;
    color: white;
}

.btn-view:hover {
    background: #5568d3;
}

.btn-edit {
    background: #28a745;
    color: white;
}

.btn-edit:hover {
    background: #218838;
}

.btn-delete {
    background: #dc3545;
    color: white;
}

.btn-delete:hover {
    background: #c82333;
}

.role-description {
    color: #666;
    margin-bottom: 10px;
}

.role-permissions {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
}

.permission-badge {
    display: inline-block;
    padding: 4px 8px;
    background: #f0f0f0;
    border-radius: 3px;
    font-size: 12px;
    color: #666;
}

/* --- Company Grid (Assign Role to User) --- */
.companies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    padding: 4px 0;
}

.company-grid-cell {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    user-select: none;
}

.company-grid-cell:hover {
    border-color: #003B7A;
    background: #f5f7ff;
}

.company-grid-cell input[type="checkbox"] {
    accent-color: #003B7A;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

.company-grid-cell input[type="checkbox"]:checked + .company-grid-name {
    color: #003B7A;
    font-weight: 600;
}

.company-grid-cell:has(input:checked) {
    border-color: #003B7A;
    background: #eef0ff;
}

.company-grid-name {
    font-size: 14px;
    color: #333;
}

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

/* --- User Current Assignments (Assign Role to User tab) --- */
.user-assignments-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.assignment-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    flex-wrap: wrap;
}

.assignment-company {
    font-size: 13px;
    font-weight: 600;
    color: #444;
    min-width: 140px;
    flex-shrink: 0;
}

.assignment-roles {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

/* Deletable role badge inside assignments grid */
.assignment-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px 3px 10px;
    background: #eef0ff;
    border: 1px solid #c5caff;
    border-radius: 4px;
    font-size: 12px;
    color: #444;
    font-weight: 500;
}

.assignment-badge-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: #888;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
    border-radius: 3px;
    transition: color 0.15s, background 0.15s;
}

.assignment-badge-delete:hover {
    color: #dc3545;
    background: #fde8ea;
}

/* Current assignments table (Assign Role to User tab) */
.assign-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.assign-table-header {
    text-align: left;
    padding: 8px 12px;
    background: #f0f0f7;
    color: #555;
    font-weight: 600;
    border-bottom: 2px solid #ddd;
}

.assign-table-cell {
    padding: 8px 12px;
    border-bottom: 1px solid #eee;
    color: #444;
    vertical-align: middle;
}

.assign-table-action {
    width: 90px;
}

/* ============ Chatbot Styles ============ */

/* SMark Modules Tree Table */
.modules-tree-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    font-size: 14px;
}

.modules-tree-table thead {
    background: #003B7A;
    color: white;
}

.modules-tree-table thead th {
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modules-tree-table tbody tr {
    border-bottom: 1px solid #e0e0e0;
    transition: background 0.2s;
}

.modules-tree-table tbody tr:hover {
    background: #f5f7ff;
}

.modules-tree-table tbody td {
    padding: 12px 15px;
    color: #333;
    vertical-align: middle;
}

.module-row[data-level="1"] {
    background: #fafbff;
}

.module-row[data-level="2"] {
    background: #f5f7ff;
}

.module-row[data-level="3"] {
    background: #f0f4ff;
}

.module-expand-btn {
    background: none;
    border: none;
    color: #003B7A;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    margin-right: 8px;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.module-expand-btn:hover {
    color: #B946B2;
    transform: scale(1.2);
}

.module-expand-btn[aria-expanded="true"] {
    color: #B946B2;
}

@media (max-width: 768px) {
    .modules-tree-table {
        font-size: 12px;
    }

    .modules-tree-table thead th {
        padding: 10px 8px;
        font-size: 11px;
    }

    .modules-tree-table tbody td {
        padding: 10px 8px;
    }

    /* Responsive header styles */
    .navbar-container {
        flex-direction: column;
        min-height: auto;
        padding: 15px 10px;
    }

    .header-logo-section {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .header-logo {
        height: 60px;
        width: 60px;
    }

    .header-title {
        font-size: 16px;
    }

    .header-subtitle {
        font-size: 11px;
    }

    .navbar-menu {
        width: 100%;
        flex-direction: column;
        gap: 10px;
    }

    .navbar-nav {
        width: 100%;
        justify-content: center;
        gap: 15px;
        flex-wrap: wrap;
    }

    .navbar-auth {
        width: 100%;
        justify-content: center;
        padding-left: 0;
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, 0.3);
        padding-top: 10px;
        margin-left: 0;
    }

    .login-links {
        justify-content: center;
        width: 100%;
    }

    .auth-link.btn-login {
        padding: 8px 12px;
        font-size: 11px;
    }
}
    }
}

/* ============ Chatbot Styles ============ */

/* Chatbot Page - Full Chat Container */
.chat-container {
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

.chat-messages {
    height: 500px;
    overflow-y: auto;
    padding: 20px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chat-message {
    display: flex;
    flex-direction: column;
    gap: 5px;
    animation: fadeIn 0.3s;
}

.message-content {
    padding: 12px 16px;
    border-radius: 8px;
    max-width: 80%;
    line-height: 1.5;
    word-wrap: break-word;
}

.user-message .message-content {
    background: #003B7A;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e0e0e0;
    align-self: flex-start;
}

.message-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #e0e0e0;
    font-size: 12px;
    color: #666;
}

.source-tag {
    display: inline-block;
    background: #f0f0f0;
    padding: 2px 8px;
    border-radius: 3px;
    margin-right: 5px;
    margin-top: 3px;
    font-size: 11px;
    color: #555;
}

.chat-input-container {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: white;
    border-top: 2px solid #e0e0e0;
}

.chat-input {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    resize: none;
    min-height: 50px;
    max-height: 120px;
}

.chat-input:focus {
    outline: none;
    border-color: #003B7A;
}

.chat-send-btn {
    padding: 12px 24px;
    background: #003B7A;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    align-self: flex-end;
}

.chat-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.chat-send-btn:active {
    transform: translateY(0);
}

/* Documents Grid */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.document-card {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s;
    cursor: default;
}

.document-card:hover {
    border-color: #003B7A;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.document-icon {
    font-size: 40px;
    margin-bottom: 10px;
    color: #003B7A;
}

.document-name {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
    word-break: break-word;
}

.document-info {
    font-size: 11px;
    color: #999;
}

/* ============ Floating Chatbot Widget ============ */
.chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
}

.chat-widget-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #003B7A;
    color: white;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-widget-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.5);
}

.chat-widget-window {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: none;
    flex-direction: column;
    overflow: hidden;
}

.chat-widget-window.show {
    display: flex;
    animation: slideUp 0.3s;
}

.chat-widget-header {
    background: #003B7A;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-widget-title {
    font-size: 16px;
    font-weight: 600;
}

.chat-widget-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.chat-widget-close-btn:hover {
    opacity: 0.8;
}

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-widget-input-container {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.chat-widget-input {
    flex: 1;
    padding: 10px;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    resize: none;
    min-height: 40px;
    max-height: 80px;
}

.chat-widget-input:focus {
    outline: none;
    border-color: #003B7A;
}

.chat-widget-send-btn {
    width: 40px;
    height: 40px;
    background: #003B7A;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: flex-end;
}

.chat-widget-send-btn:hover {
    transform: scale(1.05);
}

.widget-loading {
    padding: 10px;
    text-align: center;
}

.widget-loading .spinner {
    width: 30px;
    height: 30px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (max-width: 768px) {
    .chat-widget-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 40px);
        bottom: 20px;
        right: 20px;
    }

    .chat-messages {
        height: 400px;
    }
}

@media (max-width: 480px) {
    .chat-widget-toggle {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .chat-widget-window {
        width: 100vw;
        height: 100vh;
        bottom: 0;
        right: 0;
        border-radius: 0;
    }

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

/* ============ Chapter Management WYSIWYG ============ */
/* TinyMCE provides its own editor UI styles. */

/* ============ Add Question Page ============ */
.aq-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    gap: 20px;
    align-items: start;
}

.aq-left-col {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.aq-right-col {
    min-width: 0;
}

@media (max-width: 900px) {
    .aq-layout {
        grid-template-columns: 1fr;
    }
    .aq-left-col {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

.aq-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 14px;
    background: #f5f8fc;
    border: 1px solid #dde6f0;
    border-radius: 6px;
    font-size: 13px;
    color: #333;
    margin-bottom: 16px;
}

.aq-breadcrumb .aq-crumb {
    font-weight: 600;
    color: #003B7A;
}

.aq-breadcrumb .aq-sep {
    color: #999;
}

.aq-banner {
    padding: 12px 16px;
    background: #eef4ff;
    border: 1px solid #c9dcfc;
    border-radius: 6px;
    color: #1a4b8c;
    font-size: 14px;
    margin-bottom: 16px;
}

.aq-multiselect {
    position: relative;
}

.aq-multiselect-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
    font-size: 14px;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    text-align: left;
    background: white;
    color: #333;
    cursor: pointer;
    transition: border-color 0.3s;
}

.aq-multiselect-toggle:focus,
.aq-multiselect-toggle.open {
    outline: none;
    border-color: #003B7A;
}

.aq-multiselect-toggle > span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aq-multiselect-toggle::after {
    content: '';
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-right: 2px solid #888;
    border-bottom: 2px solid #888;
    transform: rotate(45deg);
    margin-top: -4px;
    transition: transform 0.2s;
}

.aq-multiselect-toggle.open::after {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.aq-multiselect-panel {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    z-index: 20;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.12);
    max-height: 240px;
    overflow-y: auto;
    padding: 8px;
}

.aq-multiselect-panel.show {
    display: block;
}

.aq-multiselect-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
}

.aq-multiselect-option:hover {
    background: #f5f8fc;
}

.aq-multiselect-option input {
    width: auto;
}

.aq-tag-box {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border: 2px solid #e0e0e0;
    border-radius: 5px;
}

.aq-tag-box.disabled {
    background: #f5f5f5;
}

.aq-tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e8eefc;
    color: #1976d2;
    border-radius: 14px;
    padding: 4px 10px;
    font-size: 13px;
    font-weight: 500;
}

.aq-tag-chip .aq-tag-remove {
    cursor: pointer;
    font-weight: 700;
    line-height: 1;
}

.aq-tag-box input {
    flex: 1;
    min-width: 140px;
    border: none;
    padding: 4px;
    outline: none;
    width: auto;
}

.aq-type-section {
    display: none;
}

.aq-type-section.active {
    display: block;
}

.aq-options-header {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #888;
    font-weight: 600;
    padding: 0 0 10px 0;
}

.aq-blank-row, .aq-matrix-row {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

/* Question Options are a mini TinyMCE editor (see initOptionEditor), not a single-line input -
   align to the top of the row so the badge/correct-checkbox sit near its toolbar instead of
   dead-center against the whole (taller) editor block. */
.aq-option-row {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    align-items: start;
    gap: 10px;
    margin-bottom: 12px;
}

.aq-option-row .aq-option-left,
.aq-option-row .aq-row-remove {
    margin-top: 6px;
}

.aq-blank-row {
    grid-template-columns: 90px 1fr 40px;
}

.aq-option-left {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.aq-option-badge {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    flex-shrink: 0;
}

.aq-option-correct {
    width: auto;
}

.aq-row-remove {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.aq-tf-group {
    display: flex;
    gap: 24px;
}

.aq-tf-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    width: auto;
    margin: 0;
}

.aq-tf-group input {
    width: auto;
}

.aq-matrix-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.aq-matrix-col-header {
    font-weight: 600;
    color: #003B7A;
    margin-bottom: 12px;
}

/* Matrix left/right item text is also a mini editor now (see initOptionEditor) - align to the
   top for the same reason as .aq-option-row above. Column A is just content (no matches
   selector/correctness state - see the Answer Options section instead), so this is a simple
   badge + text + remove row. */
.aq-matrix-row-left {
    display: grid;
    grid-template-columns: 32px 1fr 32px;
    gap: 8px;
    align-items: start;
    margin-bottom: 12px;
}

.aq-matrix-row-left .aq-option-badge,
.aq-matrix-row-left .aq-row-remove {
    margin-top: 6px;
}

.aq-matrix-row-right {
    display: grid;
    grid-template-columns: 60px 1fr 32px;
    gap: 8px;
    align-items: start;
    margin-bottom: 12px;
}

.aq-matrix-row-right .aq-matrix-right-label,
.aq-matrix-row-right .aq-row-remove {
    margin-top: 6px;
}

.aq-subq-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 8px;
    gap: 12px;
}

.aq-subq-item .aq-subq-text {
    flex: 1;
    font-size: 14px;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.aq-subq-meta {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

/* Assertion-Reason has no separate Question editor (it's hidden - the Assertion and Reason
   statements are the content). Collapse the space the hidden field would otherwise leave
   below the Question Type dropdown so the next section follows on without a dangling gap. */
#questionEntrySection.aq-hide-question-text {
    padding-bottom: 0;
}

@media (max-width: 768px) {
    .aq-matrix-columns {
        grid-template-columns: 1fr;
    }
}

/* ---- Comprehensive: passage marks budget tally + inline sub-question editor ---- */
.aq-marks-tally {
    margin: 12px 0 0;
    padding: 8px 12px;
    border-radius: 6px;
    background: #eef6ee;
    border: 1px solid #cfe6cf;
    color: #2f6f2f;
    font-size: 13px;
    font-weight: 600;
}
.aq-marks-tally.over {
    background: #fdecec;
    border-color: #f5c2c2;
    color: #b02a2a;
}

.aq-compsubq {
    border: 1px solid #d9e2ec;
    border-radius: 8px;
    padding: 16px;
    margin: 16px 0;
    background: #fbfdff;
}
.aq-compsubq-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}
.aq-compsubq-title {
    font-weight: 700;
    color: #003B7A;
}
.aq-compsubq-saved {
    font-size: 12px;
    color: #2f6f2f;
    font-weight: 600;
    margin-left: 8px;
}
.aq-compsubq-mode {
    display: flex;
    gap: 20px;
    align-items: center;
    margin: 10px 0;
    font-size: 14px;
}
.aq-compsubq-mode label {
    display: flex;
    align-items: center;
    gap: 6px;
}
.aq-compsubq-marks {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 12px;
}
@media (max-width: 700px) {
    .aq-compsubq-marks {
        grid-template-columns: 1fr 1fr;
    }
}

/* ============ View Questions Page ============ */
.vq-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    align-items: start;
}

.vq-left-col {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.vq-right-col {
    min-width: 0;
}

@media (max-width: 900px) {
    .vq-layout {
        grid-template-columns: 1fr;
    }
    .vq-left-col {
        position: static;
        max-height: none;
        overflow-y: visible;
    }
}

.vq-tree, .vq-tree-children {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 13px;
}

.vq-tree-children {
    padding-left: 18px;
    display: none;
}

.vq-tree-node.expanded > .vq-tree-children {
    display: block;
}

.vq-tree-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px;
    border-radius: 4px;
    cursor: pointer;
    user-select: none;
}

.vq-tree-row:hover {
    background: #f5f7ff;
}

.vq-tree-node.selected > .vq-tree-row {
    background: #eef0ff;
    color: #003B7A;
    font-weight: 700;
}

.vq-tree-toggle {
    width: 14px;
    flex-shrink: 0;
    text-align: center;
    font-size: 11px;
    color: #888;
    display: inline-block;
    transition: transform 0.15s;
}

.vq-tree-node.expanded > .vq-tree-row .vq-tree-toggle {
    transform: rotate(90deg);
}

.vq-tree-toggle-spacer {
    width: 14px;
    flex-shrink: 0;
}

.vq-tree-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.vq-tree-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.vq-tree-loading, .vq-tree-empty {
    padding: 6px 6px 6px 24px;
    font-size: 12px;
    color: #999;
    font-style: italic;
    list-style: none;
}

.vq-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 16px;
}

.vq-filters select {
    width: auto;
    min-width: 160px;
    padding: 8px 10px;
}

.vq-row-actions {
    display: flex;
    gap: 6px;
}

/* Icon-only row actions (View / Edit / Delete) for the questions grid. */
.vq-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid #d0d7e2;
    border-radius: 5px;
    background: #fff;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.vq-icon-btn svg {
    width: 16px;
    height: 16px;
    fill: #5a6b7f;
    transition: fill 0.15s;
}
.vq-icon-btn:hover { background: #f0f4f9; }
.vq-icon-btn.view:hover { border-color: #003B7A; }
.vq-icon-btn.view:hover svg { fill: #003B7A; }
.vq-icon-btn.edit:hover { border-color: #28a745; }
.vq-icon-btn.edit:hover svg { fill: #28a745; }
.vq-icon-btn.delete:hover { border-color: #dc3545; }
.vq-icon-btn.delete:hover svg { fill: #dc3545; }

.vq-pager {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.vq-pager select {
    width: auto;
    padding: 6px 10px;
}

.vq-pager button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#questionsGrid .sm-dg-pagination {
    display: none;
}

.status-badge.status-draft {
    background: #eee;
    color: #555;
}

.status-badge.status-scrutiny {
    background: #fff3cd;
    color: #8a6d00;
}

.status-badge.status-approved {
    background: #d4edda;
    color: #155724;
}

.status-badge.status-rejected {
    background: #f8d7da;
    color: #721c24;
}

/* ============ View Question (single, question-paper preview) ============ */
.vqp-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.vqp-meta {
    display: flex;
    align-items: baseline;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 2px solid #e0e0e0;
}
.vqp-qno { font-size: 20px; font-weight: 700; color: #003B7A; }
.vqp-type {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #5a6b7f;
    background: #eef3f9;
    border-radius: 4px;
    padding: 3px 8px;
}
.vqp-marks { margin-left: auto; font-size: 14px; color: #444; white-space: nowrap; }

.vqp-body { font-size: 15px; line-height: 1.7; color: #1f2937; }
.vqp-body img { max-width: 100%; height: auto; }
.vqp-body p { margin: 0 0 10px; }

.vqp-passage {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 18px;
}

.vqp-qtext { margin-bottom: 12px; }

.vqp-block { margin: 12px 0; }
.vqp-labelled { display: flex; gap: 10px; margin-bottom: 8px; }
.vqp-tag {
    flex: 0 0 auto;
    font-weight: 700;
    color: #003B7A;
    min-width: 108px;
}

.vqp-inline-choices { margin: 10px 0; font-weight: 600; }

.vqp-options { margin: 12px 0 4px; display: flex; flex-direction: column; gap: 8px; }
.vqp-option {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 10px;
    border: 1px solid #e5e9f0;
    border-radius: 6px;
}
.vqp-option.is-correct { background: #e9f7ec; border-color: #b7e2c3; }
.vqp-opt-label { font-weight: 700; color: #003B7A; flex: 0 0 auto; }
.vqp-opt-text { flex: 1 1 auto; }
.vqp-correct-mark { color: #1e7e34; font-weight: 700; flex: 0 0 auto; }

.vqp-matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 14px 0; }
.vqp-matrix-col { border: 1px solid #e5e9f0; border-radius: 6px; padding: 10px 12px; }
.vqp-matrix-head { font-weight: 700; color: #003B7A; margin-bottom: 8px; }
.vqp-matrix-row { display: flex; gap: 8px; margin-bottom: 6px; }
@media (max-width: 640px) { .vqp-matrix { grid-template-columns: 1fr; } }

.vqp-subq { margin-top: 20px; padding-top: 16px; border-top: 1px dashed #d5dde7; }
.vqp-subq-head { font-weight: 700; color: #003B7A; margin-bottom: 8px; }

.vqp-answer { font-size: 15px; margin: 4px 0 12px; }
.vqp-blank-key { margin: 4px 0 12px 22px; }
.vqp-solution { margin-top: 12px; padding: 12px 14px; background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px; }
.vqp-ref { font-size: 13px; color: #555; margin: 6px 0 0; }
.vqp-key-block { margin-bottom: 18px; padding-bottom: 14px; border-bottom: 1px dashed #d5dde7; }
.vqp-key-block:last-child { border-bottom: none; }

/* Metadata header saved with the question (chapter path / type / objective / status / ...) */
.vqh {
    background: #efefef;
    border-radius: 10px 10px 0 0;
    font-size: 13.5px;
    color: #1f2937;
    overflow: hidden;
}
.vqh-path {
    font-weight: 700;
    padding: 12px 18px;
    border-bottom: 1px solid #bcd6ea;
}
.vqh-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px 24px;
    padding: 12px 18px;
    border-bottom: 1px solid #bcd6ea;
}
.vqh-col { display: flex; flex-direction: column; gap: 8px; }
.vqh-foot {
    display: flex;
    align-items: center;
    gap: 28px;
    flex-wrap: wrap;
    padding: 12px 18px;
}
.vqh-item { line-height: 1.5; }
.vqh-label { font-weight: 700; }
.vqh-value { word-break: break-word; }
.vqh-actions { margin-left: auto; display: flex; gap: 24px; }
.vqh-actions a { color: #1155cc; text-decoration: underline; cursor: pointer; }
.vqh-actions a:hover { color: #003B7A; }
@media (max-width: 800px) {
    .vqh-grid { grid-template-columns: 1fr 1fr; }
    .vqh-actions { margin-left: 0; }
}
@media (max-width: 560px) {
    .vqh-grid { grid-template-columns: 1fr; }
}

@media print {
    #headerContainer, #dynamicSidebarContainer, #footerContainer,
    .vqp-toolbar, #chatWidget, .chat-widget-toggle, .sidebar-toggle {
        display: none !important;
    }
    .page-content, .container { padding: 0 !important; }
    .profile-card { box-shadow: none !important; border: none !important; }
    .vqh { border-radius: 0; }
}

/* ============ Test Management (list / add-edit / view) ============ */
/* Paper Structure table - shared by the editable AddTest form and the read-only ViewTest page. */
.ts-table-wrap {
    overflow-x: auto;
    margin-bottom: 10px;
}

.ts-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    min-width: 760px;
}

.ts-table th {
    background: #003B7A;
    color: #fff;
    text-align: left;
    padding: 10px 8px;
    font-weight: 600;
    white-space: nowrap;
}

.ts-table td {
    padding: 6px 8px;
    border-bottom: 1px solid #e5e9f0;
    vertical-align: middle;
}

.ts-table tbody tr:hover {
    background: #f8fafc;
}

.ts-table input[type="text"],
.ts-table input[type="number"] {
    width: 100%;
    padding: 7px 8px;
    border: 1px solid #d9e2ec;
    border-radius: 4px;
    font-size: 13px;
}

.ts-table .ts-total-cell {
    font-weight: 600;
    color: #003B7A;
    white-space: nowrap;
}

.ts-table .ts-remove-col {
    width: 36px;
    text-align: center;
}

/* Question Type multi-select on each Paper Structure row. */
.ts-table select[multiple] {
    width: 100%;
    min-width: 150px;
    padding: 4px;
    border: 1px solid #d9e2ec;
    border-radius: 4px;
    font-size: 13px;
}

.ts-empty-row td {
    text-align: center;
    color: #999;
    font-style: italic;
    padding: 16px 8px;
}

/* Created/updated attribution strip at the top of the read-only Test Detail page. */
.tv-meta {
    font-size: 12px;
    color: #888;
    margin-bottom: 18px;
}

.tv-meta strong {
    color: #555;
}

/* ============ PYQ Paper Import (UploadPYQ.html) ============ */

/* PDF drag-and-drop zone. Disabled (no Test picked yet) greys everything out and blocks the click
   handler in JS - the file input stays truly `disabled` too, so a stray drop can't sneak a file in. */
.upy-dropzone {
    border: 2px dashed #c9d4e0;
    border-radius: 8px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    background: #fafbfc;
}

.upy-dropzone:hover {
    border-color: #1976d2;
}

.upy-dropzone.dragover {
    border-color: #1976d2;
    background: #eef4ff;
}

.upy-dropzone.disabled {
    cursor: not-allowed;
    background: #f4f6f9;
    border-color: #dde3ea;
    opacity: 0.7;
}

.upy-dropzone-icon {
    font-size: 32px;
    margin-bottom: 8px;
}

.upy-dropzone-text {
    color: #333;
    font-weight: 600;
    font-size: 14px;
}

.upy-dropzone-hint {
    color: #888;
    font-size: 12px;
    margin-top: 4px;
}

.upy-inline-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f1aeb5;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin: 10px 0;
}

/* Queued -> Extracting -> Inserting -> Completed progress stepper. Failed greys the whole thing
   out (see .upy-stepper-failed) rather than guessing which stage a failure actually reached. */
.upy-stepper {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 18px 0;
}

.upy-step {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    color: #999;
}

.upy-step:not(:last-child)::after {
    content: '';
    flex: 1;
    height: 2px;
    background: #e0e0e0;
    margin-left: 8px;
}

.upy-step-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #e0e0e0;
    flex-shrink: 0;
}

.upy-step-label {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.upy-step.done .upy-step-dot {
    background: #28a745;
}

.upy-step.done {
    color: #28a745;
}

.upy-step.active .upy-step-dot {
    background: #1976d2;
    box-shadow: 0 0 0 4px rgba(25,118,210,0.15);
}

.upy-step.active {
    color: #1976d2;
}

.upy-stepper-failed .upy-step {
    opacity: 0.45;
}

.upy-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
    margin: 14px 0;
    font-size: 13px;
}

.upy-meta-label {
    display: block;
    color: #888;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 2px;
}

.upy-count-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin: 16px 0;
}

.upy-count-tile {
    background: #f5f8fc;
    border: 1px solid #dde6f0;
    border-radius: 8px;
    padding: 14px;
    text-align: center;
}

.upy-count-value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #003B7A;
}

.upy-count-label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.status-badge.status-completed {
    background: #d4edda;
    color: #28a745;
}

.status-badge.status-failed {
    background: #f8d7da;
    color: #dc3545;
}

.status-badge.status-inprogress {
    background: #fff3cd;
    color: #997404;
}

.upy-report-group {
    margin-bottom: 26px;
}

.upy-report-group:last-child {
    margin-bottom: 0;
}

.upy-report-group-title {
    font-weight: 600;
    color: #003B7A;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.upy-report-group-count {
    background: #e7ecf3;
    color: #1f2d3d;
    border-radius: 12px;
    padding: 2px 10px;
    font-size: 12px;
    font-weight: 600;
}

/* Small "N issues" badge in a report grid cell - full text lives in its title tooltip. */
.upy-issue-badge {
    display: inline-block;
    background: #fff3cd;
    color: #997404;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    cursor: help;
}

.upy-extracted-pre {
    max-height: 50vh;
    overflow: auto;
    background: #f5f8fc;
    border: 1px solid #dde6f0;
    border-radius: 6px;
    padding: 14px;
    font-size: 12px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* ==================== PYQ Import Review (PYQImportReview.html) ==================== */
/* One editable card per PendingReview item - see js/pyq-import-review.js. Layout intentionally
   mirrors AddPYQ.html's aq-* option/blank/matrix rows (same rich-text-row pattern, reused as-is)
   so this screen doesn't invent a second visual language for the same kind of editing. */
.pir-card {
    border: 1px solid #dde6f0;
    border-radius: 10px;
    padding: 18px 20px;
    margin-bottom: 20px;
    background: #fff;
}

.pir-card.pir-done {
    background: #f8faf7;
}

.pir-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.pir-card-header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pir-qnum {
    font-weight: 700;
    color: #003B7A;
    font-size: 15px;
}

.pir-badge {
    display: inline-block;
    border-radius: 12px;
    padding: 3px 10px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.pir-badge-subject { background: #e7ecf3; color: #1f2d3d; }
.pir-badge-conf-high { background: #d4edda; color: #28a745; }
.pir-badge-conf-low { background: #fff3cd; color: #997404; }
.pir-badge-bonus { background: #e3d7fb; color: #6f42c1; }
.pir-badge-image { background: #fde2d0; color: #b25a1f; }
.pir-badge-approved { background: #d4edda; color: #28a745; }
.pir-badge-rejected { background: #f8d7da; color: #dc3545; }

.pir-issues {
    background: #fff3cd;
    border: 1px solid #ffe69c;
    border-radius: 6px;
    padding: 10px 14px;
    margin-bottom: 14px;
}

.pir-issue-line {
    color: #806515;
    font-size: 13px;
    line-height: 1.5;
}

.pir-issue-line:not(:last-child) {
    margin-bottom: 3px;
}

.pir-card-error {
    background: #f8d7da;
    color: #842029;
    border: 1px solid #f1aeb5;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 13px;
    margin: 14px 0;
}

.pir-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.pir-reject-box {
    margin-top: 14px;
    padding: 14px;
    background: #fff8f8;
    border: 1px solid #f1aeb5;
    border-radius: 8px;
}

.pir-reject-box textarea {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    resize: vertical;
}

.pir-reject-box-actions {
    display: flex;
    gap: 8px;
}

.pir-result-banner {
    border-radius: 8px;
    padding: 14px 16px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.pir-result-banner.pir-result-approved { background: #eef6ee; border: 1px solid #cfe6cf; color: #2f6f2f; }
.pir-result-banner.pir-result-rejected { background: #faf1f1; border: 1px solid #ecc; color: #7a3030; }

.pir-images {
    margin-top: 10px;
}

.pir-images-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
}

.pir-image-thumb {
    position: relative;
    width: 90px;
    height: 90px;
    border: 1px solid #dde6f0;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f8fc;
}

.pir-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.pir-image-thumb .pir-image-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(220,53,69,0.9);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    line-height: 18px;
    text-align: center;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}

.pir-images-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.pir-images-controls select {
    width: auto;
}

.pir-section-note {
    color: #666;
    font-size: 13px;
    margin: 4px 0 16px;
}

#pdfModal .modal-content {
    max-width: 96vw;
    width: 1100px;
    height: 92vh;
    padding: 16px;
    display: flex;
    flex-direction: column;
}

#pdfModal iframe {
    flex: 1;
    width: 100%;
    border: 1px solid #dde6f0;
    border-radius: 6px;
}




/* ============================================================
   Student Management (addStudent.html) - page-specific styles
   ============================================================ */
.stu-page .container { max-width: 100%; padding: 20px; }
.stu-view { display: none; }
.stu-view.active { display: block; animation: fadeIn 0.3s; }
.stu-sub { color: #666; margin: 4px 0 20px; }
.stu-loading-text { margin-top: 12px; color: #003B7A; font-weight: 600; }
.stu-note { color: #555; font-size: 14px; margin: 0 0 16px; padding: 10px 14px; background: #f5f7ff; border-left: 4px solid #003B7A; border-radius: 4px; }
.stu-hint { display: block; margin-top: 4px; color: #777; font-size: 12px; }

.stu-btn-auto { width: auto !important; margin-top: 0 !important; padding: 10px 20px !important; font-size: 14px !important; }
.stu-btn-danger { background: #b02a37; color: #fff; border: none; border-radius: 4px; cursor: pointer; }
.stu-btn-danger:hover { background: #8c1f2b; }
button.stu-btn-danger.modal-button { background: #b02a37; color: #fff; }

.stu-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.stu-toolbar .list-filter-select { flex: 0 1 320px; }

.stu-filters { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; align-items: center; margin-bottom: 16px; }
.stu-filters input, .stu-filters select { padding: 9px 10px; }
.stu-filters .stu-btn-auto { justify-self: start; }

.stu-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.stu-page-head h1 { margin: 0; }
.stu-back { margin: 0; }

.stu-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 18px; }
.stu-grid .stu-full { grid-column: 1 / -1; }
@media (max-width: 1100px) { .stu-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) {
    .stu-grid { grid-template-columns: 1fr; }
    .stu-page .container { padding: 10px; }
    .tabs { overflow-x: auto; }
    .tab { padding: 10px 14px; white-space: nowrap; }
    .stu-toolbar .list-filter-select { flex-basis: 100%; }
}

.stu-check { display: flex; align-items: center; gap: 8px; margin: 26px 0 0; cursor: pointer; }
.stu-check input { width: auto; margin: 0; }

.stu-field-error { display: none; margin-top: 4px; color: #dc3545; font-size: 12px; }
.stu-field-error.has { display: block; }
.stu-grid input:has(+ .stu-field-error.has), .form-group:has(> .stu-field-error.has) > input,
.form-group:has(> .stu-field-error.has) > select, .form-group:has(> .stu-field-error.has) > textarea { border-color: #dc3545; }

.stu-pw { position: relative; }
.stu-pw input { padding-right: 64px; }
.stu-pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); background: none; border: none; color: #003B7A; font-weight: 600; font-size: 13px; cursor: pointer; padding: 6px 8px; }

.stu-photo img { margin-top: 8px; max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid #e0e0e0; object-fit: cover; }

.stu-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.stu-actions-center { justify-content: center; }
.stu-detail-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.stu-detail-actions .btn-small { padding: 10px 16px; font-size: 14px; }
#stuViewDetail:not(.stu-editing) .stu-edit-only { display: none !important; }

.stu-danger-zone { margin-top: 30px; padding: 16px 18px; border: 1px solid #f1aeb5; background: #fff5f5; border-radius: 8px; }
.stu-danger-zone h3 { margin: 0 0 6px; color: #b02a37; font-size: 15px; }
.stu-danger-zone p { margin: 0 0 12px; color: #666; font-size: 13px; }

.stu-success { max-width: 720px; margin: 20px auto; padding: 30px; text-align: center; }
.stu-success-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin: 20px 0; text-align: left; }
.stu-success-grid > div { background: #f5f7ff; border-radius: 8px; padding: 12px 14px; }
.stu-success-grid span { display: block; font-size: 12px; color: #777; text-transform: uppercase; letter-spacing: .4px; margin-bottom: 4px; }
.stu-success-grid strong { word-break: break-word; color: #003B7A; }
.stu-login-info { margin-top: 0; }

.stu-badge { padding: 3px 10px; font-size: 11px; }
.status-badge.stu-st-active { background: #d4edda; color: #28a745; }
.status-badge.stu-st-inactive { background: #e9ecef; color: #6c757d; }
.status-badge.stu-st-suspended { background: #fff3cd; color: #b58105; }
.status-badge.stu-st-dropped { background: #f8d7da; color: #dc3545; }
.status-badge.stu-st-graduated { background: #d6e4f5; color: #003B7A; }

.stu-confirm { text-align: left; max-width: 460px; }
.stu-confirm .modal-title { font-size: 20px; }
.stu-confirm .modal-message { margin-bottom: 16px; }
.stu-confirm .stu-btn-danger:disabled, .stu-confirm .modal-button:disabled { opacity: .5; cursor: not-allowed; }

.stu-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 2000; display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 36px)); }
.stu-toast { padding: 12px 16px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); cursor: pointer; animation: slideDown 0.25s; }
.stu-toast-success { background: #28a745; }
.stu-toast-error { background: #dc3545; }
.stu-toast-info { background: #003B7A; }

/* ============================================================
   Company Profile / Edit Company (CompanyProfile.html) - page-specific styles
   ============================================================ */
.cp-page .container { max-width: 100%; padding: 20px; }
.cp-hidden { display: none !important; }
.cp-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.cp-head h1 { margin: 0; }
.cp-back { color: #003B7A; font-weight: 600; text-decoration: none; }
.cp-back:hover { text-decoration: underline; }
.cp-sub { color: #666; margin: 4px 0 20px; }
.cp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 20px; }
.cp-toolbar .list-filter-select { flex: 0 1 400px; max-width: 400px; }
.cp-loading-text { margin-top: 12px; color: #003B7A; font-weight: 600; }
.cp-note { color: #555; font-size: 14px; margin: 0 0 16px; padding: 10px 14px; background: #f5f7ff; border-left: 4px solid #003B7A; border-radius: 4px; }

.cp-page .responsive-grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0 20px; align-items: start; }
.cp-page .cp-span-2 { grid-column: span 2; }
.cp-page .cp-span-full { grid-column: 1 / -1; }
.cp-switch { display: flex; align-items: center; gap: 8px; margin: 0; padding: 10px 12px; min-height: 44px; box-sizing: border-box; border: 1px solid #e0e6ef; border-radius: 6px; background: #fafbfd; cursor: pointer; font-weight: 500; }
.cp-switch:hover { border-color: #b8c7dc; }
.cp-switch input { width: 16px; height: 16px; margin: 0; padding: 0; flex: 0 0 auto; accent-color: #003B7A; }
.cp-switch span { flex: 1; }
.cp-notset { display: none; font-size: 11px; font-style: italic; color: #9aa5b1; white-space: nowrap; }
.cp-switch.cp-is-notset .cp-notset { display: inline; }
.cp-switch.cp-is-notset { border-style: dashed; }

.cp-dependent { margin-top: 10px; padding-left: 14px; border-left: 3px solid #d6e4f5; }
.cp-dependent .form-group { margin-bottom: 0; }

.cp-clear-hint { display: none; margin-top: 4px; color: #9a6700; font-size: 12px; }
.cp-clear-hint.show { display: block; }

.cp-logo-row { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.cp-logo-preview { width: 110px; height: 70px; object-fit: contain; border: 1px solid #ddd; border-radius: 6px; background: #fafafa; }

.cp-meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 4px 0 0; padding: 10px 14px; font-size: 12px; color: #666; background: #f8f9fb; border-radius: 6px; }
.cp-meta:empty { display: none; }
.cp-meta strong { color: #444; font-weight: 600; }

.cp-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.cp-actions .modal-button { width: auto; margin-top: 0; padding: 12px 40px; }
.cp-actions .modal-button:disabled { opacity: .6; cursor: not-allowed; }

@media (max-width: 1200px) {
    .cp-page .responsive-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    .cp-page .container { padding: 10px; }
    .cp-page .responsive-grid-4 { grid-template-columns: 1fr; }
    .cp-page .cp-span-2 { grid-column: auto; }
    .cp-page .tabs { overflow-x: auto; }
    .cp-page .tab { padding: 10px 14px; white-space: nowrap; }
    .cp-toolbar .list-filter-select { flex-basis: 100%; max-width: 100%; }
}

/* ===== Course / Course Mapping pages: inline form errors + toast ===== */
.crs-field-error { display: none; margin-top: 4px; color: #dc3545; font-size: 12px; }
.crs-field-error.has { display: block; }
.form-group:has(> .crs-field-error.has) > input { border-color: #dc3545; }
.crs-form-error { display: none; margin-top: 12px; padding: 10px 12px; border: 1px solid #f5c2c7; border-radius: 6px; background: #f8d7da; color: #842029; font-size: 13px; }
.crs-form-error.has { display: block; }
.crs-toast { position: fixed; right: 20px; bottom: 20px; z-index: 10000; max-width: 420px; padding: 12px 16px; border-radius: 8px; background: #1f7a3d; color: #fff; font-size: 14px; box-shadow: 0 4px 14px rgba(0,0,0,0.2); opacity: 0; transform: translateY(10px); transition: opacity 0.2s, transform 0.2s; pointer-events: none; }
.crs-toast.error { background: #b02a37; }
.crs-toast.show { opacity: 1; transform: translateY(0); }
@media (max-width: 600px) { .crs-toast { left: 16px; right: 16px; max-width: none; } }

/* ===== Grade Schemes page (gradeschemes.html / js/grade-schemes.js) ===== */
.gs-page [hidden] { display: none !important; }
.gs-page .page-content { width: 100%; padding: 0; }
.gs-page .container { max-width: 100%; padding: 20px; }
.gs-page .profile-card { max-width: 100%; margin: 0; }
.gs-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 16px; }
.gs-toolbar select, .gs-toolbar input { width: auto; margin: 0; }
.gs-company-filter { min-width: 220px; max-width: 320px; }
.gs-filter-batch { width: 170px !important; }
.gs-filter-name { flex: 1 1 220px; max-width: 320px; }
.gs-primary-btn { width: auto; padding: 12px 24px; margin: 0 0 0 auto; }
.gs-loading-text { margin-top: 15px; color: #003B7A; font-weight: 600; }
.gs-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 16px; border: 1px dashed #c9d4e2; border-radius: 8px; background: #f8fafc; text-align: center; }
.gs-empty-title { margin: 0; font-size: 18px; font-weight: 600; color: #003B7A; }
.gs-empty-hint { margin: 0 0 8px; color: #666; font-size: 14px; }
.gs-empty .gs-primary-btn { margin: 0; }
.gs-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.gs-head .profile-section-title { margin: 0; }
.gs-head-actions, .gs-bands-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.gs-back-btn, .gs-small-btn { width: auto; margin-top: 0; padding: 8px 16px; }
.gs-secondary-btn { background: #6c757d; }
.gs-danger-btn { background: #dc3545; }
.gs-company-line { margin: -8px 0 16px; color: #555; font-size: 14px; }
.gs-field-error { display: none; margin-top: 4px; color: #dc3545; font-size: 12px; }
.gs-field-error.has { display: block; }
.form-group:has(> .gs-field-error.has) > input { border-color: #dc3545; }
.gs-form-error { display: none; margin: 12px 0; padding: 10px 12px; border: 1px solid #f5c2c7; border-radius: 6px; background: #f8d7da; color: #842029; font-size: 13px; }
.gs-form-error.has { display: block; }
.gs-form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.gs-form-actions .modal-button { width: auto; margin-top: 0; padding: 12px 32px; }
.gs-form-actions .modal-button:disabled { opacity: .6; cursor: not-allowed; }
.gs-toggle { display: inline-flex; border: 1px solid #c9d4e2; border-radius: 6px; overflow: hidden; }
.gs-toggle-opt { display: flex; align-items: center; margin: 0; cursor: pointer; }
.gs-toggle-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.gs-toggle-opt span { padding: 8px 18px; font-weight: 500; color: #003B7A; background: #fff; }
.gs-toggle-opt input:checked + span { background: #003B7A; color: #fff; }
.gs-toggle-opt input:focus-visible + span { outline: 2px solid #4d90fe; outline-offset: -2px; }
.gs-bands-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.gs-bands-head .profile-section-title { margin: 0; }
.gs-bands-help { margin: 8px 0 12px; }
.gs-coverage { margin-bottom: 14px; }
.gs-coverage-strip { display: flex; height: 28px; border-radius: 6px; overflow: hidden; border: 1px solid #c9d4e2; background: #fff; }
.gs-seg { display: flex; align-items: center; justify-content: center; min-width: 0; overflow: hidden; white-space: nowrap; font-size: 12px; font-weight: 600; }
.gs-seg-band { background: #3d6fa8; color: #fff; }
.gs-seg-band.gs-seg-alt { background: #6a93c2; }
.gs-seg-gap { background: repeating-linear-gradient(45deg, #ffe08a, #ffe08a 6px, #fff3cd 6px, #fff3cd 12px); }
.gs-seg-overlap { background: #dc3545; color: #fff; }
.gs-seg-empty { color: #888; font-weight: 400; font-style: italic; }
.gs-coverage-scale { display: flex; justify-content: space-between; margin-top: 2px; font-size: 11px; color: #777; }
.gs-coverage-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 6px; font-size: 12px; color: #555; }
.gs-lg { display: inline-block; width: 12px; height: 12px; margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.gs-lg-band { background: #3d6fa8; }
.gs-lg-gap { background: #ffe08a; }
.gs-lg-overlap { background: #dc3545; }
.gs-bands-wrap { overflow-x: auto; }
.gs-bands { width: 100%; border-collapse: collapse; font-size: 14px; }
.gs-bands th { padding: 8px 6px; background: #f0f4f9; color: #003B7A; font-weight: 600; text-align: left; white-space: nowrap; border-bottom: 1px solid #d9e2ec; }
.gs-bands td { padding: 6px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.gs-bands input[type="text"], .gs-bands input[type="number"], .gs-bands select { width: 100%; min-width: 70px; margin: 0; padding: 6px 8px; }
.gs-bands .gs-in-grade { min-width: 56px; max-width: 80px; }
.gs-bands input.gs-invalid, .gs-bands select.gs-invalid { border-color: #dc3545; background: #fff6f7; }
.gs-bands input[type="checkbox"] { width: 18px; height: 18px; margin: 0; }
.gs-center { text-align: center; }
.gs-order-cell { white-space: nowrap; }
.gs-order { display: inline-block; min-width: 18px; font-weight: 600; color: #003B7A; }
.gs-move { display: inline-flex; flex-direction: column; vertical-align: middle; margin-left: 4px; }
.gs-icon-btn { border: 1px solid #c9d4e2; background: #fff; color: #003B7A; border-radius: 4px; padding: 0 6px; font-size: 10px; line-height: 16px; cursor: pointer; }
.gs-icon-btn:disabled { opacity: .35; cursor: default; }
.gs-icon-btn.gs-remove { font-size: 13px; line-height: 24px; padding: 0 9px; color: #dc3545; }
.gs-icon-btn:hover:not(:disabled) { border-color: #003B7A; }
.gs-band-err-row td { padding: 2px 6px 8px; color: #dc3545; font-size: 12px; border-bottom: 1px solid #eef2f7; }
.gs-detail-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 20px; margin: 0; }
.gs-detail-item dt { font-size: 12px; color: #777; margin-bottom: 2px; }
.gs-detail-item dd { margin: 0; font-weight: 600; color: #333; }
.gs-bands-readonly { margin-top: 12px; }
.gs-status { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; font-weight: 600; background: #e7f5ec; color: #1f7a3d; }
.gs-status-fail { background: #fbe4e6; color: #b02a37; }
.gs-status-detained, .gs-status-absent { background: #fff3cd; color: #8a6d00; }
.gs-muted { color: #888; font-style: italic; }
@media (max-width: 768px) {
    .gs-page .container { padding: 10px 16px; }
    .gs-toolbar > * { flex: 1 1 100%; max-width: 100% !important; width: 100% !important; }
    .gs-primary-btn { margin-left: 0; }
    .gs-page .input-row { grid-template-columns: 1fr; }
}

/* ===== Course page: Internal Pass Marks / Grade Scheme fields ===== */
.form-group:has(> .crs-field-error.has) > select { border-color: #dc3545; }
.crs-field-hint { display: none; margin-top: 4px; color: #8a6d00; font-size: 12px; }
.crs-field-hint.has { display: block; }

/* ============================================================
   Exam Fee Setup (ExamFeeSetup.html) - page-specific styles
   ============================================================ */
.fs-page .container { max-width: 100%; padding: 20px; }
.fs-page [hidden], .fs-modal[hidden], .fs-modal [hidden] { display: none !important; }
.fs-breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: #5b6b7f; margin-bottom: 10px; }
.fs-breadcrumb a { color: var(--eer-link); text-decoration: none; }
.fs-breadcrumb a:hover { text-decoration: underline; }
.fs-breadcrumb [aria-current] { color: #1f2d3d; font-weight: 600; }
.fs-crumb-sep { color: #9aa5b1; }

.fs-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.fs-head-title { display: flex; align-items: center; gap: 14px; }
.fs-head-title h1 { margin: 0; color: var(--eer-primary); }
.fs-head-icon { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 50%; background: var(--eer-link); display: flex; align-items: center; justify-content: center; }
.fs-head-icon svg { width: 30px; height: 30px; fill: #fff; }
.fs-sub { margin: 2px 0 0; color: #555; font-size: 14px; }
.fs-head-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.fs-company-filter { min-width: 220px; max-width: 320px; }
.fs-head-filter { display: flex; flex-direction: column; min-width: 150px; padding: 6px 10px; border: 1px solid #d9e2ec; border-radius: 8px; background: #fff; }
.fs-head-filter label { font-size: 12px; color: var(--eer-link); margin: 0 0 2px; }
.fs-head-filter select { border: none; padding: 2px 0; font-weight: 600; background: transparent; }
.fs-head-filter select:focus { outline: none; box-shadow: none; }

.fs-page .fs-tabs { flex-wrap: wrap; gap: 4px; margin-bottom: 18px; background: #fff; border: 1px solid #e0e6ef; border-radius: 8px 8px 0 0; padding: 0 8px; }
.fs-page .fs-tabs .tab { padding: 12px 18px; font-size: 14px; }
.fs-page .fs-tabs .tab.active { font-weight: 600; color: var(--eer-link); border-bottom-color: var(--eer-link); }
.fs-page .fs-tabs .fs-tab-disabled { color: #aab4c0; cursor: not-allowed; }
.fs-page .fs-tabs .fs-tab-disabled:hover { color: #aab4c0; }

.fs-card { background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; padding: 16px 18px; margin-bottom: 18px; box-shadow: 0 1px 3px rgba(var(--eer-primary-rgb), .05); min-width: 0; }
.fs-card-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 16px; font-weight: 600; color: var(--eer-primary); }
.fs-step { display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; background: var(--eer-link); color: #fff; font-size: 13px; }

.fs-grid { display: grid; gap: 0 18px; align-items: start; }
.fs-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fs-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.fs-grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.fs-span-2 { grid-column: span 2; }
.fs-span-full { grid-column: 1 / -1; }
.fs-page .form-group, .fs-modal .form-group { margin-bottom: 14px; }
.fs-page .form-group label, .fs-modal .form-group label { font-size: 13px; }
.fs-field-error { color: #dc3545; font-size: 12px; margin-top: 4px; }
.fs-field-error:empty { display: none; }
.fs-invalid { border-color: #dc3545 !important; }
.fs-muted { color: #8a97a6; }

.fs-row-2 { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.fs-row-2 > .fs-card { margin-bottom: 0; }

/* Step 1 chip multi-select */
.fs-chipselect { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 42px; padding: 5px 8px; border: 1px solid #ddd; border-radius: 6px; background: #fff; box-sizing: border-box; }
.fs-chips { display: contents; }
.fs-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 4px 3px 10px; border-radius: 14px; background: var(--eer-tint); color: var(--eer-primary); font-size: 13px; font-weight: 500; }
.fs-chip button { border: none; background: none; color: inherit; font-size: 16px; line-height: 1; cursor: pointer; padding: 0 4px; }
.fs-chip button:hover { color: #dc3545; }
.fs-page .fs-chip-add { flex: 1 1 90px; min-width: 90px; width: auto; border: none; padding: 4px; background: transparent; color: #666; }
.fs-page .fs-chip-add:focus { outline: none; box-shadow: none; }

/* Toggle switch */
.fs-switch { position: relative; display: inline-block; width: 38px; height: 22px; margin: 0; flex: 0 0 auto; vertical-align: middle; }
.fs-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.fs-slider { position: absolute; inset: 0; cursor: pointer; border-radius: 22px; background: #c5ccd6; transition: background .2s; }
.fs-slider::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform .2s; }
.fs-switch input:checked + .fs-slider { background: #1f9d55; }
.fs-switch input:checked + .fs-slider::before { transform: translateX(16px); }
.fs-switch input:disabled + .fs-slider { opacity: .55; cursor: wait; }
.fs-switch input:focus-visible + .fs-slider { outline: 2px solid var(--eer-link); outline-offset: 2px; }
.fs-inline-switch { display: flex; align-items: center; gap: 10px; min-height: 38px; }
.fs-switch-label { font-weight: 600; font-size: 13px; color: #333; }
.fs-switch-text { font-size: 13px; color: #444; }
.fs-tax-pct { width: 90px; padding: 6px 8px; }

/* Step 2 Fee Components */
.fs-comp-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.fs-comp-head .fs-card-title { margin: 0; }
.fs-comp-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.fs-comp-toolbar input[type="search"] { width: 240px; padding: 8px 10px; }
.fs-comp-toolbar select { width: 140px; padding: 8px 10px; }
.fs-page .fs-add-btn, .fs-page .fs-secondary-btn { width: auto; margin-top: 0; padding: 9px 18px; }
.fs-secondary-btn { background: #fff !important; color: var(--eer-link) !important; border: 1px solid var(--eer-link) !important; }
.fs-secondary-btn:hover { background: var(--eer-tint) !important; }

.fs-comp-grid .sm-dg-table-wrapper { max-height: 560px; overflow: auto; }
.fs-comp-grid .sm-dg-table thead th { position: sticky; top: 0; z-index: 1; background: #eef3fa; }
.fs-comp-name { font-weight: 600; color: #1f2d3d; }
.fs-comp-desc { font-size: 12px; color: #8a97a6; margin-top: 2px; white-space: normal; }
.fs-amount { display: block; text-align: right; font-variant-numeric: tabular-nums; }
.fs-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; background: var(--eer-tint); color: var(--eer-primary); white-space: nowrap; }
.fs-badge-per_subject { background: #fff4e0; color: #9a5b00; }
.fs-badge-per_copy { background: #f1e8fd; color: #6a2fb8; }
.fs-chip-cell { display: flex; flex-wrap: wrap; gap: 4px; }
.fs-mini-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; background: #eef3fa; color: #34506f; white-space: nowrap; }
.fs-mini-more { background: #fff; border: 1px dashed #b8c7dc; cursor: help; }
.fs-mini-reg { background: #e7f5ec; color: #1f7a3d; }
.fs-comp-footer { margin-top: 10px; font-size: 13px; color: #5b6b7f; }
.fs-comp-footer:empty { display: none; }

.fs-skeleton { display: flex; flex-direction: column; gap: 10px; padding: 6px 0; }
.fs-skel-row { height: 34px; border-radius: 6px; background: linear-gradient(90deg, #eef2f7 25%, #f7f9fc 37%, #eef2f7 63%); background-size: 400% 100%; animation: fsShimmer 1.4s ease infinite; }
.fs-skel-head { height: 40px; background-color: #e3e9f1; }
@keyframes fsShimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
@media (prefers-reduced-motion: reduce) { .fs-skel-row { animation: none; } }
.fs-state { text-align: center; padding: 36px 16px; border: 1px dashed #d0dae6; border-radius: 8px; background: #fafcff; }
.fs-state-title { margin: 0 0 14px; color: #5b6b7f; font-size: 14px; }
.fs-state-error { border-color: #f1b0b7; background: #fff7f8; }
.fs-state-error .fs-state-title { color: #b02a37; }

/* Step 3 */
.fs-seg { display: flex; flex-wrap: wrap; margin-bottom: 12px; border: 1px solid #d9e2ec; border-radius: 6px; overflow: hidden; }
.fs-seg:empty { display: none; }
.fs-seg-btn { flex: 1 1 0; padding: 9px 12px; border: none; border-right: 1px solid #d9e2ec; background: #fff; color: var(--eer-link); font-weight: 600; cursor: pointer; }
.fs-seg-btn:last-child { border-right: none; }
.fs-seg-btn.active { background: var(--eer-link); color: #fff; }
.fs-seg-btn:disabled { color: #aab4c0; cursor: not-allowed; }
.fs-table-wrap { overflow-x: auto; border: 1px solid #e3e9f1; border-radius: 6px; }
.fs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.fs-table th { background: #eef3fa; color: var(--eer-primary); font-weight: 600; text-align: left; padding: 8px; white-space: nowrap; border-bottom: 1px solid #dbe4ef; }
.fs-table td { padding: 7px 8px; border-bottom: 1px solid #eef2f7; }
.fs-table tbody tr:last-child td { border-bottom: none; }
.fs-table .fs-num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Step 4 */
.fs-kv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 10px 12px; align-items: center; }
.fs-kv > label { margin: 0; font-size: 13px; color: #333; font-weight: 500; }
.fs-kv input, .fs-kv select { padding: 7px 9px; font-size: 13px; }
.fs-kv-pair { display: flex; align-items: center; gap: 8px; }
.fs-kv-pair input { min-width: 0; }
.fs-kv-sep { font-size: 12px; color: #666; }

/* Modals (Add / Edit, View) */
body.fs-modal-open { overflow: hidden; }
.fs-modal { position: fixed; inset: 0; z-index: 3000; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(15, 30, 55, .55); }
.fs-modal-dialog { display: flex; flex-direction: column; width: 100%; max-width: 720px; max-height: calc(100vh - 32px); background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); overflow: hidden; }
.fs-modal-lg { max-width: 960px; }
.fs-modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 16px 20px; background: var(--eer-link); color: #fff; }
.fs-modal-header h2 { margin: 0; font-size: 19px; color: #fff; }
.fs-modal-header p { margin: 4px 0 0; font-size: 13px; color: rgba(255, 255, 255, .82); }
.fs-modal-close { flex: 0 0 auto; width: 34px; height: 34px; border: none; border-radius: 6px; background: rgba(255, 255, 255, .15); color: #fff; font-size: 22px; line-height: 1; cursor: pointer; }
.fs-modal-close:hover { background: rgba(255, 255, 255, .28); }
.fs-modal-close:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.fs-modal-body { flex: 1 1 auto; overflow-y: auto; padding: 18px 20px; background: #f6f8fb; }
.fs-modal-footer { flex: 0 0 auto; display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid #e0e6ef; background: #fff; }
.fs-modal-footer .modal-button { width: auto; margin-top: 0; padding: 10px 22px; }
.fs-modal .fs-secondary-btn { background: #fff; }

.fs-alert { margin-bottom: 14px; padding: 10px 14px; border-radius: 6px; border: 1px solid #f1b0b7; background: #fdecee; color: #8a1c28; font-size: 14px; white-space: pre-line; }
.fm-section { background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; padding: 14px 16px 4px; margin-bottom: 14px; }
.fm-section-title { display: flex; align-items: center; gap: 10px; margin: 0 0 14px; font-size: 15px; font-weight: 600; color: var(--eer-primary); }
.fm-badge { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; border-radius: 7px; background: var(--eer-tint); }
.fm-badge svg { width: 16px; height: 16px; fill: var(--eer-link); }
.fm-input-btn { display: flex; gap: 6px; }
.fm-input-btn input { flex: 1 1 auto; min-width: 0; }
.fm-upper { text-transform: uppercase; }
.fm-icon-btn { flex: 0 0 auto; width: 40px; border: 1px solid #c9d6e8; border-radius: 6px; background: #fff; color: var(--eer-link); font-size: 18px; cursor: pointer; }
.fm-icon-btn:hover { background: var(--eer-tint); }
.fm-icon-btn:disabled { opacity: .5; cursor: wait; }
.fm-counter { display: block; text-align: right; font-size: 12px; color: #8a97a6; margin-top: 3px; }
.fm-warn { margin: -4px 0 12px; padding: 8px 12px; border-radius: 6px; background: #fff8e6; border: 1px solid #f3d38a; color: #7a5600; font-size: 13px; }
.fm-fieldset { border: none; padding: 0; margin: 0 0 14px; min-width: 0; }
.fm-fieldset legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 600; color: #333; }
.fm-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.fm-check { display: inline-flex; align-items: center; gap: 6px; margin: 0; padding: 7px 12px; border: 1px solid #d9e2ec; border-radius: 6px; background: #fff; font-size: 13px; font-weight: 500; cursor: pointer; }
.fm-check:has(input:checked) { border-color: var(--eer-link); background: var(--eer-tint); }
.fm-check input { width: 15px; height: 15px; margin: 0; accent-color: var(--eer-link); }
.fm-check-all { font-weight: 600; }
.fm-radios { display: flex; flex-wrap: wrap; gap: 18px; margin-bottom: 8px; }
.fm-radios label { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-size: 14px; cursor: pointer; }
.fm-radios input { accent-color: var(--eer-link); }
.fm-dept-picker { border: 1px solid #d9e2ec; border-radius: 6px; padding: 8px; background: #fff; }
.fm-dept-picker input[type="search"] { width: 100%; box-sizing: border-box; margin-bottom: 6px; }
.fm-dept-list { max-height: 200px; overflow-y: auto; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px 12px; }
.fm-dept-item { display: flex; align-items: flex-start; gap: 8px; margin: 0; padding: 5px 6px; border-radius: 4px; font-size: 13px; font-weight: 400; cursor: pointer; }
.fm-dept-item:hover { background: #f3f7fc; }
.fm-dept-item input { margin-top: 2px; accent-color: var(--eer-link); }
.fm-summary { margin: 0 0 12px; padding: 9px 12px; border-radius: 6px; background: var(--eer-tint); color: var(--eer-primary); font-size: 13px; font-weight: 600; }
.fm-switch-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 28px; margin-bottom: 10px; }
.fm-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid #f0f3f7; }
.fm-switch-row > label { margin: 0; font-size: 13px; font-weight: 500; color: #333; }
.fm-hint { display: block; font-size: 11px; font-weight: 400; color: #8a97a6; }
.fm-order { width: 90px; padding: 6px 8px; }
.fm-save-btn { display: inline-flex; align-items: center; gap: 8px; }
.fm-spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .5); border-top-color: #fff; border-radius: 50%; animation: fsSpin .8s linear infinite; }
.fm-save-btn.is-saving .fm-spinner { display: inline-block; }
.fm-save-btn:disabled { opacity: .75; cursor: wait; }
@keyframes fsSpin { to { transform: rotate(360deg); } }

.fv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 20px; margin: 0 0 18px; }
.fv-item dt { font-size: 12px; color: #6b7a8c; margin-bottom: 2px; }
.fv-item dd { margin: 0; font-weight: 600; color: #1f2d3d; word-break: break-word; }
.fv-wide { grid-column: 1 / -1; }
.fv-lists { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 18px; }
.fv-lists h4 { margin: 0 0 6px; font-size: 13px; color: var(--eer-primary); }
.fv-list { margin: 0; padding: 8px 10px 8px 26px; max-height: 180px; overflow-y: auto; background: #fff; border: 1px solid #e0e6ef; border-radius: 6px; font-size: 13px; }

/* Toasts */
.fs-toasts { position: fixed; right: 18px; bottom: 18px; z-index: 4000; display: flex; flex-direction: column; gap: 10px; max-width: min(420px, calc(100vw - 32px)); }
.fs-toast { padding: 12px 16px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: 0 4px 16px rgba(0, 0, 0, .25); cursor: pointer; animation: slideDown .25s; }
.fs-toast-success { background: #1f7a3d; }
.fs-toast-error { background: #b02a37; }
.fs-toast-warn { background: #9a6700; }
.fs-toast-info { background: var(--eer-link); }

@media (max-width: 1200px) {
    .fs-row-2 { grid-template-columns: 1fr; }
    .fs-grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
    .fs-page .container { padding: 10px 16px; }
    .fs-grid-2, .fs-grid-3, .fs-grid-6, .fm-switch-grid, .fm-dept-list, .fv-lists { grid-template-columns: 1fr; }
    .fs-span-2 { grid-column: auto; }
    .fs-head-filters, .fs-head-filter, .fs-company-filter { width: 100%; max-width: 100%; }
    .fs-page .fs-tabs { flex-wrap: nowrap; overflow-x: auto; }
    .fs-page .fs-tabs .tab { white-space: nowrap; padding: 10px 12px; }
    .fs-comp-toolbar, .fs-comp-toolbar > * { width: 100% !important; }
    .fs-modal { padding: 0; }
    .fs-modal-dialog { max-height: 100vh; height: 100%; border-radius: 0; }
    .fs-modal-footer .modal-button { flex: 1 1 0; }
}

/* ============================================================
   Credit Register (CreditRegister.html / js/credit-register.js)
   ============================================================ */
/* One page scrollbar: the global html/body { height: 100%; overflow-x: hidden } makes <body> a fixed-height
   scroll box (second scrollbar, and print stops after the first screen). clip hides sideways overflow
   without creating a scroll container. */
html:has(.cr-page) { height: auto; }
html:has(.cr-page) body { height: auto; overflow-x: clip; }
.cr-page .container { min-width: 0; }
.cr-page [hidden] { display: none !important; }
.cr-page .stu-toolbar { flex-direction: column; align-items: stretch; }
.cr-title { text-align: center; }
.cr-page .stu-toolbar h1 { margin: 0; }
.cr-sub { margin-bottom: 0; }
.cr-search { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.cr-roll-link { color: #1565F5; font-weight: 600; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; }
.cr-roll-link:hover, .cr-roll-link:focus-visible { color: #003B7A; text-decoration-thickness: 2px; }
.cr-roll-link:visited { color: #5a3fa8; }
.cr-search input[type="search"] { width: 220px; padding: 10px 12px; }
.cr-batch-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: 10px; align-items: center; margin-bottom: 16px; }
.cr-select { position: relative; min-width: 0; }
.cr-select select { width: 100%; max-width: none; padding: 10px 12px; }
.cr-select select:disabled { opacity: .6; cursor: not-allowed; }
.cr-select.is-loading::after { content: ""; position: absolute; right: 30px; top: 50%; width: 14px; height: 14px; margin-top: -7px; border: 2px solid #d9e2ec; border-top-color: #003B7A; border-radius: 50%; animation: spin .8s linear infinite; pointer-events: none; }
.cr-batch-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.cr-batch-btn:disabled { opacity: .5; cursor: not-allowed; }
.cr-btn-spinner { display: none; width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .4); border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite; }
.cr-batch-btn.is-busy .cr-btn-spinner { display: inline-block; }
.cr-note-error { color: #8c1f2b; background: #fdecee; border-left-color: #c62828; }
.cr-result-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.cr-result-bar strong { color: #003B7A; }
.cr-result-bar input[type="search"] { flex: 0 1 360px; min-width: 0; padding: 9px 12px; }
.cr-grid tbody tr { cursor: pointer; }
.cr-page a.btn-small { display: inline-block; text-decoration: none; }
.cr-reg-actions { justify-content: space-between; margin-bottom: 14px; }
.cr-reg-actions .modal-button:disabled { opacity: .5; cursor: not-allowed; }

.cr-register { min-width: 0; }
.cr-card { background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; margin-bottom: 16px; overflow: hidden; }
.cr-card-title { background: #003B7A; color: #fff; font-weight: 700; letter-spacing: .5px; text-align: center; padding: 10px 16px; }
.cr-student { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; padding: 16px 18px; }
.cr-photo { width: 96px; height: 116px; flex: 0 0 auto; border: 1px solid #d9e2ec; border-radius: 6px; background: #f1f4f8; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cr-photo img { width: 100%; height: 100%; object-fit: cover; }
.cr-photo svg { width: 64px; height: 64px; fill: #aab4c0; }
.cr-details { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 18px; margin: 0; flex: 1 1 240px; min-width: 0; }
.cr-details dt { color: #5b6b7f; font-weight: 600; }
.cr-details dt::after { content: " :"; }
.cr-details dd { margin: 0; color: #1f2d3d; font-weight: 600; overflow-wrap: anywhere; }

.cr-table-wrap { position: relative; overflow-x: auto; overflow-y: hidden; background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; margin-bottom: 16px; }
.cr-table { width: 100%; min-width: 680px; border-collapse: collapse; font-size: 14px; position: relative; z-index: 1; }
.cr-table th, .cr-table td { padding: 8px 10px; border: 1px solid #e0e6ef; text-align: left; }
.cr-table thead th { background: #f1f4f8; color: #003B7A; font-weight: 700; white-space: nowrap; }
.cr-table .cr-num { text-align: right; white-space: nowrap; }
.cr-table .cr-center { text-align: center; }
.cr-table .cr-right { text-align: right; }
.cr-table .cr-muted { color: #8a96a3; }
.cr-table .cr-fail { color: #c62828; font-weight: 700; }
.cr-band td { font-weight: 700; color: #fff; }
.cr-band-sem td { background: #1565F5; }
.cr-band-sgpa td { background: #c62828; text-align: right; }
.cr-band-cgpa td { background: #2e7d32; text-align: right; }
.cr-total td { font-weight: 700; background: #f8fafc; }
/* The box stays unrotated and clips; only the text (::before) is rotated, so nothing sticks out and scrolls */
.cr-watermark { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; pointer-events: none; z-index: 2; user-select: none; }
.cr-watermark::before { content: attr(data-text); transform: rotate(-30deg); white-space: nowrap; font-size: 72px; font-weight: 800; color: rgba(0, 59, 122, .06); }
.cr-subtitle { font-size: 16px; color: #003B7A; margin: 8px 0 10px; }
.cr-grades { min-width: 520px; }
.cr-grades th[scope="row"] { background: #f1f4f8; color: #003B7A; white-space: nowrap; width: 1%; }
.cr-grades td { white-space: nowrap; }

@media (max-width: 900px) {
    .cr-batch-filters { grid-template-columns: 1fr; }
    .cr-batch-btn { width: 100% !important; }
}
@media (max-width: 600px) {
    .cr-result-bar input[type="search"] { flex: 1 1 100%; }
    .cr-search, .cr-search .list-filter-select, .cr-search input[type="search"] { width: 100%; max-width: none; flex: 1 1 100%; }
    .cr-watermark::before { font-size: 44px; }
}

@media print {
    #headerContainer, #dynamicSidebarContainer, #footerContainer,
    .cr-page .stu-toolbar, .cr-reg-actions, #crViewList, #chatWidget, .chat-widget-toggle, .sidebar-toggle { display: none !important; }
    html:has(.cr-page), html:has(.cr-page) body { height: auto !important; min-height: 0 !important; overflow: visible !important; display: block !important; background: #fff !important; }
    .cr-page { display: block !important; margin: 0 !important; padding: 0 !important; background: #fff !important; }
    .cr-page .container { padding: 0 !important; max-width: none !important; box-shadow: none !important; border-radius: 0 !important; }
    .cr-table-wrap { overflow: visible; border: none; }
    .cr-table { min-width: 0; font-size: 12px; }
    .cr-band td, .cr-card-title { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .cr-table tr { break-inside: avoid; }
}

/* ===================================================================
   External Exam Results page (ExternalExamResults.html) - eer-*
   Brand colours come from the --eer-* variables below (SmarkAI blue by
   default). A skin (the style.css under templates/) re-points them to its own
   palette in its :root block; semantic colours (pass/fail/delete) stay.
   =================================================================== */
:root {
    --eer-primary: #003B7A;
    --eer-primary-dark: #002a5c;
    --eer-primary-rgb: 0, 59, 122;
    --eer-tint: #e8eef7;
    --eer-link: #1565F5;
    --eer-band: #1565F5;
}

.eer-page .container { min-width: 0; }
/* Full width + one page scrollbar (same fix as the Credit Register page): the global
   html/body { height: 100%; overflow-x: hidden } turns <body> into a second, fixed-height scroll box,
   and .container is capped at 900px. clip hides sideways overflow without creating a scroll container. */
html:has(.eer-page) { height: auto; }
html:has(.eer-page) body { height: auto; overflow-x: clip; }
.page-content.eer-page { padding: 20px; }
.eer-page .container { max-width: 100%; width: 100%; padding: 24px; }
.eer-page [hidden], .eer-drawer[hidden], .eer-backdrop[hidden], .eer-combo-list[hidden], .eer-drawer [hidden] { display: none !important; }
.eer-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.eer-title { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; min-width: 0; }
.eer-title h1 { margin: 0; }
.eer-chip { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--eer-tint); color: var(--eer-primary); font-size: 13px; font-weight: 700; white-space: nowrap; }
.eer-btn { width: auto !important; min-width: 0; margin-top: 0 !important; padding: 10px 18px !important; font-size: 14px !important; }
.eer-btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.eer-btn-danger, .eer-btn.eer-btn-danger { background: #dc3545; }
.eer-btn-danger:hover, .eer-btn.eer-btn-danger:hover { background: #b52a37; box-shadow: 0 4px 12px rgba(220, 53, 69, .35); }
.eer-btn-secondary { background: #fff; color: #33475b; border: 1px solid #cfd8e3; border-radius: 5px; padding: 10px 18px; font-size: 14px; font-weight: 600; cursor: pointer; }
.eer-btn-secondary:hover { background: #f1f4f8; }
.eer-link-btn { background: none; border: none; color: var(--eer-primary); font-weight: 700; font-size: 14px; cursor: pointer; padding: 6px 4px; display: inline-flex; align-items: center; gap: 6px; }
.eer-link-btn:hover { text-decoration: underline; }
.eer-count { background: var(--eer-primary); color: #fff; border-radius: 999px; font-size: 11px; padding: 1px 7px; }
.eer-caret { display: inline-block; transition: transform .2s; }
.eer-link-btn[aria-expanded="false"] .eer-caret { transform: rotate(-90deg); }

/* Filter bar */
.eer-filters { background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; padding: 10px 14px; margin-bottom: 12px; }
.eer-filters-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.eer-clear { margin-left: auto; color: #b02a37; }
.eer-search { display: flex; flex: 1 1 320px; max-width: 520px; min-width: 0; }
.eer-search select, .eer-search input { padding: 8px 10px; border: 1px solid #cfd8e3; font-size: 14px; background: #fff; }
.eer-search select { border-radius: 6px 0 0 6px; border-right: none; flex: 0 0 auto; width: auto; max-width: 160px; margin: 0; }
.eer-search input { border-radius: 0 6px 6px 0; flex: 1; min-width: 0; }
.eer-filter-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 12px; margin-top: 10px; padding-top: 12px; border-top: 1px solid #eef2f7; }
.eer-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.eer-field > label, .eer-range-label { font-size: 12px; font-weight: 600; color: #5b6b7f; }
.eer-field input, .eer-field select { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid #cfd8e3; border-radius: 6px; font-size: 14px; background: #fff; color: #1f2d3d; }
.eer-field input:focus, .eer-field select:focus, .eer-search input:focus, .eer-search select:focus { outline: none; border-color: var(--eer-primary); box-shadow: 0 0 0 2px rgba(var(--eer-primary-rgb), .15); }
.eer-range { grid-column: span 2; }
.eer-range > div { display: flex; align-items: center; gap: 6px; }
.eer-range > div input { flex: 1; min-width: 0; }

/* Type-ahead combo */
.eer-combo { position: relative; }
.eer-combo input { padding-right: 28px; }
.eer-combo-clear { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); border: none; background: none; color: #8a96a3; font-size: 18px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.eer-combo-clear:hover { color: #b02a37; }
.eer-combo-list { position: absolute; z-index: 1200; left: 0; right: 0; top: calc(100% + 2px); max-height: 260px; overflow-y: auto; margin: 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid #cfd8e3; border-radius: 6px; box-shadow: 0 6px 20px rgba(0, 0, 0, .15); min-width: 180px; }
.eer-combo-list li { display: flex; justify-content: space-between; gap: 8px; padding: 6px 10px; font-size: 14px; cursor: pointer; }
.eer-combo-list li span { overflow-wrap: anywhere; }
.eer-combo-list li small { color: #8a96a3; font-size: 11px; white-space: nowrap; }
.eer-combo-list li:hover, .eer-combo-list li.active { background: var(--eer-tint); }
.eer-combo-list li[aria-selected="true"] { font-weight: 700; color: var(--eer-primary); }
.eer-combo-list li.eer-combo-none { color: #8a96a3; cursor: default; }
.eer-upper { text-transform: uppercase; }

/* Grid: SmDataGrid host (sticky header + sticky Roll No, server-side filters only) */
#eerGrid .sm-dg-tb-btn[data-action="filters"], #eerGrid .sm-dg-filter-panel { display: none !important; }
#eerGrid .sm-dg-toolbar { flex-wrap: wrap; }
#eerGrid .sm-dg-tb-btn, #eerGrid .sm-dg-col-footer-btn { color: var(--eer-primary); }
#eerGrid .sm-dg-tb-btn:hover, #eerGrid .sm-dg-tb-btn-active { background: var(--eer-tint); }
#eerGrid .sm-dg-th-header:hover, #eerGrid .sm-dg-sort-arrow { color: var(--eer-primary); }
#eerGrid .sm-dg-table-wrapper { overflow-x: auto; overflow-y: visible; -webkit-overflow-scrolling: touch; }   /* no inner vertical scroll: the page scrolls */
#eerGrid .sm-dg-table { border-collapse: separate; border-spacing: 0; font-size: 13px; }
#eerGrid .sm-dg-table th, #eerGrid .sm-dg-table td { white-space: nowrap; }
#eerGrid .sm-dg-table th { padding: 8px; white-space: normal; line-height: 1.25; vertical-align: bottom; }   /* long headers wrap instead of widening the grid */
#eerGrid .sm-dg-sort-arrow:empty { display: none; }   /* unsorted columns don't reserve arrow space */
#eerGrid .eer-act { margin-left: 2px; padding: 4px; line-height: 0; }
#eerGrid .eer-act svg { width: 15px; height: 15px; fill: currentColor; }
#eerGrid .sm-dg-table thead th { position: sticky; top: 0; z-index: 2; background: #f5f5f5; color: var(--eer-primary); border-bottom: 2px solid #e0e0e0; }
#eerGrid .sm-dg-table tbody tr { background: #fff; }
#eerGrid .sm-dg-table tbody tr:nth-child(even) { background: #f8fafc; }
#eerGrid .sm-dg-table tbody tr:hover { background: var(--eer-tint) !important; }
#eerGrid .sm-dg-table td { border-bottom: 1px solid #f2f2f2; }
#eerGrid .sm-dg-table th[data-field="rollNo"], #eerGrid .sm-dg-table td:first-child { position: sticky; left: 0; z-index: 1; background: inherit; box-shadow: 1px 0 0 #e0e0e0; }
#eerGrid .sm-dg-table thead th[data-field="rollNo"] { z-index: 3; background: #f5f5f5; }
#eerGrid th[data-field="actions"] .sm-dg-th-header, #eerGrid th[data-field="result"] .sm-dg-th-header { cursor: default; }
#eerGrid :is(th[data-field="chance"], th[data-field="internal"], th[data-field="extMarks"], th[data-field="total"], th[data-field="credits"], th[data-field="actCredits"], th[data-field="gradePoint"]) .sm-dg-th-header { justify-content: flex-end; flex-direction: row-reverse; }
.eer-num { display: block; text-align: right; font-variant-numeric: tabular-nums; }
.eer-skel-bar { display: block; height: 12px; min-width: 40px; border-radius: 4px; background: linear-gradient(90deg, #edf1f6 25%, #f7f9fc 50%, #edf1f6 75%); background-size: 200% 100%; animation: eerShimmer 1.2s infinite linear; }
@keyframes eerShimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.eer-roll { all: unset; cursor: pointer; color: var(--eer-link); font-weight: 600; }
.eer-roll:hover, .eer-roll:focus-visible { text-decoration: underline; }
.eer-act { border: 1px solid #cfd8e3; background: #fff; color: #33475b; border-radius: 4px; padding: 3px 8px; font-size: 12px; cursor: pointer; margin-left: 4px; }
.eer-act:hover { border-color: var(--eer-primary); color: var(--eer-primary); }
.eer-act-del:hover { border-color: #dc3545; color: #dc3545; }
.eer-badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.eer-badge.pass { background: #e3f4e8; color: #1f7a3d; }
.eer-badge.fail { background: #fde8ea; color: #b02a37; }
.eer-badge.absent { background: #eceff3; color: #5b6b7f; }

/* Pager */
.eer-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 10px 18px; padding: 10px 2px; font-size: 14px; color: #33475b; }
.eer-pagesize { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-weight: 400; margin: 0; }
.eer-pagesize select { width: auto; margin: 0; padding: 5px 8px; border: 1px solid #cfd8e3; border-radius: 6px; background: #fff; }
.eer-range-text { font-variant-numeric: tabular-nums; }
.eer-pager-btns { display: inline-flex; align-items: center; gap: 4px; }
.eer-pager-btns button { min-width: 32px; height: 32px; border: 1px solid #cfd8e3; background: #fff; border-radius: 6px; font-size: 16px; cursor: pointer; color: var(--eer-primary); }
.eer-pager-btns button:hover:not(:disabled) { background: var(--eer-tint); }
.eer-pager-btns button:disabled { opacity: .4; cursor: not-allowed; }
.eer-page-info { padding: 0 6px; white-space: nowrap; }

/* Drawer (add / edit / view) */
.eer-no-scroll { overflow: hidden; }
.eer-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 1090; }
.eer-drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100vw); background: #fff; z-index: 1150; display: flex; flex-direction: column; box-shadow: -8px 0 30px rgba(0, 0, 0, .2); transform: translateX(100%); transition: transform .22s ease-out; }
.eer-drawer.open { transform: none; }
.eer-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 3px solid var(--eer-primary); }
.eer-drawer-head h2 { margin: 0; font-size: 18px; color: var(--eer-primary); overflow-wrap: anywhere; }
.eer-x { border: none; background: none; font-size: 26px; line-height: 1; color: #5b6b7f; cursor: pointer; padding: 0 4px; min-width: 36px; min-height: 36px; }
.eer-x:hover { color: #1f2d3d; }
.eer-drawer-body { flex: 1; overflow-y: auto; padding: 16px 18px; }
.eer-drawer-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid #e0e6ef; }
.eer-drawer fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.eer-drawer fieldset:disabled input, .eer-drawer fieldset:disabled select { background: #f5f7fa; color: #1f2d3d; }
.eer-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 14px; }
.eer-req { color: #dc3545; }
.eer-hint { font-weight: 400; color: #8a96a3; margin-left: 4px; }
.eer-check { justify-content: flex-end; }
.eer-check label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: #1f2d3d; padding: 8px 0; }
.eer-check input { width: auto; accent-color: var(--eer-primary); }
.eer-form-error { background: #fde8ea; color: #8f1d29; border: 1px solid #f3b8bf; border-radius: 6px; padding: 10px 12px; margin-bottom: 14px; font-size: 14px; }

/* Student register view (Credit Register .cr-* layout, re-pointed at the skin variables) */
.eer-page .stu-note { border-left-color: var(--eer-primary); }
.eer-page .cr-card-title { background: var(--eer-primary); }
.eer-page .cr-table thead th, .eer-page .cr-subtitle, .eer-page .cr-grades th[scope="row"] { color: var(--eer-primary); }
.eer-page .cr-band-sem td { background: var(--eer-band); }
.eer-page .cr-watermark::before { color: rgba(var(--eer-primary-rgb), .06); }
.eer-page .eer-reg-table { min-width: 720px; }
.eer-page .eer-reg-table th, .eer-page .eer-reg-table td { padding: 7px 8px; }
.eer-page .eer-reg-table thead th { white-space: normal; }
.eer-page .eer-reg-table td { vertical-align: top; }
.eer-page .eer-reg-course { min-width: 180px; white-space: normal; }
.eer-page .eer-reg-course .eer-roll { white-space: normal; }
.eer-reg-earlier { margin-top: 2px; font-size: 11px; color: #c62828; white-space: normal; }
.eer-page .cr-reg-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-bottom: 14px; }

/* Delete confirm */
#eerConfirm { z-index: 1300; }
.eer-confirm { text-align: left; max-width: 440px; padding: 28px; }
.eer-confirm-btns { display: flex; justify-content: flex-end; gap: 10px; }
#eerExport { z-index: 1300; }
.eer-progress { width: 100%; height: 10px; margin: -12px 0 20px; accent-color: var(--eer-primary); }

/* Tablet */
@media (max-width: 900px) {
    .eer-search { flex-basis: 100%; max-width: none; order: 3; }
}

/* Phone */
@media (max-width: 600px) {
    .page-content.eer-page { padding: 12px 8px; }
    .eer-page .container { padding: 16px; }
    .eer-title h1 { font-size: 22px; }
    .eer-head .eer-btn { flex: 1 1 100%; }
    .eer-filters { padding: 8px 12px; }
    .eer-range { grid-column: auto; }
    .eer-filter-body { grid-template-columns: minmax(0, 1fr); }
    .eer-search select { max-width: 120px; }
    .eer-field input, .eer-field select, .eer-search input, .eer-search select { font-size: 16px; }   /* no iOS zoom on focus */
    .eer-combo-list li { padding: 10px 12px; }
    #eerGrid .eer-act { padding: 7px; }
    .eer-pager { justify-content: center; gap: 8px 12px; }
    .eer-range-text { order: -1; flex-basis: 100%; text-align: center; }
    .eer-pager-btns button { min-width: 40px; height: 40px; }
    .eer-drawer, .eer-drawer.open { width: 100vw; }
    .eer-drawer-head, .eer-drawer-body, .eer-drawer-foot { padding-left: 16px; padding-right: 16px; }
    .eer-grid { grid-template-columns: minmax(0, 1fr); }
    .eer-drawer-foot > button { flex: 1 1 0; }
    .eer-page .cr-reg-actions .modal-button { flex: 1 1 0; }
    /* the register table scrolls sideways: keep SGPA / CGPA / Total text on screen */
    .eer-page .cr-band-sgpa td, .eer-page .cr-band-cgpa td, .eer-page .cr-total td.cr-right { text-align: left; }
    .eer-page .eer-band-text { display: block; max-width: calc(100vw - 110px); white-space: normal; }
    .eer-confirm { min-width: 0; width: calc(100vw - 32px); padding: 22px; }
    .eer-confirm-btns > button { flex: 1 1 0; }
}

@media (prefers-reduced-motion: reduce) {
    .eer-drawer, .eer-caret { transition: none; }
    .eer-skel-bar { animation: none; }
}

/* The results list prints landscape (named page) so all columns fit; the register keeps the default page */
@page eer-list { size: landscape; margin: 10mm; }

@media print {
    #headerContainer, #dynamicSidebarContainer, #footerContainer,
    .eer-page .cr-reg-actions, #eerToasts, #chatWidget, .chat-widget-toggle, .sidebar-toggle { display: none !important; }
    /* Ctrl+P on the list view: print the grid with every visible column, no scroll clipping */
    #eerViewList.active { page: eer-list; }
    .eer-page .stu-view.active { animation: none !important; }
    .eer-page .container { box-shadow: none !important; padding: 0 !important; }
    .eer-skel-bar { min-width: 0; }
    .eer-filters, .eer-head .eer-btn, .eer-pager-btns, .eer-pagesize, #eerGrid .sm-dg-toolbar, #eerGrid .sm-dg-panel,
    #eerGrid th[data-field="actions"], #eerGrid td:last-child { display: none !important; }
    #eerGrid, #eerGrid .sm-dg-table-wrapper { overflow: visible !important; border: none; }
    #eerGrid .sm-dg-table { font-size: 9px; width: 100%; }
    #eerGrid .sm-dg-table th, #eerGrid .sm-dg-table td { position: static !important; padding: 3px 4px !important; white-space: normal; box-shadow: none; }
    #eerGrid .sm-dg-table thead { display: table-header-group; }
    #eerGrid .sm-dg-table tr { break-inside: avoid; }
    .eer-badge { padding: 0; background: none !important; }
    .eer-page .eer-roll { color: inherit; }
    .eer-page { margin: 0 !important; padding: 0 !important; }
    .eer-page .container { padding: 0 !important; }
    .eer-page .cr-table-wrap { overflow: visible; border: none; }
    .eer-page .eer-reg-table { min-width: 0; font-size: 11px; }
    .eer-page .eer-roll { color: inherit; }
    .eer-page .cr-band td, .eer-page .cr-card-title { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .eer-page .cr-table tr { break-inside: avoid; }
}

/* ===================================================================
   Exam Codes page (examsetup.html / js/exam-setup.js) - ec-*
   Reuses the Exam Fee Setup modal shell (.fs-modal*), toasts (.fs-toast*),
   skeleton / empty state (.fs-skel-row, .fs-state) and form bits (.fm-*).
   Brand colours follow the --eer-* variables, so a skin re-colours this page too.
   =================================================================== */
html:has(.ec-page) { height: auto; }
html:has(.ec-page) body { height: auto; overflow-x: clip; }
.page-content.ec-page { padding: 20px; }
.ec-page .container { max-width: 100%; width: 100%; padding: 24px; min-width: 0; }
.ec-page [hidden], .ec-modal [hidden] { display: none !important; }

.ec-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.ec-head h1 { margin: 0; color: var(--eer-primary, #003B7A); }
.ec-sub { margin: 2px 0 0; color: #5b6b7f; font-size: 14px; }
.ec-page .ec-btn, .ec-modal .ec-btn { width: auto; margin-top: 0; padding: 9px 18px; }

/* Filters */
.ec-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; align-items: center; margin-bottom: 16px; padding: 12px; background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; }
.ec-filters select, .ec-filters input { width: 100%; margin: 0; padding: 8px 10px; font-size: 14px; box-sizing: border-box; }
.ec-filters select:disabled { background: #f3f5f8; color: #9aa5b1; }
.ec-filters input[type="search"] { grid-column: span 2; }
.ec-link-btn { justify-self: start; border: none; background: none; padding: 8px 4px; color: var(--eer-link, #1565F5); font-size: 14px; font-weight: 600; cursor: pointer; }
.ec-link-btn:hover { text-decoration: underline; }

/* Grid */
#ecGrid .sm-dg-tb-btn[data-action="filters"], #ecGrid .sm-dg-filter-panel { display: none !important; }
#ecGrid .sm-dg-pagination { display: none; }
#ecGrid .sm-dg-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#ecGrid .sm-dg-table { font-size: 13px; }
#ecGrid .sm-dg-table th, #ecGrid .sm-dg-table td { white-space: nowrap; }
#ecGrid .sm-dg-sort-arrow:empty { display: none; }
/* Every column centred (headers + cells, Exam Code included) */
#ecGrid .sm-dg-table th, #ecGrid .sm-dg-table td { text-align: center; }
#ecGrid .sm-dg-th-header { justify-content: center; }
#ecGrid .ec-num { text-align: center; }
.ec-code { color: #1f2d3d; letter-spacing: .3px; }
.ec-name { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
.ec-num { display: block; text-align: right; font-variant-numeric: tabular-nums; }
.ec-expand { width: 24px; height: 24px; padding: 0; border: 1px solid #b9c7da; border-radius: 50%; background: #fff; color: var(--eer-link, #1565F5); font-size: 16px; font-weight: 700; line-height: 1; cursor: pointer; }
.ec-expand:hover, .ec-expand[aria-expanded="true"] { background: var(--eer-tint, #e8eef7); }
.ec-actions { display: inline-flex; gap: 4px; }
.ec-act { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; padding: 0; border: 1px solid transparent; border-radius: 6px; background: transparent; cursor: pointer; }
.ec-act svg { width: 18px; height: 18px; }
.ec-act-edit svg { fill: #d99a00; }
.ec-act-edit:hover { background: #fff6dc; border-color: #f3d38a; }
.ec-act-del svg { fill: #c62f3d; }
.ec-act-del:hover { background: #fdecee; border-color: #f1b0b7; }
.ec-act-done svg { fill: #1f7a3d; }
.ec-act-done:hover { background: #e3f4e8; border-color: #a9d8b7; }
.ec-act:disabled { opacity: .45; cursor: wait; }
.ec-badge { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.ec-badge-ongoing { background: #e3edff; color: #0d47c4; }
.ec-badge-completed { background: #e3f4e8; color: #1f7a3d; }
.ec-badge-other { background: #eceff3; color: #5b6b7f; }

/* Expanded row */
.ec-detail-row > td { padding: 0 !important; background: #f6f8fb; white-space: normal !important; }
.ec-detail { display: grid; grid-template-columns: minmax(260px, 340px) minmax(0, 1fr); gap: 18px; padding: 14px 16px 16px 48px; }
.ec-detail h4 { margin: 0 0 6px; font-size: 13px; color: var(--eer-primary, #003B7A); }
.ec-fee-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid #e0e6ef; font-size: 13px; }
.ec-fee-table th, .ec-fee-table td { padding: 6px 10px; border-bottom: 1px solid #eef2f7; text-align: left; }
.ec-fee-table thead th { background: #eef3fa; color: var(--eer-primary, #003B7A); font-weight: 600; }
.ec-fee-table tbody th { font-weight: 500; color: #33475b; }
.ec-fee-table .ec-num { display: table-cell; text-align: right; }
.ec-detail-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 18px; margin: 0; align-content: start; }
.ec-detail-grid dt { font-size: 12px; color: #6b7a8c; }
.ec-detail-grid dd { margin: 0; font-size: 13px; font-weight: 600; color: #1f2d3d; overflow-wrap: anywhere; }

/* Cards (mobile) */
.ec-cards { display: none; }
.ec-card { background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; padding: 12px 14px; margin-bottom: 12px; }
.ec-card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ec-card-no { margin-left: 8px; font-size: 12px; color: #8a97a6; }
.ec-card-name { margin: 6px 0 10px; font-size: 13px; color: #33475b; }
.ec-card-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 0 0 8px; }
.ec-card-kv dt { font-size: 11px; color: #6b7a8c; }
.ec-card-kv dd { margin: 0; font-size: 13px; font-weight: 600; color: #1f2d3d; }
.ec-card-more summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--eer-link, #1565F5); padding: 4px 0; }
.ec-card-more .ec-detail { grid-template-columns: 1fr; padding: 8px 0; }
.ec-card-foot { display: flex; justify-content: flex-end; border-top: 1px solid #eef2f7; padding-top: 8px; margin-top: 6px; }

/* Pager */
.ec-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 18px; padding: 10px 2px; font-size: 14px; color: #33475b; }
.ec-range { font-variant-numeric: tabular-nums; }
.ec-pagesize { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 400; white-space: nowrap; }
.ec-pagesize select { width: auto; margin: 0; padding: 5px 8px; }
.ec-pager-btns { display: inline-flex; align-items: center; gap: 6px; }
.ec-pager-btns button { min-width: 34px; height: 32px; border: 1px solid #cfd8e3; border-radius: 6px; background: #fff; color: var(--eer-primary, #003B7A); font-size: 18px; cursor: pointer; }
.ec-pager-btns button:hover:not(:disabled) { background: var(--eer-tint, #e8eef7); }
.ec-pager-btns button:disabled { opacity: .4; cursor: not-allowed; }

/* Modal form: 3 columns, labels right-aligned beside the control */
.ec-dialog { max-width: 1180px; }
.ec-modal-loading { display: flex; justify-content: center; padding: 60px 0; }
.ec-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 22px; margin-bottom: 14px; }
.ec-field { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 10px; align-items: start; min-width: 0; }
.ec-field > label { margin: 0; padding-top: 9px; text-align: right; font-size: 13px; font-weight: 600; color: #33475b; line-height: 1.25; }
.ec-control { min-width: 0; }
.ec-control > input, .ec-control > select, .ec-date input, .ec-combo input { width: 100%; margin: 0; padding: 8px 10px; font-size: 14px; box-sizing: border-box; }
.ec-control select:disabled { background: #f3f5f8; color: #9aa5b1; }
.ec-span-2 { grid-column: span 2; }
.ec-span-full { grid-column: 1 / -1; }
.ec-req { color: #dc3545; }
.ec-amount { text-align: right; font-variant-numeric: tabular-nums; }
.ec-section-link { margin: 6px 0 12px; font-size: 15px; font-weight: 600; color: var(--eer-link, #1565F5); text-decoration: underline; text-underline-offset: 3px; }
.ec-section-title { margin: 6px 0 12px; padding-bottom: 6px; font-size: 15px; font-weight: 600; color: var(--eer-primary, #003B7A); border-bottom: 1px solid #dfe6ef; }
.ec-collapse { margin-bottom: 12px; background: #fff; border: 1px solid #e0e6ef; border-radius: 8px; }
.ec-collapse > summary { padding: 10px 14px; font-weight: 600; color: var(--eer-primary, #003B7A); cursor: pointer; }
.ec-collapse[open] > summary { border-bottom: 1px solid #eef2f7; margin-bottom: 12px; }
.ec-collapse > .ec-form-grid { padding: 0 14px; }
.ec-range-pair { display: flex; align-items: center; gap: 8px; }
.ec-range-pair > span { font-size: 13px; color: #6b7a8c; }
.ec-range-pair .ec-date { flex: 1 1 0; min-width: 0; }

/* Date picker with clear (x) */
.ec-date { position: relative; }
.ec-date input { padding-right: 30px; }
.ec-date-clear, .ec-combo-clear { position: absolute; top: 50%; right: 30px; transform: translateY(-50%); width: 22px; height: 22px; padding: 0; border: none; border-radius: 50%; background: transparent; color: #8a97a6; font-size: 18px; line-height: 1; cursor: pointer; }
.ec-date-clear:hover, .ec-combo-clear:hover { background: #eef2f7; color: #c62f3d; }
.ec-combo-clear { right: 6px; }

/* Searchable select */
.ec-combo { position: relative; }
.ec-combo input { padding-right: 30px; }
.ec-combo-list { position: absolute; z-index: 20; top: calc(100% + 2px); left: 0; right: 0; max-height: 240px; overflow-y: auto; margin: 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid #cfd8e3; border-radius: 6px; box-shadow: 0 8px 22px rgba(0, 0, 0, .15); }
.ec-combo-list li { padding: 7px 12px; font-size: 13px; cursor: pointer; }
.ec-combo-list li[aria-selected="true"] { font-weight: 600; }
.ec-combo-list li.active, .ec-combo-list li[role="option"]:hover { background: var(--eer-tint, #e8eef7); }
.ec-combo-list .ec-combo-none { color: #8a97a6; cursor: default; font-style: italic; }

.ec-modal-footer { justify-content: space-between; }
.ec-modal .ec-cancel-btn { background: #dc3545; border-color: #dc3545; }
.ec-modal .ec-cancel-btn:hover { background: #b02a37; }
.ec-modal .fm-save-btn:disabled:not(.is-saving) { opacity: .55; cursor: not-allowed; }

@media (max-width: 1200px) {
    .ec-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ec-blank { display: none; }
    .ec-span-2 { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
    .page-content.ec-page { padding: 0; }
    .ec-page .container { padding: 12px 16px; }
    .ec-head .ec-btn { width: 100%; }
    .ec-filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ec-filters input[type="search"] { grid-column: 1 / -1; }
    #ecGrid { display: none; }
    .ec-cards { display: block; }
    .ec-pager { justify-content: center; }
    .ec-form-grid { grid-template-columns: 1fr; }
    .ec-field { grid-template-columns: 1fr; gap: 4px; }
    .ec-field > label { padding-top: 0; text-align: left; }
    .ec-range-pair { flex-wrap: wrap; }
    .ec-detail { grid-template-columns: 1fr; padding: 12px; }
}

/* ===================================================================
   Grace Marks page (gracemarks.html) - gm-*
   Full width like the other exam pages. Brand colour follows --eer-primary
   so a skin that re-points it re-themes this page too.
   =================================================================== */
:root {
    --gm-primary: var(--eer-primary, #003B7A);
    --gm-primary-dark: var(--eer-primary-dark, #002a5c);
    --gm-tint: var(--eer-tint, #e8eef7);
    --gm-border: #e0e6ef;
    --gm-head-bg: #f4f6f9;
}
html:has(.gm-page) { height: auto; }
html:has(.gm-page) body { height: auto; overflow-x: clip; }
.page-content.gm-page { padding: 20px; }
.gm-page .container { max-width: 100%; width: 100%; min-width: 0; padding: 24px; }
.gm-page [hidden], .gm-overlay[hidden], .gm-overlay [hidden] { display: none !important; }
.gm-h1 { margin: 0 0 14px; }
.gm-upper { text-transform: uppercase; }

/* Cards */
.gm-card { background: #fff; border: 1px solid var(--gm-border); border-radius: 8px; box-shadow: 0 1px 3px rgba(0, 0, 0, .05); margin-bottom: 16px; min-width: 0; }
.gm-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--gm-border); }
.gm-card-head h2 { margin: 0; font-size: 17px; color: var(--gm-primary); }
.gm-filters .gm-card-head { border-bottom: none; padding-bottom: 4px; }

/* Buttons */
.gm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: auto; margin: 0; padding: 9px 16px; border-radius: 5px; border: 1px solid transparent; font-size: 14px; font-weight: 600; cursor: pointer; line-height: 1.2; white-space: nowrap; }
.gm-btn:disabled { opacity: .6; cursor: not-allowed; }
.gm-btn-primary { background: var(--gm-primary); color: #fff; }
.gm-btn-primary:hover:not(:disabled) { background: var(--gm-primary-dark); }
.gm-btn-secondary { background: #fff; color: #33475b; border-color: #cfd8e3; }
.gm-btn-secondary:hover:not(:disabled) { background: #f1f4f8; }
.gm-btn-danger { background: #dc3545; color: #fff; }
.gm-btn-danger:hover:not(:disabled) { background: #b52a37; }
.gm-link-btn { background: none; border: none; color: var(--gm-primary); font-weight: 700; font-size: 15px; cursor: pointer; padding: 4px 0; margin: 0; width: auto; display: inline-flex; align-items: center; gap: 6px; }
.gm-caret { display: inline-block; transition: transform .2s; }
.gm-link-btn[aria-expanded="false"] .gm-caret { transform: rotate(-90deg); }

/* Fields */
.gm-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.gm-field > label, .gm-range-label, .gm-label { font-size: 12px; font-weight: 600; color: #4a5a6a; margin: 0; }
.gm-page .gm-field input:not([type=checkbox]), .gm-page .gm-field select,
.gm-overlay .gm-field input:not([type=checkbox]), .gm-overlay .gm-field select {
    width: 100%; min-width: 0; height: 36px; padding: 6px 10px; margin: 0; border: 1px solid #cfd8e3; border-radius: 5px; font-size: 14px; background: #fff; box-sizing: border-box;
}
.gm-field input:focus, .gm-field select:focus, .gm-search input:focus, .gm-inline select:focus { outline: none; border-color: var(--gm-primary); box-shadow: 0 0 0 3px rgba(var(--eer-primary-rgb, 0, 59, 122), .15); }
.gm-page .gm-field select:disabled, .gm-overlay .gm-field select:disabled, .gm-overlay .gm-field input:disabled { background: #f3f5f8; color: #8a96a3; }
.gm-field [aria-invalid="true"] { border-color: #dc3545 !important; }
.gm-err { color: #dc3545; font-size: 12px; }
.gm-range > div { display: flex; align-items: center; gap: 6px; }
.gm-range > div > span { color: #8a96a3; }
.gm-check { justify-content: flex-end; }
.gm-check label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; height: 36px; margin: 0; cursor: pointer; }
.gm-check input { width: 18px; height: 18px; margin: 0; }
.gm-req { color: #dc3545; }
.gm-hint { color: #8a96a3; font-size: 11px; }
.gm-calc { display: flex; align-items: center; height: 36px; padding: 0 10px; border: 1px dashed #cfd8e3; border-radius: 5px; background: var(--gm-tint); font-weight: 700; color: var(--gm-primary); }

/* Filter panel */
.gm-filter-body { padding: 8px 16px 16px; }
.gm-filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 14px; }
.gm-filter-grid .gm-range { grid-column: span 2; }
.gm-filter-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }

/* List toolbar */
.gm-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; }
.gm-toolbar-left { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.gm-inline { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: #33475b; margin: 0; font-weight: 400; }
.gm-inline select { width: auto; height: 32px; padding: 2px 8px; margin: 0; border: 1px solid #cfd8e3; border-radius: 5px; }
.gm-search input { width: 260px; max-width: 60vw; height: 32px; padding: 4px 10px; margin: 0; border: 1px solid #cfd8e3; border-radius: 5px; font-size: 14px; }

/* Grid (the table scrolls sideways inside the card on narrow screens) */
.gm-grid-wrap { position: relative; min-height: 120px; padding: 0 16px; }
.gm-grid { min-width: 0; }
/* The grid's Filters panel would only filter the loaded page - the filter panel above does it server-side */
#gmGrid .sm-dg-tb-btn[data-action="filters"] { display: none; }
#gmGrid .gm-dg-excel { color: #1d7a45; font-weight: 600; }
#gmGrid .gm-dg-excel .sm-dg-tb-icon { fill: #1d7a45; }
#gmGrid .gm-dg-excel:disabled { opacity: .6; cursor: progress; }
#gmGrid .sm-dg-table-wrapper { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#gmGrid .sm-dg-table th { background: var(--gm-head-bg); white-space: nowrap; font-size: 13px; }
#gmGrid .sm-dg-table td { white-space: nowrap; font-size: 13px; }
.gm-loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .65); z-index: 2; }
.gm-loading-inline { padding: 20px 0; }
.gm-exp { width: 22px; height: 22px; padding: 0; margin: 0; border: none; border-radius: 50%; background: var(--gm-primary); color: #fff; font-weight: 700; font-size: 15px; line-height: 22px; cursor: pointer; }
.gm-exp[aria-expanded="true"] { background: #dc3545; }
.gm-grace { color: #1d7a45; }
.gm-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .02em; }
.gm-badge-paid { background: #d9f2e3; color: #17663a; }
.gm-badge-unpaid { background: #e9ecef; color: #5a6570; }
.gm-badge-fail { background: #fde2e4; color: #a71d2a; }
.gm-actions { display: inline-flex; gap: 4px; }
.gm-icon-btn { width: 30px; height: 30px; padding: 5px; margin: 0; border: 1px solid #d6dee8; border-radius: 5px; background: #fff; color: var(--gm-primary); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.gm-icon-btn svg { width: 16px; height: 16px; fill: currentColor; }
.gm-icon-btn:hover { background: var(--gm-tint); }
.gm-icon-danger { color: #dc3545; }
.gm-icon-danger:hover { background: #fde2e4; }
#gmGrid tr.gm-detail > td { background: #f8fafc; padding: 10px 16px 12px 52px !important; white-space: normal; }
.gm-detail-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 18px; margin: 0; }
.gm-detail-dl dt, .gm-dl dt { font-size: 11px; font-weight: 600; color: #6b7a89; text-transform: uppercase; letter-spacing: .03em; }
.gm-detail-dl dd, .gm-dl dd { margin: 2px 0 0; font-size: 13px; color: #1f2d3a; word-break: break-word; }

/* Pager */
.gm-pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 16px; }
.gm-pager-info { font-size: 14px; color: #4a5a6a; }
.gm-pager-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; }
.gm-pager-nav button { min-width: 34px; height: 32px; padding: 0 10px; margin: 0; border: 1px solid #d6dee8; border-radius: 4px; background: #fff; color: var(--gm-primary); font-size: 13px; cursor: pointer; width: auto; }
.gm-pager-nav button:hover:not(:disabled):not(.current) { background: var(--gm-tint); }
.gm-pager-nav button.current { background: var(--gm-primary); border-color: var(--gm-primary); color: #fff; cursor: default; }
.gm-pager-nav button:disabled { color: #9aa6b2; cursor: not-allowed; background: #f5f7fa; }
.gm-ellipsis { padding: 0 4px; color: #8a96a3; }

/* Type-ahead */
.gm-ta { position: relative; }
.gm-ta-list { position: absolute; left: 0; right: 0; top: 100%; z-index: 30; margin: 2px 0 0; padding: 4px 0; list-style: none; background: #fff; border: 1px solid #cfd8e3; border-radius: 5px; box-shadow: 0 6px 18px rgba(0, 0, 0, .12); max-height: 260px; overflow-y: auto; min-width: 240px; }
.gm-ta-list li { padding: 7px 10px; font-size: 13px; cursor: pointer; display: flex; gap: 8px; align-items: baseline; }
.gm-ta-list li small { margin-left: auto; color: #8a96a3; }
.gm-ta-list li.active, .gm-ta-list li[role=option]:hover { background: var(--gm-tint); }
.gm-ta-list li.gm-ta-empty { color: #8a96a3; cursor: default; }

/* Modals */
body.gm-modal-open { overflow: hidden; }
.gm-overlay { position: fixed; inset: 0; z-index: 1005; background: rgba(15, 25, 40, .5); display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; }
.gm-dialog { background: #fff; border-radius: 10px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); width: 100%; display: flex; flex-direction: column; max-height: calc(100vh - 60px); animation: slideDown .25s; }
.gm-dialog-lg { max-width: 900px; }
.gm-dialog-sm { max-width: 440px; }
.gm-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-bottom: 1px solid var(--gm-border); }
.gm-dialog-head h2 { margin: 0; font-size: 18px; color: var(--gm-primary); }
.gm-x { background: none; border: none; font-size: 26px; line-height: 1; color: #6b7a89; cursor: pointer; padding: 0 4px; margin: 0; width: auto; }
.gm-x:hover { color: #1f2d3a; }
.gm-dialog-body { padding: 16px 20px; overflow-y: auto; }
.gm-dialog-body fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
.gm-dialog-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 20px; border-top: 1px solid var(--gm-border); }
.gm-section { margin: 14px 0 10px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--gm-primary); border-bottom: 1px solid var(--gm-border); padding-bottom: 4px; }
.gm-section:first-child { margin-top: 0; }
.gm-form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 14px; }
.gm-span-2 { grid-column: span 2; }
.gm-form-error { background: #fde2e4; color: #a71d2a; border: 1px solid #f5c2c7; border-radius: 5px; padding: 10px 12px; margin-bottom: 12px; font-size: 14px; }
.gm-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px 18px; margin: 0; }

@media (max-width: 900px) {
    .gm-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
    .page-content.gm-page { padding: 10px; }
    .gm-page .container { padding: 12px; }
    .gm-filter-grid { grid-template-columns: 1fr; }
    .gm-filter-grid .gm-range, .gm-span-2 { grid-column: auto; }
    .gm-form-grid { grid-template-columns: 1fr; }
    .gm-toolbar, .gm-pager { flex-direction: column; align-items: stretch; }
    .gm-search { width: 100%; }
    .gm-search input { width: 100%; max-width: none; flex: 1; }
    .gm-filter-actions .gm-btn { flex: 1; }
    .gm-grid-wrap { padding: 0 8px; }
    .gm-overlay { padding: 0; }
    .gm-dialog { max-height: 100vh; border-radius: 0; }
}
