* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f1f5f9;
  color: #0f172a;
}

.hidden { display: none !important; }

.login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.logo {
  width: 64px;
  height: 64px;
  border-radius: 999px;
  object-fit: cover;
  border: 2px solid #e2e8f0;
  background: #fff;
}

.login-logo {
  width: 84px;
  height: 84px;
  display: block;
  margin: 0 auto 12px auto;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 8px 24px rgba(2, 6, 23, 0.08);
}

.login-card h1 { margin: 0 0 8px 0; font-size: 24px; }
.login-card p { margin: 0 0 16px 0; color: #64748b; font-size: 14px; }
.login-card label { display: block; margin-bottom: 8px; font-size: 14px; }
.login-card input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
}
.login-card button {
  width: 100%;
  border: none;
  border-radius: 10px;
  padding: 10px;
  background: #4f46e5;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.login-card small { display: block; margin-top: 10px; color: #64748b; }
.error-box {
  background: #ffe4e6;
  color: #be123c;
  border: 1px solid #fecdd3;
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 12px;
}

.app { min-height: 100vh; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 12px 16px;
  max-height: 320px;
  overflow: hidden;
  transition: max-height 0.22s ease, padding 0.22s ease, border-color 0.22s ease, opacity 0.22s ease;
}
.title-row { margin-bottom: 10px; }
.brand-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-logo {
  width: 48px;
  height: 48px;
}
.title-input {
  width: 100%;
  max-width: 500px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 24px;
  font-weight: 800;
}
.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.search {
  flex: 1 1 260px;
  min-width: 200px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  padding: 10px 14px;
}

.btn {
  border: 1px solid #cbd5e1;
  background: #fff;
  color: #334155;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn.primary { background: #4f46e5; border-color: #4f46e5; color: #fff; }
.btn.dark { background: #0f172a; border-color: #0f172a; color: #fff; }
.btn.danger { color: #e11d48; border-color: #fecdd3; background: #fff1f2; }
.btn.ghost { background: #f8fafc; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.logout-form { margin: 0; }
.mobile-only { display: none; }
.mobile-menu-toggle { display: none; }

.content {
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) 280px;
  padding: 16px;
}
.left-panel { min-width: 0; }
.right-panel {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  padding: 14px;
  height: fit-content;
  position: sticky;
  top: 126px;
}
.right-panel h3 { margin: 0 0 10px 0; }
.summary-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
  padding: 10px;
  margin-bottom: 10px;
}
.summary-box > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 0;
}
.summary-box strong { font-size: 24px; }

.status-bar {
  margin-bottom: 10px;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 10px;
  border-radius: 10px;
  font-size: 14px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.section-head h2 { margin: 0; }
.section-head span { color: #64748b; font-size: 13px; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.card-image {
  position: relative;
  height: 180px;
  background: #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}
.card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.no-image {
  height: 100%;
  display: grid;
  place-items: center;
  color: #64748b;
  font-size: 12px;
}
.ref-tag {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
  padding: 2px 6px;
}
.delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid #fecdd3;
  background: #fff1f2;
  color: #be123c;
  border-radius: 6px;
  padding: 3px 6px;
  font-size: 11px;
  cursor: pointer;
}
.card-body { padding: 10px; display: grid; gap: 8px; }
.name { font-weight: 700; min-height: 40px; }
.local-name { color: #64748b; font-size: 13px; min-height: 18px; }
.pack { display: inline-block; background: #f1f5f9; padding: 3px 8px; border-radius: 8px; font-size: 12px; }
.qty-row { display: flex; justify-content: space-between; align-items: center; }
.qty-box {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #4f46e5;
  color: #fff;
  border-radius: 999px;
  padding: 5px 10px;
}
.qty-box button {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: #334155;
  font-weight: 800;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.qty-num {
  min-width: 28px;
  text-align: center;
  font-weight: 800;
  font-size: 20px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: grid;
  place-items: center;
  z-index: 30;
}
.modal-card {
  width: min(92vw, 420px);
  background: #fff;
  border-radius: 14px;
  border: 1px solid #e2e8f0;
  padding: 14px;
}
.modal-card h3 { margin: 0 0 8px 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.row label { font-size: 13px; color: #475569; }
.row input, .checkbox input { margin-top: 6px; }
.row input {
  width: 100%;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  padding: 8px;
}
.checkbox { display: flex; gap: 8px; align-items: center; margin-top: 10px; font-size: 14px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 12px; }

.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
}
.drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
}
.drawer-panel {
  position: absolute;
  right: 0;
  top: 0;
  width: min(92vw, 430px);
  height: 100%;
  background: #fff;
  border-left: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
}
.drawer-head {
  padding: 12px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.cart-items {
  flex: 1;
  overflow: auto;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.cart-row {
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
}
.cart-head {
  display: flex;
  gap: 10px;
}
.cart-thumb {
  width: 56px;
  height: 56px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: #f8fafc;
}
.cart-thumb img { width: 100%; height: 100%; object-fit: contain; }
.cart-meta { font-size: 12px; color: #64748b; }
.cart-title { font-weight: 700; color: #0f172a; }
.cart-actions { margin-top: 8px; display: flex; justify-content: space-between; align-items: center; }

.toast {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 60;
  border: 1px solid #cbd5e1;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(2, 6, 23, 0.16);
  padding: 10px 14px;
}
.toast.success { border-color: #bbf7d0; background: #f0fdf4; color: #166534; }
.toast.error { border-color: #fecdd3; background: #fff1f2; color: #9f1239; }

.site-footer {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  margin-top: 20px;
  padding: 24px 16px 30px 16px;
}

.site-footer-text {
  display: inline-block;
  width: min(100%, 720px);
  font-size: 11px;
  line-height: 1.6;
  color: #94a3b8;
  letter-spacing: 0.01em;
  text-align: center;
}

.app-footer {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid #e2e8f0;
  background: #f8fafc;
}

@media (max-width: 980px) {
  .content { grid-template-columns: 1fr; }
  .right-panel { position: static; }
}

@media (max-width: 680px) {
  .topbar.mobile-hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-bottom-color: transparent;
    opacity: 0.02;
  }
  .topbar.mobile-hidden .title-row,
  .topbar.mobile-hidden .toolbar {
    visibility: hidden;
    pointer-events: none;
  }
  .title-input {
    font-size: 17px;
    padding: 8px 10px;
  }
  .app-logo {
    width: 42px;
    height: 42px;
  }
  .content { padding: 10px; }
  .section-head {
    align-items: flex-start;
    gap: 8px;
  }
  .section-head span {
    max-width: 48%;
    text-align: right;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .card-image { height: 150px; }
  .card-body { padding: 8px; gap: 6px; }
  .name { min-height: 34px; font-size: 14px; }
  .local-name { font-size: 12px; }
  .pack { font-size: 11px; }
  .qty-box {
    width: 100%;
    max-width: 150px;
    margin: 0 auto;
    justify-content: space-between;
    padding: 4px 6px;
    gap: 2px;
  }
  .qty-box button {
    width: 34px;
    height: 34px;
    font-size: 20px;
  }
  .qty-num {
    min-width: 22px;
    font-size: 18px;
  }
  .qty-row {
    justify-content: center;
  }
  .qty-row > span {
    display: none;
  }
  .mobile-only { display: inline-flex; }
  .mobile-menu-toggle {
    display: inline-flex;
    position: fixed;
    right: 12px;
    top: 10px;
    z-index: 25;
    border: 1px solid #cbd5e1;
    background: rgba(255, 255, 255, 0.94);
    color: #334155;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.14);
  }
  .site-footer {
    margin-top: 16px;
    padding: 22px 12px 28px 12px;
  }
  .site-footer-text {
    font-size: 10px;
    line-height: 1.5;
  }
}
