* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "clig" 0;
}

:root {
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-light: #d1fae5;
  --primary-grad: linear-gradient(135deg, #34d399, #059669);
  --bg: #f3f6f8;
  --card: #ffffff;
  --text: #0f172a;
  --text-light: #64748b;
  --border: #e5e9ee;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --radius-lg: 1.25rem;
  --radius: 0.9rem;
  --radius-sm: 0.6rem;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 4px 16px -4px rgba(15, 23, 42, 0.08), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 40px -12px rgba(15, 23, 42, 0.18);
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --bg-glow-1: #ecfdf5;
  --bg-glow-2: #eff6ff;
  --header-bg: rgba(255, 255, 255, 0.75);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #34d399;
    --primary-dark: #10b981;
    --primary-light: #0d3b2e;
    --primary-grad: linear-gradient(135deg, #10b981, #059669);
    --bg: #0b1220;
    --card: #141b2d;
    --text: #e5e9f0;
    --text-light: #94a3b8;
    --border: #232c3d;
    --danger: #f87171;
    --danger-light: #3f1d1d;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
    --bg-glow-1: rgba(16, 185, 129, 0.08);
    --bg-glow-2: rgba(59, 130, 246, 0.08);
    --date-icon-filter: invert(1);
    --header-bg: rgba(20, 27, 45, 0.75);
  }
}

:root[data-theme="dark"] {
  --primary: #34d399;
  --primary-dark: #10b981;
  --primary-light: #0d3b2e;
  --primary-grad: linear-gradient(135deg, #10b981, #059669);
  --bg: #0b1220;
  --card: #141b2d;
  --text: #e5e9f0;
  --text-light: #94a3b8;
  --border: #232c3d;
  --danger: #f87171;
  --danger-light: #3f1d1d;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow: 0 4px 16px -4px rgba(0, 0, 0, 0.45), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 20px 40px -12px rgba(0, 0, 0, 0.6);
  --bg-glow-1: rgba(16, 185, 129, 0.08);
  --bg-glow-2: rgba(59, 130, 246, 0.08);
  --date-icon-filter: invert(1);
  --header-bg: rgba(20, 27, 45, 0.75);
}

body {
  font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(circle at 0% 0%, var(--bg-glow-1) 0%, transparent 45%),
    radial-gradient(circle at 100% 0%, var(--bg-glow-2) 0%, transparent 40%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.hidden { display: none !important; }

/* Login */
.login-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(15, 23, 42, 0.04);
  animation: rise 0.4s var(--ease);
}

.login-card h1 {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
  background: var(--primary-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: -0.02em;
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-light);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
  background: var(--card);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.8rem 1.5rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.15s var(--ease), box-shadow 0.15s var(--ease), background 0.15s var(--ease), opacity 0.15s var(--ease);
  text-decoration: none;
}

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

.btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none !important;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  display: inline-block;
  animation: btn-spin 0.6s linear infinite;
}

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

.blocking-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 3000;
}

.blocking-overlay.show {
  display: flex;
}

.blocking-overlay-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 1.75rem 2.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

.blocking-overlay-card p {
  font-weight: 700;
  color: var(--text);
}

.blocking-spinner {
  width: 30px;
  height: 30px;
  border-width: 3px;
  border-color: var(--primary-light);
  border-top-color: var(--primary);
}

.btn-primary {
  background: var(--primary-grad);
  color: white;
  width: 100%;
  box-shadow: 0 6px 16px -4px rgba(5, 150, 105, 0.45);
}

.btn-primary:hover {
  box-shadow: 0 8px 20px -4px rgba(5, 150, 105, 0.55);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  padding: 0.45rem 0.8rem;
  font-size: 0.8rem;
}

.btn-danger:hover {
  background: var(--danger);
  color: white;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary-dark);
}

.btn-outline:hover {
  background: var(--primary-light);
}

.error-msg {
  color: var(--danger);
  text-align: center;
  margin-top: 0.75rem;
  font-size: 0.88rem;
}

