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

:root {
  --bg-1: #0b1224;
  --bg-2: #0f172a;
  --card: #111827;
  --stroke: #1f2937;
  --text: #e5e7eb;
  --muted: #9ca3af;
  --accent: #0ea5e9;
  --accent-2: #f59e0b;
  --success: #16a34a;
  --danger: #ef4444;
  --radius: 14px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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 40%),
    radial-gradient(circle at 80% 10%, rgba(245, 158, 11, 0.18), transparent 35%),
    linear-gradient(135deg, var(--bg-1), var(--bg-2));
  color: var(--text);
  min-height: 100vh;
}

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

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

.top-bar {
  padding: 20px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.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: 12px;
}

.nav-link {
  padding: 8px 12px;
  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: 16px;
}

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

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

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

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

.stack {
  display: grid;
  gap: 10px;
}

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

.stack.compact {
  gap: 8px;
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.field input,
.field select {
  width: 100%;
  padding: 12px 14px;
  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.compact {
  gap: 4px;
}

button,
.button,
.primary,
.ghost {
  border: none;
  cursor: pointer;
  border-radius: 10px;
  padding: 12px 16px;
  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.55;
  cursor: not-allowed;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
}

.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: 14px;
}

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

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

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

.stat-value {
  font-size: 20px;
  font-weight: 700;
  margin-top: 6px;
}

.small {
  font-size: 12px;
}

.chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  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: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  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: 12px;
}

.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: 12px 14px;
  border-bottom: 1px solid var(--stroke);
}

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

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

.dot-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(18px, 1fr));
  gap: 10px 12px;
  align-items: end;
  margin: 22px 0 12px;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.entry-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 14px;
  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-auto-flow: column;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.entry-amount-wrap {
  display: flex;
  align-items: center;
  min-width: 72px;
  justify-content: flex-start;
}

.edit-trigger {
  background: none;
  border: none;
  padding: 6px 8px;
  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.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: 10px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.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: 6px;
  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 {
  min-width: 56px;
  text-align: right;
  opacity: 0.9;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  margin-right: 6px;
}

.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(--danger);
}

.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: 12px;
}

.weight-inline {
  margin-top: 6px;
  align-items: center;
  flex-wrap: nowrap;
}

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

.inline-edit--amount {
  flex-wrap: nowrap;
}

.inline-edit--amount .inline-edit-input {
  width: 120px;
  max-width: 140px;
  text-align: right;
}

.delete-placeholder .placeholder-delete {
  visibility: hidden;
  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: 12px;
  margin-bottom: 10px;
}

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

.day-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.day-chip {
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-radius: 12px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 120ms ease, border 120ms ease;
}

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

.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: 8px;
  margin-bottom: 10px;
}

.timeframe {
  display: grid;
  gap: 10px;
  justify-items: end;
}

.range-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-start;
}

.range-chip {
  padding: 7px 10px;
  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;
  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: 6px 8px;
}

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

.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: 8px;
  justify-items: end;
}

.range-toggle {
  padding: 8px 12px;
}

.range-custom {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  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: 18px;
}

.data-card {
  padding: 16px;
  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: 10px;
}

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

.spaced-top {
  margin-top: 12px;
}

.upload-row {
  display: flex;
  gap: 12px;
  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: 14px;
}

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

.share-card-head {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: flex-start;
  gap: 6px 10px;
  margin-bottom: 8px;
}

.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-top: 10px;
}

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

.weight-form {
  display: grid;
  gap: 10px;
}

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

.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);
}

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

.footer {
  padding: 10px 0 12px;
}

.build-tag {
  position: fixed;
  right: 14px;
  bottom: 12px;
  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;
}

.link-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.02);
}

.link-row > div:first-child {
  flex: 1;
  min-width: 0;
}

.link-email {
  font-weight: 600;
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.link-form {
  margin-bottom: 16px;
}

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .nav {
    flex-wrap: wrap;
  }

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

  .timeframe {
    justify-items: start;
  }

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