@import url("fonts.css");

* { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  margin: 0;
  font-family: var(--font-text);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: #eef2f7;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

.sheet {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.head {
  background: linear-gradient(135deg, #071426, #0b3b91);
  color: #fff;
  padding: 22px 26px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.head .brand {
  font-size: 13px;
  opacity: 0.85;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 700;
  margin: 0 0 8px;
}

.head h1 {
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.head .sub {
  margin: 0;
  font-size: 14px;
  opacity: 0.88;
}

.head-qr {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  text-align: center;
}

.head-qr-img {
  display: block;
  width: 112px;
  height: 112px;
  border-radius: 10px;
  background: #fff;
  padding: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}

.head-qr-caption {
  margin: 0;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.9;
  line-height: 1.25;
}

.filters {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  gap: 12px;
  padding: 14px 16px 16px;
  margin: 0 0 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
}

.filter-row label,
.filter-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  min-width: 4.5rem;
}

.filters select {
  flex: 1 1 220px;
  max-width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: #fff;
}

.phase-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.phase-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.phase-btn:hover {
  border-color: #c5d0e0;
  background: var(--brand-soft);
}

.phase-btn.is-active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.term-banner {
  margin: 0 0 14px;
  padding: 14px 16px 12px;
  border-radius: 12px;
  background: var(--brand-soft);
  color: var(--ink);
}

.term-banner-text {
  margin: 0 0 12px;
  font-size: 15px;
}

.porce-public {
  margin: -4px 0 12px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.porce-public strong {
  color: var(--ink);
  font-weight: 800;
}

.porce-public-detail {
  font-weight: 500;
  color: var(--muted);
}

.porce-chip {
  display: none;
}

.meal-cell {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 16px;
  width: 100%;
}

.meal-cell-main {
  flex: 1 1 auto;
  min-width: 0;
}

.porce-flags {
  flex: 0 0 auto;
  display: inline-flex;
  flex-direction: row;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.porce-flags-detail {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}

.porce-flags-row {
  display: flex;
  flex-wrap: nowrap;
  justify-content: flex-end;
  gap: 6px 8px;
  white-space: nowrap;
}

.porce-flag {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
}

.porce-flag-l {
  display: inline-block;
  min-width: 0.9em;
  padding: 0 3px;
  border-radius: 3px;
  background: #e8eef6;
  color: var(--brand);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.45;
}

.porce-flag-n {
  font-weight: 800;
  color: var(--ink);
  font-size: 12px;
}

.porce-sum-box {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 4px 10px;
  border: 2px solid var(--brand);
  border-radius: 8px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(11, 59, 145, 0.08);
}

.porce-sum-n {
  font-size: 1.55rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.porce-day {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin: 0 0 8px;
}

.porce-day th,
.porce-day td {
  padding: 2px 5px;
  border: 1px solid #e2e8f0;
  text-align: right;
}

.porce-day th:first-child {
  text-align: left;
  font-weight: 700;
  color: var(--muted);
}

.porce-day thead th {
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--muted);
  background: #f8fafc;
}

.porce-day .porce-celkem {
  font-weight: 800;
  background: #f1f5f9;
}

.stay-timeline {
  display: grid;
  grid-template-columns: repeat(21, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
}

.stay-day {
  display: block;
  height: 14px;
  border-radius: 3px;
  background: #dbe3ef;
  transition: background 0.15s ease, transform 0.15s ease;
}

.stay-day.is-on {
  background: #16a34a;
  box-shadow: 0 0 0 1px rgba(22, 163, 74, 0.25);
}

.stay-timeline-legend {
  display: grid;
  grid-template-columns: 5fr 7fr 7fr 2fr;
  gap: 3px;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stay-timeline-legend-short {
  grid-template-columns: 1fr 8fr 1fr;
}

.stay-timeline-legend span {
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 20px 26px;
  margin: 0 0 16px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}

.panel[hidden] {
  display: none !important;
}

.panel h2 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--brand);
}

.panel .lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 14px;
}

.panel .lead strong {
  color: var(--ink);
  font-weight: 700;
}

.empty-week {
  padding: 28px 22px;
  border-radius: 12px;
  background: var(--soft);
  border: 1px dashed #cbd5e1;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.days {
  display: grid;
  gap: 16px;
}

.day-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.day-card h3 {
  margin: 0;
  padding: 10px 14px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.01em;
  border-bottom: 1px solid var(--line);
}

.meals-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14.5px;
}

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

.meals-table tr:last-child th,
.meals-table tr:last-child td {
  border-bottom: 0;
}

.meals-table th {
  width: 8.5rem;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  background: #fafbfc;
  white-space: nowrap;
  text-transform: none;
}

.meal-text {
  font-weight: 600;
  color: var(--ink);
}

.allergens {
  display: block;
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 500;
  color: #64748b;
}

.allergen-code {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted #94a3b8;
  color: #475569;
}

.allergen-code:hover,
.allergen-code:focus {
  color: var(--brand);
  border-bottom-color: var(--brand);
  outline: none;
}

.allergen-code:hover::after,
.allergen-code:focus::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 30;
  min-width: 12rem;
  max-width: 18rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: #0f172a;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  text-align: center;
  white-space: normal;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.25);
  pointer-events: none;
}

.allergen-code:hover::before,
.allergen-code:focus::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #0f172a;
  pointer-events: none;
}

.cell-empty {
  color: #94a3b8;
  font-weight: 500;
}

.meal-neni th {
  color: #94a3b8;
}

.cell-neni {
  display: inline-block;
  color: #94a3b8;
  font-weight: 600;
  text-decoration: line-through;
}

.legend-panel {
  padding-top: 18px;
}

.legend {
  padding: 18px 18px 8px;
  border-radius: 12px;
  background: var(--soft);
  border: 1px solid var(--line);
}

.legend h3 {
  margin: 0 0 10px;
  font-size: 14px;
  font-weight: 800;
  color: var(--brand);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.legend ol {
  margin: 0;
  padding: 0 0 0 1.25rem;
  columns: 2;
  column-gap: 28px;
  font-size: 13px;
  color: var(--muted);
}

.legend li {
  margin: 0 0 8px;
  break-inside: avoid;
}

.footer-note {
  margin: 18px 0 0;
  font-size: 13px;
  color: #64748b;
}

@media (max-width: 720px) {
  .head {
    flex-direction: column;
  }

  .head-qr {
    align-self: flex-start;
    flex-direction: row;
    gap: 10px;
  }

  .head-qr-img {
    width: 88px;
    height: 88px;
  }

  .head-qr-caption {
    text-align: left;
  }

  .stay-day {
    height: 12px;
  }

  .stay-timeline-legend {
    font-size: 10px;
  }

  .meals-table,
  .meals-table tbody,
  .meals-table tr,
  .meals-table th,
  .meals-table td {
    display: block;
    width: 100%;
  }

  .meals-table tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
  }

  .meals-table tr:last-child {
    border-bottom: 0;
  }

  .meals-table th,
  .meals-table td {
    border-bottom: 0;
    padding: 4px 14px;
  }

  .meal-cell {
    flex-wrap: wrap;
  }

  .porce-flags {
    width: auto;
    margin-left: auto;
  }

  .porce-sum-n {
    font-size: 1.35rem;
  }

  .meals-table th {
    background: transparent;
    padding-top: 8px;
  }

  .legend ol {
    columns: 1;
  }
}

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

  .wrap {
    max-width: none;
    padding: 0;
  }

  .filters {
    position: static;
    box-shadow: none;
  }

  .phase-btn:not(.is-active) {
    display: none;
  }

  .sheet,
  .panel,
  .day-card,
  .filters {
    box-shadow: none;
    border-color: #ccc;
  }

  .head {
    background: #0b3b91 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .day-card,
  .phase-block {
    break-inside: avoid;
  }

  .footer-note {
    display: none;
  }
}
