@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Serif+Display:ital@0;1&display=swap');

:root {
  --ink: #182820;
  --ink-soft: #52625a;
  --forest: #16382f;
  --forest-2: #245348;
  --cream: #f6f1e7;
  --paper: #fffdf8;
  --white: #fff;
  --orange: #e97132;
  --orange-dark: #b84f1f;
  --gold: #e9b75c;
  --sage: #dfe9d5;
  --sage-deep: #b9cbaa;
  --line: #ded8cc;
  --line-strong: #c9c0b2;
  --danger: #a74335;
  --success: #2e694f;
  --breakfast: #fff0bc;
  --snack: #e5efd8;
  --lunch: #dcecf0;
  --dinner: #f8ddcf;
  --dessert: #e8def4;
  --shadow: 0 18px 50px rgba(28, 53, 42, .09);
  --shadow-small: 0 8px 24px rgba(28, 53, 42, .07);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 88% 2%, rgba(233, 183, 92, .19), transparent 24rem),
    var(--cream);
  color: var(--ink);
  font-family: 'DM Sans', system-ui, sans-serif;
  min-width: 320px;
}

button, input, select, textarea { font: inherit; }
button, select, input[type='file'] { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(233, 113, 50, .36);
  outline-offset: 2px;
}

.skip-link {
  position: fixed;
  left: 1rem;
  top: -5rem;
  z-index: 100;
  background: var(--white);
  color: var(--forest);
  padding: .8rem 1rem;
  border-radius: 10px;
  font-weight: 700;
}
.skip-link:focus { top: 1rem; }

.app-shell {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 28px 20px;
  background: var(--forest);
  color: var(--white);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: var(--orange);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.16);
  font-size: 23px;
}
.brand p { margin: 0; }
.brand-name { font-family: 'DM Serif Display', serif; font-size: 21px; }
.brand-subtitle { max-width: 160px; margin-top: 3px !important; color: rgba(255,255,255,.64); font-size: 10px; line-height: 1.35; }

.primary-nav { display: grid; gap: 6px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 13px;
  border: 0;
  border-radius: 13px;
  background: transparent;
  color: rgba(255,255,255,.68);
  text-align: left;
  font-weight: 600;
  transition: .18s ease;
}
.nav-item > span:first-child {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(255,255,255,.15);
  border-radius: 8px;
  font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: var(--white); }
.nav-item.active { background: var(--white); color: var(--forest); box-shadow: var(--shadow-small); }
.nav-item.active > span:first-child { background: var(--sage); border-color: var(--sage); }

.sidebar-note {
  margin-top: auto;
  padding: 17px;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 18px;
  background: rgba(255,255,255,.06);
}
.sidebar-note strong { display: block; margin: 7px 0; font-family: 'DM Serif Display', serif; font-size: 18px; line-height: 1.2; }
.sidebar-note p { margin: 0; color: rgba(255,255,255,.59); font-size: 11px; line-height: 1.5; }

