:root {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-elevated: #334155;
  --text: #f8fafc;
  --text-muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --accent: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --border: rgba(148, 163, 184, 0.18);
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top right, #1e1b4b, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.875rem;
}

.mt-05 {
  margin-top: 0.5rem;
}

.mt-1 {
  margin-top: 1rem;
}

.center-row {
  display: flex;
  justify-content: center;
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 1.25rem 0;
}

/* Auth Screen */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.auth-card {
  width: 100%;
  max-width: 410px;
  background: rgba(30, 41, 59, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo h1 {
  font-size: 1.65rem;
  margin-top: 0.5rem;
}

.auth-logo p {
  color: var(--text-muted);
  font-size: 0.92rem;
}

.info-banner {
  background: rgba(99, 102, 241, 0.16);
  border: 1px solid rgba(99, 102, 241, 0.4);
  color: #e0e7ff;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

/* App Shell */
.app-shell {
  max-width: 820px;
  margin: 0 auto;
  padding-bottom: 5.5rem;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.brand-title {
  font-weight: 700;
  font-size: 1.15rem;
  margin-right: 0.4rem;
}

.user-badge {
  font-size: 0.75rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.35);
}

.header-date {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: right;
}

/* Navigation */
.app-nav {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  background: rgba(15, 23, 42, 0.6);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 67px;
  z-index: 19;
  backdrop-filter: blur(12px);
}

.nav-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.65rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(30, 41, 59, 0.7);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.18s ease;
  position: relative;
}

.nav-tab:hover {
  color: var(--text);
  background: var(--bg-card);
}

.nav-tab.active {
  background: linear-gradient(135deg, var(--primary), #8b5cf6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
}

.badge-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
}

/* Content & Cards */
.app-content {
  padding: 1.25rem;
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: rgba(30, 41, 59, 0.88);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.hero-top,
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

/* Forms & Buttons */
.form-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 0.9rem;
  align-items: end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.84rem;
  font-weight: 600;
  color: #cbd5e1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.weekday-pill {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(236, 72, 153, 0.2);
  color: #fbcfe8;
  font-weight: 600;
}

input[type="text"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.75);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s ease;
}

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

.checkbox-group {
  justify-content: center;
  padding-bottom: 0.35rem;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  justify-content: flex-start !important;
  gap: 0.55rem;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  font-weight: 600;
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 0.16s ease;
  color: #fff;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.82rem;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
}

.btn-secondary {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.btn-secondary:hover:not(:disabled) {
  background: #475569;
}

.btn-success {
  background: var(--success);
}

.btn-warning {
  background: var(--warning);
  color: #0f172a;
}

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

.btn-danger-outline {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.45);
  color: #fca5a5;
}

.btn-danger-outline:hover {
  background: var(--danger);
  color: #fff;
}

.btn-icon {
  background: var(--bg-elevated);
  padding: 0.45rem 0.8rem;
}

.btn-link {
  background: none;
  border: none;
  color: #818cf8;
  cursor: pointer;
  text-decoration: underline;
}

/* Notifications List */
.notifications-box {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: 0.9rem;
}

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

.notifications-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 260px;
  overflow-y: auto;
}

.notif-item {
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  font-size: 0.88rem;
}

.notif-item.unread {
  border-left: 3px solid var(--accent);
  background: rgba(99, 102, 241, 0.12);
}

.notif-title {
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
}

/* Users List */
.users-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0.75rem;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.9rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
}

.user-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Calendar Grid */
.calendar-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.week-title-block {
  text-align: center;
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: 0.9rem;
  margin-bottom: 0.35rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
}

.cal-day {
  min-height: 58px;
  padding: 0.35rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.14s ease;
}

.cal-day:hover {
  border-color: var(--primary);
}

.cal-day.outside {
  opacity: 0.32;
}

.cal-day.today {
  border-color: var(--accent);
}

.cal-day.selected {
  background: rgba(99, 102, 241, 0.25);
  border-color: var(--primary);
}

.cal-day-num {
  font-size: 0.82rem;
  font-weight: 700;
}

.cal-dots {
  display: flex;
  gap: 3px;
  flex-wrap: wrap;
}

.cal-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.cal-dot.confirmed {
  background: var(--success);
}
.cal-dot.pending {
  background: var(--primary);
}
.cal-dot.unclear {
  background: var(--warning);
}
.cal-dot.rejected {
  background: var(--danger);
}
.cal-dot.busy {
  background: #64748b;
}

/* Events List & Cards */
.events-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.event-item {
  padding: 0.9rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.event-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

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

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: #cbd5e1;
}

.countdown-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
  border: 1px solid rgba(99, 102, 241, 0.4);
}

.status-badge {
  display: inline-block;
  padding: 0.18rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.status-confirmed {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}
.status-pending {
  background: rgba(99, 102, 241, 0.22);
  color: #c7d2fe;
}
.status-unclear {
  background: rgba(245, 158, 11, 0.22);
  color: #fcd34d;
}
.status-rejected {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}
.status-busy {
  background: rgba(100, 116, 139, 0.25);
  color: #cbd5e1;
}

.rejection-box {
  background: rgba(239, 68, 68, 0.12);
  border-left: 3px solid var(--danger);
  padding: 0.45rem 0.7rem;
  border-radius: 6px;
  font-size: 0.84rem;
  color: #fecaca;
}

.event-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.35rem;
}

/* Weekly Meals Grid */
.meals-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}

.meal-card {
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.meal-image {
  width: 100%;
  height: 185px;
  object-fit: cover;
  background: #0f172a;
}

.meal-image-placeholder {
  width: 100%;
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(236, 72, 153, 0.2));
}

.meal-body {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  flex: 1;
}

.meal-day-tag {
  display: inline-block;
  align-self: flex-start;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: rgba(236, 72, 153, 0.2);
  color: #fbcfe8;
}

.meal-title {
  font-size: 1.12rem;
  font-weight: 700;
}

.meal-portions-info {
  font-size: 0.83rem;
  color: #cbd5e1;
  background: rgba(30, 41, 59, 0.7);
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-sm);
}

.meal-footer {
  margin-top: auto;
  padding-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn-portion-active {
  background: var(--success);
  color: #fff;
}

/* Saved Dishes Library */
.saved-dishes-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.saved-dish-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid var(--border);
}

.saved-dish-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  background: var(--bg-elevated);
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

/* Toasts */
.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  left: 1.25rem;
  max-width: 380px;
  margin-left: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  pointer-events: none;
}

.toast {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  background: #1e293b;
  border: 1px solid var(--primary);
  color: #fff;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  pointer-events: auto;
}

.toast.error {
  border-color: var(--danger);
  background: #3f1d28;
}

@media (max-width: 560px) {
  .app-content {
    padding: 0.85rem;
  }
  .card {
    padding: 1rem;
  }
}
