/* ============================================================
   MarketingOS — Dark Professional Design System
   Inspired by Linear, Vercel, Raycast dashboards
   ============================================================ */

/* === CSS Variables === */
:root {
    /* Surface colors */
    --bg-root: #09090b;
    --bg-surface: #111113;
    --bg-card: #18181b;
    --bg-elevated: #1f1f23;
    --bg-hover: #27272a;
    --bg-input: #0f0f12;

    /* Borders */
    --border: #27272a;
    --border-light: #1e1e22;
    --border-focus: #3b82f6;

    /* Text */
    --text-primary: #fafafa;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-heading: #f4f4f5;
    --text-inverse: #09090b;

    /* Accent colors */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.12);
    --primary-text: #60a5fa;

    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --success-text: #4ade80;

    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --warning-text: #fbbf24;

    --danger: #ef4444;
    --danger-bg: rgba(239, 68, 68, 0.1);
    --danger-text: #f87171;

    --info: #6366f1;
    --info-bg: rgba(99, 102, 241, 0.1);
    --info-text: #818cf8;

    /* Layout */
    --sidebar-width: 260px;
    --header-height: 56px;
    --radius: 8px;
    --radius-sm: 6px;
    --radius-lg: 12px;

    /* Transitions */
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 250ms cubic-bezier(0.4, 0, 0.2, 1);

    /* Shadows (subtle for dark mode) */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* === Light Theme === */
[data-theme="light"] {
    /* Surface colors */
    --bg-root: #f8f9fb;
    --bg-surface: #ffffff;
    --bg-card: #ffffff;
    --bg-elevated: #f3f4f6;
    --bg-hover: #f0f1f3;
    --bg-input: #ffffff;

    /* Borders */
    --border: #e2e4e9;
    --border-light: #eef0f3;
    --border-focus: #3b82f6;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --text-heading: #0f172a;
    --text-inverse: #ffffff;

    /* Accent colors (same hues, tweaked for light bg) */
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.08);
    --primary-text: #2563eb;

    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.08);
    --success-text: #15803d;

    --warning: #d97706;
    --warning-bg: rgba(217, 119, 6, 0.08);
    --warning-text: #b45309;

    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --danger-text: #b91c1c;

    --info: #4f46e5;
    --info-bg: rgba(79, 70, 229, 0.08);
    --info-text: #4338ca;

    /* Shadows for light mode */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.12);
}

/* Light theme select dropdown arrow */
[data-theme="light"] select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%234b5563' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 6.146a.5.5 0 0 1 .708 0L8 8.793l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
}

[data-theme="light"] select option {
    background: #fff;
    color: #111827;
}

[data-theme="light"] ::selection {
    background: rgba(59, 130, 246, 0.2);
    color: #111827;
}

[data-theme="light"] .card,
[data-theme="light"] .stat-card {
    box-shadow: var(--shadow-sm);
}

[data-theme="light"] .sidebar {
    box-shadow: 1px 0 0 var(--border);
}

/* Light-mode alerts */
[data-theme="light"] .alert-success {
    background: #ecfdf5;
    color: #166534;
    border-color: #a7f3d0;
}
[data-theme="light"] .alert-error,
[data-theme="light"] .alert-danger {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
[data-theme="light"] .alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
}
[data-theme="light"] .alert-info {
    background: #eef2ff;
    color: #3730a3;
    border-color: #c7d2fe;
}

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-root);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

a { color: var(--primary-text); text-decoration: none; }
a:hover { color: var(--primary); }

img { max-width: 100%; display: block; }
hr { border: none; border-top: 1px solid var(--border); margin: 1.5rem 0; }

::selection {
    background: rgba(59, 130, 246, 0.3);
    color: var(--text-primary);
}

/* === Login Page === */
.login-page {
    background: var(--bg-root);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
}

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

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.5rem 2rem;
}

.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.login-logo h1 span {
    color: var(--primary);
}

.login-logo p {
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-top: 0.35rem;
}

/* === Password Field with Eye Toggle === */
.password-field { position: relative; }
.password-field .form-input { padding-right: 2.8rem; }
.password-toggle { position: absolute; right: 0; top: 0; bottom: 0; width: 2.8rem; display: flex; align-items: center; justify-content: center; background: none; border: none; color: var(--text-muted); cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0; }
.password-toggle:hover { color: var(--text-primary); }
.password-toggle i, .password-toggle svg { width: 18px; height: 18px; }

/* === Developer Info Trigger === */
.dev-info-trigger { position: fixed; bottom: 1.25rem; right: 1.25rem; width: 40px; height: 40px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,0.15); transition: all 200ms; z-index: 10; }
.dev-info-trigger:hover { color: var(--primary); border-color: var(--primary); transform: scale(1.08); }
.dev-info-trigger i, .dev-info-trigger svg { width: 18px; height: 18px; }

/* === Modal === */
.modal-overlay { display: none; position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,0.45); backdrop-filter: blur(4px); align-items: center; justify-content: center; padding: 1.5rem; }
.modal-overlay.open { display: flex; }
.modal-card { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg); width: 100%; max-width: 380px; box-shadow: 0 16px 48px rgba(0,0,0,0.25); animation: fadeIn 200ms ease-out; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 0.95rem; font-weight: 700; color: var(--text-heading); }
.modal-body { padding: 1.5rem 1.25rem; }