.main-content { width: 100%; max-width: 1680px; padding: 34px clamp(22px, 3vw, 54px) 24px; overflow: hidden; }
.topbar { display: flex; justify-content: space-between; gap: 28px; align-items: flex-start; margin-bottom: 28px; }
.topbar h1 {
  max-width: 760px;
  margin: 10px 0 8px;
  color: var(--forest);
  font-family: 'DM Serif Display', serif;
  font-size: clamp(40px, 5vw, 68px);
  font-weight: 400;
  line-height: .95;
  letter-spacing: -.035em;
}
.topbar h1 em { color: var(--orange); font-weight: 400; }
.status-line { display: flex; align-items: center; gap: 8px; color: var(--ink-soft); font-size: 12px; font-weight: 600; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #56a370; box-shadow: 0 0 0 5px rgba(86,163,112,.12); }
.lead { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.6; }
.top-actions, .action-row { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.top-actions { justify-content: flex-end; padding-top: 4px; }

.button, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-weight: 700;
  font-size: 13px;
  transition: .16s ease;
}
.button:hover, .btn:hover { transform: translateY(-1px); }
.button-primary, .primary { background: var(--orange); color: var(--white); box-shadow: 0 7px 18px rgba(233,113,50,.19); }
.button-primary:hover, .primary:hover { background: var(--orange-dark); }
.button-secondary, .button-ghost, .secondary { background: var(--white); color: var(--forest); border-color: var(--line); }
.button-ghost { background: rgba(255,255,255,.52); }
.button-danger { background: #fff5f2; color: var(--danger); border-color: #ecd2cc; }
.button-small { min-height: 34px; padding: 0 11px; font-size: 11px; }
.import-button input { display: none; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 34px;
}
.stat {
  position: relative;
  min-height: 104px;
  padding: 17px;
  border: 1px solid rgba(22,56,47,.1);
  border-radius: 18px;
  background: rgba(255,253,248,.86);
  box-shadow: var(--shadow-small);
  overflow: hidden;
}
.stat::after { content: ''; position: absolute; right: -13px; bottom: -19px; width: 65px; height: 65px; border-radius: 50%; background: var(--sage); opacity: .5; }
.stat small { display: block; color: var(--ink-soft); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.stat strong { display: block; margin-top: 12px; font-family: 'DM Serif Display', serif; font-size: 25px; font-weight: 400; }

.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin: 0 0 16px; }
.section-heading h2 { margin: 3px 0 0; font-family: 'DM Serif Display', serif; font-size: clamp(30px, 3vw, 42px); font-weight: 400; letter-spacing: -.02em; }
.eyebrow { color: var(--orange-dark); font-size: 10px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.context-pill, .pill { display: inline-flex; align-items: center; padding: 7px 11px; border: 1px solid var(--sage-deep); border-radius: 999px; background: var(--sage); color: var(--forest); font-size: 11px; font-weight: 700; }

.panel, .card {
  padding: 22px;
  border: 1px solid rgba(22,56,47,.1);
  border-radius: var(--radius-xl);
  background: rgba(255,253,248,.93);
  box-shadow: var(--shadow);
}
.panel + .panel { margin-top: 18px; }
.panel h3, .panel h4 { margin: 0; }
.panel h3 { font-family: 'DM Serif Display', serif; font-size: 24px; font-weight: 400; }
.panel h4 { font-size: 14px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 15px; }
.helper-text, .small, .muted { color: var(--ink-soft); font-size: 12px; line-height: 1.5; }
.helper-text { margin: 5px 0 0; }
.spark, .category-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--sage); color: var(--forest); font-size: 17px; }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 2.2fr) minmax(280px, .8fr); gap: 18px; }
.week-panel { padding: 13px; }
.ideas-panel { background: var(--forest); color: var(--white); }
.ideas-panel .eyebrow { color: var(--gold); }
.ideas-panel .helper-text, .ideas-panel .muted, .ideas-panel .small { color: rgba(255,255,255,.62); }
.ideas-panel .spark { background: rgba(255,255,255,.1); color: var(--gold); }

.table-scroll { overflow-x: auto; scrollbar-color: var(--sage-deep) transparent; scrollbar-width: thin; }
table { width: 100%; border-collapse: separate; border-spacing: 0 7px; }
th { padding: 0 8px 5px; color: var(--ink-soft); font-size: 9px; font-weight: 800; letter-spacing: .08em; text-align: left; text-transform: uppercase; white-space: nowrap; }
td { padding: 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255,255,255,.72); vertical-align: top; font-size: 12px; }
td:first-child { width: 66px; border-left: 1px solid var(--line); border-radius: 13px 0 0 13px; font-weight: 800; }
td:last-child { border-right: 1px solid var(--line); border-radius: 0 13px 13px 0; }
.planner { min-width: 1120px; }
.readMeal { min-width: 125px; margin-bottom: 5px; padding: 7px 8px; border-radius: 10px; font-weight: 700; line-height: 1.25; }
.readMeal small { display: block; margin-top: 3px; color: rgba(24,40,32,.57); font-size: 9px; font-weight: 500; }

