:root {
  --brand-yellow: #ffb000;
  --brand-black: #000002;
  --bg: #000002;
  --panel: #09090d;
  --panel-2: #131318;
  --panel-3: #050507;
  --border: #4a3400;
  --border-soft: #272112;
  --border-day: #ffb000;
  --text: #e8ecf3;
  --muted: #a9adba;
  --accent: var(--brand-yellow);
  --accent-text: #fff4cf;
  --accent-strong-text: #fff0b8;
  --danger: #ff6b6b;
  --danger-bg: #d83a3a;
  --danger-bg-hover: #ef4d4d;
  --danger-text: #ffffff;
  --error-text: #ff9b9b;
  --error-border: #ff6b6b;
  --error-focus: rgba(255, 107, 107, .35);
  --success: var(--brand-yellow);
  --shadow: rgba(0,0,0,.25);
  --placeholder: #858a98;
  --table-wrap-bg: #030305;
  --table-header-bg: var(--panel-3);
  --table-subheader-bg: #1c1708;
  --sticky-bg: rgba(12, 12, 17, .98);
  --sticky-alt-bg: #060608;
  --sticky-day-bg: #221804;
  --strong-text: #f3f6fb;
  --soft-text: #d8e0ef;
  --contact-text: #eef3ff;
  --cell-subtle-bg: rgba(255,255,255,.02);
  --cell-softer-bg: rgba(255,255,255,.01);
  --cell-hover-bg: rgba(255,255,255,.04);
  --cell-border: rgba(255,255,255,.06);
  --cell-border-strong: rgba(255,255,255,.08);
  --actions-bg: rgba(16,20,28,.92);
  --sticky1: 230px;
  --sticky2: 240px;
}

[data-theme="light"] {
  --bg: #f7f7f8;
  --panel: #ffffff;
  --panel-2: #f1f2f4;
  --panel-3: #fff6de;
  --border: #ffcc4d;
  --border-soft: #d8dbe2;
  --border-day: var(--brand-yellow);
  --text: #111116;
  --muted: #646977;
  --accent: var(--brand-yellow);
  --accent-text: #5c3b00;
  --accent-strong-text: #3f2a00;
  --danger: #c73d3d;
  --danger-bg: #b32626;
  --danger-bg-hover: #8f1f1f;
  --danger-text: #ffffff;
  --error-text: #8f1f1f;
  --error-border: #b32626;
  --error-focus: rgba(179, 38, 38, .24);
  --success: var(--brand-yellow);
  --shadow: rgba(0, 0, 2, .12);
  --placeholder: #7b808c;
  --table-wrap-bg: #ffffff;
  --table-header-bg: #fff2cc;
  --table-subheader-bg: #ffe4a3;
  --sticky-bg: rgba(249, 250, 252, .98);
  --sticky-alt-bg: #f2f3f5;
  --sticky-day-bg: #ffebb5;
  --strong-text: #000002;
  --soft-text: #31333b;
  --contact-text: #17181e;
  --cell-subtle-bg: rgba(0,0,2,.03);
  --cell-softer-bg: rgba(0,0,2,.018);
  --cell-hover-bg: rgba(255, 176, 0, .12);
  --cell-border: rgba(0,0,2,.12);
  --cell-border-strong: rgba(0,0,2,.2);
  --actions-bg: rgba(247, 247, 248, .95);
}

html, body {
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

body, .table, .table td, .table th, .form-label, .form-check-label, .btn, .badge {
  color: var(--text);
}

[data-theme="light"] .text-dark {
  color: #1a1200 !important;
}

[data-theme="light"] .btn-close-white {
  filter: none;
}

.app-shell { max-width: 1840px; }

.card-dark, .toolbar-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 10px 30px var(--shadow);
}

.card-dark{
  margin-left: calc(1.5rem * .5);
  margin-right: calc(1.5rem * .5);
}

.toolbar-box {
  padding: 1rem;
  margin-bottom: 1rem;
}

.toolbar-box + .toolbar-box {
  margin-top: 0;
}