/* === Dev Social Links === */
.dev-links { display: flex; flex-direction: column; gap: 6px; }
.dev-link-item { display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 0.82rem; color: var(--text-secondary); text-decoration: none; border-radius: 8px; transition: all 150ms; }
.dev-link-item:hover { background: var(--bg-hover); color: var(--text-heading); }

/* === Forms === */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.4rem;
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
input[type="tel"],
input[type="number"],
input[type="date"],
input[type="search"],
textarea,
select {
    width: 100%;
    padding: 0.55rem 0.75rem;
    font-size: 0.87rem;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus, textarea:focus, select:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

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

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%2371717a' viewBox='0 0 16 16'%3E%3Cpath d='M4.646 6.146a.5.5 0 0 1 .708 0L8 8.793l2.646-2.647a.5.5 0 0 1 .708.708l-3 3a.5.5 0 0 1-.708 0l-3-3a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2rem;
}

select option {
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger-text);
    margin-top: 0.3rem;
}

.section-divider {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.5rem 0;
}

.form-section-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-heading);
    margin-bottom: 1rem;
}

/* === Buttons === */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-size: 0.82rem;
    font-weight: 500;
    font-family: inherit;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1.4;
    text-decoration: none;
}

.btn svg, .btn i { width: 15px; height: 15px; flex-shrink: 0; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: #fff;
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}
.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    color: #fff;
}

.btn-sm {
    padding: 0.35rem 0.7rem;
    font-size: 0.78rem;
}
.btn-sm svg, .btn-sm i { width: 13px; height: 13px; }

.btn-full {
    width: 100%;
    padding: 0.6rem;
}

.btn-icon {
    padding: 0.35rem;
    min-width: 0;
}

.btn-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

/* === Sidebar === */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform var(--transition-slow);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1.25rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
}

.mos-wordmark {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.05em;
    line-height: 1;
    margin: 0;
}

.mos-wordmark span {
    background: linear-gradient(135deg, var(--primary), #a855f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
}

.sidebar-brand-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand-icon i, .sidebar-brand-icon svg {
    width: 16px;
    height: 16px;
}

.sidebar-brand h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-brand h2 span {
    color: var(--primary);
}

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
    list-style: none;
}

.sidebar-nav::-webkit-scrollbar {
    width: 3px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 8px;
}

.nav-section {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    padding: 1.25rem 1.25rem 0.4rem;
    list-style: none;
}

.sidebar-nav li { list-style: none; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 1.25rem;
    font-size: 0.84rem;
    font-weight: 450;
    color: var(--text-secondary);
    border-radius: 0;
    transition: all var(--transition);
    text-decoration: none;
    position: relative;
}

.sidebar-nav a:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.sidebar-nav a.active {
    color: var(--text-primary);
    background: var(--bg-elevated);
}

.sidebar-nav a.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 2px;
    height: 60%;
    background: var(--primary);
    border-radius: 0 2px 2px 0;
}

.nav-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-icon i, .nav-icon svg {
    width: 18px;
    height: 18px;
}

/* Nav badge (unread count) */
.nav-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    border-radius: 100px;
    margin-left: auto;
    line-height: 1;
}

/* Mobile nav badge */
.mobile-nav-badge {
    position: absolute;
    top: 2px;
    right: 50%;
    transform: translateX(calc(50% + 10px));
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 0.6rem;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    border-radius: 100px;
    line-height: 16px;
    text-align: center;
}

/* Sidebar Footer — see User Menu Popup section */

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 600;
    flex-shrink: 0;
}

.user-info { min-width: 0; }

.user-name {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* Sidebar overlay (mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* === Main Content === */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-left h1 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-heading);
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-role {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 0.2rem 0.65rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 100px;
    text-transform: capitalize;
}

/* Header company avatar */
.header-company-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    overflow: hidden;
    border: 1.5px solid var(--border);
    background: var(--bg-elevated);
    text-decoration: none;
    color: var(--text-heading);
    font-size: 0.75rem;
    font-weight: 700;
    transition: all var(--transition);
    flex-shrink: 0;
}

.header-company-avatar:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.header-company-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mobile-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem;
}

.mobile-toggle i, .mobile-toggle svg {
    width: 20px;
    height: 20px;
}

/* Content area */
.content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
}

/* === Alerts (Toast Notifications) === */
.alert-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 380px;
    width: calc(100% - 2rem);
    pointer-events: none;
}

.alert {
    padding: 0.65rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    border: 1px solid transparent;
    transition: opacity 300ms, transform 300ms;
    pointer-events: auto;
    box-shadow: var(--shadow-lg);
    animation: alertSlideIn 300ms ease-out;
}

@keyframes alertSlideIn {
    from { opacity: 0; transform: translateX(40px); }
    to { opacity: 1; transform: translateX(0); }
}

.alert-success {
    background: #0a2614;
    color: var(--success-text);
    border-color: #163d24;
}

.alert-error, .alert-danger {
    background: #2a0f0f;
    color: var(--danger-text);
    border-color: #3d1616;
}

.alert-warning {
    background: #2a1f06;
    color: var(--warning-text);
    border-color: #3d2d0c;
}

.alert-info {
    background: #111230;
    color: var(--info-text);
    border-color: #1c1e45;
}