/* Header */
.header {
  background: var(--header-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header .logo {
  font-weight: 800;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  background: var(--primary-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-nav {
  display: none;
}

.header-guide {
  width: 2.1rem;
  height: 2.1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: var(--primary-light);
  border: none;
  border-radius: 50%;
  color: var(--primary-dark);
  font-family: inherit;
  font-weight: 800;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.15s var(--ease);
}

.header-guide:hover {
  background: var(--primary-grad);
  color: #fff;
}

.header-logout {
  background: var(--danger-light);
  border: 1.5px solid #fca5a5;
  color: var(--danger);
  font-family: inherit;
  font-weight: 600;
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  transition: all 0.15s var(--ease);
  white-space: nowrap;
}

.header-logout:hover {
  background: var(--danger);
  border-color: var(--danger);
  color: white;
}

/* Main content */
.main {
  max-width: 800px;
  margin: 0 auto;
  padding: 1.5rem;
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

/* Bottom tab navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  gap: 0.25rem;
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px -8px rgba(15, 23, 42, 0.1);
  padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
  z-index: 100;
  max-width: 800px;
  margin: 0 auto;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  color: var(--text-light);
  font-family: inherit;
  font-weight: 600;
  transition: all 0.15s var(--ease);
}

.nav-item:hover {
  color: var(--primary-dark);
}

.nav-item.active {
  color: var(--primary-dark);
  background: var(--primary-light);
}

.bottom-nav .nav-item {
  flex: 1;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.5rem 0.25rem;
  font-size: 0.7rem;
}

.bottom-nav .nav-item .nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.top-nav .nav-item {
  flex-direction: row;
  gap: 0.45rem;
  padding: 0.55rem 1.1rem;
  font-size: 0.9rem;
}

.top-nav .nav-item .nav-icon {
  font-size: 1.05rem;
  line-height: 1;
}

.btn-logout-full {
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
}

/* Add meal form */
.add-meal-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.04);
}

.add-meal-card h2 {
  margin-bottom: 1.1rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.photo-upload {
  margin-bottom: 1.1rem;
}

.photo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  max-width: 320px;
}

.photo-grid:has(.add-empty) {
  max-width: none;
}

.photo-grid-readonly {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  max-width: none;
}

.photo-grid-readonly .photo-slot {
  width: 150px;
  height: 150px;
  flex: 0 0 auto;
}

.photo-slot {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius);
  overflow: hidden;
}

.photo-slot.add {
  border: 2px dashed var(--border);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: var(--bg);
}

.photo-slot.add:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.photo-slot.add .icon {
  font-size: 1.5rem;
}

.photo-slot.add .text {
  font-size: 0.72rem;
  color: var(--text-light);
}

.photo-slot.add-empty {
  grid-column: 1 / -1;
  aspect-ratio: auto;
  height: 100px;
  flex-direction: row;
}

.photo-slot.add-empty .icon {
  font-size: 1.3rem;
}

.photo-slot.add-empty .text {
  font-size: 0.85rem;
}

.photo-slot.filled img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-remove-btn {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  border: none;
  background: rgba(15, 23, 42, 0.65);
  color: #fff;
  font-size: 0.7rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.form-row {
  display: flex;
  gap: 0.75rem;
}

.form-col {
  flex: 1;
}

/* Custom input button */
.custom-input {
  width: 100%;
  height: 2.75rem;
  padding: 0 0.9rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: normal;
  background: var(--card);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.custom-input:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

input.custom-input[type="time"],
input.custom-input[type="date"] {
  -webkit-appearance: none;
  appearance: none;
  min-height: 0;
}

input.custom-input[type="date"]::-webkit-calendar-picker-indicator {
  filter: var(--date-icon-filter, none);
}

/* Date navigation */
.date-nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.date-nav-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  font-size: 1rem;
  color: var(--text);
  transition: all 0.15s var(--ease);
}

.date-nav-btn:hover { background: var(--primary-light); border-color: var(--primary); }

.date-nav-label {
  flex: 1;
  text-align: center !important;
  font-weight: 700;
}

/* Calendar */
.cal-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  width: 100%;
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.25s var(--ease);
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cal-title {
  font-weight: 700;
  font-size: 1rem;
}

.cal-nav {
  background: none;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s var(--ease);
}

.cal-nav:hover { background: var(--primary-light); border-color: var(--primary); }

.cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 0.35rem;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.cal-empty {
  padding: 0.45rem;
}

.cal-day {
  padding: 0.45rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.85rem;
  transition: background 0.15s var(--ease);
}

.cal-day:hover { background: var(--primary-light); }
.cal-today { font-weight: 700; color: var(--primary-dark); }
.cal-sel { background: var(--primary-grad) !important; color: white !important; font-weight: 700; }

.meal-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.55rem;
  margin-bottom: 1.1rem;
}

.meal-type-option {
  text-align: center;
  padding: 0.7rem 0.5rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  background: var(--bg);
}

.meal-type-option:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.meal-type-option.selected {
  border-color: transparent;
  background: var(--primary-grad);
  color: white;
  box-shadow: 0 6px 14px -4px rgba(5, 150, 105, 0.45);
}

.meal-type-option .emoji {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.3rem;
}

/* Meals list */
.meals-section h2 {
  margin-bottom: 1rem;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.meals-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.meals-section-header h2 {
  display: block;
  margin-bottom: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.meals-section-header .btn-link {
  width: auto;
  margin-top: 0;
  flex-shrink: 0;
}

.meal-filters {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1rem;
}

.meal-filters-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.meal-filters-row .custom-input {
  flex: 1;
  min-width: 130px;
  cursor: auto;
}

.meal-filters-row button {
  flex-shrink: 0;
}


.meal-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.65rem;
  margin-bottom: 0.6rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(15, 23, 42, 0.04);
  display: flex;
  gap: 0.65rem;
  align-items: center;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.meal-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.meal-card .meal-photo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
  background: var(--primary-light);
  cursor: pointer;
}

.meal-photo-wrap {
  position: relative;
  flex-shrink: 0;
  cursor: pointer;
}

.meal-photo-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 0 0.25rem;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-light);
}

.meal-photo-collage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  gap: 2px;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  flex-shrink: 0;
  cursor: pointer;
  background: var(--border);
}

