:root {
    --bg-dark: #09090b;
    --bg-surface: #18181b;
    --bg-surface-glass: rgba(24, 24, 27, 0.6);
    --border-glass: rgba(255, 255, 255, 0.08);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --primary-color: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.5);
    --secondary-color: #ec4899;
    --accent-color: #06b6d4;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
}

:root[data-theme="light"] {
    --bg-dark: #f0f4f8;
    --bg-surface: #ffffff;
    --bg-surface-glass: rgba(255, 255, 255, 0.85);
    --border-glass: rgba(0, 0, 0, 0.1);
    --text-main: #0f172a;
    --text-muted: #475569;
    --primary-color: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.3);
    /* Colors usually remain same, maybe slightly tweaked for light bg */
    --secondary-color: #db2777;
    --accent-color: #0891b2;
    --success: #059669;
    --warning: #d97706;
    --danger: #dc2626;
    --info: #2563eb;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    height: 100vh;
    overscroll-behavior-y: auto;
    background-image: radial-gradient(circle at 15% 50%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
                      radial-gradient(circle at 85% 30%, rgba(236, 72, 153, 0.15) 0%, transparent 50%);
}

h1, h2, h3, h4 {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Typography Enhancements */
.gradient-text {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.gradient-text-alt {
    background: linear-gradient(135deg, var(--accent-color) 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Utility Glasses */
.glass-panel {
    background: var(--bg-surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: 20px;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

.glass-card {
    background: rgba(255, 255, 255, 0.03);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-glass);
    border-radius: 16px;
    padding: 24px;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Layout */
.app-container {
    display: flex;
    width: 100%;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 280px;
    height: calc(100vh - 32px);
    margin: 16px;
    display: flex;
    flex-direction: column;
    padding: 24px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
}

.logo-circle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    box-shadow: 0 0 20px var(--primary-glow);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 20px;
    border-radius: 12px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.3s ease;
    border: 1px solid transparent;
}

.nav-item i {
    font-size: 20px;
}

.nav-item:hover, .nav-item.active {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--border-glass);
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(99, 102, 241, 0.15), transparent);
    border-left: 3px solid var(--primary-color);
}

.power-ups-link {
    margin-top: auto;
    background: rgba(6, 182, 212, 0.05);
    border: 1px solid rgba(6, 182, 212, 0.1);
}

.power-ups-link:hover {
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.2);
    border-color: var(--accent-color);
}

/* User Profile */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 24px;
    border-top: 1px solid var(--border-glass);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.user-info strong {
    display: block;
    font-size: 14px;
    color: var(--text-main);
}

.user-info small {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;

}

/* Header */
.top-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    margin-bottom: 24px;
}

.header-search {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(0,0,0,0.2);
    padding: 10px 20px;
    border-radius: 12px;
    width: 300px;
    border: 1px solid var(--border-glass);
    transition: all 0.3s;
}

.header-search:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 15px rgba(99, 102, 241, 0.2);
}

.header-search input {
    background: transparent;
    border: none;
    outline: none;
    color: var(--text-main);
    width: 100%;
    font-size: 14px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(236, 72, 153, 0.5);
}

.btn-primary-outline {
    background: transparent;
    color: var(--text-main);
    border: 1px solid var(--border-glass);
    padding: 10px 20px;
    border-radius: 12px;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
}

.btn-primary-outline:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: var(--primary-color);
}

.icon-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    position: relative;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
}

.badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.pulse-glow {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* Views Controller */
.views-wrapper {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease forwards;
}

.view.active {
    display: block;
}

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

.section-header {
    margin-bottom: 32px;
}

.section-header h1 {
    font-size: 32px;
    margin-bottom: 8px;
}

.section-header p {
    color: var(--text-muted);
    font-size: 16px;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    margin-bottom: 16px;
}

.stat-icon.calls { background: rgba(99, 102, 241, 0.1); color: var(--primary-color); }
.stat-icon.missed { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.stat-icon.rev { background: rgba(236, 72, 153, 0.1); color: var(--secondary-color); }

.stat-content h3 {
    font-size: 14px;
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    margin: 8px 0;
}

.stat-trend {
    font-size: 13px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 4px;
}

.stat-trend.positive { color: var(--success); }

.highlight-card {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(6, 182, 212, 0.05));
    border-color: rgba(16, 185, 129, 0.2);
}

.dashboard-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Activity List */
.live-feed { padding: 24px; }
.live-feed h2 { font-size: 20px; margin-bottom: 20px; }

.activity-list { list-style: none; display: flex; flex-direction: column; gap: 16px; }
.activity-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: rgba(0,0,0,0.2);
    border-radius: 12px;
    border: 1px solid var(--border-glass);
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.activity-icon.success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.activity-icon.warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); }
.activity-icon.info { background: rgba(6, 182, 212, 0.1); color: var(--accent-color); }

.activity-details { flex: 1; }
.activity-details strong { display: block; font-size: 14px; }
.activity-details span { font-size: 13px; color: var(--text-muted); }
.activity-time { font-size: 12px; color: var(--text-muted); }

/* Integrations Panel */
.leadsdock-integration { padding: 24px; }
.integration-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.status-indicator {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-indicator.live {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.system-flow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(0,0,0,0.2);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid var(--border-glass);
    margin-bottom: 16px;
}

.flow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.flow-step i {
    font-size: 32px;
    color: var(--primary-color);
}

.flow-step.pulse i {
    color: var(--secondary-color);
    animation: flowPulse 2s infinite;
}

@keyframes flowPulse {
    0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(236,72,153,0.5)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 10px rgba(236,72,153,0.8)); }
    100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(236,72,153,0.5)); }
}

.flow-arrow {
    color: var(--text-muted);
    font-size: 24px;
    opacity: 0.5;
}

.flow-desc {
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
}

/* IVR Builder */
.ivr-builder { padding: 24px; }
.ivr-builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    border-bottom: 1px solid var(--border-glass);
    padding-bottom: 16px;
}

.ivr-canvas {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 24px 0;
}

.ivr-node {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    padding: 16px 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    width: 400px;
    justify-content: center;
}

.start-node {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.action-node {
    flex-direction: column;
    text-align: center;
}

.highlight-action {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
    position: relative;
}

.highlight-badge {
    position: absolute;
    top: -12px;
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 10px;
    font-weight: 600;
}

.ivr-line {
    width: 2px;
    height: 30px;
    background: var(--border-glass);
}

.ivr-branch {
    border: 1px dashed var(--border-glass);
    border-radius: 12px;
    padding: 20px;
    width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.branch-logic {
    position: absolute;
    top: -10px;
    background: var(--bg-dark);
    padding: 0 12px;
    font-size: 12px;
    color: var(--text-muted);
    border-radius: 10px;
    border: 1px solid var(--border-glass);
}

.ivr-option {
    background: rgba(0,0,0,0.2);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 8px;
    width: 100%;
    text-align: center;
}

/* Social AI */
.ai-generator-panel { padding: 32px; }
.ai-input-wrapper h3 { margin-bottom: 24px; }

.mad-libs-sentence {
    font-size: 24px;
    line-height: 1.8;
    color: var(--text-main);
    margin-bottom: 32px;
}

.mad-libs-sentence select,
.mad-libs-sentence input {
    font-size: 20px;
    font-family: inherit;
    background: rgba(255,255,255,0.05);
    border: 1px dashed var(--primary-color);
    color: var(--accent-color);
    padding: 8px 16px;
    border-radius: 8px;
    outline: none;
    margin: 0 8px;
    font-weight: 600;
    transition: all 0.3s;
}

.mad-libs-sentence input:focus {
    background: rgba(99, 102, 241, 0.1);
    border-style: solid;
}

.sparkles { position: relative; overflow: hidden; }
.sparkles::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 200%;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.3), transparent);
    transform: rotate(45deg);
    animation: sparkleAnim 3s infinite linear;
}

@keyframes sparkleAnim {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

.hidden { display: none !important; }

.ai-results {
    margin-top: 40px;
    padding-top: 32px;
    border-top: 1px solid var(--border-glass);
    animation: fadeIn 0.5s ease;
}

.generation-loader {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--primary-color);
    font-weight: 600;
}

