:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #1d2330;
  --muted: #667085;
  --line: #e3e6eb;
  --primary: #1f6feb;
  --primary-text: #ffffff;
  --ok: #e7f6ec;
  --ok-line: #34a853;
  --warn: #fff5e0;
  --warn-line: #e3a008;
  --error: #c62828;
  --closed: #f0f1f3;
  --radius: 10px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --card: #1b1f27;
    --text: #e6e9ef;
    --muted: #98a2b3;
    --line: #2c323d;
    --primary: #4c8dff;
    --ok: #16301f;
    --warn: #3a2e12;
    --closed: #222730;
    --error: #ff6b6b;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.35rem; margin: 0 0 8px; }
h2 { font-size: 1.1rem; margin: 0 0 8px; }
h3 { font-size: .95rem; margin: 16px 0 6px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logo { font-size: 1.6rem; }
.logo-img { height: 40px; width: auto; max-width: 160px; object-fit: contain; }

/* Háttérkép: a kép a body-n, fölötte témához igazodó, állítható átlátszóságú
   réteg (mint az FBase-ben), hogy a szöveg mindig olvasható maradjon. */
body.has-bg {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-attachment: fixed;
}
body.has-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--bg);
  opacity: var(--bg-overlay, .7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 0;
  pointer-events: none;
}
body.has-bg > .topbar, body.has-bg > main, body.has-bg > .footer { position: relative; z-index: 1; }
body.has-bg .topbar { background: color-mix(in srgb, var(--card) 88%, transparent); backdrop-filter: blur(8px); }
body.has-bg .footer, body.has-bg .footer a { color: var(--text); }
.school { font-weight: 600; }
.sub { font-size: .8rem; color: var(--muted); }
.user { display: flex; gap: 10px; align-items: center; font-size: .9rem; flex-wrap: wrap; justify-content: flex-end; }
.user span { overflow-wrap: anywhere; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.narrow { max-width: 420px; margin: 24px auto; }

form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 500; }
input, select {
  font: inherit; color: var(--text); background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
input.code { font-size: 1.4rem; letter-spacing: .3em; text-align: center; }
button {
  font: inherit; cursor: pointer; border-radius: 8px; padding: 9px 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
}
button.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); font-weight: 600; }
button:disabled { opacity: .55; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--primary); text-decoration: underline; }
button.icon { width: 36px; height: 36px; padding: 0; font-size: 1.3rem; line-height: 1; }
.links { display: flex; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.error { color: var(--error); min-height: 1.2em; margin: 0; font-size: .9rem; }

.toast {
  position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px);
}

.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button[aria-selected="true"] { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.monthnav { display: flex; align-items: center; gap: 10px; }
.monthnav strong { min-width: 130px; text-align: center; }
.notice { background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--primary); padding: 8px 12px; border-radius: 6px; margin: 8px 0; }
.notice.warn { border-left-color: var(--warn-line); background: var(--warn); }

.layout { display: grid; grid-template-columns: 1fr 300px; gap: 16px; align-items: start; }
@media (max-width: 860px) { .layout { grid-template-columns: 1fr; } }
.tablecard { padding: 0; overflow: hidden; }
.tablewrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 10px; text-align: center; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; position: sticky; left: 0; background: var(--card); }
thead th { font-weight: 600; vertical-align: bottom; }
thead .price { display: block; font-weight: 400; color: var(--muted); font-size: .8rem; }
thead .bulk { display: flex; gap: 6px; justify-content: center; margin-top: 4px; }
thead .bulk button { font-size: .75rem; padding: 2px 6px; }
tr.closed td { background: var(--closed); color: var(--muted); }
tr.closed td:first-child { background: var(--closed); }
td.on { background: var(--ok); }
td.changed { box-shadow: inset 0 0 0 2px var(--warn-line); }
td input[type="checkbox"] { width: 20px; height: 20px; cursor: pointer; }
td select { padding: 4px 6px; font-size: .88rem; max-width: 220px; }
.day { font-variant-numeric: tabular-nums; }
.wd { color: var(--muted); margin-left: 4px; }
.reason { font-size: .8rem; margin-left: 6px; }
.lock { font-size: .8rem; margin-left: 4px; }
.legend { padding: 8px 12px; margin: 0; font-size: .8rem; }

.summary dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; margin: 0; }
.summary dt { color: var(--muted); font-size: .85rem; }
.summary dd { margin: 0; overflow-wrap: anywhere; }
.summary .big { font-size: 1.3rem; font-weight: 700; }

.savebar {
  position: sticky; bottom: 12px; margin-top: 16px; z-index: 10;
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--card); border: 1px solid var(--warn-line); border-radius: var(--radius);
  padding: 10px 14px; box-shadow: 0 4px 18px rgba(0,0,0,.12);
}
.savebar div { display: flex; gap: 8px; }

.footer { text-align: center; padding: 16px; font-size: .85rem; color: var(--muted); display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; }
.footer a { color: var(--muted); }

/* Telefon: keskenyebb cellák, a menü-legördülő rövidebb, a mentősáv rögzített */
@media (max-width: 600px) {
  main { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .sub { display: none; }
  th, td { padding: 6px 6px; }
  thead th { white-space: normal; min-width: 64px; }
  thead .bulk { flex-direction: column; gap: 3px; }
  td select { max-width: 112px; font-size: .82rem; }
  .reason { display: block; margin-left: 0; }
  .savebar { position: fixed; left: 12px; right: 12px; bottom: 12px; margin: 0; }
  .layout { padding-bottom: 72px; }
}

/* Étlap: napi kinyitható sor ételekkel és allergénekkel */
.menu-toggle { margin-left: 8px; padding: 1px 7px; font-size: .75rem; border-radius: 999px; }
tr.menu-row td { background: var(--bg); white-space: normal; text-align: left; position: static; }
.menu-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.menu-grid strong { display: block; margin-bottom: 2px; }
ul.dishes { margin: 0; padding-left: 18px; }
ul.dishes li { margin: 1px 0; }
abbr.allergen {
  text-decoration: none; cursor: help; font-size: .7rem; margin-left: 3px; padding: 0 4px;
  border-radius: 999px; background: var(--warn); border: 1px solid var(--warn-line); vertical-align: 1px;
}
.variant { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; }
.variant-code { font-weight: 700; min-width: 1.2em; }
.variant ul.dishes { padding-left: 14px; }
/* Telefonon a táblázat vízszintesen görgethető — az étlap-sor tartalma maradjon a képernyőn */
@media (max-width: 600px) {
  tr.menu-row td > * { position: sticky; left: 8px; max-width: calc(100vw - 64px); }
}
