/* ── LAYOUT ── */
.dash-layout {
  display: grid; grid-template-columns: 240px 1fr;
  min-height: 100vh; padding-top: 72px;
}
@media(max-width:768px) {
  .dash-layout { grid-template-columns: 1fr; }
  .dash-sidebar { display: none; }
}

/* ── SIDEBAR ── */
.dash-sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  padding: 32px 16px; position: sticky; top: 72px; height: calc(100vh - 72px);
  overflow-y: auto;
}
.dash-avatar-wrap { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; padding: 0 8px; }
.dash-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 800; color: #000; flex-shrink: 0;
}
.dash-user-name { font-weight: 700; font-size: 14px; }
.dash-user-email { font-size: 12px; color: var(--muted); }

.dash-nav { display: flex; flex-direction: column; gap: 4px; }
.dash-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 10px;
  font-size: 14px; font-weight: 500; color: var(--muted);
  transition: var(--transition); cursor: pointer;
}
.dash-nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text); }
.dash-nav-item.active { background: rgba(0,200,150,0.1); color: var(--green); font-weight: 600; }

/* ── MAIN ── */
.dash-main { padding: 40px 32px; max-width: 860px; }
@media(max-width:640px) { .dash-main { padding: 24px 16px; } }

.dash-tab { display: none; }
.dash-tab.active { display: block; }
.dash-title { font-family: var(--font2); font-size: 26px; font-weight: 700; margin-bottom: 24px; }
.dash-subtitle { font-size: 16px; font-weight: 700; margin: 28px 0 12px; }

/* ── WALLET ── */
.wallet-balance-card {
  background: linear-gradient(135deg, rgba(0,200,150,0.12), rgba(155,143,255,0.08));
  border: 1px solid rgba(0,200,150,0.25); border-radius: 24px;
  padding: 36px; text-align: center; margin-bottom: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
}
.wallet-balance-num {
  font-family: var(--font2); font-size: 48px; font-weight: 900; color: var(--green);
}
.wallet-costs-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 20px; margin-bottom: 28px;
}
.wallet-costs-title { font-weight: 700; font-size: 14px; margin-bottom: 14px; }
.cost-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; font-size: 13px; color: rgba(240,244,255,0.7);
}
.cost-badge {
  font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 6px;
}
.cost-badge.green  { background: rgba(0,200,150,0.15);  color: var(--green); }
.cost-badge.orange { background: rgba(255,107,53,0.15); color: var(--orange); }
.cost-badge.purple { background: rgba(155,143,255,0.15);color: var(--purple); }
.cost-note { font-size: 11px; color: rgba(0,200,150,0.7); margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }

/* ── PACK LIST ── */
.pack-list { display: flex; flex-direction: column; gap: 12px; margin-bottom: 28px; }
.pack-card {
  display: flex; align-items: center; justify-content: space-between;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 16px 20px; cursor: pointer;
  transition: var(--transition); position: relative;
}
.pack-card:hover { border-color: rgba(0,200,150,0.3); transform: translateX(4px); }
.pack-popular { border-color: rgba(255,107,53,0.4); background: linear-gradient(135deg, rgba(255,107,53,0.06), var(--surface)); }
.pack-popular-badge {
  position: absolute; top: -10px; left: 16px;
  background: var(--orange); color: #000; font-size: 10px; font-weight: 800;
  padding: 2px 10px; border-radius: 100px;
}
.pack-left { display: flex; flex-direction: column; gap: 3px; }
.pack-tokens { font-weight: 700; font-size: 15px; }
.pack-label { font-size: 12px; color: var(--muted); }
.pack-btn {
  background: var(--green); color: #000; border: none; border-radius: 10px;
  padding: 8px 20px; font-weight: 700; font-size: 15px; cursor: pointer;
  transition: var(--transition);
}
.pack-btn:hover { background: #00e0a8; }
.pack-btn.orange { background: var(--orange); color: #fff; }
.pack-btn.orange:hover { background: #ff8555; }

/* ── LEGAL ── */
.legal-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px; margin-top: 8px;
}
.legal-title { font-size: 13px; font-weight: 600; margin-bottom: 8px; color: rgba(240,244,255,0.8); }
.legal-card p { font-size: 12px; color: var(--muted); line-height: 1.7; }
.legal-card a { color: var(--green); }

/* ── TRANSACTIONS ── */
.tx-list { display: flex; flex-direction: column; gap: 8px; }
.tx-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 16px;
}
.tx-icon { font-size: 20px; flex-shrink: 0; }
.tx-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.tx-note { font-size: 13px; font-weight: 500; }
.tx-date { font-size: 11px; color: var(--muted); }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.tx-amount { font-size: 15px; font-weight: 700; }
.tx-bal { font-size: 11px; color: var(--muted); }

/* ── PROFILE GRID ── */
.profile-grid { display: flex; flex-direction: column; gap: 8px; }
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 16px;
}
.profile-key { font-size: 13px; color: var(--muted); }
.profile-val { font-size: 13px; font-weight: 600; }

