/**
 * Global Styles
 * Lead CRM - Multi-Tenant SaaS Platform
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-secondary, var(--bg-primary, #f8f9fa));
    color: var(--text-primary, #333);
    line-height: 1.5;
    font-size: 14px;
}

a {
    color: inherit;
    text-decoration: none;
}

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

.main {
    flex: 1;
    margin-left: 240px;
}

/* Sidebar Base */
.sidebar {
    width: 240px;
    color: #fff;
    padding: 20px 0;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1001;
}

.logo {
    padding: 0 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 20px;
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

/* Navigation */
.nav-section {
    margin-bottom: 25px;
}

.nav-section-title {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.4);
    padding: 0 20px;
    margin-bottom: 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.nav-icon {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    opacity: 0.7;
}

.nav-badge {
    background: #fbbf24;
    color: #000;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    min-width: 20px;
    text-align: center;
}

/* Header */
.header {
    background: var(--bg-primary, var(--bg-card, #fff));
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color, var(--border, #e5e7eb));
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-left h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-secondary, var(--bg-tertiary, #f9fafb));
    border-radius: 8px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary, var(--accent-light, #e5e7eb));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary, #6b7280);
    flex-shrink: 0;
}

.user-avatar svg {
    width: 18px;
    height: 18px;
}

.user-info {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    line-height: 1.3;
}

.user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary, #1f2937);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

/* Content */
.content {
    padding: 25px 30px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: #3b82f6;
    color: #fff;
}

.btn-primary:hover {
    background: #2563eb;
}

.btn-secondary {
    background: var(--bg-primary, var(--bg-card, #fff));
    color: var(--text-primary, #374151);
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
}

.btn-secondary:hover {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-info {
    background: #0ea5e9 !important;
    color: #fff !important;
    border: 1px solid #0ea5e9;
}

.btn-info:hover {
    background: #0284c7 !important;
    border-color: #0284c7;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 12px 24px;
    font-size: 0.9rem;
}

/* Cards & Panels */
.panel {
    background: var(--bg-primary, var(--bg-card, #fff));
    border-radius: 10px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    margin-bottom: 20px;
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color, var(--border, #e5e7eb));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.panel-body {
    padding: 20px;
}

/* Activity List */
.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color, var(--border, #f3f4f6));
}
.activity-item:last-child {
    border-bottom: none;
}
.activity-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}
.activity-dot.blue {
    background: #3b82f6;
}
.activity-dot.green {
    background: #16a34a;
}
.activity-dot.orange {
    background: #f59e0b;
}
.activity-dot.red {
    background: #dc2626;
}
.activity-content {
    flex: 1;
    min-width: 0;
}
.activity-text {
    font-size: 0.9rem;
    color: var(--text-primary, #374151);
    line-height: 1.4;
}
.activity-text strong {
    color: var(--text-primary, #1e3a5f);
    font-weight: 600;
}
.activity-time {
    font-size: 0.75rem;
    color: var(--text-muted, var(--text-secondary, #9ca3af));
    margin-top: 4px;
}

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-primary, var(--bg-card, #fff));
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

.stat-change {
    font-size: 0.75rem;
    margin-top: 5px;
}

.stat-change.positive {
    color: #16a34a;
}

.stat-change.negative {
    color: #dc2626;
}

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    text-align: left;
    padding: 12px 15px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
    text-transform: uppercase;
    background: var(--bg-secondary, var(--bg-tertiary, #f9fafb));
    border-bottom: 1px solid var(--border-color, var(--border, #e5e7eb));
}

.table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-color, var(--border, #f3f4f6));
    font-size: 0.85rem;
    color: var(--text-primary, inherit);
}

.table tr:hover {
    background: var(--bg-secondary, var(--bg-tertiary, #f9fafb));
}

/* Filter Tabs */
.filter-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color, var(--border, #e5e7eb));
    padding-bottom: 10px;
}

.filter-tab {
    padding: 8px 16px;
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.filter-tab:hover {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
    color: var(--text-primary, #374151);
}

.filter-tab.active {
    background: var(--success, #3b82f6);
    color: #fff;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-primary, #374151);
    margin-bottom: 6px;
}

.form-label.required::after {
    content: ' *';
    color: #dc2626;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, var(--bg-card, #fff));
    color: var(--text-primary, inherit);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-input.error {
    border-color: #dc2626;
}

.form-select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, var(--bg-card, #fff));
    color: var(--text-primary, inherit);
    cursor: pointer;
}

.form-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, var(--bg-card, #fff));
    color: var(--text-primary, inherit);
    resize: vertical;
    min-height: 80px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

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

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}

.badge-success {
    background: #dcfce7;
    color: #16a34a;
}

.badge-danger {
    background: #fee2e2;
    color: #dc2626;
}

.badge-warning {
    background: #fef3c7;
    color: #d97706;
}

.badge-info {
    background: #dbeafe;
    color: #2563eb;
}

.badge-secondary {
    background: #f3f4f6;
    color: #6b7280;
}

.badge-dark {
    background: #374151;
    color: #fff;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
}
.status-badge.status-draft { background: #f3f4f6; color: #4b5563; }
.status-badge.status-created { background: #dbeafe; color: #1e40af; }
.status-badge.status-sent { background: #fef3c7; color: #92400e; }
.status-badge.status-partial { background: #fef9c3; color: #854d0e; }
.status-badge.status-paid { background: #dcfce7; color: #166534; }
.status-badge.status-overdue { background: #fee2e2; color: #991b1b; }
.status-badge.status-cancelled { background: #e5e7eb; color: #6b7280; }

/* Alerts */
.alerts-container {
    margin-bottom: 20px;
}

.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.85rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-success {
    background: #dcfce7;
    color: #16a34a;
    border: 1px solid #bbf7d0;
}

.alert-error,
.alert-danger {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fecaca;
    font-weight: 500;
}

.alert-warning {
    background: #fef3c7;
    color: #d97706;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #2563eb;
    border: 1px solid #bfdbfe;
}

.alert-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    opacity: 0.7;
}

.alert-close:hover {
    opacity: 1;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color, var(--border, #e5e7eb));
}

.pagination-info {
    font-size: 0.85rem;
    color: var(--text-secondary, #6b7280);
}

.pagination-links {
    display: flex;
    gap: 5px;
}

.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary, #374151);
    background: var(--bg-primary, var(--bg-card, #fff));
    text-decoration: none;
    transition: all 0.2s;
}

.pagination-link:hover:not(.disabled):not(.active) {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
    border-color: var(--border-color, #d1d5db);
}

.pagination-link.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.pagination-link.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    color: var(--text-secondary, #6b7280);
}

/* Search & Filters */
.search-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-input {
    flex: 1;
    max-width: 300px;
}

.filter-group {
    display: flex;
    gap: 10px;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color, var(--border, #e5e7eb));
    padding-bottom: 0;
}

.tab {
    padding: 10px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary, #6b7280);
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-primary, #374151);
}

.tab.active {
    color: var(--success, #3b82f6);
    border-bottom-color: var(--success, #3b82f6);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary, #6b7280);
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, #374151);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 0.9rem;
    margin-bottom: 20px;
}

/* Avatar */
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-tertiary, var(--accent-light, #e5e7eb));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, #6b7280);
}

.avatar-sm {
    width: 28px;
    height: 28px;
    font-size: 0.7rem;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}

/* Grid Layouts */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background: var(--bg-primary, var(--bg-card, #fff));
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    z-index: 1000;
    display: none;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 10px 16px;
    font-size: 0.85rem;
    color: var(--text-primary, #374151);
    text-decoration: none;
}

.dropdown-item:hover {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
}

.dropdown-item.text-danger {
    color: #dc2626;
}

.dropdown-item.text-danger:hover {
    background: #fef2f2;
}

/* Table Actions */
.table-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
}

.table-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: transparent;
    border: none;
    color: var(--text-secondary, #6b7280);
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
}

.table-action-btn:hover {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
    color: var(--text-primary, #1f2937);
}

.table-actions .dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    min-width: 160px;
    background: var(--bg-primary, var(--bg-card, #fff));
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 100;
    padding: 4px 0;
    margin-top: 4px;
}

.table-actions .dropdown-menu .dropdown-item {
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: var(--bg-primary, var(--bg-card, #fff));
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color, var(--border, #e5e7eb));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary, inherit);
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    opacity: 0.7;
}

.modal-close:hover {
    opacity: 1;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color, var(--border, #e5e7eb));
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Stats Mini */
.stats-mini {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-mini {
    background: var(--bg-primary, var(--bg-card, #fff));
    border-radius: 8px;
    padding: 15px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
}

.stat-mini-label {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    margin-bottom: 4px;
}

.stat-mini-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary, #1a1a1a);
}

/* Toolbar */
.toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.toolbar-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Search Bar (redesigned) */
.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-primary, var(--bg-card, #fff));
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    padding: 0;
    margin-bottom: 0;
}

.search-bar svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted, var(--text-secondary, #9ca3af));
    margin-left: 10px;
}

.search-bar input {
    border: none;
    padding: 8px 10px;
    font-size: 0.85rem;
    outline: none;
    min-width: 200px;
    background: transparent;
    color: var(--text-primary, inherit);
}

/* Filter Select */
.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    font-size: 0.85rem;
    background: var(--bg-primary, var(--bg-card, #fff));
    color: var(--text-primary, inherit);
    cursor: pointer;
}

/* Company Row */
.company-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.company-logo {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.company-info {
    flex: 1;
}

.company-name {
    font-weight: 500;
    color: var(--text-primary, #1a1a1a);
}

.company-subdomain {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
}

/* Actions */
.actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Form Row */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

/* Form Hint */
.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 6px;
}

/* Header Left P */
.header-left p {
    font-size: 0.8rem;
    color: var(--text-secondary, #6b7280);
    margin-top: 2px;
}

/* Pagination Button */
.pagination-btn {
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    background: var(--bg-primary, var(--bg-card, #fff));
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-primary, #374151);
    text-decoration: none;
    transition: all 0.2s;
}

.pagination-btn:hover {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
    border-color: var(--border-color, #d1d5db);
}

/* Hamburger Menu */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.hamburger:hover {
    background: var(--bg-tertiary, var(--accent-light, #f3f4f6));
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--text-primary, #374151);
    margin: 3px 0;
    transition: all 0.3s;
    border-radius: 2px;
}

.hamburger.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
    opacity: 0;
}

.hamburger.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* Sidebar Close Button (Mobile) */
.sidebar-close {
    display: none;
    position: absolute;
    top: 15px;
    right: 15px;
    width: 32px;
    height: 32px;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 6px;
    color: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    align-items: center;
    justify-content: center;
}

.sidebar-close:hover {
    background: rgba(255,255,255,0.2);
}

/* Package Cards Responsive */
.package-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.package-card {
    background: var(--bg-primary, var(--bg-card, #fff));
    border: 1px solid var(--border-color, var(--border, #e5e7eb));
    border-radius: 12px;
    padding: 25px;
    text-align: center;
    transition: all 0.2s;
}

.package-card.featured {
    border: 2px solid #dc2626;
    transform: scale(1.02);
}

.package-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Responsive */
@media (max-width: 1024px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }

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

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

@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden !important;
    }

    .layout {
        overflow-x: hidden;
    }

    /* Show hamburger menu */
    .hamburger {
        display: flex !important;
    }

    .sidebar-close {
        display: flex !important;
    }

    /* Sidebar mobile behavior */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 1000;
        width: 260px;
    }

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

    .main {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* Header adjustments */
    .header,
    .top-header {
        padding: 12px 15px !important;
    }

    .header-left {
        flex: 1;
        min-width: 0;
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .header-left h2,
    .header-left h1 {
        font-size: 1rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-left p {
        display: none !important;
    }

    .header-right {
        flex-shrink: 0;
    }

    .header-right .user-menu,
    .header-right .user-info {
        display: none !important;
    }

    .header-right .btn {
        padding: 6px 10px !important;
        font-size: 0.75rem !important;
    }

    /* Content area */
    .content {
        padding: 15px !important;
        max-width: 100vw;
        overflow-x: hidden;
    }

    /* Stats grids - force single column on mobile */
    .stats-grid {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .stats-mini {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }

    .stat-mini {
        padding: 12px !important;
    }

    .stat-mini-label {
        font-size: 0.7rem !important;
    }

    .stat-mini-value {
        font-size: 1rem !important;
    }

    .stat-card {
        padding: 12px !important;
    }

    .stat-label {
        font-size: 0.7rem !important;
    }

    .stat-value {
        font-size: 1.25rem !important;
    }

    /* Grids */
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr !important;
    }

    .form-grid {
        grid-template-columns: 1fr !important;
    }

    .form-row {
        grid-template-columns: 1fr !important;
    }

    /* Table responsive - wrap in scrollable container */
    .panel {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .table {
        min-width: 500px;
        font-size: 0.8rem;
    }

    .table th,
    .table td {
        padding: 8px 10px !important;
        font-size: 0.75rem !important;
    }

    /* Actions column */
    .actions {
        flex-direction: column !important;
        gap: 4px !important;
    }

    .actions .btn-sm {
        width: 100%;
        justify-content: center;
        font-size: 0.7rem !important;
        padding: 4px 8px !important;
    }

    .pagination {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }

    .toolbar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    .toolbar-left,
    .toolbar-right {
        width: 100% !important;
    }

    .toolbar-right .btn {
        width: 100%;
        justify-content: center;
    }

    .toolbar-form {
        width: 100% !important;
        flex-direction: column !important;
    }

    .search-bar {
        width: 100% !important;
    }

    .search-bar input {
        width: 100% !important;
        min-width: auto !important;
    }

    .filter-select {
        width: 100% !important;
    }

    /* Panel adjustments */
    .panel {
        border-radius: 8px;
    }

    .panel-header {
        padding: 12px 15px !important;
        flex-direction: column;
        gap: 10px;
        align-items: flex-start !important;
    }

    .panel-body {
        padding: 15px !important;
    }

    .panel-title {
        font-size: 0.9rem;
    }

    /* Modal mobile */
    .modal,
    .pipeline-modal-content {
        width: 95% !important;
        max-width: 95% !important;
        max-height: 85vh;
        margin: 10px auto !important;
    }

    .modal-header,
    .modal-body,
    .modal-footer,
    .pipeline-modal-header,
    .pipeline-modal-footer {
        padding: 15px !important;
    }

    /* Tabs scrollable on mobile */
    .tabs,
    .filter-tabs {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        flex-wrap: nowrap !important;
        padding-bottom: 5px;
    }

    .tab,
    .filter-tab {
        white-space: nowrap;
        flex-shrink: 0;
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    /* Package cards mobile */
    .package-grid {
        grid-template-columns: 1fr !important;
        gap: 15px !important;
    }

    .package-card {
        padding: 20px !important;
    }

    .package-card.featured {
        transform: none !important;
    }

    /* Company row */
    .company-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 5px;
    }

    .company-logo {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.8rem !important;
    }

    .company-name {
        font-size: 0.85rem;
    }

    .company-subdomain {
        font-size: 0.7rem;
    }

    /* Badges */
    .badge {
        font-size: 0.65rem !important;
        padding: 3px 8px !important;
    }

    /* Buttons */
    .btn {
        font-size: 0.8rem;
    }

    .btn-sm {
        font-size: 0.7rem !important;
        padding: 5px 8px !important;
    }

    /* Greeting on team dashboard */
    .greeting h1 {
        font-size: 1.25rem !important;
    }

    .greeting p {
        font-size: 0.8rem;
    }

    /* Header actions */
    .header-actions {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-actions .btn {
        font-size: 0.75rem;
        padding: 6px 10px;
    }

}

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

    .header,
    .top-header {
        padding: 10px 12px !important;
    }

    .header-left h2,
    .header-left h1 {
        font-size: 0.9rem !important;
    }

    .content {
        padding: 10px !important;
    }

    .stat-card {
        padding: 10px !important;
    }

    .stat-label {
        font-size: 0.65rem !important;
    }

    .stat-value {
        font-size: 1.1rem !important;
    }

    .btn {
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
    }

    .btn-sm {
        padding: 4px 6px !important;
        font-size: 0.65rem !important;
    }

    /* Company row on small screens */
    .company-row {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 5px;
    }

    .company-logo {
        width: 32px !important;
        height: 32px !important;
        font-size: 0.7rem !important;
    }

    .company-name {
        font-size: 0.8rem !important;
    }

    /* Table */
    .table th,
    .table td {
        padding: 6px 8px !important;
        font-size: 0.7rem !important;
    }

    /* Package cards */
    .package-card {
        padding: 15px !important;
    }

    /* Greeting */
    .greeting h1 {
        font-size: 1.1rem !important;
    }
}
