/* Material Design 3 & SaaS Hybrid Theme for Native Android CRM */
:root {
	--m3-sys-light-primary: #1a56db;
	--m3-sys-light-on-primary: #ffffff;
	--m3-sys-light-primary-container: #dbeafe;
	--m3-sys-light-on-primary-container: #1e40af;
	--m3-sys-light-secondary: #0d9488;
	--m3-sys-light-on-secondary: #ffffff;
	--m3-sys-light-surface: #ffffff;
	--m3-sys-light-on-surface: #0f172a;
	--m3-sys-light-surface-variant: #f1f5f9;
	--m3-sys-light-on-surface-variant: #475569;
	--m3-sys-light-outline: #cbd5e1;
	--m3-sys-light-outline-variant: #e2e8f0;
	--m3-sys-light-background: #f8fafc;
	--m3-sys-light-error: #dc2626;
	--m3-sys-light-success: #16a34a;
	--m3-sys-light-warning: #d97706;

	--radius-sm: 8px;
	--radius-md: 12px;
	--radius-lg: 16px;
	--radius-xl: 24px;
	--radius-full: 9999px;

	--font-sans: -apple-system, BlinkMacSystemFont, "Roboto", "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
	--font-mono: "JetBrains Mono", "SF Mono", "Fira Code", monospace;

	--shadow-elevation-1: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
	--shadow-elevation-2: 0 4px 6px -1px rgba(15, 23, 42, 0.1), 0 2px 4px -2px rgba(15, 23, 42, 0.06);
	--shadow-elevation-3: 0 10px 15px -3px rgba(15, 23, 42, 0.1), 0 4px 6px -4px rgba(15, 23, 42, 0.05);
	--shadow-elevation-4: 0 20px 25px -5px rgba(15, 23, 42, 0.1), 0 8px 10px -6px rgba(15, 23, 42, 0.05);

	--bg: var(--m3-sys-light-background);
	--fg: var(--m3-sys-light-on-surface);
	--muted: var(--m3-sys-light-on-surface-variant);
	--accent: var(--m3-sys-light-primary);
	--border: var(--m3-sys-light-outline-variant);
	--radius: 12px;
	--space: 1rem;
}

[data-theme="dark"] {
	--m3-sys-light-primary: #60a5fa;
	--m3-sys-light-on-primary: #0f172a;
	--m3-sys-light-primary-container: #1e3a8a;
	--m3-sys-light-on-primary-container: #dbeafe;
	--m3-sys-light-secondary: #2dd4bf;
	--m3-sys-light-surface: #111827;
	--m3-sys-light-on-surface: #f8fafc;
	--m3-sys-light-surface-variant: #1e293b;
	--m3-sys-light-on-surface-variant: #94a3b8;
	--m3-sys-light-outline: #334155;
	--m3-sys-light-outline-variant: #1f293d;
	--m3-sys-light-background: #0b0f19;
	--m3-sys-light-error: #f87171;
	--m3-sys-light-success: #4ade80;
	--m3-sys-light-warning: #fbbf24;

	--bg: var(--m3-sys-light-background);
	--fg: var(--m3-sys-light-on-surface);
	--muted: var(--m3-sys-light-on-surface-variant);
	--accent: var(--m3-sys-light-primary);
	--border: var(--m3-sys-light-outline-variant);
}

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

body {
	font-family: var(--font-sans);
	background: var(--bg);
	color: var(--fg);
	line-height: 1.5;
	-webkit-font-smoothing: antialiased;
	overflow-x: hidden;
}

/* App Container Layout */
.crm-app-root {
	min-height: 100vh;
	display: flex;
	flex-direction: column;
	background: var(--bg);
}

/* Top Global Navigation Bar */
.crm-header {
	background: var(--m3-sys-light-surface);
	border-bottom: 1px solid var(--border);
	padding: 0.6rem 1.25rem;
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 100;
	box-shadow: var(--shadow-elevation-1);
}

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