/* ── ADMIN ── */
.admin-nav-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(255,107,53,0.15); border: 1px solid rgba(255,107,53,0.3);
  color: var(--orange); font-size: 12px; font-weight: 700;
  padding: 4px 12px; border-radius: 100px;
}
.admin-loading { display: flex; justify-content: center; padding: 40px; }
.admin-user-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 14px 18px; margin-bottom: 10px;
  cursor: pointer; transition: var(--transition);
}
.admin-user-row:hover { border-color: rgba(0,200,150,0.3); transform: translateX(4px); }
.admin-user-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 800; color: #000;
}
.admin-user-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.admin-user-name { font-size: 14px; font-weight: 600; }
.admin-user-email { font-size: 12px; color: var(--muted); }
.admin-user-stats { display: flex; gap: 8px; flex-wrap: wrap; }
.admin-stat-badge {
  font-size: 11px; font-weight: 600; padding: 3px 10px; border-radius: 100px;
  background: rgba(255,255,255,0.06); color: var(--muted);
}
.admin-stat-badge.green { background: rgba(0,200,150,0.12); color: var(--green); }

/* ── USER DETAIL PANEL ── */
.detail-panel {
  position: fixed; top: 0; right: -100%; width: min(520px, 100vw);
  height: 100vh; background: var(--bg); border-left: 1px solid var(--border);
  z-index: 200; transition: right 0.35s cubic-bezier(0.4,0,0.2,1);
  display: flex; flex-direction: column; overflow: hidden;
}
.detail-panel.open { right: 0; }
.detail-backdrop {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px); z-index: 199;
}
.detail-panel-inner { display: flex; flex-direction: column; height: 100%; }
.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.detail-header h3 { font-family: var(--font2); font-size: 18px; font-weight: 700; }
.detail-section { margin-bottom: 28px; }
.detail-section h4 { font-size: 14px; font-weight: 700; margin-bottom: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.detail-balance {
  font-family: var(--font2); font-size: 32px; font-weight: 800; color: var(--green);
  background: rgba(0,200,150,0.08); border: 1px solid rgba(0,200,150,0.2);
  border-radius: 16px; padding: 20px; text-align: center;
}
.adjust-row { display: flex; gap: 8px; flex-wrap: wrap; }
.adjust-input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 14px; color: var(--text); font-size: 14px; font-family: var(--font);
  flex: 1; min-width: 120px;
}
.adjust-input:focus { outline: none; border-color: var(--green); }
.log-detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}

/* ── PAGINATION ── */
.pagination-bar { display:flex; gap:6px; justify-content:center; margin-top:20px; flex-wrap:wrap; }
.pg-btn {
  background:var(--surface); border:1px solid var(--border); color:var(--muted);
  border-radius:8px; padding:6px 12px; font-size:13px; font-weight:600;
  cursor:pointer; font-family:var(--font); transition:var(--transition);
}
.pg-btn:hover:not([disabled]) { border-color:var(--green); color:var(--green); }
.pg-btn.pg-active { background:rgba(0,200,150,0.15); border-color:var(--green); color:var(--green); }
.pg-btn[disabled] { opacity:0.3; cursor:default; }

