:root {
  --bg: #16181d;
  --panel: #1f2229;
  --line: #333844;
  --text: #e8e9ec;
  --muted: #9aa0ab;
  --accent: #4f8cff;
  --danger: #d9534f;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute is only honoured by the UA stylesheet's
   `display: none`, which any author `display` rule outranks. Restore it
   globally so `el.hidden = true` is reliable everywhere on this page. */
[hidden] {
  display: none !important;
}

body {
  margin: 0 auto;
  padding: 1.5rem 1rem 4rem;
  max-width: 46rem;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1 {
  margin: 0 0 1rem;
  font-size: 1.5rem;
}

h2 {
  margin: 0 0 0.25rem;
  font-size: 1.75rem;
}

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

/* Tabs */

#tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--line);
}

#tabs button {
  padding: 0.6rem 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

#tabs button.active {
  border-bottom-color: var(--accent);
  color: var(--text);
}

/* Buttons */

button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

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

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

button.big {
  width: 100%;
  padding: 1.1rem;
  font-size: 1.1rem;
}

/* Today's pick */

#result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

#message {
  margin-top: 1.5rem;
}

/* Banner */

#banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  background: var(--danger);
  color: #fff;
}

#banner button {
  border: none;
  background: none;
  color: #fff;
  font-size: 1.25rem;
  line-height: 1;
}

/* Meals table */

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

