/* === BASE === */
html, body {
  overflow: hidden;
  background: var(--bg-body);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
}

/* Background ambient glow */
body::before {
  content: '';
  position: fixed;
  top: -200px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 500px;
  background: radial-gradient(ellipse, color-mix(in srgb, var(--tint) 6%, transparent) 0%, transparent 70%);
  pointer-events: none;
  display: none;
  z-index: 0;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}

/* ========================================
   LOGIN SCREEN
   ======================================== */
#login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  width: 100%;
  gap: var(--sp-xl);
  background: var(--bg-body);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-md);
}

.login-logo {
  width: 72px;
  height: 72px;
  border-radius: 22%;
}

.login-brand h1 {
  font-size: 2.8rem;
  font-weight: 800;
  letter-spacing: 3px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-subtitle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  letter-spacing: 1px;
}

#login-form {
  display: flex;
  gap: var(--sp-sm);
  width: 340px;
}

#login-form input {
  min-width: 0;
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
}

#login-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--tint) 10%, transparent);
}

#login-form input::placeholder {
  color: var(--text-muted);
}

#signup-form , #forgot-form , #reset-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-sm);
  width: 340px;
  max-width: 100%;
}

#signup-form input, #forgot-form input, #reset-form input {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  color: var(--text-primary);
  font-size: 0.95rem;
}

.login-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 0.9rem;
  cursor: pointer;
}

.login-legal {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.login-legal a {
  color: inherit;
}

.google-login {
  width: 340px;
  max-width: 100%;
  justify-content: center;
  border: 1px solid var(--glass-border);
  background: var(--bg-secondary);
  color: var(--text-primary);
}

#login-error {
  color: var(--danger);
  font-size: 0.85rem;
  min-height: 1.2em;
}

/* ========================================
   TAB BAR : sous la barre du haut (bureau), en bas (téléphone)
   ======================================== */
.tabbar {
  display: flex;
  justify-content: center;
  gap: var(--sp-xs);
  padding: 6px var(--sp-lg);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-tab {
  position: relative;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 18px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.nav-tab svg {
  width: 17px;
  height: 17px;
}

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

.nav-tab.active {
  color: var(--accent);
  background: var(--bg-active);
}

/* Le « + » n'existe que sur téléphone : le bureau garde le bouton Ajouter du haut */
.tab-add {
  display: none;
}

.tab-dot::after,
.me-row-dot::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.tab-dot::after {
  position: absolute;
  top: 5px;
  right: 14px;
}

/* Menu Moi */
.me-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.me-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 11px var(--sp-md);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  color: var(--text-primary);
  text-align: left;
}

.me-row:hover {
  background: var(--bg-hover);
}

.me-row-danger {
  color: var(--danger);
}

/* ========================================
   TOP NAVBAR
   ======================================== */
.navbar {
  display: flex;
  align-items: center;
  height: var(--navbar-height);
  padding: 0 var(--sp-lg);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: var(--sp-lg);
  backdrop-filter: blur(12px);
  position: relative;
  z-index: 50;
}

.navbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  flex-shrink: 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

.navbar-brand .logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 22%;
}

.navbar-brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.navbar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.date-nav {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 4px;
}

.date-nav button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 1rem;
  transition: all var(--transition-fast);
}

.date-nav button:hover {
  color: var(--accent);
  background: var(--accent-bg);
}

.date-nav .date-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-primary);
  min-width: 150px;
  text-align: center;
  cursor: pointer;
  padding: 0 var(--sp-sm);
  border-radius: var(--radius-sm);
  transition: color var(--transition-fast);
}

.date-nav .date-label:hover {
  color: var(--accent);
}

.navbar-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  flex-shrink: 0;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.nav-btn:hover {
  color: var(--text-primary);
  border-color: var(--glass-border-hover);
  background: var(--bg-elevated);
}

.nav-btn svg {
  width: 15px;
  height: 15px;
  opacity: 0.7;
}

.nav-btn-primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  font-weight: 600;
}

.nav-btn-primary:hover {
  box-shadow: var(--shadow-glow);
  transform: translateY(-1px);
  color: #fff;
}

