:root {
  --primary: #2d6a4f;
  --primary-light: #40916c;
  --primary-dark: #1b4332;
  --accent: #52b788;
  --bg: #f8faf8;
  --card: #ffffff;
  --text: #1a1a2e;
  --muted: #6c757d;
  --border: #e8ede8;
  --shadow: 0 2px 12px rgba(0,0,0,0.08);
  --radius: 14px;
  --fab-size: 56px;
}

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

body {
  font-family: -apple-system, 'SF Pro', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0) env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

/* Screens */
.screen { display: none; min-height: 100vh; min-height: 100dvh; }
.screen.active { display: block; }

/* Loading */
.loader-container { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100vh; gap: 16px; }
.loader { width: 40px; height: 40px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Login */
.login-hero {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100vh; padding: 24px; text-align: center;
  background: linear-gradient(160deg, var(--primary-dark), var(--primary));
  color: #fff;
}
.login-hero h1 { font-size: 2.4em; margin-bottom: 8px; }
.login-hero p { opacity: 0.85; font-size: 1.1em; margin-bottom: 40px; }
.google-login-btn {
  display: flex; align-items: center; gap: 12px;
  background: #fff; color: #333; padding: 14px 28px;
  border-radius: 8px; font-size: 1em; font-weight: 500;
  cursor: pointer; box-shadow: var(--shadow);
  transition: transform 0.15s;
}
.google-login-btn:active { transform: scale(0.97); }
.apple-login-soon { margin-top: 16px; font-size: 0.8em; opacity: 0.6; color: #fff; }
.lang-switcher { margin-top: 24px; display: flex; gap: 8px; align-items: center; justify-content: center; }
.lang-btn { background: none; border: 1px solid var(--border); color: var(--text); font-size: 0.85em; cursor: pointer; padding: 6px 14px; border-radius: 16px; }
.login-hero .lang-switcher .lang-btn { border-color: rgba(255,255,255,0.4); color: #fff; }

/* Onboarding */
.onboarding { padding: 40px 24px; max-width: 400px; margin: 0 auto; text-align: center; }
.onboarding h2 { margin-bottom: 12px; }
.onboarding p { color: var(--muted); margin-bottom: 24px; }
.onboarding-options { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.onboarding input { width: 100%; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; font-size: 1em; margin-bottom: 12px; }

/* Header */
header { background: var(--card); padding: 16px 20px 0; padding-top: calc(16px + env(safe-area-inset-top, 0px)); position: sticky; top: 0; z-index: 100; border-bottom: 1px solid var(--border); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.header-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.header-top h1 { font-size: 1.4em; }
.header-actions { display: flex; gap: 8px; }
.icon-btn { background: none; border: none; font-size: 1.4em; cursor: pointer; padding: 4px; }
.back-btn { background: none; border: none; font-size: 1em; cursor: pointer; color: var(--primary); font-weight: 500; padding: 8px 0; }

/* Tabs */
.tabs { display: flex; gap: 4px; overflow-x: visible; padding-bottom: 12px; -webkit-overflow-scrolling: touch; scrollbar-width: none; flex-wrap: wrap; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 6px 12px; border-radius: 20px; border: none;
  background: var(--bg); font-size: 0.78em; font-weight: 500;
  cursor: pointer; white-space: nowrap; color: var(--muted); flex-shrink: 0;
}
.tab.active { background: var(--primary); color: #fff; }

/* Tab Dropdown */
.tab-dropdown { position: relative; flex-shrink: 0; }
.tab-dropdown-menu { display: none; position: absolute; top: 100%; left: 0; margin-top: 4px; background: var(--card); border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.2); z-index: 999; min-width: 200px; overflow: hidden; }
.tab-dropdown.open .tab-dropdown-menu { display: block; }
.tab-dropdown-menu button { display: block; width: 100%; padding: 14px 20px; border: none; background: none; text-align: left; font-size: 0.9em; cursor: pointer; border-bottom: 1px solid var(--border); }
.tab-dropdown-menu button:last-child { border-bottom: none; }
.tab-dropdown-menu button:active { background: var(--bg); }

/* Plants Grid */
.plants-grid { padding: 16px; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; padding-bottom: 80px; max-width: 800px; margin: 0 auto; }

/* Plant Card */
.plant-card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
  cursor: pointer; transition: transform 0.15s, box-shadow 0.15s;
}
.plant-card:active { transform: scale(0.97); }
.plant-card:hover { box-shadow: 0 4px 20px rgba(0,0,0,0.12); }
.plant-card img { width: 100%; height: 140px; object-fit: cover; }
.plant-card .no-photo { width: 100%; height: 140px; background: linear-gradient(135deg, #d8f3dc, #b7e4c7); display: flex; align-items: center; justify-content: center; font-size: 2.5em; }
.plant-card-info { padding: 12px 14px; }
.plant-card-info h3 { font-size: 0.9em; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plant-card-info .meta-species { font-size: 0.72em; color: var(--muted); font-style: italic; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plant-card-info .meta { font-size: 0.72em; color: var(--muted); margin-bottom: 4px; }
.plant-card-info .status { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 0.7em; font-weight: 500; }
.card-water-btn { width: 100%; padding: 8px; border: none; background: #e3f2fd; color: #1565c0; font-size: 0.8em; font-weight: 500; cursor: pointer; border-top: 1px solid var(--border); }
.card-water-btn:active { background: #bbdefb; }
.status-ok { background: #d8f3dc; color: #1b4332; }
.status-due { background: #fff3cd; color: #856404; }
.status-overdue { background: #f8d7da; color: #721c24; }

/* Notification Badge */
.notif-badge { position: absolute; top: -4px; right: -4px; background: #dc3545; color: #fff; font-size: 0.6em; width: 16px; height: 16px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; }

/* Notification Banner */
.notif-banner { background: linear-gradient(135deg, #2d6a4f, #40916c); color: #fff; padding: 12px 16px; margin: 0 16px 8px; border-radius: 10px; font-size: 0.85em; cursor: pointer; text-align: center; animation: fadeIn 0.3s; }

/* FAB */
.fab {
  position: fixed; bottom: 24px; right: 24px;
  width: var(--fab-size); height: var(--fab-size);
  border-radius: 50%; border: none;
  background: var(--primary); color: #fff;
  font-size: 1.8em; font-weight: 300;
  box-shadow: 0 4px 16px rgba(45,106,79,0.3);
  cursor: pointer; z-index: 200;
  transition: transform 0.15s;
}
.fab:active { transform: scale(0.9); }

/* Buttons */
.btn { padding: 14px 24px; border-radius: 8px; border: none; font-size: 1em; font-weight: 500; cursor: pointer; width: 100%; transition: transform 0.15s; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-secondary { background: var(--bg); color: var(--primary); border: 1px solid var(--border); }
.btn-large { padding: 18px 32px; font-size: 1.1em; }
.btn-danger { background: #dc3545; color: #fff; }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; display: flex; align-items: flex-end; justify-content: center; }
.modal.hidden { display: none; }
.modal-content { background: var(--card); border-radius: var(--radius) var(--radius) 0 0; width: 100%; max-width: 500px; max-height: 85vh; overflow-y: auto; padding: 24px; animation: slideUp 0.2s ease-out; }
@keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }

/* Identify */
.identify-container { padding: 24px; text-align: center; }
.identify-container p { color: var(--muted); margin-bottom: 16px; }
#credits-display { margin-bottom: 20px; font-size: 0.9em; color: var(--muted); }
#identify-result { margin-top: 24px; text-align: left; background: var(--bg); padding: 16px; border-radius: var(--radius); }

/* Scoreboard */
#scoreboard-content { padding: 20px; }
.score-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.score-card .name { font-weight: 600; }
.score-card .points { font-size: 1.4em; font-weight: 700; color: var(--primary); }

/* Settings */
#settings-content { padding: 20px; }
.settings-section { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.settings-section h3 { margin-bottom: 12px; font-size: 0.95em; }
.invite-code { font-size: 1.8em; font-weight: 700; letter-spacing: 4px; color: var(--primary); text-align: center; padding: 16px; }

/* Utility */
/* Tutorial */
.tutorial { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 40px 24px; }
.tutorial-slides { width: 100%; max-width: 360px; position: relative; min-height: 280px; }
.tutorial-slide { display: none; text-align: center; animation: fadeIn 0.3s ease; }
.tutorial-slide.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.tutorial-icon { font-size: 4em; margin-bottom: 20px; }
.tutorial-slide h2 { font-size: 1.4em; margin-bottom: 12px; }
.tutorial-slide p { color: var(--muted); font-size: 1em; line-height: 1.5; }
.tutorial-dots { display: flex; gap: 8px; margin: 24px 0; }
.tutorial-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--border); transition: all 0.2s; }
.tutorial-dot.active { background: var(--primary); width: 24px; border-radius: 4px; }
.tutorial-actions { display: flex; gap: 12px; width: 100%; max-width: 360px; }
.tutorial-actions .btn { flex: 1; }

/* Help/FAQ */
.help-content { padding: 20px; }
.faq-item { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.faq-item h3 { font-size: 0.95em; margin-bottom: 6px; }
.faq-item p { font-size: 0.85em; color: var(--muted); line-height: 1.5; }
.faq-item a { color: var(--primary); }
.faq-item.contact { border-left: 3px solid var(--primary); }

/* Fertilizer Groups */
.fert-group { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; }
.fert-group-header h3 { font-size: 0.95em; margin-bottom: 4px; }
.fert-group-recipe { font-size: 0.8em; color: var(--primary); font-weight: 500; margin-bottom: 10px; padding: 6px 10px; background: #f0fdf4; border-radius: 6px; }
.fert-group-plants { display: flex; flex-direction: column; gap: 4px; }
.fert-plant-row { display: flex; justify-content: space-between; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.85em; }
.fert-plant-row:last-child { border: none; }

/* Room Filters */
.room-filters-wrapper { position: relative; }
.room-filters { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 12px; scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-behavior: smooth; }
.room-filters::-webkit-scrollbar { display: none; }
.room-arrow { position: absolute; top: 50%; transform: translateY(-50%); background: var(--card); border: 1px solid var(--border); border-radius: 50%; width: 24px; height: 24px; display: none; align-items: center; justify-content: center; cursor: pointer; z-index: 10; font-size: 0.75em; box-shadow: 0 2px 6px rgba(0,0,0,0.1); }
.room-filters-wrapper:hover .room-arrow { display: flex; }
.room-arrow-left { left: -4px; }
.room-arrow-right { right: -4px; }
@media (max-width: 600px) { .room-arrow { display: none !important; } }
.room-chip {
  padding: 6px 14px; border-radius: 16px; border: 1px solid var(--border);
  background: var(--bg); font-size: 0.8em; font-weight: 500;
  cursor: pointer; white-space: nowrap; color: var(--muted); flex-shrink: 0;
}
.room-chip.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Detail Page */
.detail-hero img { width: 100%; height: 240px; object-fit: cover; }
.detail-no-photo { width: 100%; height: 200px; background: linear-gradient(135deg, #d8f3dc, #b7e4c7); display: flex; align-items: center; justify-content: center; font-size: 4em; }
.detail-body { padding: 20px; max-width: 600px; margin: 0 auto; }
.detail-body h2 { font-size: 1.5em; margin-bottom: 4px; }
.detail-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 10px; margin: 16px 0; }
.stat-card { background: var(--bg); border-radius: 10px; padding: 12px; text-align: center; display: flex; flex-direction: column; gap: 2px; }
.stat-icon { font-size: 1.4em; }
.stat-value { font-size: 1.2em; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.7em; color: var(--muted); }
.detail-warning { background: #fff3cd; color: #856404; padding: 8px 12px; border-radius: 8px; font-size: 0.85em; margin: 8px 0; }
.detail-notes { background: var(--bg); padding: 10px 12px; border-radius: 8px; font-size: 0.85em; color: var(--muted); margin: 8px 0; font-style: italic; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0; }
.detail-actions .btn { flex: 1; min-width: 140px; }
.detail-history { margin-top: 24px; }
.detail-history h3 { margin-bottom: 12px; font-size: 1em; }

/* History List */
.history-list { display: flex; flex-direction: column; gap: 8px; }
.history-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--bg); border-radius: 8px; }
.history-icon { font-size: 1.2em; }
.history-info { flex: 1; display: flex; flex-direction: column; }
.history-action { font-size: 0.85em; font-weight: 500; }
.history-by { font-size: 0.75em; color: var(--muted); }
.history-date { font-size: 0.75em; color: var(--muted); white-space: nowrap; }

/* Products */
.products-content { padding: 16px; max-width: 600px; margin: 0 auto; padding-bottom: 80px; }
.product-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; margin-bottom: 12px; display: flex; cursor: pointer; transition: transform 0.15s; }
.product-card:active { transform: scale(0.98); }
.product-card img { width: 80px; height: 80px; object-fit: cover; }
.product-no-photo { width: 80px; height: 80px; background: linear-gradient(135deg, #e8f5e9, #c8e6c9); display: flex; align-items: center; justify-content: center; font-size: 1.8em; flex-shrink: 0; }
.product-info { padding: 12px; flex: 1; }
.product-info h3 { font-size: 0.9em; margin-bottom: 4px; }
.product-meta { font-size: 0.75em; color: var(--muted); }
.product-season { font-size: 0.72em; color: var(--primary); margin-top: 4px; }

/* Fertilizer Recipes */
.fertilizer-content { padding: 16px; max-width: 600px; margin: 0 auto; }
.recipe-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 16px; }
.recipe-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.recipe-header h3 { font-size: 0.95em; }
.recipe-dilution { font-size: 0.75em; background: var(--accent); color: #fff; padding: 3px 8px; border-radius: 10px; }
.recipe-summary { display: flex; gap: 12px; margin-bottom: 12px; padding: 10px; background: #f0fdf4; border-radius: 8px; }
.recipe-stat { flex: 1; text-align: center; }
.recipe-stat-value { display: block; font-size: 1.1em; font-weight: 700; color: var(--primary); }
.recipe-stat-label { font-size: 0.7em; color: var(--muted); }
.recipe-plants { border-top: 1px solid var(--border); padding-top: 10px; }
.recipe-plant { display: flex; justify-content: space-between; padding: 4px 0; font-size: 0.85em; }
.recipe-dose { color: var(--primary); font-weight: 500; }

/* Calendar */
.calendar-content { padding: 16px; max-width: 600px; margin: 0 auto; }
.calendar-day { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.calendar-day.today { background: #f0fdf4; margin: 0 -16px; padding: 12px 16px; border-radius: 8px; }
.calendar-date { display: flex; flex-direction: column; align-items: center; min-width: 48px; }
.day-name { font-size: 0.7em; color: var(--muted); text-transform: uppercase; }
.day-number { font-size: 1.3em; font-weight: 700; color: var(--primary); }
.day-month { font-size: 0.7em; color: var(--muted); }
.calendar-plants { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.calendar-plant { display: flex; justify-content: space-between; align-items: center; padding: 6px 10px; background: var(--card); border-radius: 6px; font-size: 0.85em; }
.calendar-plant.overdue { background: #fff3cd; border-left: 3px solid #ffc107; }
.calendar-room { font-size: 0.75em; color: var(--muted); }

/* Tips Page */
.tips-content { padding: 16px; max-width: 600px; margin: 0 auto; }
.tip-card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px; display: flex; gap: 12px; align-items: flex-start; }
.tip-icon { font-size: 1.6em; flex-shrink: 0; margin-top: 2px; }
.tip-card h3 { font-size: 0.9em; margin-bottom: 4px; }
.tip-card p { font-size: 0.82em; color: var(--muted); line-height: 1.5; }

/* Modal Inputs */
.modal-input { width: 100%; padding: 12px 14px; margin: 6px 0; border: 1px solid var(--border); border-radius: 8px; font-size: 0.95em; background: var(--bg); }
.modal-input:focus { outline: none; border-color: var(--primary); }
select.modal-input { background: var(--bg); }
textarea.modal-input { resize: vertical; font-family: inherit; }

/* Rooms list in settings */
.rooms-list { display: flex; flex-direction: column; gap: 6px; }
.room-row { display: flex; justify-content: space-between; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.room-row:last-child { border: none; }

/* Header More Menu */
.header-more { position: relative; }
.header-more-menu { display: none; position: absolute; top: 100%; right: 0; background: var(--card); border-radius: 10px; box-shadow: 0 4px 20px rgba(0,0,0,0.15); padding: 6px 0; min-width: 160px; z-index: 100; }
.header-more.open .header-more-menu { display: block; }
.header-more-menu button { display: block; width: 100%; text-align: left; padding: 10px 16px; border: none; background: none; font-size: 0.9em; cursor: pointer; }
.header-more-menu button:hover { background: var(--bg); }

/* Family Wall */
.wall-content { padding: 0 16px 16px; }
.wall-input { display: flex; gap: 8px; padding: 12px 0; position: sticky; top: 0; background: var(--bg); z-index: 5; }
.wall-messages { display: flex; flex-direction: column; gap: 8px; }
.wall-msg { background: var(--card); border-radius: 12px; padding: 10px 14px; box-shadow: var(--shadow); }
.wall-msg-mine { background: #f0fdf4; }
.wall-msg-header { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.wall-msg-body { font-size: 0.9em; line-height: 1.4; padding-left: 36px; }

/* Rewards */
.rewards-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reward-card { display: flex; align-items: center; gap: 10px; background: var(--card); padding: 12px; border-radius: 10px; box-shadow: var(--shadow); }
.reward-icon { font-size: 24px; }
.reward-info { display: flex; flex-direction: column; }
.reward-info strong { font-size: 0.8em; }
.reward-info span { font-size: 0.7em; color: var(--muted); }
.rewards-history { display: flex; flex-direction: column; gap: 6px; }
.reward-history-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 0.85em; }
.reward-history-item:last-child { border: none; }

.hidden { display: none !important; }
.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt-12 { margin-top: 12px; }
.mb-12 { margin-bottom: 12px; }
