:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-muted: #f7f7f8;
  --ink: #111111;
  --muted: #656565;
  --rule: #d8d8d8;
  --accent: #e4002b;
  --accent-dark: #b90023;
  --font: "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.masthead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.72fr);
  min-height: 310px;
  border-bottom: 1px solid var(--ink);
}

.masthead > div {
  padding: 32px clamp(22px, 4vw, 64px);
}

.masthead-actions {
  display: grid;
  align-content: end;
  grid-template-columns: 1fr 1fr;
  border-left: 1px solid var(--ink);
}

.masthead-actions .button-quiet {
  grid-column: 1 / -1;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 900px;
  margin: 42px 0 0;
  font-size: clamp(58px, 8vw, 126px);
  font-weight: 700;
  letter-spacing: -0.075em;
  line-height: 0.79;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(28px, 3vw, 46px);
  letter-spacing: -0.045em;
  line-height: 1;
}

.section-number {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.09em;
}

.button {
  min-height: 50px;
  padding: 14px 18px;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-align: left;
}

.button:hover,
.button:focus-visible {
  background: var(--surface-muted);
}

.button-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.button-primary:hover,
.button-primary:focus-visible {
  background: var(--accent-dark);
}

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

.summary-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  border-bottom: 1px solid var(--ink);
}

.summary-card {
  min-height: 210px;
  padding: 24px clamp(22px, 4vw, 64px);
  border-right: 1px solid var(--ink);
  background: var(--surface-muted);
}

.summary-card:last-child {
  border-right: 0;
}

.summary-card span,
.summary-card small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.summary-card strong {
  display: block;
  margin: 20px 0 2px;
  font-size: clamp(72px, 9vw, 150px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.08em;
  line-height: 0.74;
}

.summary-card:not(.summary-card-featured) strong {
  font-size: clamp(58px, 6vw, 100px);
}

.summary-card.is-alert {
  background: var(--accent);
  color: var(--surface);
}

.summary-card.is-alert span,
.summary-card.is-alert small {
  color: var(--surface);
}

.inventory-section,
.movements-section {
  border-bottom: 1px solid var(--ink);
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  padding: 36px clamp(22px, 4vw, 64px) 28px;
  border-bottom: 1px solid var(--rule);
}

.section-heading .section-number {
  margin-bottom: 12px;
}

.filters {
  display: flex;
  align-items: center;
  gap: 22px;
}

input,
select,
textarea {
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
  outline: 0;
}

input,
select {
  min-height: 44px;
  padding: 10px 0;
}

textarea {
  padding: 10px 0;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-bottom-color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

input[type="search"] {
  width: min(360px, 40vw);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 9px;
  white-space: nowrap;
}

.checkbox-label input {
  width: 17px;
  min-height: auto;
  accent-color: var(--accent);
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 1080px;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  padding: 15px 12px;
  border-right: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}

th:first-child,
td:first-child {
  padding-left: clamp(22px, 4vw, 64px);
}

th:last-child,
td:last-child {
  padding-right: clamp(22px, 4vw, 64px);
  border-right: 0;
}

th {
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

td {
  font-variant-numeric: tabular-nums;
}

.product-name {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
}

.number-cell,
.stock-cell {
  text-align: right;
}

.stock-cell {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.05em;
}

.stock-low {
  color: var(--accent);
}

.status {
  display: inline-block;
  padding: 6px 8px;
  border: 1px solid var(--ink);
  font-size: 11px;
  font-weight: 700;
}

.status-low {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--surface);
}

.empty-state {
  padding: 56px clamp(22px, 4vw, 64px);
  border-bottom: 1px solid var(--rule);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
}

.empty-state p {
  margin-bottom: 0;
  color: var(--muted);
}

.empty-state.compact {
  padding-top: 26px;
  padding-bottom: 26px;
}

.movement-list {
  display: grid;
}

.movement-row {
  display: grid;
  grid-template-columns: 130px minmax(220px, 1.5fr) 100px 90px minmax(150px, 1fr) minmax(150px, 1fr);
  align-items: center;
  min-height: 72px;
  padding: 0 clamp(22px, 4vw, 64px);
  border-bottom: 1px solid var(--rule);
  font-size: 14px;
}

.movement-row > * {
  padding: 12px;
}

.movement-quantity {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.movement-quantity.negative {
  color: var(--accent);
}

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

dialog {
  width: min(850px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--ink);
  border-radius: 0;
  background: var(--surface);
  color: var(--ink);
}

dialog::backdrop {
  background: rgb(0 0 0 / 58%);
}

dialog form {
  padding: clamp(22px, 4vw, 48px);
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 34px;
}

.dialog-heading .section-number {
  margin-bottom: 12px;
}

.close-button {
  align-self: start;
  padding: 0 0 5px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: transparent;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px 30px;
}

.form-grid label,
.auth-dialog label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.form-span {
  grid-column: 1 / -1;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 30px;
}

.form-error {
  min-height: 20px;
  margin: 18px 0 0;
  color: var(--accent);
  font-weight: 700;
}

.field-hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.auth-dialog {
  width: min(480px, calc(100vw - 32px));
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  max-width: min(380px, calc(100vw - 36px));
  padding: 14px 18px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--surface);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .masthead {
    grid-template-columns: 1fr;
  }

  .masthead-actions {
    border-top: 1px solid var(--ink);
    border-left: 0;
  }

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

  .summary-card-featured {
    grid-column: 1 / -1;
    border-bottom: 1px solid var(--ink);
  }

  .movement-row {
    grid-template-columns: 100px minmax(150px, 1fr) 80px 70px;
  }

  .movement-row .movement-reference,
  .movement-row .movement-contact {
    display: none;
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: 58px;
  }

  .section-heading,
  .filters {
    align-items: stretch;
    flex-direction: column;
  }

  input[type="search"] {
    width: 100%;
  }

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

  .summary-card,
  .summary-card-featured {
    grid-column: auto;
    min-height: 160px;
    border-right: 0;
    border-bottom: 1px solid var(--ink);
  }

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

  .form-span {
    grid-column: auto;
  }

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

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