.crm-header-right {
	display: flex;
	align-items: center;
	gap: 0.6rem;
	flex-wrap: wrap;
}

.crm-brand-badge {
	display: flex;
	align-items: center;
	gap: 0.5rem;
	font-weight: 700;
	font-size: 1.1rem;
	letter-spacing: -0.02em;
	color: var(--fg);
}

.android-logo-icon {
	width: 28px;
	height: 28px;
	background: linear-gradient(135deg, #3ddc84, #00875a);
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #ffffff;
	font-size: 16px;
	box-shadow: 0 2px 4px rgba(61, 220, 132, 0.3);
}

.crm-badge-chip {
	font-size: 0.75rem;
	padding: 0.2rem 0.6rem;
	border-radius: var(--radius-full);
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}

.chip-online {
	background: #dcfce7;
	color: #15803d;
	border: 1px solid #86efac;
}

.chip-offline {
	background: #fef3c7;
	color: #b45309;
	border: 1px solid #fcd34d;
}

.chip-syncing {
	background: #dbeafe;
	color: #1d4ed8;
	border: 1px solid #93c5fd;
}

.chip-role {
	background: var(--m3-sys-light-surface-variant);
	color: var(--fg);
	border: 1px solid var(--border);
}

/* Device View Toggle Mode */
.device-toggle-bar {
	display: inline-flex;
	background: var(--m3-sys-light-surface-variant);
	border-radius: var(--radius-md);
	padding: 2px;
	border: 1px solid var(--border);
}

.device-toggle-btn {
	padding: 0.35rem 0.75rem;
	font-size: 0.8125rem;
	font-weight: 500;
	border: none;
	background: transparent;
	color: var(--muted);
	border-radius: 8px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	transition: all 0.15s ease;
}

.device-toggle-btn.active {
	background: var(--m3-sys-light-surface);
	color: var(--accent);
	box-shadow: var(--shadow-elevation-1);
	font-weight: 600;
}

/* Phone Frame Mockup View */
.phone-mockup-wrapper {
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: 1.5rem 1rem;
	background: radial-gradient(circle at 50% 10%, rgba(26, 86, 219, 0.05) 0%, transparent 60%);
	flex: 1;
}

.phone-chassis {
	width: 100%;
	max-width: 430px;
	min-height: 840px;
	background: var(--m3-sys-light-surface);
	border-radius: 40px;
	border: 10px solid #1e293b;
	box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25), 0 0 0 1px rgba(255, 255, 255, 0.1);
	display: flex;
	flex-direction: column;
	position: relative;
	overflow: hidden;
}

/* Android Status Bar */
.android-status-bar {
	height: 32px;
	background: var(--m3-sys-light-surface);
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 0 1.25rem;
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--fg);
	border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.android-camera-notch {
	width: 10px;
	height: 10px;
	background: #0f172a;
	border-radius: 50%;
	position: absolute;
	left: 50%;
	top: 10px;
	transform: translateX(-50%);
}

.status-bar-icons {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

/* Android Top App Bar */
.android-top-app-bar {
	padding: 0.75rem 1rem;
	background: var(--m3-sys-light-surface);
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
	position: sticky;
	top: 0;
	z-index: 20;
}

.app-bar-title {
	font-size: 1.15rem;
	font-weight: 700;
	color: var(--fg);
}

.app-bar-subtitle {
	font-size: 0.75rem;
	color: var(--muted);
}

/* Android Bottom Navigation Bar */
.android-bottom-nav {
	height: 64px;
	background: var(--m3-sys-light-surface);
	border-top: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-around;
	padding: 0 0.5rem;
	margin-top: auto;
	position: sticky;
	bottom: 0;
	z-index: 30;
	box-shadow: 0 -4px 6px -1px rgba(0, 0, 0, 0.04);
}

.bottom-nav-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 2px;
	background: transparent;
	border: none;
	color: var(--muted);
	font-size: 0.7rem;
	font-weight: 500;
	cursor: pointer;
	padding: 4px 12px;
	border-radius: var(--radius-md);
	transition: all 0.15s ease;
	position: relative;
}

