﻿:root {
  --bg: #f4f1e8;
  --card: rgba(255, 255, 255, 0.82);
  --card-strong: #ffffff;
  --line: #d6ded6;
  --text: #26352d;
  --muted: #5f7167;
  --accent: #6f8f7b;
  --accent-dark: #456252;
  --accent-soft: #e3ece4;
  --shadow: 0 24px 60px rgba(50, 71, 60, 0.12);
  --radius-lg: 24px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(190, 211, 196, 0.45), transparent 30%),
    radial-gradient(circle at top right, rgba(215, 201, 175, 0.35), transparent 28%),
    linear-gradient(180deg, #f7f4eb 0%, #f0ede4 100%);
  font-family: "Aptos", "Segoe UI Variable", "Trebuchet MS", sans-serif;
}
button, input, select, a { font: inherit; }
textarea { font: inherit; }
.app-shell { width: min(1360px, calc(100% - 24px)); margin: 0 auto; padding: 18px 0 40px; }
.hero {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin-bottom: 18px; padding: 24px; border: 1px solid rgba(111, 143, 123, 0.18);
  border-radius: 28px; background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(232,239,233,0.76));
  box-shadow: var(--shadow);
}
.hero-side { display: grid; gap: 12px; justify-items: end; }
.session-chip {
  display: grid; gap: 4px; padding: 12px 14px; border-radius: 18px;
  background: rgba(255,255,255,0.78); border: 1px solid rgba(111,143,123,0.14); min-width: 140px;
}
.session-chip span { color: var(--muted); font-size: 0.8rem; }
.session-chip strong { color: var(--accent-dark); }
.logout-link { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.login-shell { min-height: 100vh; display: grid; place-items: center; }
.login-card {
  width: min(460px, 100%); padding: 28px; border-radius: 28px; background: linear-gradient(145deg, rgba(255,255,255,0.94), rgba(236,241,235,0.82));
  border: 1px solid rgba(111,143,123,0.16); box-shadow: var(--shadow);
}
.login-card h1 {
  margin: 0 0 8px; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: clamp(2rem, 5vw, 3rem); line-height: 0.95;
}
.login-form { display: grid; gap: 14px; margin-top: 20px; }
.error-banner {
  margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: rgba(150, 64, 45, 0.08); color: #8d4b3d; border: 1px solid rgba(150, 64, 45, 0.12);
}
.success-banner {
  margin-top: 16px; padding: 12px 14px; border-radius: 14px; background: rgba(69, 98, 82, 0.08); color: #456252; border: 1px solid rgba(69, 98, 82, 0.12);
}
.eyebrow, .card-kicker {
  margin: 0 0 8px; color: var(--accent-dark); font-size: 0.74rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}
.hero h1 {
  margin: 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 0.95;
}
.hero p { margin: 10px 0 0; max-width: 46ch; color: var(--muted); }
.app-meta-line { margin-top: 8px; font-size: 0.92rem; }
.language-picker {
  display: grid; gap: 8px; min-width: 100px; padding: 14px; border-radius: 18px; background: rgba(255,255,255,0.76); border: 1px solid rgba(111,143,123,0.14);
}
.language-picker span, label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.tab-bar {
  position: sticky; top: 0; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  margin-bottom: 18px; padding: 8px; border: 1px solid rgba(111,143,123,0.14); border-radius: 20px; background: rgba(248,245,238,0.88); backdrop-filter: blur(12px);
}
.tab-button { padding: 14px 16px; border: 0; border-radius: 14px; background: transparent; color: var(--muted); font-weight: 700; }
.tab-button.active { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); color: white; }
.tab-button:disabled, .tab-button-disabled { opacity: 0.45; cursor: not-allowed; }
.tab-panel { display: none; animation: fade-up 220ms ease; }
.tab-panel.active { display: block; }
.card { padding: 20px; border: 1px solid rgba(111,143,123,0.16); border-radius: var(--radius-lg); background: var(--card); box-shadow: var(--shadow); }
.card + .totals-grid, .totals-grid + .card { margin-top: 18px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.card-head.compact { margin-bottom: 20px; }
.card-head h2, .card-head h3 { margin: 0; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; font-size: 1.5rem; }
.muted { margin: 6px 0 0; color: var(--muted); }
.product-input, input[type="search"], input[type="number"], input[type="text"], input[type="password"], input[type="date"], select {
  width: 100%; min-height: 46px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,0.88); color: var(--text);
}
.custom-food-notes {
  width: 100%;
  min-height: 78px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.88);
  color: var(--text);
  resize: vertical;
}
.product-input { min-width: min(100%, 360px); }
.split-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); gap: 18px; }
.panel { min-width: 0; padding: 18px; border: 1px solid rgba(111,143,123,0.14); border-radius: 20px; background: rgba(249,247,242,0.85); }
.table-wrap { overflow: auto; border: 1px solid rgba(111,143,123,0.12); border-radius: 16px; background: var(--card-strong); }
.data-table { width: 100%; border-collapse: collapse; min-width: 640px; }
.data-table th, .data-table td { padding: 14px 16px; text-align: left; border-bottom: 1px solid #edf1ec; vertical-align: middle; }
.data-table th { position: sticky; top: 0; background: #eef5f0; color: var(--accent-dark); font-size: 0.88rem; z-index: 1; }
.data-table tbody tr:nth-child(even) { background: #fbfcfa; }
.data-table .numeric { text-align: center; white-space: nowrap; }
.tab-panel[data-panel="calculator"] .split-layout { grid-template-columns: minmax(0, 1.25fr) minmax(0, 0.75fr); }
#manual-table { min-width: 560px; table-layout: fixed; }
#manual-table th, #manual-table td { padding: 11px 10px; }
#manual-table th { font-size: 0.82rem; line-height: 1.12; }
#manual-table th:nth-child(1), #manual-table td:nth-child(1) { width: 23%; }
#manual-table th:nth-child(2), #manual-table td:nth-child(2) { width: 17%; text-align: center; }
#manual-table th:nth-child(3), #manual-table td:nth-child(3),
#manual-table th:nth-child(4), #manual-table td:nth-child(4),
#manual-table th:nth-child(5), #manual-table td:nth-child(5) { width: 20%; text-align: center; }
#manual-table .manual-input { min-height: 40px; padding: 8px 10px; }
.tab-panel[data-panel="calculator"] #imported-list { max-height: 460px; overflow: auto; padding-right: 4px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.primary, .secondary, .ghost, .remove-button {
  min-height: 44px; padding: 10px 16px; border-radius: 999px; border: 0; font-weight: 700;
}
.primary { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-dark) 100%); color: white; }
.secondary { background: rgba(111,143,123,0.12); color: var(--accent-dark); }
.ghost { background: transparent; color: var(--accent-dark); border: 1px solid rgba(111,143,123,0.18); }
.ghost.danger, .secondary.danger { background: rgba(150,64,45,0.1); color: #8d4b3d; border: 1px solid rgba(150,64,45,0.2); }
button:disabled { opacity: 0.48; cursor: not-allowed; }
.selected-list, .results-list { display: grid; gap: 12px; }
.selected-item, .result-card { padding: 16px; border: 1px solid rgba(111,143,123,0.14); border-radius: 18px; background: rgba(255,255,255,0.88); }
.result-card { cursor: pointer; }
.result-card.active { border-color: rgba(69,98,82,0.55); box-shadow: 0 16px 30px rgba(69,98,82,0.09); }
.result-card h3, .selected-item h3, #selected-name { margin: 0; font-size: 1.08rem; }
.saved-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(111,143,123,0.16); }
.saved-block.standalone { margin-top: 0; padding-top: 0; border-top: 0; }
.saved-results-card { margin-top: 18px; }
.saved-results-list { display: grid; gap: 8px; max-height: 280px; overflow: auto; padding-right: 4px; }
.saved-item {
  padding: 10px 12px;
  border: 1px solid rgba(111,143,123,0.14);
  border-radius: 14px;
  background: rgba(255,255,255,0.86);
}
.saved-item h4 { margin: 0; font-size: 0.98rem; }
.saved-item .meta { margin-top: 4px; font-size: 0.82rem; }
.saved-actions { display: flex; gap: 8px; margin-top: 10px; }
.saved-actions .ghost { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.compact-head { margin-bottom: 8px; }
.meta, .meta-grid { margin-top: 8px; color: var(--muted); font-size: 0.92rem; }
.selected-item footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 14px; }
.custom-inline-actions { display: flex; align-items: center; gap: 8px; }
.custom-inline-actions .ghost { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.remove-button { width: 40px; min-width: 40px; padding: 0; background: rgba(125,55,44,0.08); color: #8d4b3d; }
.totals-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.total-card { padding: 18px; border: 1px solid rgba(111,143,123,0.16); border-radius: 20px; background: linear-gradient(160deg, rgba(255,255,255,0.9), rgba(236,241,235,0.86)); box-shadow: var(--shadow); }
.total-card span { display: block; margin-bottom: 10px; color: var(--muted); font-size: 0.92rem; }
.total-card strong { font-size: 1.45rem; font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif; }
.filters-grid { display: grid; grid-template-columns: 180px minmax(0,1fr) 220px; gap: 12px; margin-bottom: 18px; }
.detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 14px; }
.quantity-box { width: min(180px, 100%); }
.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.info-chip { padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); }
.info-chip strong, .info-chip span { display: block; }
.info-chip strong { color: var(--accent-dark); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; }
.info-chip span { margin-top: 4px; word-break: break-word; }
.nutrients-wrap .data-table { min-width: 0; }
.nutrients-table td:last-child, .nutrients-table th:last-child { width: 150px; text-align: center; }
.tooltip { position: relative; }
.tooltip::after {
  content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translateX(-50%);
  width: min(280px, 80vw); padding: 10px 12px; border-radius: 12px; background: rgba(38,53,45,0.96);
  color: white; line-height: 1.35; white-space: pre-line; opacity: 0; pointer-events: none; transition: opacity 120ms ease;
}
.tooltip:hover::after { opacity: 1; }
.empty-state { padding: 28px 20px; border: 1px dashed rgba(111,143,123,0.35); border-radius: 18px; background: rgba(255,255,255,0.64); color: var(--muted); text-align: center; }
.hidden { display: none; }
.empty-cell { text-align: center; color: var(--muted); padding: 24px; }
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f3f8f3; }

