@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "IBM Plex Mono";
  src: url("fonts/IBMPlexMono-Medium.ttf") format("truetype");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #f5f5f5;
  --bg-card: #ffffff;
  --bg-input: #f0f0f0;
  --border: #dcdcdc;
  --border-hover: #c4c4c4;
  --accent: #1d73ff;
  --accent-dim: #2563eb;
  --text-primary: #1a1a1a;
  --text-muted: #999;
  --text-label: #666;
  --danger: #d92d2d;
  --font-sans: "IBM Plex Sans", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --radius: 4px;
  --radius-lg: 8px;
}

body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  padding: 2rem 1rem 4rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
}

/* Header */
.page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 2rem;
}

.page-header__label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--accent);
  white-space: nowrap;
}

.page-header__line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Form */
.form-wrap {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Card */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.card__title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 1rem;
  text-transform: uppercase;
}

/* Grid */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}

.grid-2:last-child {
  margin-bottom: 0;
}

/* Fields */
.field__label {
  display: block;
  font-size: 11px;
  color: var(--text-label);
  margin-bottom: 5px;
  font-family: var(--font-mono);
}

.field__input,
.field__select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}

.field__select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.field__input:focus,
.field__select:focus {
  outline: none;
  border-color: var(--accent);
}

.field__input[readonly] {
  color: var(--text-muted);
  cursor: default;
}

/* Products */
.products-head {
  display: grid;
  grid-template-columns: 1fr 120px 96px 36px;
  gap: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.products-head span {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.product-row {
  display: grid;
  grid-template-columns: 1fr 120px 96px 36px;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}

.product-row input {
  height: 36px;
  padding: 0 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  width: 100%;
  transition: border-color 0.15s;
}

.product-row input:focus {
  outline: none;
  border-color: var(--accent);
}

.btn-remove {
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    border-color 0.15s,
    color 0.15s;
  line-height: 1;
}

.btn-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-add {
  width: 100%;
  height: 36px;
  margin-top: 4px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  letter-spacing: 0.04em;
  transition:
    border-color 0.15s,
    color 0.15s;
}

.btn-add:hover {
  border-color: var(--border-hover);
  color: var(--text-primary);
}

/* Totals */
.totals {
  border-top: 1px solid var(--border);
  margin-top: 14px;
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.totals__row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--text-label);
}

.totals__row--main {
  color: var(--text-primary);
  font-weight: 500;
  font-size: 15px;
  margin-top: 2px;
}

.totals__val {
  font-family: var(--font-mono);
}

/* Generate button */
.btn-generate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  height: 48px;
  width: 100%;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition:
    background 0.15s,
    opacity 0.15s;
}

.btn-generate:hover {
  background: var(--accent-dim);
}

.btn-generate:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-generate__arrow {
  font-size: 16px;
}

/* Status */
.status {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  min-height: 18px;
}

.status--error {
  color: var(--danger);
}
.status--success {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 480px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .products-head,
  .product-row {
    grid-template-columns: 1fr 90px 72px 36px;
  }
}


@media (prefers-color-scheme: dark) {
  :root {
      --bg: #0f0f0f;
      --bg-card: #161616;
      --bg-input: #1c1c1c;
      --border: #2a2a2a;
      --border-hover: #3a3a3a;
      --accent: #1d73ff;
      --accent-dim: #2563eb;
      --text-primary: #e8e8e8;
      --text-muted: #666;
      --text-label: #888;
      --danger: #ff4d4d;
    }
}