.nav-btn-logout {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.nav-btn-logout:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.nav-btn-round {
  width: 34px;
  height: 34px;
  padding: 0;
  justify-content: center;
  border-radius: 50%;
}

.nav-btn-round:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* Rainbow blink for unseen changelog */
.rainbow-blink {
  animation: rainbow-glow 2s ease-in-out infinite;
}

@keyframes rainbow-glow {
  0%   { border-color: var(--red); color: var(--red); }
  25%  { border-color: #ffd93d; color: #ffd93d; }
  50%  { border-color: #6bcb77; color: #6bcb77; }
  75%  { border-color: #4d96ff; color: #4d96ff; }
  100% { border-color: var(--red); color: var(--red); }
}

/* Changelog modal */
.changelog-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-lg);
}

.changelog-entry {
  padding-bottom: var(--sp-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.changelog-entry:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.changelog-header {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  margin-bottom: 4px;
}

.changelog-tag {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
}

.changelog-tag.feature {
  background: color-mix(in srgb, var(--green) 15%, transparent);
  color: var(--success);
}

.changelog-tag.fix {
  background: color-mix(in srgb, var(--blue) 15%, transparent);
  color: var(--blue);
}

.changelog-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.changelog-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 4px 0 6px;
}

.changelog-description {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
}

.changelog-image {
  margin-top: var(--sp-sm);
  border-radius: var(--radius-md);
  max-width: 100%;
  border: 1px solid var(--border-subtle);
}

/* === ADMIN BUTTON === */
.nav-btn-admin {
  color: var(--red);
  border-color: color-mix(in srgb, var(--red) 30%, transparent);
}

.nav-btn-admin:hover {
  border-color: var(--red);
  color: var(--red);
  background: color-mix(in srgb, var(--red) 8%, transparent);
}

/* Exit spectator button */
.btn-exit-spectator {
  background: color-mix(in srgb, var(--red) 15%, transparent);
  border-color: var(--red);
  color: var(--red);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 5px 12px;
  gap: 4px;
  border-radius: var(--radius-md);
  animation: spectator-pulse 2s ease-in-out infinite;
}

.btn-exit-spectator:hover {
  background: color-mix(in srgb, var(--red) 25%, transparent);
}

@keyframes spectator-pulse {
  0%, 100% { border-color: var(--red); }
  50% { border-color: var(--red); box-shadow: 0 0 8px color-mix(in srgb, var(--red) 30%, transparent); }
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

.input-sm {
  padding: 6px 10px;
  font-size: 0.85rem;
}

/* === DEFICIT DISPLAY === */
.deficit-display {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: 6px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.deficit-bar-wrap {
  width: 160px;
  height: 6px;
  background: var(--fill);
  border-radius: 3px;
  flex-shrink: 0;
  position: relative;
}

.deficit-bar-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--success);
  transition: width 0.4s ease, background 0.4s ease;
  width: 0%;
  position: relative;
  z-index: 1;
}

.deficit-bar-fill.warning {
  background: var(--accent);
}

.deficit-bar-fill.over {
  background: var(--danger);
}

.deficit-bar-fill.over-glow {
  --glow-size: 6px;
  background: var(--danger);
  animation: deficit-glow 1.2s ease-in-out infinite alternate;
}

@keyframes deficit-glow {
  0% {
    box-shadow: 0 0 2px var(--danger), 0 0 var(--glow-size) color-mix(in srgb, var(--red) 40%, transparent);
  }
  100% {
    box-shadow: 0 0 4px var(--danger), 0 0 calc(var(--glow-size) * 1.8) color-mix(in srgb, var(--red) 70%, transparent);
  }
}

.deficit-goal-cursor {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--text-secondary);
  z-index: 2;
  transition: left 0.4s ease;
  display: none;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);
}

.deficit-goal-cursor::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 4px solid var(--text-secondary);
}

.deficit-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  white-space: nowrap;
}

.deficit-sub {
  font-size: 0.85em;
  font-weight: 500;
  color: var(--text-muted);
}

/* Reprend le trait blanc du curseur pour relier la légende à la barre */
.deficit-legend-cursor {
  display: inline-block;
  width: 2px;
  height: 0.9em;
  margin-right: 4px;
  vertical-align: -1px;
  background: var(--text-secondary);
}

.deficit-remaining {
  color: var(--text-muted);
  font-weight: 500;
}

