* { margin:0; padding:0; box-sizing:border-box; }

:root {
  --primary: #4CAF50;
  --primary-dark: #388E3C;
  --primary-light: #C8E6C9;
  --secondary: #2196F3;
  --accent: #FF9800;
  --danger: #f44336;
  --success: #4CAF50;
  --bg: #f0f4f0;
  --bg-card: #ffffff;
  --text: #1a1a1a;
  --text-secondary: #555;
  --text-light: #888;
  --border: #ddd;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 4px 20px rgba(0,0,0,0.12);
  --radius: 16px;
  --radius-sm: 10px;
}

body {
  font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* ===== НАВИГАЦИЯ ===== */
.nav {
  background: white;
  box-shadow: 0 1px 4px rgba(0,0,0,0.1);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 16px;
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.nav-logo { display:flex; align-items:center; gap:8px; font-size:18px; font-weight:700; color:var(--primary); text-decoration:none; cursor:pointer; }
.nav-logo span { font-size:24px; }
.nav-links { display:flex; gap:2px; align-items:center; }
.nav-link {
  display:inline-flex; align-items:center; justify-content:center;
  width:44px; height:44px; border-radius:12px;
  color:var(--text-secondary); text-decoration:none;
  font-size:22px; cursor:pointer; transition:all 0.2s;
}
.nav-link:hover, .nav-link.active { background:var(--primary-light); color:var(--primary-dark); }
.nav-link { -webkit-tap-highlight-color: transparent; user-select: none; }
.nav-user { display:flex; align-items:center; gap:8px; font-size:14px; color:var(--text-secondary); }
.avatar {
  width:40px; height:40px; border-radius:50%;
  background:var(--primary-light); color:var(--primary-dark);
  display:flex; align-items:center; justify-content:center;
  font-weight:700; font-size:18px; flex-shrink:0;
}

/* ===== ОСНОВНОЙ КОНТЕЙНЕР ===== */
.container { max-width: 900px; margin:0 auto; padding:0 16px; }
.view { padding:16px 0; }

/* ===== КНОПКИ ===== */
button { cursor:pointer; border:none; font-family:inherit; transition:all 0.2s; border-radius:var(--radius-sm); }
.btn {
  display:inline-flex; align-items:center; justify-content:center; gap:8px;
  padding:14px 24px; border-radius:var(--radius-sm); font-weight:600;
  font-size:16px; border:none; cursor:pointer;
}
.btn-primary { background:var(--primary); color:white; }
.btn-primary:hover { background:var(--primary-dark); transform:translateY(-1px); box-shadow:0 4px 12px rgba(76,175,80,0.3); }
.btn-secondary { background:var(--secondary); color:white; }
.btn-secondary:hover { background:#1976D2; transform:translateY(-1px); }
.btn-danger { background:var(--danger); color:white; }
.btn-danger:hover { background:#d32f2f; }
.btn-success { background:var(--success); color:white; }
.btn-outline { background:transparent; border:2px solid var(--border); color:var(--text); }
.btn-outline:hover { border-color:var(--primary); color:var(--primary); }
.btn-sm { padding:10px 16px; font-size:14px; }
.btn-big { padding:18px 32px; font-size:20px; border-radius:14px; width:100%; max-width:320px; }

/* ===== КАРТОЧКИ ===== */
.card {
  background:var(--bg-card); border-radius:var(--radius);
  box-shadow:var(--shadow); padding:20px; margin-bottom:16px;
}

/* ===== ПРИВЕТСТВИЕ ===== */
.welcome { text-align:center; padding:40px 0; }
.welcome-header { margin-bottom:32px; }
.welcome-icon { font-size:80px; margin-bottom:16px; }
.welcome-header h1 { font-size:36px; color:var(--text); margin-bottom:8px; }
.welcome-header p { font-size:18px; color:var(--text-secondary); }
.welcome-buttons { display:flex; flex-direction:column; align-items:center; gap:16px; margin-bottom:40px; }
.welcome-features { display:flex; flex-direction:column; gap:12px; max-width:500px; margin:0 auto; }
.feature-card {
  display:flex; align-items:center; gap:16px; background:white;
  padding:16px 20px; border-radius:var(--radius); box-shadow:var(--shadow);
  text-align:left; font-size:16px;
}
.feature-icon { font-size:36px; }

/* ===== ЗАГОЛОВОК СТРАНИЦЫ ===== */
.page-header {
  display:flex; align-items:center; justify-content:space-between;
  margin-bottom:16px; padding:8px 0;
}
.page-header h1 { font-size:24px; }

/* ===== СТАТИСТИКА ===== */
.stats-row { display:flex; gap:12px; margin-bottom:16px; flex-wrap:wrap; }
.stat-card {
  flex:1; min-width:100px; background:white; border-radius:var(--radius-sm);
  box-shadow:var(--shadow); padding:16px; text-align:center;
  font-size:14px; color:var(--text-secondary);
}
.stat-num { display:block; font-size:32px; font-weight:700; color:var(--primary); margin-bottom:4px; }

/* ===== СПИСОК ПОКАЗАНИЙ ===== */
.reading-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 0; border-bottom:1px solid var(--border); gap:12px;
}
.reading-item:last-child { border-bottom:none; }
.reading-value { font-size:20px; font-weight:700; color:var(--primary); margin-left:8px; }
.reading-meta { display:flex; align-items:center; gap:8px; flex-shrink:0; }

/* ===== МЕДИКАМЕНТЫ ===== */
.med-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 0; border-bottom:1px solid var(--border); gap:12px;
}
.med-item:last-child { border-bottom:none; }
.med-actions { display:flex; gap:6px; flex-shrink:0; }

/* ===== СЕМЬЯ ===== */
.family-item {
  display:flex; align-items:center; justify-content:space-between;
  padding:10px 0; border-bottom:1px solid var(--border); gap:12px;
}
.family-item > div:first-child { display:flex; align-items:center; gap:12px; flex:1; }

/* ===== МОДАЛЬНОЕ ОКНО ===== */
.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:1000; padding:20px;
}
.modal {
  background:white; border-radius:var(--radius); padding:28px;
  width:100%; max-width:480px; max-height:85vh; overflow-y:auto;
  box-shadow:0 10px 40px rgba(0,0,0,0.2);
}
.modal h2 { margin-bottom:16px; font-size:22px; }
.modal input, .modal select, .modal textarea {
  width:100%; padding:14px 16px; border:2px solid var(--border);
  border-radius:var(--radius-sm); font-size:16px; font-family:inherit;
  background:white; transition:border-color 0.2s;
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline:none; border-color:var(--primary);
}
.form-error { color:var(--danger); font-size:14px; margin:8px 0; display:none; }

/* ===== ЧЕКБОКСЫ ДНЕЙ ===== */
.day-cb {
  display:flex; align-items:center; gap:4px; cursor:pointer;
  padding:8px 12px; border:1px solid var(--border); border-radius:8px;
  font-size:14px; user-select:none;
}
.day-cb input { width:auto; padding:0; margin:0; }
.day-cb:has(input:checked) { background:var(--primary-light); border-color:var(--primary); }

/* ===== TOAST ===== */
.toast {
  position:fixed; bottom:20px; left:50%; transform:translateX(-50%);
  background:#323232; color:white; border-radius:12px;
  padding:16px 24px; font-size:16px; z-index:2000;
  animation:slideUp 0.3s ease; white-space:nowrap;
  box-shadow:0 4px 20px rgba(0,0,0,0.2);
}
.toast.success { background:var(--primary); }
.toast.error { background:var(--danger); }
@keyframes slideUp { from { transform:translateX(-50%) translateY(100px); opacity:0; } to { transform:translateX(-50%) translateY(0); opacity:1; } }

/* ===== СТАТУСЫ ===== */
.status { display:inline-flex; align-items:center; gap:4px; padding:4px 12px; border-radius:20px; font-size:13px; font-weight:600; }
.status-good { background:#e8f5e9; color:#2e7d32; }
.status-warning { background:#fff3e0; color:#e65100; }
.status-bad { background:#ffebee; color:#c62828; }

.health-warning-card {
  background: #fffdf7;
  border: 1px solid #f2d79c;
  border-radius: 14px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.health-warning-card.critical {
  background: #fff4f4;
  border-color: #f3b0b0;
}

.health-warning-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.health-warning-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.health-warning-message {
  color: var(--text);
  margin-bottom: 8px;
}

.health-warning-advice {
  color: var(--text-secondary);
  font-size: 14px;
}

.ai-chat-empty {
  text-align: center;
  color: var(--text-light);
  padding: 20px 0;
  font-size: 14px;
}

.ai-chat-bubble {
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 10px;
  max-width: 88%;
}

.ai-chat-bubble.assistant {
  background: #f3f6f8;
  color: var(--text);
}

.ai-chat-bubble.assistant.warning {
  background: #fff3e0;
}

.ai-chat-bubble.user {
  background: var(--primary-light);
  margin-left: auto;
  color: var(--text);
}

.ai-chat-role {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

/* ===== AI FAB КНОПКА ===== */
.ai-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}
.ai-fab:hover {
  transform: scale(1.1);
}

/* ===== ПУСТОЕ СОСТОЯНИЕ ===== */
.empty-state { text-align:center; padding:40px 20px; color:var(--text-light); }
.empty-state span { font-size:48px; display:block; margin-bottom:12px; }
.empty-state h3 { color:var(--text); margin-bottom:8px; }

/* ===== СПИННЕР ===== */
.spinner {
  width:40px; height:40px; border:4px solid #e0e0e0;
  border-top-color:var(--primary); border-radius:50%;
  animation:spin 0.8s linear infinite;
}
@keyframes spin { to { transform:rotate(360deg); } }

/* ===== АДАПТИВНОСТЬ ===== */
@media (max-width: 1024px) {
  .nav-link { padding:8px 10px; font-size:14px; }
  .page-header h1 { font-size:20px; }
  .stats-row { flex-wrap:wrap; }
}

@media (max-width: 768px) {
  .nav-inner { height:auto; padding:6px 0; flex-wrap:wrap; gap:4px; }
  .nav-links { width:100%; justify-content:space-around; padding:2px 0; }
  .nav-link { width:40px; height:40px; font-size:20px; }
  .nav-user { width:100%; justify-content:flex-end; padding:2px 0; }
  .page-header { flex-direction:column; gap:12px; align-items:flex-start; }
  .page-header h1 { font-size:20px; }
  .stat-num { font-size:24px; }
  .welcome-header h1 { font-size:26px; }
  .btn-big { max-width:100%; }
  .stats-row { flex-direction:column; }
  .stat-card { min-width:auto; }
  .modal { padding:20px; }
}

@media (max-width: 480px) {
  .nav-logo span:last-child { display:none; }
  .nav-link { width:36px; height:36px; font-size:18px; }
  .ai-fab { width:48px; height:48px; bottom:16px; right:16px; font-size:20px; }
}