.collage-cell {
  background: #000;
  overflow: hidden;
}

.collage-cell img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.meal-card .meal-info {
  flex: 1;
  min-width: 0;
}

.meal-type-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.15rem 0.5rem;
  border-radius: 1rem;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.meal-card .meal-time {
  font-size: 0.68rem;
  color: var(--text-light);
  margin-left: 0.3rem;
  font-weight: 600;
}

.meal-card .meal-desc {
  font-weight: 600;
  font-size: 0.88rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 0.25rem;
}

.meal-card .meal-notes {
  font-size: 0.76rem;
  color: var(--text-light);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.meal-card .meal-actions {
  flex-shrink: 0;
}

.meal-card .meal-actions .btn-danger {
  padding: 0.3rem 0.55rem;
  font-size: 0.7rem;
}

.btn-rate {
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--text);
  padding: 0.3rem 0.55rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.btn-rate:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.no-meals {
  text-align: center;
  padding: 2.5rem 1rem;
  color: var(--text-light);
  background: var(--card);
  border-radius: var(--radius);
  border: 1px dashed var(--border);
}

/* Nutritionist - patient list */
.patient-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(15, 23, 42, 0.04);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.patient-card:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--primary-light);
}

.patient-card .patient-info h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.patient-card .patient-info p {
  font-size: 0.85rem;
  color: var(--text-light);
}

.patient-card .arrow {
  font-size: 1.5rem;
  color: var(--primary);
}

.patients-limit-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--primary-light);
  border: 1.5px solid var(--primary);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.9rem;
  margin-bottom: 0.85rem;
}

.patients-limit-banner.at-max {
  background: var(--danger-light);
  border-color: var(--danger);
}

.patients-limit-count {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--primary-dark);
  white-space: nowrap;
}

.patients-limit-banner.at-max .patients-limit-count {
  color: var(--danger);
}

.patients-limit-text {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  margin-bottom: 1rem;
  padding: 0.25rem 0;
  font-family: inherit;
}