/* ── REGISTRY ── */
.registry-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 14px 18px; margin-bottom: 10px;
}
.registry-email { font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.registry-meta { display: flex; gap: 16px; flex-wrap: wrap; font-size: 12px; color: var(--muted); }

/* ── HISTORY ── */
.history-day-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.035), rgba(255,255,255,0.015));
  border: 1px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.16);
}
.history-day-header,
.history-meal-header {
  width: 100%;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.history-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 18px;
  cursor: pointer;
  transition: var(--transition);
}
.history-day-header:hover { background: rgba(255,255,255,0.025); }
.history-day-copy { min-width: 0; }
.history-day-label {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 8px;
  letter-spacing: -0.2px;
}
.history-day-macros { display: flex; gap: 6px; flex-wrap: wrap; }
.history-day-toggle { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.history-day-count { font-size: 12px; color: var(--muted); white-space: nowrap; font-weight: 600; }
.history-chevron {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  transition: transform 0.24s ease, color 0.24s ease;
}
.history-chevron svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.history-day-card.open .history-day-chevron,
.history-meal-group.open .history-meal-chevron {
  color: var(--text);
  transform: rotate(180deg);
}
.history-day-body,
.history-meal-body,
.history-scan-items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.3s ease;
}
.history-day-card.open .history-day-body,
.history-meal-group.open .history-meal-body,
.history-scan-card.open .history-scan-items {
  grid-template-rows: 1fr;
}
.history-day-card.open .history-day-body { border-top: 1px solid rgba(255,255,255,0.06); }
.history-day-body-inner,
.history-meal-body-inner,
.history-scan-items-inner { overflow: hidden; }
.history-day-body-inner {
  padding: 4px 12px 14px;
  background: linear-gradient(180deg, rgba(0,0,0,0.18), rgba(0,0,0,0.1));
}
.history-meal-group {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 4px 4px 0;
}
.history-meal-group:last-child { border-bottom: none; }
.history-meal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 10px;
  cursor: pointer;
  transition: var(--transition);
  border-radius: 16px;
}
.history-meal-header:hover { background: rgba(255,255,255,0.025); }
.history-meal-copy { min-width: 0; }
.history-meal-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.history-meal-count { font-size: 12px; color: var(--muted); margin-top: 4px; }
.history-meal-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}
.history-meal-body-inner {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 0 0 14px 12px;
}
.history-scan-card {
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(255,255,255,0.025);
  box-shadow: 0 10px 26px rgba(0,0,0,0.18);
  transition: border-color 0.24s ease, box-shadow 0.24s ease;
}
.history-scan-card.open {
  border-color: rgba(255,255,255,0.12);
  box-shadow: 0 18px 34px rgba(0,0,0,0.22);
}
.history-scan-summary {
  position: relative;
  cursor: pointer;
  outline: none;
  overflow: hidden;
}
.history-scan-summary:focus-visible {
  box-shadow: inset 0 0 0 1px rgba(16,185,129,0.35), 0 0 0 3px rgba(16,185,129,0.16);
}
.history-scan-card-photo .history-scan-summary {
  min-height: 176px;
  display: flex;
  align-items: flex-end;
}
.history-scan-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.history-scan-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.16), rgba(0,0,0,0.04) 38%, rgba(9,9,11,0.92));
}
.history-scan-toolbar {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 8px;
  z-index: 2;
}
.history-icon-btn {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.45);
  color: #fff;
  cursor: pointer;
  transition: transform 0.24s ease, background 0.24s ease, border-color 0.24s ease;
  backdrop-filter: blur(10px);
}
.history-icon-btn:hover {
  transform: translateY(-1px);
  background: rgba(0,0,0,0.62);
  border-color: rgba(255,255,255,0.2);
}
.history-icon-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform 0.24s ease;
}
.history-scan-card.open .history-scan-toggle-btn svg { transform: rotate(180deg); }
.history-scan-footer {
  position: relative;
  z-index: 1;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 12px;
  padding: 16px;
}
.history-scan-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.2px;
}
.history-scan-card-photo .history-scan-title {
  color: #fff;
  text-shadow: 0 3px 14px rgba(0,0,0,0.45);
}
.history-scan-macros { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.history-scan-card-plain .history-scan-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
}
.history-scan-plain-copy { flex: 1; min-width: 0; }
.history-scan-card-plain .history-scan-title {
  color: var(--text);
  margin-bottom: 8px;
}
.history-scan-card-plain .history-icon-btn {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border-color: rgba(255,255,255,0.08);
}
.history-scan-card-plain .history-icon-btn:hover {
  background: rgba(255,255,255,0.11);
  border-color: rgba(255,255,255,0.14);
}
.history-scan-card.open .history-scan-items { border-top: 1px solid rgba(255,255,255,0.06); }
.history-log-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.history-log-row:last-child { border-bottom: none; }
.history-log-main { flex: 1; min-width: 0; }
.history-log-name { font-size: 14px; font-weight: 600; }
.history-log-qty  { font-size: 12px; color: var(--muted); margin-top: 4px; }
.history-log-macros {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
}
.macro-chip {
  font-size: 11px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.macro-chip.orange { background: rgba(255,107,53,0.15); color: var(--orange); border-color: rgba(255,107,53,0.2); }
.macro-chip.green  { background: rgba(0,200,150,0.15);  color: var(--green);  border-color: rgba(0,200,150,0.2); }
.macro-chip.purple { background: rgba(155,143,255,0.15);color: var(--purple); border-color: rgba(155,143,255,0.2); }
.history-log-action-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  cursor: pointer;
  transition: var(--transition);
  font-size: 15px;
  line-height: 1;
}
.history-log-action-btn:hover {
  transform: translateY(-1px);
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.1);
}
.log-edit-btn { opacity: 1; }
.log-del-btn {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.18);
  color: var(--danger);
}
.log-del-btn:hover {
  background: rgba(239,68,68,0.18);
  border-color: rgba(239,68,68,0.28);
}