/* === Cards === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}

.card-body {
    padding: 1.15rem;
}

.card-body.no-pad,
.card-body.no-padding {
    padding: 0;
}

/* === Stats Grid === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
}

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon i, .stat-icon svg { width: 18px; height: 18px; }

.stat-icon.purple  { background: var(--info-bg); color: var(--info-text); }
.stat-icon.blue    { background: var(--primary-glow); color: var(--primary-text); }
.stat-icon.teal    { background: rgba(20, 184, 166, 0.1); color: #2dd4bf; }
.stat-icon.green   { background: var(--success-bg); color: var(--success-text); }
.stat-icon.orange  { background: var(--warning-bg); color: var(--warning-text); }
.stat-icon.pink    { background: rgba(236, 72, 153, 0.1); color: #f472b6; }

.stat-info { min-width: 0; }

.stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    line-height: 1.3;
}

.stat-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* === Dashboard Grid === */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.dashboard-grid .full-width {
    grid-column: 1 / -1;
}

/* === Page Header === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 0.75rem;
}

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

.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 0.75rem;
}

/* === Task Items === */
.task-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--bg-elevated); }

.task-item-avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.task-item-content {
    flex: 1;
    min-width: 0;
}

.task-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-item-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-item-meta {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.task-item-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* === List Items === */
.list-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.7rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--bg-elevated); }

.list-item-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.list-item-content { flex: 1; min-width: 0; }

.list-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === Status Badges === */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    font-size: 0.7rem;
    font-weight: 500;
    border-radius: 100px;
    white-space: nowrap;
    letter-spacing: 0.01em;
}

.status-badge.todo       { background: var(--info-bg); color: var(--info-text); }
.status-badge.in_progress { background: var(--warning-bg); color: var(--warning-text); }
.status-badge.review      { background: rgba(168, 85, 247, 0.1); color: #c084fc; }
.status-badge.done        { background: var(--success-bg); color: var(--success-text); }

/* Status dot inline */
.status {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 500;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-active  .status-dot { background: var(--success); }
.status-pending .status-dot { background: var(--warning); }
.status-inactive .status-dot { background: var(--text-muted); }

.status-active  { color: var(--success-text); }
.status-pending { color: var(--warning-text); }
.status-inactive { color: var(--text-muted); }

/* === Progress Bar === */
.progress-bar {
    height: 6px;
    background: var(--bg-hover);
    border-radius: 100px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 100px;
    transition: width 500ms ease;
    min-width: 2px;
}

/* === Filters === */
.filters {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filter-chip {
    padding: 0.3rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 100px;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
}

.filter-chip:hover {
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: var(--border);
}

.filter-chip.active {
    color: var(--text-primary);
    background: var(--bg-elevated);
    border-color: var(--primary);
}

/* View Toggle */
.view-toggle {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    color: var(--text-muted);
    text-decoration: none;
    transition: all var(--transition);
    border-right: 1px solid var(--border);
}

.view-toggle-btn:last-child {
    border-right: none;
}

.view-toggle-btn:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.view-toggle-btn.active {
    background: var(--bg-elevated);
    color: var(--primary);
}

/* === Tables === */
.table-wrapper {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.data-table thead th {
    padding: 0.65rem 1.15rem;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    background: var(--bg-elevated);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 0.65rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg-elevated); }

/* === Task Detail === */
.task-detail-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 1rem;
    align-items: start;
}

.detail-field {
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-field:last-child { border-bottom: none; }

.detail-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.3rem;
}

.detail-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

/* === Comments === */
.comment {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border-light);
}

.comment:last-of-type { border-bottom: none; }

.comment-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    flex-shrink: 0;
}

.comment-content { flex: 1; min-width: 0; }

.comment-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
}

.comment-author {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
}

.comment-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.comment-text {
    font-size: 0.84rem;
    color: var(--text-secondary);
    line-height: 1.55;
}

/* === Credentials / Vault === */
.credentials-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
}

.credential-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
}

.credential-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.85rem;
}

.credential-name {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
}

.credential-name-icon {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--primary-glow);
    color: var(--primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

.credential-name-icon i, .credential-name-icon svg { width: 14px; height: 14px; }

.credential-actions {
    display: flex;
    gap: 0.2rem;
}

.credential-field {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0;
}

.credential-field-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    width: 48px;
    flex-shrink: 0;
}

.credential-field-value {
    font-size: 0.84rem;
    color: var(--text-primary);
    font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.secret-masked {
    color: var(--text-muted);
    letter-spacing: 0.15em;
}

.btn-reveal {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--primary-text);
    background: var(--primary-glow);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    padding: 0.2rem 0.55rem;
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.btn-reveal:hover {
    background: rgba(59, 130, 246, 0.2);
}

/* === Messages / Inbox === */
.conversation-list {
    display: flex;
    flex-direction: column;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
    transition: background var(--transition);
    text-decoration: none;
    color: inherit;
}

.conversation-item:last-child { border-bottom: none; }
.conversation-item:hover { background: var(--bg-elevated); }

.conversation-item.unread {
    background: rgba(59, 130, 246, 0.04);
}

.conv-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
    flex-shrink: 0;
}

.conv-info { flex: 1; min-width: 0; }

.conv-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.2rem;
}

.conv-name {
    font-size: 0.84rem;
    font-weight: 500;
    color: var(--text-primary);
}

.conv-role {
    font-size: 0.68rem;
    color: var(--text-muted);
    padding: 0.1rem 0.4rem;
    background: var(--bg-hover);
    border-radius: 100px;
}

.conv-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3rem;
    flex-shrink: 0;
}

.conv-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.conv-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    font-size: 0.65rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border-radius: 100px;
}