.form-control, .form-select {
  background-color: var(--panel-2);
  color: var(--text);
  border-color: var(--border);
}

.form-control:focus, .form-select:focus {
  background-color: var(--panel-2);
  color: var(--text);
  border-color: var(--accent);
  box-shadow: 0 0 0 .2rem rgba(255, 176, 0, .18);
}

.form-control::placeholder { color: var(--placeholder); }

.table-wrap {
  max-height: 74vh;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--table-wrap-bg);
}

.table-dark-custom {
  --bs-table-bg: transparent;
  --bs-table-striped-bg: var(--cell-subtle-bg);
  --bs-table-hover-bg: var(--cell-hover-bg);
  --bs-table-color: var(--text);
  --bs-table-striped-color: var(--text);
  --bs-table-hover-color: var(--text);
  margin-bottom: 0;
}

.table-dark-custom > :not(caption) > * > * {
  color: var(--text) !important;
  background-color: transparent;
  border-color: var(--border-soft);
}

.sticky-head thead th {
  position: sticky;
  background: var(--table-header-bg) !important;
  z-index: 5;
  white-space: nowrap;
  vertical-align: middle;
  font-size: .8rem;
  padding: 0 .55rem;
  line-height: 1.1;
  color: var(--strong-text) !important;
  border-bottom: 1px solid var(--border);
  text-transform: none;
  letter-spacing: .01em;
  box-sizing: border-box;
}

.sticky-head thead tr:first-child th {
  top: 0;
  font-weight: 700;
  height: 46px;
  min-height: 46px;
}

.sticky-head thead tr:nth-child(2) th {
  top: 46px;
  z-index: 4;
  font-size: .72rem;
  font-weight: 600;
  color: var(--soft-text) !important;
  background: var(--table-subheader-bg) !important;
  padding: 0 .25rem;
  height: 34px;
  min-height: 34px;
}

.sticky-head thead th[rowspan="2"] {
  height: 80px !important;
  min-height: 80px !important;
}
.sticky-head thead tr:first-child th.sticky-col-1,
.sticky-head thead tr:first-child th.sticky-col-2 {
  z-index: 30 !important;
}

.sticky-col-1, .sticky-col-2 {
  position: sticky;
  background: var(--sticky-bg) !important;
  backdrop-filter: blur(3px);
  z-index: 8;
}

.sticky-col-1 {
  left: 0;
  box-shadow: 2px 0 0 var(--border);
}

.sticky-col-2 {
  left: var(--sticky1);
  box-shadow: 2px 0 0 var(--border);
}

thead .sticky-col-1,
thead .sticky-col-2 {
  z-index: 20 !important;
  background: var(--sticky-alt-bg) !important;
}

thead tr:nth-child(2) .sticky-col-1,
thead tr:nth-child(2) .sticky-col-2 {
  z-index: 21 !important;
}

tbody .sticky-col-1,
tbody .sticky-col-2 {
  z-index: 9;
}

.col-name { min-width: var(--sticky1); width: var(--sticky1); }
.col-contact { min-width: var(--sticky2); width: var(--sticky2); }
.col-compact { min-width: 122px; }

.sticky-head thead th {
  text-align: center;
}

.sticky-head thead th.sticky-col-1,
.sticky-head thead th.sticky-col-2,
.sticky-head thead th[rowspan="2"] {
  vertical-align: middle !important;
}

.meal-head {
  min-width: 42px;
  text-align: center;
  height: 34px;
  min-height: 34px;
}