.spinner {
    width: 24px; height: 24px;
    border: 3px solid rgba(99,102,241,0.3);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.results-content { margin-top: 24px; }
.results-content.hidden { display: none; }
.post-card {
    background: rgba(0,0,0,0.2);
    border: 1px solid var(--border-glass);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
}

.post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.day-badge {
    background: var(--primary-color);
    color: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: bold;
}

.ai-image-prompt {
    margin: 16px 0;
    padding: 12px;
    background: rgba(236, 72, 153, 0.1);
    border-left: 3px solid var(--secondary-color);
    border-radius: 0 8px 8px 0;
    font-size: 13px;
    color: #fce7f3;
}

.post-actions {
    margin-top: 16px;
    display: flex;
    justify-content: flex-end;
}

/* Finance Section */
.finance-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
}

.finance-actions, .finance-list { padding: 24px; }
.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-top: 20px;
}

.finance-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-glass);
    color: white;
    padding: 20px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transition: all 0.3s;
    font-size: 16px;
    font-weight: 600;
}

.finance-btn i { font-size: 32px; color: var(--primary-color); }
.finance-btn span { font-size: 12px; color: var(--text-muted); font-weight: 400; }

.finance-btn.hero-btn {
    background: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(236,72,153,0.1));
    border-color: rgba(99,102,241,0.3);
}

.finance-btn:hover { background: rgba(255,255,255,0.1); transform: translateY(-3px); }

/* Table */
.modern-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.modern-table th {
    text-align: left;
    padding: 16px;
    color: var(--text-muted);
    font-weight: 500;
    border-bottom: 1px solid var(--border-glass);
}

.modern-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.status-badge.success { background: rgba(16,185,129,0.1); color: var(--success); }
.status-badge.pending { background: rgba(6,182,212,0.1); color: var(--accent-color); }
.status-badge.waiting { background: rgba(245,158,11,0.1); color: var(--warning); }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    width: 400px;
    padding: 24px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.close-btn {
    background: none; border: none; color: var(--text-muted); font-size: 24px; cursor: pointer;
}
.close-btn:hover { color: white; }

.modal-body label {
    display: block; margin-bottom: 8px; color: var(--text-muted); font-size: 14px;
}
.modal-body input {
    width: 100%; padding: 12px; background: rgba(0,0,0,0.2); border: 1px solid var(--border-glass);
    border-radius: 8px; color: white; margin-bottom: 20px; outline: none;
}
.modal-body input:focus { border-color: var(--primary-color); }
.fill-width { width: 100%; justify-content: center; }

/* Agenda */
.calendar-panel { padding: 24px; }
.calendar-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.time-slots { display: flex; flex-direction: column; gap: 16px; }
.time-slot { display: flex; gap: 16px; align-items: center; }
.time-label { width: 60px; color: var(--text-muted); font-size: 14px; font-weight: 500; }
.event-card {
    flex: 1;
    background: rgba(255,255,255,0.05);
    padding: 16px;
    border-radius: 12px;
    border-left: 4px solid var(--text-muted);
}
.event-line { flex: 1; height: 1px; border-bottom: 1px dashed var(--border-glass); }

.highlight-event {
    background: rgba(99,102,241,0.1);
    border-left-color: var(--primary-color);
}
.event-alert {
    font-size: 12px; color: var(--primary-color); font-weight: bold; margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px;
}
.reminder-sent {
    background: rgba(16,185,129,0.05);
    border-left-color: var(--success);
}

/* Powerups */
.tabs-container {
    display: flex; gap: 12px; margin-top: 24px; margin-bottom: 32px;
}
.power-tab {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border-glass); color: var(--text-muted);
    padding: 10px 20px; border-radius: 20px; cursor: pointer; transition: all 0.3s;
}
.power-tab.active {
    background: var(--accent-color); color: var(--bg-dark); border-color: var(--accent-color); font-weight: 600;
}
.powerup-content { display: none; animation: fadeIn 0.4s ease; }
.powerup-content.active { display: block; }

