@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-dark: #f1f5f9;
    --bg-card: #ffffff;
    --primary: #0c2340;
    --primary-hover: #0a1b31;
    --primary-glow: rgba(12, 35, 64, 0.1);
    --secondary: #475569;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-light: #f8fafc;
    --glass: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --sidebar-bg: #0f172a;
    --sidebar-hover: rgba(255, 255, 255, 0.05);
    --sidebar-active: rgba(12, 35, 64, 0.2);
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-float: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

/* Stunning Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Layout Shell */
#app {
    display: none;
    grid-template-columns: 280px 1fr;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
aside {
    background: var(--sidebar-bg);
    margin: 1.2rem 0 1.2rem 1.2rem;
    border-radius: 24px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    color: #ffffff;
    box-shadow: var(--shadow-lg);
    height: calc(100vh - 2.4rem);
    position: relative;
    overflow: hidden;
}

/* Subtle gradient glow in sidebar */
aside::before {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(37,99,235,0.4) 0%, transparent 70%);
    pointer-events: none;
}

nav {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
    z-index: 1;
}

nav::-webkit-scrollbar { width: 4px; }
nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }
nav::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

.logo {
    font-size: 1.6rem;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -0.5px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    z-index: 1;
}

.logo i {
    color: #38bdf8;
    filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.4));
}

nav ul { list-style: none; display: flex; flex-direction: column; gap: 0.4rem; }
nav li {
    padding: 0.85rem 1.2rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
    white-space: nowrap;
}
nav li:hover {
    background: var(--sidebar-hover);
    color: #ffffff;
    transform: translateX(4px);
}
nav li.active {
    background: var(--sidebar-active);
    color: #ffffff;
    box-shadow: inset 3px 0 0 #38bdf8;
}

#user-display-name { color: #ffffff; font-weight: 600; font-size: 1.05rem; margin-bottom: 0.2rem; }
#user-display-role { color: #64748b; font-size: 0.85rem; font-weight: 500; }

/* Main Content */
main {
    padding: 1rem 2rem;
    overflow-y: auto;
}

header {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin: 0;
    padding: 0.25rem 0;
    position: sticky;
    top: 0;
    background: rgba(241, 245, 249, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100;
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}
header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
    margin: 0;
}

/* Premium Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 24px;
    padding: 2rem;
    max-width: 1000px;
    margin: 0 0 2.5rem 0;
    box-shadow: var(--shadow-md);
    transition: all 0.3s ease;
}
.card:hover {
    box-shadow: var(--shadow-float);
    border-color: rgba(37, 99, 235, 0.2);
}

/* Login View */
#login-container {
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, #e0e7ff, var(--bg-dark));
    position: relative;
    overflow: hidden;
}

#login-container::before {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.15;
    top: -200px;
    right: -200px;
    animation: float 10s infinite alternate ease-in-out;
}

@keyframes float {
    0% { transform: translateY(0) scale(1); }
    100% { transform: translateY(50px) scale(1.1); }
}

.login-card {
    width: 440px;
    padding: 2.25rem 3.5rem;
    text-align: center;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 32px;
    box-shadow: var(--shadow-float);
    position: relative;
    z-index: 10;
}

.login-card h2 { margin-bottom: 0.5rem; font-size: 2.2rem; font-weight: 800; letter-spacing: -1px; }
.login-card p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }

