:root {
  --bg: #f7f2f7;
  --panel: #fffdfb;
  --text: #3e3847;
  --line: #decfe0;
  --tab: #efdfd9;
  --tab-active: #fffdfb;
  --btn: #b9d6c7;
  --btn-hover: #a7c7b6;
  --select: #d7e9f5;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: linear-gradient(180deg, #f4edf6 0%, #f7f2f7 100%);
  color: var(--text);
  font: 14px/1.35 "Helvetica Neue", "Segoe UI", Arial, sans-serif;
}

.app {
  max-width: 1220px;
  margin: 14px auto;
  padding: 8px;
}

.topbar h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 22px;
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.tab {
  border: 1px solid var(--line);
  background: var(--tab);
  color: var(--text);
  padding: 8px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  font-size: 16px;
}

.tab.active {
  background: var(--tab-active);
  font-weight: 700;
}

.panel {
  display: none;
  background: rgba(255, 253, 251, 0.6);
  border: 1px solid var(--line);
  border-radius: 0 8px 8px 8px;
  padding: 10px;
  box-shadow: inset 0 0 0 1px #ece0ef;
}

.panel.active {
  display: block;
}

.collapsed {
  display: none !important;
}

h2,
h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

label {
  display: grid;
  gap: 4px;
  font-size: 15px;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  height: 38px;
  border: 1px solid #b9aebf;
  border-radius: 6px;
  background: var(--panel);
  padding: 6px 8px;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--btn);
  color: #2b3a34;
  padding: 10px 14px;
  cursor: pointer;
}

button:hover {
  background: var(--btn-hover);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.grid2,
.grid3,
.grid4,
.actions,
.result {
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.grid2 {
  grid-template-columns: 1fr 220px;
}

.grid3 {
  grid-template-columns: 1fr 220px 260px;
}

.grid4 {
  grid-template-columns: 1fr 240px 240px;
}

.field-end {
  display: flex;
  align-items: end;
  gap: 8px;
}

.actions {
  grid-auto-flow: column;
  grid-auto-columns: max-content;
  justify-content: start;
}

.result {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 10px;
  font-size: 15px;
}

.table-wrap {
  overflow-x: auto;
  overflow-y: scroll;
  border: 2px solid #d8c8de;
  border-radius: 8px;
  background: #fff;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  margin-top: 10px;
}

.table-wrap.tall {
  height: 360px;
}

.table-wrap.mid {
  height: 250px;
}

#tab-online .grid3 {
  margin-bottom: 6px;
}

#tab-freezer table {
  min-width: 0;
}

#tab-week table {
  min-width: 460px;
}

#tab-week .week-grid {
  display: grid;
  gap: 10px;
}

#tab-week .week-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 251, 0.8);
  padding: 8px;
}

#tab-week .week-add-row {
  grid-template-columns: 130px 1fr 160px;
}

#tab-week .week-list-wrap {
  height: 190px;
}

#tab-week tbody tr.empty-row td {
  text-align: center;
  color: #766e82;
  background: #fbf8fd;
  font-weight: 500;
}

#tab-freezer tbody tr.empty-row td {
  text-align: center;
  color: #766e82;
  background: #fbf8fd;
  font-weight: 500;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 700px;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #d9cde3;
}

th,
td {
  border-bottom: 1px solid #eadfec;
  border-right: 1px solid #eadfec;
  padding: 6px 8px;
  text-align: left;
  font-size: 15px;
  background: #fff;
}

th:last-child,
td:last-child {
  border-right: 0;
}

tbody tr {
  cursor: pointer;
}

tbody tr.selected {
  background: var(--select);
}

tbody tr.selected td {
  background: var(--select);
}

#tab-saved .grid3 {
  grid-template-columns: 1fr 220px;
}

#tab-saved .saved-to-day-row {
  grid-template-columns: 220px 260px;
}

#tab-saved .saved-search-row {
  grid-template-columns: minmax(320px, 620px);
  margin-bottom: 6px;
}

#tab-saved #saved-body td:first-child {
  font-weight: 600;
}

#tab-saved #saved-body tr.empty-row td {
  text-align: center;
  color: #766e82;
  background: #fbf8fd;
  font-weight: 500;
}

#tab-saved #saved-body tr.saved-child-row td {
  background: #f7f1fb;
  color: #574f63;
  font-weight: 500;
}

#tab-saved #saved-body td.saved-child-name {
  padding-left: 28px;
}

#tab-day tbody tr.selected td {
  background: #b8d3ea;
  color: #233546;
  font-weight: 600;
}

#tab-day tbody tr.day-selected td {
  background: #8ab8da !important;
  color: #142739 !important;
  font-weight: 700;
}

.backup-tools {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 251, 0.8);
  padding: 10px;
}

.backup-title {
  font-size: 15px;
  font-weight: 700;
}

.status {
  margin-top: 8px;
  color: #766e82;
  font-size: 13px;
}

@media (max-width: 980px) {
  .app {
    margin: 0;
    padding: 8px;
  }

  .tab,
  label,
  th,
  td,
  .result,
  .status {
    font-size: 14px;
  }

  h2,
  h3 {
    font-size: 18px;
  }

  .grid2,
  .grid3,
  .grid4 {
    grid-template-columns: 1fr;
  }

  .actions {
    grid-auto-flow: row;
  }

  input,
  select {
    height: 36px;
  }
}

/* Portal integration: compact workbench in the existing health palette. */
:root { --bg: #f7faf9; --panel: #ffffff; --text: #203d45; --line: #cadeda; --tab: #e7f0ed; --tab-active: #fff; --btn: #d5e8df; --btn-hover: #c0dcd0; }
body { background: #f7faf9; }
.app { margin: 0 auto; padding: 0 0 16px; }
.account-tools { margin-bottom: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 10px; }
.account-tools p { margin: 0 0 10px; line-height: 1.5; }
.account-tools .actions { display: flex; flex-wrap: wrap; }
.account-tools button[hidden] { display: none; }
.table-wrap.tall { height: 240px; }
.table-wrap { border-color: var(--line); }
thead th { background: #e7f0ed; }
button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #28776d; outline-offset: 2px; }
input, select, label { min-width: 0; max-width: 100%; }
@media (max-width: 720px) {
  .actions { display: flex; flex-wrap: wrap; }
  .actions button { max-width: 100%; }
  #tab-saved .grid3, #tab-saved .saved-to-day-row, #tab-saved .saved-search-row, #tab-week .week-add-row { grid-template-columns: minmax(0, 1fr); }
  .result { grid-template-columns: minmax(0, 1fr); }
  .tab { padding: 10px; border-radius: 6px; }
  table { min-width: 420px; }
}