/* === Chat === */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    background: var(--bg-root);
    overflow: hidden;
}

.chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chat-partner {
    display: flex;
    align-items: center;
    gap: 0.65rem;
}

.chat-partner-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
}

.chat-partner-role {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-bubble {
    display: flex;
    gap: 0.5rem;
    max-width: 70%;
}

.chat-bubble.mine {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.chat-bubble.theirs {
    align-self: flex-start;
}

.bubble-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    font-weight: 600;
    flex-shrink: 0;
    align-self: flex-end;
}

.bubble-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius) var(--radius) var(--radius) 4px;
    padding: 0.6rem 0.85rem;
    min-width: 60px;
}

.chat-bubble.mine .bubble-content {
    background: var(--primary);
    border-color: var(--primary);
    border-radius: var(--radius) var(--radius) 4px var(--radius);
}

.bubble-text {
    font-size: 0.84rem;
    line-height: 1.5;
    color: var(--text-primary);
    word-break: break-word;
}

.chat-bubble.mine .bubble-text { color: #fff; }
.chat-bubble.mine .bubble-text a { color: rgba(255, 255, 255, 0.85); text-decoration: underline; }

.bubble-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.3rem;
}

.chat-bubble.mine .bubble-time { color: rgba(255, 255, 255, 0.6); }

.bubble-media {
    margin-bottom: 0.4rem;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.bubble-media img { max-width: 280px; max-height: 300px; border-radius: var(--radius-sm); }
.bubble-media video { max-width: 280px; border-radius: var(--radius-sm); }
.bubble-media audio { max-width: 250px; }
.bubble-audio { padding: 0.3rem; }

.bubble-file {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    margin-bottom: 0.3rem;
}

.bubble-file a {
    color: var(--primary-text);
    font-size: 0.82rem;
    font-weight: 500;
}

.chat-bubble.mine .bubble-file { background: rgba(255, 255, 255, 0.15); }
.chat-bubble.mine .bubble-file a { color: #fff; }

.chat-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--text-muted);
}

.chat-empty h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-secondary); }
.chat-empty p { font-size: 0.82rem; }

/* Chat Input */
.chat-input-area {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
    flex-shrink: 0;
}

.chat-input-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-attach-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-attach-btn i, .chat-attach-btn svg { width: 18px; height: 18px; }

.chat-text-input {
    flex: 1;
    padding: 0.55rem 0.85rem;
    font-size: 0.84rem;
    font-family: inherit;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.chat-text-input:focus { border-color: var(--border-focus); }

.chat-send-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background var(--transition);
    flex-shrink: 0;
}

.chat-send-btn:hover { background: var(--primary-hover); }
.chat-send-btn i, .chat-send-btn svg { width: 16px; height: 16px; }

.chat-attachment-preview {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
    padding: 0.4rem 0.65rem;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* === Invite Card / Centered Cards === */
.invite-card {
    max-width: 480px;
    margin: 2rem auto;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem;
    text-align: center;
}

.invite-card h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-heading);
    margin-bottom: 0.5rem;
}

.invite-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.invite-link-box {
    margin-top: 1rem;
}

.invite-url {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.invite-url input[type="text"] {
    flex: 1;
    font-size: 0.78rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
}

/* === Empty States === */
.empty-state {
    padding: 2.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state h3 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.empty-state p {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.empty-state-icon, .empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.85rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-muted);
}

.empty-state-icon i, .empty-state-icon svg,
.empty-icon i, .empty-icon svg {
    width: 22px;
    height: 22px;
}

/* === Profile === */
/* === Company Hero (Company Dashboard) === */
.company-hero {
    display: flex;
    align-items: flex-start;
    gap: 1.25rem;
}
.company-hero-logo {
    width: 72px;
    height: 72px;
    border-radius: var(--radius);
    overflow: hidden;
    flex-shrink: 0;
    border: 2px solid var(--border);
    background: var(--bg-hover);
}
.company-hero-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.company-hero-initial {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-elevated);
}
.company-hero-info {
    min-width: 0;
    flex: 1;
}

@media (max-width: 480px) {
    .company-hero { gap: 0.85rem; }
    .company-hero-logo { width: 56px; height: 56px; }
}

/* === Profile Header === */
.profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.profile-avatar-lg {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--bg-hover);
    border: 2px solid var(--border);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 600;
    flex-shrink: 0;
}

.profile-info h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.role-tag {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--primary-text);
    background: var(--primary-glow);
    padding: 0.15rem 0.55rem;
    border-radius: 100px;
    margin-top: 0.25rem;
}

/* === Detail Meta (Company Detail) === */
.detail-meta {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.meta-label {
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.25rem;
}

.meta-value {
    font-size: 0.85rem;
    color: var(--text-primary);
}

.meta-value a { color: var(--primary-text); }

/* === Message Items (dashboard) === */
.message-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.7rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
}

.message-item:last-child { border-bottom: none; }
.message-item.unread { background: rgba(59, 130, 246, 0.04); }

.msg-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    flex-shrink: 0;
}

.msg-content { flex: 1; min-width: 0; }