.settings-panel { margin-bottom: 18px; background: var(--forest); color: var(--white); }
.settings-panel label { color: rgba(255,255,255,.6); }
.settings-grid, .form-grid { display: grid; gap: 12px; }
.settings-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 14px; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { min-width: 0; margin-bottom: 12px; }
.field label, label:not(.button):not(.check-label) { display: block; margin: 0 0 6px; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .07em; text-transform: uppercase; }
input, select, textarea {
  width: 100%;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--white);
  color: var(--ink);
}
textarea { min-height: 90px; resize: vertical; cursor: text; }
input::placeholder, textarea::placeholder { color: #9a9d96; }
.planner-panel { padding: 14px; }
.planner-intro { padding: 8px 8px 0; }
.planner-key { display: flex; gap: 6px; flex-wrap: wrap; }
.planner-key span { padding: 5px 7px; border-radius: 999px; font-size: 9px; font-weight: 700; }
.key-breakfast, .b { background: var(--breakfast) !important; }
.key-snack, .s { background: var(--snack) !important; }
.key-lunch, .l { background: var(--lunch) !important; }
.key-dinner, .d { background: var(--dinner) !important; }
.key-dessert, .p { background: var(--dessert) !important; }
.slot { min-width: 175px; }
.slotHead { margin-bottom: 6px; color: var(--ink-soft); font-size: 9px; font-weight: 800; }
.warn { color: #a35716; }
.opt { margin-bottom: 7px; padding: 8px; border: 1px solid rgba(22,56,47,.1); border-radius: 12px; }
.opt select, .opt input { min-height: 34px; padding: 5px 7px; border-radius: 8px; font-size: 10px; }
.mini { display: grid; grid-template-columns: minmax(0, 1fr) 60px; gap: 5px; margin-top: 5px; }
.mini2 { display: grid; grid-template-columns: minmax(0, 1fr) 64px; gap: 5px; margin-top: 5px; }
.addOpt { width: 100%; min-height: 36px; border: 1px dashed var(--line-strong); border-radius: 10px; background: rgba(255,255,255,.66); color: var(--orange-dark); font-size: 10px; font-weight: 800; }
.recommendation-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }

.itemCard, .recipeCard {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255,255,255,.76);
}
.ideas-panel .itemCard { border-color: rgba(255,255,255,.13); background: rgba(255,255,255,.07); }
.recipeTitle { display: flex; align-items: center; gap: 10px; }
.recipeTitle h4 { margin: 0; }
.food { display: grid; flex: 0 0 auto; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--sage); font-size: 21px; }
.itemCard p, .recipeCard p { margin-bottom: 0; }

