/* ds-meal Phase 1 CSS.  Slice A focus: typography + tables + nav + hero. */

:root {
  --bg: #ffffff;
  --fg: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --brand: #1f6f52;
  --brand-dark: #144b37;
  --tag-bg: #eef2ff;
  --tag-fg: #3730a3;
  --allergen-bg: #fef3c7;
  --allergen-fg: #92400e;

  /* Status tokens reused across Slices C+ */
  --status-pending: #e0a80f;
  --status-confirmed: #2c7be5;
  --status-in_preparation: #7e3af2;
  --status-out_for_delivery: #00a1b5;
  --status-delivered: #0aab53;
  --status-cancelled: #8a94a6;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  color: var(--fg);
  background: var(--bg);
  line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* -------- Top nav -------- */
.topnav {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.topnav .brand {
  font-weight: 700;
  color: var(--brand-dark);
  font-size: 1.1rem;
}
.topnav a { color: #374151; }
.topnav a:hover { color: var(--brand-dark); }
.topnav .spacer { flex: 1; }
.topnav .signin, .topnav .linkbtn {
  background: var(--brand);
  color: white;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  font-size: 0.95rem;
}
.topnav .signin:hover, .topnav .linkbtn:hover {
  background: var(--brand-dark);
  text-decoration: none;
  color: white;
}
.topnav form.inline { margin: 0; }
.topnav .user { color: var(--muted); font-size: 0.9rem; }

/* -------- Layout -------- */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 3rem;
}
footer {
  border-top: 1px solid var(--border);
  padding: 1rem 1.25rem;
  color: var(--muted);
  text-align: center;
}

/* -------- Typography -------- */
h1 { margin: 0 0 0.5rem; font-size: 1.8rem; }
h2 { margin: 1.5rem 0 0.5rem; font-size: 1.25rem; }
p.muted, .muted { color: var(--muted); }
p.subtitle { font-size: 1.1rem; color: #374151; margin: 0 0 1rem; }
p.breadcrumb { margin: 0 0 0.75rem; color: var(--muted); font-size: 0.9rem; }
.label { display: block; color: var(--muted); font-size: 0.85rem; }

/* -------- Buttons / CTA -------- */
.btn {
  display: inline-block;
  padding: 0.55rem 1.1rem;
  border-radius: 6px;
  background: #f3f4f6;
  color: #111827;
  border: 1px solid var(--border);
  font-weight: 500;
}
.btn:hover { text-decoration: none; background: #e5e7eb; }
.btn-primary {
  background: var(--brand);
  color: white;
  border-color: var(--brand);
}
.btn-primary:hover { background: var(--brand-dark); color: white; }
.cta-row { display: flex; gap: 0.75rem; margin: 1rem 0; }

/* -------- Hero / landing -------- */
.hero {
  padding: 2.5rem 0 2rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}
.hero h1 { font-size: 2.2rem; }
.pitch { max-width: 700px; }

/* -------- Tables -------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
th, td {
  text-align: left;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 0.9rem;
  color: #374151;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.recipe-list tr:hover td { background: #f9fafb; }

/* -------- Tags -------- */
.tag {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  background: var(--tag-bg);
  color: var(--tag-fg);
  margin-right: 0.25rem;
}
.tag-allergen { background: var(--allergen-bg); color: var(--allergen-fg); }

/* -------- Meta grid (recipe detail) -------- */
.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
  padding: 1rem;
  background: #f9fafb;
  border-radius: 8px;
}

/* -------- Nutrition list -------- */
.nutrition-list {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.5rem;
}
.nutrition-list li {
  display: flex;
  justify-content: space-between;
  padding: 0.4rem 0.7rem;
  background: #f9fafb;
  border-radius: 6px;
}

/* -------- Scale form (ingredients page) -------- */
.scale-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
.scale-form input[type="number"] {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 100px;
  font-size: 1rem;
}

/* -------- Status tokens (used in later slices) -------- */
.status-badge {
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  color: white;
  text-transform: capitalize;
}
.status-pending { background: var(--status-pending); }
.status-confirmed { background: var(--status-confirmed); }
.status-in_preparation { background: var(--status-in_preparation); }
.status-out_for_delivery { background: var(--status-out_for_delivery); }
.status-delivered { background: var(--status-delivered); }
.status-cancelled { background: var(--status-cancelled); }

/* -------- Dashboard (Slice C) -------- */
.status-tiles {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0;
}
.status-tiles .tile {
  background: #f9fafb;
  padding: 1rem;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: flex-start;
}
.status-tiles .tile-count {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--fg);
}
.next-delivery {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  background: #eff6ff;
  border-left: 4px solid var(--status-confirmed);
  border-radius: 4px;
}

/* -------- Orders table -------- */
.orders-table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
}
.orders-table th, .orders-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.orders-table th {
  background: #f9fafb;
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  color: var(--muted);
}
.orders-table tbody tr:hover { background: #f9fafb; }

.order-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 1rem 0;
}
.order-filter select {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.95rem;
}

.pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 1rem 0;
  color: var(--muted);
}

/* -------- Order detail -------- */
.crumbs { margin-bottom: 0.5rem; }
.order-meta dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0.5rem 0 1.5rem;
}
.order-meta dt { font-weight: 600; color: var(--muted); }

