@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
    --bg: #060b16;
    --bg2: #0c1222;
    --card: #111a2e;
    --input: #162037;
    --hover: #1a2845;
    --active: #1a3a5c;
    --brd: #1a2744;
    --brdL: #243860;
    --acc: #2196F3;
    --accL: #42a5f5;
    --accD: #1565C0;
    --glow: rgba(33, 150, 243, 0.25);
    --txt: #e4eaf4;
    --mut: #8195b8;
    --dim: #4d6382;
    --ok: #10b981;
    --warn: #f59e0b;
    --err: #ef4444;
    --w: #ffffff;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg);
    color: var(--txt);
    -webkit-font-smoothing: antialiased;
}
input, select, textarea { font-family: 'Outfit', sans-serif; }
::selection { background: var(--acc); color: white; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: 'JetBrains Mono', monospace; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--brdL); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--acc); }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}
@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}
.fi { animation: fadeIn 0.25s ease-out; }
.sl { animation: slideInLeft 0.2s ease-out; }

/* Loading screen */
#loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    flex-direction: column;
    gap: 16px;
    color: var(--mut);
}
#loading .spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--brd);
    border-top-color: var(--acc);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
    background: var(--bg);
}

/* Sidebar */
.sidebar {
    background: var(--card);
    border-right: 1px solid var(--brd);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease;
    overflow: hidden;
    flex-shrink: 0;
}
.sidebar.collapsed { width: 52px; }
.sidebar.expanded { width: 220px; }

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--brd);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 56px;
}

.sidebar-nav {
    flex: 1;
    padding: 8px 6px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
}

.nav-divider {
    padding: 10px 8px 4px;
    font-size: 9px;
    color: var(--dim);
    text-transform: uppercase;
    letter-spacing: 1.2px;
    font-weight: 600;
}
.sidebar.collapsed .nav-divider {
    padding: 6px 0;
}
.nav-divider-line {
    height: 1px;
    background: var(--brd);
    margin: 0 6px;
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 7px;
    border: none;
    cursor: pointer;
    width: 100%;
    text-align: left;
    background: transparent;
    color: var(--mut);
    font-size: 12px;
    font-family: 'Outfit', sans-serif;
    font-weight: 400;
    transition: all 0.15s;
    border-left: 2px solid transparent;
}
.nav-btn:hover { background: var(--hover); }
.nav-btn.active {
    background: var(--active);
    color: var(--acc);
    font-weight: 600;
    border-left-color: var(--acc);
}
.sidebar.collapsed .nav-btn {
    justify-content: center;
    padding: 8px;
}

.sidebar-footer {
    padding: 10px 12px;
    border-top: 1px solid var(--brd);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Main */
.main-content { flex: 1; overflow: auto; }
.main-header {
    padding: 10px 24px;
    border-bottom: 1px solid var(--brd);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card);
    position: sticky;
    top: 0;
    z-index: 10;
}
.main-body { padding: 24px; }

/* Login */
.login-bg {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(ellipse at 20% 30%, rgba(33,150,243,0.06), transparent 60%), var(--bg);
}
.login-card {
    width: 100%;
    max-width: 400px;
    padding: 36px;
    background: var(--card);
    border-radius: 20px;
    border: 1px solid var(--brd);
    box-shadow: 0 8px 48px rgba(0,0,0,0.5), 0 0 60px var(--glow);
}

/* Status dot */
.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.online { background: var(--ok); }

/* Responsive */
@media (max-width: 768px) {
    body { overflow-x: hidden !important; }
    .app-layout { overflow-x: hidden !important; }
    .sidebar.expanded { width: 180px; }
    .main-body { padding: 10px !important; overflow-x: hidden !important; }
    .main-header { padding: 8px 12px !important; }
    .main-content { overflow-x: hidden !important; }
    h2 { font-size: 17px !important; }
    
    /* Stack all grids */
    .crm-detail-grid { grid-template-columns: 1fr !important; }
    .crm-map-grid { grid-template-columns: 1fr !important; }
    .doc-grid { grid-template-columns: 1fr !important; }
    .stats-grid { grid-template-columns: 1fr !important; }
    .file-grid { grid-template-columns: 1fr !important; }
    
    /* Prevent overflow */
    * { max-width: 100vw; box-sizing: border-box; }
    table, pre, code { overflow-x: auto; max-width: 100%; }
    img { max-width: 100%; height: auto; }
    input, select, textarea, button { max-width: 100%; }
}
@media (max-width: 500px) {
    .main-body { padding: 6px !important; }
    h2 { font-size: 15px !important; }
}
