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

:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --text: #1b2b2a;
  --muted: #63716f;
  --line: #d9ded8;
  --primary: #1d5c57;
  --primary-dark: #143f3b;
  --accent: #b55a2a;
  --success: #2e7d55;
  --danger: #b23333;
  --warning: #8a6417;
  --shadow: 0 10px 28px rgba(35, 48, 45, .08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: 'Inter', Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

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

a:hover {
  text-decoration: underline;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 12px clamp(16px, 4vw, 42px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
}

.brand:hover {
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  font-size: 14px;
  letter-spacing: 0;
}

.topnav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.topnav a {
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text);
}

.topnav a:hover {
  background: #edf3ef;
  text-decoration: none;
}

.page {
  width: min(1120px, calc(100% - 28px));
  margin: 28px auto 52px;
}

.auth-panel {
  width: min(460px, 100%);
  margin: 54px auto;
  padding: 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

h1,
h2 {
  margin: 0 0 10px;
  line-height: 1.15;
}

h1 {
  font-size: 30px;
}

h2 {
  font-size: 20px;
}

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

.page-head,
.report-toolbar,
.share-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.page-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.searchbar,
.inline-form {
  display: flex;
  gap: 10px;
  align-items: center;
}

.searchbar {
  margin-bottom: 16px;
}

.searchbar input {
  flex: 1;
}

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

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.span-2 {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 7px;
  color: #2d3c3a;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c9d1cc;
  border-radius: 6px;
  padding: 11px 12px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-weight: 400;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(29, 92, 87, .16);
  border-color: var(--primary);
}

.button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.button:hover,
button:hover {
  text-decoration: none;
  border-color: #a9b8b2;
}

.button.primary {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.button.primary:hover {
  background: var(--primary-dark);
}

.button.success {
  color: #fff;
  background: var(--success);
  border-color: var(--success);
}

.button.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.table-wrap {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  background: #f9faf7;
  font-size: 13px;
  text-transform: uppercase;
}

tr:last-child td {
  border-bottom: 0;
}

.actions {
  white-space: nowrap;
}

.actions a + a {
  margin-left: 10px;
}

.empty {
  padding: 34px;
  color: var(--muted);
  text-align: center;
}

.alert {
  margin-bottom: 14px;
  padding: 12px 14px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #fff;
}

.alert.success {
  color: #174931;
  border-color: #a8d3bd;
  background: #edf8f2;
}

.alert.error {
  color: #822020;
  border-color: #e1aaaa;
  background: #fff0f0;
}

.alert.warning {
  color: var(--warning);
  border-color: #e2cc8b;
  background: #fff8df;
}

.split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.split.split-three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.split > div,
.danger-zone,
.share-panel {
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.file-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.file-row:last-child {
  border-bottom: 0;
}

.link-danger {
  min-height: 0;
  padding: 0;
  border: 0;
  color: var(--danger);
  background: transparent;
}

.danger-zone {
  margin-top: 20px;
}

.checklist-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9faf7;
}

.checklist-launch h2,
.checklist-launch p {
  margin-bottom: 0;
}

.checklist-dialog {
  width: min(1040px, calc(100% - 24px));
  max-height: 90vh;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: #fff;
  box-shadow: var(--shadow);
}

.checklist-dialog::backdrop {
  background: rgba(20, 35, 33, .45);
}

.dialog-head,
.dialog-actions {
  position: sticky;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 18px;
  background: #fff;
}

.dialog-head {
  top: 0;
  border-bottom: 1px solid var(--line);
}

.dialog-actions {
  bottom: 0;
  justify-content: flex-end;
  border-top: 1px solid var(--line);
}

.checklist-section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.checklist-section h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.checklist-table {
  display: grid;
  gap: 10px;
}

.checklist-row {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, auto) minmax(180px, 260px);
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.checklist-question {
  font-weight: 700;
}

.checklist-options {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.radio-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 700;
}

.radio-pill input {
  width: auto;
  margin: 0;
}

.report-sheet {
  padding: clamp(22px, 4vw, 48px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.report-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 20px;
  margin-bottom: 22px;
  border-bottom: 2px solid var(--primary);
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
}

.report-date {
  color: var(--muted);
  white-space: nowrap;
}

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

.report-grid div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.report-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

.report-section {
  margin-top: 24px;
}

.preline {
  white-space: pre-wrap;
  padding: 14px;
  border-left: 4px solid var(--primary);
  background: #f8fbf8;
}

.attachment {
  display: block;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.copy-field {
  margin-top: 6px;
  min-width: min(620px, 100%);
}

.nutrition-overview,
.recipe-dashboard {
  display: grid;
  grid-template-columns: minmax(320px, .95fr) minmax(0, 1.35fr);
  gap: 18px;
  margin-bottom: 22px;
}

.dashboard-chart,
.stat-card,
.nutrition-main,
.nutrition-stats-table {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.dashboard-chart {
  display: grid;
  gap: 16px;
  padding: 20px;
}

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

.stat-card {
  display: grid;
  align-content: space-between;
  min-height: 116px;
  padding: 16px;
}

.stat-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

.stat-card strong {
  margin-top: 10px;
  font-size: 24px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.stat-card.stat-card-compact strong {
  font-size: 18px;
  line-height: 1.22;
}

.pie-chart {
  display: grid;
  grid-template-columns: 190px 1fr;
  gap: 18px;
  align-items: center;
}

.pie-disc {
  width: 190px;
  aspect-ratio: 1;
  overflow: visible;
}

.pie-slice {
  cursor: default;
  stroke: #fff;
  stroke-width: 1.5;
  transition: filter .15s ease, transform .15s ease;
  transform-origin: 100px 100px;
}

.pie-slice:hover {
  filter: brightness(1.08);
  transform: scale(1.015);
}

.pie-hole {
  fill: #fff;
  stroke: var(--line);
  stroke-width: 1;
}

.pie-total {
  fill: var(--text);
  font: 700 17px 'Inter', Arial, Helvetica, sans-serif;
}

.pie-legend {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.pie-legend li {
  display: grid;
  grid-template-columns: 12px 1fr auto;
  gap: 8px;
  align-items: center;
}

.pie-legend span {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.pie-legend strong {
  font-size: 14px;
}

.pie-legend em {
  color: var(--muted);
  font-style: normal;
  font-weight: 700;
}

.pie-empty {
  padding: 18px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 6px;
}

.nutrition-layout {
  display: grid;
  gap: 18px;
}

.nutrition-main {
  overflow: hidden;
}

.nutrition-builder {
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.nutrition-table-wrap {
  overflow-x: auto;
}

.nutrition-table {
  min-width: 980px;
}

.nutrition-table select {
  width: 100%;
  min-width: 220px;
  border: 1px solid #c9d1cc;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff;
  font: inherit;
}

.nutrition-table input {
  min-width: 88px;
}

.nutrition-table tfoot th {
  color: var(--text);
  background: #edf3ef;
}

.nutrition-stats-table {
  margin-bottom: 22px;
}

.nutrition-recipe-view {
  margin-top: 22px;
}

.selected-row {
  background: #f8fbf8;
}

.inline-delete {
  display: inline;
}

@media (max-width: 760px) {
  .topbar,
  .page-head,
  .report-toolbar,
  .share-panel,
  .checklist-launch,
  .dialog-head,
  .dialog-actions,
  .report-head,
  .searchbar,
  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .page {
    width: min(100% - 22px, 1120px);
    margin-top: 18px;
  }

  .form-grid,
  .split,
  .split.split-three,
  .report-grid,
  .checklist-row,
  .nutrition-overview,
  .recipe-dashboard,
  .stats-grid,
  .pie-chart {
    grid-template-columns: 1fr;
  }

  .pie-disc {
    width: min(220px, 100%);
    margin: 0 auto;
  }

  .page-actions,
  .form-actions,
  .checklist-options {
    flex-direction: column;
    align-items: stretch;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    display: none;
  }

  tr {
    padding: 12px;
    border-bottom: 1px solid var(--line);
  }

  td {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 10px;
    padding: 7px 0;
    border: 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 700;
  }

  td.actions {
    display: flex;
    padding-top: 12px;
    white-space: normal;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .no-print,
  .alert {
    display: none !important;
  }

  .page {
    width: 100%;
    margin: 0;
  }

  .report-sheet {
    border: 0;
    box-shadow: none;
    padding: 0;
  }
}
