:root {
  --primary: #4f46e5;
  --primary-strong: #4338ca;
  --success: #15803d;
  --warning: #f59e0b;
  --nav: #ffffff;
  --nav-soft: #eef0ff;
  --blue: #2563eb;
  --danger: #dc2626;
  --gray: #64748b;
  --bg: #f5f6fb;
  --card-bg: #ffffff;
  --field-bg: #f1f2f7;
  --text-main: #11142a;
  --text-muted: #717891;
  --border: #e8eaf2;
  --border-strong: #d8dbe8;
  --border-table: #cfd4e3;
  --header-bg: #eef0ff;
  --cat-bg: #f1f2f7;
  --chk-bg: #f1f2f7;
  --chk-active-bg: #eef0ff;
  --matrix-head-bg: #eef0ff;
  --saved-bg: #e3e7ff;
  --saved-text: #3730a3;
  --shadow-card: 0 1px 2px rgba(17, 20, 42, 0.04), 0 2px 8px rgba(17, 20, 42, 0.05);
  --shadow-float: 0 8px 28px rgba(17, 20, 42, 0.12);
  --shadow-accent: 0 8px 20px rgba(79, 70, 229, 0.28);
  --radius: 16px;
  --top-nav-height: 92px;
  --tabs-height: 48px;
  --sticky-overlap: 1px;
  --tab-content-gap: 0px;
  --footer-side-padding: 14px;
  --footer-bottom-padding: 10px;
}

body.dark-theme {
  --primary: #6366f1;
  --primary-strong: #818cf8;
  --success: #22c55e;
  --warning: #fbbf24;
  --nav: #161a26;
  --nav-soft: #20223a;
  --blue: #60a5fa;
  --danger: #ef4444;
  --gray: #94a3b8;
  --bg: #0d0f16;
  --card-bg: #161a26;
  --field-bg: #1d2231;
  --text-main: #e7e9f3;
  --text-muted: #8b93a7;
  --border: #232838;
  --border-strong: #2e3447;
  --border-table: #3a4157;
  --header-bg: #20223a;
  --cat-bg: #1d2231;
  --chk-bg: #1d2231;
  --chk-active-bg: #272a52;
  --matrix-head-bg: #20223a;
  --saved-bg: #272a52;
  --saved-text: #c7d2fe;
  --shadow-card: 0 8px 22px rgba(0, 0, 0, 0.22);
  --shadow-float: 0 12px 36px rgba(0, 0, 0, 0.48);
  --shadow-accent: 0 8px 20px rgba(99, 102, 241, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-splash {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg);
  color: var(--text-main);
  opacity: 1;
  transition: opacity 220ms ease, visibility 220ms ease;
}

.app-splash.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.app-splash-card {
  position: relative;
  display: grid;
  justify-items: center;
  gap: 10px;
  min-width: 210px;
  padding: 24px 26px;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--card-bg);
  box-shadow: var(--shadow-float);
  transform: translateY(0);
  transition: transform 220ms ease;
}

.app-splash.is-hidden .app-splash-card {
  transform: translateY(8px);
}

.app-splash-icon {
  width: 82px;
  height: 82px;
  border-radius: 22px;
  box-shadow: var(--shadow-accent);
}

.app-splash-title {
  margin-top: 4px;
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.02em;
}

.app-splash-subtitle {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 800;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

.login-screen.active {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 400px;
  padding: 28px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-float);
  text-align: center;
}

.login-box h1 {
  margin: 0 0 20px;
  color: var(--text-main);
  font-size: 1.45rem;
}

.login-input {
  width: 100%;
  padding: 15px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text-main);
  font-size: 1.05rem;
}

.login-btn {
  width: 100%;
  padding: 15px;
  border: 0;
  border-radius: var(--radius);
  background: var(--primary);
  color: #ffffff;
  font-size: 1.15rem;
  font-weight: 800;
  box-shadow: var(--shadow-accent);
}

.auth-error {
  display: none;
  margin-bottom: 12px;
  color: var(--danger);
  font-weight: 800;
}

.auth-error.active {
  display: block;
}

.guest-screen.active {
  min-height: 100vh;
  display: block;
  padding: 14px;
  background: var(--bg);
}

.guest-root {
  max-width: 760px;
  margin: 0 auto;
}

