/* === Базовые переменные и сброс === */
:root {
  --bg: #f4f1ea;
  --surface: #ffffff;
  --surface-2: #faf7f0;
  --text: #20302a;
  --text-soft: #5b6b65;
  --muted: #93a39b;
  --primary: #3a8a5d;
  --primary-soft: #d9ecdf;
  --accent: #c98a5a;
  --warn: #d39b46;
  --danger: #c75450;
  --border: #e2ddd1;
  --shadow: 0 8px 24px rgba(40, 60, 50, 0.08);
  --shadow-soft: 0 2px 8px rgba(40, 60, 50, 0.05);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-lg: 24px;
  --ok: #4ca776;
  --soon: #c69538;
  --today: #d77a3a;
  --overdue: #c75450;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display",
    "PT Sans", "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  min-height: 100vh;
  -webkit-text-size-adjust: 100%;
}

body {
  background:
    radial-gradient(circle at 0% 0%, rgba(58, 138, 93, 0.05), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(201, 138, 90, 0.06), transparent 45%),
    var(--bg);
  background-attachment: fixed;
}

button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
}

input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
}

a {
  color: var(--primary);
}

.hidden {
  display: none !important;
}

/* === Экран авторизации === */
.screen-auth {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.auth-logo {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 12px;
}

.logo-leaf {
  font-size: 36px;
}

.auth-title {
  text-align: center;
  font-size: 26px;
  margin: 0;
  font-weight: 700;
}

.auth-subtitle {
  text-align: center;
  margin: 4px 0 24px;
  color: var(--text-soft);
  font-size: 14px;
}

.auth-tabs {
  display: flex;
  background: var(--surface-2);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 20px;
}

.tab-btn {
  min-height: 44px;
  flex: 1;
  padding: 10px;
  border: 0;
  background: transparent;
  border-radius: 10px;
  color: var(--text-soft);
  font-weight: 600;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: var(--shadow-soft);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
}

.field input, .field select, .field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px;
  outline: none;
  transition: border-color 0.15s, background 0.15s;
  min-height: 44px;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary);
  background: var(--surface);
}

.field textarea {
  min-height: 80px;
  resize: vertical;
}

.auth-error {
  font-size: 13px;
  color: var(--danger);
  min-height: 16px;
}

.primary-btn {
  background: var(--primary);
  color: white;
  border: 0;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 600;
  min-height: 48px;
  transition: background 0.15s, transform 0.05s;
}

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

.primary-btn:disabled {
  background: var(--muted);
  cursor: not-allowed;
}

.secondary-btn {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 500;
  min-height: 44px;
}

.danger-btn {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  min-height: 44px;
}

/* === Основное приложение === */
.screen-main {
  min-height: 100vh;
  padding-bottom: 80px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(244, 241, 234, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-title {
  font-weight: 700;
  font-size: 18px;
}

.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.main {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}

.section-title {
  font-size: 22px;
  font-weight: 700;
  margin: 8px 0 16px;
}

.section-subtitle {
  color: var(--text-soft);
  font-size: 14px;
  margin: 0 0 16px;
}

/* === Нижняя навигация === */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  z-index: 40;
}

.nav-btn {
  background: transparent;
  border: 0;
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--text-soft);
  font-size: 11px;
  border-radius: 10px;
  min-height: 56px;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-icon {
  font-size: 22px;
}

/* === Главная: сводка === */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--border);
}

.summary-card .num {
  font-size: 28px;
  font-weight: 700;
  display: block;
}

.summary-card .label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.summary-card.today .num   { color: var(--today); }
.summary-card.overdue .num { color: var(--overdue); }
.summary-card.soon .num    { color: var(--soon); }
.summary-card.total .num   { color: var(--primary); }

.upcoming-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upcoming-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.upcoming-item .meta {
  font-size: 12px;
  color: var(--text-soft);
}

/* === Карточки растений === */
.plant-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  gap: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
  margin-bottom: 10px;
  cursor: pointer;
  transition: transform 0.06s;
}

.plant-card:active {
  transform: scale(0.99);
}

.plant-card .photo {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary-soft), #efe9d8);
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.plant-card .info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.plant-card .name {
  font-weight: 700;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.plant-card .species {
  color: var(--text-soft);
  font-size: 13px;
}

.plant-card .next {
  font-size: 12px;
  color: var(--text-soft);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--primary-soft);
  color: var(--primary);
  align-self: flex-start;
}