.powerup-card {
    display: flex; gap: 24px; background: rgba(0,0,0,0.2); padding: 32px; border-radius: 16px;
    border: 1px solid var(--border-glass);
}
.pu-icon {
    width: 64px; height: 64px; border-radius: 16px; background: linear-gradient(135deg, var(--accent-color), var(--primary-color));
    display: flex; align-items: center; justify-content: center; font-size: 32px; color: white; flex-shrink: 0;
}
.powerup-card h3 { font-size: 24px; margin-bottom: 12px; }
.powerup-card p { color: var(--text-muted); line-height: 1.6; margin-bottom: 24px; }

/* Theme Overrides for Inline Styles */
[data-theme="light"] [style*="color:white"],
[data-theme="light"] [style*="color: white"] {
    color: var(--text-main) !important;
}

[data-theme="light"] [style*="border-color:white"],
[data-theme="light"] [style*="border-color: white"] {
    border-color: var(--primary-color) !important;
}

[data-theme="light"] [style*="background:rgba(0,0,0,"],
[data-theme="light"] [style*="background: rgba(0,0,0,"] {
    background: var(--bg-surface-glass) !important;
}

[data-theme="light"] [style*="border:1px solid rgba(255,255,255,0.2)"] {
    border: 1px solid var(--border-glass) !important;
}

[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    color: var(--text-main) !important;
    background: var(--bg-surface) !important;
    color-scheme: light !important;
}