.guest-card {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

.guest-card h1,
.guest-card h2,
.guest-card h3 {
  margin: 0 0 10px;
}

.guest-card h1 {
  color: var(--primary);
  font-size: 1.7rem;
}

.guest-card h2 {
  font-size: 1.25rem;
}

.guest-section {
  display: block;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.guest-section summary {
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 900;
}

.guest-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.guest-summary > div,
.guest-menu-meal {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.guest-meal-summary {
  margin-top: 12px;
}

.guest-meal-title {
  margin-bottom: 4px;
  font-weight: 900;
  text-transform: uppercase;
}

.guest-meal-summary ul {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.guest-meal-summary li {
  margin: 2px 0;
  line-height: 1.25;
}

.guest-menu-list {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.guest-menu-section {
  margin-top: 8px;
}

.guest-menu-section span {
  color: var(--text-muted);
  font-weight: 900;
}

.guest-menu-section p {
  margin: 4px 0 0;
}

.duty-mark {
  color: var(--primary);
  font-weight: 900;
}

.guest-days {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.top-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  background: var(--nav);
  color: var(--text-main);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-card);
  transform: translateZ(0);
}

.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.nav-badges {
  display: flex;
  flex: 0 0 auto;
  gap: 7px;
  align-items: center;
}

.user-badge {
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--nav-soft);
  color: var(--primary-strong);
  font-size: 0.75rem;
  font-weight: 800;
}

.sync-badge {
  min-width: 70px;
  padding: 5px 9px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(21, 128, 61, 0.12);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.sync-badge.online {
  background: rgba(21, 128, 61, 0.12);
  border-color: transparent;
  color: var(--success);
}

.sync-badge.offline {
  background: rgba(220, 38, 38, 0.12);
  border-color: transparent;
  color: var(--danger);
}

.sync-badge.pending {
  background: rgba(245, 158, 11, 0.16);
  border-color: transparent;
  color: #b45309;
}

.nav-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  text-transform: uppercase;
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-actions {
  justify-content: center;
}

.nav-btn {
  min-height: 38px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: var(--nav-soft);
  color: var(--primary-strong);
  font-size: 0.9rem;
  font-weight: 800;
}

.nav-btn:hover {
  background: var(--chk-active-bg);
}

.nav-btn.danger {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
}

.nav-btn.icon-btn {
  min-width: 48px;
}

.nav-btn.wide {
  width: 100%;
  margin-top: 8px;
  border: 1px dashed var(--border-strong);
  background: var(--field-bg);
  color: var(--text-main);
}

.app-root {
  min-height: calc(100vh - var(--top-nav-height));
  padding-top: var(--top-nav-height);
}

.content {
  padding: 12px;
}

.screen-heading,
.report-heading {
  margin: 8px 4px 16px;
  text-align: left;
  color: var(--text-main);
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.day-btn {
  min-height: 100px;
  padding: 18px 18px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-main);
  font-size: 1.12rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.day-btn:hover {
  border-color: var(--primary);
  background: var(--field-bg);
}

.day-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  background: var(--primary);
  opacity: 0.88;
}

.day-btn span {
  display: block;
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  text-transform: none;
}

.day-screen {
  padding-top: calc(var(--tabs-height) - var(--sticky-overlap) + var(--tab-content-gap));
  padding-bottom: calc(178px + env(safe-area-inset-bottom, 0px));
}

.tabs {
  position: fixed;
  top: calc(var(--top-nav-height) - var(--sticky-overlap));
  left: 0;
  right: 0;
  z-index: 35;
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 0;
  background: var(--bg);
  box-shadow: none;
  transform: translateZ(0);
}

.tab {
  flex: 1;
  padding: 10px 5px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 900;
}

.tab.active {
  border-bottom-color: transparent;
  color: var(--primary-strong);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

.tab-content {
  display: none;
  padding: 8px;
}

.tab-content.active {
  display: block;
}

.input-card,
.admin-section {
  min-width: 0;
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
  overflow-wrap: anywhere;
}

.label-title {
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.input-card input,
.input-card select,
.admin-section input,
.admin-section select,
.json-area {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: 11px;
  background: var(--field-bg);
  color: var(--text-main);
}

.input-card input:focus,
.input-card select:focus,
.admin-section input:focus,
.admin-section select:focus,
.json-area:focus,
.login-input:focus,
.modal-input:focus {
  border-color: var(--primary);
  outline: 3px solid var(--nav-soft);
  outline-offset: 0;
}

.field-error {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px rgba(211, 47, 47, 0.16);
}

.shift-warning {
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, 0.45);
  border-radius: var(--radius);
  background: #fff7ed;
  color: #9a3412;
  font-weight: 800;
}

.shift-warning div {
  margin-top: 4px;
  color: var(--text-main);
  font-weight: 700;
}

.menu-remote-warning {
  border: 1px solid rgba(245, 158, 11, 0.45);
  background: #fff7ed;
  color: #9a3412;
}

body.dark-theme .menu-remote-warning {
  border-color: var(--warning);
  background: rgba(245, 158, 11, 0.15);
  color: #fde68a;
}

body.dark-theme .shift-warning,
body.dark-theme .preflight-summary.warn,
body.dark-theme .day-shift-status.warn,
body.dark-theme .incomplete-label,
body.dark-theme .tracker-box.incomplete {
  border-color: rgba(251, 191, 36, 0.42);
  background: rgba(245, 158, 11, 0.14);
  color: #fde68a;
}

body.dark-theme .preflight-summary.bad,
body.dark-theme .day-shift-status.bad {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
}

body.dark-theme .preflight-summary.ok,
body.dark-theme .day-shift-status.ok {
  background: rgba(45, 212, 191, 0.13);
  color: #99f6e4;
}

body.dark-theme .tracker-box {
  background: #2a3142;
  color: #aeb7ca;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.14);
}

body.dark-theme .tracker-box.saved {
  background: #3730a3;
  color: #f8fafc;
  box-shadow: inset 0 0 0 1px rgba(199, 210, 254, 0.22);
}

body.dark-theme .tracker-box.active {
  background: #818cf8;
  color: #0d0f16;
  box-shadow: 0 0 0 2px rgba(199, 210, 254, 0.35), var(--shadow-accent);
}

/* ── Тосты (неблокирующие уведомления) ───────────────────────────────────── */
.toast-root {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: max-content;
  max-width: 92vw;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  min-width: 220px;
  max-width: 92vw;
  padding: 12px 16px;
  border-radius: var(--radius);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.35;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.toast-success { background: var(--success); }
.toast-error { background: #c62828; }
.toast-warn { background: #d97706; }
.toast-info { background: var(--blue); }

/* ── Модальное окно ввода (замена prompt) ────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 23, 42, 0.58);
  opacity: 0;
  transition: opacity 0.16s ease;
}

.modal-overlay.show {
  opacity: 1;
}

.modal-dialog {
  width: 100%;
  max-width: 420px;
  background: var(--card-bg);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-float);
  transform: translateY(8px);
  transition: transform 0.16s ease;
}

.modal-overlay.show .modal-dialog {
  transform: translateY(0);
}

.modal-title {
  font-size: 18px;
  font-weight: 800;
  margin-bottom: 10px;
}

.modal-label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
}

.modal-input {
  width: 100%;
  padding: 11px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text-main);
  box-sizing: border-box;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}

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

.table-row {
  display: flex;
  align-items: center;
  gap: 11px;
  font-weight: 900;
}

.table-row input {
  flex: 1;
  padding: 11px 13px;
  border: 1.5px solid var(--border-strong);
  border-radius: 11px;
  background: var(--field-bg);
  font-size: 1.35rem;
  font-weight: 900;
  text-align: center;
}

.transfer-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(90px, 1fr)) auto;
  gap: 8px;
  align-items: end;
}

.transfer-row label {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.transfer-row input {
  margin-top: 4px;
  text-align: center;
}

.seat-count-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: var(--text-muted);
  font-weight: 900;
}

.seat-count-row span {
  flex: 1;
}

.seat-count-row .mini-btn:disabled {
  opacity: 0.45;
}

.guest-request-row {
  display: grid;
  grid-template-columns: minmax(76px, 0.8fr) minmax(110px, 1.4fr) repeat(3, minmax(92px, auto));
  gap: 7px;
  align-items: center;
  margin-top: 7px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.tracker-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 11px;
}

.tracker-box {
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 11px;
  background: var(--chk-bg);
  color: #aeb4c7;
  font-size: 0.9rem;
  font-weight: 900;
  flex-direction: column;
  line-height: 1;
}

.tracker-box small {
  margin-top: 3px;
  font-size: 0.56rem;
  opacity: 0.9;
}

.tracker-box.saved {
  border-color: transparent;
  background: var(--saved-bg);
  color: var(--saved-text);
}

.tracker-box.incomplete {
  border-color: rgba(245, 158, 11, 0.58);
  background: #fff3d6;
  color: #92400e;
}

.tracker-box.active {
  border: 0;
  background: var(--primary);
  color: #ffffff;
  box-shadow: var(--shadow-accent);
}

.meal-jump-row {
  display: flex;
  gap: 7px;
  margin-top: 11px;
  overflow-x: auto;
}

.meal-jump-row .nav-btn {
  flex: 1;
  min-width: max-content;
  border: 1.5px solid var(--border-strong);
  border-radius: 999px;
  background: var(--card-bg);
  color: var(--text-muted);
}

.table-history-info {
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text-muted);
  font-size: 0.86rem;
}

.table-history-list {
  margin-top: 8px;
}

.history-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 0.82rem;
}

.history-row b {
  color: var(--text-main);
}

.table-scroll,
.matrix-container {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--border-table);
  background: var(--card-bg);
  border-radius: var(--radius);
}

#tab-in .table-scroll {
  margin-bottom: 34px;
}

#employeesBox > .table-scroll {
  margin-bottom: 16px;
}

#employeesBox > .input-card {
  margin-top: 16px;
}

.blank-table,
.matrix-table,
.emp-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  background: var(--card-bg);
}

.admin-days-table,
.backup-runs-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card-bg);
}

.blank-table th,
.blank-table td,
.matrix-table th,
.matrix-table td,
.emp-table th,
.emp-table td {
  border: 0;
  border-right: 1px solid var(--border-table);
  border-bottom: 1px solid var(--border-table);
  padding: 8px 4px;
  color: var(--text-main);
  vertical-align: middle;
}

.blank-table tr > *:last-child,
.matrix-table tr > *:last-child,
.emp-table tr > *:last-child {
  border-right: 0;
}

.blank-table tr:last-child > *,
.matrix-table tr:last-child > *,
.emp-table tr:last-child > * {
  border-bottom: 0;
}

.blank-table th:first-child {
  width: 42%;
  padding-left: 8px;
  text-align: left;
}

.blank-table th:not(:first-child),
.blank-table td:not(:first-child) {
  text-align: center;
}

.meal-header {
  background: var(--header-bg) !important;
  color: var(--primary-strong) !important;
  text-align: center !important;
  font-size: 1.05rem;
  font-weight: 900;
  scroll-margin-top: calc(var(--top-nav-height) + var(--tabs-height) + 8px);
}

.cat-header {
  background: var(--cat-bg) !important;
  text-align: center !important;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--text-muted) !important;
  letter-spacing: 0.04em;
}

.dish-name {
  padding-left: 8px !important;
  text-align: left !important;
  font-weight: 600;
}

.seat-head {
  user-select: none;
}

.seat-head.selected {
  background: var(--warning) !important;
  color: #ffffff !important;
}

.chk-cell {
  cursor: pointer;
  color: transparent;
  font-size: 1.35rem;
}

.chk-cell.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.chk-cell.selected-seat-col {
  background: rgba(245, 158, 11, 0.16);
  box-shadow: inset 0 0 0 2px rgba(245, 158, 11, 0.35);
}

.chk-cell.active.selected-seat-col {
  background: var(--primary-strong);
}

.chk-cell.active::after {
  content: "✓";
  font-weight: 900;
}

.footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 11px;
  padding: 12px var(--footer-side-padding) max(var(--footer-bottom-padding), env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
  background: var(--card-bg);
  box-shadow: 0 -8px 24px rgba(17, 20, 42, 0.08);
  transform: translateZ(0);
}

.scroll-top-btn {
  position: fixed;
  right: calc(16px + env(safe-area-inset-right, 0px));
  bottom: calc(154px + env(safe-area-inset-bottom, 0px));
  z-index: 38;
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 13px;
  background: var(--primary);
  color: #ffffff;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: var(--shadow-float);
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 150ms ease, transform 150ms ease;
  will-change: opacity, transform;
}

.scroll-top-btn.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.footer-buttons {
  display: flex;
  gap: 10px;
}

.incomplete-label {
  display: flex;
  align-self: flex-start;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid rgba(245, 158, 11, 0.44);
  border-radius: var(--radius);
  background: #fff7ed;
  color: #c2410c;
  font-weight: 900;
  line-height: 1.15;
}

.incomplete-label input {
  width: 22px;
  height: 22px;
}

.btn {
  flex: 1;
  padding: 13px;
  border: 0;
  border-radius: 12px;
  color: #ffffff;
  font-size: 1rem;
  font-weight: 900;
}

.btn.green {
  background: var(--primary);
  box-shadow: var(--shadow-accent);
}

.btn.gray {
  border: 1px solid var(--border);
  background: var(--field-bg);
  color: var(--text-muted);
  flex: 0.35;
}

.btn.blue {
  background: var(--blue);
}

.btn.orange {
  background: #d97706;
}

.btn.red {
  background: var(--danger);
}

.btn.purple {
  background: #4f46e5;
}

.btn.teal {
  background: var(--primary);
}

.btn:not(:disabled):hover,
.mini-btn:not(:disabled):hover,
.add-btn:not(:disabled):hover,
.login-btn:not(:disabled):hover {
  filter: brightness(1.04);
}

.btn:not(:disabled):active,
.mini-btn:not(:disabled):active,
.add-btn:not(:disabled):active,
.nav-btn:not(:disabled):active {
  transform: translateY(1px);
}

.btn.full {
  width: 100%;
  margin-top: 10px;
}

.print-toolbar {
  margin: 14px 0;
  text-align: center;
}

.print-toolbar .btn {
  width: auto;
  padding: 10px 25px;
}

.danger-panel {
  border-color: rgba(220, 38, 38, 0.28);
  background: linear-gradient(180deg, var(--card-bg), rgba(220, 38, 38, 0.035));
}

.clear-day-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr));
  gap: 8px;
}

.matrix-title {
  margin: 24px 0 8px;
  padding-bottom: 6px;
  border-bottom: 2px solid var(--border-strong);
  font-size: 1.08rem;
  font-weight: 900;
  text-transform: uppercase;
  color: var(--primary-strong);
}

.matrix-table {
  min-width: 720px;
}

.matrix-table th {
  background: var(--matrix-head-bg);
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
  hyphens: auto;
}

.matrix-table td {
  text-align: center;
  vertical-align: top;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.sub-head {
  display: block;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.matrix-table th.garnish-head {
  display: table-cell;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
  font-weight: 500;
  line-height: 1.15;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.main-dish-total {
  display: block;
  margin-top: 3px;
  color: var(--primary-strong);
  font-size: 0.72rem;
  font-weight: 900;
}

.cell-data {
  line-height: 1.45;
  font-weight: 900;
}

.total-row td,
.k-total-val {
  background: var(--cat-bg) !important;
  color: var(--success) !important;
  font-weight: 900;
}

.garnish-summary {
  margin: 10px 0 28px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--chk-active-bg);
  color: var(--primary-strong);
  font-weight: 900;
}

.admin-layout {
  display: grid;
  gap: 12px;
  width: 100%;
  min-width: 0;
  max-width: 1100px;
  margin: 0 auto;
}

.admin-section,
.admin-meal-card,
.admin-section-card,
.edit-row {
  min-width: 0;
}

.admin-section h2 {
  margin-top: 0;
  color: var(--primary-strong);
}

.admin-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.admin-collapse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text-main);
  font-weight: 900;
}

.admin-section.collapsed .admin-section-body {
  display: none;
}

.preflight-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-weight: 900;
}

.preflight-summary.ok {
  background: var(--chk-active-bg);
  color: var(--primary-strong);
}

.preflight-summary.warn {
  background: #fff7ed;
  color: #9a3412;
}

.preflight-summary.bad {
  background: #fef2f2;
  color: #991b1b;
}

.preflight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 8px;
}

.preflight-item {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.preflight-item > span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: #ffffff;
  font-weight: 900;
}

.preflight-item.ok > span {
  background: var(--primary);
}

.preflight-item.warn > span {
  background: var(--warning);
}

.preflight-item.bad > span {
  background: var(--danger);
}

.preflight-item b {
  display: block;
  margin-bottom: 3px;
}

.preflight-item p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.day-shift-card {
  display: grid;
  gap: 10px;
}

.day-shift-head {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(170px, auto);
  gap: 10px;
  align-items: end;
}

.day-shift-head label span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-muted);
  font-size: 0.82rem;
  font-weight: 900;
  text-transform: uppercase;
}

.day-shift-status {
  min-height: 44px;
  padding: 8px 10px;
  border-radius: var(--radius);
  font-weight: 900;
}

.day-shift-status span,
.day-shift-status small {
  display: block;
}

.day-shift-status small {
  margin-top: 2px;
  font-size: 0.76rem;
  font-weight: 700;
}

.day-shift-status.ok {
  background: var(--chk-active-bg);
  color: var(--primary-strong);
}

.day-shift-status.warn {
  background: #fff7ed;
  color: #9a3412;
}

.day-shift-status.bad {
  background: #fef2f2;
  color: #991b1b;
}

.day-shift-workers {
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.day-shift-worker {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}

.day-shift-worker:last-child {
  border-bottom: 0;
}

.day-shift-worker span {
  color: var(--text-muted);
  font-weight: 900;
}

.day-shift-worker-editor {
  display: grid;
  gap: 6px;
}

.day-shift-worker-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(120px, 190px);
  gap: 8px;
  align-items: center;
}

.day-shift-worker-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.day-shift-worker-toggle input {
  width: 18px;
  height: 18px;
}

.day-shift-worker-toggle b {
  overflow-wrap: anywhere;
}

.day-shift-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(120px, 1fr));
  gap: 8px;
}

.admin-menu-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.admin-menu-toolbar .btn {
  flex: 1 1 140px;
  font-size: 0.9rem;
  min-width: 0;
}

.admin-days-table {
  min-width: 520px;
  margin: 0;
}

.admin-days-table th,
.admin-days-table td {
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 7px 5px;
  font-size: 0.9rem;
}

.admin-days-table tr > *:last-child {
  border-right: 0;
}

.admin-days-table tr:last-child > * {
  border-bottom: 0;
}

.admin-days-table th {
  background: var(--matrix-head-bg);
  text-align: left;
}

.admin-days-table tr.active-day-row {
  outline: 2px solid var(--primary);
  background: var(--chk-active-bg);
}

.day-name-cell {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text-main);
  text-align: left;
  font-weight: 900;
}

.day-actions {
  width: 170px;
  white-space: nowrap;
  text-align: right;
}

.admin-editor-title {
  margin: 16px 0 8px;
  color: var(--primary-strong);
}

.admin-meal-card {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow-card);
}

.admin-meal-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.admin-meal-title input {
  flex: 1;
  min-width: 0;
  font-weight: 900;
}

.admin-section-card {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.admin-section-head {
  display: grid;
  grid-template-columns: minmax(160px, 1fr) 130px auto;
  gap: 6px;
  align-items: center;
  margin-bottom: 8px;
}

.edit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
}

.edit-row input[type="text"],
.edit-row input:not([type]) {
  flex: 1 1 180px;
  min-width: 0;
}

.edit-row .item-short-name-input {
  flex-basis: 150px;
}

.edit-row .item-full-name-input {
  flex-basis: 260px;
}

.edit-row label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--danger);
  font-size: 0.82rem;
  font-weight: 900;
}

.edit-row label input {
  width: 18px;
  height: 18px;
}

.edit-row label.duty-edit-label {
  color: var(--success);
}

.mini-actions {
  display: flex;
  gap: 4px;
  white-space: nowrap;
}

.mini-btn,
.add-btn {
  border: 0;
  border-radius: var(--radius);
  color: #ffffff;
  font-weight: 900;
}

.mini-btn {
  min-width: 30px;
  padding: 7px 9px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.add-btn {
  padding: 8px 12px;
  margin-bottom: 8px;
}

.mini-btn.gray,
.add-btn.gray {
  background: #64748b;
}

.mini-btn.red,
.add-btn.red {
  background: var(--danger);
}

.mini-btn.orange,
.add-btn.orange {
  background: #d97706;
}

.add-btn.blue,
.mini-btn.blue {
  background: var(--blue);
}

.add-btn.green,
.mini-btn.green {
  background: var(--primary);
}

.add-btn.purple,
.mini-btn.purple {
  background: #4f46e5;
}

.day-access-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.day-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-weight: 900;
}

.day-chip input {
  width: 20px;
  height: 20px;
}

.qr-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

.qr-grid.single {
  grid-template-columns: minmax(150px, 220px);
}

.qr-card {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  text-align: center;
}

.qr-card img {
  width: 132px;
  height: 132px;
  background: #ffffff;
  border-radius: 4px;
}

.qr-card a {
  color: var(--blue);
  font-weight: 900;
}

.qr-manager {
  display: grid;
  gap: 12px;
}

.qr-manager-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.qr-manager-head > div {
  display: grid;
  gap: 3px;
}

.qr-manager-head .btn {
  flex: 0 0 auto;
}

.qr-tools {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(160px, 2fr) auto;
  gap: 8px;
  align-items: end;
}

.qr-tools label {
  display: grid;
  gap: 5px;
}

.qr-tools span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.qr-search-result {
  display: grid;
  gap: 8px;
}

.qr-groups {
  display: grid;
  gap: 8px;
}

.qr-group {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.qr-group summary {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  cursor: pointer;
  font-weight: 900;
}

.qr-group summary span {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.qr-group .qr-grid {
  padding: 10px;
  border-top: 1px solid var(--border);
}

.qr-settings-card {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
}

.toggle-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: fit-content;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-bg);
  font-weight: 900;
}

.toggle-row input {
  width: 22px;
  height: 22px;
  margin: 0;
  accent-color: var(--primary);
}

.qr-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.qr-settings-grid label {
  display: grid;
  gap: 5px;
}

.qr-settings-grid label > span {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.qr-settings-grid small {
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.25;
}

.admin-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.emp-table {
  min-width: 760px;
  table-layout: auto;
}

.emp-table input,
.emp-table select {
  min-width: 100px;
}

.json-area {
  min-height: 260px;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 0.86rem;
}

.json-area.small {
  min-height: 120px;
  margin-top: 10px;
}

.backup-file-input {
  width: 100%;
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--field-bg);
  color: var(--text-main);
}

.backup-runs {
  margin-top: 12px;
}

.backup-runs-table {
  min-width: 620px;
}

.backup-runs-table th,
.backup-runs-table td {
  padding: 8px;
  border: 0;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.backup-runs-table tr > *:last-child {
  border-right: 0;
}

.backup-runs-table tr:last-child > * {
  border-bottom: 0;
}

.backup-runs-table th {
  background: var(--cat-bg);
  font-weight: 900;
}

.muted-text,
.empty-state,
.error-text {
  color: var(--text-muted);
}

.error-text {
  color: var(--danger);
  font-weight: 900;
}

@media (max-width: 900px) {
  .guest-request-row {
    grid-template-columns: 1fr 1fr;
    align-items: stretch;
  }

  .guest-request-row b,
  .guest-request-row span {
    grid-column: 1 / -1;
  }

  .guest-request-row .mini-btn {
    width: 100%;
  }
}

@media (max-width: 700px) {
  :root {
    --tab-content-gap: 16px;
  }

  .content {
    padding: 8px;
  }

  .footer {
    --footer-side-padding: 8px;
    --footer-bottom-padding: 8px;
  }

  .scroll-top-btn {
    right: calc(10px + env(safe-area-inset-right, 0px));
    bottom: calc(166px + env(safe-area-inset-bottom, 0px));
    width: 46px;
    height: 46px;
  }

  .incomplete-label {
    width: 100%;
    max-width: 100%;
    padding: 7px 8px;
    font-size: 0.88rem;
  }

  .guest-request-row {
    grid-template-columns: 1fr;
  }

  .admin-form {
    grid-template-columns: 1fr;
  }

  .qr-settings-grid {
    grid-template-columns: 1fr;
  }

  .qr-manager-head,
  .qr-tools {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .qr-manager-head {
    display: grid;
  }

  .preflight-summary {
    align-items: stretch;
    flex-direction: column;
  }

  .preflight-summary .mini-btn {
    width: 100%;
  }

  .day-shift-head,
  .day-shift-actions {
    grid-template-columns: 1fr;
  }

  .admin-section-head {
    grid-template-columns: 1fr;
  }

  .admin-meal-title {
    align-items: stretch;
    flex-direction: column;
  }

  .edit-row {
    align-items: stretch;
    flex-direction: column;
  }

  .mini-actions {
    flex-wrap: wrap;
    white-space: normal;
  }

  .nav-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }

  .tabs {
    top: calc(var(--top-nav-height) - var(--sticky-overlap));
  }
}

@media (max-width: 520px) {
  .guest-request-row {
    grid-template-columns: 1fr;
  }

  .footer-buttons {
    gap: 8px;
  }

  .btn {
    padding: 10px 8px;
    font-size: 0.95rem;
  }
}

@media print {
  @page {
    size: A4 landscape;
    margin: 7mm;
  }

  .top-nav,
  .tabs,
  .footer,
  .input-card,
  .no-print,
  #screen-login,
  #screen-home,
  #screen-admin {
    display: none !important;
  }

  body,
  .app-root,
  .day-screen,
  .tab-content.active {
    display: block !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    background: #ffffff !important;
    color: #000000 !important;
  }

  .tab-content {
    display: none !important;
  }

  .tab-content.print-active {
    display: block !important;
  }

  .matrix-table,
  .matrix-table th,
  .matrix-table td {
    color: #000000 !important;
    background: #ffffff !important;
  }

  .print-break {
    break-after: page;
    page-break-after: always;
  }

  .last-print-section {
    break-after: auto;
    page-break-after: auto;
  }

  .matrix-container {
    border: 0 !important;
    border-radius: 0 !important;
    background: #ffffff !important;
    box-shadow: none !important;
    overflow: visible !important;
  }

  .matrix-table {
    width: 100% !important;
    min-width: 0 !important;
    border-collapse: collapse !important;
    border-spacing: 0 !important;
    border: 1px solid #000000 !important;
    border-radius: 0 !important;
    table-layout: fixed !important;
  }

  .matrix-table th,
  .matrix-table td,
  .matrix-table th.garnish-head {
    border: 1px solid #000000 !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
    word-break: break-word !important;
    hyphens: auto !important;
  }

  .matrix-table th {
    font-size: 11px !important;
    line-height: 1.15 !important;
  }

  #tab-mx.print-active .control-print-section {
    display: block !important;
    box-sizing: border-box;
    overflow: visible;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  #tab-mx.print-active .control-print-section .matrix-title {
    flex: 0 0 auto;
    margin: 0 0 2mm;
    padding-bottom: 1mm;
    font-size: 10pt;
    line-height: 1.05;
  }

  #tab-mx.print-active .control-matrix-container {
    overflow: visible !important;
  }

  #tab-mx.print-active .matrix-table {
    height: auto;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  #tab-mx.print-active .matrix-table th,
  #tab-mx.print-active .matrix-table td {
    padding: 2px 1.5px !important;
    font-size: 9.2pt !important;
    line-height: 1.12 !important;
  }

  #tab-mx.print-active .matrix-table th {
    font-size: 8.6pt !important;
  }

  #tab-mx.print-active .matrix-table th.garnish-head,
  #tab-mx.print-active .sub-head,
  #tab-mx.print-active .main-dish-total {
    font-size: 7.6pt !important;
    line-height: 1.08 !important;
  }

  #tab-mx.print-active .cell-data {
    font-size: 9.2pt;
    line-height: 1.12;
  }

  #tab-mx.print-active .total-row td {
    font-size: 9pt !important;
    line-height: 1.05 !important;
  }

  #tab-mx.print-active .garnish-summary {
    flex: 0 0 auto;
    margin: 1.6mm 0 0;
    padding: 1.5mm 2mm;
    border-radius: 0;
    font-size: 8.8pt;
    line-height: 1.12;
  }

  #tab-mx.print-active .control-print-section.print-dense .matrix-table th,
  #tab-mx.print-active .control-print-section.print-dense .matrix-table td {
    padding: 1.4px 1px !important;
    font-size: 8.4pt !important;
    line-height: 1.06 !important;
  }

  #tab-mx.print-active .control-print-section.print-dense .cell-data {
    font-size: 8.4pt;
    line-height: 1.06;
  }

  #tab-mx.print-active .control-print-section.print-dense .garnish-summary {
    margin-top: 1.2mm;
    padding: 1.1mm 1.5mm;
    font-size: 8.4pt;
    line-height: 1.08;
  }

  #tab-mx.print-active .control-print-section.print-ultra-dense .matrix-title {
    margin-bottom: 1mm;
    font-size: 9.5pt;
  }

  #tab-mx.print-active .control-print-section.print-ultra-dense .matrix-table th,
  #tab-mx.print-active .control-print-section.print-ultra-dense .matrix-table td {
    padding: 1px 0.8px !important;
    font-size: 7.8pt !important;
    line-height: 1.02 !important;
  }

  #tab-mx.print-active .control-print-section.print-ultra-dense .matrix-table th.garnish-head,
  #tab-mx.print-active .control-print-section.print-ultra-dense .sub-head,
  #tab-mx.print-active .control-print-section.print-ultra-dense .main-dish-total {
    font-size: 6.8pt !important;
    line-height: 1.02 !important;
  }

  #tab-mx.print-active .control-print-section.print-ultra-dense .cell-data {
    font-size: 7.8pt;
    line-height: 1.02;
  }

  #tab-mx.print-active .control-print-section.print-ultra-dense .garnish-summary {
    margin-top: 0.8mm;
    padding: 0.8mm 1.2mm;
    font-size: 7.8pt;
    line-height: 1.05;
  }

  .transfer-row {
    display: none !important;
  }
}