input, .auth-select {
    width: 100%;
    background: #f8fafc;
    border: 1px solid var(--border);
    padding: 0.85rem 1.1rem;
    border-radius: 12px;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
input:focus, .auth-select:focus { 
    border-color: var(--primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px var(--primary-glow);
}

button {
    width: 100%;
    padding: 0.9rem;
    background: linear-gradient(135deg, var(--primary) 0%, #1e1b4b 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(12, 35, 64, 0.3);
}
button:hover { 
    transform: translateY(-2px); 
    box-shadow: 0 8px 25px rgba(12, 35, 64, 0.4); 
}
button:active {
    transform: translateY(1px);
}

/* Form Elements */
.form-group { margin-bottom: 1.5rem; text-align: left; }
.form-group label { display: block; margin-bottom: 0.6rem; color: var(--text-main); font-size: 0.9rem; font-weight: 600; }

/* Status Badges */
.badge {
    padding: 0.35rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-pending { background: #fffbeb; color: #d97706; border: 1px solid #fde68a; }
.badge-approved { background: #ecfdf5; color: #059669; border: 1px solid #a7f3d0; }

.btn-action {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1rem;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    background: #f1f5f9;
    color: #000000;
    font-weight: 600;
}
.btn-edit { color: var(--primary); }
.btn-edit:hover { background: var(--primary); color: white; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.btn-delete { color: #ef4444; }
.btn-delete:hover { background: #ef4444; color: white; transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* Professional Badges */
.badge-role {
    font-weight: 700;
    font-size: 0.7rem;
    padding: 0.3rem 0.8rem;
    border-radius: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.role-admin { background: #e0f2fe; color: #0284c7; }
.role-hod { background: #fef3c7; color: #b45309; }
.role-gm { background: #fae8ff; color: #a21caf; }
.role-staff { background: #f1f5f9; color: #475569; }

.badge-status {
    font-weight: 600;
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
    border: 1px solid rgba(0,0,0,0.05);
}

.dept-tag {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1rem;
}

/* Portal Side-by-Side Layout Overlay */
.portal-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    margin: 0 auto;
    max-width: 1400px;
    align-items: flex-start;
}
.portal-left, .portal-right {
    display: flex;
    flex-direction: column;
}
.portal-container .card {
    width: 100%;
    margin: 0 0 1.5rem 0;
}

/* Updated Action Grid for Side-by-Side */
.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
}
.action-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.25rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}
.action-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--primary), #8b5cf6);
    opacity: 0;
    transition: opacity 0.3s;
}
.action-card i {
    font-size: 2.8rem;
    color: var(--primary);
    transition: transform 0.4s;
}
.action-card h4 {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
    line-height: 1.3;
}
.action-card:hover {
    transform: translateY(-8px);
    border-color: transparent;
    box-shadow: var(--shadow-float);
}
.action-card:hover::before { opacity: 1; }
.action-card:hover i { transform: scale(1.1); }

.section-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.5px;
}
.section-title i { color: var(--primary); }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); filter: blur(4px); } to { opacity: 1; transform: translateY(0); filter: blur(0); } }
.animate-in { animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Modal System */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}
.modal-card {
    background: var(--bg-card);
    padding: 3rem;
    border-radius: 28px;
    width: 450px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    border: 1px solid var(--border-light);
    transform: scale(0.95);
    animation: modalPop 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
@keyframes modalPop { to { transform: scale(1); } }

.modal-actions { display: flex; gap: 1rem; margin-top: 2rem; }
.modal-actions button { flex: 1; padding: 0.9rem; font-size: 0.95rem; border-radius: 12px; }
#modal-cancel { background: #f1f5f9; color: var(--text-main); box-shadow: none; }
#modal-cancel:hover { background: #e2e8f0; transform: none; box-shadow: none; }

/* Wide Selection Modals */
.modal-card.modal-wide {
    width: 900px;
    padding: 0;
    overflow: hidden;
    border: 1px solid var(--border);
}
.modal-wide-header {
    background: #f8fafc;
    color: var(--text-main);
    padding: 1.25rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border);
}
.modal-wide-body { padding: 0; max-height: 600px; overflow-y: auto; }

/* Tables */
.erp-select-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 0.9rem;
}
.erp-select-table th {
    background: #f8fafc;
    border-bottom: 2px solid var(--border);
    padding: 0.75rem 1.5rem;
    text-align: left;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 10;
}
.erp-select-table td {
    padding: 0.75rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-main);
    vertical-align: middle;
}
.erp-select-table tr { transition: background 0.2s; }
.erp-select-table tr:hover { background: #f1f5f9; }
.erp-select-table tr:last-child td { border-bottom: none; }

.filter-row input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.85rem;
    outline: none;
}
.filter-row input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-glow); }

.pagination-footer {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: #ffffff;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
    color: var(--text-muted);
}

.status-dot-green {
    width: 8px; height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

/* ERP Style Forms */
.erp-card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.01);
    overflow: hidden;
    transition: all 0.3s ease;
}
.erp-card:hover { 
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04); 
    transform: translateY(-2px);
}

