:root {
  color-scheme: light;
  --ink: #17201a;
  --muted: #617064;
  --line: #d9e1d6;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --green: #1e7a3b;
  --green-dark: #12542b;
  --mint: #e9f6ec;
  --lemon: #fff3b0;
  --tomato: #d84f3a;
  --blue: #276f8f;
  --shadow: 0 20px 55px rgba(23, 32, 26, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(255, 243, 176, 0.55), transparent 34rem),
    linear-gradient(135deg, #f7fbf0 0%, #eef7f2 52%, #fdf8ed 100%);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] {
  display: none !important;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.auth-panel {
  width: min(430px, 100%);
  display: grid;
  gap: 15px;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 0 0 4px;
  font-size: 2rem;
}

.auth-panel .eyebrow {
  color: var(--green);
}

.setup-fields {
  display: grid;
  grid-template-columns: 0.72fr 1fr;
  gap: 10px;
}

.form-message {
  min-height: 20px;
  margin: 0;
  color: #8a321f;
  font-weight: 800;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 42px;
}

.hero {
  min-height: 245px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
  padding: 38px;
  border-radius: 8px;
  color: white;
  background:
    linear-gradient(90deg, rgba(18, 84, 43, 0.94), rgba(18, 84, 43, 0.58)),
    url("https://images.unsplash.com/photo-1542838132-92c53300491e?auto=format&fit=crop&w=1800&q=80") center/cover;
  box-shadow: var(--shadow);
}

.hero h1 {
  width: min(840px, 100%);
  margin: 8px 0 0;
  font-size: clamp(2rem, 4vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0;
  color: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: var(--lemon);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
  min-width: min(520px, 100%);
}

.location-form {
  display: grid;
  grid-template-columns: 86px minmax(96px, 1fr) auto;
  gap: 8px;
  width: min(100%, 420px);
  padding: 0;
}

.location-form input {
  min-width: 0;
  min-height: 42px;
  padding: 0 11px;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 8px;
  color: white;
  background: rgba(255, 255, 255, 0.14);
}

.location-form input::placeholder {
  color: rgba(255, 255, 255, 0.76);
}

.ghost-button,
.primary-button,
.tab-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-weight: 800;
}

.ghost-button {
  padding: 0 15px;
  color: white;
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.34);
}

.primary-button {
  width: 100%;
  padding: 0 18px;
  color: white;
  background: var(--green);
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin: 16px 0;
}

.summary-strip article {
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
}

.summary-strip span {
  display: block;
  font-size: 1.7rem;
  font-weight: 800;
}

.summary-strip p {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 700;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(330px, 0.78fr) minmax(620px, 1.22fr);
  gap: 16px;
  align-items: start;
}

.bottom-workspace {
  grid-template-columns: 1fr 0.82fr;
  margin-top: 16px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 35px rgba(23, 32, 26, 0.07);
}

.panel-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 4px 0 0;
  font-size: 1.2rem;
}

.panel-header .eyebrow {
  color: var(--green);
}

.search-box {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.search-box input,
form input,
form textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  outline: none;
}

.search-box input {
  min-height: 38px;
  padding: 0 12px;
}

.quick-add {
  display: grid;
  grid-template-columns: 1fr minmax(110px, 0.46fr) auto;
  gap: 8px;
  padding: 14px 16px 0;
}

.quick-add input {
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.small-button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: var(--green);
  color: white;
  font-weight: 800;
}

.grocery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  padding: 16px;
  max-height: 642px;
  overflow: auto;
}

.grocery-card {
  display: grid;
  gap: 9px;
  align-items: stretch;
  min-height: 58px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.grocery-card.selected,
.grocery-card:has(input:checked) {
  border-color: rgba(30, 122, 59, 0.45);
  background: var(--mint);
}

.grocery-select {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
}

.grocery-card input {
  width: 19px;
  height: 19px;
  accent-color: var(--green);
}

.card-actions {
  display: flex;
  gap: 6px;
}

.mini-button {
  min-height: 28px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-dark);
  background: white;
  font-size: 0.72rem;
  font-weight: 800;
}

.mini-button.danger {
  color: #8a321f;
}

