@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --bg-1: #070d1a;
  --bg-2: #0a1220;
  --card: #0c1320;
  --stroke: #182030;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #0ea5e9;
  --accent-2: #a855f7;
  --success: #16a34a;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);

  /* Consistent spacing scale */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  height: 100%;
}

body {
  margin: 0;
  font-family: "Space Grotesk", "Neue Haas Grotesk", "Helvetica Neue", sans-serif;
  background:
    radial-gradient(circle at 20% 20%, rgba(14, 165, 233, 0.15), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(168, 85, 247, 0.25), transparent 50%),
    radial-gradient(circle at 60% 80%, rgba(14, 165, 233, 0.12), transparent 45%),
    radial-gradient(circle at 10% 70%, rgba(168, 85, 247, 0.22), transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(168, 85, 247, 0.08), transparent 60%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  color: var(--text);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent);
  text-decoration: none;
}

.shell {
  width: min(1100px, 92vw);
  margin: 0 auto;
}

.top-bar {
  padding: var(--space-lg) 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-sm);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--stroke);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  padding: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
}

.brand-logo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.brand-name {
  font-weight: 700;
  font-size: 18px;
}

.brand-sub {
  font-size: 13px;
  color: var(--muted);
}

.nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.nav-link {
  padding: var(--space-sm) var(--space-md);
  border-radius: 10px;
  color: var(--text);
  transition: background 120ms ease;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.active {
  background: rgba(14, 165, 233, 0.14);
  border: 1px solid rgba(14, 165, 233, 0.5);
}

.inline-form {
  display: inline;
}

main.shell {
  padding-bottom: var(--space-xl);
  flex: 1;
}

.panel {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: var(--space-lg);
  margin-bottom: var(--space-lg);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 var(--space-sm);
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.01em;
}

.stack {
  display: grid;
  gap: var(--space-md);
}

.stack.horizontal {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.stack.compact {
  gap: var(--space-sm);
}

.field {
  display: grid;
  gap: var(--space-sm);
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: #0b1021;
  color: var(--text);
}

.field input:focus,
.field select:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.field input:-webkit-autofill,
.field input:-webkit-autofill:hover,
.field input:-webkit-autofill:focus,
.field input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 1000px #0b1021 inset !important;
  -webkit-text-fill-color: var(--text) !important;
  box-shadow: 0 0 0 1000px #0b1021 inset !important;
  caret-color: var(--text);
  transition: background-color 5000s ease-in-out 0s;
}

.field.compact {
  gap: var(--space-xs);
}

.captcha-image {
  background: #1a1a2e;
  border-radius: 8px;
  padding: var(--space-sm);
  display: flex;
  justify-content: center;
}

.captcha-image svg {
  max-width: 100%;
  height: auto;
}

button,
.button,
.primary,
.ghost {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: var(--space-md) var(--space-lg);
  font-weight: 700;
  color: #0b0f1c;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  transition: transform 100ms ease, filter 120ms ease;
}

button:hover,
.primary:hover,
.ghost:hover {
  filter: brightness(1.05);
}

button:active,
.primary:active,
.ghost:active {
  transform: translateY(1px);
}

.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--stroke);
}

.ghost.danger {
  border-color: rgba(239, 68, 68, 0.5);
  color: #fca5a5;
}

button:disabled,
.ghost:disabled,
.primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #2a2a3a;
  color: #6b7280;
}

button:focus-visible,
.ghost:focus-visible,
.primary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

a:focus-visible,
.nav-link:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.alert {
  padding: var(--space-md) var(--space-lg);
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  margin-bottom: var(--space-md);
}

.alert.success {
  border-color: rgba(22, 163, 74, 0.5);
  color: #bbf7d0;
}

.alert.danger {
  border-color: rgba(239, 68, 68, 0.6);
  color: #fecdd3;
}

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

.grid.two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
}

.stat {
  padding: var(--space-md);
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 200ms ease, background 200ms ease;
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: var(--space-sm);
}

.stat-detail {
  margin-top: var(--space-xs);
  display: block;
}

/* Balance stat color states */
.stat-balance.stat-success {
  background: rgba(22, 163, 74, 0.08);
  border-color: rgba(22, 163, 74, 0.3);
}