tbody td {
  padding: .55rem .5rem;
  font-size: .88rem;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

tbody tr:nth-child(odd) td,
tbody tr:nth-child(even) td {
  color: var(--text) !important;
}

tbody tr:nth-child(odd) {
  background: var(--cell-subtle-bg);
}

tbody tr:nth-child(even) {
  background: var(--cell-softer-bg);
}

tbody tr:hover td {
  background: var(--cell-hover-bg);
  color: var(--strong-text) !important;
}

.meal-cell {
  text-align: center;
  padding: .38rem .16rem !important;
  border-right: 1px solid var(--cell-border);
}

.day-group-header {
  background: var(--sticky-day-bg) !important;
  border-left: 2px solid var(--border-day) !important;
  border-right: 2px solid var(--border-day) !important;
  box-shadow: inset 0 -1px 0 var(--cell-border);
}

.meal-subheader {
  border-right: 1px solid var(--cell-border-strong) !important;
}

.meal-subheader.day-end,
.meal-cell.day-end {
  border-right: 2px solid var(--border-day) !important;
}

.meal-subheader.day-start,
.meal-cell.day-start {
  border-left: 2px solid var(--border-day) !important;
}

.badge-soft {
  background: var(--cell-hover-bg);
  color: var(--muted);
  border: 1px solid var(--border);
  font-weight: 500;
}

.section-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .01em;
  margin-bottom: 1rem;
}

.muted { color: var(--muted) !important; }
.footer-note { font-size: .9rem; color: var(--muted); }

.btn-soft-primary {
  background: rgba(255, 176, 0, .16);
  border: 1px solid rgba(255, 176, 0, .45);
  color: var(--accent-text);
}

.btn-soft-primary:hover {
  background: rgba(255, 176, 0, .24);
  color: var(--strong-text);
}

.btn-soft-danger {
  background: var(--danger-bg);
  border: 1px solid var(--danger-bg);
  color: var(--danger-text);
  font-weight: 700;
}

.btn-soft-danger:hover {
  background: var(--danger-bg-hover);
  border-color: var(--danger-bg-hover);
  color: var(--danger-text);
}

.btn-soft-danger:focus-visible {
  box-shadow: 0 0 0 .2rem rgba(255, 107, 107, .35);
}

.btn-with-icon {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
}

.btn-icon {
  width: 1rem;
  height: 1rem;
  flex: 0 0 auto;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
}

.top-action-btn {
  min-height: 44px;
}

.top-actions .btn-with-icon {
  justify-content: center;
}

.theme-icon {
  width: 1.08rem;
  height: 1.08rem;
}

.theme-icon-moon {
  display: none;
}

[data-theme="light"] .theme-icon-sun {
  display: none;
}

[data-theme="light"] .theme-icon-moon {
  display: block;
}

.meal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .75rem;
}

.meal-editor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: .75rem;
}

.meal-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: .5rem;
}

.meal-box {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem;
}

.meal-box-header {
  margin-bottom: .5rem;
}

.meal-box .title {
  font-weight: 700;
  font-size: .95rem;
  overflow-wrap: anywhere;
}

.day-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: .5rem;
  margin-bottom: .55rem;
  padding: .35rem .5rem;
  background: rgba(255, 176, 0, .08);
  border: 1px solid rgba(255, 176, 0, .28);
  border-radius: 8px;
  color: var(--accent-text);
  font-size: .8rem;
  line-height: 1.2;
  text-align: left;
  cursor: pointer;
}

.day-toggle:hover {
  background: rgba(255, 176, 0, .14);
  color: var(--strong-text);
}

.day-toggle.is-selected {
  background: rgba(255, 176, 0, .22);
  border-color: rgba(255, 176, 0, .6);
  color: var(--strong-text);
}

.day-toggle.is-partial {
  border-style: dashed;
}

.day-toggle-count {
  min-width: 2.1rem;
  padding: .12rem .35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--accent-text);
  text-align: center;
  flex: 0 0 auto;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .2rem 0;
}

