/* ── Design Tokens ─────────────────────────────────────────── */
:root {
  --green-primary:  #4a7c59;
  --green-dark:     #355c42;
  --green-light:    #edf5f0;
  --green-border:   #cfdece;
  --amber:          #d4892a;
  --amber-light:    #fdf3e3;
  --bg:             #f5f3ee;
  --white:          #ffffff;
  --text:           #1c2b1c;
  --muted:          #6b7b6b;
  --border:         #dde8dd;
  --radius-sm:      6px;
  --radius:         10px;
  --radius-lg:      16px;
  --shadow-sm:      0 1px 4px rgba(28, 43, 28, 0.07);
  --shadow:         0 2px 10px rgba(28, 43, 28, 0.09);
  --shadow-md:      0 4px 20px rgba(28, 43, 28, 0.12);
  --transition:     0.15s ease;
}

/* ── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background-color: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

h1 { font-size: 1.7rem;  margin-bottom: 1.25rem; }
h2 { font-size: 1.35rem; margin-bottom: 1rem; }
h3 { font-size: 1.1rem;  margin-bottom: 0.75rem; }
h4 { font-size: 0.95rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

a {
  color: var(--green-primary);
  text-decoration: none;
  transition: color var(--transition);
}
a:hover { color: var(--green-dark); }

ul { padding-left: 1.25rem; }
li { margin-bottom: 0.25rem; }

/* ── Navigation ────────────────────────────────────────────── */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--white);
  border-bottom: 1px solid var(--green-border);
  padding: 0 1.75rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 56px;
  box-shadow: var(--shadow-sm);
}

.app-nav .brand {
  font-size: 1rem;
  font-weight: 700;
  color: var(--green-primary);
  letter-spacing: -0.02em;
  white-space: nowrap;
  flex-shrink: 0;
}
.app-nav .brand:hover { color: var(--green-dark); }

.nav-links {
  display: flex;
  gap: 0.125rem;
  margin: 0;
  padding: 0;
  list-style: none;
  flex-wrap: wrap;
}

.nav-links a {
  display: block;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  transition: background var(--transition), color var(--transition);
}
.nav-links a:hover,
.nav-links a.active {
  background: var(--green-light);
  color: var(--green-primary);
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.75rem;
}

/* ── Cards ─────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow); }

.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}
.card-subtitle {
  font-size: 0.8rem;
  color: var(--muted);
}

/* Dashboard action cards */
.action-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 1.75rem 1.5rem;
  display: block;
  color: var(--text);
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
}
.action-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--green-primary);
  color: var(--text);
  transform: translateY(-2px);
}
.action-card .icon {
  font-size: 1.75rem;
  margin-bottom: 0.75rem;
  display: block;
}
.action-card .label {
  font-weight: 600;
  font-size: 1rem;
  display: block;
}
.action-card .desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 0.25rem;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  transition: all var(--transition);
  cursor: pointer;
}

.btn-primary {
  background-color: var(--green-primary);
  border-color: var(--green-primary);
  color: var(--white);
}
.btn-primary:hover,
.btn-primary:focus {
  background-color: var(--green-dark);
  border-color: var(--green-dark);
  color: var(--white);
}

.btn-outline-primary {
  color: var(--green-primary);
  border-color: var(--green-primary);
  background: transparent;
}
.btn-outline-primary:hover {
  background-color: var(--green-primary);
  border-color: var(--green-primary);
  color: var(--white);
}

.btn-secondary {
  background-color: var(--white);
  border-color: var(--border);
  color: var(--muted);
}
.btn-secondary:hover {
  background-color: var(--green-light);
  border-color: var(--green-primary);
  color: var(--green-primary);
}

.btn-danger {
  background-color: #c0392b;
  border-color: #c0392b;
  color: var(--white);
}
.btn-danger:hover {
  background-color: #a93226;
  border-color: #a93226;
  color: var(--white);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.3rem 0.7rem;
}

