:root {
  --bg: #f7f8fa;
  --ink: #111827;
  --sub: #667085;
  --muted: #98a2b3;
  --card: #ffffff;
  --line: #e4e7ec;
  --line2: #cfd5df;
  --brand: #0f172a;
  --blue: #2563eb;
  --green: #0f9f6e;
  --amber: #d97706;
  --red: #d92d20;
  --violet: #6941c6;
  --radius: 8px;
  --shadow: 0 12px 30px rgba(16, 24, 40, .07);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans KR", system-ui, sans-serif;
}

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

.shell {
  width: min(100% - 40px, 1320px);
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .9);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.topbar-inner {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  display: grid;
  place-items: center;
  background: var(--brand);
  color: #fff;
  flex: 0 0 auto;
}

.brand-title {
  font-size: 17px;
  font-weight: 900;
}

.brand-sub {
  margin-top: 1px;
  color: var(--sub);
  font-size: 12px;
}

.nav-actions, .btn-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

main.shell { padding: 24px 0 56px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 38px;
  line-height: 1.12;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 650px;
  margin: 10px 0 0;
  color: var(--sub);
  line-height: 1.6;
}

.status-card, .panel, .stat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.status-card { padding: 13px; }

.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sub);
  font-size: 13px;
  font-weight: 800;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
}

.dot.loading { background: var(--amber); }
.dot.error { background: var(--red); }

.panel {
  overflow: hidden;
}

.panel-head {
  min-height: 58px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  margin: 0;
  font-size: 16px;
  font-weight: 900;
}

.panel-body { padding: 16px; }

.field { margin-bottom: 14px; }

label {
  display: block;
  margin-bottom: 7px;
  color: #344054;
  font-size: 13px;
  font-weight: 900;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line2);
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
  padding: 10px 12px;
}

textarea {
  min-height: 96px;
  resize: vertical;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(37, 99, 235, .75);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
}

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.btn {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  color: var(--ink);
  background: #fff;
  text-decoration: none;
  font-weight: 900;
  white-space: nowrap;
}

.btn.primary { background: var(--brand); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.light { border-color: var(--line2); background: #fff; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stat { padding: 14px; }

.stat strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.stat span {
  display: block;
  margin-top: 7px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 900;
}

.filters {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) 160px 160px;
  gap: 8px;
  margin-bottom: 12px;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: calc(100vh - 330px);
}

table {
  width: 100%;
  min-width: 940px;
  border-collapse: collapse;
  background: #fff;
}

th, td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f4f7;
  color: #475467;
  font-size: 12px;
  font-weight: 900;
}

tr:last-child td { border-bottom: 0; }
.nowrap { white-space: nowrap; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin: 2px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.pill.blue { color: #1d4ed8; background: #e7f0ff; border-color: #c8dcff; }
.pill.green { color: #087f5b; background: #e6fcf5; border-color: #c3fae8; }
.pill.amber { color: #b45309; background: #fff4e6; border-color: #ffd8a8; }
.pill.red { color: #c92a2a; background: #fff0ed; border-color: #ffc9c9; }
.pill.violet { color: #5f3dc4; background: #f3f0ff; border-color: #d0bfff; }

.empty {
  border: 1px dashed var(--line2);
  border-radius: var(--radius);
  background: #fff;
  padding: 38px 16px;
  text-align: center;
  color: var(--sub);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(18px);
  opacity: 0;
  pointer-events: none;
  z-index: 50;
  border-radius: var(--radius);
  background: #111827;
  color: #fff;
  padding: 11px 15px;
  font-size: 13px;
  font-weight: 800;
  box-shadow: 0 18px 50px rgba(17, 24, 39, .22);
  transition: .18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, .34);
}

.modal.show { display: flex; }

.modal-box {
  width: min(720px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .22);
}

.edit-fields {
  grid-template-columns: 140px 1fr 1fr;
}

.meal-box {
  width: min(820px, 100%);
}

.meal-controls {
  display: grid;
  grid-template-columns: 220px auto;
  gap: 10px;
  align-items: end;
  margin-bottom: 14px;
}

.meal-controls .field {
  margin-bottom: 0;
}

.meal-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.meal-summary div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px;
}

.meal-summary strong {
  display: block;
  font-size: 28px;
  line-height: 1;
}

.meal-summary span {
  display: block;
  margin-top: 7px;
  color: var(--sub);
  font-size: 12px;
  font-weight: 900;
}

.meal-final {
  background: #eef4ff !important;
  border-color: #bfd3ff !important;
}

.meal-note {
  color: var(--sub);
  font-size: 13px;
  margin-bottom: 10px;
}

.meal-types {
  margin-bottom: 12px;
}

.meal-list {
  max-height: 210px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.meal-list span {
  border-radius: 999px;
  background: #f2f4f7;
  padding: 5px 9px;
  color: #344054;
  font-size: 12px;
  font-weight: 800;
}

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

.detail-grid div {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  padding: 12px;
}

.detail-grid span {
  display: block;
  color: var(--sub);
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 6px;
}

.detail-grid strong {
  display: block;
  font-size: 14px;
  line-height: 1.5;
}

.detail-wide {
  grid-column: 1 / -1;
}

@media (max-width: 900px) {
  .shell { width: min(100% - 28px, 1320px); }
  .hero { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .filters { grid-template-columns: 1fr; }
  .edit-fields { grid-template-columns: 1fr; }
  .meal-controls, .meal-summary, .detail-grid { grid-template-columns: 1fr; }
  .topbar-inner { align-items: flex-start; flex-direction: column; padding: 12px 0; }
}