/* Photo modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
}

.modal-overlay .close-modal {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: white;
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s var(--ease);
}

.modal-overlay .close-modal:hover {
  transform: scale(1.08);
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: white;
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  transition: transform 0.15s var(--ease);
}

.modal-nav:hover {
  transform: translateY(-50%) scale(1.08);
}

.modal-nav-prev { left: 1rem; }
.modal-nav-next { right: 1rem; }

.modal-dots {
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.4rem;
}

.modal-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.45);
}

.modal-dot.active {
  background: #fff;
}

/* Button link */
.btn-link {
  display: block;
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 1rem;
  text-align: center;
  width: 100%;
  font-family: inherit;
}

.btn-link:hover {
  text-decoration: underline;
}

.danger-link {
  color: var(--danger);
  margin-top: 0.6rem;
}

/* Button small */
.btn-sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
}

/* Info & success messages */
.info-msg {
  color: var(--primary-dark);
  background: var(--primary-light);
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  margin-bottom: 0.75rem;
  font-weight: 500;
}

.success-msg {
  color: var(--primary-dark);
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Profile / Settings */
.profile-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.profile-sidebar {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.04);
  padding: 1.75rem 1.5rem;
  text-align: center;
}

.profile-avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary-grad);
  color: white;
  font-size: 1.8rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 0.85rem;
}

.profile-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.15rem;
}

.profile-username {
  color: var(--text-light);
  font-size: 0.85rem;
  margin-bottom: 0.6rem;
}

.profile-role-tag {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.2rem 0.7rem;
  border-radius: 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 1.25rem;
}

.profile-sidebar .btn-logout-full {
  margin-top: 0;
}

.profile-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(15, 23, 42, 0.04);
  overflow: hidden;
}

.setting-row {
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child {
  border-bottom: none;
}

.setting-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.setting-value {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.setting-value span {
  font-size: 0.95rem;
  font-weight: 500;
}

.setting-action {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0;
  font-family: inherit;
}

.setting-action:hover {
  text-decoration: underline;
}

.theme-toggle {
  display: flex;
  gap: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.25rem;
}

.theme-toggle-btn {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-light);
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius-sm) - 0.2rem);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.theme-toggle-btn.active {
  background: var(--primary-grad);
  color: #fff;
}

.setting-edit {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.setting-edit input {
  padding: 0.55rem 0.8rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  width: 100%;
  font-family: inherit;
}

.setting-edit input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.setting-edit-actions {
  display: flex;
  gap: 0.5rem;
}

/* Modal blur */
.modal-blur {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
  animation: rise 0.25s var(--ease);
}

.modal-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.modal-actions .btn-danger {
  padding: 0.8rem 1.5rem;
  font-size: 0.95rem;
}

.confirm-message {
  font-size: 0.98rem;
  line-height: 1.4;
  margin-bottom: 0.25rem;
}

.onboarding-steps {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.onboarding-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.onboarding-step-icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
}

.onboarding-step strong {
  display: block;
  font-size: 0.95rem;
  margin-bottom: 0.15rem;
}

.onboarding-step p {
  font-size: 0.85rem;
  color: var(--text-light);
  line-height: 1.35;
}

/* Meal detail modal */
.modal-card-lg {
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-x {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  line-height: 1;
}

.modal-x:hover {
  color: var(--danger);
  background: var(--danger-light);
}

.rating-section {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: 0.5rem;
}

.rating-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-light);
}

.rating-slider-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.rating-slider {
  flex: 4;
  min-width: 0;
  accent-color: var(--primary);
}

.rating-value {
  flex: 1;
  font-weight: 800;
  font-size: 1.3rem;
  color: var(--primary-dark);
  text-align: center;
}

.rating-badge {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.3rem 0.7rem;
  border-radius: 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  margin-top: 0.3rem;
}

.rating-comment-display {
  margin-top: 0.6rem;
  font-size: 0.9rem;
  color: var(--text-light);
  line-height: 1.4;
}

.rating-empty {
  color: var(--text-light);
  font-size: 0.85rem;
  font-style: italic;
}

.meal-rating-chip {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 0.05rem 0.4rem;
  border-radius: 1rem;
  font-size: 0.68rem;
  font-weight: 700;
  margin-left: 0.3rem;
}

/* Day rating card */
.day-rating-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid rgba(15, 23, 42, 0.04);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  font-size: 0.88rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.day-rating-card.clickable {
  cursor: pointer;
  transition: box-shadow 0.2s var(--ease), transform 0.2s var(--ease);
}

