/* ═══════════════════════════════════════════════════════════════════════
   OmniCRM AI SaaS — Premium Design System
   ═══════════════════════════════════════════════════════════════════════ */

:root {
    /* Color Palette — Dark Premium */
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-tertiary: #1e2030;
    --bg-card: #1a1c2e;
    --bg-hover: #252840;
    --bg-input: #1a1d2e;
    --bg-sidebar: #0d0f18;

    --text-primary: #e4e6f0;
    --text-secondary: #8b8fa7;
    --text-muted: #5d6178;
    --text-white: #ffffff;

    --accent-primary: #6c5ce7;
    --accent-primary-hover: #7c6df7;
    --accent-secondary: #00cec9;
    --accent-success: #00b894;
    --accent-warning: #fdcb6e;
    --accent-danger: #ff6b6b;
    --accent-info: #74b9ff;

    --gradient-primary: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    --gradient-success: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    --gradient-danger: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    --gradient-card: linear-gradient(135deg, rgba(108, 92, 231, 0.08) 0%, rgba(0, 206, 201, 0.04) 100%);

    --border-color: #2a2d40;
    --border-light: #1e2030;
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 20px rgba(108, 92, 231, 0.2);

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --sidebar-width: 260px;
    --sidebar-collapsed: 70px;
    --topbar-height: 64px;

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    font-family: var(--font);
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100%;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Login ─────────────────────────────────────────────────────────────── */

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse at 20% 50%, rgba(108, 92, 231, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 206, 201, 0.06) 0%, transparent 50%);
}

.login-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    width: 420px;
    max-width: 95vw;
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    animation: fadeInUp 0.6s ease;
}

.login-logo {
    text-align: center;
    margin-bottom: 36px;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
    animation: pulse 2s infinite;
}

.login-logo h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-white);
    letter-spacing: -0.5px;
}

.login-logo h1 span {
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.login-form input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
}

.login-form input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.15);
}

.login-error {
    margin-top: 16px;
    padding: 10px 14px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid rgba(255, 107, 107, 0.3);
    border-radius: var(--radius-sm);
    color: var(--accent-danger);
    font-size: 13px;
    text-align: center;
}

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 12px rgba(108, 92, 231, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(108, 92, 231, 0.4);
}

.btn-success {
    background: var(--gradient-success);
    color: white;
}

.btn-danger {
    background: var(--gradient-danger);
    color: white;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}

.btn-full {
    width: 100%;
    padding: 13px;
    font-size: 15px;
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ── App Layout ────────────────────────────────────────────────────────── */

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    flex-shrink: 0;
    z-index: 100;
}

.sidebar-header {
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--border-light);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.logo-icon-sm {
    font-size: 24px;
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-white);
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.nav-section {
    margin-bottom: 8px;
    padding: 0 12px;
}

.nav-section-title {
    display: block;
    padding: 8px 12px 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent-primary);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background: var(--accent-primary);
    border-radius: 0 3px 3px 0;
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-badge {
    margin-left: auto;
    background: var(--accent-danger);
    color: white;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    overflow: hidden;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
}

.user-details {
    overflow: hidden;
}

.user-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.btn-logout:hover {
    background: rgba(255, 107, 107, 0.1);
    color: var(--accent-danger);
}

/* ── Main Content ──────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
}

.top-bar {
    height: var(--topbar-height);
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
    background: var(--bg-secondary);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.top-bar-left h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-white);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box .search-input {
    padding: 8px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 13px;
    font-family: var(--font);
    width: 240px;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    width: 300px;
}

.system-badge {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-success);
    padding: 5px 12px;
    background: rgba(0, 184, 148, 0.1);
    border-radius: var(--radius-lg);
}

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ── Metric Cards ──────────────────────────────────────────────────────── */

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.metric-card:hover {
    border-color: rgba(108, 92, 231, 0.3);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.metric-card:hover::after {
    opacity: 1;
}

.metric-icon {
    font-size: 28px;
    margin-bottom: 12px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-white);
    line-height: 1;
    margin-bottom: 4px;
}

.metric-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* ── Data Tables ───────────────────────────────────────────────────────── */

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
}

.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

/* ── Cards ─────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-white);
}

.card-body {
    padding: 20px;
}

/* ── Kanban ─────────────────────────────────────────────────────────────── */

.kanban-board {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    padding-bottom: 16px;
    min-height: calc(100vh - 200px);
}

.kanban-column {
    min-width: 300px;
    max-width: 320px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.kanban-column-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-light);
}

.kanban-column-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kanban-column-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.kanban-column-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.kanban-column-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 10px;
}

