:root {
  --bg: #111;
  --bg2: #1a1a1a;
  --bg3: #242424;
  --border: #333;
  --red: #cc2222;
  --red-hover: #e02222;
  --text: #eee;
  --text-muted: #888;
  --green: #2ecc71;
  --orange: #e67e22;
  --yellow: #f1c40f;
  --radius: 10px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
  direction: rtl;
  font-size: 15px;
  min-height: 100vh;
}

/* ── NAV ── */
nav {
  background: var(--bg2);
  border-bottom: 2px solid var(--red);
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--red);
  text-decoration: none;
}

.nav-links { display: flex; gap: 6px; align-items: center; }

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  transition: all .2s;
  font-size: .9rem;
}

.nav-links a:hover, .nav-links a.active {
  background: var(--bg3);
  color: var(--text);
}

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

/* ── LAYOUT ── */
.container { max-width: 900px; margin: 0 auto; padding: 20px 16px; }

/* ── CARDS ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── PROGRESS BARS ── */
.progress-group { margin-bottom: 12px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: .85rem;
  margin-bottom: 5px;
}
.progress-bar-bg {
  background: var(--bg3);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 20px;
  transition: width .4s ease;
}
.fill-green { background: var(--green); }
.fill-orange { background: var(--orange); }
.fill-red { background: var(--red); }

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 7px;
  border: none;
  cursor: pointer;
  font-size: .9rem;
  font-weight: 600;
  transition: all .2s;
}

.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: var(--red-hover); }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: #555; }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--red); }
.btn-sm { padding: 4px 10px; font-size: .8rem; }

/* ── FORM ELEMENTS ── */
input, select, textarea {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 7px;
  padding: 8px 12px;
  font-size: .9rem;
  width: 100%;
  direction: rtl;
  outline: none;
  transition: border-color .2s;
}
input:focus, select:focus { border-color: var(--red); }

.form-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 10px;
}
.form-group { flex: 1; }
.form-group label { display: block; font-size: .82rem; color: var(--text-muted); margin-bottom: 4px; }

/* ── MEAL SECTION ── */
.meal-section {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}

.meal-header {
  background: var(--bg3);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.meal-header-left { display: flex; align-items: center; gap: 10px; }
.meal-title { font-weight: 700; font-size: .95rem; }
.meal-stats { font-size: .8rem; color: var(--text-muted); }

.meal-body { padding: 14px 16px; }

.food-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: .88rem;
}
.food-item:last-child { border-bottom: none; }
.food-item-name { flex: 1; }
.food-item-meta { color: var(--text-muted); font-size: .8rem; margin-right: 8px; }
.food-item-calories { color: var(--orange); font-weight: 600; min-width: 60px; text-align: center; }
.food-item-protein { color: var(--green); font-size: .8rem; min-width: 55px; text-align: center; }

/* ── SUGGESTIONS ── */
.suggestions-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 600px) { .suggestions-grid { grid-template-columns: 1fr; } }

.suggestion-group-title {
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
}

.suggestion-item {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 12px;
  margin-bottom: 7px;
  cursor: pointer;
  transition: border-color .2s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.suggestion-item:hover { border-color: var(--red); }
.suggestion-item-name { font-size: .88rem; flex: 1; }
.suggestion-item-cal { font-size: .8rem; color: var(--orange); font-weight: 600; }
.suggestion-item-protein { font-size: .75rem; color: var(--green); }

/* ── TABS ── */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg2);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 8px;
  text-align: center;
  border-radius: 6px;
  cursor: pointer;
  font-size: .85rem;
  color: var(--text-muted);
  transition: all .2s;
}
.tab.active { background: var(--red); color: #fff; font-weight: 600; }

/* ── BADGES / CHIPS ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-red { background: rgba(204,34,34,.2); color: var(--red); }
.badge-green { background: rgba(46,204,113,.15); color: var(--green); }
.badge-orange { background: rgba(230,126,34,.15); color: var(--orange); }
.badge-blue { background: rgba(52,152,219,.15); color: #3498db; }
.badge-purple { background: rgba(155,89,182,.15); color: #9b59b6; }

/* ── TOTALS SUMMARY ── */
.totals-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.total-box {
  background: var(--bg3);
  border-radius: 8px;
  padding: 14px;
  text-align: center;
}
.total-box-value { font-size: 1.6rem; font-weight: 700; }
.total-box-label { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
.val-green { color: var(--green); }
.val-red { color: var(--red); }
.val-orange { color: var(--orange); }
.val-white { color: var(--text); }

/* ── LOGIN ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  width: 100%;
  max-width: 340px;
}
.login-box h1 { color: var(--red); text-align: center; margin-bottom: 24px; font-size: 1.4rem; }

/* ── TABLE ── */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; background: var(--bg3); }
tr:hover td { background: rgba(255,255,255,.02); }

/* ── CHART CANVAS ── */
.chart-wrap { position: relative; height: 220px; }

/* ── ALERTS ── */
.alert {
  padding: 10px 14px;
  border-radius: 7px;
  margin-bottom: 12px;
  font-size: .88rem;
}
.alert-error { background: rgba(204,34,34,.15); border: 1px solid var(--red); color: #f88; }
.alert-success { background: rgba(46,204,113,.12); border: 1px solid var(--green); color: var(--green); }

/* ── UTILITY ── */
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-8 { gap: 8px; }

/* ── SEARCH INPUT ── */
.search-wrap { position: relative; }
.search-wrap input { padding-right: 12px; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
}
.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.food-search-results {
  max-height: 320px;
  overflow-y: auto;
  margin-top: 10px;
}