.deficit-remaining.over {
  color: var(--danger);
}

.deficit-weight {
  display: flex;
  align-items: baseline;
  gap: 3px;
  margin-left: var(--sp-xs);
  padding-left: var(--sp-sm);
  border-left: 1px solid var(--border);
  font-family: var(--font-mono);
  color: var(--weight-color);
  cursor: text;
}

.deficit-weight input {
  background: transparent;
  border: none;
  outline: none;
  padding: 0;
  width: 2ch;
  min-width: 2ch;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  color: inherit;
  -moz-appearance: textfield;
}

.deficit-weight input::-webkit-outer-spin-button,
.deficit-weight input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.deficit-weight input::placeholder {
  color: var(--text-muted);
}

.deficit-weight .unit {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.deficit-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.deficit-hint:hover {
  color: var(--accent);
}

/* ========================================
   MAIN CONTENT
   ======================================== */
#dashboard {
  display: none;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

#dashboard.active {
  display: flex;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-lg) var(--sp-2xl);
  min-height: 0;
}

/* === SUMMARY CARDS ROW === */
.summary-row {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: var(--sp-md);
  margin-bottom: var(--sp-lg);
}

.summary-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  padding: var(--sp-lg);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.summary-card:hover {
  border-color: var(--glass-border-hover);
}

.summary-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
}

.summary-card.card-kcal::before {
  background: var(--accent-gradient);
}

.summary-card.card-macros::before {
  background: linear-gradient(90deg, var(--blue), var(--orange), var(--green));
}

.summary-card .card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-md);
}

.card-kcal .card-icon {
  background: color-mix(in srgb, var(--tint) 12%, transparent);
  color: var(--accent);
}

.card-macros .card-icon {
  background: color-mix(in srgb, var(--blue) 12%, transparent);
  color: var(--protein-color);
}

.card-macros .macros-row {
  display: flex;
  gap: var(--sp-md);
}

.card-macros .macro-item {
  flex: 1;
}

.card-macros .macro-item:first-child {
  text-align: left;
}

.card-macros .macro-item:nth-child(2) {
  text-align: center;
}

.card-macros .macro-item:last-child {
  text-align: right;
}

.card-macros .macro-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}

.card-macros .macro-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 2px;
}

.macro-protein .macro-value { color: var(--protein-color); }
.macro-fat .macro-value { color: var(--warning); }
.macro-carbs .macro-value { color: var(--success); }

.summary-card .card-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 4px;
}

.card-kcal .card-value { color: var(--accent-bright); }

.summary-card .card-unit {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-left: 2px;
}

.summary-card .card-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* === CONSUMPTION PANEL === */
.consumption-panel {
  background: var(--bg-card);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-md) var(--sp-lg);
  border-bottom: 1px solid var(--border);
}

.panel-header h2 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.panel-actions {
  display: flex;
  gap: var(--sp-xs);
}

#btn-select.active {
  background: var(--accent-bg);
  color: var(--accent);
  border-color: var(--accent);
}

/* Pastille de sélection (copier) + case « mangé » côte à côte */
.entry-lead {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

/* Pastille de sélection (copier), distincte de la case « mangé » */
.entry-select {
  width: 20px;
  height: 20px;
  margin-right: 10px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
}

.entry-selected .entry-select {
  border-color: var(--accent);
  background: var(--accent);
}

.entry-selected .entry-select::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 4px;
  height: 8px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

#consumption-list.select-mode .entry-item {
  cursor: pointer;
}

/* Les modales ouvertes passent devant : la barre revient à leur fermeture */
body:has(.modal-overlay) .copy-bar {
  display: none;
}

.copy-bar-hint {
  align-self: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.panel-header .entry-count {
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  font-family: var(--font-mono);
}

#consumption-list {
  min-height: 120px;
  max-height: calc(100vh - var(--navbar-height) - 280px);
  overflow-y: auto;
}

.entry-item {
  display: flex;
  align-items: center;
  padding: 6px var(--sp-lg);
  border-bottom: 1px solid var(--border-subtle);
  transition: background var(--transition-fast);
}

.entry-item:last-child {
  border-bottom: none;
}

.entry-item:hover {
  background: var(--bg-hover);
}

