/* ────────────────────────────────────────────────────────
   ImpireX Agents — Global styles
   ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --brand:         #6366f1;
    --brand-dark:    #4f46e5;
    --brand-light:   #e0e7ff;
    --surface:       #ffffff;
    --surface-2:     #f8fafc;
    --surface-3:     #f1f5f9;
    --border:        #e2e8f0;
    --text:          #0f172a;
    --text-2:        #475569;
    --text-3:        #94a3b8;
    --danger:        #ef4444;
    --danger-light:  #fef2f2;
    --green:         #22c55e;
    --green-light:   #f0fdf4;
    --purple:        #a855f7;
    --purple-light:  #faf5ff;
    --sidebar-w:     240px;
    --topbar-h:      60px;
    --radius:        10px;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow:        0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -1px rgba(0,0,0,.04);
    --shadow-lg:     0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -2px rgba(0,0,0,.04);
}

html, body { height: 100%; font-family: 'Inter', system-ui, sans-serif; font-size: 15px; line-height: 1.5; color: var(--text); }

/* ── Login page ──────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #2563eb 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 420px;
}

.login-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,.08);
    overflow: hidden;
}

.login-header {
    text-align: center;
    padding: 36px 32px 28px;
    background: linear-gradient(180deg, #f8f7ff 0%, var(--surface) 100%);
    border-bottom: 1px solid var(--border);
}

.login-logo {
    width: 56px;
    height: 56px;
    background: var(--brand);
    border-radius: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
    box-shadow: 0 4px 14px rgba(99,102,241,.4);
}
.login-logo svg { width: 28px; height: 28px; color: #fff; }

.login-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -.3px;
}
.login-subtitle {
    font-size: .85rem;
    color: var(--text-3);
    margin-top: 2px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.login-form {
    padding: 28px 32px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .04em;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 12px;
    width: 16px;
    height: 16px;
    color: var(--text-3);
    pointer-events: none;
    flex-shrink: 0;
}

.form-input {
    width: 100%;
    height: 42px;
    padding: 0 40px 0 38px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    color: var(--text);
    background: var(--surface-2);
    transition: border-color .15s, box-shadow .15s, background .15s;
    outline: none;
    font-family: inherit;
}
.form-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(99,102,241,.15);
    background: var(--surface);
}
.form-input::placeholder { color: var(--text-3); }

.toggle-password {
    position: absolute;
    right: 10px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-3);
    padding: 4px;
    display: flex;
    align-items: center;
}
.toggle-password svg { width: 16px; height: 16px; }
.toggle-password:hover { color: var(--text-2); }

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}
.check-input {
    width: 16px;
    height: 16px;
    accent-color: var(--brand);
    cursor: pointer;
    border-radius: 4px;
    flex-shrink: 0;
}
.check-label {
    font-size: .85rem;
    color: var(--text-2);
    cursor: pointer;
    user-select: none;
}

.field-error {
    font-size: .78rem;
    color: var(--danger);
    font-weight: 500;
}

.alert {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: .85rem;
    font-weight: 500;
}
.alert:empty { display: none; }
.alert-error {
    background: var(--danger-light);
    color: var(--danger);
    border: 1px solid #fecaca;
}

.btn-login {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 44px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-size: .92rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s, transform .1s, box-shadow .15s;
    font-family: inherit;
    box-shadow: 0 2px 8px rgba(99,102,241,.35);
    margin-top: 4px;
}
.btn-login svg { width: 16px; height: 16px; }
.btn-login:hover { background: var(--brand-dark); box-shadow: 0 4px 12px rgba(99,102,241,.4); }
.btn-login:active { transform: translateY(1px); }

.login-footer {
    text-align: center;
    padding: 14px 32px 20px;
    font-size: .78rem;
    color: var(--text-3);
    border-top: 1px solid var(--border);
}

/* ── App layout (sidebar + content) ─────────────────── */
.app-body {
    display: flex;
    min-height: 100vh;
    background: var(--surface-2);
}

.sidebar {
    width: var(--sidebar-w);
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 20px;
    height: var(--topbar-h);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.brand-icon { width: 22px; height: 22px; color: var(--brand); }
.brand-name { font-size: 1rem; font-weight: 700; color: var(--text); }
.brand-sub {
    font-size: .7rem;
    font-weight: 600;
    color: var(--brand);
    background: var(--brand-light);
    padding: 1px 6px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-section-label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .07em;
    padding: 0 8px;
    margin-bottom: 6px;
    margin-top: 8px;
}
.nav-section-label:first-child { margin-top: 0; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 8px;
    color: var(--text-2);
    text-decoration: none;
    font-size: .875rem;
    font-weight: 500;
    transition: background .12s, color .12s;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item:hover { background: var(--surface-3); color: var(--text); }
.nav-item.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }

.sidebar-footer {
    padding: 12px 14px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}
.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--brand);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    font-weight: 700;
    flex-shrink: 0;
}
.user-details { min-width: 0; }
.user-name { font-size: .82rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: .72rem; color: var(--text-3); }

.logout-btn {
    width: 30px;
    height: 30px;
    border-radius: 7px;
    background: none;
    border: 1px solid var(--border);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    transition: background .12s, color .12s, border-color .12s;
    flex-shrink: 0;
}
.logout-btn svg { width: 14px; height: 14px; }
.logout-btn:hover { background: var(--danger-light); color: var(--danger); border-color: #fecaca; }

.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.top-bar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: var(--shadow-sm);
}

.page-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.content-area {
    flex: 1;
    padding: 28px;
}

/* ── Dashboard ───────────────────────────────────────── */
.dashboard-welcome { display: flex; flex-direction: column; gap: 24px; }

.welcome-card {
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-radius: var(--radius);
    padding: 28px 32px;
    color: #fff;
    box-shadow: var(--shadow-lg);
}
.welcome-card .welcome-icon {
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,.2);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}
.welcome-card .welcome-icon svg { width: 24px; height: 24px; color: #fff; }
.welcome-card h2 { font-size: 1.25rem; font-weight: 700; margin-bottom: 6px; }
.welcome-card p { opacity: .85; font-size: .9rem; }
.welcome-time { margin-top: 10px; opacity: .7; font-size: .82rem; }

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

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .15s;
}
.stat-card:hover { box-shadow: var(--shadow); }

.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stat-icon svg { width: 20px; height: 20px; }
.stat-icon--blue  { background: #eff6ff; color: #3b82f6; }
.stat-icon--green { background: var(--green-light); color: var(--green); }
.stat-icon--purple{ background: var(--purple-light); color: var(--purple); }

.stat-body { min-width: 0; }
.stat-label { font-size: .78rem; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .05em; }
.stat-value { font-size: 1.5rem; font-weight: 700; color: var(--text); margin-top: 2px; }