.day-rating-card.clickable:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.day-rating-comment {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-light);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #0f172a;
  color: white;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  z-index: 2000;
  opacity: 0;
  box-shadow: var(--shadow-lg);
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
  pointer-events: none;
  max-width: calc(100vw - 2rem);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast-error {
  background: var(--danger);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Responsive */
@media (max-width: 480px) {
  .login-card { padding: 1.5rem; }
  .main { padding: 0.75rem; padding-bottom: calc(5.5rem + env(safe-area-inset-bottom)); }
}

/* Desktop */
@media (min-width: 900px) {
  .top-nav {
    display: flex;
    gap: 0.5rem;
  }

  .bottom-nav { display: none; }

  .main {
    max-width: 1200px;
    padding: 2.25rem 2rem 3rem;
  }

  /* Meals: card grid with large photos */
  .meals-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.1rem;
  }

  .meals-list .no-meals,
  .patients-list .no-meals {
    grid-column: 1 / -1;
  }

  .meal-card {
    flex-direction: column;
    align-items: stretch;
    padding: 0;
    overflow: hidden;
    position: relative;
  }

  .meal-card .meal-photo {
    width: 100%;
    height: 210px;
    border-radius: 0;
  }

  .meal-card .meal-photo-fallback {
    width: 100%;
    height: 210px;
    background: #000;
    color: #fff;
    font-size: 1.1rem;
    border-radius: 0;
  }

  .meal-card .meal-info {
    padding: 1rem 1.1rem 1.1rem;
  }

  .meal-card .meal-desc,
  .meal-card .meal-notes {
    white-space: normal;
  }

  .meal-card .meal-desc {
    font-size: 1rem;
  }

  .meal-card .meal-actions {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
  }

  .meal-card .meal-actions .btn-danger,
  .meal-card .meal-actions .btn-rate {
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-sm);
  }

  .meal-card .meal-photo-collage {
    width: 100%;
    height: 210px;
    border-radius: 0;
    gap: 3px;
  }

  /* Add meal form: two columns */
  .add-meal-card {
    padding: 2rem 2.25rem;
    max-width: 900px;
    margin: 0 auto;
  }

  .add-meal-grid {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 2.5rem;
  }

  /* Nutritionist patients: card grid */
  .patients-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
  }

  .patient-card { margin-bottom: 0; }

  /* Profile: identity sidebar + settings, not a lone card floating in empty space */
  .profile-layout {
    flex-direction: row;
    align-items: flex-start;
    max-width: 900px;
    margin: 0 auto;
    gap: 2rem;
  }

  .profile-sidebar {
    width: 280px;
    flex-shrink: 0;
  }

  .profile-main {
    flex: 1;
  }
}

/* Tour guiado */
.tour-block {
  position: fixed;
  inset: 0;
  z-index: 9997;
  background: transparent;
}

.tour-block-dim {
  background: rgba(8, 12, 20, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.tour-spotlight {
  position: fixed;
  z-index: 9998;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 0 9999px rgba(8, 12, 20, 0.65);
  pointer-events: none;
  transition: top 0.2s var(--ease), left 0.2s var(--ease), width 0.2s var(--ease), height 0.2s var(--ease);
}

.tour-tooltip {
  z-index: 9999;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 1.25rem;
  width: min(320px, calc(100vw - 2rem));
  animation: rise 0.2s var(--ease);
}

.tour-tooltip-anchored {
  position: fixed;
}

.tour-tooltip-center {
  text-align: center;
}

.tour-step-count {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.tour-tooltip h3 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.tour-tooltip p {
  font-size: 0.88rem;
  color: var(--text-light);
  line-height: 1.45;
  margin-bottom: 1rem;
}

.tour-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.tour-tooltip-center .tour-actions {
  justify-content: center;
  flex-direction: column-reverse;
  gap: 0.75rem;
}

.tour-actions-solo {
  justify-content: flex-end;
}

.tour-actions-nav {
  display: flex;
  gap: 0.5rem;
}

.tour-actions .btn-link {
  margin: 0;
  width: auto;
}
