:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #20251f;
  background: #e7ece3;
  font-synthesis: none;
  --green-700: #17653e;
  --green-600: #1f7a49;
  --green-100: #e6f3e9;
  --surface: #ffffff;
  --surface-soft: #f5f7f2;
  --line: #e2e7de;
  --muted: #687166;
  --danger: #9f3f35;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: #e7ece3;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.9), transparent 30rem),
    #e7ece3;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: 100%;
  max-width: 430px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  overflow-x: hidden;
  background: var(--surface-soft);
  box-shadow: 0 0 40px rgba(29, 50, 32, 0.12);
}

.app-header {
  position: sticky;
  z-index: 5;
  top: 0;
  padding: max(18px, env(safe-area-inset-top)) 18px 12px;
  background: rgba(245, 247, 242, 0.96);
  border-bottom: 1px solid rgba(226, 231, 222, 0.9);
  backdrop-filter: blur(14px);
}

.brand-line {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 13px;
  color: var(--green-700);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.055em;
  text-transform: uppercase;
}

.brand-mark {
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #fff;
  background: var(--green-600);
  border-radius: 7px 7px 11px 7px;
  font-size: 12px;
}

.heading-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-heading {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 8px;
}

.back-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  color: var(--green-700);
  background: var(--green-100);
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-size: 24px;
  line-height: 1;
}