.checkbox-row input {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

@media (max-width: 576px) {
  .meal-editor-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .meal-editor-actions {
    justify-content: flex-start;
  }
}

.modal-content {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 18px;
}

.modal-header, .modal-footer { border-color: var(--border); }

.invalid-note {
  font-size: .9rem;
  color: var(--error-text);
  font-weight: 700;
}

.field-error {
  margin-top: .35rem;
  font-size: .82rem;
  color: var(--error-text);
  font-weight: 700;
}

.form-control.is-invalid,
.form-select.is-invalid {
  border-color: var(--error-border);
  box-shadow: 0 0 0 .16rem var(--error-focus);
}

.required-hint {
  color: var(--muted);
  font-size: .86rem;
}

.required-hint span {
  color: var(--accent);
  font-weight: 700;
}

.required-marker {
  color: var(--accent);
}

.btn:disabled {
  cursor: not-allowed;
}

.person-name {
  font-weight: 700;
  font-size: .96rem;
  line-height: 1.2;
  color: var(--strong-text);
}

.person-sub {
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.2;
  margin-top: .18rem;
}

.contact-main {
  font-size: .86rem;
  line-height: 1.2;
  color: var(--contact-text);
  word-break: break-word;
}

.contact-sub {
  color: var(--muted);
  font-size: .8rem;
  margin-top: .18rem;
  line-height: 1.2;
}

.status-chip {
  display: inline-block;
  padding: .18rem .45rem;
  border-radius: 999px;
  font-size: .74rem;
  border: 1px solid var(--border);
  background: var(--cell-hover-bg);
  color: var(--text);
  white-space: nowrap;
}

.meal-pill {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  border: 1px solid var(--cell-border-strong);
  font-size: .72rem;
  line-height: 1;
  background: var(--cell-softer-bg);
  color: transparent;
  user-select: none;
}

.meal-pill.active {
  background: rgba(255, 176, 0, .20);
  border-color: rgba(255, 176, 0, .55);
  color: var(--strong-text);
  font-weight: 700;
}

.meal-toggle {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--accent);
  transform: translateY(1px);
}

.control-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .9rem;
  align-items: stretch;
}

.search-panel,
.toggle-panel {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  justify-content: flex-start;
  min-height: 102px;
  padding: .75rem;
  background: rgba(255, 176, 0, .04);
  border: 1px solid rgba(255, 176, 0, .22);
  border-radius: 8px;
}

.search-panel {
  flex: 1 1 320px;
  min-width: 280px;
}

.toggle-panel {
  flex: 0 1 360px;
  min-width: 280px;
}

.search-panel .form-label,
.toggle-panel .form-label {
  display: block;
  min-height: 0;
  margin: 0;
  line-height: 1.2;
}

.search-panel .form-control,
.toggle-group {
  min-height: 42px;
}

.filter-panel-header {
  display: flex;
  flex-direction: column;
  gap: .22rem;
  min-height: 40px;
}

.toggle-help {
  margin: 0;
  color: var(--muted);
  font-size: .82rem;
  line-height: 1.25;
}

.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: .55rem;
}

.toggle-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .5rem .85rem;
  background: var(--panel-2);
  border: 1px solid rgba(255, 176, 0, .62);
  border-radius: 8px;
  color: var(--accent-text);
  font-weight: 600;
  line-height: 1.1;
  min-height: 40px;
  cursor: pointer;
  user-select: none;
  transition: background-color .15s ease, border-color .15s ease, color .15s ease, box-shadow .15s ease;
}

.toggle-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle-chip:has(input:checked) {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a1200;
  box-shadow: 0 0 0 .15rem rgba(255, 176, 0, .14);
}

.toggle-chip:has(input:not(:checked)) {
  background: rgba(255, 176, 0, .05);
}

.toggle-chip:hover {
  background: rgba(255, 176, 0, .18);
  color: var(--strong-text);
}

.toggle-chip:has(input:checked):hover {
  background: #ffc033;
  color: #1a1200;
}

.toggle-chip:has(input:focus-visible) {
  outline: 2px solid rgba(255, 176, 0, .8);
  outline-offset: 3px;
}

.actions-cell {
  min-width: 150px;
  background: var(--actions-bg);
}



.help-content h5 {
  color: var(--strong-text);
  margin-top: 1rem;
  margin-bottom: .45rem;
}

.help-content h5:first-child {
  margin-top: 0;
}

.help-content p,
.help-content ul {
  color: var(--text);
}

.help-content ul {
  padding-left: 1.2rem;
  margin-bottom: .85rem;
}

footer {
  margin: 20px 10px 10px 10px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 1200px) {
  :root {
    --sticky1: 190px;
    --sticky2: 200px;
  }
  .col-name, .col-contact {
    min-width: unset;
    width: auto;
  }
}