.msg-subject {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-preview {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-time {
    font-size: 0.68rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* === Audit Log === */
.audit-log-list {
    padding: 0;
}

.audit-log-item {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1.15rem;
    border-bottom: 1px solid var(--border-light);
}

.audit-log-item:last-child { border-bottom: none; }

.audit-log-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.audit-log-icon.info    { background: var(--info-bg); color: var(--info-text); }
.audit-log-icon.success { background: var(--success-bg); color: var(--success-text); }
.audit-log-icon.warning { background: var(--warning-bg); color: var(--warning-text); }
.audit-log-icon.danger  { background: var(--danger-bg); color: var(--danger-text); }

.audit-log-body {
    flex: 1;
    font-size: 0.84rem;
    color: var(--text-secondary);
}

.audit-log-user { font-weight: 600; color: var(--text-primary); }
.audit-log-action { margin: 0 0.2rem; }

.audit-log-time {
    font-size: 0.72rem;
    color: var(--text-muted);
    flex-shrink: 0;
    white-space: nowrap;
}

/* === Grid Layouts === */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-2 > .card {
    margin-bottom: 0;
}

/* === Utility Classes === */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }

.d-flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.flex-wrap { flex-wrap: wrap; }

.gap-sm { gap: 0.5rem; }
.gap-md { gap: 0.75rem; }

.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }

.no-pad { padding: 0 !important; }

/* === User Menu Popup === */
.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.75rem 1.25rem;
    position: relative;
}

.user-menu-section-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.65rem 0.25rem;
}

.user-menu-item.active-company {
    color: var(--primary-text);
    background: var(--primary-glow);
}

.company-switcher-logo {
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.8rem;
    flex-shrink: 0;
    overflow: hidden;
}
.company-switcher-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.company-switcher-info {
    overflow: hidden;
    min-width: 0;
}
.company-switcher-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-heading);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.company-switcher-label {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.company-switcher-item-logo {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7rem;
    flex-shrink: 0;
    overflow: hidden;
}
.company-switcher-item-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* === Mobile Company Section (in Account Popup) === */
.mobile-company-section {
    margin-bottom: 0.15rem;
}
.mobile-company-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.3rem 0.5rem 0.25rem;
}
.mobile-company-icon {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    background: var(--bg-hover);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.7rem;
    flex-shrink: 0;
    overflow: hidden;
}
.mobile-company-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.mobile-account-link.active-company {
    color: var(--primary-text);
    background: var(--primary-glow);
}

.user-menu-popup {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 0.75rem;
    right: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.35rem;
    box-shadow: var(--shadow-lg);
    z-index: 200;
    animation: popupSlideUp 150ms ease-out;
}

.user-menu-popup.open { display: block; }

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

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    font-size: 0.82rem;
    font-weight: 450;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    text-decoration: none;
    cursor: pointer;
    background: none;
    border: none;
    width: 100%;
    font-family: inherit;
    text-align: left;
}

.user-menu-item:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.user-menu-item.danger { color: var(--danger-text); }
.user-menu-item.danger:hover { background: var(--danger-bg); }

.user-menu-item i, .user-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.user-menu-divider {
    border: none;
    border-top: 1px solid var(--border-light);
    margin: 0.25rem 0;
}

/* === Modern Avatar Upload === */
.avatar-drop-zone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1.5rem;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--bg-input);
    cursor: pointer;
    transition: all var(--transition);
    text-align: center;
    min-height: 120px;
}

.avatar-drop-zone:hover,
.avatar-drop-zone.dragover {
    border-color: var(--primary);
    background: var(--primary-glow);
}

.avatar-drop-zone input[type="file"] {
    display: none;
}

.avatar-upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
}

.avatar-upload-placeholder i,
.avatar-upload-placeholder svg {
    width: 28px;
    height: 28px;
    color: var(--text-muted);
}

.avatar-upload-placeholder .upload-text {
    font-size: 0.82rem;
    font-weight: 500;
}

.avatar-upload-placeholder .upload-hint {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.avatar-preview {
    display: none;
    align-items: center;
    justify-content: center;
}

.avatar-preview img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

/* === Service Progress Cards === */
.service-progress-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.service-progress-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
}

.service-progress-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.service-progress-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-heading);
}

.service-progress-count {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--primary-text);
}

.service-progress-bar {
    height: 8px;
    background: var(--bg-hover);
    border-radius: 100px;
    overflow: hidden;
}

.service-progress-bar-fill {
    height: 100%;
    border-radius: 100px;
    transition: width 500ms ease;
    min-width: 2px;
    background: var(--primary);
}

.service-progress-bar-fill.complete {
    background: var(--success);
}

.service-progress-sub {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 0.45rem;
}

/* === Kanban Board === */
.mobile-task-list { display: none; }

.kanban-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.kanban-column {
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 200px;
    display: flex;
    flex-direction: column;
}

.kanban-column-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 0.85rem;
    border-bottom: 1px solid var(--border);
}

.kanban-column-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.kanban-column-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-heading);
}

.kanban-column-count {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 0.1rem 0.45rem;
    border-radius: 100px;
    margin-left: auto;
}

.kanban-column-body {
    padding: 0.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    overflow-y: auto;
    max-height: 500px;
}

.kanban-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.7rem 0.8rem;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
}

.kanban-card:hover {
    border-color: var(--primary);
    background: var(--bg-elevated);
}

.kanban-card-title {
    font-size: 0.8rem;
    font-weight: 550;
    color: var(--text-heading);
    margin-bottom: 0.4rem;
    line-height: 1.35;
}

.kanban-card-assignee {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-bottom: 0.3rem;
}

.kanban-card-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--bg-hover);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    font-weight: 600;
    flex-shrink: 0;
}

.kanban-card-due {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.68rem;
    color: var(--text-muted);
}

