:root {
  --navy: #001f3f;
  --cyan: #00bcd4;
  --cyan-dark: #0097a7;
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --danger: #ef4444;
  --success: #22c55e;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius: 8px;
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: var(--font); background: linear-gradient(135deg, var(--navy), #003366); min-height: 100vh; color: var(--gray-800); }
.app-container { min-height: 100vh; display: flex; flex-direction: column; }
.header { background: var(--white); padding: 1rem 2rem; display: flex; justify-content: space-between; align-items: center; box-shadow: var(--shadow); }
.logo { display: flex; align-items: center; gap: 0.75rem; }
.logo-icon { font-size: 1.5rem; }
.logo-text { font-size: 1.25rem; font-weight: 700; color: var(--navy); }
.user-info { font-size: 0.875rem; color: var(--gray-600); }
.auth-required { flex: 1; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.auth-card { background: var(--white); padding: 3rem; border-radius: var(--radius); text-align: center; box-shadow: var(--shadow-lg); max-width: 400px; }
.auth-card h2 { color: var(--navy); margin-bottom: 1rem; }
.auth-card p { color: var(--gray-600); margin-bottom: 1.5rem; }
.main-content { flex: 1; padding: 2rem; max-width: 800px; margin: 0 auto; width: 100%; }
.composer-card, .output-card { background: var(--white); border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow-lg); margin-bottom: 1.5rem; }
.composer-card h1 { color: var(--navy); font-size: 1.75rem; margin-bottom: 0.5rem; }
.subtitle { color: var(--gray-500); margin-bottom: 2rem; }
.output-card h2 { color: var(--navy); font-size: 1.5rem; margin-bottom: 1.5rem; padding-bottom: 1rem; border-bottom: 2px solid var(--gray-100); }
.form-section { margin-bottom: 1.5rem; }
.form-label { display: block; font-weight: 600; color: var(--navy); margin-bottom: 0.5rem; font-size: 0.875rem; text-transform: uppercase; letter-spacing: 0.05em; }
.form-label-sm { display: block; font-weight: 500; color: var(--gray-600); margin-bottom: 0.25rem; font-size: 0.75rem; }
.form-input, .form-textarea { width: 100%; padding: 0.75rem 1rem; border: 2px solid var(--gray-200); border-radius: var(--radius); font-family: var(--font); font-size: 1rem; transition: all 0.2s; background: var(--white); }
.form-input:focus, .form-textarea:focus { outline: none; border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(0,188,212,0.1); }
.form-textarea { resize: vertical; min-height: 100px; }
select.form-input { cursor: pointer; }

/* Client search */
.client-row { display: flex; gap: 0.5rem; align-items: flex-start; }
.search-container { flex: 1; position: relative; }
.search-dropdown { 
  position: absolute; 
  top: 100%; 
  left: 0; 
  right: 0; 
  background: var(--white); 
  border: 2px solid var(--cyan); 
  border-radius: var(--radius); 
  max-height: 300px; 
  overflow-y: auto; 
  z-index: 1000; 
  display: none; 
  box-shadow: var(--shadow-lg);
  margin-top: 4px;
}
.search-dropdown.active { display: block; }
.search-item { 
  padding: 0.75rem 1rem; 
  cursor: pointer; 
  border-bottom: 1px solid var(--gray-100); 
  transition: background 0.15s;
}
.search-item:hover { background: var(--gray-50); }
.search-item:last-child { border-bottom: none; }
.search-item-name { font-weight: 600; color: var(--navy); font-size: 0.95rem; }
.search-item-email { font-size: 0.8rem; color: var(--cyan-dark); margin-top: 2px; }
.search-item-company { font-size: 0.8rem; color: var(--gray-500); font-style: italic; }

.selected-client { 
  display: flex; 
  align-items: center; 
  gap: 0.5rem; 
  margin-top: 0.5rem; 
  padding: 0.75rem 1rem; 
  background: linear-gradient(135deg, rgba(0,188,212,0.15), rgba(0,31,63,0.08)); 
  border-radius: var(--radius); 
  border: 2px solid var(--cyan); 
}
.selected-client span { flex: 1; font-weight: 600; color: var(--navy); }
.clear-btn { background: none; border: none; color: var(--gray-500); cursor: pointer; padding: 0.25rem 0.5rem; font-size: 1.25rem; line-height: 1; border-radius: 4px; }
.clear-btn:hover { color: var(--white); background: var(--danger); }

/* Manual client */
.manual-client-section { background: var(--gray-50); padding: 1rem; border-radius: var(--radius); margin-top: 0.5rem; border: 1px solid var(--gray-200); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; }

/* Templates */
.template-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 600px) { .template-grid { grid-template-columns: 1fr; } .form-row { grid-template-columns: 1fr; } }
.template-btn { display: flex; flex-direction: column; align-items: center; padding: 1.25rem; border: 2px solid var(--gray-200); border-radius: var(--radius); background: var(--white); cursor: pointer; transition: all 0.2s; }
.template-btn:hover { border-color: var(--cyan); background: var(--gray-50); }
.template-btn.selected { border-color: var(--cyan); background: linear-gradient(135deg, rgba(0,188,212,0.1), rgba(0,31,63,0.05)); }
.template-icon { font-size: 2rem; margin-bottom: 0.5rem; }
.template-name { font-weight: 600; color: var(--navy); font-size: 0.875rem; }
.template-desc { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.25rem; text-align: center; }

/* Voice */
.voice-container { margin-bottom: 1rem; }
.voice-btn { width: 100%; display: flex; align-items: center; justify-content: center; gap: 0.75rem; padding: 1rem; background: linear-gradient(135deg, var(--navy), #003366); color: var(--white); border: none; border-radius: var(--radius); cursor: pointer; font-family: var(--font); font-size: 1rem; font-weight: 500; transition: all 0.2s; }
.voice-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.voice-btn.recording { background: linear-gradient(135deg, var(--danger), #dc2626); animation: pulse 1.5s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.8; } }
.mic-icon { font-size: 1.5rem; }
.voice-status { text-align: center; font-size: 0.875rem; color: var(--gray-500); margin-top: 0.5rem; min-height: 1.25rem; }
.voice-status.error { color: var(--danger); }
.voice-status.success { color: var(--success); }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; padding: 0.75rem 1.5rem; border: none; border-radius: var(--radius); font-family: var(--font); font-size: 1rem; font-weight: 500; cursor: pointer; transition: all 0.2s; text-decoration: none; }
.btn-primary { background: linear-gradient(135deg, var(--cyan), var(--cyan-dark)); color: var(--white); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-large { width: 100%; padding: 1rem; font-size: 1.125rem; }
.btn-icon { font-size: 1.25rem; }

/* Output */
.output-section { margin-bottom: 1.5rem; position: relative; }
.output-label { display: block; font-weight: 600; color: var(--navy); margin-bottom: 0.5rem; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
.output-body { min-height: 200px; background: var(--gray-50); }
.copy-btn { position: absolute; top: 0; right: 0; padding: 0.25rem 0.75rem; background: var(--gray-100); border: 1px solid var(--gray-200); border-radius: var(--radius); font-size: 0.75rem; cursor: pointer; transition: all 0.2s; }
.copy-btn:hover { background: var(--cyan); color: var(--white); border-color: var(--cyan); }
.output-actions { display: flex; gap: 1rem; justify-content: flex-end; }

/* Loading */
.loading-overlay { position: fixed; inset: 0; background: rgba(0,31,63,0.9); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.loading-content { text-align: center; color: var(--white); }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255,255,255,0.2); border-top-color: var(--cyan); border-radius: 50%; animation: spin 1s linear infinite; margin: 0 auto 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 768px) { .main-content { padding: 1rem; } .composer-card, .output-card { padding: 1.5rem; } .header { padding: 1rem; } .output-actions { flex-direction: column; } .output-actions .btn { width: 100%; } .client-row { flex-direction: column; } }