.order-lines-table {
  width: 100%;
  border-collapse: collapse;
  margin: 0.5rem 0;
}
.order-lines-table th, .order-lines-table td {
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.pricing-source {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: capitalize;
}

/* -------- Progress bar -------- */
.progress-bar {
  position: relative;
  height: 28px;
  background: #e5e7eb;
  border-radius: 999px;
  margin: 1rem 0;
  overflow: hidden;
}
.progress-fill {
  position: absolute;
  top: 0; left: 0; bottom: 0;
  background: linear-gradient(90deg, var(--status-pending), var(--status-delivered));
  transition: width 0.3s ease;
}
.progress-steps {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  list-style: none;
  margin: 0; padding: 0;
  height: 100%;
  align-items: center;
}
.progress-steps .step {
  text-align: center;
  font-size: 0.7rem;
  color: var(--fg);
  padding: 0 0.25rem;
  text-transform: capitalize;
  z-index: 1;
}
.progress-steps .step-done {
  font-weight: 700;
  color: white;
  text-shadow: 0 0 2px rgba(0,0,0,0.3);
}
.progress-cancelled { color: var(--status-cancelled); font-style: italic; }

/* -------- Timeline -------- */
.order-timeline {
  list-style: none;
  padding-left: 1rem;
  border-left: 3px solid var(--border);
  margin: 1rem 0;
}
.order-timeline .event {
  position: relative;
  padding: 0.5rem 0 0.5rem 1rem;
}
.order-timeline .event::before {
  content: "";
  position: absolute;
  left: -0.6rem;
  top: 0.9rem;
  width: 0.75rem; height: 0.75rem;
  border-radius: 50%;
  background: var(--brand);
}
.order-timeline .event time {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
}
.order-timeline .event strong { display: block; margin: 0.2rem 0; }
.order-timeline .event-note {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: #374151;
}

/* -------- Calendar (Slice C) -------- */
.month-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0.5rem 0 1rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 6px;
}
.month-label { font-weight: 700; font-size: 1.1rem; }

.calendar { width: 100%; border-collapse: collapse; table-layout: fixed; }
.calendar th, .calendar td {
  border: 1px solid var(--border);
  padding: 0.5rem;
  vertical-align: top;
  height: 90px;
}
.calendar th {
  background: #f9fafb;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--muted);
  height: auto;
}
.calendar td.today { background: #fff7e6; }
.calendar td.out-of-month { background: #fafafa; }
.calendar .day-label { font-weight: 600; margin-bottom: 0.25rem; }
.calendar .day-orders {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.75rem;
}
.calendar .day-orders li { margin-bottom: 0.15rem; }
.calendar .dot-link { display: inline-flex; align-items: center; gap: 0.2rem; }
.calendar .dot {
  display: inline-block;
  width: 0.7rem; height: 0.7rem;
  border-radius: 50%;
}
.calendar .dot.status-pending { background: var(--status-pending); }
.calendar .dot.status-confirmed { background: var(--status-confirmed); }
.calendar .dot.status-in_preparation { background: var(--status-in_preparation); }
.calendar .dot.status-out_for_delivery { background: var(--status-out_for_delivery); }
.calendar .dot.status-delivered { background: var(--status-delivered); }
.calendar .dot.status-cancelled { background: var(--status-cancelled); }

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.calendar-legend .dot {
  display: inline-block;
  width: 0.65rem; height: 0.65rem;
  border-radius: 50%;
  margin-right: 0.2rem;
}
.calendar-legend .dot.status-pending { background: var(--status-pending); }
.calendar-legend .dot.status-confirmed { background: var(--status-confirmed); }
.calendar-legend .dot.status-in_preparation { background: var(--status-in_preparation); }
.calendar-legend .dot.status-out_for_delivery { background: var(--status-out_for_delivery); }
.calendar-legend .dot.status-delivered { background: var(--status-delivered); }
.calendar-legend .dot.status-cancelled { background: var(--status-cancelled); }

/* -------- NL ordering (Slice D) -------- */
.nl-order-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
  max-width: 640px;
}
.nl-order-form textarea {
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
  min-height: 100px;
}
.nl-order-form button {
  align-self: flex-start;
  background: var(--brand);
  color: white;
  border: 0;
  padding: 0.6rem 1.25rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
}
.nl-order-form button:hover { background: var(--brand-dark); }

.proposal-card {
  max-width: 640px;
  padding: 1.25rem;
  background: #f0fdf4;
  border: 2px solid var(--brand);
  border-radius: 10px;
  margin: 1rem 0;
}
.proposal-summary {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0.75rem 0 1rem;
}
.proposal-summary dt { font-weight: 600; color: var(--muted); }
.confirm-form {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.5rem;
}
.confirm-btn {
  background: var(--status-delivered);
  color: white;
  border: 0;
  padding: 0.6rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
}
.cancel-link { color: var(--muted); font-size: 0.9rem; }

.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  margin: 1rem 0;
  max-width: 640px;
}
.alert-error { background: #fee2e2; border-left: 4px solid #dc2626; color: #7f1d1d; }
.alert-warning { background: #fef3c7; border-left: 4px solid var(--status-pending); color: #78350f; }
.disambiguation-options { margin: 0.5rem 0; padding-left: 1.25rem; }

/* -------- USDA macros (T-010/T-011) -------- */
.usda-macros {
  margin: 1rem 0;
}
.usda-estimate {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 1rem 0;
}
.macros-unavailable {
  color: #c0392b;
  background: #fadbd8;
  padding: 0.75rem 1rem;
  border-radius: 4px;
  font-style: italic;
}
tr.total-macros {
  font-weight: 600;
  background: #f8f9fa;
}

/* Phase 2 Graduation: CSS framework swap (Tailwind / design tokens) or component library. */
