/* Price-It-Right — mobile-first, premium small-business styling. */
:root {
  --bg: #faf7f1;
  --card: #ffffff;
  --ink: #2c231a;
  --ink-soft: #6f5f4e;
  --ink-faint: #a08e78;
  --line: #e9e0d2;
  --accent: #2e7d4f;
  --accent-dark: #256a42;
  --accent-tint: #e7f3ea;
  --warn: #9a6a14;
  --warn-tint: #fdf3df;
  --warn-line: #ecd9a8;
  --bad: #b23a2e;
  --bad-tint: #fbeae8;
  --bad-line: #f0c4bf;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(60, 42, 20, 0.06), 0 4px 14px rgba(60, 42, 20, 0.06);
  --nav-h: 68px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
}
.app { max-width: 640px; margin: 0 auto; }

/* ---------- header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(250, 247, 241, 0.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-weight: 800; font-size: 18px; letter-spacing: -0.02em; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-soft); letter-spacing: 0.04em; text-transform: uppercase; }
.iconbtn {
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  width: 42px; height: 42px; border-radius: 12px; font-size: 19px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.backbtn {
  border: none; background: none; color: var(--ink); font-size: 16px; font-weight: 600;
  cursor: pointer; padding: 10px 4px; display: inline-flex; align-items: center; gap: 4px;
}

/* ---------- layout ---------- */
.view { padding: 16px 16px 24px; }
h1 { font-size: 26px; letter-spacing: -0.02em; margin: 4px 0 4px; }
h2 { font-size: 19px; margin: 22px 0 10px; letter-spacing: -0.01em; }
.sub { color: var(--ink-soft); margin: 0 0 16px; font-size: 14.5px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 12px;
}
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--ink-soft); }
.small { font-size: 13.5px; }
.faint { color: var(--ink-faint); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field .hint { font-size: 12.5px; color: var(--ink-faint); margin-top: 5px; font-weight: 400; }
input, select, textarea {
  width: 100%; font-size: 16px; padding: 13px 14px; min-height: 50px;
  border: 1.5px solid var(--line); border-radius: 12px; background: #fff; color: var(--ink);
  font-family: inherit; appearance: none; -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236f5f4e' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 52px; padding: 14px 20px; border-radius: 14px; font-size: 16px; font-weight: 700;
  border: none; cursor: pointer; width: 100%; font-family: inherit;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:active { background: var(--accent-dark); }
.btn-ghost { background: var(--card); color: var(--ink); border: 1.5px solid var(--line); }
.btn-danger-ghost { background: none; color: var(--bad); border: 1.5px solid var(--bad-line); }
.btn-sm { min-height: 42px; padding: 8px 14px; font-size: 14px; width: auto; border-radius: 10px; }
.btnrow { display: flex; gap: 10px; margin-top: 14px; }
.btnrow .btn { flex: 1; }

/* ---------- ingredient / list rows ---------- */
.item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
  cursor: pointer; text-align: left; font-family: inherit; color: var(--ink); font-size: 16px;
}
.item:active { transform: scale(0.99); }
.item .grow { flex: 1; min-width: 0; }
.item .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .s { font-size: 13px; color: var(--ink-soft); }
.chev { color: var(--ink-faint); font-size: 20px; }
.pill {
  font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.pill-ok { background: var(--accent-tint); color: var(--accent-dark); }
.pill-warn { background: var(--warn-tint); color: var(--warn); }
.pill-bad { background: var(--bad-tint); color: var(--bad); }
.pill-mute { background: #f1ece2; color: var(--ink-soft); }

/* ---------- results ---------- */
.hero {
  background: linear-gradient(135deg, #2e7d4f, #3d9a63);
  color: #fff; border-radius: 20px; padding: 22px 20px; margin: 4px 0 12px;
  box-shadow: var(--shadow); text-align: center;
}
.hero .k { font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.08em; opacity: 0.85; font-weight: 700; }
.hero .v { font-size: 46px; font-weight: 800; letter-spacing: -0.03em; margin: 2px 0; }
.hero .s { font-size: 13.5px; opacity: 0.9; }
.hero.blocked { background: linear-gradient(135deg, #b23a2e, #cf5a4c); }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px dashed var(--line); font-size: 15px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--ink-soft); }
.kv .v { font-weight: 700; font-variant-numeric: tabular-nums; }
.banner {
  border-radius: 14px; padding: 14px 16px; margin-bottom: 12px; font-size: 14.5px;
  border: 1px solid; line-height: 1.55;
}
.banner.warn { background: var(--warn-tint); border-color: var(--warn-line); color: #6d4d10; }
.banner.bad { background: var(--bad-tint); border-color: var(--bad-line); color: #8c2b22; }
.banner.ok { background: var(--accent-tint); border-color: #bfe0c9; color: #1f5c36; }
.banner strong { display: block; margin-bottom: 2px; }

/* ---------- recipe ingredient rows ---------- */
.ingrow { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.ingrow .top { display: grid; grid-template-columns: 1fr 88px; gap: 8px; margin-bottom: 8px; }
.ingrow .bot { display: grid; grid-template-columns: 1fr 44px; gap: 8px; align-items: end; }
.ingrow input, .ingrow select { min-height: 46px; padding: 10px 12px; }
.ingrow .warnline { margin-top: 8px; }
.delbtn {
  border: 1.5px solid var(--bad-line); background: var(--bad-tint); color: var(--bad);
  border-radius: 10px; min-height: 46px; font-size: 18px; cursor: pointer;
}
.costline { font-size: 13px; color: var(--ink-soft); text-align: right; margin-top: 6px; font-variant-numeric: tabular-nums; }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 10px; text-align: center; box-shadow: var(--shadow); }
.stat .n { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; }
.stat .l { font-size: 11.5px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

/* ---------- bottom nav ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar .inner { max-width: 640px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr); }
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 10px 4px 8px; color: var(--ink-faint); text-decoration: none;
  font-size: 11px; font-weight: 600; min-height: var(--nav-h);
}
.tab svg { width: 23px; height: 23px; }
.tab.active { color: var(--accent-dark); }

.empty { text-align: center; padding: 40px 20px; color: var(--ink-soft); }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom)); z-index: 25;
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--accent); color: #fff; font-size: 30px; line-height: 1;
  box-shadow: 0 6px 20px rgba(46, 125, 79, 0.4);
}
.fab:active { transform: scale(0.94); }

.divider { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom));
  background: var(--ink); color: #fff; padding: 13px 16px; border-radius: 12px; font-size: 14.5px;
  z-index: 50; text-align: center; box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}
.storewarn {
  position: sticky; top: 0; z-index: 60;
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff8e1; color: #6d4c00; border-bottom: 1px solid #f0dfae;
  padding: 10px 12px; padding-top: calc(10px + env(safe-area-inset-top));
  font-size: 13.5px; line-height: 1.45;
}
.storewarn button {
  flex: none; border: none; background: none; color: #6d4c00;
  font-size: 16px; padding: 2px 6px; cursor: pointer;
}
@media (min-width: 700px) {
  body { padding-bottom: calc(var(--nav-h) + 24px); }
  .view { padding-top: 24px; }
}
