:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #1e2228;
  --muted: #767d86;
  --line: #e5e8eb;
  --accent: #03c75a;
  --accent-strong: #00a84f;
  --accent-soft: #e9fff4;
  --danger: #d14141;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(3, 199, 90, 0.1), rgba(245, 247, 248, 0) 220px),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.eyebrow {
  width: fit-content;
  margin: 0 0 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 850;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(30px, 4vw, 42px);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  font-size: 21px;
}

.icon-button {
  width: 44px;
  height: 44px;
  border: 1px solid #dce1e5;
  border-radius: 8px;
  background: var(--panel);
  color: #4b5563;
  cursor: pointer;
  font-size: 23px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.secondary-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  padding: 0 16px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(3, 199, 90, 0.24);
}

.quick-panel,
.item-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quick-panel {
  padding: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(17, 24, 39, 0.45);
  padding: 16px;
  z-index: 20;
}

.modal-backdrop.visible {
  display: flex;
}

.modal-panel {
  width: min(680px, 100%);
  max-height: calc(100vh - 32px);
  overflow: auto;
  border-top: 4px solid var(--accent);
}

.modal-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.item-form {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(140px, 180px);
  gap: 12px;
}

.item-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

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

input,
select {
  width: 100%;
  min-height: 46px;
  border: 1px solid #dfe4e8;
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 0 12px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(3, 199, 90, 0.2);
  outline-offset: 2px;
}

.primary-button {
  grid-column: 1 / -1;
  min-height: 50px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: white;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(3, 199, 90, 0.22);
}

.toolbar {
  display: grid;
  grid-template-columns: 1fr 170px;
  gap: 12px;
  margin: 20px 0 18px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 14px;
  box-shadow: 0 8px 18px rgba(3, 199, 90, 0.12);
}

.search-box span {
  color: var(--accent-strong);
  font-size: 20px;
  font-weight: 900;
}

.search-box input {
  border: 0;
  padding: 0;
}

.search-box input:focus {
  outline: 0;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

#countLabel {
  color: var(--muted);
  font-weight: 700;
}

.item-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.item-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 120px 40px;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  transition:
    transform 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

.item-card:hover {
  border-color: rgba(3, 199, 90, 0.36);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.09);
  transform: translateY(-1px);
}

.item-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.category-pill {
  flex-shrink: 0;
  width: fit-content;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 850;
}

.item-card h3 {
  min-height: 0;
  font-size: 16px;
  line-height: 1.3;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.button-row {
  min-width: 0;
}

.buy-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border-radius: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 850;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(3, 199, 90, 0.2);
}

.buy-link:hover {
  background: var(--accent-strong);
}

.buy-link.disabled {
  pointer-events: none;
  background: #d8dbd6;
  color: #797f78;
}

.delete-button {
  justify-self: end;
  width: 34px;
  min-height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  padding: 0;
  font-size: 12px;
  font-weight: 750;
}

.delete-button:hover {
  color: var(--danger);
  text-decoration: underline;
}

.empty-state {
  display: none;
  border: 1px dashed #cfd6dc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.75);
  color: var(--muted);
  padding: 26px 16px;
  text-align: center;
}

.empty-state.visible {
  display: block;
}

@media (max-width: 680px) {
  .app-shell {
    padding: 18px 12px 36px;
  }

  .top-bar {
    align-items: flex-start;
    gap: 12px;
  }

  .header-actions {
    align-items: center;
    gap: 6px;
  }

  .secondary-button {
    min-width: 108px;
    padding: 0 10px;
    font-size: 14px;
  }

  .item-form,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .item-card {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .item-main {
    align-items: flex-start;
    flex-direction: column;
    gap: 7px;
  }

  .buy-link {
    width: 100%;
  }

  .delete-button {
    width: auto;
  }
}