.stat-balance.stat-success .stat-value {
  color: #86efac;
}

.stat-balance.stat-warning {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.3);
}

.stat-balance.stat-warning .stat-value {
  color: #fcd34d;
}

.stat-balance.stat-danger {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.3);
}

.stat-balance.stat-danger .stat-value {
  color: #fca5a5;
}

.small {
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: var(--space-sm) var(--space-md);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 600;
  border: 1px solid transparent;
}

.chip.success {
  background: rgba(22, 163, 74, 0.15);
  border-color: rgba(22, 163, 74, 0.5);
}

.chip.danger {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.6);
}

.chip.muted {
  color: var(--muted);
  border-color: var(--stroke);
}

.chip.subtle {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--stroke);
  color: var(--text);
}

.pill-group {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-md);
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md);
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-weight: 600;
  transition: border-color 120ms ease, background 120ms ease, transform 100ms ease;
}

.pill input {
  display: none;
}

.pill:hover {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(14, 165, 233, 0.06);
}

.pill.active {
  border-color: rgba(14, 165, 233, 0.9);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.16), rgba(14, 165, 233, 0.08));
  box-shadow: 0 10px 40px rgba(14, 165, 233, 0.2);
}

.preference-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
}

.beta-badge {
  margin-left: 8px;
  font-size: 11px;
  padding: 2px 8px;
  background: #f5f6f8;
  border-color: var(--stroke);
  color: #111;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.table {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
}

.table-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--stroke);
  gap: var(--space-md);
}

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

.table-row.header {
  background: rgba(255, 255, 255, 0.04);
  font-weight: 700;
}

.table-row.linked-row {
  grid-template-columns: 1fr auto;
}

.dot-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18px, 32px));
  row-gap: 36px;
  column-gap: 12px;
  align-items: end;
  margin: 22px 0 12px;
  justify-content: space-between;
}

.table-row > div {
  min-width: 0;
}

.table-email {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.entry-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md);
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 140ms ease, background 140ms ease;
}

.entry-row.view-only {
  grid-template-columns: 1fr auto auto;
}

.entry-row:hover {
  border-color: rgba(14, 165, 233, 0.4);
  background: rgba(255, 255, 255, 0.04);
}

.entry-name {
  font-weight: 600;
  font-size: 15px;
}

.entry-actions {
  display: grid;
  grid-template-columns: 100px 52px 70px;
  align-items: center;
  gap: var(--space-sm);
}

.entry-amount-wrap {
  display: flex;
  align-items: center;
  width: 100px;
  justify-content: flex-start;
  position: relative;
}

.edit-trigger {
  background: none;
  border: none;
  padding: 8px 10px;
  min-height: 36px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
}

.edit-trigger:hover {
  color: var(--accent);
  background: rgba(255, 255, 255, 0.04);
}

.edit-trigger:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.edit-trigger.is-locked {
  pointer-events: none;
  cursor: default;
}

.edit-trigger.is-locked:hover {
  background: none;
  color: inherit;
}

.weight-input.is-disabled {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--stroke);
  color: var(--muted);
  cursor: not-allowed;
}

.inline-edit {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-top: var(--space-xs);
}

.inline-edit.is-saving {
  opacity: 0.7;
}

.inline-edit-input {
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: #0b1021;
  color: var(--text);
  min-width: 120px;
}

.inline-edit-input--amount {
  min-width: 100px;
  text-align: right;
}

.inline-edit-input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.inline-edit-actions {
  display: flex;
  gap: var(--space-sm);
  margin-left: auto;
  justify-content: flex-end;
  flex-direction: row-reverse;
}