/* Naked input[type=submit] — wrap in .btn classes via templates, but fallback: */
input[type="submit"] {
  font-family: 'Inter', system-ui, sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  border-radius: var(--radius-sm);
  padding: 0.45rem 1rem;
  background-color: var(--green-primary);
  border: 1px solid var(--green-primary);
  color: var(--white);
  cursor: pointer;
  transition: all var(--transition);
}
input[type="submit"]:hover {
  background-color: var(--green-dark);
  border-color: var(--green-dark);
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-label,
label {
  font-weight: 500;
  font-size: 0.875rem;
  color: var(--muted);
  margin-bottom: 0.3rem;
  display: block;
}

.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
select,
textarea {
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.75rem;
  background: var(--white);
  color: var(--text);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus,
input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--green-primary);
  box-shadow: 0 0 0 3px rgba(74, 124, 89, 0.15);
}

.form-section {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1.25rem;
}

/* ── Tables ────────────────────────────────────────────────── */
.table {
  font-size: 0.9rem;
}
.table th {
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  border-bottom: 2px solid var(--border);
  padding: 0.6rem 0.75rem;
}
.table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table-hover tbody tr:hover {
  background-color: var(--green-light);
}

/* ── Meal Plan Grid ────────────────────────────────────────── */
.meal-plan-grid {
  font-size: 0.85rem;
  background: var(--white);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.meal-plan-grid .grid-header {
  background: var(--green-light);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--green-dark);
  padding: 0.6rem 0.5rem;
  border-bottom: 1px solid var(--green-border);
  text-align: center;
}

.meal-plan-grid .grid-label {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding: 0.75rem 0.5rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.meal-plan-grid .grid-cell {
  padding: 0.5rem;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  text-align: center;
  font-size: 0.82rem;
  min-height: 52px;
  vertical-align: top;
}

.meal-plan-grid .grid-cell a.meal-name {
  font-weight: 500;
  color: var(--text);
  display: block;
  line-height: 1.3;
}
.meal-plan-grid .grid-cell a.meal-name:hover {
  color: var(--green-primary);
}

.meal-plan-grid .grid-cell a.add-link,
.meal-plan-grid .grid-cell a.empty-link {
  color: var(--muted);
  font-size: 0.78rem;
}
.meal-plan-grid .grid-cell a.add-link:hover,
.meal-plan-grid .grid-cell a.empty-link:hover {
  color: var(--green-primary);
}

/* ── Grocery List ──────────────────────────────────────────── */
.grocery-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--green-dark);
  background: var(--green-light);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  margin-top: 1rem;
}

.grocery-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.grocery-item:last-child { border-bottom: none; }

.grocery-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.grocery-item.checked label {
  text-decoration: line-through;
  color: var(--muted);
}

/* ── Page Header ───────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.page-header h1 { margin-bottom: 0; }

/* ── Sort / Filter Pills ───────────────────────────────────── */
.sort-pills {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.sort-pill {
  display: inline-block;
  padding: 0.3rem 0.85rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 500;
  background: var(--white);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}
.sort-pill:hover,
.sort-pill.active {
  background: var(--green-light);
  border-color: var(--green-primary);
  color: var(--green-primary);
}

/* ── Misc ──────────────────────────────────────────────────── */
.badge-tag {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  background: var(--green-light);
  color: var(--green-dark);
  border: 1px solid var(--green-border);
}

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

.text-muted { color: var(--muted) !important; }

/* ── Print ─────────────────────────────────────────────────── */
@media print {
  @page { size: landscape; }
  .app-nav { display: none; }
  .main-content { max-width: 100%; padding: 0; }
  .col-md-4 { float: left; width: 33.33333%; }
  .mpcol { width: 45%; font-size: 10pt; }
  .btn, .sort-pills, form { display: none; }
}

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-nav {
    height: auto;
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }
  .main-content { padding: 1.25rem 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .meal-plan-grid { overflow-x: auto; }
}
