:root {
  /* Светлая тема по умолчанию */
  --bg: #f3f4f6;
  --bg-soft: #e0f2fe;
  --card-bg: rgba(255, 255, 255, 0.96);
  --border: #e5e7eb;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --orange: #f97316;
  --orange-soft: #ffedd5;
  --text-main: #111827;
  --text-muted: #6b7280;
  --nav-bg: rgba(255, 255, 255, 0.85);
  --nav-border: rgba(148, 163, 184, 0.6);
  --nav-shadow: 0 18px 40px rgba(15, 23, 42, 0.35);
}

/* Тёмная тема: переопределяем переменные */
.theme-dark {
  --bg: #020617;
  --bg-soft: #0f172a;
  --card-bg: rgba(15, 23, 42, 0.98);
  --border: #1f2937;
  --blue: #3b82f6;
  --blue-soft: #1e3a8a;
  --orange: #fb923c;
  --orange-soft: #7c2d12;
  --text-main: #e5e7eb;
  --text-muted: #9ca3af;
  --nav-bg: rgba(15, 23, 42, 0.92);
  --nav-border: rgba(30, 64, 175, 0.8);
  --nav-shadow: 0 18px 40px rgba(0, 0, 0, 0.75);
}

/* Сброс */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  background: radial-gradient(circle at top, var(--bg-soft), var(--bg));
  color: var(--text-main);
}

.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Шапка */

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid rgba(209, 213, 219, 0.9);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
}

.theme-dark .app-header {
  border-bottom-color: rgba(15, 23, 42, 0.9);
  background: rgba(3, 7, 18, 0.9);
}

.logo {
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--blue);
  font-size: 0.9rem;
}

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

.user-info {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* Основное содержимое */

.app-main {
  flex: 1;
  padding: 20px 16px 96px; /* запас снизу под нижний бар */
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

/* Карточки */

.card {
  background: var(--card-bg);
  border-radius: 18px;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
}

.card h2 {
  margin: 0 0 12px 0;
  font-size: 1.05rem;
}

/* Авторизация — центр */

.auth-card {
  max-width: 520px;
  margin: 40px auto 0;
  text-align: left;
}

.auth-title {
  margin: 0 0 4px;
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-subtitle {
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* Сетка после входа */

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr);
  grid-template-rows: auto auto;
  gap: 16px;
}

#profileCard {
  grid-column: 1 / 2;
  grid-row: 1 / 2;
}

#entryCard {
  grid-column: 1 / 2;
  grid-row: 2 / 3;
}

#chartCard {
  grid-column: 2 / 3;
  grid-row: 1 / 2;
}

#historyCard {
  grid-column: 2 / 3;
  grid-row: 2 / 3;
}

/* Формы */

.form-group {
  margin-bottom: 12px;
}

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

.form-row .form-group {
  flex: 1;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 4px;
}

input,
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text-main);
  font: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease,
    background-color 0.12s ease;
}

.theme-dark input,
.theme-dark select,
.theme-dark textarea {
  background: #020617;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

textarea {
  resize: vertical;
}

/* Вопросы */

.section-title {
  margin: 12px 0 6px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--blue);
}

.question-block {
  margin-bottom: 10px;
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}

.question-text {
  margin: 0 0 6px;
  font-size: 0.85rem;
}

.question-scale {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Кнопки */

.btn {
  border-radius: 999px;
  border: none;
  padding: 8px 14px;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.05s ease,
    box-shadow 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--blue);
  color: #f9fafb;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-secondary {
  background: var(--bg-soft);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: #dde4ee;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding-inline: 12px;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.6);
}

.theme-dark .btn-outline:hover {
  background: rgba(15, 23, 42, 0.9);
}

/* Кнопка иконки темы */

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 8px;
  border-radius: 999px;
  background: var(--blue-soft);
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.btn-icon:hover {
  background: #bfdbfe;
}

.theme-dark .btn-icon:hover {
  background: #1e293b;
}

.full-width {
  width: 100%;
}

/* Tabs */

.tabs {
  display: flex;
  margin-bottom: 12px;
  border-radius: 999px;
  padding: 4px;
  background: var(--bg-soft);
}

.tab {
  flex: 1;
  padding: 6px 10px;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
}

.tab.active {
  background: var(--card-bg);
  color: var(--text-main);
}

/* Контент вкладок */

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Range */

.range-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="range"] {
  flex: 1;
}

.range-value {
  min-width: 28px;
  text-align: center;
  font-weight: 600;
  color: var(--orange);
}

/* Таблица */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table th {
  text-align: left;
  color: var(--text-muted);
  font-weight: 500;
}

.data-table tr:last-child td {
  border-bottom: none;
}

/* Сообщения */

.error-msg {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #dc2626;
}

.success-msg {
  margin-top: 8px;
  font-size: 0.85rem;
  color: #16a34a;
}

/* Скрытие */

.hidden {
  display: none !important;
}

/* Нижний liquid glass бар */

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 16px 18px;
  display: flex;
  justify-content: center;
  z-index: 30;
  pointer-events: none;
}

.bottom-nav-inner {
  pointer-events: auto;
  max-width: 480px;
  width: 100%;
  display: flex;
  gap: 6px;
  background: var(--nav-bg);
  border-radius: 999px;
  backdrop-filter: blur(22px);
  box-shadow: var(--nav-shadow);
  border: 1px solid var(--nav-border);
  padding: 6px;
}

.nav-btn {
  flex: 1;
  border-radius: 999px;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 0.75rem;
  padding: 6px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
}

.nav-btn:hover {
  background: var(--blue-soft);
}

.nav-icon {
  font-size: 1.1rem;
}

.nav-label {
  font-size: 0.7rem;
}

/* Адаптив */

@media (max-width: 800px) {
  .app-main {
    padding: 16px 10px 96px;
  }

  .auth-card {
    margin-top: 24px;
  }

  .app-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .bottom-nav-inner {
    max-width: 100%;
  }
}