.inline-edit-spinner {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.inline-edit-spinner.hidden {
  display: none;
}

.entry-row.is-editing {
  border-color: rgba(14, 165, 233, 0.4);
}

.entry-row.is-editing .entry-amount {
  color: var(--text);
}

.danger-text {
  color: #fca5a5;
}

.entry-time {
  width: 52px;
  text-align: left;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

.entry-amount {
  font-weight: 700;
  min-width: 60px;
  text-align: left;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: var(--text);
}

.entry-amount.pos {
  color: var(--accent);
}

.entry-amount.neg {
  color: var(--accent-2);
}

.weight-row {
  border-color: rgba(125, 211, 252, 0.35);
  background: linear-gradient(120deg, rgba(14, 165, 233, 0.08), rgba(125, 211, 252, 0.04));
}

.weight-row:hover {
  border-color: rgba(125, 211, 252, 0.55);
  background: linear-gradient(120deg, rgba(14, 165, 233, 0.12), rgba(125, 211, 252, 0.08));
}

.weight-row .entry-name {
  color: #e0f2fe;
}

.entry-amount.weight {
  color: #7dd3fc;
}

.entry-amount.weight:hover {
  color: #a5f3fc;
}

.log-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.weight-inline {
  margin-top: var(--space-sm);
  align-items: center;
  flex-wrap: nowrap;
}

.weight-inline .inline-edit-input {
  width: 120px;
  max-width: 140px;
}

.inline-edit--amount {
  flex-wrap: nowrap;
  position: absolute;
  left: 0;
  z-index: 10;
}

.inline-edit--amount .inline-edit-input {
  width: 80px;
  min-width: 80px;
  text-align: right;
}

.delete-placeholder {
  display: inline-block;
}

.delete-placeholder .placeholder-delete {
  opacity: 0;
  pointer-events: none;
}


@media (max-width: 640px) {
  .entry-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
  }

  .entry-actions {
    width: 100%;
    justify-content: flex-start;
    gap: 8px;
    display: flex;
    align-items: center;
  }

  .entry-amount-wrap {
    min-width: auto;
    justify-content: flex-start;
  }

  .entry-time {
    margin-left: auto;
    min-width: auto;
    font-size: 12px;
  }

  .inline-edit {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-edit-actions {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
    flex-direction: row-reverse;
  }

  .inline-edit-input {
    width: 100%;
    min-width: 0;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.panel-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
}

.panel-toggle .muted {
  margin: 0;
}

.day-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.day-chip {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  min-height: 40px;
  cursor: pointer;
  transition: background 120ms ease, border 120ms ease;
  display: inline-flex;
  align-items: center;
}

.day-chip:hover {
  border-color: rgba(14, 165, 233, 0.5);
}

.day-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.day-chip.active {
  background: rgba(14, 165, 233, 0.14);
  border-color: rgba(14, 165, 233, 0.6);
}

.day-selected {
  color: var(--muted);
  font-size: 13px;
  margin-top: var(--space-sm);
  margin-bottom: var(--space-md);
}

.timeframe {
  display: grid;
  gap: var(--space-md);
  justify-items: end;
}

.range-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  justify-content: flex-start;
}

.range-chip {
  padding: 9px 12px;
  min-height: 38px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  cursor: pointer;
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border 120ms ease, background 120ms ease, transform 100ms ease;
}

.range-chips.nested {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, max-content));
  justify-content: start;
  max-width: 340px;
}

.range-chip.narrow {
  padding: 8px 10px;
  min-height: 36px;
}

.range-chip:hover {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(14, 165, 233, 0.1);
}

.range-chip:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.range-chip.active {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.2), rgba(245, 158, 11, 0.2));
  border-color: rgba(14, 165, 233, 0.8);
  box-shadow: 0 10px 26px rgba(14, 165, 233, 0.15);
  transform: translateY(-1px);
}

.range-controls {
  display: grid;
  gap: var(--space-sm);
  justify-items: end;
}

.range-toggle {
  padding: var(--space-sm) var(--space-md);
}

.range-custom {
  display: flex;
  align-items: flex-end;
  gap: var(--space-sm);
  flex-wrap: nowrap;
}

.range-custom .field {
  flex: 1 1 160px;
}

.range-custom button {
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .timeframe {
    justify-items: start;
    width: 100%;
  }

  .range-chips {
    justify-content: flex-start;
  }

  .range-controls {
    justify-items: start;
  }

  .range-custom {
    flex-wrap: wrap;
    width: 100%;
  }

  .range-custom .field {
    flex: 1 1 140px;
    min-width: 0;
  }

  .range-custom button {
    width: 100%;
  }
}

.hidden {
  display: none !important;
}

.data-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-lg);
}

.data-card {
  padding: var(--space-lg);
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.danger-card {
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.06);
}

.spaced-top {
  margin-top: var(--space-md);
}

.upload-row {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
  flex-wrap: wrap;
}

.file-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
  color: var(--text);
}