.entry-item.entry-selected {
  background: rgba(16, 163, 127, 0.12);
  box-shadow: inset 3px 0 0 var(--accent);
}

.entry-item.entry-selected:hover {
  background: rgba(16, 163, 127, 0.18);
}

/* Floating copy bar (visible while at least one entry is selected) */
.copy-bar {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--bg-card-solid);
  border: 1px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  animation: copy-bar-in 0.15s ease-out;
}

@keyframes copy-bar-in {
  from { transform: translate(-50%, 8px); opacity: 0; }
  to { transform: translate(-50%, 0); opacity: 1; }
}

.copy-bar-sep {
  width: 1px;
  height: 22px;
  background: var(--border);
  display: inline-block;
}

.copy-bar-totals {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px;
  font-size: 0.78rem;
  white-space: nowrap;
}

.copy-bar-totals .copy-bar-kcal {
  font-weight: 700;
  color: var(--accent);
}

.copy-bar-totals .macro-p {
  font-weight: 500;
  color: var(--protein-color);
}

.copy-bar-totals .macro-l {
  font-weight: 500;
  color: var(--warning);
}

.copy-bar-totals .macro-g {
  font-weight: 500;
  color: var(--success);
}

@media (max-width: 600px) {
  .copy-bar {
    left: 8px;
    right: 8px;
    transform: translateY(0);
    flex-wrap: wrap;
    justify-content: center;
    row-gap: 8px;
    padding: 10px 12px;
  }

  @keyframes copy-bar-in {
    from { transform: translateY(8px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
  }

  .copy-bar-totals {
    font-size: 0.72rem;
    gap: 6px;
    padding: 0 4px;
    flex-basis: 100%;
    justify-content: center;
  }

  .copy-bar-sep {
    display: none;
  }
}

.paste-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.paste-btn svg {
  flex-shrink: 0;
}

.paste-clear {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: none;
  background: var(--bg-hover);
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.paste-clear:hover {
  background: var(--danger);
  color: #fff;
}

.entry-checkbox {
  appearance: none;
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border: 2px solid var(--text-muted);
  border-radius: 3px;
  cursor: pointer;
  flex-shrink: 0;
  margin-right: 8px;
  position: relative;
  background: transparent;
  transition: border-color 0.15s, background 0.15s;
}

.entry-checkbox:checked {
  border-color: var(--success);
  background: var(--success);
}

.entry-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 3px;
  top: 0px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.entry-checkbox:indeterminate {
  border-color: var(--text-muted);
  background: var(--text-muted);
}

.entry-checkbox:indeterminate::after {
  content: '';
  position: absolute;
  left: 2px;
  top: 5px;
  width: 8px;
  height: 2px;
  background: #fff;
}

.entry-checkbox-all {
  margin-right: 6px;
}

.entry-time {
  font-size: 0.75rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  min-width: 48px;
  flex-shrink: 0;
}

.entry-info {
  flex: 1;
  min-width: 0;
  margin-left: var(--sp-md);
  display: flex;
  align-items: baseline;
  overflow: hidden;
}

.entry-name {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 0 1 auto;
}

.entry-qty-inline {
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 4px;
}

.entry-nutrition {
  display: flex;
  gap: var(--sp-lg);
  flex: none;
  margin-left: var(--sp-md);
  width: 460px;
}

.entry-kcal {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
  min-width: 70px;
  text-align: right;
}

.entry-macros {
  font-size: 0.8rem;
  display: flex;
  gap: 0;
}

.entry-macros span {
  display: inline-block;
  white-space: nowrap;
}

.entry-macros .macro-p { color: var(--protein-color); min-width: 140px; }
.entry-macros .macro-l { color: var(--warning); min-width: 120px; }
.entry-macros .macro-g { color: var(--success); }
.entry-macros .macro-label-short { display: none; }

.entry-edit,
.entry-delete {
  color: var(--text-muted);
  margin-left: var(--sp-xs);
  font-size: 0.9rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  opacity: 0.4;
  transition: all var(--transition-fast);
}

.entry-item:hover .entry-edit,
.entry-item:hover .entry-delete {
  opacity: 1;
}

.entry-edit:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--tint) 10%, transparent);
}

.entry-delete:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--red) 10%, transparent);
}