.kanban-cards {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 50px;
    transition: var(--transition);
}

.kanban-cards.drag-over {
    background: rgba(108, 92, 231, 0.05);
    border-radius: var(--radius-sm);
    box-shadow: inset 0 0 0 2px rgba(108, 92, 231, 0.3);
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 14px;
    cursor: grab;
    transition: var(--transition);
}

.kanban-card:active {
    cursor: grabbing;
}

.kanban-card.dragging {
    opacity: 0.5;
    box-shadow: var(--shadow-lg);
    transform: scale(1.02);
    border-color: var(--accent-primary);
}

.kanban-card:hover {
    border-color: rgba(108, 92, 231, 0.4);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
}

.kanban-card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.kanban-card-value {
    font-weight: 700;
    color: var(--accent-success);
}

/* ── Inbox ─────────────────────────────────────────────────────────────── */

.inbox-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 0;
    height: calc(100vh - var(--topbar-height) - 120px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.inbox-list {
    border-right: 1px solid var(--border-color);
    overflow-y: auto;
    background: var(--bg-secondary);
}

.inbox-item {
    padding: 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.inbox-item:hover {
    background: var(--bg-hover);
}

.inbox-item.active {
    background: rgba(108, 92, 231, 0.1);
    border-left: 3px solid var(--accent-primary);
}

.inbox-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.inbox-item-info {
    flex: 1;
    overflow: hidden;
}

.inbox-item-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.inbox-item-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.inbox-item-time {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
}

.inbox-detail {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    overflow: hidden;
    min-height: 0;
    height: 100%;
}

.inbox-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
}

.message-bubble {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
}

.message-incoming {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message-outgoing {
    background: var(--accent-primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.inbox-composer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    background: var(--bg-secondary);
    flex-shrink: 0;
}

.inbox-composer input {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
}

.inbox-composer input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.inbox-detail-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-secondary);
    z-index: 10;
}

.message-note {
    background: rgba(253, 203, 110, 0.15);
    border: 1px dashed var(--accent-warning);
    color: var(--accent-warning);
    align-self: center;
    width: 90%;
    max-width: 90%;
    margin: 8px 0;
    text-align: center;
}

.inbox-composer-wrapper {
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.inbox-composer-tabs {
    display: flex;
    gap: 20px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-light);
}

.composer-tab {
    padding: 10px 0;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.composer-tab:hover {
    color: var(--text-primary);
}

.composer-tab.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.inbox-composer-wrapper.mode-note .composer-tab.active {
    color: var(--accent-warning);
    border-bottom-color: var(--accent-warning);
}

.inbox-composer-wrapper.mode-note .inbox-composer {
    background: rgba(253, 203, 110, 0.05);
}

/* ── Forms ─────────────────────────────────────────────────────────────── */

.form-row {
    margin-bottom: 16px;
}

.form-row label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 14px;
    font-family: var(--font);
    transition: var(--transition);
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.form-row textarea {
    resize: vertical;
    min-height: 80px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ── Status Badges ─────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success {
    background: rgba(0, 184, 148, 0.15);
    color: var(--accent-success);
}

.badge-warning {
    background: rgba(253, 203, 110, 0.15);
    color: var(--accent-warning);
}

.badge-danger {
    background: rgba(255, 107, 107, 0.15);
    color: var(--accent-danger);
}

.badge-info {
    background: rgba(116, 185, 255, 0.15);
    color: var(--accent-info);
}

.badge-primary {
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-primary);
}

/* ── Tags ──────────────────────────────────────────────────────────────── */

.tag {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    margin-right: 4px;
}

/* ── Modal ─────────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 540px;
    max-width: 95vw;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-white);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* ── Toast ─────────────────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: white;
    box-shadow: var(--shadow-md);
    animation: slideInRight 0.3s ease;
    max-width: 400px;
}

.toast-success {
    background: var(--accent-success);
}

.toast-error {
    background: var(--accent-danger);
}

.toast-info {
    background: var(--accent-info);
}

.toast-warning {
    background: var(--accent-warning);
    color: #333;
}

/* ── Empty States ──────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 14px;
    margin-bottom: 20px;
}

/* ── Page Header ───────────────────────────────────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

/* ── Dashboard Grid ────────────────────────────────────────────────────── */

.dashboard-grid {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-4px);
    border-color: var(--accent-primary);
}

.metric-icon {
    font-size: 24px;
    margin-bottom: 12px;
}

.metric-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-white);
    margin-bottom: 4px;
}

.metric-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.section-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.card-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-white);
}

.card-body {
    padding: 20px;
}