.file-input::file-selector-button {
  padding: 8px 12px;
  margin-right: 12px;
  border: none;
  border-radius: 8px;
  background: rgba(14, 165, 233, 0.14);
  color: var(--text);
  cursor: pointer;
}

.file-input:hover {
  border-color: rgba(14, 165, 233, 0.5);
}

.upload-trigger {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--stroke);
  color: var(--text);
  cursor: pointer;
  transition: background 120ms ease, border 120ms ease;
}

.upload-trigger:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(14, 165, 233, 0.5);
}

.upload-trigger input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.primary.full {
  width: 100%;
  text-align: center;
  margin-top: auto;
}

.share-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-md);
}

.share-card {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.02);
  padding: var(--space-md) var(--space-md) var(--space-sm);
}

.share-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: flex-start;
  gap: var(--space-xs) var(--space-sm);
  margin-bottom: 0;
}

.share-card-head > div:first-child {
  min-width: 0;
}

.share-title {
  margin: 0;
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-height: 24px;
}

.share-title-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: left;
  display: block;
  width: 100%;
  min-height: 24px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.share-card.is-editing .share-title {
  white-space: normal;
  overflow: visible;
}

.share-card-head .chip {
  justify-self: end;
  max-width: 140px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.share-card .dot-row {
  margin: 16px 0 4px 0;
}

.weight-panel .panel-header {
  align-items: flex-start;
}

.weight-form {
  display: grid;
  gap: var(--space-md);
}

.weight-hint {
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed var(--stroke);
  padding: var(--space-md);
  border-radius: 10px;
  margin-top: var(--space-sm);
}

.dot-wrap {
  text-align: center;
  position: relative;
  cursor: pointer;
}

.dot {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  margin: 0 auto;
  transition: box-shadow 120ms ease, transform 120ms ease;
}

.dot.success {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  box-shadow: 0 8px 20px rgba(34, 197, 94, 0.35);
}

.dot.danger {
  background: linear-gradient(135deg, #ef4444, #f97316);
  box-shadow: 0 8px 20px rgba(239, 68, 68, 0.35);
}

.dot.warn {
  background: linear-gradient(135deg, #f59e0b, #fbbf24);
  box-shadow: 0 8px 20px rgba(245, 158, 11, 0.35);
}

.dot.muted {
  background: rgba(255, 255, 255, 0.08);
  border: 1px dashed var(--stroke);
}

.dot.zero {
  background: linear-gradient(135deg, #4b5563, #6b7280);
  box-shadow: 0 6px 16px rgba(107, 114, 128, 0.35);
}

.dot-wrap.active .dot {
  box-shadow:
    0 0 0 4px rgba(255, 255, 255, 0.12),
    0 0 0 8px rgba(14, 165, 233, 0.45),
    0 12px 22px rgba(14, 165, 233, 0.2);
  transform: translateY(-3px) scale(1.08);
}

.dot.today {
  position: relative;
  background: linear-gradient(135deg, #0ea5e9, #38bdf8);
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.35);
}

.dot.today::after {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  animation: spin 2.2s linear infinite;
}

.dot-wrap::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid var(--stroke);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease, transform 120ms ease;
  box-shadow: var(--shadow);
}

.dot-wrap:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(-2px);
}

.qr img {
  width: 180px;
  height: 180px;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.totp-setup {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-lg);
}

.totp-setup form {
  width: 100%;
}

.qr-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.qr-center img {
  width: 180px;
  height: 180px;
  background: #fff;
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

.totp-secret {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.totp-secret code {
  flex: 1;
  font-size: 0.75rem;
}

.totp-secret button {
  flex-shrink: 0;
}

.break {
  word-break: break-all;
  display: block;
}

.footer {
  padding: var(--space-lg) 0;
  margin-top: auto;
}

.footer-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  flex-wrap: wrap;
}

.footer-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.footer-quote {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.footer-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
}

.muted-link {
  color: var(--muted);
  font-weight: 600;
}

.separator {
  margin: 0 6px;
  color: var(--muted);
}

.imprint-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin-bottom: var(--space-md);
}

.imprint-label {
  margin-left: -12px;
}

.imprint-img {
  display: block;
  max-width: 100%;
  height: auto;
  margin-top: var(--space-xs);
  margin-left: -12px; /* Pull left to align text optically */
  border-radius: var(--radius-sm);
}

.build-tag {
  display: inline-flex;
  align-items: center;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 12px;
  backdrop-filter: blur(4px);
  z-index: 20;
}

.table-actions {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.link-form {
  margin-bottom: var(--space-lg);
}

/* Hamburger Menu Styles */
.hamburger {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  padding: 8px;
  cursor: pointer;
  border-radius: 8px;
  transition: background 120ms ease;
}

.hamburger:hover {
  background: rgba(255, 255, 255, 0.06);
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: transform 200ms ease, opacity 200ms ease;
}

.hamburger.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

/* Tablet Breakpoint */
@media (max-width: 900px) {
  .shell {
    width: min(1100px, 94vw);
  }

  .stats {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  }

  .grid.two {
    grid-template-columns: 1fr;
  }
}

/* Mobile Navigation */
@media (max-width: 768px) {
  .top-bar {
    padding: 16px 0;
  }

  .hamburger {
    display: flex;
  }

  .nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 280px;
    height: 100vh;
    background: var(--card);
    border-left: 1px solid var(--stroke);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.6);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 20px;
    transform: translateX(100%);
    transition: transform 250ms ease;
    z-index: 1000;
    overflow-y: auto;
  }

  .nav.active {
    transform: translateX(0);
  }

  .nav-link {
    padding: 14px 16px;
    border-radius: 10px;
    display: block;
    margin-bottom: 4px;
    font-size: 16px;
  }

  .nav .ghost {
    width: 100%;
    text-align: left;
    padding: 14px 16px;
    margin-top: 8px;
  }

  .nav .inline-form {
    display: block;
  }

  /* Mobile overlay */
  .mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background: rgba(11, 18, 36, 0.85);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    transition: opacity 250ms ease;
  }

  .mobile-overlay.active {
    display: block;
    opacity: 1;
  }
}