.status-pill.ok       { background: var(--primary-soft); color: var(--ok); }
.status-pill.soon     { background: #f7e9c8; color: var(--soon); }
.status-pill.today    { background: #fbd9c4; color: var(--today); }
.status-pill.overdue  { background: #f6caca; color: var(--overdue); }

/* === Список растений: фильтры === */
.plants-toolbar {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.plants-toolbar input[type="search"],
.plants-toolbar select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  min-height: 44px;
}

.plants-toolbar input[type="search"] {
  flex: 1;
  min-width: 160px;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 80px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 0;
  background: var(--primary);
  color: white;
  font-size: 28px;
  box-shadow: 0 8px 20px rgba(58, 138, 93, 0.4);
  z-index: 30;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* === Пустые состояния === */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
  color: var(--text-soft);
}

.empty-state .emoji {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.empty-state h3 {
  margin: 4px 0 6px;
  color: var(--text);
}

/* === Модалка и форма растения === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 25, 0.4);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: relative;
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 16px 16px 24px;
  width: 100%;
  max-width: 720px;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 -8px 30px rgba(20, 30, 25, 0.2);
  animation: slideUp 0.18s ease-out;
}

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

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

.form-actions {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.form-actions button {
  flex: 1;
}

/* === Карточка растения: подробно === */
.plant-hero {
  height: 220px;
  border-radius: 16px;
  background-size: cover;
  background-position: center;
  background-color: var(--primary-soft);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 80px;
}

.plant-name {
  font-size: 22px;
  font-weight: 700;
  margin: 0;
}

.plant-species {
  color: var(--text-soft);
  margin: 2px 0 12px;
}

.watering-card {
  background: linear-gradient(135deg, #e6f2eb, #f7f1e1);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}

.watering-card .label {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.watering-card .date {
  font-size: 18px;
  font-weight: 700;
  margin-top: 4px;
}

.watering-card .amount {
  font-size: 14px;
  color: var(--text-soft);
  margin-top: 4px;
}

.watering-card .explanation {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 8px;
  line-height: 1.5;
}

.watering-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.water-amount-input {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border-radius: 12px;
  padding: 6px 8px;
  border: 1px solid var(--border);
}

.water-amount-input input {
  width: 70px;
  border: 0;
  background: transparent;
  text-align: center;
  outline: none;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.quick-action {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text);
  min-height: 76px;
}

.quick-action .icon {
  font-size: 22px;
}

.tabs-row {
  display: flex;
  gap: 6px;
  margin: 14px 0 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.tab-pill {
  background: transparent;
  border: 0;
  padding: 10px 14px;
  border-bottom: 2px solid transparent;
  color: var(--text-soft);
  font-weight: 600;
  white-space: nowrap;
}

.tab-pill.active {
  color: var(--primary);
  border-color: var(--primary);
}

.info-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.info-item {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 12px;
}

.info-item .label {
  font-size: 11px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.info-item .value {
  font-size: 15px;
  font-weight: 600;
  margin-top: 4px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.history-item {
  background: var(--surface);
  border-radius: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.history-item .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.history-item .badge {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.history-item .date {
  font-size: 12px;
  color: var(--text-soft);
}

/* === Календарь === */
.calendar-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.calendar-day {
  background: var(--surface);
  border-radius: 14px;
  padding: 12px;
  border: 1px solid var(--border);
}

.calendar-day .day-title {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
}

.calendar-day .day-title.today-label {
  color: var(--primary);
}

.calendar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.calendar-item:first-of-type {
  border-top: 0;
}

.calendar-item .badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.calendar-item .badge.fertilizing  { background: #f6e8c4; }
.calendar-item .badge.repotting   { background: #e9e1cf; }
.calendar-item .badge.misting     { background: #dceaf2; }
.calendar-item .badge.pruned      { background: #ece4d2; }
.calendar-item .badge.pestTreated { background: #f1d3cb; }
.calendar-item .badge.rotated     { background: #e3ecd6; }
.calendar-item .badge.note        { background: #ece6d8; }

.calendar-item .meta {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-soft);
}

/* === Профиль === */
.profile-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
  margin-bottom: 16px;
}

.profile-card .name {
  font-size: 18px;
  font-weight: 700;
}

.profile-card .email {
  color: var(--text-soft);
  font-size: 14px;
}

.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* === Тост === */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(20, 30, 25, 0.92);
  color: white;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 60;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.show {
  opacity: 1;
}

/* === Загрузка === */
.loader-overlay {
  position: fixed;
  inset: 0;
  background: rgba(244, 241, 234, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
}

.loader-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--primary-soft);
  border-top-color: var(--primary);
  animation: spin 0.9s linear infinite;
}

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

/* === Адаптив для больших экранов === */
@media (min-width: 768px) {
  .main { padding: 24px; }
  .summary-grid { grid-template-columns: repeat(4, 1fr); }
  .form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 380px) {
  .quick-actions { grid-template-columns: repeat(3, 1fr); }
  .info-list { grid-template-columns: 1fr; }
}

/* Keep the welcome photo and form within a phone screen. */
.screen-auth { flex-direction: column; gap: 0; padding: 20px; }
.auth-hero { width: 100%; max-width: 420px; height: 180px; overflow: hidden; border-radius: 24px 24px 0 0; flex: none; }
.auth-hero-img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-card { min-width: 0; border-radius: 0 0 24px 24px; }
.auth-hero-overlay { display: none; }
@media (max-width: 480px) { .auth-card { padding: 24px 20px; } }

/* === Восстановление пароля: ссылка и подсказки === */
.auth-row {
  display: flex;
  justify-content: flex-end;
  margin-top: -4px;
}

.link-btn {
  background: transparent;
  border: 0;
  padding: 6px 0;
  color: var(--primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  min-height: 44px;
}

.link-btn:hover,
.link-btn:focus {
  text-decoration: underline;
  outline: none;
}

.modal-hint {
  color: var(--text-soft);
  font-size: 13px;
  line-height: 1.5;
  margin: 0 0 8px;
}

.dev-code-hint {
  background: #fff7e0;
  border: 1px dashed var(--warn);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  color: #7a5a1a;
  margin-bottom: 4px;
  word-break: break-all;
}

/* Keep phone form controls within the modal columns. */
.form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { min-width: 0; }
.field input, .field select, .field textarea { min-width: 0; max-width: 100%; width: 100%; box-sizing: border-box; }
