:root {
  --bg: #111111;
  --surface: #1a1a1a;
  --surface-soft: #202020;
  --line: #2f2f2f;
  --line-strong: #444444;
  --text: #ffffff;
  --muted: #c8c8c8;
  --accent: #c8ced8;
  --accent-ink: #1c2430;
  --focus: #a8b3c4;
  --primary-dark: #2a313d;
  --primary-dark-hover: #353f4f;
  --primary-dark-line: #4d5a6e;
  --radius: 12px;
  --container: 1060px;
  --error-bg: #2a1717;
  --error-line: #6d2e2e;
  --error-text: #ffbcbc;
  --ok-bg: #163021;
  --ok-line: #2f6a4a;
  --ok-text: #b8f5cd;
  --shadow: 0 14px 28px rgba(0, 0, 0, 0.42);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  background: radial-gradient(circle at 12% -8%, #1f1f1f 0%, var(--bg) 44%);
  line-height: 1.55;
}

.page {
  width: min(var(--container), calc(100% - 2rem));
  margin: 1rem auto 1.5rem;
  display: grid;
  gap: 1rem;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--surface-soft));
  box-shadow: var(--shadow);
  padding: 1.15rem;
}

h1,
h2 {
  margin: 0;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.28rem, 1.05rem + 1vw, 1.8rem);
}

h2 {
  font-size: clamp(1.1rem, 0.97rem + 0.55vw, 1.4rem);
}

p {
  margin: 0.45rem 0 0.9rem;
}

.divider {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 0.95rem 0 0.9rem;
}

.muted {
  color: var(--muted);
}

code {
  border: 1px solid #4a4a4a;
  border-radius: 6px;
  padding: 0.1rem 0.36rem;
  background: #1a1a1a;
  color: #f1f1f1;
}

.grid {
  display: grid;
  gap: 0.8rem;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.8rem;
}

.field > span,
.field > legend {
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
}

fieldset.field {
  margin: 0 0 0.8rem;
  padding: 0;
  border: 0;
  min-width: 0;
}

fieldset.field legend {
  margin-bottom: 0.5rem;
  padding: 0;
}

input,
textarea,
button {
  font: inherit;
}

input[type="text"],
input[type="number"],
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  padding: 0.65rem 0.76rem;
  background: #141414;
  color: var(--text);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

input[type="text"][readonly] {
  background: #171717;
}

input::placeholder,
textarea::placeholder {
  color: #a1a1a1;
}

textarea {
  resize: vertical;
  min-height: 5.2rem;
}

input[type="text"]:focus,
input[type="number"]:focus,
textarea:focus,
button:focus-visible {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(168, 179, 196, 0.25);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  margin: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.checks,
.stack {
  display: grid;
  gap: 0.45rem;
}

.checks label,
.stack label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #191919;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin: 0.45rem 0 0.9rem;
}

.actions-with-total {
  align-items: stretch;
}

.total-inline {
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #191919;
  padding: 0.5rem 0.72rem;
  display: grid;
  align-content: center;
  gap: 0.08rem;
}

.total-inline span {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.total-inline strong {
  color: #f3f6fb;
  font-size: 1.06rem;
  line-height: 1.2;
}

.qty-control {
  display: grid;
  grid-template-columns: 2.7rem minmax(0, 6rem) 2.7rem;
  align-items: center;
  gap: 0.45rem;
  width: max-content;
}

.qty-control input[type="text"] {
  text-align: center;
  font-weight: 700;
}

.qty-btn {
  padding: 0.62rem 0;
  font-size: 1.25rem;
  line-height: 1;
}

button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.7rem 1rem;
  border-radius: 10px;
  border: 1px solid transparent;
  text-decoration: none;
  font-size: 0.97rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

button:not(.secondary):not(.ghost) {
  background: var(--primary-dark);
  color: #f2f5fa;
  border-color: var(--primary-dark-line);
}

button:not(.secondary):not(.ghost):hover {
  background: var(--primary-dark-hover);
  border-color: #65748d;
}

button.secondary {
  background: transparent;
  color: var(--text);
  border-color: #4a4a4a;
}

button.secondary:hover {
  background: #252525;
}

button.ghost {
  background: transparent;
  color: var(--text);
  border-color: #4a4a4a;
}

button.ghost:hover {
  background: #252525;
}

#sendBtn {
  background: #2f3845;
  border-color: #58667d;
  color: #f3f6fb;
}

#sendBtn:hover {
  background: #394556;
  border-color: #6a7890;
}

button:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.alert {
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.85rem;
  font-weight: 600;
}

.alert-error {
  background: var(--error-bg);
  border-color: var(--error-line);
  color: var(--error-text);
}

.alert-success {
  background: var(--ok-bg);
  border-color: var(--ok-line);
  color: var(--ok-text);
}

.hidden {
  display: none !important;
}

.summary {
  border: 1px dashed #4a4a4a;
  border-radius: 10px;
  padding: 0.75rem;
  margin-bottom: 0.95rem;
  background: #181818;
}

.summary p {
  margin: 0.2rem 0;
}

.box {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.8rem;
  margin: 0.25rem 0 0.9rem;
  background: #191919;
}

.box h2 {
  font-size: 1rem;
  margin-bottom: 0.6rem;
}

.batch-results {
  display: grid;
  gap: 0.65rem;
}

.batch-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "title title"
    "input action";
  gap: 0.55rem;
  padding: 0.72rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #191919;
}

.batch-title {
  grid-area: title;
  font-weight: 700;
  color: var(--text);
}

.batch-row input[type="text"] {
  grid-area: input;
}

.batch-row button {
  grid-area: action;
  align-self: stretch;
}

@media (min-width: 760px) {
  .card {
    padding: 1.35rem;
  }
}

@media (max-width: 880px) {
  .page {
    width: min(var(--container), calc(100% - 1rem));
    margin: 0.75rem auto 1rem;
  }

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

@media (max-width: 620px) {
  .qty-control {
    width: 100%;
    grid-template-columns: 3rem minmax(0, 1fr) 3rem;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .actions button,
  .total-inline {
    width: 100%;
  }

  .batch-row {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "input"
      "action";
  }
}