.funnel-bar {
    margin-bottom: 16px;
}

.funnel-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}

.funnel-track {
    height: 12px;
    background: var(--bg-tertiary);
    border-radius: 6px;
    overflow: hidden;
}

.funnel-fill {
    height: 100%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 8px;
    font-size: 9px;
    font-weight: 800;
    color: white;
    transition: width 1s ease-out;
}

.page-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-white);
}

/* ── Section Grid ──────────────────────────────────────────────────────── */

.section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

/* ── Funnel Chart ──────────────────────────────────────────────────────── */

.funnel-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.funnel-label {
    width: 120px;
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.funnel-track {
    flex: 1;
    height: 28px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.funnel-fill {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    min-width: 30px;
    transition: width 0.8s ease;
}

.funnel-count {
    width: 50px;
    text-align: right;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

/* ── Animations ────────────────────────────────────────────────────────── */

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(40px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.08);
    }
}

/* ── Loading ───────────────────────────────────────────────────────────── */

.loading-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.loading-spinner::after {
    content: '';
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ── Responsive ────────────────────────────────────────────────────────── */

/* ── Tablet Landscape (≤1024px) ─────────────────────────────────────── */
@media (max-width: 1024px) {
    .sidebar {
        width: var(--sidebar-collapsed);
    }

    .nav-label,
    .nav-section-title,
    .user-details,
    .logo-text {
        display: none;
    }

    .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .nav-icon {
        margin: 0;
    }

    .sidebar-logo {
        justify-content: center;
    }

    .user-info {
        justify-content: center;
    }

    .nav-badge {
        position: absolute;
        top: 4px;
        right: 4px;
    }

    .kanban-column {
        min-width: 260px;
    }

    .inbox-layout {
        grid-template-columns: 300px 1fr;
    }

    .section-grid {
        grid-template-columns: 1fr;
    }

    .deal-sidebar {
        width: 380px;
    }
}

/* ── Mobile Overlay (backdrop escuro ao abrir sidebar) ──────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}

.sidebar-overlay.active {
    display: block;
}

/* ── Tablet Portrait / Mobile (≤768px) ──────────────────────────────── */
@media (max-width: 768px) {

    /* Sidebar: off-canvas drawer */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100%;
        width: var(--sidebar-width);
        z-index: 200;
        transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar.open {
        left: 0;
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.5);
    }

    /* Restaurar labels e textos no drawer aberto */
    .sidebar.open .nav-label,
    .sidebar.open .nav-section-title,
    .sidebar.open .user-details,
    .sidebar.open .logo-text {
        display: block;
    }

    .sidebar.open .nav-item {
        justify-content: flex-start;
        padding: 10px 16px;
    }

    .sidebar.open .nav-icon {
        margin-right: 10px;
    }

    .sidebar.open .sidebar-logo {
        justify-content: flex-start;
    }

    .sidebar.open .user-info {
        justify-content: flex-start;
    }

    .sidebar.open .nav-badge {
        position: static;
    }

    /* Main content ocupa 100% */
    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Top bar ajustes */
    .top-bar {
        padding: 10px 16px;
    }

    .top-bar-left h2 {
        font-size: 15px;
    }

    .search-box {
        display: none;
    }

    /* Grids responsivos */
    .metrics-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .section-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    /* Inbox: conversas empilhadas */
    .inbox-layout {
        grid-template-columns: 1fr;
    }

    /* Kanban: scroll horizontal */
    .kanban-board {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        padding-bottom: 12px;
    }

    .kanban-column {
        min-width: 280px;
        scroll-snap-align: start;
    }

    /* Tabelas: scroll horizontal */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    /* Modais: full-screen em mobile */
    .modal {
        width: 100vw;
        max-width: 100vw;
        max-height: 100vh;
        height: 100vh;
        border-radius: 0;
    }

    .modal-overlay {
        align-items: stretch;
    }

    /* Deal sidebar: full-width */
    .deal-sidebar {
        width: 100vw;
        max-width: 100vw;
    }

    /* Toasts: repositionados embaixo */
    .toast-container {
        top: auto;
        bottom: 20px;
        right: 10px;
        left: 10px;
    }

    .toast {
        max-width: 100%;
    }

    /* Page headers */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .page-header-left {
        width: 100%;
    }

    /* Ocultar filtros complexos */
    .filter-bar {
        flex-direction: column;
    }

    /* Login ajustado */
    .login-card {
        padding: 32px 24px;
    }

    /* Cards de métricas menores */
    .metric-card {
        padding: 16px;
    }

    .metric-value {
        font-size: 22px;
    }

    .metric-icon {
        font-size: 20px;
    }

    /* Tabs: scroll horizontal */
    .tabs-header {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap;
        gap: 4px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 13px;
        white-space: nowrap;
    }
}

/* ── Small Mobile (≤480px) ──────────────────────────────────────────── */
@media (max-width: 480px) {
    .metrics-grid {
        grid-template-columns: 1fr;
    }

    .metric-card {
        padding: 14px;
    }

    .metric-value {
        font-size: 20px;
    }

    .top-bar-left h2 {
        font-size: 14px;
    }

    .system-badge {
        display: none;
    }

    .login-card {
        padding: 24px 16px;
        width: 100%;
    }

    .login-logo h1 {
        font-size: 22px;
    }

    .btn {
        padding: 10px 16px;
        font-size: 13px;
    }

    .page-content {
        padding: 12px;
    }

    /* Funnel chart ajustado */
    .funnel-label {
        width: 80px;
        font-size: 11px;
    }

    .funnel-count {
        width: 35px;
        font-size: 11px;
    }

    .card-header {
        padding: 12px 14px;
    }

    .card-body {
        padding: 14px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    /* Kanban cards menores */
    .kanban-column {
        min-width: 250px;
    }

    /* Tab header: full scroll */
    .tab-header-actions {
        flex-direction: column;
        gap: 8px;
    }
}

/* ── Selection List (Modal) ─────────────────────────────────────────── */

.list-item-select {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition);
}

.list-item-select:hover {
    background: var(--bg-hover);
}

.list-item-select:last-child {
    border-bottom: none;
}

.list-item-select .user-avatar {
    flex-shrink: 0;
}

/* ── Pipeline Enhancements ─────────────────────────────────────────────── */

/* Pipeline metrics bar */
.pipeline-metrics .metric-card {
    padding: 14px;
    text-align: center;
}

.pipeline-metrics .metric-value {
    font-size: 22px;
}

.pipeline-metrics .metric-label {
    font-size: 11px;
}

/* Card visual indicators */
.kanban-card.card-stale {
    border-left: 3px solid var(--accent-warning);
}

.kanban-card.card-no-owner {
    border-left: 3px solid var(--accent-danger);
}

.card-tag {
    display: inline-block;
    font-size: 10px;
    padding: 1px 6px;
    border-radius: 8px;
    background: rgba(108, 92, 231, 0.15);
    color: var(--accent-primary);
    font-weight: 600;
}

.card-alert {
    font-size: 11px;
    color: var(--accent-warning);
}

.card-unread {
    font-size: 11px;
    color: var(--accent-info);
    font-weight: 600;
}

.card-tasks {
    font-size: 11px;
    color: var(--text-muted);
}

/* Deal Detail Sidebar */
.deal-sidebar {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 480px;
    max-width: 100vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 500;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.4);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sidebar-header h3 {
    color: var(--text-white);
}

.sidebar-body {
    overflow-y: auto;
}

/* Detail sections */
.detail-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-light);
}