.kanban-card-due.overdue {
    color: var(--danger-text);
}

.kanban-empty {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    padding: 1.5rem 0.5rem;
}

/* === Company Task Grid (superadmin task picker) === */
.company-task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1rem;
}

.company-task-card {
    display: block;
    text-decoration: none;
    color: inherit;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.company-task-card:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.company-task-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.company-task-card-logo {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
}

.company-task-card-logo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.company-task-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.company-task-card-total {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.company-task-card-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
}

.company-task-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
}

.company-task-stat-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.company-task-stat-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.company-task-stat-count {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* === Task Calendar === */
.task-calendar {
    width: 100%;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.calendar-month-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-heading);
    min-width: 120px;
    text-align: center;
}

.cal-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border);
}

.cal-header-cell {
    padding: 0.5rem 0.4rem;
    font-size: 0.68rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 0.03em;
}

.cal-week {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    border-bottom: 1px solid var(--border-light);
}

.cal-week:last-child {
    border-bottom: none;
}

.cal-day {
    min-height: 72px;
    padding: 0.3rem;
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: relative;
    transition: background var(--transition);
}

.cal-day-clickable {
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.cal-day-clickable:hover {
    background: var(--bg-hover);
}

.cal-day:last-child {
    border-right: none;
}

.cal-day-empty {
    background: var(--bg-surface);
    opacity: 0.4;
}

.cal-day-today {
    background: rgba(59, 130, 246, 0.04);
}

.cal-day-today.cal-day-clickable:hover {
    background: rgba(59, 130, 246, 0.08);
}

.cal-day-today .cal-day-number {
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cal-day-number {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 2px;
    padding: 0 0.15rem;
}

/* Dot indicators on day cells */
.cal-day-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    justify-content: center;
    padding-top: 2px;
}

.cal-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    flex-shrink: 0;
}

.cal-dot.todo { background: var(--info-text); }
.cal-dot.in_progress { background: var(--warning-text); }
.cal-dot.review { background: #c084fc; }
.cal-dot.done { background: var(--success-text); }

/* Task count badge on day cells */
.cal-day-task-count {
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 0px 5px;
    border-radius: 100px;
    margin-top: auto;
}

/* === Battery Progress === */
.battery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 0.75rem;
}

.battery-card {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.15rem;
    text-decoration: none;
    color: inherit;
    transition: all var(--transition);
}

.battery-card:hover {
    border-color: var(--primary);
    background: var(--bg-elevated);
}

.battery-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.65rem;
}

.battery-name {
    font-size: 0.88rem;
    font-weight: 650;
    color: var(--text-heading);
}

.battery-fraction {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
}

.battery-outer {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 0.55rem;
}

.battery-body {
    flex: 1;
    height: 28px;
    background: var(--bg-surface);
    border: 2px solid var(--border);
    border-radius: 6px;
    border-top-right-radius: 3px;
    border-bottom-right-radius: 3px;
    overflow: hidden;
    position: relative;
    display: flex;
    align-items: center;
}

.battery-cap {
    width: 6px;
    height: 14px;
    background: var(--border);
    border-radius: 0 3px 3px 0;
    flex-shrink: 0;
}

.battery-fill {
    height: 100%;
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: width 0.6s ease;
    min-width: 0;
}

.battery-fill.low {
    background: var(--danger-text);
}

.battery-fill.mid {
    background: var(--warning-text);
}

.battery-fill.high {
    background: var(--primary);
}

.battery-fill.full {
    background: var(--success-text);
}

.battery-pct {
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.battery-pct.outside {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    text-shadow: none;
    font-size: 0.7rem;
}

.battery-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.battery-stat {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.7rem;
    font-weight: 550;
    color: var(--text-muted);
}

.battery-stat-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}

.battery-stat.done .battery-stat-dot    { background: var(--success-text); }
.battery-stat.review .battery-stat-dot  { background: #c084fc; }
.battery-stat.in-progress .battery-stat-dot { background: var(--warning-text); }
.battery-stat.todo .battery-stat-dot    { background: var(--info-text); }

/* === Responsive === */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .task-detail-grid {
        grid-template-columns: 1fr;
    }

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

    .content {
        padding: 1rem;
    }
}

@media (max-width: 768px) {
    html { font-size: 14px; }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

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

    .detail-meta {
        grid-template-columns: 1fr;
    }

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

    .header {
        padding: 0 1rem;
    }

    /* Hide kanban, show list only on small screens */
    .kanban-board {
        display: none;
    }
    .view-toggle {
        display: none;
    }
    .mobile-task-list {
        display: block;
    }

    .cal-day {
        min-height: 56px;
    }

    .cal-task-chip {
        font-size: 0.58rem;
    }
}

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

    .btn-group {
        flex-direction: column;
        width: 100%;
    }

    .btn-group .btn {
        width: 100%;
    }

    .chat-bubble {
        max-width: 88%;
    }

    .detail-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .kanban-board {
        display: none;
    }

    .cal-header-cell {
        font-size: 0.6rem;
        padding: 0.35rem 0.2rem;
    }

    .cal-day {
        min-height: 44px;
        padding: 0.2rem;
    }

    .cal-day-number {
        font-size: 0.65rem;
    }

    .cal-task-chip {
        font-size: 0.55rem;
    }
}

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

.card { animation: fadeIn 200ms ease-out; }
.stat-card { animation: fadeIn 200ms ease-out; }