.reference-filters { margin-bottom: 10px; }
#reference-db-table { min-width: 1180px; }
.reference-actions { margin-top: 6px; margin-bottom: 12px; }
.account-card { margin-top: 18px; }
.account-info-grid { margin-bottom: 0; }
.account-form-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.account-form-grid .actions {
  grid-column: 1 / -1;
  margin-top: 4px;
}
.admin-create-panel { margin-bottom: 18px; }
.admin-create-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}
.admin-options { margin-top: 12px; margin-bottom: 0; }
.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.inline-check span {
  margin: 0;
}
.admin-users-table { min-width: 980px; }
.admin-actions-cell { min-width: 260px; }
.admin-temp-password-input {
  min-width: 180px;
  margin-bottom: 8px;
}
.admin-actions-stack {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.admin-actions-stack .ghost {
  min-height: 34px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(20, 34, 28, 0.46);
  backdrop-filter: blur(3px);
}
.modal.hidden { display: none; }
.modal-card {
  width: min(960px, 100%);
  max-height: min(92vh, 900px);
  overflow: auto;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(111, 143, 123, 0.22);
  background: #f9f7f2;
  box-shadow: var(--shadow);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.modal-header h3 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  font-size: 1.35rem;
}
.close-btn {
  min-height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 99px;
  font-size: 1.2rem;
  line-height: 1;
}
.modal-filters { margin-bottom: 10px; }
.quick-results {
  max-height: 46vh;
  overflow: auto;
  padding-right: 4px;
}
.pdf-modal-card { width: min(760px, 100%); }
.pdf-preview-modal-card {
  width: min(1100px, 100%);
  height: min(92vh, 900px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
}
.pdf-preview-modal-card iframe {
  width: 100%;
  min-height: 0;
  height: 100%;
  border: 1px solid rgba(111,143,123,0.22);
  border-radius: 14px;
  background: white;
}
.admin-delete-modal-card { width: min(520px, 100%); }
.custom-food-modal-card { width: min(980px, 100%); }
.custom-food-top { grid-template-columns: minmax(0, 1fr) 180px 280px; margin-bottom: 8px; }
.custom-food-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.custom-food-grid label {
  display: grid;
  gap: 4px;
}
.custom-food-grid label span {
  margin-bottom: 0;
}
.option-list {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}
.option-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(111, 143, 123, 0.15);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}
.pdf-nutrients-box {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(111, 143, 123, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.68);
}
.nutrient-choice-list {
  max-height: 200px;
  overflow: auto;
  display: grid;
  gap: 6px;
}
.compact-empty {
  padding: 10px;
  font-size: 0.9rem;
}
.modal-actions {
  margin-top: 14px;
  justify-content: flex-end;
}
@keyframes fade-up { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@media (max-width: 1500px) {
  .tab-panel[data-panel="calculator"] .split-layout { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .hero, .split-layout, .filters-grid, .totals-grid, .info-grid { grid-template-columns: 1fr; display: grid; }
  .detail-header, .hero-side { display: grid; justify-items: stretch; }
  .tab-bar { grid-template-columns: 1fr; }
  .panel { padding: 14px; }
  .data-table { min-width: 560px; }
  #reference-db-table { min-width: 860px; }
  .custom-food-grid { grid-template-columns: 1fr; }
  .custom-food-top { grid-template-columns: 1fr; }
  .account-form-grid, .admin-create-grid { grid-template-columns: 1fr; }
  .admin-users-table { min-width: 900px; }
}