.erp-header {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #ffffff;
    padding: 1rem 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px 16px 0 0;
    letter-spacing: 0.3px;
}
.erp-header i { 
    color: #38bdf8; 
    font-size: 1.3rem; 
    filter: drop-shadow(0 2px 4px rgba(56,189,248,0.4));
}
.erp-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    background: #fafafa;
}
.erp-row {
    display: grid;
    grid-template-columns: 150px 1fr;
    align-items: center;
    gap: 1.5rem;
}
.erp-row label {
    font-size: 0.75rem;
    font-weight: 800;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.erp-input-group {
    display: flex;
    align-items: center;
    gap: 0;
    width: 100%;
}
.erp-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 120px;
    flex-shrink: 0;
}
.erp-search-wrapper input {
    border-radius: 10px 0 0 10px !important;
    border-right: none !important;
}
.erp-name-field {
    flex: 1;
    border-radius: 0 10px 10px 0 !important;
    background: #f8fafc !important;
    border-left: 1px solid var(--border) !important;
}
.erp-full-input {
    padding: 0.85rem 1.1rem;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    font-size: 0.95rem;
    width: 100%;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    background: #ffffff;
    color: #0f172a;
    font-weight: 500;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
.erp-full-input:hover {
    border-color: #cbd5e1;
}
.erp-full-input:focus {
    border-color: var(--primary);
    background: #ffffff;
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15), inset 0 1px 2px rgba(0,0,0,0.01);
    transform: translateY(-1px);
}
/* Distinct placeholder styling */
.erp-full-input::placeholder {
    color: #94a3b8;
    font-style: italic;
    font-weight: 400;
    opacity: 1;
}
input::placeholder, textarea::placeholder {
    color: #94a3b8;
    font-style: italic;
    opacity: 1;
}
.erp-search-wrapper i {
    position: absolute;
    right: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: color 0.2s;
}
.erp-search-wrapper i:hover { color: var(--primary); }

/* Toolbar for forms */
.form-toolbar {
    display: flex;
    gap: 0.75rem;
    padding: 0;
    margin-bottom: 0;
}
.btn-tool {
    background: #ffffff;
    border: 1px solid var(--border);
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    width: auto;
}
.btn-tool:hover { 
    background: var(--bg-dark); 
    border-color: #cbd5e1; 
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn-tool i { font-size: 1rem; }

/* ERP Data Table Menu */
.erp-col-trigger { color: var(--text-muted); transition: color 0.2s; }
.erp-col-trigger:hover { color: var(--primary); }

#erp-column-menu { border-radius: 12px; overflow: visible; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }

.menu-item {
    padding: 0.75rem 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
    border-bottom: 1px solid var(--border-light);
    font-size: 0.9rem;
    font-weight: 500;
}
.menu-item:last-child { border-bottom: none; }
.menu-item:hover { background: var(--bg-dark); color: var(--primary); }

.menu-parent { position: relative; }
.menu-submenu {
    display: none;
    position: absolute;
    left: 100%;
    top: -1px;
    background: white;
    border: 1px solid var(--border);
    min-width: 200px;
    box-shadow: var(--shadow-lg);
    border-radius: 12px;
    z-index: 2001;
}
.menu-parent:hover > .menu-submenu { display: block; }

.col-toggle-item {
    padding: 0.6rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.85rem;
}
.col-toggle-item:hover { background: var(--bg-dark); }
.col-toggle-item input { margin-bottom: 0; width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }

#menu-filter-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* Grid Form Layout */
.form-group-erp {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.form-group-erp label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.form-group-erp .erp-full-input {
    height: 42px;
    font-size: 0.95rem;
    padding: 0 1rem;
}
.form-group-erp select.erp-full-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='C19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.25em;
    padding-right: 2.5rem;
}

/* AI Assistant */
.ai-container {
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2.5rem;
    height: calc(100vh - 140px);
}

.ai-chat-card {
    background: white;
    border-radius: 24px;
    border: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.ai-chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    background: #f8fafc;
}

.ai-chat-body {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    background: #ffffff;
}

.ai-message {
    max-width: 85%;
    padding: 1.25rem 1.5rem;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
    box-shadow: var(--shadow-sm);
}

.ai-message.assistant {
    align-self: flex-start;
    background: #f8fafc;
    border: 1px solid var(--border-light);
    color: var(--text-main);
    border-bottom-left-radius: 6px;
}

.ai-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--primary) 0%, #1e1b4b 100%);
    color: white;
    border-bottom-right-radius: 6px;
    box-shadow: 0 4px 15px rgba(12, 35, 64, 0.2);
}

