body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f4f6f8;
  color: #111827;
}

.top {
  background: #111827;
  color: white;
  padding: 14px 24px;
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.top a {
  color: white;
  text-decoration: none;
  font-size: 14px;
}

main {
  padding: 24px;
}

.card {
  background: white;
  padding: 20px;
  border-radius: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}

input, select, button, .button {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin: 10px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 16px;
}

button, .button {
  background: #111827;
  color: white;
  border: none;
  cursor: pointer;
  text-align: center;
  text-decoration: none;
}

button:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.danger {
  background: #b91c1c;
}

.small {
  width: auto;
  display: inline-block;
  padding: 8px 12px;
  font-size: 13px;
}

.weight {
  font-size: 52px;
  font-weight: bold;
  margin: 20px 0;
}

.big {
  font-size: 34px;
  font-weight: bold;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 14px;
  overflow: hidden;
  font-size: 14px;
}

th, td {
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  text-align: left;
}

th {
  background: #111827;
  color: white;
}

.login {
  display: grid;
  place-items: center;
  min-height: 100vh;
}

.login-card {
  width: 360px;
}

.error {
  color: #b91c1c;
}

.hint {
  color: #6b7280;
}

.row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.row input {
  width: auto;
}

.label {
  background: white;
  width: 320px;
  min-height: 260px;
  padding: 20px;
  border: 2px dashed #111827;
  margin-bottom: 20px;
}

.label pre {
  font-size: 18px;
  white-space: pre-wrap;
}

.barcode {
  width: 100%;
  max-height: 80px;
  object-fit: contain;
}

@media print {
  body * {
    visibility: hidden;
  }

  .label, .label * {
    visibility: visible;
  }

  .label {
    position: absolute;
    left: 0;
    top: 0;
    border: none;
  }

  button, .button {
    display: none;
  }
}

.click-row {
  cursor: pointer;
}

.click-row:hover {
  background: #f3f4f6;
}

td a {
  color: #111827;
  font-weight: bold;
  text-decoration: none;
}

td a:hover {
  text-decoration: underline;
}

.edit-card {
  max-width: 640px;
}

.secondary {
  background: #6b7280;
}

textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 16px;
  margin: 10px 0;
  resize: vertical;
}

/* Mobile friendly layout */
@media (max-width: 768px) {
  body {
    font-size: 15px;
  }

  .top {
    padding: 12px;
    gap: 8px;
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  .top strong {
    flex: 0 0 auto;
  }

  .top a {
    background: #1f2937;
    padding: 8px 10px;
    border-radius: 8px;
    flex: 0 0 auto;
  }

  main {
    padding: 12px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 18px;
  }

  .grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 12px;
  }

  input,
  select,
  textarea,
  button,
  .button {
    font-size: 16px;
    min-height: 46px;
  }

  .weight {
    font-size: 42px;
    text-align: center;
  }

  .big {
    font-size: 28px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    border-radius: 12px;
  }

  th,
  td {
    padding: 10px;
    font-size: 13px;
  }

  .login-card {
    width: calc(100vw - 32px);
  }

  .edit-card {
    max-width: 100%;
  }

  .label {
    width: calc(100vw - 48px);
    max-width: 360px;
  }
}

@media (max-width: 480px) {
  .top {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .weight {
    font-size: 36px;
  }

  .card {
    margin-bottom: 12px;
  }

  table {
    font-size: 12px;
  }

  .small {
    width: 100%;
  }
}

/* Strong mobile rewrite */
.mobile-header {
  display: none;
}

@media (max-width: 768px) {
  html, body {
    width: 100%;
    overflow-x: hidden;
  }

  body {
    background: #f9fafb;
  }

  .mobile-header {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 100;
    background: #111827;
    color: white;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
  }

  .mobile-header button {
    width: auto;
    min-height: auto;
    margin: 0;
    padding: 8px 12px;
    background: #374151;
    color: white;
    border-radius: 8px;
    font-size: 22px;
  }

  .top {
    display: none;
    position: fixed;
    top: 52px;
    left: 0;
    right: 0;
    z-index: 99;
    background: #111827;
    padding: 10px;
    flex-direction: column;
    gap: 6px;
    max-height: calc(100vh - 52px);
    overflow-y: auto;
  }

  body.nav-open .top {
    display: flex;
  }

  .desktop-brand {
    display: none;
  }

  .top a {
    display: block;
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    background: #1f2937;
    font-size: 16px;
  }

  main {
    padding: 12px;
  }

  h1 {
    font-size: 24px;
    margin: 12px 0;
  }

  h2 {
    font-size: 18px;
  }

  .grid {
    display: block;
  }

  .card {
    padding: 14px;
    margin-bottom: 14px;
    border-radius: 14px;
  }

  input,
  select,
  textarea,
  button,
  .button {
    width: 100%;
    font-size: 16px;
    min-height: 48px;
    margin: 8px 0 14px 0;
  }

  label {
    font-weight: bold;
    display: block;
    margin-top: 8px;
  }

  .weight {
    font-size: 42px;
    text-align: center;
    background: #111827;
    color: white;
    border-radius: 14px;
    padding: 20px 10px;
  }

  .big {
    font-size: 28px;
  }

  table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
    width: 100%;
  }

  table {
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: visible;
  }

  tr {
    background: white;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,.06);
    box-sizing: border-box;
  }

  th {
    display: none;
  }

  td {
    border: none;
    padding: 6px 0;
    white-space: normal;
    word-break: break-word;
  }

  td::before {
    content: attr(data-label);
    display: block;
    font-size: 12px;
    color: #6b7280;
    font-weight: bold;
    margin-bottom: 2px;
  }

  td a {
    font-size: 18px;
  }

  .click-row:hover {
    background: white;
  }

  .login-card {
    width: calc(100vw - 28px);
    padding: 18px;
  }

  .edit-card {
    max-width: 100%;
  }

  .label {
    width: calc(100vw - 36px);
    max-width: 360px;
    box-sizing: border-box;
  }

  .label pre {
    font-size: 15px;
  }

  .small {
    width: 100%;
  }
}