.price-grid, .price { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; margin-bottom: 14px; }
.priceBox { padding: 15px; border: 1px solid var(--line); border-radius: 16px; background: var(--white); }
.priceBox small { display: block; color: var(--ink-soft); font-size: 10px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.priceBox strong { display: block; margin-top: 7px; font-family: 'DM Serif Display', serif; font-size: 22px; font-weight: 400; }
.info-banner, .info, .success-banner, .success {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 0;
  padding: 12px 14px;
  border: 1px solid #cbdac4;
  border-radius: 14px;
  background: #edf3e8;
  color: #2c503d;
  font-size: 12px;
  line-height: 1.5;
}
.info-banner p { margin: 0; }
.success-banner, .success { border-color: #c4dfcf; background: #eaf6ee; color: var(--success); }
.shopGroup { margin-top: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 17px; background: rgba(255,255,255,.69); }
.shopGroup h4 { margin: 0 0 8px; font-family: 'DM Serif Display', serif; font-size: 19px; font-weight: 400; }
.shopGroup table { min-width: 720px; }
.actualQty { display: inline-block; width: 76px; min-height: 34px; padding: 5px 7px; }
.include, .ingCheck { width: auto; min-height: 0; transform: scale(1.05); }
details { margin-top: 6px; }
details summary { color: var(--orange-dark); cursor: pointer; font-size: 10px; font-weight: 800; }
details ul { margin: 8px 0 0; padding-left: 18px; color: var(--ink-soft); font-size: 10px; line-height: 1.55; }
.bad { color: var(--danger); }
.ok { color: var(--success); }

.recipe-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(330px, .6fr); gap: 18px; }
.recipe-layout .panel + .panel { margin-top: 0; }
.library-tools { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 9px; }
.recipe-library-panel { align-self: start; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
.ingredient-section { margin: 16px 0; padding: 16px; border: 1px solid var(--line); border-radius: 18px; background: #faf8f2; }
.ingredient-controls { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.check-label { display: inline-flex; align-items: center; gap: 6px; color: var(--ink); font-size: 11px; font-weight: 700; }
.count-label { color: var(--ink-soft); font-size: 10px; }
#ingredientRows table { min-width: 690px; }
#ingredientRows input, #ingredientRows select { min-height: 35px; padding: 5px 7px; font-size: 10px; }
.qty { max-width: 80px; }

.inventory-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.inventory-grid .panel + .panel { margin-top: 0; }
.item-stack { margin-top: 16px; }
.ratings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ratings-grid .itemCard { margin: 0; align-items: center; }
.rating-intro { max-width: 780px; margin: 0 0 16px; }

.help-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.help-card { box-shadow: var(--shadow-small); }
.help-card > span { display: block; margin-bottom: 24px; color: var(--orange); font-family: 'DM Serif Display', serif; font-size: 27px; }
.help-card h3 { font-size: 20px; }
.help-card p { margin-bottom: 0; color: var(--ink-soft); font-size: 12px; line-height: 1.6; }
.data-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; }

.site-footer { display: flex; justify-content: space-between; gap: 20px; margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 10px; }
.site-footer p { margin: 0; }
.site-footer a, .public-back { color: var(--forest); font-weight: 800; }
.public-page { min-height: 100vh; padding: 48px 20px; background: radial-gradient(circle at 80% 0%, rgba(169, 191, 169, .28), transparent 32%), var(--cream); }
.public-card { width: min(760px, 100%); margin: 0 auto; padding: clamp(24px, 5vw, 56px); border: 1px solid var(--line); border-radius: 28px; background: rgba(255, 255, 255, .92); box-shadow: var(--shadow); }
.public-card h1 { margin: 16px 0 10px; font-size: clamp(38px, 7vw, 64px); }
.public-card h2 { margin-top: 28px; font-size: 22px; }
.public-card p, .public-card li { color: var(--ink-soft); font-size: 14px; line-height: 1.75; }
.hidden { display: none !important; }

@media (max-width: 1250px) {
  .stats-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dashboard-grid, .recipe-layout { grid-template-columns: 1fr; }
  .recipe-library-panel { position: static; max-height: none; }
  .help-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
  .app-shell { grid-template-columns: minmax(0, 1fr); width: 100%; }
  .sidebar, .main-content { min-width: 0; width: 100%; max-width: 100vw; }
  .sidebar { position: sticky; height: auto; padding: 12px 14px; overflow: hidden; }
  .brand { padding: 0 4px 10px; }
  .brand-mark { width: 38px; height: 38px; border-radius: 13px; }
  .sidebar-note { display: none; }
  .brand-subtitle { display: block; max-width: 245px; font-size: 9px; }
  .primary-nav { display: flex; width: 100%; min-width: 0; max-width: 100%; gap: 5px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
  .primary-nav::-webkit-scrollbar { display: none; }
  .nav-item { flex: 0 0 auto; width: auto; padding: 8px 10px; }
  .nav-item > span:first-child { display: none; }
  .main-content { padding-top: 24px; }
  .topbar { flex-direction: column; }
  .top-actions { justify-content: flex-start; }
  .settings-grid, .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .recommendation-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .main-content { padding-inline: 14px; }
  .topbar h1 { font-size: 42px; }
  .top-actions { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .top-actions .button { width: 100%; }
  .import-button { grid-column: span 2; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { min-height: 92px; }
  .section-heading, .data-panel { align-items: flex-start; flex-direction: column; }
  .settings-grid, .form-grid-3, .inventory-grid, .ratings-grid, .price-grid, .price, .help-grid { grid-template-columns: 1fr; }
  .library-tools { grid-template-columns: 1fr; }
  .panel, .card { padding: 16px; border-radius: 20px; }
  .planner-key { display: none; }
  .site-footer { flex-direction: column; }
}

@media print {
  @page { size: A4 landscape; margin: 8mm; }
  body { background: #fff; }
  .sidebar, .topbar, .stats-grid, .tab:not(#plannerTab), #settings, .no-print, .noPrint, .site-footer { display: none !important; }
  .app-shell { display: block; }
  .main-content { max-width: none; padding: 0; }
  #plannerTab { display: block !important; }
  #plannerTab > .section-heading { display: flex; margin-bottom: 5mm; }
  .panel, .card { padding: 0; border: 0; border-radius: 0; box-shadow: none; }
  .planner-panel { display: block !important; }
  .planner { min-width: 0; font-size: 8px; }
  .opt select, .opt input, .addOpt, .removeBtn { display: none !important; }
  .opt { padding: 4px; margin-bottom: 3px; }
  th { font-size: 7px; }
  td { padding: 4px; font-size: 8px; }
}