.ai-chat-footer {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 1rem;
    align-items: center;
    background: #f8fafc;
}

.ai-input-wrapper {
    flex: 1;
    position: relative;
}

.ai-input-wrapper input {
    margin-bottom: 0;
    padding-right: 7rem;
    border-radius: 20px;
    height: 54px;
    border: 1px solid #cbd5e1;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.ai-send-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    height: 38px !important;
    padding: 0 1.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
    margin: 0;
}

.ai-sidebar-card {
    background: white;
    border-radius: 24px;
    border: 1px solid var(--border);
    padding: 1.75rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

.ai-sidebar-card h4 {
    margin-bottom: 1.25rem;
    font-size: 1.05rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-main);
}

.quick-question-item {
    padding: 0.85rem 1rem;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--secondary);
    margin-bottom: 0.75rem;
}
.quick-question-item:hover {
    border-color: var(--primary);
    background: var(--primary-glow);
    color: var(--primary);
    transform: translateX(4px);
}

.insight-item {
    padding: 0.75rem 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-light);
}
.insight-item:last-child { border-bottom: none; }
.insight-item i { color: #10b981; margin-top: 4px; }

.ai-typing {
    display: flex;
    gap: 6px;
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: 20px;
    border-bottom-left-radius: 6px;
    width: fit-content;
    margin-bottom: 1rem;
}
.ai-typing span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }

.ai-message li {
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid rgba(37, 99, 235, 0.1);
    color: var(--primary);
    font-weight: 500;
    list-style-type: none;
}
.ai-message li:hover {
    background: var(--primary);
    color: white;
    transform: translateX(4px);
    box-shadow: var(--shadow-sm);
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-6px); }
}

/* --- OVERLAY FORM LAYOUT --- */
.sidebar-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
    align-items: start;
    align-content: start;
}

.sidebar-layout.form-active {
    grid-template-columns: 1fr;
}

/* Headers and toolbars always span full width */
.sidebar-layout > header,
.sidebar-layout > .form-toolbar {
    grid-column: 1 / -1;
}

/* Table card — full width by default */
.sidebar-layout > .erp-card:nth-of-type(1) {
    grid-column: 1 / -1;
    margin-top: 0 !important;
}

/* Form card — hidden by default */
.sidebar-layout > .erp-card:nth-of-type(2) {
    display: none;
}

/* Backdrop overlay when form is active */
.sidebar-layout.form-active::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 500;
}

/* Form card — centered modal when active */
.sidebar-layout.form-active > .erp-card:nth-of-type(2) {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 660px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 501;
    margin-top: 0 !important;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.45);
    animation: slideInModal 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInModal {
    from { opacity: 0; transform: translate(-50%, -45%) scale(0.95); }
    to   { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

/* Mobile: handle small screens */
@media (max-width: 768px) {
    .sidebar-layout.form-active > .erp-card:nth-of-type(2) {
        width: 95vw;
        height: 95vh;
        max-height: 95vh;
        border-radius: 12px;
    }
}
