:root {
  color-scheme: light;
  --background: #f4f7f2;
  --surface: #ffffff;
  --primary: #205c42;
  --primary-dark: #174531;
  --text: #17231d;
  --muted: #607069;
  --border: #d8e2dc;
  --shadow: 0 8px 24px rgba(23, 69, 49, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  padding-bottom: 5.5rem;
  background: var(--background);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

.container {
  width: min(100% - 2rem, 68rem);
  margin-inline: auto;
}

.app-header {
  padding: 2rem 0;
  background: var(--primary);
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 0.4rem;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.5rem;
  font-size: clamp(2rem, 10vw, 3.5rem);
  line-height: 1.05;
}

.header-description {
  max-width: 32rem;
  margin-bottom: 0;
  color: #dcebe3;
}

.app-content {
  padding-block: 0.25rem;
}

.app-screen {
  display: none;
}

.app-screen.is-active {
  display: block;
}

.content-section {
  margin-block: 1.5rem;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  background: var(--surface);
}

.content-section h2 {
  margin-bottom: 0.4rem;
  font-size: 1.25rem;
}

.content-section p {
  margin-bottom: 0;
  color: var(--muted);
}

.content-section .section-description {
  margin-bottom: 1.25rem;
}

.product-form label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.form-controls {
  display: grid;
  gap: 0.65rem;
}

input,
select,
button {
  min-height: 2.8rem;
  border-radius: 0.65rem;
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid var(--border);
  padding: 0.7rem 0.85rem;
  color: var(--text);
}

input:focus,
select:focus {
  border-color: var(--primary);
  outline: 2px solid rgba(32, 92, 66, 0.18);
}

button {
  border: 0;
  padding: 0.65rem 1rem;
  cursor: pointer;
  font-weight: 700;
}

button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
}

.primary-button:hover {
  background: var(--primary-dark);
}

.form-message {
  min-height: 1.5rem;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.form-message.is-success {
  color: var(--primary);
}

.form-message.is-error {
  color: #a12727;
}

.empty-message {
  padding-block: 0.75rem;
}

.product-list {
  display: grid;
  gap: 0.65rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
}

.product-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 0.4rem;
}

.edit-button {
  border: 1px solid var(--primary);
  background: #ffffff;
  color: var(--primary-dark);
}

.edit-button:hover {
  background: var(--background);
}

.delete-button {
  flex: 0 0 auto;
  border: 1px solid #e4bcbc;
  background: #fff5f5;
  color: #8c2020;
}

.delete-button:hover {
  background: #fce2e2;
}

.shopping-title-field,
.add-item-form {
  margin-bottom: 1rem;
}

.shopping-title-field label,
.add-item-form label,
.item-field label {
  display: block;
  margin-bottom: 0.4rem;
  font-size: 0.9rem;
  font-weight: 700;
}

.shopping-items {
  display: grid;
  gap: 0.8rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.shopping-item {
  display: grid;
  gap: 0.8rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  background: #fbfcfb;
}

.shopping-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.checked-field {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
}

.checked-field input {
  width: 1.25rem;
  min-height: 1.25rem;
  accent-color: var(--primary);
}

.shopping-item.is-checked .item-name {
  color: var(--muted);
  text-decoration: line-through;
}

.item-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.7rem;
}

.note-field {
  grid-column: 1 / -1;
}

.item-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 0.7rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
}

.item-total strong {
  color: var(--text);
}

.shopping-total {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 1rem;
  border-radius: 0.75rem;
  background: var(--primary-dark);
  color: #ffffff;
  font-size: 1.05rem;
}

.shopping-total strong {
  font-size: 1.35rem;
}

.complete-button {
  display: block;
  width: 100%;
  margin-top: 0.8rem;
  background: #d8a421;
  color: #2e2409;
}

.complete-button:hover {
  background: #c59619;
}

.purchase-history,
.purchase-detail-items {
  display: grid;
  gap: 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.purchase-history-item {
  display: grid;
  gap: 0.75rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
}

.purchase-summary {
  display: grid;
  gap: 0.2rem;
}

.purchase-summary time {
  color: var(--muted);
  font-size: 0.9rem;
}

.purchase-summary-total {
  color: var(--primary-dark);
  font-weight: 700;
}

.secondary-button {
  border: 1px solid var(--primary);
  background: #ffffff;
  color: var(--primary-dark);
}

.secondary-button:hover {
  background: var(--background);
}

.purchase-detail {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.purchase-detail-header {
  margin-bottom: 1rem;
}

.purchase-detail-header time {
  color: var(--muted);
}

.purchase-detail-item {
  display: grid;
  gap: 0.55rem;
  padding: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.7rem;
  background: #fbfcfb;
}

.detail-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.item-status {
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  background: #f3ead3;
  color: #755913;
  font-size: 0.75rem;
  font-weight: 700;
}

.item-status.is-checked {
  background: #dcebe3;
  color: var(--primary-dark);
}

.detail-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
}

.detail-value {
  display: grid;
  gap: 0.1rem;
}

.detail-value span {
  color: var(--muted);
  font-size: 0.72rem;
}

.detail-value strong {
  overflow-wrap: anywhere;
  font-size: 0.85rem;
}

.purchase-detail-total {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  padding: 0.85rem;
  border-radius: 0.7rem;
  background: var(--primary-dark);
  color: #ffffff;
}

.detail-note {
  margin: 0;
  padding: 0.55rem;
  border-radius: 0.5rem;
  background: var(--background);
  color: var(--text);
  font-size: 0.9rem;
}

.detail-note strong {
  display: block;
  margin-bottom: 0.15rem;
  color: var(--muted);
  font-size: 0.75rem;
}

.modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(12, 28, 20, 0.62);
}

.modal[hidden] {
  display: none;
}

.modal-panel {
  width: min(100%, 28rem);
  padding: 1.25rem;
  border-radius: 0.9rem;
  background: var(--surface);
  box-shadow: 0 18px 50px rgba(12, 28, 20, 0.28);
}

.modal-panel h2 {
  margin-bottom: 1rem;
}

.modal-panel label {
  display: block;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.modal-message {
  margin-bottom: 0.75rem;
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

body.has-open-modal {
  overflow: hidden;
}

.bottom-navigation {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
  padding: 0.55rem max(0.65rem, env(safe-area-inset-right)) max(0.55rem, env(safe-area-inset-bottom)) max(0.65rem, env(safe-area-inset-left));
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -6px 20px rgba(23, 69, 49, 0.1);
}

.screen-navigation-button {
  min-width: 0;
  padding: 0.55rem 0.25rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.78rem;
}

.screen-navigation-button.is-active {
  background: var(--primary);
  color: #ffffff;
}

@media (min-width: 48rem) {
  .app-header {
    padding-block: 2.5rem;
  }

  .form-controls {
    grid-template-columns: 1fr auto;
  }

  .shopping-item {
    grid-template-columns: minmax(12rem, 1fr) minmax(16rem, 1fr) auto;
    align-items: end;
  }

  .shopping-item-header {
    align-self: center;
  }

  .item-total {
    min-width: 9rem;
    border-top: 0;
  }

  .complete-button {
    width: auto;
    margin-left: auto;
  }

  .purchase-history-item {
    grid-template-columns: 1fr auto;
    align-items: center;
  }

  .bottom-navigation {
    right: 50%;
    left: 50%;
    width: min(32rem, calc(100% - 2rem));
    border: 1px solid var(--border);
    border-bottom: 0;
    border-radius: 0.9rem 0.9rem 0 0;
    transform: translateX(-50%);
  }
}