@media(max-width:768px) {
  .history-day-header {
    padding: 16px;
    align-items: flex-start;
  }
  .history-day-toggle {
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
  }
  .history-day-body-inner { padding: 2px 8px 12px; }
  .history-meal-header { padding: 12px 8px; }
  .history-meal-body-inner {
    padding: 0 0 10px 4px;
    gap: 10px;
  }
  .history-scan-card-photo .history-scan-summary { min-height: 164px; }
  .history-icon-btn {
    width: 36px;
    height: 36px;
  }
  .history-scan-footer {
    padding: 14px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .history-log-row {
    flex-direction: column;
    align-items: flex-start;
    padding: 14px;
    gap: 12px;
  }
  .history-log-macros { width: 100%; justify-content: flex-start; }
}

/* ── ADMIN CONTROLS ── */
.admin-tab-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.admin-controls { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── REGISTRY ── */
.registry-row {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 16px 18px; margin-bottom: 10px;
}
.registry-email-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px;
}
.registry-email { font-weight: 700; font-size: 14px; }
.registry-count { font-size: 12px; color: var(--muted); margin-left: auto; }
.dup-badge {
  background: rgba(255,77,106,0.15); color: #ff4d6a;
  font-size: 10px; font-weight: 800; padding: 2px 8px; border-radius: 100px;
}
.registry-accounts { display: flex; flex-direction: column; gap: 6px; }
.registry-header-row {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.5px;
  padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.registry-account-row {
  display: flex; justify-content: space-between;
  font-size: 12px; padding: 4px 0;
}