.entry-edit-popup {
  position: fixed;
  background: var(--bg-card-solid);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  min-width: 180px;
  overflow: hidden;
}

.entry-edit-option {
  display: block;
  width: 100%;
  padding: 10px 14px;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: background 0.15s ease;
}

.entry-edit-option:hover {
  background: var(--bg-hover);
  color: var(--accent);
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-2xl);
  color: var(--text-muted);
  font-size: 0.9rem;
  gap: var(--sp-sm);
}

.empty-state svg {
  width: 40px;
  height: 40px;
  opacity: 0.3;
}


/* ========================================
   RESPONSIVE MOBILE (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {

  /* Login */
  #login-form {
    width: 90%;
    max-width: 340px;
  }

  /* Navbar: stack brand left, date center, actions right */
  .navbar {
    padding: 0 var(--sp-sm);
    gap: var(--sp-sm);
  }

  .navbar-left {
    gap: var(--sp-xs);
  }

  .navbar-brand h1 {
    display: none;
  }

  .date-nav .date-label {
    min-width: 80px;
    font-size: 0.78rem;
  }

  .deficit-display {
    padding: 4px 8px;
    gap: 4px;
  }

  .deficit-bar-wrap {
    width: 60px;
  }

  .deficit-weight {
    margin-left: 0;
    padding-left: 6px;
  }

  .deficit-text {
    font-size: 0.68rem;
  }

  .navbar-actions {
    gap: 4px;
  }

  /* Hide text labels on nav buttons, keep icons */
  .nav-btn {
    padding: 7px 10px;
    font-size: 0;
    gap: 0;
  }

  .nav-btn svg {
    width: 16px;
    height: 16px;
  }

  .nav-btn-primary {
    font-size: 0;
  }

  /* Main content */
  .main-content {
    padding: var(--sp-md) var(--sp-sm);
  }

  /* Tab bar en bas, zone sûre incluse */
  :root {
    --tabbar-h: 60px;
  }

  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 60;
    justify-content: space-around;
    align-items: center;
    gap: 0;
    padding: 4px var(--sp-xs) calc(4px + env(safe-area-inset-bottom));
    border-bottom: none;
    border-top: 1px solid var(--border);
    backdrop-filter: blur(12px);
  }

  .nav-tab {
    flex: 1;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-height: 52px;
    padding: 4px 2px;
    font-size: 0.68rem;
  }

  .nav-tab svg {
    width: 22px;
    height: 22px;
  }

  .tab-dot::after {
    right: calc(50% - 18px);
  }

  .tab-add {
    display: flex;
    flex: 0 0 56px;
    min-height: 0;
    width: 56px;
    height: 56px;
    margin-top: -18px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #fff;
    box-shadow: var(--shadow-md);
  }

  .tab-add:hover,
  .tab-add.active {
    color: #fff;
    background: var(--accent-gradient);
  }

  #btn-add {
    display: none;
  }

  .main-content {
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + var(--sp-md));
  }

  .copy-bar {
    bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 8px);
  }

  /* Summary cards: horizontal row, compact */
  .summary-row {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--sp-sm);
  }

  .summary-card {
    padding: var(--sp-md) var(--sp-sm);
  }

  .summary-card .card-icon {
    width: 32px;
    height: 32px;
    margin-bottom: var(--sp-sm);
  }

  .summary-card .card-value {
    font-size: 1.4rem;
  }

  .card-macros .macro-value {
    font-size: 1.4rem;
  }

  .card-macros .macro-unit {
    font-size: 0.7rem;
  }

  .summary-card .card-label {
    font-size: 0.65rem;
    letter-spacing: 1px;
  }

  /* Consumption list */
  .entry-item {
    padding: 6px var(--sp-md);
  }

  .entry-nutrition {
    flex-direction: column;
    gap: 2px;
    align-items: flex-end;
    margin-left: var(--sp-sm);
    width: auto;
  }

  .entry-edit,
  .entry-delete {
    opacity: 1;
    margin-left: var(--sp-xs);
  }

  #consumption-list {
    max-height: calc(100vh - var(--navbar-height) - var(--tabbar-h) - 240px);
  }

}

/* ========================================
   RESPONSIVE SMALL PHONE (max-width: 480px)
   ======================================== */