h1 {
  margin: 0;
  font-size: clamp(27px, 8vw, 34px);
  font-weight: 760;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.month-chip {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
  padding: 7px 10px;
  color: var(--green-700);
  background: var(--green-100);
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
}

.month-chip svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.screen-tools {
  margin-top: 16px;
}

.search-actions-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.suggestion-tools {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.search-field {
  display: flex;
  min-width: 0;
  min-height: 46px;
  flex: 1 1 auto;
  align-items: center;
  gap: 10px;
  padding: 0 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 15px;
  box-shadow: 0 2px 8px rgba(32, 48, 31, 0.04);
}

.square-button,
.hidden-button {
  min-height: 46px;
  color: var(--green-700);
  background: var(--green-100);
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
}

.square-button {
  width: 46px;
  padding: 0;
  color: #fff;
  background: var(--green-600);
  font-size: 25px;
}

.hidden-button {
  position: relative;
  padding: 0 11px;
  font-size: 11px;
}

.inline-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 19px;
  height: 19px;
  padding: 0 5px;
  color: #fff;
  background: var(--green-700);
  border: 2px solid var(--surface-soft);
  border-radius: 999px;
  font-size: 9px;
  line-height: 15px;
}

.search-field:focus-within {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(31, 122, 73, 0.13);
}

.search-field svg {
  width: 20px;
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 11px 0;
  color: #20251f;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 16px;
}

.search-field input::placeholder {
  color: #8a9388;
}

.filters {
  display: flex;
  gap: 7px;
  margin-top: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.filters[hidden] {
  display: none;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-button {
  min-width: 44px;
  min-height: 44px;
  flex: 0 0 auto;
  padding: 8px 13px;
  color: #596258;
  background: #eaeee7;
  border: 1px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
}

.filter-button.is-active {
  color: #fff;
  background: var(--green-600);
  box-shadow: 0 4px 12px rgba(31, 122, 73, 0.2);
}

.app-content {
  padding: 16px 14px calc(94px + env(safe-area-inset-bottom));
}

.list-meta,
.column-heading,
.product-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 32px 32px;
  column-gap: 7px;
}

.list-meta {
  display: flex;
  min-height: 25px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.list-meta p,
.list-meta span {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.column-heading {
  align-items: center;
  padding: 7px 12px 6px;
  color: #7b8479;
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
}

.column-heading span:first-child {
  text-align: left;
}

.product-list {
  display: grid;
  gap: 8px;
}

.product-table.without-cards .column-heading,
.product-table.without-cards .product-row {
  grid-template-columns: minmax(0, 1fr);
}

.product-table.without-cards .column-heading span:not(:first-child),
.product-table.without-cards .purchase-cell {
  display: none;
}

.product-row {
  min-height: 70px;
  align-items: stretch;
  padding: 11px 10px 11px 13px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 2px 10px rgba(35, 51, 34, 0.045);
}

.product-details {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-content: center;
  padding-right: 3px;
}

.product-name {
  overflow-wrap: anywhere;
  font-size: 14.5px;
  font-weight: 610;
  line-height: 1.3;
}

.purchase-cell {
  display: grid;
  min-width: 32px;
  place-items: center;
  align-self: stretch;
  color: #a5ada3;
  border-left: 1px solid #edf0ea;
  font-size: 16px;
}

.purchase-cell.has-purchase::before {
  display: grid;
  width: 25px;
  height: 25px;
  place-items: center;
  color: #fff;
  background: var(--green-600);
  border-radius: 50%;
  content: "✓";
  font-size: 14px;
  font-weight: 800;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.row-actions:empty {
  display: none;
}

.action-button {
  min-height: 44px;
  padding: 8px 11px;
  color: var(--green-700);
  background: var(--green-100);
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.action-button.secondary {
  color: #697167;
  background: #f0f2ed;
}

.action-button.danger {
  color: var(--danger);
  background: #faece9;
}

.action-button.icon-action {
  min-width: 44px;
  padding-right: 8px;
  padding-left: 8px;
  color: #526052;
  background: #eef1eb;
  font-size: 16px;
}

.action-button:disabled {
  color: #899187;
  background: #eff1ed;
  cursor: default;
}

.empty-state {
  margin-top: 10px;
  padding: 28px 22px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed #d3dacf;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  text-align: center;
}

.bottom-nav {
  position: fixed;
  z-index: 10;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  width: 100%;
  max-width: 430px;
  min-height: 70px;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 auto;
  padding: 7px 8px max(7px, env(safe-area-inset-bottom));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--line);
  box-shadow: 0 -8px 24px rgba(30, 45, 30, 0.08);
  backdrop-filter: blur(16px);
}

.nav-button {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 53px;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  color: #747d72;
  background: transparent;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 680;
}

.nav-button svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-button.is-active {
  color: var(--green-700);
  background: var(--green-100);
}

.basket-badge {
  position: absolute;
  top: 3px;
  left: calc(50% + 10px);
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  color: #fff;
  background: var(--green-600);
  border: 2px solid #fff;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 800;
  line-height: 14px;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(31, 122, 73, 0.3);
  outline-offset: 2px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.app-dialog {
  width: min(calc(100% - 28px), 402px);
  max-height: min(86vh, 720px);
  padding: 20px;
  overflow: auto;
  color: #20251f;
  background: var(--surface);
  border: 0;
  border-radius: 22px;
  box-shadow: 0 28px 70px rgba(18, 35, 22, 0.28);
}

.app-dialog::backdrop {
  background: rgba(18, 28, 19, 0.48);
  backdrop-filter: blur(3px);
}

.dialog-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.dialog-kicker {
  display: block;
  margin-bottom: 3px;
  color: var(--green-700);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 24px;
  letter-spacing: -0.025em;
}

.dialog-close {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  color: #5e685d;
  background: #eef1eb;
  border: 0;
  border-radius: 13px;
  cursor: pointer;
  font-size: 25px;
}

.month-options {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.month-picker-year {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  text-align: center;
}

.month-year-button {
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--green-700);
  background: var(--green-100);
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 20px;
}

.month-year-button:disabled,
.month-option:disabled {
  color: #a6ada4;
  background: #f3f5f1;
  border-color: #e7eae4;
  cursor: default;
}

.month-option {
  min-height: 46px;
  padding: 8px;
  color: #253126;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  font-weight: 680;
  text-align: center;
}

.month-option.is-selected {
  color: var(--green-700);
  background: var(--green-100);
  border-color: #bed8c3;
}

.month-static-label {
  min-height: 34px;
  padding: 8px 10px;
  color: var(--green-700);
  background: var(--green-100);
  border-radius: 12px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.reference-field,
.form-field {
  display: grid;
  gap: 7px;
  margin-bottom: 16px;
}

.reference-field > span,
.form-field > span,
.card-switches legend {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.reference-field p {
  margin: 0;
  padding: 11px 12px;
  color: #4f594e;
  background: #f2f4ef;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.4;
}

.form-field input {
  min-height: 48px;
  width: 100%;
  padding: 10px 12px;
  color: #20251f;
  background: #fff;
  border: 1px solid #cfd7cc;
  border-radius: 13px;
  outline: 0;
  font-size: 16px;
}

.form-field input:focus {
  border-color: var(--green-600);
  box-shadow: 0 0 0 3px rgba(31, 122, 73, 0.13);
}

.card-switches {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.card-switches legend {
  grid-column: 1 / -1;
  margin-bottom: 7px;
}

.card-switches label {
  display: flex;
  min-height: 48px;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  border-radius: 13px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 680;
}

.card-switches input {
  width: 21px;
  height: 21px;
  margin: 0;
  accent-color: var(--green-600);
}

.form-error {
  margin: 10px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.form-error:empty {
  display: none;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 22px;
}

.dialog-button {
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 750;
}

.dialog-button.primary {
  color: #fff;
  background: var(--green-600);
}

.dialog-button.secondary {
  color: #566055;
  background: #edf0ea;
}

@media (min-width: 431px) {
  .app-shell {
    border-right: 1px solid rgba(38, 60, 38, 0.08);
    border-left: 1px solid rgba(38, 60, 38, 0.08);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .filter-button,
  .nav-button,
  .action-button {
    transition: color 140ms ease, background-color 140ms ease, transform 140ms ease;
  }

  .month-chip,
  .square-button,
  .hidden-button,
  .dialog-button,
  .month-option {
    transition: color 140ms ease, background-color 140ms ease, transform 140ms ease;
  }

  .filter-button:active,
  .nav-button:active,
  .action-button:not(:disabled):active {
    transform: scale(0.97);
  }
}

@media (max-width: 370px) {
  .app-header {
    padding-right: 13px;
    padding-left: 13px;
  }
}