th,
td {
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* "2026-08-01 08:59" is one value, not two. Without this the space in the
   middle is a wrap opportunity, and the users table is narrow enough that the
   time drops onto its own line under the date. */
td.last-active {
  white-space: nowrap;
}

td input[type="text"],
td input[type="number"],
td input[type="date"] {
  width: 100%;
  padding: 0.35rem 0.45rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: inherit;
}

td input:hover {
  border-color: var(--line);
}

/* `input[type="date"]` already gives the browser's native calendar popup — no
   library involved. But Chrome draws its calendar button as a near-black glyph,
   which is invisible against this background, so the picker looks like it isn't
   there. Invert it and give it a hit area worth aiming at. */
input[type="date"]::-webkit-calendar-picker-indicator {
  padding: 0.2rem;
  border-radius: 3px;
  cursor: pointer;
  opacity: 0.55;
  filter: invert(1);
}

input[type="date"]:hover::-webkit-calendar-picker-indicator,
input[type="date"]:focus::-webkit-calendar-picker-indicator {
  opacity: 1;
  background: var(--line);
}

/* Summary line directly under the table — sits closer to it than the
   explanatory note that follows, so it reads as part of the table. */
.total {
  margin: 0.75rem 0 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

td input:focus {
  border-color: var(--accent);
  background: var(--bg);
  outline: none;
}

td.chance {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

tr.inactive td:not(.row-actions) {
  opacity: 0.45;
}

tfoot td {
  padding-top: 0.9rem;
  border-bottom: none;
}

.row-actions {
  white-space: nowrap;
  text-align: right;
}

.row-actions button {
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

/* Narrow screens: stop being a table.
   Six columns cannot share a phone's width — the meal name was being crushed to
   a few characters ("Bac", "Csir") while the native date input, which has a
   wide intrinsic size, took a third of the row. So each row becomes a card: the
   name gets a full-width line of its own, and every other field becomes a
   labelled row beneath it. The markup is unchanged; only the display is. */
@media (max-width: 34rem) {
  table,
  tbody,
  tfoot,
  tr,
  td {
    display: block;
    width: auto;
  }

  /* The header row's labels are replaced by per-cell ones below. */
  thead {
    display: none;
  }

  tr {
    margin-bottom: 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--line);
    border-radius: 8px;
  }

  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.3rem 0;
    border-bottom: none;
  }

  /* The label the hidden thead used to provide. */
  td[data-label]::before {
    content: attr(data-label);
    flex: none;
    color: var(--muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* The name is the point of the row, so it gets the full width and a size
     that reads as a heading rather than a table cell. */
  .cell-name {
    display: block;
    padding-bottom: 0.4rem;
  }

  .cell-name input {
    width: 100%;
    font-size: 1.05rem;
    font-weight: 600;
  }

  td.username {
    font-size: 1.05rem;
    font-weight: 600;
  }

  /* Inputs sit right, hard against their label rather than stretched. */
  td[data-label] input[type="number"],
  td[data-label] input[type="date"],
  td[data-label] input[type="password"] {
    width: auto;
    max-width: 60%;
    border-color: var(--line);
    text-align: right;
  }

  td[data-label] input[type="checkbox"] {
    margin: 0;
  }

  .row-actions {
    justify-content: flex-end;
    padding-top: 0.5rem;
  }

  /* An empty spacer cell would otherwise render as a stray blank row. */
  .spacer {
    display: none;
  }

  tr.inactive td:not(.row-actions) {
    opacity: 0.45;
  }
}

/* Title on the left, who's signed in on the right, one line. `wrap` lets the
   identity drop under the title on a narrow screen rather than squeezing it. */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1rem;
}

.page-head h1 {
  margin: 0;
}

.signed-in {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
  font-size: 0.9rem;
}

.signed-in button {
  padding: 0.25rem 0.6rem;
  font-size: 0.85rem;
}

/* Flags are inline SVG, not emoji: Windows has no regional-indicator glyphs,
   so 🇬🇧 and 🇭🇺 render as the bare letters GB and HU in Chrome and Edge. */
.lang-picker {
  display: flex;
  gap: 0.3rem;
}

/* No `cursor: pointer` here on purpose: the base `button` rule already sets it,
   and repeating it at this specificity would beat `button:disabled`'s
   `cursor: default` — leaving a flag that looks clickable while a save is in
   flight and it is not. */
.lang-picker button {
  display: flex;
  padding: 0.2rem;
  border: 1px solid transparent;
  border-radius: 4px;
  background: none;
  opacity: 0.45;
}

.lang-picker button svg {
  width: 22px;
  height: 11px;
}

.lang-picker button[aria-pressed='true'] {
  border-color: var(--line);
  opacity: 1;
}

.lang-picker button:hover:not(:disabled) {
  opacity: 1;
}

/* Login page */

body.centred {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1rem;
}

.card {
  width: 100%;
  max-width: 22rem;
  padding: 1.75rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.card h1 {
  margin-bottom: 0.25rem;
}

.card form {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-top: 1.5rem;
}

.card label {
  color: var(--muted);
  font-size: 0.85rem;
}

.card input {
  margin-bottom: 0.75rem;
  padding: 0.6rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: inherit;
  font: inherit;
}

.card input:focus {
  border-color: var(--accent);
  outline: none;
}

/* ------------------------------------------------------------ history ---- */

.month-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.month-head span {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}

/* Shares the calendar grid's own column definition, so the labels line up with
   the day cells below without a hand-tuned width anywhere. */
.dow-head {
  margin-bottom: 0.3rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-align: center;
  text-transform: uppercase;
}

.calendar .cell {
  min-height: 3.4rem;
  padding: 0.2rem 0.3rem;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: none;
  font: inherit;
  text-align: left;
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.calendar .cell.filler {
  border: none;
  cursor: default;
}

.calendar .cell.empty {
  border-style: dashed;
}

.calendar .cell.today {
  outline: 2px solid var(--accent);
}

.calendar .cell.selected {
  background: var(--panel);
  border-color: var(--accent);
}

.calendar .cell:disabled {
  cursor: default;
  opacity: 0.45;
}

.day-number {
  display: block;
  font-size: 0.7rem;
  opacity: 0.55;
}

.day-meal {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.15;
}

.day-rejects {
  position: absolute;
  right: 0.25rem;
  bottom: 0.15rem;
  font-size: 0.65rem;
  opacity: 0.6;
}

.panel {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.panel h3 {
  margin: 0 0 0.6rem;
  font-variant-numeric: tabular-nums;
}

.field {
  margin: 0 0 0.7rem;
}

.field label {
  display: block;
  font-size: 0.8rem;
  opacity: 0.7;
  margin-bottom: 0.2rem;
}

.chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.3rem;
  margin-right: 0.4rem;
}

/* A chip marks a meal that was turned down — a border in the danger colour
   says so without the shouting a filled red background would do, and it
   matches how .panel and #result already sit on --panel over the page's
   --bg rather than carrying a colour of their own. */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.05rem 0.4rem;
  border: 1px solid var(--danger);
  border-radius: 10px;
  background: var(--panel);
  color: var(--text);
  font-size: 0.8rem;
}

.chip button {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  line-height: 1;
  cursor: pointer;
}

/* Seven columns on a phone leave about 45px a cell, which no meal name
   survives. The name is dropped rather than truncated — the badge and the
   editor still say what happened, and a row of half-words says nothing. */
@media (max-width: 34rem) {
  .calendar .cell {
    min-height: 2.4rem;
  }

  .day-meal {
    display: none;
  }

  .calendar .cell:not(.empty):not(.filler)::after {
    content: '•';
    position: absolute;
    left: 0.3rem;
    bottom: 0.1rem;
    font-size: 0.7rem;
    color: var(--accent);
  }
}