@media (max-width: 480px) {

  /* --- NAVBAR --- */
  .navbar {
    flex-wrap: wrap;
    padding: var(--sp-xs) var(--sp-xs);
    gap: var(--sp-xs);
    height: auto;
    min-height: 48px;
  }

  .navbar-center {
    order: 3;
    flex: 0 0 100%;
    width: 100%;
    justify-content: center;
    padding-top: 2px;
  }

  .navbar-center .deficit-display {
    width: 100%;
    justify-content: center;
    padding: 4px 8px;
    gap: 6px;
    background: transparent;
    border: none;
    border-top: 1px solid var(--border);
    border-radius: 0;
    margin: 0 calc(-1 * var(--sp-xs));
    padding-left: var(--sp-xs);
    padding-right: var(--sp-xs);
  }

  .navbar-center .deficit-bar-wrap {
    width: 44px;
  }

  .navbar-center .deficit-text {
    font-size: 0.74rem;
  }

  .navbar-left {
    flex: 1;
    min-width: 0;
  }

  .navbar-brand .logo-icon {
    width: 22px;
    height: 22px;
  }

  .date-nav {
    padding: 2px;
    gap: 2px;
  }

  .date-nav button {
    width: 26px;
    height: 26px;
  }

  .date-nav .date-label {
    min-width: 60px;
    font-size: 0.72rem;
    padding: 0 2px;
  }

  .navbar-actions {
    gap: 3px;
  }

  .nav-btn {
    padding: 5px 7px;
  }

  .nav-btn svg {
    width: 14px;
    height: 14px;
  }

  .nav-btn-round,
  .nav-btn-logout {
    width: 30px;
    height: 30px;
  }

  /* --- MAIN CONTENT --- */
  .main-content {
    padding: var(--sp-sm) var(--sp-xs);
  }

  /* --- SUMMARY CARDS: stack vertically --- */
  .summary-row {
    grid-template-columns: 1fr;
    gap: var(--sp-sm);
  }

  .summary-card {
    padding: var(--sp-sm) var(--sp-md);
  }

  .summary-card .card-icon {
    width: 32px;
    height: 32px;
    margin-bottom: var(--sp-xs);
  }

  .summary-card .card-value {
    font-size: 1.5rem;
  }

  .card-macros .macros-row {
    gap: var(--sp-lg);
  }

  .card-macros .macro-value {
    font-size: 1.5rem;
  }

  /* --- ENTRY ITEMS --- */
  .entry-item {
    display: grid;
    grid-template-columns: auto auto 1fr auto auto;
    grid-template-rows: auto auto;
    align-items: center;
    padding: 6px var(--sp-sm);
    gap: 0 4px;
  }

  .entry-item .entry-lead {
    grid-row: 1 / 3;
    align-self: center;
    margin-right: 4px;
  }

  .entry-time {
    grid-column: 2;
    grid-row: 1;
    min-width: auto;
    font-size: 0.7rem;
  }

  .entry-info {
    grid-column: 3;
    grid-row: 1;
    margin-left: 4px;
  }

  .entry-name {
    font-size: 0.82rem;
  }

  .entry-edit {
    grid-column: 4;
    grid-row: 1;
    opacity: 1;
    padding: 4px;
  }

  .entry-delete {
    grid-column: 5;
    grid-row: 1;
    opacity: 1;
    padding: 4px;
  }

  .entry-nutrition {
    grid-column: 2 / 6;
    grid-row: 2;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    margin-left: 0;
    margin-top: 0;
    gap: var(--sp-sm);
  }

  .entry-kcal {
    min-width: auto;
    font-size: 0.8rem;
    text-align: left;
  }

  .entry-macros {
    gap: var(--sp-sm);
  }

  .entry-macros span {
    min-width: 0 !important;
    font-size: 0.7rem;
  }

  .entry-macros .macro-label-full {
    display: none;
  }

  .entry-macros .macro-label-short {
    display: inline;
  }

  /* --- CONSUMPTION LIST --- */
  #consumption-list {
    max-height: calc(100vh - 48px - 180px);
  }

  .panel-header {
    padding: var(--sp-sm) var(--sp-md);
  }

  .panel-header h2 {
    font-size: 0.85rem;
  }

}