@media (max-width: 640px) {
  .shell {
    width: min(1100px, 90vw);
  }

  .top-bar {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-md) 0;
    margin-bottom: var(--space-xs);
  }

  .brand {
    flex: 1;
    gap: var(--space-sm);
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .brand-name {
    font-size: 16px;
  }

  .brand-sub {
    font-size: 12px;
  }

  .nav {
    width: 260px;
    padding: var(--space-lg);
  }

  main.shell {
    padding-bottom: var(--space-lg);
  }

  .entry-row {
    grid-template-columns: 1fr;
    align-items: flex-start;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
  }

  .entry-actions {
    width: 100%;
    justify-content: flex-start;
    gap: var(--space-sm);
    display: flex;
    align-items: center;
  }

  .entry-amount-wrap {
    min-width: auto;
    justify-content: flex-start;
  }

  .entry-time {
    margin-left: auto;
    min-width: auto;
    font-size: 12px;
  }

  .inline-edit {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-edit-actions {
    width: 100%;
    justify-content: flex-end;
    margin-left: 0;
    flex-direction: row-reverse;
  }

  .inline-edit-input {
    width: 100%;
    min-width: 0;
  }

  .table-row {
    grid-template-columns: 1.2fr 1fr 1fr;
    padding: var(--space-md);
    font-size: 14px;
  }

  .table-row.linked-row {
    grid-template-columns: 1fr auto;
  }

  .table-actions {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-sm);
  }

  .table-actions .ghost {
    width: 100%;
  }

  .timeframe {
    justify-items: start;
  }

  .range-custom {
    justify-content: flex-start;
  }

  .panel {
    padding: var(--space-md);
    margin-bottom: var(--space-md);
  }

  .panel-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
  }

  .stats {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-sm);
  }

  .stat {
    padding: var(--space-sm);
  }

  .stat-value {
    font-size: 18px;
  }

  .stat-label {
    font-size: 12px;
  }

  button,
  .button,
  .primary,
  .ghost {
    padding: var(--space-md) var(--space-lg);
    font-size: 15px;
    min-height: 44px;
  }

  .field input,
  .field select {
    padding: var(--space-md);
    font-size: 16px;
    min-height: 44px;
  }

  .stack.horizontal {
    grid-template-columns: 1fr;
  }

  .data-actions {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .share-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .preference-grid {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .pill-group {
    grid-template-columns: 1fr;
    gap: var(--space-sm);
  }

  .day-picker {
    gap: var(--space-xs);
    margin-bottom: var(--space-sm);
  }

  .day-chip {
    padding: var(--space-sm) var(--space-md);
    font-size: 14px;
  }

  .range-chip {
    padding: var(--space-sm) var(--space-md);
    font-size: 13px;
  }

  .dot-row {
    grid-template-columns: repeat(auto-fit, minmax(20px, 36px));
    row-gap: 18px;
    column-gap: var(--space-xs);
    justify-content: space-between;
  }

  .dot {
    width: 20px;
    height: 20px;
  }

  h1 {
    font-size: 22px;
    margin-bottom: var(--space-sm);
  }

  h2 {
    font-size: 18px;
    margin-bottom: var(--space-xs);
  }

  .footer {
    padding: var(--space-md) 0;
    margin-top: var(--space-lg);
  }

  .footer-content {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-md);
  }

  .footer-right {
    width: 100%;
    justify-content: flex-start;
  }

  .footer-quote {
    font-size: 16px;
  }

  .qr img {
    width: 160px;
    height: 160px;
  }
}