.detail-section h4 {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 10px;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.detail-label {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.detail-value {
    display: block;
    font-size: 13px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Timeline */
.timeline {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.timeline-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    font-size: 13px;
}

.timeline-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 2px;
}

.timeline-content {
    color: var(--text-secondary);
}

.timeline-content b {
    color: var(--text-white);
}

/* Bulk actions button */
#bulk-btn {
    background: rgba(108, 92, 231, 0.12);
    color: var(--accent-primary);
    border: 1px solid rgba(108, 92, 231, 0.3);
}

/* Deal checkbox */
.deal-select {
    opacity: 0.3;
    transition: var(--transition);
}

.kanban-card:hover .deal-select,
.deal-select:checked {
    opacity: 1;
}

/* ── Segmentation & Targeting ─────────────────────────────────────────── */

.tabs-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.tabs-header {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 2px;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}

.tab-btn.active {
    color: var(--accent-primary);
    border-bottom-color: var(--accent-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.tab-header-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.group-card {
    transition: var(--transition);
}

.group-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--accent-primary);
}

.tag-pill {
    transition: var(--transition);
    cursor: default;
}

.tag-pill:hover {
    filter: brightness(1.2);
    transform: scale(1.02);
}

.btn-icon-xs {
    background: transparent;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px 6px;
    border-radius: 4px;
    opacity: 0.6;
}

.btn-icon-xs:hover {
    background: rgba(255, 255, 255, 0.1);
    opacity: 1;
}

.filter-bar {
    background: var(--bg-secondary) !important;
    border: 1px solid var(--border-color) !important;
    animation: fadeIn 0.3s ease;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}