:root {
  --bg: #f5f7f8;
  --surface: #ffffff;
  --surface-muted: #eef4f1;
  --text: #17201c;
  --muted: #65716c;
  --line: #d8e0dd;
  --primary: #0f5c4a;
  --primary-strong: #0a4638;
  --accent: #d98f2b;
  --danger: #ad2f32;
  --shadow: 0 16px 40px rgba(23, 32, 28, 0.08);
  --radius: 8px;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: var(--text);
  background: var(--bg);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  min-height: 100%;
  margin: 0;
  background:
    linear-gradient(180deg, rgba(15, 92, 74, 0.09), transparent 280px),
    var(--bg);
}

body.drawer-open {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

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

.app-shell {
  width: min(100%, 1060px);
  margin: 0 auto;
  padding: 18px 14px 112px;
}

.app-header {
  display: grid;
  grid-template-columns: 44px 48px 1fr 44px;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  margin-bottom: 16px;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 29;
  background: rgba(23, 32, 28, 0.36);
  backdrop-filter: blur(2px);
}

.nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 30;
  width: min(340px, calc(100vw - 34px));
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 24px 0 60px rgba(23, 32, 28, 0.18);
  padding: 18px 14px calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-104%);
  transition: transform 180ms ease;
}

.nav-drawer.is-open {
  transform: translateX(0);
}

.drawer-header {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.drawer-header p,
.drawer-header h2,
.drawer-section-title h3 {
  margin: 0;
}

.drawer-header p {
  color: var(--primary);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.drawer-header h2 {
  margin-top: 2px;
  font-size: 1.35rem;
  line-height: 1.1;
}

.drawer-new-button {
  width: 100%;
  margin-bottom: 16px;
}

.drawer-section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 4px 0 10px;
}

.drawer-section-title h3 {
  font-size: 1rem;
  line-height: 1.2;
}

.drawer-section-title span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  background: var(--primary);
  box-shadow: 0 10px 24px rgba(15, 92, 74, 0.22);
}

.brand-mark svg {
  width: 34px;
  height: 34px;
  fill: none;
  stroke: #ffffff;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.header-copy p,
.header-copy h1,
.section-title h2 {
  margin: 0;
}

.header-copy p {
  color: var(--primary);
  font-size: 0.77rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.header-copy h1 {
  margin-top: 2px;
  font-size: clamp(1.42rem, 6vw, 2.15rem);
  line-height: 1.06;
}

.page-actions {
  display: flex;
  justify-content: flex-start;
  margin: -4px 0 14px;
}

.page-new-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding-inline: 14px;
}

.page-new-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.workspace {
  display: grid;
  gap: 14px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
}

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

.section-title h2 {
  font-size: 1rem;
  line-height: 1.2;
}

.section-title span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  white-space: nowrap;
}

.field-grid,
.product-form,
.product-fields {
  display: grid;
  gap: 12px;
}

.compact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.field input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfc;
  color: var(--text);
  outline: none;
  padding: 12px 12px;
  transition:
    border-color 150ms ease,
    box-shadow 150ms ease,
    background 150ms ease;
}

.field input:focus {
  border-color: var(--primary);
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(15, 92, 74, 0.12);
}

.field input::placeholder {
  color: #9aa5a0;
}

.full-width {
  grid-column: 1 / -1;
}

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

.form-actions .primary-button {
  grid-column: 2;
}

.form-actions .secondary-button[hidden] + .primary-button {
  grid-column: 1 / -1;
}

.primary-button,
.secondary-button,
.icon-button {
  border: 0;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 850;
}

.primary-button,
.secondary-button {
  min-height: 48px;
  padding: 12px 16px;
}

.primary-button {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 92, 74, 0.18);
}

.primary-button:active {
  background: var(--primary-strong);
  transform: translateY(1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.secondary-button {
  background: var(--surface-muted);
  color: var(--primary-strong);
  border: 1px solid rgba(15, 92, 74, 0.16);
}

.secondary-button:active {
  transform: translateY(1px);
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(15, 92, 74, 0.16);
  color: var(--primary);
}

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

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

.empty-state {
  display: grid;
  place-items: center;
  min-height: 128px;
  border: 1px dashed #bdc9c4;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 750;
  text-align: center;
  padding: 18px;
}

.product-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-left: 5px solid var(--accent);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.product-name {
  margin: 0;
  font-size: 1rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.product-values {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.value-chip {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
  min-height: 30px;
  border-radius: 999px;
  background: #f2f5f6;
  color: var(--text);
  padding: 6px 9px;
  font-size: 0.86rem;
  font-weight: 800;
}

.value-chip span {
  color: var(--muted);
  font-weight: 750;
}

.card-actions {
  display: grid;
  grid-template-columns: 38px 38px;
  gap: 6px;
}

.card-actions .icon-button {
  width: 38px;
  height: 38px;
  background: #f8faf9;
}

.card-actions .delete-action {
  color: var(--danger);
}

.history-list,
.column-list {
  display: grid;
  gap: 10px;
}

.history-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  padding: 12px;
}

.history-title {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.history-meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.history-actions {
  display: grid;
  grid-template-columns: 38px 38px;
  gap: 6px;
}

.history-actions .icon-button {
  width: 38px;
  height: 38px;
  background: #f8faf9;
}

.settings-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  cursor: pointer;
  font-weight: 850;
  list-style: none;
}

.settings-summary::-webkit-details-marker {
  display: none;
}

.settings-summary span:last-child {
  color: var(--primary);
  font-size: 0.86rem;
}

.column-list {
  margin-top: 12px;
}

.column-row {
  display: grid;
  grid-template-columns: 1fr 38px;
  gap: 8px;
  align-items: end;
}

.column-row.is-locked {
  grid-template-columns: 1fr;
}

.column-row .icon-button {
  width: 38px;
  height: 38px;
  color: var(--danger);
  background: #f8faf9;
}

.add-column-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.action-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
  box-shadow: 0 -12px 28px rgba(23, 32, 28, 0.1);
}

.action-bar .primary-button,
.action-bar .secondary-button {
  min-height: 52px;
}

.toast {
  position: fixed;
  right: 14px;
  bottom: calc(86px + env(safe-area-inset-bottom));
  left: 14px;
  z-index: 20;
  display: none;
  max-width: 520px;
  margin: 0 auto;
  border-radius: var(--radius);
  background: #17201c;
  color: #ffffff;
  padding: 13px 14px;
  font-weight: 760;
  box-shadow: 0 18px 44px rgba(23, 32, 28, 0.24);
}

.toast.is-visible {
  display: block;
}

@media (min-width: 760px) {
  .app-shell {
    padding: 28px 24px 124px;
  }

  .app-header {
    margin-bottom: 22px;
  }

  .page-actions {
    margin: -12px 0 18px;
  }

  .workspace {
    grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr);
    align-items: start;
  }

  .details-panel,
  .item-panel,
  .columns-panel {
    grid-column: 1;
  }

  .products-panel {
    grid-column: 2;
    grid-row: 1 / span 2;
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .action-bar {
    right: 24px;
    bottom: 22px;
    left: auto;
    width: min(430px, calc(100% - 48px));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 10px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .app-shell,
  .action-bar,
  .toast {
    display: none !important;
  }
}