/* Responsive POS System */
.pos-split {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.pos-left {
    flex: 2;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0; /* allows flex children to shrink */
}

.pos-right {
    flex: 1;
    min-width: 320px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 24px;
    height: auto;
    max-height: calc(100vh - 48px);
}

/* Responsive Design (Tablet & Mobile) */

@media (max-width: 1024px) {
    .dashboard-split, .finance-grid {
        grid-template-columns: 1fr;
    }
    [style*="grid-template-columns: repeat(4, 1fr)"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .ivr-canvas {
        transform: scale(0.9);
    }
}

@media (max-width: 768px) {
    body {
        overflow-y: auto;
    }
    .app-container {
        flex-direction: column;
        height: auto;
    }
    .sidebar {
        width: 100% !important;
        height: auto !important;
        margin: 0;
        padding: 12px;
        position: relative;
        background: var(--bg-surface-glass);
        border-bottom: 1px solid var(--border-glass);
        border-radius: 0;
        box-shadow: none;
    }
    .sidebar-header {
        display: none;
    }
    .user-profile {
        display: none;
    }
    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        gap: 16px;
        padding-bottom: 8px;
        align-items: center;
    }
    .nav-item {
        padding: 8px;
        flex-shrink: 0;
        flex-direction: column;
        gap: 4px;
        border: none !important;
        background: transparent !important;
    }
    .nav-item i {
        font-size: 24px;
        margin-bottom: 2px;
    }
    .nav-item span {
        display: none;
    }
    .nav-item.active {
        color: var(--primary-color) !important;
        transform: translateY(-4px);
    }
    .nav-item.active i {
        color: var(--primary-color) !important;
    }
    .main-content {
        padding: 16px;
        overflow: visible;
    }
    .top-header {
        flex-direction: column;
        gap: 16px;
        padding: 16px;
        align-items: stretch;
    }
    .header-search {
        width: 100%;
    }
    .stats-grid, [style*="grid-template-columns: repeat(4, 1fr)"], [style*="grid-template-columns: repeat(3, 1fr)"], [style*="grid-template-columns: repeat(2, 1fr)"] {
        grid-template-columns: 1fr !important;
    }
    .views-wrapper {
        overflow: visible;
    }
    .ivr-canvas {
        transform: scale(0.65);
        transform-origin: top left;
        overflow-x: auto;
        padding: 16px 0;
    }
    /* Button Un-shrinking for tight rows */
    .btn-primary, .btn-primary-outline {
        flex: 1;
        min-width: fit-content;
        text-align: center;
        justify-content: center;
    }
    /* Make inline flex row groups wrap on mobile so buttons stack nicely instead of shrinking */
    .pos-left > div, .pos-right > div, .header-actions {
        flex-wrap: wrap !important;
    }
    /* Fix Telecom & IVR View squeezing */
    #view-connect div[style*="display: flex"],
    #view-connect div[style*="display:flex"] {
        flex-wrap: wrap !important;
    }
    #view-connect div[style*="gap: 24px; min-height: 400px;"],
    #view-connect div[style*="gap:24px; min-height:400px;"] {
        flex-direction: column !important;
    }
    /* Fix IVR Header Badge squishing */
    .ivr-builder-header div[style*="display:flex; align-items:center; gap:12px;"] {
        flex-wrap: wrap;
        width: 100%;
        margin-bottom: 8px;
    }
    .modal {
        width: 95% !important;
        max-height: 85vh;
        overflow-y: auto;
        padding: 20px;
    }
    .powerup-card {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
    
    /* Mobile POS Adjustments */
    .pos-split {
        flex-direction: column; /* Normal stacking: Search -> Products -> Cart */
        gap: 16px;
        align-items: stretch;
    }
    #pos-product-grid {
        max-height: 40vh !important; /* Forces product list to scroll internally, keeping Cart always in view */
        border: 1px solid rgba(255,255,255,0.05);
        border-radius: 8px;
        padding-bottom: 8px;
    }
    .pos-right {
        position: relative;
        top: 0;
        min-width: 100%;
        max-height: 50vh; /* Don't let it take the whole screen */
    }
    .pos-left {
        min-width: 100%;
        padding: 16px;
    }
    .pos-right [style*="display:flex; gap:12px;"] {
        flex-direction: column; /* Stack the big payment buttons */
    }
    .pos-right [style*="display:flex; flex-direction:column; gap:12px;"] > div {
        flex-direction: column !important; /* Forces QR and Contant on their own lines */
    }
    
    /* GLOBAL MOBILE OVERRIDES FOR ALL REMAINING VIEWS */
    /* Force section headers with inline flex to stack strictly */
    .section-header > div[style*="display:flex"],
    .section-header > div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 16px !important;
    }
    /* Let tab buttons wrap instead of shrinking */
    .tabs-container {
        flex-wrap: wrap !important;
        height: auto !important;
        margin-top: 16px !important;
    }
    /* Prevent table columns squeezing */
    .modern-table {
        white-space: nowrap !important;
    }
    
    /* Convert explicitly split grids into stacked columns (Finance, Instellingen, Campagnes) */
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns: 1fr 2fr"],
    div[style*="grid-template-columns: 2fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr 1fr"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
    }
    
    /* Force all aggressive nested inline rows to wrap globally */
    .view div[style*="display:flex"],
    .view div[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    /* Gently stack buttons natively when space is tight */
    .btn-primary, .btn-primary-outline {
        flex: 1 1 auto;
        min-width: 160px;
        white-space: normal !important; 
    }
    
    /* Exclude specific small utility icons */
    .icon-btn, .close-btn, .nav-item {
        width: auto !important;
        margin-bottom: 0 !important;
        min-width: 0;
    }

    /* Transform raw Modals into elegant centered floating sheets */
    .modal-overlay {
        align-items: center !important; 
        padding: 16px !important;
    }
    .modal {
        width: 100% !important;
        max-width: 500px !important;
        margin: auto !important;
        border-radius: 20px !important;
        padding: 24px !important;
        max-height: 85vh !important;
        overflow-y: auto !important;
        position: relative;
    }
    
    /* Fix inline side-by-side forms inside modals from bleeding off-screen */
    .modal-body div[style*="display:flex"], 
    .modal-body div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 12px !important;
    }
    
    /* Force inputs strictly inside their boundaries */
    .modal-body input, .modal-body select, .modal-body textarea, input[type="text"], input[type="number"] {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }
    
    /* Specific overrides for Calendar/Agenda which used strict gaps and row directions */
    .calendar-panel div[style*="gap:24px"] {
        flex-direction: column !important;
    }
    
    /* Correctly push the menu search bar inside Restaurant view to its own line */
    #restaurant-products-panel div[style*="justify-content:space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
    }
}