.item-name {
  min-width: 0;
  overflow-wrap: anywhere;
  font-weight: 800;
}

.item-meta {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.notice {
  margin: 16px 20px 0;
  padding: 12px 14px;
  border-left: 4px solid var(--blue);
  border-radius: 8px;
  background: #eef8fb;
  color: #25586b;
  font-size: 0.88rem;
  font-weight: 700;
}

.view-tabs {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.tab-button {
  min-height: 34px;
  padding: 0 12px;
  color: var(--muted);
  background: transparent;
}

.tab-button.active {
  color: white;
  background: var(--green);
}

.table-wrap {
  margin: 16px 20px 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
  background: white;
}

th,
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f2f7ef;
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

td {
  font-size: 0.9rem;
  font-weight: 700;
}

tr:last-child td {
  border-bottom: 0;
}

.price-input {
  width: 82px;
  min-height: 36px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.source-badge,
.verify-button {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-top: 7px;
  padding: 0 7px;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 800;
}

.source-badge {
  border: 1px solid var(--line);
  color: var(--muted);
  background: #f6f8f4;
}

.source-badge.manual,
.source-badge.verified,
.source-badge.fresh {
  border-color: rgba(30, 122, 59, 0.34);
  color: var(--green-dark);
  background: var(--mint);
}

.source-badge.automated,
.source-badge.stale {
  border-color: rgba(216, 79, 58, 0.3);
  color: #8a321f;
  background: #fff1ed;
}

.source-badge.missing {
  color: #6c5f11;
  background: #fff8cf;
}

.source-link {
  display: inline-flex;
  margin: 7px 0 0 5px;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 800;
}

.verify-button {
  margin-left: 5px;
  border: 1px solid var(--green);
  color: var(--green-dark);
  background: #ffffff;
}

.best-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 9px;
  border-radius: 999px;
  background: var(--lemon);
  color: #594d00;
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.best-pill.trusted,
.best-pill.fresh,
.best-pill.manual {
  background: var(--mint);
  color: var(--green-dark);
}

.best-pill.untrusted,
.best-pill.stale {
  background: #fff1ed;
  color: #8a321f;
}

.store-links {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 16px 20px 20px;
}

.store-links a {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--green-dark);
  background: var(--paper);
  font-size: 0.82rem;
  font-weight: 800;
  text-decoration: none;
}

.route-plan {
  display: grid;
  gap: 12px;
  padding: 16px 20px 20px;
}

.route-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: white;
}

.route-card h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0;
  padding: 13px 14px;
  background: #f2f7ef;
  font-size: 1rem;
}

.route-card ul {
  margin: 0;
  padding: 10px 14px 14px 28px;
}

.route-card li {
  margin: 5px 0;
  color: var(--muted);
  font-weight: 700;
}

.route-card.warning h3 {
  background: #fff1ed;
  color: #8a321f;
}

form {
  display: grid;
  gap: 13px;
  padding: 16px 20px 0;
}

form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

form input {
  min-height: 42px;
  padding: 0 12px;
}

form textarea {
  resize: vertical;
  padding: 10px 12px;
}

.email-preview {
  margin: 16px 20px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.email-preview h3 {
  margin: 0;
  padding: 12px 14px;
  background: #f2f7ef;
  font-size: 0.96rem;
}

pre {
  min-height: 170px;
  max-height: 360px;
  margin: 0;
  padding: 14px;
  overflow: auto;
  color: var(--muted);
  white-space: pre-wrap;
  word-break: break-word;
  font-family: Inter, system-ui, sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
}

@media (max-width: 1040px) {
  .workspace,
  .bottom-workspace {
    grid-template-columns: 1fr;
  }

  .hero {
    align-items: flex-start;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .location-form {
    grid-template-columns: 86px 1fr;
  }

  .location-form button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 700px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 10px;
  }

  .hero {
    min-height: 330px;
    padding: 24px;
  }

  .summary-strip {
    grid-template-columns: 1fr;
  }

  .panel-header {
    align-items: stretch;
    flex-direction: column;
  }

  .grocery-grid {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .quick-add,
  .setup-fields {
    grid-template-columns: 1fr;
  }
}
