:root {
  --bg: #0f1419;
  --card: #161d24;
  --line: #2a3642;
  --text: #e6edf3;
  --muted: #9fb0c0;
  --primary: #3ea870;
  --primary-ink: #06150d;
  --field-bg: #0f1419;
  --header-bg: #1a2430;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, #1e2a35 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, #14222c 0%, transparent 40%),
    var(--bg);
}

.app {
  max-width: 1200px;
  margin: 2rem auto;
  padding: 1rem;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 2vw, 2.3rem);
}

.header p {
  margin: 0.5rem 0 0;
  color: var(--muted);
}

.controls {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.9rem;
}

.controls label {
  display: grid;
  gap: 0.25rem;
  font-size: 0.95rem;
}

.controls input[type="date"] {
  min-width: 170px;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  padding: 0.45rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text);
}

button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-ink);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  cursor: pointer;
}

button.ghost {
  background: transparent;
  color: var(--primary);
}

.print-week-label {
  margin: 1rem 0 0.25rem;
  font-size: 1.05rem;
}

.planner-wrap {
  margin-top: 1rem;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}

.planner {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.planner th,
.planner td {
  border-bottom: 1px solid var(--line);
  padding: 0.55rem;
  vertical-align: top;
}

.planner th {
  text-align: left;
  background: var(--header-bg);
}

.planner td:first-child {
  font-weight: 600;
  white-space: nowrap;
  width: 90px;
}

textarea {
  min-height: 84px;
  resize: vertical;
}

textarea.field-meal {
  min-height: 44px;
}

textarea.field-notes {
  min-height: 84px;
}

.status {
  min-height: 1.2rem;
  color: var(--muted);
  margin-top: 0.75rem;
}

@media (max-width: 700px) {
  .app {
    margin: 1rem auto;
  }

  .controls {
    align-items: stretch;
    gap: 0.5rem;
  }

  .controls button,
  .controls label {
    width: 100%;
  }

  .planner {
    min-width: 0;
  }

  .planner thead {
    display: none;
  }

  .planner tbody,
  .planner tr,
  .planner td {
    display: block;
    width: 100%;
  }

  .planner tr {
    border-bottom: 1px solid var(--line);
    padding: 0.5rem 0.35rem 0.65rem;
  }

  .planner td {
    border-bottom: none;
    padding: 0.3rem 0.35rem;
  }

  .planner td:first-child {
    width: auto;
    font-size: 1rem;
    margin-bottom: 0.2rem;
  }

  .planner td:not(:first-child)::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.8rem;
    margin-bottom: 0.2rem;
  }
}

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
    font-family: "Segoe UI", Tahoma, sans-serif;
  }

  .app {
    margin: 0;
    padding: 0;
    max-width: none;
    background: #fff !important;
    color: #000 !important;
  }

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

  .header {
    display: none !important;
  }

  .print-week-label {
    display: block !important;
    margin: 0 0 0.45rem;
    font-size: 14pt;
    font-weight: 700;
    color: #000 !important;
  }

  .planner-wrap {
    border: none;
    background: #fff !important;
    color: #000 !important;
  }

  .planner {
    min-width: 0;
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
    background: #fff !important;
    color: #000 !important;
  }

  .planner thead {
    display: table-header-group;
  }

  .planner tbody {
    display: table-row-group;
  }

  .planner tr {
    display: table-row;
    break-inside: avoid;
  }

  .planner td,
  .planner th {
    display: table-cell;
    width: auto;
    border-bottom: 1px solid #ddd;
    padding: 0.3rem 0.35rem;
    vertical-align: top;
    background: #fff !important;
    color: #000 !important;
    overflow-wrap: anywhere;
  }

  .planner td::before {
    content: none !important;
  }

  input,
  textarea {
    border: none;
    padding: 0;
    background: transparent !important;
    resize: none;
    color: #000 !important;
    min-height: 0;
    line-height: 1.25;
    -webkit-text-fill-color: #000;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
  }

  input.print-empty,
  textarea.print-empty {
    display: none;
  }

  .planner tr.print-empty-row {
    display: none;
  }

  .planner th {
    background: #f2f2f2 !important;
  }

  .planner.print-hide-col-breakfast th:nth-child(2),
  .planner.print-hide-col-breakfast td:nth-child(2),
  .planner.print-hide-col-lunch th:nth-child(3),
  .planner.print-hide-col-lunch td:nth-child(3),
  .planner.print-hide-col-dinner th:nth-child(4),
  .planner.print-hide-col-dinner td:nth-child(4),
  .planner.print-hide-col-snacks th:nth-child(5),
  .planner.print-hide-col-snacks td:nth-child(5),
  .planner.print-hide-col-notes th:nth-child(6),
  .planner.print-hide-col-notes td:nth-child(6) {
    display: none !important;
  }
}
