:root {
  --bg: #0f1110;
  --surface: #171c1a;
  --surface-2: #202721;
  --surface-3: #272b25;
  --text: #f4f4ef;
  --muted: #aab1a6;
  --line: rgba(244, 244, 239, 0.1);
  --green: #50d18d;
  --blue: #66a8ff;
  --coral: #ff7f5f;
  --yellow: #f4c85d;
  --ink: #07120d;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(135deg, rgba(80, 209, 141, 0.1), transparent 34%),
    linear-gradient(180deg, #11140f 0%, var(--bg) 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 980px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 28px;
}

.topbar,
.panel-header,
.section-title,
.form-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar {
  margin-bottom: 16px;
}

.eyebrow,
.muted,
.meal-card p,
.product-card p,
.signal-card span,
.signal-card p,
.assistant-message p {
  color: var(--muted);
}

.assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.assistant-message p {
  white-space: pre-line;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 2rem;
  line-height: 1.05;
}

h2 {
  font-size: 1.12rem;
}

.icon-button,
.primary-button,
.secondary-button,
.text-button,
.tab-button,
.mini-button {
  border: 0;
  cursor: pointer;
}

.icon-button {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  background: var(--green);
  font-weight: 900;
}

.tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 0;
  background: rgba(15, 17, 16, 0.94);
  backdrop-filter: blur(14px);
}

.tab-button {
  min-height: 42px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 0.92rem;
  font-weight: 850;
}

.tab-button.active {
  color: var(--ink);
  background: var(--green);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(0, 0.92fr);
  gap: 12px;
}

.balance-panel,
.quick-panel,
.assistant-panel,
.view,
.meal-card,
.product-card,
.signal-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 28, 26, 0.94);
  box-shadow: var(--shadow);
}

.balance-panel,
.quick-panel,
.assistant-panel,
.view {
  padding: 16px;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  color: var(--ink);
  background: var(--green);
  font-size: 0.78rem;
  font-weight: 900;
  white-space: nowrap;
}

.calorie-ring {
  --ring-progress: 45%;
  display: grid;
  width: 156px;
  aspect-ratio: 1;
  margin: 18px auto;
  place-items: center;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--surface) 58%, transparent 59%),
    conic-gradient(var(--green) 0 var(--ring-progress), var(--surface-2) 0 100%);
  transition: background 180ms ease;
}

.calorie-ring span {
  font-size: 1.5rem;
  font-weight: 950;
}

.macro-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.macro-grid div {
  min-width: 0;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--surface-2);
}

.macro-grid span,
.target-bars span,
.search-box span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 0.78rem;
}

.macro-grid strong {
  display: block;
  font-size: 1rem;
}

.meal-form,
.assistant-form {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: #101410;
  outline: none;
}

textarea {
  min-height: 102px;
  resize: vertical;
  padding: 12px;
}

input,
select {
  height: 44px;
  padding: 0 12px;
}

textarea:focus,
input:focus,
select:focus {
  border-color: var(--blue);
}

.primary-button,
.secondary-button,
.text-button {
  min-height: 42px;
  border-radius: 8px;
  font-weight: 850;
}

.primary-button {
  padding: 0 16px;
  color: #07111f;
  background: var(--blue);
}

.secondary-button {
  padding: 0 14px;
  color: var(--text);
  background: var(--surface-2);
}

.text-button {
  color: var(--coral);
  background: transparent;
}

.signal-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.signal-card {
  padding: 14px;
  box-shadow: none;
}

.signal-card span {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.signal-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.2rem;
}

.signal-card p {
  margin-top: 5px;
  line-height: 1.35;
}

.assistant-panel {
  box-shadow: var(--shadow);
}

.assistant-feed {
  display: grid;
  gap: 10px;
  max-height: 460px;
  min-height: 260px;
  margin: 14px 0;
  overflow: auto;
}

.assistant-message {
  width: min(88%, 620px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.assistant-message.user {
  justify-self: end;
  background: #152235;
}

.assistant-message.bot {
  justify-self: start;
}

.assistant-message strong {
  display: block;
  margin-bottom: 4px;
}

.assistant-form {
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 0;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.meal-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.meal-card,
.product-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  box-shadow: none;
}

.meal-main {
  min-width: 0;
}

.meal-side {
  display: grid;
  justify-items: end;
  gap: 8px;
}

.meal-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.meal-card p,
.product-card p {
  margin-top: 4px;
  line-height: 1.35;
}

.meal-card span {
  color: var(--yellow);
  font-weight: 850;
  white-space: nowrap;
}

.mini-button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  background: var(--surface-2);
  font-size: 0.78rem;
  font-weight: 850;
}

.mini-button.danger {
  color: var(--coral);
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--muted);
  background: rgba(23, 28, 26, 0.58);
}

.search-box {
  display: block;
  margin: 12px 0;
}

.product-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.product-meta span {
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(32, 39, 33, 0.72);
  font-size: 0.72rem;
  font-weight: 800;
}

.section-title.compact h3 {
  margin: 0;
  font-size: 1rem;
}

.nutrient-panel {
  margin-top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 28, 26, 0.62);
}

.nutrient-grid {
  display: grid;
  gap: 14px;
  margin-top: 12px;
}

.nutrient-grid .empty-state {
  grid-column: 1 / -1;
}

.nutrient-group {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 18, 16, 0.52);
}

.nutrient-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.nutrient-group-title h4 {
  margin: 0;
  font-size: 0.98rem;
}

.nutrient-group-title span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 850;
  white-space: nowrap;
}

.nutrient-card-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.nutrient-card {
  min-height: 72px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: none;
}

.nutrient-card span,
.target-card span,
.target-bars span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.35;
}

.nutrient-card strong {
  display: block;
  margin-top: 8px;
  font-size: 1.05rem;
}

.target-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.target-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  box-shadow: none;
}

.target-card strong {
  display: block;
  margin-top: 5px;
  font-size: 1.25rem;
}

.target-card p {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.35;
}

.target-bars {
  display: grid;
  gap: 14px;
  margin-top: 14px;
}

.target-bars > div {
  display: grid;
  gap: 6px;
}

.target-form {
  display: grid;
  gap: 14px;
  margin-top: 18px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(23, 28, 26, 0.62);
}

.target-form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.target-form label {
  display: grid;
  gap: 6px;
}

.target-form label span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
}

progress {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--green);
}

@media (max-width: 760px) {
  .dashboard-grid,
  .signal-grid,
  .nutrient-card-grid,
  .target-form-grid {
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: 1.75rem;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding-inline: 10px;
  }

  .tabs {
    grid-template-columns: repeat(5, minmax(68px, 1fr));
    overflow-x: auto;
  }

  .tab-button {
    font-size: 0.84rem;
  }

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

  .target-summary {
    grid-template-columns: 1fr;
  }

  .meal-card,
  .product-card,
  .form-actions,
  .assistant-form {
    align-items: stretch;
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .meal-side,
  .meal-actions {
    justify-items: start;
    justify-content: flex-start;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }
}