.bottom-nav-item.active {
	color: var(--accent);
	font-weight: 700;
}

.bottom-nav-item.active .nav-icon-pill {
	background: var(--m3-sys-light-primary-container);
	color: var(--accent);
}

.nav-icon-pill {
	width: 44px;
	height: 26px;
	border-radius: 16px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.15s ease;
}

.nav-badge-dot {
	position: absolute;
	top: 2px;
	right: 14px;
	width: 8px;
	height: 8px;
	background: var(--m3-sys-light-error);
	border-radius: 50%;
	border: 1px solid #fff;
}

/* Main Content Area */
.app-screen-content {
	flex: 1;
	overflow-y: auto;
	padding: 1rem;
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

/* Full Width Tablet/Desktop CRM Layout */
.crm-desktop-view {
	max-width: 1440px;
	margin: 0 auto;
	padding: 1.5rem;
	width: 100%;
}

/* Material 3 Card Primitives */
.m3-card {
	background: var(--m3-sys-light-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 1.25rem;
	box-shadow: var(--shadow-elevation-1);
	transition: all 0.2s ease;
}

.m3-card-elevated {
	background: var(--m3-sys-light-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-lg);
	padding: 1.25rem;
	box-shadow: var(--shadow-elevation-2);
}

.m3-card:hover {
	border-color: var(--m3-sys-light-outline);
}

/* KPI Summary Cards */
.kpi-grid {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
	gap: 0.75rem;
}

.kpi-card {
	background: var(--m3-sys-light-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 0.9rem;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.kpi-label {
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--muted);
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.kpi-value {
	font-size: 1.35rem;
	font-weight: 700;
	color: var(--fg);
	letter-spacing: -0.02em;
}

.kpi-trend {
	font-size: 0.75rem;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 0.2rem;
}

.trend-up { color: var(--m3-sys-light-success); }
.trend-down { color: var(--m3-sys-light-error); }

/* Pipeline Kanban Board */
.pipeline-board {
	display: flex;
	gap: 1rem;
	overflow-x: auto;
	padding-bottom: 0.75rem;
}

.pipeline-stage-column {
	flex: 0 0 260px;
	background: var(--m3-sys-light-surface-variant);
	border-radius: var(--radius-lg);
	border: 1px solid var(--border);
	display: flex;
	flex-direction: column;
	max-height: 600px;
}

.stage-column-header {
	padding: 0.75rem 1rem;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.stage-title {
	font-size: 0.85rem;
	font-weight: 700;
	color: var(--fg);
}

.stage-count {
	font-size: 0.75rem;
	background: var(--m3-sys-light-surface);
	padding: 2px 8px;
	border-radius: var(--radius-full);
	font-weight: 600;
	color: var(--muted);
}

.stage-cards-list {
	padding: 0.75rem;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	overflow-y: auto;
	flex: 1;
}

.deal-card {
	background: var(--m3-sys-light-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-md);
	padding: 0.85rem;
	box-shadow: var(--shadow-elevation-1);
	cursor: pointer;
	transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.deal-card:hover {
	transform: translateY(-2px);
	box-shadow: var(--shadow-elevation-2);
	border-color: var(--accent);
}

.deal-card-title {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--fg);
	margin-bottom: 0.35rem;
}

.deal-card-value {
	font-size: 0.95rem;
	font-weight: 700;
	color: var(--accent);
}

/* Material 3 Floating Action Button (FAB) */
.m3-fab {
	position: fixed;
	bottom: 80px;
	right: 24px;
	background: linear-gradient(135deg, var(--accent), #1d4ed8);
	color: #ffffff;
	border: none;
	border-radius: 16px;
	padding: 0.85rem 1.25rem;
	font-size: 0.875rem;
	font-weight: 600;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	box-shadow: var(--shadow-elevation-3);
	cursor: pointer;
	z-index: 50;
	transition: all 0.2s ease;
}

.m3-fab:hover {
	transform: scale(1.05);
	box-shadow: var(--shadow-elevation-4);
}

/* Material Buttons */
.btn-m3 {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	padding: 0.55rem 1rem;
	font-size: 0.875rem;
	font-weight: 600;
	border-radius: var(--radius-md);
	border: 1px solid transparent;
	cursor: pointer;
	transition: all 0.15s ease;
	font-family: inherit;
}

.btn-m3-primary {
	background: var(--accent);
	color: #ffffff;
}

.btn-m3-primary:hover {
	filter: brightness(1.08);
}

.btn-m3-tonal {
	background: var(--m3-sys-light-primary-container);
	color: var(--m3-sys-light-on-primary-container);
}

.btn-m3-tonal:hover {
	filter: brightness(0.96);
}

.btn-m3-outlined {
	background: transparent;
	border-color: var(--border);
	color: var(--fg);
}

.btn-m3-outlined:hover {
	background: var(--m3-sys-light-surface-variant);
}

.btn-m3-danger {
	background: var(--m3-sys-light-error);
	color: #fff;
}

/* Form Controls */
.m3-input, .m3-select, .m3-textarea {
	width: 100%;
	padding: 0.65rem 0.85rem;
	background: var(--m3-sys-light-surface);
	border: 1.5px solid var(--border);
	border-radius: var(--radius-md);
	color: var(--fg);
	font-size: 0.875rem;
	font-family: inherit;
	transition: border-color 0.15s ease;
}

.m3-input:focus, .m3-select:focus, .m3-textarea:focus {
	outline: none;
	border-color: var(--accent);
	box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.15);
}

.m3-form-field {
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	margin-bottom: 0.85rem;
}

.m3-form-field label {
	font-size: 0.8rem;
	font-weight: 600;
	color: var(--muted);
}

/* Charts and Visualization */
.chart-container {
	position: relative;
	width: 100%;
}

.svg-chart {
	width: 100%;
	height: auto;
	display: block;
}

/* Modal Overlay */
.m3-modal-backdrop {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.55);
	backdrop-filter: blur(4px);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	z-index: 200;
}

.m3-modal-sheet {
	background: var(--m3-sys-light-surface);
	border: 1px solid var(--border);
	border-radius: var(--radius-xl);
	width: 100%;
	max-width: 540px;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: var(--shadow-elevation-4);
	display: flex;
	flex-direction: column;
}

.m3-modal-header {
	padding: 1.25rem 1.5rem;
	border-bottom: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: space-between;
}

.m3-modal-body {
	padding: 1.25rem 1.5rem;
	flex: 1;
}

.m3-modal-footer {
	padding: 1rem 1.5rem;
	border-top: 1px solid var(--border);
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 0.75rem;
}

/* Code Inspector Screen */
.code-viewer-container {
	background: #0d1117;
	color: #e6edf3;
	border-radius: var(--radius-lg);
	overflow: hidden;
	font-family: var(--font-mono);
	font-size: 0.8125rem;
	border: 1px solid #30363d;
}

.code-tabs {
	display: flex;
	background: #161b22;
	border-bottom: 1px solid #30363d;
	overflow-x: auto;
}

.code-tab-btn {
	padding: 0.6rem 1rem;
	background: transparent;
	border: none;
	color: #8b949e;
	cursor: pointer;
	font-size: 0.75rem;
	font-family: var(--font-mono);
	white-space: nowrap;
	border-right: 1px solid #30363d;
}

.code-tab-btn.active {
	background: #0d1117;
	color: #58a6ff;
	font-weight: 600;
	border-top: 2px solid #58a6ff;
}

.code-content-pre {
	padding: 1.25rem;
	overflow-x: auto;
	line-height: 1.6;
	max-height: 520px;
	overflow-y: auto;
}

/* Audio Waveform Animation */
.waveform-bars {
	display: flex;
	align-items: center;
	gap: 3px;
	height: 32px;
}

.waveform-bar {
	width: 4px;
	height: 10px;
	background: var(--accent);
	border-radius: 2px;
	animation: wavePulse 1s ease-in-out infinite alternate;
}

.waveform-bar:nth-child(2) { animation-delay: 0.15s; }
.waveform-bar:nth-child(3) { animation-delay: 0.3s; }
.waveform-bar:nth-child(4) { animation-delay: 0.45s; }
.waveform-bar:nth-child(5) { animation-delay: 0.6s; }

@keyframes wavePulse {
	from { height: 6px; }
	to { height: 28px; }
}

/* Notification banner toast */
.fcm-notification-toast {
	position: fixed;
	top: 64px;
	right: 16px;
	background: #1e293b;
	color: #ffffff;
	padding: 0.85rem 1.15rem;
	border-radius: var(--radius-md);
	box-shadow: var(--shadow-elevation-3);
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	z-index: 300;
	max-width: 360px;
	animation: slideInDown 0.25s ease-out;
	border-left: 4px solid #3ddc84;
}

@keyframes slideInDown {
	from { transform: translateY(-20px); opacity: 0; }
	to { transform: translateY(0); opacity: 1; }
}

/* Tab Pills in Screens */
.screen-tab-bar {
	display: flex;
	gap: 0.5rem;
	overflow-x: auto;
	padding: 0.25rem 0;
}

.screen-tab-btn {
	padding: 0.4rem 0.85rem;
	border-radius: var(--radius-full);
	border: 1px solid var(--border);
	background: var(--m3-sys-light-surface);
	color: var(--muted);
	font-size: 0.8125rem;
	font-weight: 500;
	cursor: pointer;
	white-space: nowrap;
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
	transition: all 0.15s ease;
}

.screen-tab-btn.active {
	background: var(--accent);
	color: #ffffff;
	border-color: var(--accent);
	font-weight: 600;
}

/* Map Simulation Pin */
.map-canvas-box {
	height: 180px;
	background: #e2e8f0;
	border-radius: var(--radius-md);
	position: relative;
	overflow: hidden;
	background-image: 
		linear-gradient(#cbd5e1 1px, transparent 1px),
		linear-gradient(90deg, #cbd5e1 1px, transparent 1px);
	background-size: 24px 24px;
}

.map-pin {
	position: absolute;
	width: 24px;
	height: 24px;
	background: var(--m3-sys-light-error);
	border-radius: 50% 50% 50% 0;
	transform: rotate(-45deg);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}

.map-pin::after {
	content: '';
	width: 10px;
	height: 10px;
	background: #fff;
	border-radius: 50%;
}

/* Standard utilities from seed */
.loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: calc(var(--space) * 1.5);
	color: var(--muted);
}

.spinner {
	flex: none;
	width: 1.15rem;
	height: 1.15rem;
	border: 2px solid var(--border);
	border-top-color: var(--accent);
	border-radius: 50%;
	animation: fab-spin 0.7s linear infinite;
}

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

.skeleton {
	display: block;
	height: 1rem;
	border-radius: calc(var(--radius) / 2);
	background: linear-gradient(90deg, var(--border), transparent, var(--border));
	background-size: 200% 100%;
	animation: fab-shimmer 1.2s linear infinite;
}

@keyframes fab-shimmer {
	to { background-position: -200% 0; }
}

.alert {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	flex-wrap: wrap;
	padding: 0.7rem 0.85rem;
	border: 1px solid var(--border);
	border-left: 3px solid var(--muted);
	border-radius: var(--radius);
}

.alert-error {
	border-left-color: var(--m3-sys-light-error);
	color: var(--m3-sys-light-error);
}

.badge {
	display: inline-block;
	padding: 0.1rem 0.5rem;
	border: 1px solid var(--border);
	border-radius: 999px;
	font-size: 0.8125rem;
	color: var(--muted);
}