/* === Dropdown Menu (3-dot actions) === */
.dropdown { position: relative; display: inline-flex; }
.dropdown-trigger { background: none; border: none; padding: 4px; border-radius: 6px; color: var(--text-muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.dropdown-trigger:hover { background: var(--bg-hover); color: var(--text-heading); }
.dropdown-menu { display: none; position: absolute; right: 0; top: 100%; z-index: 50; min-width: 170px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.18); padding: 6px; }
.dropdown-menu.open { display: block; }
.dropdown-item { display: flex; align-items: center; gap: 8px; padding: 7px 10px; font-size: 0.8rem; color: var(--text-secondary); text-decoration: none; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.dropdown-item:hover { background: var(--bg-hover); color: var(--text-heading); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: rgba(239,68,68,0.08); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; border: none; }

/* === Credential Meta === */
.credential-meta { font-size: 0.72rem; color: var(--text-muted); margin-bottom: 0.35rem; display: flex; align-items: center; gap: 4px; }

/* === Avatar Images (everywhere) === */
.user-avatar img, .profile-avatar-lg img, .bubble-avatar img, .conv-avatar img, .list-item-avatar img, .task-item-avatar img {
    width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block;
}

/* === Vault Access Checkbox Row === */
.vault-access-row { display: flex; align-items: center; gap: 10px; padding: 10px 16px; cursor: pointer; border-bottom: 1px solid var(--border); transition: background 120ms; }
.vault-access-row:last-child { border-bottom: none; }
.vault-access-row:hover { background: var(--bg-hover); }
.vault-access-row input[type="checkbox"] { display: none; }
.vault-access-check { width: 18px; height: 18px; border-radius: 5px; border: 2px solid var(--border); display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 150ms; }
.vault-access-row input[type="checkbox"]:checked + .vault-access-check { background: var(--primary); border-color: var(--primary); }
.vault-access-row input[type="checkbox"]:checked + .vault-access-check::after { content: ''; display: block; width: 5px; height: 9px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg) translate(-1px, -1px); }
.vault-access-name { font-size: 0.85rem; font-weight: 500; color: var(--text-heading); }
.vault-access-count { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }

/* === Vault Folder Grid === */
.vault-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 0.75rem;
}

.vault-folder-card {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem 1.15rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: inherit;
    transition: border-color var(--transition), background var(--transition);
}

.vault-folder-card:hover {
    border-color: var(--primary);
    background: var(--bg-hover);
}

.vault-folder-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: var(--primary-glow);
    color: var(--primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.vault-folder-info {
    flex: 1;
    min-width: 0;
}

.vault-folder-name {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.vault-folder-meta {
    font-size: 0.76rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

.vault-folder-desc {
    font-size: 0.78rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* === Vault Agent Chips === */
.vault-agents-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
    padding: 0.65rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.agent-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.55rem 0.2rem 0.25rem;
    background: var(--bg-hover);
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 500;
    color: var(--text-primary);
}

.agent-chip-avatar {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    object-fit: cover;
}

.agent-chip-initial {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary-glow);
    color: var(--primary-text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 600;
}

/* === Modern File Drop Zone (generic) === */
.file-drop-zone { position: relative; border: 2px dashed var(--border); border-radius: 10px; padding: 1.5rem; text-align: center; cursor: pointer; transition: all 200ms; }
.file-drop-zone:hover, .file-drop-zone.dragover { border-color: var(--primary); background: rgba(124,92,252,0.04); }
.file-drop-zone input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.file-drop-zone .upload-placeholder { display: flex; flex-direction: column; align-items: center; gap: 6px; color: var(--text-muted); }
.file-drop-zone .upload-placeholder i { width: 28px; height: 28px; }
.file-drop-zone .upload-text { font-size: 0.82rem; font-weight: 500; }
.file-drop-zone .upload-hint { font-size: 0.72rem; }
.file-drop-zone .file-preview { display: none; align-items: center; gap: 8px; font-size: 0.82rem; color: var(--text-heading); font-weight: 500; }
.file-drop-zone .file-preview.active { display: flex; }
.file-drop-zone .file-preview.active + .upload-placeholder { display: none; }

/* Hide Django's default ClearableFileInput "Currently / Clear" elements */
.form-group input[type="checkbox"][name$="-clear"],
.form-group label[for$="-clear_id"],
.form-group .clearable-file-input a,
input[type="file"] + input[type="checkbox"],
.form-input[type="file"] ~ br,
.form-group br {
    display: none !important;
}

/* Custom file delete button */
.file-delete-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.35rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--danger-text);
    background: var(--danger-bg);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 0.4rem;
}
.file-delete-btn:hover {
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.file-delete-btn i, .file-delete-btn svg { width: 14px; height: 14px; }

/* Current file info bar (shown above drop zone when file exists) */
.file-current-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
    transition: opacity 200ms;
}
.file-current-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
    min-width: 0;
}
.file-current-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.file-current-bar .file-delete-btn {
    margin-top: 0;
    flex-shrink: 0;
}

