:root {
  --bg: #121212;
  --panel: #1a1a1a;
  --ink: #f2f2f2;
  --dim: #9a9a9a;
  --line: #2c2c2c;
  --qty: #f5c451;
  --ok: #7dcc8a;
  --danger: #e06b63;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: Manrope, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.35;
}

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-wrap { width: min(380px, 100%); }
.login-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px 22px;
  display: grid;
  gap: 12px;
  text-align: center;
}
.login-logo {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  margin: 0 auto;
  object-fit: cover;
}
.login-card h1 { margin: 0; font-size: 24px; }
.login-card label { text-align: left; }
.muted { color: var(--dim); }
label { display: grid; gap: 6px; font-size: 13px; color: var(--dim); font-weight: 600; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #101010;
  color: var(--ink);
  border-radius: 10px;
  padding: 12px;
  font: inherit;
}
.alert {
  background: #3a1c1c;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px;
}

.top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { font-size: 17px; }
.logo { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.top-actions { display: flex; gap: 14px; }
.text-btn {
  background: none;
  border: 0;
  color: var(--dim);
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  padding: 0;
  text-decoration: none;
  cursor: pointer;
}

.layout { padding: 8px 0 96px; }
.summary {
  margin: 0;
  padding: 12px 16px 8px;
  color: var(--dim);
  font-size: 14px;
}
.summary b { color: var(--qty); font-size: 18px; }

.list { border-top: 1px solid var(--line); }
.group-h {
  padding: 14px 16px 8px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #cfcfcf;
  background: #161616;
}
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  width: 100%;
  background: transparent;
  color: inherit;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.row:active { background: #222; }
.row.empty { opacity: 0.55; }
.row-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.01em;
}
.row-sub { margin-top: 2px; color: var(--dim); font-size: 13px; }
.row-qty {
  text-align: right;
  min-width: 72px;
}
.row-qty b {
  display: block;
  font-size: 32px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--qty);
}
.row.empty .row-qty b { color: #666; }
.row-qty span {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--dim);
  text-transform: uppercase;
}

.history {
  margin: 8px 16px 0;
  color: var(--dim);
}
.history summary { cursor: pointer; font-weight: 700; }
.history-item {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  font-size: 14px;
}
.badge { font-weight: 800; margin-right: 8px; }
.badge.in { color: var(--ok); }
.badge.out { color: var(--danger); }

.dock {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  z-index: 8;
}
.btn {
  border: 1px solid var(--line);
  background: #242424;
  color: var(--ink);
  border-radius: 12px;
  padding: 14px 12px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.btn.primary { background: var(--qty); color: #111; border-color: var(--qty); }
.btn.danger { background: #3a1c1c; color: var(--danger); border-color: #5a2a2a; }
.btn.wide { width: 100%; }

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  display: grid;
  place-items: end center;
  z-index: 20;
}
.overlay.hidden { display: none; }
.modal {
  width: 100%;
  max-height: 92vh;
  overflow: auto;
  background: var(--panel);
  border-radius: 18px 18px 0 0;
  padding: 18px 16px 28px;
}
.modal h2 { margin: 0 0 14px; font-size: 22px; }
.form-grid { display: grid; gap: 10px; }
.modal-actions { display: flex; gap: 8px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }
.total-line {
  display: flex;
  justify-content: space-between;
  margin-top: 14px;
  font-size: 22px;
  font-weight: 800;
}
.error { color: var(--danger); min-height: 18px; margin-top: 8px; }

.pick {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.pick-name { font-weight: 800; }
.pick-sub { color: var(--dim); font-size: 13px; }
.stepper { display: flex; align-items: center; gap: 6px; }
.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #101010;
  color: var(--ink);
  font-size: 20px;
  font-weight: 800;
}
.stepper input {
  width: 52px;
  text-align: center;
  padding: 8px 4px;
  font-weight: 800;
}
.sheet-qty {
  font-size: 56px;
  font-weight: 800;
  color: var(--qty);
  line-height: 1;
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
}
.sheet-meta { color: var(--dim); margin-bottom: 16px; }

.toasts {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(76px + env(safe-area-inset-bottom));
  z-index: 40;
  display: grid;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1f1f1f;
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 800;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.ok { border-color: #3d6a42; background: #1a2a1c; color: var(--ok); }
.toast.err { border-color: #6a3d3d; background: #2a1a1a; color: var(--danger); }

@media (min-width: 760px) {
  .layout { max-width: 640px; margin: 0 auto; padding-bottom: 40px; }
  .dock {
    position: static;
    max-width: 640px;
    margin: 16px auto 40px;
    padding: 0 16px;
  }
  .overlay { place-items: center; }
  .modal {
    width: min(560px, calc(100% - 32px));
    border-radius: 18px;
    margin-bottom: 24px;
  }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .toasts {
    left: auto;
    right: 24px;
    bottom: 24px;
    width: min(360px, calc(100% - 48px));
  }
}
