:root {
  --bg: #f7f8fb;
  --bg-2: #eef1f6;
  --panel: #ffffff;
  --border: #e3e7ee;
  --border-strong: #cbd0db;
  --text: #1a2236;
  --text-soft: #4a5266;
  --muted: #6b7385;
  --accent: #2e6dff;
  --accent-2: #4f86ff;
  --accent-soft: #e8efff;
  --accent-dark: #1c4dd1;
  --good: #16a34a;
  --good-soft: #e6f7ec;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --purple: #7c3aed;
  --purple-soft: #ede9fe;
  --pink: #db2777;
  --pink-soft: #fce7f3;
  --teal: #0d9488;
  --teal-soft: #ccfbf1;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
  --shadow:    0 1px 3px rgba(15,23,42,.06), 0 4px 12px rgba(15,23,42,.05);
  --shadow-lg: 0 4px 6px rgba(15,23,42,.05), 0 10px 24px rgba(15,23,42,.08);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --header-bg: linear-gradient(135deg, #1e2a47 0%, #2a3a5f 100%);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ----- TOP NAV ----- */
.topbar {
  background: var(--header-bg);
  color: #fff;
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 60px;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  margin-right: 18px;
  text-decoration: none;
  letter-spacing: -0.01em;
}
.topbar .brand-logo {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #4f86ff, #7c3aed);
  border-radius: 8px;
  display: grid;
  place-items: center;
  font-size: 18px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}
.topbar a {
  color: #b8c1d6;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: 8px;
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.topbar a:hover { color: #fff; background: rgba(255,255,255,0.07); }
.topbar a.active { color: #fff; background: rgba(255,255,255,0.13); }
.topbar .spacer { flex: 1; }
.topbar .nav-icon {
  width: 16px; height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.container { max-width: 1320px; margin: 0 auto; padding: 28px; }

/* ----- PANELS ----- */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}

/* ----- HEADINGS ----- */
h1 { font-size: 26px; margin: 0 0 18px; font-weight: 700; letter-spacing: -0.02em; color: var(--text); }
h2 { font-size: 17px; margin: 0 0 12px; font-weight: 600; color: var(--text); }
h3 { font-size: 12px; margin: 18px 0 8px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }

/* ----- TABLES ----- */
table { width: 100%; border-collapse: collapse; }
th, td {
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  text-align: left;
  vertical-align: top;
}
th { background: var(--bg-2); font-weight: 600; font-size: 12px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; }
tr:hover td { background: #f9fafb; }

/* ----- FORMS ----- */
input[type="text"], input[type="number"], input[type="password"], input[type="date"],
select, textarea {
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #fff;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: end; }
.field { flex: 1; min-width: 160px; }
.field label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-weight: 600; letter-spacing: 0.02em; }
label.check { display: inline-flex; gap: 8px; align-items: center; font-size: 13px; cursor: pointer; }

/* ----- BUTTONS ----- */
.btn, button[type="submit"], button.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--accent-dark); border-color: var(--accent-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border-strong); }
.btn.secondary:hover { background: #f4f6fa; color: var(--accent); border-color: var(--accent); }
.btn.danger  { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn-link { background: none; border: none; color: var(--accent); cursor: pointer; padding: 0; font-size: inherit; }
.btn-link:hover { text-decoration: underline; }

/* ----- FLASHES ----- */
.flashes { list-style: none; padding: 0; margin: 0 0 18px; }
.flashes li {
  padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 8px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 500;
}
.flashes li::before { font-size: 18px; }
.flash-success { background: var(--good-soft); border-color: var(--good); color: #166534; }
.flash-success::before { content: "✓"; color: var(--good); }
.flash-error   { background: var(--bad-soft);  border-color: var(--bad);  color: #991b1b; }
.flash-error::before { content: "⚠"; color: var(--bad); }

/* ----- BADGES ----- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-2);
  color: var(--text-soft);
  border: 1px solid var(--border);
}
.badge.grain   { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.badge.meat    { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.badge.fruit   { background: #ffe4e6; color: #9f1239; border-color: #fda4af; }
.badge.veg     { background: var(--good-soft); color: #166534; border-color: #86efac; }
.badge.milk    { background: var(--accent-soft); color: var(--accent-dark); border-color: #93c5fd; }
.badge.condiment, .badge.other { background: var(--bg-2); color: var(--text-soft); border-color: var(--border-strong); }

/* ----- STAT CARDS (dashboard) ----- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.stat-icon.blue   { background: var(--accent-soft); color: var(--accent); }
.stat-icon.green  { background: var(--good-soft);   color: var(--good); }
.stat-icon.amber  { background: var(--warn-soft);   color: var(--warn); }
.stat-icon.purple { background: var(--purple-soft); color: var(--purple); }
.stat-icon.pink   { background: var(--pink-soft);   color: var(--pink); }
.stat-icon.teal   { background: var(--teal-soft);   color: var(--teal); }
.stat-card .value { font-size: 24px; font-weight: 700; line-height: 1.1; color: var(--text); }
.stat-card .label { font-size: 12px; color: var(--muted); margin-top: 2px; font-weight: 500; }

/* ----- SESSION CARDS ----- */
.session-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.15s;
  text-decoration: none;
  color: inherit;
  margin-bottom: 12px;
}
.session-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); border-color: var(--accent); }
.session-card .avatar {
  width: 52px; height: 52px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}
.session-card .info { flex: 1; min-width: 0; }
.session-card .info .name { font-weight: 600; font-size: 15px; color: var(--text); }
.session-card .info .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.session-card .links { display: flex; gap: 6px; flex-shrink: 0; }

/* ----- CALENDAR ----- */
.calendar {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar .cal-head {
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding: 8px 0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.cal-day {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  min-height: 130px;
  display: block;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}
.cal-day:hover { border-color: var(--accent); box-shadow: var(--shadow); transform: translateY(-1px); }
.cal-day.empty { background: transparent; border-style: dashed; opacity: .4; }
.cal-day.today { border-color: var(--accent); background: var(--accent-soft); }
.cal-day .d-num { font-weight: 700; font-size: 13px; color: var(--text); margin-bottom: 6px; }
.cal-day.today .d-num { color: var(--accent); }
.cal-day .meal-line {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.cal-day .meal-line.has { color: var(--good); font-weight: 500; }
.cal-day .meal-line.miss { color: #b8c0d0; }

/* ----- DAY EDITOR ----- */
.meal-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 18px;
}
@media (max-width: 980px) { .meal-grid { grid-template-columns: 1fr; } }
.meal-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.meal-card h2 {
  padding: 12px 16px;
  margin: 0;
  background: var(--bg-2);
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.meal-card .meal-body { padding: 14px 16px; }

/* ----- TOOLBAR ----- */
.toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
}
.toolbar h1, .toolbar h2 { margin: 0; }
.toolbar .spacer { flex: 1; }

/* ----- MISC ----- */
.muted { color: var(--muted); }
.right { text-align: right; }
hr.soft { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.kbd-tip { color: var(--muted); font-size: 12px; margin-top: 8px; }
.no-print { }
.print-only { display: none; }

/* Production records styling tweaks */
.prod-day { margin-bottom: 30px; }
.prod-meal { margin-top: 14px; }
.prod-meal h4 { margin: 8px 0; font-size: 13px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; }

@media print {
  .topbar, .no-print, .btn, button { display: none !important; }
  .container { max-width: 100%; padding: 0; }
  .panel { box-shadow: none; border: 1px solid #ccc; }
  body { background: #fff; }
  .print-only { display: block; }
  .prod-day { page-break-after: always; }
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--muted);
}
.empty-state .icon {
  width: 60px; height: 60px;
  margin: 0 auto 14px;
  background: var(--bg-2);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 28px;
  color: var(--text-soft);
}
.empty-state h3 { color: var(--text); font-size: 16px; text-transform: none; letter-spacing: 0; margin-bottom: 6px; }

/* ------- Searchable item combobox ------- */
.combobox { position: relative; }
.combobox .combo-input {
  width: 100%;
  padding: 8px 32px 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font: inherit;
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7385' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") right 10px center no-repeat;
}
.combobox .combo-input:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.combobox .combo-input.has-value { background-color: var(--accent-soft); }
.combobox .combo-list {
  position: absolute;
  top: 100%; left: 0; right: 0;
  z-index: 50;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  margin-top: 2px;
  list-style: none;
  padding: 4px 0;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.combobox .combo-list[hidden] { display: none; }
.combobox .combo-group {
  padding: 6px 12px 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  background: var(--bg-2);
  border-top: 1px solid var(--border);
}
.combobox .combo-group:first-child { border-top: 0; }
.combobox .combo-option {
  padding: 7px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.combobox .combo-option:hover,
.combobox .combo-option.active { background: var(--accent-soft); color: var(--accent-dark); }
.combobox .combo-option[hidden] { display: none; }
.combobox .combo-option .combo-code { color: var(--muted); font-size: 11px; }
.combobox .combo-empty { padding: 14px; color: var(--muted); text-align: center; font-size: 13px; }
.combobox.invalid .combo-input { border-color: var(--bad); }