/* AI Photo Estimation */
.input-with-action {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: var(--space-xs);
}

.input-with-action input {
  flex: 1;
  min-width: 0;
}

.ai-photo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15), rgba(14, 165, 233, 0.15));
  color: var(--accent-2);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, transform 100ms ease;
  min-width: 44px;
  min-height: 44px;
}

.ai-photo-btn:hover {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.25), rgba(14, 165, 233, 0.25));
  border-color: rgba(168, 85, 247, 0.5);
}

.ai-photo-btn:active {
  transform: scale(0.96);
}

.ai-photo-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.ai-photo-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.ai-usage-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(168, 85, 247, 0.2);
  color: var(--accent-2);
  min-width: 18px;
  text-align: center;
}

.ai-usage-badge.exhausted {
  background: rgba(239, 68, 68, 0.2);
  color: var(--danger);
}

.ai-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7, 13, 26, 0.95);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  opacity: 0;
  visibility: hidden;
  transition: opacity 200ms ease, visibility 200ms ease;
}

.ai-modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.ai-modal {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

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

.ai-modal-header h3 {
  margin: 0;
  font-size: 18px;
}

.ai-modal-close {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: 8px;
  transition: background 120ms ease, color 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ai-modal-close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.ai-modal-minimal {
  padding: 0;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
  background: black;
  position: relative;
}

.ai-modal-minimal .ai-modal-body {
  padding: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
}

.ai-modal-minimal .ai-preview-container {
  flex: 1;
  height: 100%;
  aspect-ratio: auto;
}

.ai-modal-close-float {
  position: absolute;
  bottom: var(--space-lg);
  right: calc(50% - 100px);
  z-index: 10;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: 50%;
  transition: background 120ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
}

.ai-modal-close-float:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}

.ai-modal-body {
  padding: var(--space-lg);
}

.ai-modal-actions {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.ai-modal-actions button,
.ai-modal-actions label {
  flex: 1;
}

.ai-preview-container {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
  margin-bottom: var(--space-lg);
  aspect-ratio: 4/3;
}

.ai-preview-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.ai-video-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ai-capture-btn {
  position: absolute;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: 4px solid white;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  cursor: pointer;
  transition: transform 100ms ease;
  z-index: 10;
}

.ai-capture-btn:hover {
  transform: translateX(-50%) scale(1.05);
}

.ai-capture-btn:active {
  transform: translateX(-50%) scale(0.95);
}

.ai-upload-alt {
  position: absolute;
  bottom: var(--space-xl);
  right: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  z-index: 10;
}

.ai-upload-alt:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}

.ai-close-alt {
  position: absolute;
  bottom: var(--space-xl);
  left: var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  z-index: 10;
}

.ai-close-alt:hover {
  background: rgba(0, 0, 0, 0.8);
  border-color: rgba(255, 255, 255, 0.5);
}

.ai-camera-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-lg);
  padding: var(--space-xl);
  min-height: 200px;
  position: relative;
}

.ai-fallback-close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.3);
  color: white;
  cursor: pointer;
  transition: background 150ms ease;
}