/* === Flat List Rows (Companies / Agents) === */
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); gap: 12px; transition: background 120ms; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--bg-hover); }
.list-row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.list-row-title { font-size: 0.88rem; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-row-sub { font-size: 0.75rem; color: var(--text-muted); }

/* === Expandable Rows (legacy) === */
.expand-row { border-bottom: 1px solid var(--border); }
.expand-row:last-child { border-bottom: none; }
.expand-row-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; cursor: pointer; transition: background 120ms; gap: 12px; }
.expand-row-header:hover { background: var(--bg-hover); }
.expand-row-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.expand-row-title { font-size: 0.88rem; font-weight: 600; color: var(--text-heading); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.expand-row-sub { font-size: 0.75rem; color: var(--text-muted); }
.expand-row-chevron { transition: transform 200ms; flex-shrink: 0; }
.expand-row.open .expand-row-chevron { transform: rotate(180deg); }
.expand-row-body { display: none; padding: 0 16px 14px 60px; }
.expand-row.open .expand-row-body { display: block; }
.expand-row-details { display: flex; flex-wrap: wrap; gap: 16px 28px; margin-bottom: 10px; }
.expand-detail { display: flex; flex-direction: column; gap: 2px; font-size: 0.8rem; color: var(--text-secondary); }
.expand-detail-label { font-size: 0.68rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); }
.expand-row-actions { display: flex; gap: 8px; margin-top: 6px; }

/* === Mobile Bottom Navbar === */
.mobile-navbar { display: none; position: fixed; bottom: 0; left: 0; right: 0; z-index: 100; background: var(--bg-card); border-top: 1px solid var(--border); padding: 6px 0 env(safe-area-inset-bottom, 6px); justify-content: space-around; align-items: center; }
.mobile-nav-item { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 8px; font-size: 0.62rem; font-weight: 500; color: var(--text-muted); text-decoration: none; background: none; border: none; cursor: pointer; transition: color 150ms; -webkit-tap-highlight-color: transparent; position: relative; }
.mobile-nav-item i, .mobile-nav-item svg { width: 20px; height: 20px; }
.mobile-nav-item.active { color: var(--primary); }
.mobile-nav-item:hover { color: var(--text-primary); }

/* Mobile-only / Desktop-only helpers */
.mobile-only { display: none !important; }
.desktop-only { display: inline !important; }

/* Mobile More button in header */
.mobile-more-btn { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: var(--radius-sm); background: none; border: none; color: var(--text-muted); cursor: pointer; transition: all var(--transition); -webkit-tap-highlight-color: transparent; }
.mobile-more-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.mobile-more-btn i, .mobile-more-btn svg { width: 20px; height: 20px; }

/* Mobile Account Bottom Sheet */
.mobile-account-popup { display: none; position: fixed; inset: 0; z-index: 300; }
.mobile-account-popup.open { display: block; }
.mobile-account-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.mobile-account-sheet { position: absolute; bottom: 0; left: 0; right: 0; background: var(--bg-card); border-top: 1px solid var(--border); border-radius: var(--radius-lg) var(--radius-lg) 0 0; padding: 1.25rem; padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px)); animation: sheetSlideUp 200ms ease-out; z-index: 1; }
@keyframes sheetSlideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.mobile-account-header { display: flex; align-items: center; gap: 0.75rem; padding-bottom: 0.85rem; border-bottom: 1px solid var(--border); margin-bottom: 0.5rem; }
.mobile-account-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--bg-hover); color: var(--text-primary); display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 1rem; flex-shrink: 0; overflow: hidden; }
.mobile-account-avatar img { width: 100%; height: 100%; object-fit: cover; }
.mobile-account-name { font-size: 0.92rem; font-weight: 600; color: var(--text-heading); }
.mobile-account-role { font-size: 0.75rem; color: var(--text-muted); }
.mobile-account-links { display: flex; flex-direction: column; gap: 0.15rem; }
.mobile-account-link { display: flex; align-items: center; gap: 0.65rem; padding: 0.6rem 0.5rem; font-size: 0.88rem; font-weight: 450; color: var(--text-secondary); border-radius: var(--radius-sm); transition: all var(--transition); text-decoration: none; cursor: pointer; background: none; border: none; width: 100%; font-family: inherit; text-align: left; }
.mobile-account-link:hover { color: var(--text-primary); background: var(--bg-hover); }
.mobile-account-link i, .mobile-account-link svg { width: 18px; height: 18px; flex-shrink: 0; }
.mobile-account-link.danger { color: var(--danger-text); }
.mobile-account-link.danger:hover { background: var(--danger-bg); }

@media (max-width: 1024px) {
    .mobile-navbar { display: flex; }
    .mobile-toggle { display: none !important; }
    .mobile-only { display: flex !important; }
    .desktop-only { display: none !important; }
    .content { padding-bottom: 70px !important; }
    /* Chat page: hide the page header, fit between top and mobile navbar */
    .main-content:has(> .content.chat-page) > .header { display: none !important; }
    .main-content:has(> .content.chat-page) { min-height: 0 !important; height: 100dvh; overflow: hidden; }
    .content.chat-page { padding: 0 !important; padding-bottom: 0 !important; overflow: hidden; flex: 1 !important; min-height: 0 !important; max-width: 100% !important; margin-bottom: 62px; }
    .chat-page .chat-container { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
    .chat-page .chat-header { flex-shrink: 0; position: sticky; top: 0; z-index: 10; }
    .chat-page .chat-input-area { padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)); flex-shrink: 0; position: sticky; bottom: 0; z-index: 10; }
    .chat-page .chat-messages { min-height: 0; flex: 1; overflow-y: auto; }
}
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* === Print === */
@media print {
    .sidebar, .header, .mobile-toggle { display: none !important; }
    .main-content { margin-left: 0 !important; }
    body { background: #fff; color: #000; }
}