.ai-fallback-close:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.5);
}

.ai-context {
  margin-top: var(--space-md);
}

.ai-context .field {
  margin-bottom: var(--space-md);
}

.ai-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-xl);
}

.ai-loading-spinner {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 4px solid rgba(168, 85, 247, 0.2);
  border-top-color: var(--accent-2);
  animation: spin 1s linear infinite;
}

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

.ai-result {
  padding: var(--space-lg);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}

.ai-result-calories {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: var(--space-sm);
}

.ai-result-food {
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.ai-result-confidence {
  font-size: 13px;
  color: var(--muted);
}

.ai-result-actions {
  display: flex;
  gap: var(--space-sm);
  margin-top: var(--space-lg);
}

.ai-result-actions button {
  flex: 1;
}

@media (max-width: 640px) {
  .ai-modal-overlay {
    padding: 0;
  }

  .ai-modal {
    max-width: 100%;
    max-height: 100%;
    height: 100%;
    border-radius: 0;
    border: none;
  }

  .ai-preview-container {
    aspect-ratio: auto;
    height: 50vh;
  }
}

/* Landscape mode support for AI camera modal */
@media (orientation: landscape) and (max-height: 500px) {
  .ai-modal-overlay {
    padding: 0;
  }

  .ai-modal-minimal {
    width: 100vw;
    height: 100vh;
    max-width: 100vw;
    max-height: 100vh;
    border-radius: 0;
  }

  .ai-modal-minimal .ai-modal-body {
    height: 100%;
    padding: 0;
  }

  .ai-modal-minimal .ai-preview-container {
    width: 100%;
    height: 100%;
    border-radius: 0;
    margin: 0;
  }

  .ai-video-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }

  /* Move close buttons to bottom-right */
  .ai-modal-close-float,
  .ai-close-alt {
    top: auto;
    bottom: var(--space-xl);
    right: var(--space-xl);
    left: auto;
    transform: none;
  }

  /* Move capture button to right side, vertically centered */
  .ai-capture-btn {
    bottom: auto;
    left: auto;
    right: var(--space-xl);
    top: 50%;
    transform: translateY(-50%);
  }

  .ai-capture-btn:hover {
    transform: translateY(-50%) scale(1.05);
  }

  .ai-capture-btn:active {
    transform: translateY(-50%) scale(0.95);
  }

  /* Move upload button to top-right */
  .ai-upload-alt {
    top: var(--space-xl);
    bottom: auto;
    left: auto;
    right: var(--space-xl);
    transform: none;
  }

  .ai-context {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 80px;
    padding: var(--space-md);
    background: linear-gradient(transparent, rgba(0,0,0,0.8));
  }

  .ai-loading {
    justify-content: center;
  }

  .ai-result {
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: var(--space-lg);
  }

  .ai-result-actions {
    flex-wrap: wrap;
  }
}

/* Landing Page */
.landing {
  padding: var(--space-3xl) 0;
  text-align: center;
}

.landing-hero {
  max-width: 700px;
  margin: 0 auto var(--space-3xl);
}

.landing-title {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 700;
  margin: 0 0 var(--space-xl);
  background: linear-gradient(135deg, var(--text), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.landing-subtitle {
  font-size: 1.25rem;
  color: var(--muted);
  line-height: 1.6;
  margin: 0 0 var(--space-2xl);
}

.landing-cta {
  display: flex;
  gap: var(--space-lg);
  justify-content: center;
  flex-wrap: wrap;
}

.btn.large {
  padding: var(--space-lg) var(--space-2xl);
  font-size: 1.1rem;
}

.landing-features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-xl);
  margin: var(--space-3xl) 0;
}

.feature-card {
  background: var(--card);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: var(--space-xl);
  text-align: left;
}

.feature-icon {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15), rgba(168, 85, 247, 0.15));
  display: grid;
  place-items: center;
  margin-bottom: var(--space-lg);
  color: var(--accent);
}

.feature-card h3 {
  margin: 0 0 var(--space-sm);
  font-size: 1.1rem;
}

.feature-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.landing-apps {
  margin-top: var(--space-3xl);
}

.landing-apps p {
  margin: 0 0 var(--space-lg);
}

.app-badges {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
}

.app-badge img {
  height: 60px;
}
