*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #dbeafe;
  --danger: #dc2626;
  --danger-dark: #b91c1c;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --bg: #ffffff;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 2rem;
  overflow-x: hidden;
  max-width: 100%;
}

#appScreen,
#programSelectScreen,
#excelMergeScreen,
#logisticsScreen,
main {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

[hidden],
.hidden {
  display: none !important;
}

/* App top (header + product tabs) */
.app-top {
  position: sticky;
  top: 0;
  z-index: 100;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* Header */
.header {
  background: var(--primary);
  color: #fff;
  text-align: center;
  padding: 1rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

#appScreen .header-actions--programs,
#logisticsScreen .header-actions--programs,
#excelMergeScreen .header-actions--programs {
  justify-content: center;
  gap: 0.5rem;
}

.header-user-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  min-width: 0;
}

.header-user-cluster .user-email {
  max-width: 36vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
}

.header-action-cluster {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
}

.btn-header-program-select {
  padding: 0.28rem 0.55rem;
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: nowrap;
  flex-shrink: 0;
}

#appScreen .header-actions {
  gap: 0.35rem;
  flex-wrap: nowrap;
}

#appScreen .header-actions .user-email {
  max-width: 42vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.8125rem;
}

@media (max-width: 767px) {
  #appScreen .header-actions--programs,
  #logisticsScreen .header-actions--programs,
  #excelMergeScreen .header-actions--programs {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }

  .header-user-cluster {
    justify-content: center;
    flex-wrap: wrap;
  }

  .header-user-cluster .user-email {
    max-width: 100%;
    text-align: center;
  }

  .header-action-cluster {
    justify-content: center;
  }

  #appScreen .header-actions .btn-header-action,
  #logisticsScreen .header-actions .btn-header-action,
  #excelMergeScreen .header-actions .btn-header-action {
    padding: 0.38rem 0.55rem;
    font-size: 0.8125rem;
  }

  .btn-header-program-select {
    padding: 0.32rem 0.5rem;
    font-size: 0.75rem;
  }
}

@media (min-width: 768px) {
  #appScreen .header-actions--programs,
  #logisticsScreen .header-actions--programs,
  #excelMergeScreen .header-actions--programs {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
  }
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow: visible;
  padding-top: 4px;
  padding-inline: 4px;
}

.subscription-days-badge {
  display: none;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
  box-sizing: border-box;
}

.subscription-days-badge.is-visible {
  display: inline-flex;
}

.subscription-days-value {
  font-size: 0.8125rem;
  font-weight: 700;
  line-height: 1;
}

.subscription-days-badge--safe {
  background: #ffffff;
  color: var(--primary);
  border: 1px solid rgba(255, 255, 255, 0.85);
}

.subscription-days-badge--warn {
  background: #f97316;
  color: #ffffff;
}

.subscription-days-badge--danger {
  background: #dc2626;
  color: #ffffff;
}

.subscription-days-badge--expired {
  background: #94a3b8;
  color: #ffffff;
}

.subscription-expired-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 1rem;
  padding: 0.875rem 1rem;
  border-radius: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.subscription-expired-text {
  margin: 0;
  flex: 1 1 12rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: #b91c1c;
}

.subscription-expired-payment-btn {
  flex: none;
  min-height: 40px;
}

.btn-header-action.header-action--highlight {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #f97316;
}

@media (max-width: 767px) {
  .subscription-days-badge {
    width: 32px;
    height: 32px;
  }

  .subscription-days-value {
    font-size: 0.75rem;
  }
}

.user-email {
  font-size: 0.8rem;
  opacity: 0.9;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-header-action {
  flex: none;
  height: 34px;
  min-height: 34px;
  padding: 0 0.625rem;
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  cursor: pointer;
  box-sizing: border-box;
}

.btn-header-action:active {
  background: rgba(255, 255, 255, 0.15);
}

.btn-header-help {
  height: 30px;
  min-height: 30px;
  padding: 0 0.5rem;
  font-size: 0.75rem;
}

.btn-header-admin {
  position: relative;
  overflow: visible;
}

.admin-pending-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  box-shadow: 0 0 0 1.5px var(--primary);
  pointer-events: none;
  z-index: 2;
  box-sizing: border-box;
}

.admin-pending-badge-bang {
  font-size: 0.5rem;
  line-height: 1;
  margin-right: -1px;
}

.admin-pending-badge-count {
  font-size: 0.5625rem;
  line-height: 1;
}

#authCheckingScreen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.25rem;
  background: #f1f5f9;
}

.auth-checking-card {
  text-align: center;
}

.auth-checking-text {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Legal pages */
body.legal-page {
  background: #f1f5f9;
  padding: 1.25rem;
}

.legal-content {
  max-width: 720px;
  margin: 0 auto;
  background: var(--bg);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.legal-back-link {
  display: inline-block;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}

.legal-content h1 {
  font-size: 1.375rem;
  font-weight: 800;
  margin-bottom: 0.375rem;
}

.legal-updated {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}

.legal-content section {
  margin-bottom: 1.25rem;
}

.legal-content h2 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 0.375rem;
}

.legal-content p {
  font-size: 0.9375rem;
  line-height: 1.65;
  color: var(--text);
}

/* Auth screen layout (display controlled by body state rules at end) */
#authScreen {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.25rem;
  background: #f1f5f9;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg);
  border-radius: 14px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.auth-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.auth-subtitle {
  font-size: 0.9rem;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.auth-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.auth-tab {
  flex: 1;
  padding: 0.75rem;
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  min-height: 44px;
}

.auth-tab.active {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

.auth-form .form-group {
  margin-bottom: 1rem;
}

.auth-form .form-group:last-of-type {
  margin-bottom: 1.25rem;
}

.auth-form .form-group label {
  margin-bottom: 0.5rem;
}

.auth-form input[type="email"],
.auth-form input[type="password"] {
  display: block;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-size: 16px;
  line-height: 1.25;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.2s;
}

.auth-form input[type="email"]:focus,
.auth-form input[type="password"]:focus {
  outline: none;
  border-color: var(--primary);
}

.auth-form .btn-primary {
  margin-top: 0.5rem;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.25rem 0 1rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  padding: 0 16px;
  font-size: 16px;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-google:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.btn-google:active {
  background: #f1f5f9;
}

.btn-google:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.auth-error {
  margin-top: 0.625rem;
  padding: 0.625rem 0.875rem;
  border-radius: 8px;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 0.875rem;
  line-height: 1.45;
  word-break: break-word;
}

.auth-features {
  margin-top: 0.875rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.auth-features-title {
  margin: 0 0 0.375rem;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text);
}

.auth-features-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.auth-features-item {
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  margin-bottom: 0.2rem;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-muted);
}

.auth-features-item:last-child {
  margin-bottom: 0;
}

.auth-features-check {
  flex: none;
  width: 14px;
  margin-top: 1px;
  color: var(--primary);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.35;
  text-align: center;
}

.auth-legal-links {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.25rem 0.375rem;
  margin-top: 0.625rem;
  padding-top: 0.5rem;
}

.auth-legal-link {
  padding: 0;
  border: none;
  background: none;
  font-size: 12px;
  line-height: 1.3;
  font-weight: 500;
  color: #94a3b8;
  cursor: pointer;
  text-decoration: none;
}

.auth-legal-link:active {
  color: var(--text-muted);
}

.auth-legal-sep {
  font-size: 12px;
  line-height: 1;
  color: #cbd5e1;
  user-select: none;
}

@media (max-width: 767px) {
  #authScreen {
    padding: 0.875rem;
    align-items: flex-start;
    padding-top: 1rem;
  }

  .auth-card {
    padding: 1.125rem 1rem;
  }

  .auth-subtitle {
    margin-bottom: 1rem;
  }

  .auth-tabs {
    margin-bottom: 1rem;
  }

  .auth-divider {
    margin: 1rem 0 0.75rem;
  }

  .auth-features {
    margin-top: 0.75rem;
    padding-top: 0.625rem;
  }

  .auth-legal-links {
    margin-top: 0.5rem;
    padding-top: 0.375rem;
  }
}

/* Legal document modal (login screen) */
.modal-legal .modal-content-legal {
  max-width: 480px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.25rem 1.25rem 1rem;
  overflow: hidden;
}

.legal-modal-title {
  margin: 0 2rem 0.25rem 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.legal-modal-date {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.legal-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.25rem;
}

.legal-modal-section {
  margin-bottom: 1rem;
  padding-bottom: 0.875rem;
  border-bottom: 1px solid #f1f5f9;
}

.legal-modal-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.legal-modal-section-title {
  margin: 0 0 0.375rem;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

.legal-modal-section-text {
  margin: 0 0 0.25rem;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-muted);
}

.legal-modal-section-text:last-child {
  margin-bottom: 0;
}

.legal-modal-bullets {
  margin: 0;
  padding: 0;
  list-style: none;
}

.legal-modal-bullet-item {
  position: relative;
  padding-left: 0.75rem;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.legal-modal-bullet-item::before {
  content: '·';
  position: absolute;
  left: 0;
  font-weight: 700;
  color: #94a3b8;
}

.legal-modal-bullet-item:last-child {
  margin-bottom: 0;
}

.legal-modal-list {
  margin: 0;
  padding-left: 1.125rem;
}

.legal-modal-list-item {
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

.legal-modal-list-item:last-child {
  margin-bottom: 0;
}

.legal-modal-actions {
  margin-top: 0.75rem;
  padding-top: 0.625rem;
  border-top: 1px solid var(--border);
}

.legal-modal-actions .modal-btn {
  flex: none;
  width: 100%;
  min-height: 44px;
}

@media (max-width: 767px) {
  .modal-legal {
    align-items: flex-end;
    padding: 0;
  }

  .modal-legal .modal-content-legal {
    max-width: none;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
    padding: 1rem 1rem 0.875rem;
  }

  .legal-modal-title {
    font-size: 1.05rem;
  }
}

/* Tabs */
.tabs {
  display: flex;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  box-sizing: border-box;
}

.tab {
  flex: 1;
  min-width: 0;
  padding: 1rem 0.625rem;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  min-height: 56px;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab:active {
  background: var(--primary-light);
}

/* Main screen user guide bar */
.main-guide-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.375rem;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.625rem;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  box-sizing: border-box;
}

.btn-main-guide {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  min-height: 34px;
  padding: 0.375rem 0.625rem;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  -webkit-tap-highlight-color: transparent;
}

.btn-main-guide:active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

@media (max-width: 767px) {
  .main-guide-bar {
    padding: 0.4375rem 0.5rem;
    gap: 0.3125rem;
  }

  .btn-main-guide {
    flex: 1 1 calc(50% - 0.3125rem);
    font-size: 0.75rem;
    min-height: 32px;
    padding: 0.3125rem 0.4375rem;
  }
}

@media (max-width: 360px) {
  .btn-main-guide {
    white-space: normal;
    text-align: center;
    line-height: 1.3;
  }
}

/* Panels */
.panel {
  display: none;
  padding: 1.25rem 1rem;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
  overflow-x: hidden;
}

#referral-panel,
#admin-panel,
#payment-panel {
  text-align: center;
}

#referral-panel .referral-card,
#admin-panel .referral-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  text-align: left;
}

#referral-panel .referral-code-row,
#referral-panel .referral-copy-btn,
#admin-panel .admin-referral-actions {
  max-width: 100%;
}

@media (max-width: 767px) {
  .user-email {
    max-width: 9rem;
  }
}

.panel.active {
  display: block;
}

/* Form */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 0.875rem 1rem;
  font-size: 1.05rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  min-height: 52px;
  transition: border-color 0.2s;
  -webkit-appearance: none;
  appearance: none;
}

.form-group select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
}

.form-group input[type="file"] {
  width: 100%;
  padding: 0.75rem;
  font-size: 0.95rem;
  border: 2px dashed var(--primary);
  border-radius: 10px;
  background: var(--primary-light);
  min-height: 52px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

/* Size stock cards */
.size-stock-group {
  margin-bottom: 1rem;
}

.size-stock-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.size-stock-item {
  width: 100%;
  max-width: 100px;
  justify-self: center;
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 0.35rem;
  background: var(--bg);
  transition: border-color 0.2s, background 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.size-stock-item.has-stock {
  border-color: var(--primary);
  background: var(--primary-light);
}

.size-card-label {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 28px;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  user-select: none;
}

.size-stock-item.has-stock .size-card-label {
  color: var(--primary);
}

.size-stock-none .size-card-label {
  font-size: 0.68rem;
  line-height: 1.2;
  min-height: 26px;
  text-align: center;
}

.size-qty-input {
  width: 100%;
  height: 36px;
  min-height: 36px;
  padding: 0.2rem 0.35rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  text-align: center;
  -webkit-appearance: none;
  appearance: none;
}

.size-qty-input:focus {
  outline: none;
  border-color: var(--primary);
}

.size-stock-item.has-stock .size-qty-input {
  border-color: var(--primary);
}

.total-stock-display {
  margin-top: 0.625rem;
  padding: 0.5rem 0.75rem;
  background: var(--primary-light);
  border-radius: 8px;
  font-size: 0.9rem;
  text-align: center;
  color: var(--text);
}

.total-stock-display strong {
  color: var(--primary);
  font-size: 1rem;
}

@media (min-width: 520px) {
  .size-stock-list {
    grid-template-columns: repeat(5, 96px);
    justify-content: start;
    gap: 0.5rem;
  }

  .size-stock-item {
    justify-self: start;
  }

  .size-stock-none {
    grid-column: auto;
  }
}

@media (max-width: 519px) {
  .size-stock-none {
    max-width: 100%;
    grid-column: span 1;
  }
}

.product-stock-detail {
  margin-bottom: 0.75rem;
  padding: 0.75rem;
  background: #f8fafc;
  border-radius: 8px;
  font-size: 0.9rem;
}

.product-stock-detail .stock-title {
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
  font-size: 0.85rem;
}

.product-stock-detail .stock-line {
  padding: 0.125rem 0;
  font-weight: 600;
}

.product-stock-detail .stock-total {
  margin-top: 0.375rem;
  padding-top: 0.375rem;
  border-top: 1px solid var(--border);
  color: var(--primary);
  font-weight: 700;
}

/* Checkbox group (legacy fallback) */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  user-select: none;
}

.checkbox-label input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.checkbox-label:has(input:checked) {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.checkbox-label:active {
  transform: scale(0.97);
}

/* Photo usage quota */
.photo-usage-bar {
  margin: 0.625rem 0 0;
  padding: 0.5rem 0.625rem;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid var(--border);
  text-align: left;
}

.photo-usage-count {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
}

.photo-usage-reset {
  margin: 0.125rem 0 0;
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.photo-usage-bar--warn .photo-usage-count {
  color: #c2410c;
}

.photo-usage-bar--danger .photo-usage-count {
  color: var(--danger);
}

.photo-usage-bar--warn .photo-usage-reset,
.photo-usage-bar--danger .photo-usage-reset {
  color: inherit;
  opacity: 0.85;
}

/* Photo action buttons */
.photo-action-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.photo-add-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.photo-action-row > .photo-action-btn {
  flex: 1;
  min-width: 0;
}

.photo-action-btn {
  width: 100%;
  min-height: 48px;
  font-size: 0.875rem;
  padding: 0.625rem 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-action-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.photo-source-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 30;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.photo-source-menu-item {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 0.875rem;
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.9375rem;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.photo-source-menu-item:last-child {
  border-bottom: none;
}

.photo-source-menu-item:active {
  background: #f1f5f9;
}

.photo-source-menu-item--cancel {
  color: var(--text-muted);
  font-weight: 500;
}

/* Photo preview */
.photo-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.photo-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border);
}

.photo-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-preview-item .photo-name {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.6rem;
  padding: 2px 4px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-preview-item .remove-photo {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.875rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  min-height: 52px;
  transition: background 0.2s, transform 0.1s;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--border);
  color: var(--text);
  width: 100%;
  margin-top: 0.5rem;
}

.btn-outline {
  background: var(--bg);
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 0.625rem 1rem;
  font-size: 0.9rem;
  min-height: 44px;
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  flex: 1;
}

.btn-danger:hover {
  background: var(--danger-dark);
}

.btn-edit {
  background: var(--primary-light);
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  min-height: 44px;
  flex: 1;
}

.btn-clone {
  background: #f5f3ff;
  color: #6d28d9;
  border: 2px solid #8b5cf6;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-height: 44px;
  flex: 1;
}

.clone-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 0.75rem;
  padding: 12px;
  border: 1px solid #c4b5fd;
  border-radius: 8px;
  background: #f5f3ff;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.clone-banner-text {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: #5b21b6;
  line-height: 1.25;
  word-break: keep-all;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clone-cancel-btn {
  flex: none;
  width: 90px;
  height: 36px;
  min-height: 36px;
  padding: 0 0.5rem;
  font-size: 0.8125rem;
  white-space: nowrap;
  line-height: 1;
}

@media (max-width: 360px) {
  .clone-banner-text {
    flex: 1 1 100%;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }

  .clone-cancel-btn {
    margin-left: auto;
  }
}

.btn-delete {
  background: #fef2f2;
  color: var(--danger);
  border: 2px solid var(--danger);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  min-height: 44px;
  flex: 1;
}

.form-actions {
  margin-top: 1.5rem;
}

/* List search */
.list-search {
  margin-bottom: 0.75rem;
}

.list-search-field {
  position: relative;
  display: flex;
  align-items: center;
}

.list-search-input {
  width: 100%;
  height: 48px;
  padding: 0 2.75rem 0 1rem;
  font-size: 16px;
  line-height: 1.25;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}

.list-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.list-search-input::-webkit-search-cancel-button {
  display: none;
}

.list-search-clear {
  position: absolute;
  right: 0.5rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.list-search-clear:active {
  background: #f1f5f9;
  color: var(--text);
}

.list-search-row {
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.list-search-row .list-search-field {
  flex: 1;
  min-width: 0;
}

.list-scan-btn {
  flex: none;
  min-height: 48px;
  padding: 0 0.75rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.form-optional-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.product-barcode-input {
  width: 100%;
  min-height: 44px;
  padding: 0 0.75rem;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  box-sizing: border-box;
}

.barcode-size-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 1rem 0;
}

.barcode-found-barcode {
  margin: 0.25rem 0 0.75rem;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-all;
}

.barcode-found-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
}

.barcode-found-actions .modal-btn {
  width: 100%;
  min-height: 44px;
}

.barcode-size-option-btn {
  min-height: 44px;
  font-size: 0.9375rem;
  font-weight: 700;
}

.barcode-size-options .barcode-size-option-btn:nth-child(4),
.barcode-size-options .barcode-size-option-btn:nth-child(5) {
  grid-column: span 1;
}

@media (min-width: 360px) {
  .barcode-size-options {
    grid-template-columns: repeat(5, 1fr);
  }
}

.modal-content-barcode-scan {
  max-width: min(420px, calc(100vw - 2rem));
  width: 100%;
  box-sizing: border-box;
}

.barcode-scanner-shell {
  position: relative;
  width: 100%;
  max-width: 100%;
  min-height: 280px;
  aspect-ratio: 16 / 10;
  border-radius: 12px;
  overflow: hidden;
  background: #0f172a;
}

.barcode-scanner-viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0f172a;
  box-sizing: border-box;
}

.barcode-scan-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  pointer-events: none;
  z-index: 2;
}

.barcode-scan-overlay.is-visible {
  display: flex;
}

.barcode-scan-overlay-dim {
  flex: 1;
  background: rgba(15, 23, 42, 0.55);
}

.barcode-scan-overlay-middle {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0 8%;
  box-sizing: border-box;
}

.barcode-scan-frame {
  position: relative;
  width: 100%;
  height: 88px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
}

.barcode-scan-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #22c55e;
  border-style: solid;
}

.barcode-scan-corner--tl {
  top: -2px;
  left: -2px;
  border-width: 3px 0 0 3px;
  border-radius: 6px 0 0 0;
}

.barcode-scan-corner--tr {
  top: -2px;
  right: -2px;
  border-width: 3px 3px 0 0;
  border-radius: 0 6px 0 0;
}

.barcode-scan-corner--bl {
  bottom: -2px;
  left: -2px;
  border-width: 0 0 3px 3px;
  border-radius: 0 0 0 6px;
}

.barcode-scan-corner--br {
  bottom: -2px;
  right: -2px;
  border-width: 0 3px 3px 0;
  border-radius: 0 0 6px 0;
}

.barcode-scan-line {
  position: absolute;
  left: 6%;
  right: 6%;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #22c55e, transparent);
  animation: barcode-scan-sweep 2s ease-in-out infinite;
}

@keyframes barcode-scan-sweep {
  0%, 100% { transform: translateY(-36px); opacity: 0.5; }
  50% { transform: translateY(36px); opacity: 1; }
}

.barcode-torch-btn {
  position: absolute;
  top: 0.625rem;
  right: 0.625rem;
  z-index: 3;
  padding: 0.4rem 0.75rem;
  font-size: 0.8125rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.72);
  color: #fff;
  cursor: pointer;
  min-height: 36px;
}

.barcode-torch-btn.is-on {
  background: rgba(34, 197, 94, 0.85);
  border-color: rgba(34, 197, 94, 1);
}

.barcode-scanner-viewport video,
.barcode-scanner-video {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 280px;
  object-fit: cover;
}

.barcode-scanner-viewport #qr-shaded-region,
.barcode-scanner-viewport canvas {
  max-width: 100% !important;
}

.barcode-scan-status {
  margin: 0.625rem 0 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
  word-break: break-word;
  white-space: pre-line;
}

.barcode-manual-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  margin-top: 0.75rem;
  width: 100%;
  box-sizing: border-box;
}

.barcode-manual-input {
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 0 0.75rem;
  font-size: 16px;
  border: 2px solid var(--border);
  border-radius: 10px;
  box-sizing: border-box;
}

.barcode-manual-search-btn {
  width: 100%;
  min-height: 44px;
}

.product-card--barcode-highlight {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.product-barcode-hit-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--primary);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

@media (max-width: 420px) {
  .list-search-row {
    flex-wrap: wrap;
  }

  .list-scan-btn {
    width: 100%;
  }
}

.list-sort {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  margin-bottom: 0.75rem;
}

.list-sort-label {
  flex-shrink: 0;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

.list-sort-select {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 2.25rem 0 0.875rem;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.25;
  border: 2px solid var(--border);
  border-radius: 10px;
  background-color: var(--bg);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.875rem center;
  color: var(--text);
  box-sizing: border-box;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.list-sort-select:focus {
  outline: none;
  border-color: var(--primary);
}

@media (min-width: 768px) {
  .list-sort {
    max-width: 360px;
  }
}

.stock-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 0.75rem;
}

@media (min-width: 768px) {
  .stock-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1024px) {
  .stock-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.stock-summary-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  min-height: 76px;
  height: 100%;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, background 0.2s;
  container-type: inline-size;
}

.stock-summary-card:not([data-summary-filter]) {
  cursor: default;
}

.stock-summary-card:active {
  transform: scale(0.98);
}

.stock-summary-card:not([data-summary-filter]):active {
  transform: none;
}

.stock-summary-card.active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.stock-summary-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.3;
  word-break: keep-all;
  white-space: normal;
}

.stock-summary-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
  max-width: 100%;
}

.stock-summary-card--low {
  border-color: #fdba74;
  background: #fff7ed;
}

.stock-summary-card--low.active {
  border-color: #f97316;
  background: #ffedd5;
}

.stock-summary-card--low .stock-summary-value {
  color: #ea580c;
}

.stock-summary-card--soldout {
  border-color: #fca5a5;
  background: #fef2f2;
}

.stock-summary-card--soldout.active {
  border-color: var(--danger);
  background: #fee2e2;
}

.stock-summary-card--soldout .stock-summary-value {
  color: var(--danger);
}

.stock-summary-card--today {
  border-color: #93c5fd;
  background: #eff6ff;
}

.stock-summary-card--today.active {
  border-color: var(--primary);
  background: #dbeafe;
}

.stock-summary-card--today .stock-summary-value {
  color: var(--primary);
}

.stock-summary-card--revenue {
  border-color: #86efac;
  background: #f0fdf4;
}

.stock-summary-card--revenue .stock-summary-value {
  color: #15803d;
}

.stock-summary-card--profit {
  border-color: #c4b5fd;
  background: #f5f3ff;
}

.stock-summary-card--profit .stock-summary-value {
  color: #6d28d9;
}

#lg-stock-summary .stock-summary-card--stat {
  cursor: default;
  pointer-events: none;
  padding: 0.65rem 0.5rem;
  min-width: 4.5rem;
}

#lg-stock-summary .stock-summary-card--damage {
  border-color: #fdba74;
  background: #fff7ed;
}

#lg-stock-summary .stock-summary-card--damage .stock-summary-value {
  color: #c2410c;
}

#lg-stock-summary .stock-summary-card--loss {
  border-color: #fca5a5;
  background: #fef2f2;
}

#lg-stock-summary .stock-summary-card--loss .stock-summary-value {
  color: #b91c1c;
}

.lg-adjust-type-row {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.lg-adjust-type-option {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9375rem;
  cursor: pointer;
}

.lg-adjust-photo-preview img {
  max-width: 120px;
  max-height: 120px;
  border-radius: 8px;
  margin-top: 0.5rem;
  object-fit: cover;
}

#lg-movement-list .movement-type-in {
  background: #dcfce7;
  color: #15803d;
}

#lg-movement-list .movement-type-out {
  background: #dbeafe;
  color: #1d4ed8;
}

#lg-movement-list .movement-type-damage {
  background: #ffedd5;
  color: #c2410c;
}

#lg-movement-list .movement-type-loss {
  background: #fee2e2;
  color: #b91c1c;
}

#lg-movement-list .movement-item--cancelled {
  opacity: 0.55;
}

#lg-movement-list .movement-cancelled-badge {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

#lg-movement-list .movement-evidence-thumb {
  margin-top: 0.35rem;
}

#lg-movement-list .movement-evidence-thumb img {
  max-width: 72px;
  max-height: 72px;
  border-radius: 6px;
  object-fit: cover;
}

#lg-movement-list .movement-cancel-btn {
  margin-top: 0.35rem;
  font-size: 0.8125rem;
  padding: 0.35rem 0.65rem;
}

.form-label-block {
  display: block;
  font-weight: 600;
  margin-bottom: 0.35rem;
  font-size: 0.9375rem;
}

.stock-summary-value--money {
  word-break: keep-all;
  white-space: nowrap;
  font-size: 18px;
}

.stock-summary-value--money.stock-summary-value--compact {
  font-size: 15px;
}

.stock-summary-value--money.stock-summary-value--tight {
  font-size: 13px;
}

@container (max-width: 130px) {
  .stock-summary-value--money {
    font-size: 15px;
  }
}

@container (max-width: 110px) {
  .stock-summary-value--money {
    font-size: 13px;
  }
}

.movement-amounts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.movement-amounts span {
  color: var(--text-muted);
}

.movement-amounts span strong {
  color: var(--text);
  font-weight: 700;
}

/* List toolbar */
.list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.list-toolbar .btn-outline {
  flex: 1 1 calc(50% - 0.25rem);
  min-width: 0;
  min-height: 44px;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  line-height: 1.25;
  text-align: center;
  white-space: normal;
  word-break: keep-all;
}

@media (min-width: 640px) {
  .list-toolbar {
    flex-wrap: nowrap;
  }

  .list-toolbar .btn-outline {
    flex: 1 1 0;
  }
}

/* Product list */
.product-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.empty-message {
  text-align: center;
  color: var(--text-muted);
  padding: 3rem 1rem;
  font-size: 1rem;
}

.product-card {
  border: 2px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.product-card-low-stock {
  border-color: #f97316;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.18);
}

.product-card-header-low-stock {
  background: #ffedd5;
}

.product-card-header {
  background: var(--primary-light);
  padding: 0.75rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.product-card-header-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.product-soldout-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: var(--danger);
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.product-low-stock-badge {
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  background: #f97316;
  padding: 0.2rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.stock-line-soldout {
  color: var(--text-muted);
}

.stock-soldout-label {
  color: var(--danger);
  font-weight: 700;
}

.product-code {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}

.product-type-badge {
  font-size: 0.8rem;
  background: var(--primary);
  color: #fff;
  padding: 0.25rem 0.625rem;
  border-radius: 20px;
  font-weight: 600;
  flex-shrink: 0;
  max-width: 48%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-category-block {
  margin-bottom: 0.75rem;
}

.product-sub-category {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.product-main-category {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.product-card-body {
  padding: 1rem;
}

.product-name {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.product-info {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.25rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
}

.product-info dt {
  color: var(--text-muted);
  font-weight: 500;
}

.product-info dd {
  font-weight: 600;
}

.product-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.product-photo-thumb {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
  position: relative;
}

.product-photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-photo-thumb .filename {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 0.55rem;
  padding: 1px 3px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0 1rem 1rem;
}

.btn-stock {
  background: #ecfdf5;
  color: #059669;
  border: 2px solid #059669;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-height: 44px;
  flex: 1;
  min-width: calc(50% - 0.25rem);
}

.btn-sale {
  background: #fff7ed;
  color: #ea580c;
  border: 2px solid #ea580c;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-height: 44px;
  flex: 1;
  min-width: calc(50% - 0.25rem);
}

.btn-history {
  background: #eff6ff;
  color: #2563eb;
  border: 2px solid #2563eb;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-height: 44px;
  flex: 1;
  min-width: calc(50% - 0.25rem);
}

.btn-adjust {
  background: #fff7ed;
  color: #c2410c;
  border: 2px solid #ea580c;
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
  min-height: 44px;
  flex: 1;
  min-width: calc(50% - 0.25rem);
}

.product-card-actions .btn-adjust {
  min-width: calc(50% - 0.25rem);
}

.product-card-actions .btn-edit,
.product-card-actions .btn-clone,
.product-card-actions .btn-stock,
.product-card-actions .btn-sale,
.product-card-actions .btn-adjust,
.product-card-actions .btn-history,
.product-card-actions .btn-delete {
  min-width: calc(50% - 0.25rem);
}

.product-card-actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.list-toolbar .btn-outline:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Stock intake / sale modal */
.modal-content-stock {
  position: relative;
  max-width: 340px;
  max-height: 85vh;
  overflow-y: auto;
  text-align: left;
  padding: 1.25rem;
}

.modal-close-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:active {
  background: #f1f5f9;
  color: var(--text);
}

.stock-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem !important;
  text-align: center;
}

.modal-content-stock .modal-product-name {
  text-align: center;
  margin-bottom: 1rem !important;
  font-size: 0.95rem;
}

.stock-intake-list {
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin-bottom: 1rem;
}

.stock-intake-item {
  display: grid;
  grid-template-columns: 44px 1fr 88px;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.stock-intake-size {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.stock-intake-current {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.stock-add-input {
  width: 100%;
  height: 40px;
  padding: 0.375rem 0.5rem;
  font-size: 0.95rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  text-align: center;
  background: var(--bg);
  -webkit-appearance: none;
  appearance: none;
}

.stock-add-input:focus {
  outline: none;
  border-color: var(--primary);
}

.stock-add-input::placeholder {
  color: #94a3b8;
  font-size: 0.8rem;
}

.modal-content-movement {
  max-width: 420px;
}

.movement-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 50vh;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.movement-loading,
.movement-empty,
.movement-error {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.95rem;
  color: var(--text-muted);
}

.movement-error {
  color: var(--danger);
}

.movement-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem;
  background: #f8fafc;
}

.movement-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.movement-datetime {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.movement-type {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
}

.movement-type-in {
  background: #dcfce7;
  color: #15803d;
}

.movement-type-out {
  background: #fee2e2;
  color: #b91c1c;
}

.movement-item-body {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.movement-size {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.movement-qty-in {
  font-size: 1.1rem;
  font-weight: 700;
  color: #15803d;
}

.movement-qty-out {
  font-size: 1.1rem;
  font-weight: 700;
  color: #dc2626;
}

.movement-note {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  word-break: break-word;
}

.movement-product-ref {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.5rem;
  word-break: break-word;
}

.modal-all-movements .modal-content-all-movements {
  max-width: 720px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.25rem;
  overflow: hidden;
}

.all-movements-period-bar {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 0.75rem;
  padding-bottom: 0.25rem;
  scrollbar-width: none;
}

.all-movements-period-bar::-webkit-scrollbar {
  display: none;
}

.all-movements-period-btn {
  flex: 0 0 auto;
  min-height: 40px;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 600;
  border: 2px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  white-space: nowrap;
}

.all-movements-period-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.all-movements-search {
  margin-bottom: 0.75rem;
}

.all-movements-list {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  margin-bottom: 1rem;
}

.all-movements-actions {
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .modal-all-movements {
    padding: 0;
    align-items: stretch;
  }

  .modal-all-movements .modal-content-all-movements {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .all-movements-actions {
    flex-direction: column;
  }

  .all-movements-actions .modal-btn {
    width: 100%;
  }
}

/* Usage guide modal (main screen) */
.modal-usage-guide .modal-content-usage-guide {
  max-width: 420px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.25rem 1.25rem 1rem;
  overflow: hidden;
}

.usage-guide-modal-title {
  margin: 0 2rem 0.875rem 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.usage-guide-steps {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0;
  padding: 0;
  list-style: none;
}

.usage-guide-step {
  display: flex;
  align-items: flex-start;
  gap: 0.375rem;
  margin-bottom: 0.625rem;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--text);
}

.usage-guide-step-num {
  flex: none;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.5;
}

.usage-guide-step:last-child {
  margin-bottom: 0;
}

.usage-guide-pc-notice {
  margin: 0.75rem 0 0;
  padding: 0.5rem 0.625rem;
  border-radius: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-size: 0.8125rem;
  font-weight: 600;
  line-height: 1.45;
  word-break: keep-all;
  overflow-wrap: anywhere;
}

.usage-guide-modal-actions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.usage-guide-modal-actions .modal-btn {
  flex: none;
  width: 100%;
  min-height: 44px;
}

@media (max-width: 767px) {
  .modal-usage-guide {
    align-items: flex-end;
    padding: 0;
  }

  .modal-usage-guide .modal-content-usage-guide {
    max-width: none;
    max-height: 88vh;
    border-radius: 14px 14px 0 0;
    padding: 1rem 1rem 0.875rem;
  }

  .usage-guide-step {
    font-size: 0.9375rem;
  }

  .usage-guide-pc-notice {
    font-size: 0.8125rem;
    padding: 0.4375rem 0.5625rem;
  }
}

/* Help modal */
.modal-help .modal-content-help {
  max-width: 520px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.25rem 1.25rem 1rem;
  overflow: hidden;
}

.help-modal-title {
  margin: 0 2rem 1rem 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
  text-align: center;
}

.help-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.25rem;
}

.help-section {
  margin-bottom: 1rem;
}

.help-section:last-child {
  margin-bottom: 0;
}

.help-section-title {
  margin: 0 0 0.375rem;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--primary);
}

.help-section-text {
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}

.help-section-note {
  margin-top: 0.25rem;
  color: var(--text-muted);
  font-size: 0.8125rem;
}

.help-section-list {
  margin: 0;
  padding-left: 1.125rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: var(--text);
}

.help-section-list li + li {
  margin-top: 0.25rem;
}

.help-section-list strong {
  font-weight: 700;
}

.help-privacy-notice {
  margin: 0 0 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 0.8125rem;
  line-height: 1.5;
}

.help-kakao-cards {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.help-kakao-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 1rem;
  border: none;
  border-radius: 10px;
  background: #fee500;
  color: #191919;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.help-kakao-btn:active {
  opacity: 0.88;
}

.help-kakao-btn--admin {
  background: #fff;
  border: 2px solid #fee500;
}

.help-kakao-card-desc {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--text-muted);
}

.help-kakao-id-block {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--border);
}

.help-kakao-id-label {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--text);
}

.help-kakao-id-label strong {
  font-weight: 700;
  color: var(--primary);
}

.help-kakao-copy-btn {
  width: 100%;
  min-height: 44px;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
}

.help-kakao-id-guide strong {
  font-weight: 700;
  color: var(--text);
}

.help-modal-actions {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border, #e5e7eb);
}

.help-modal-actions .modal-btn {
  flex: none;
  width: 100%;
  min-height: 44px;
}

@media (max-width: 767px) {
  .modal-help {
    align-items: flex-end;
    padding: 0;
  }

  .modal-help .modal-content-help {
    max-width: none;
    max-height: 92vh;
    border-radius: 14px 14px 0 0;
    padding: 1rem 1rem 0.875rem;
  }

  .help-modal-title {
    font-size: 1.05rem;
    margin-bottom: 0.875rem;
  }

  .help-section-title {
    font-size: 0.9375rem;
  }

  .help-section-text,
  .help-section-list {
    font-size: 0.9375rem;
  }

  .help-privacy-notice {
    font-size: 0.875rem;
  }

  .help-kakao-btn {
    font-size: 1rem;
    min-height: 48px;
  }

  .help-kakao-card-desc {
    font-size: 0.875rem;
  }

  .help-kakao-copy-btn {
    min-height: 48px;
    font-size: 1rem;
  }
}

/* Excel import modal */
.modal-import-excel .modal-content-import-excel {
  max-width: 960px;
  width: 100%;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 1.25rem;
  overflow: hidden;
}

.import-excel-file-name {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  word-break: break-all;
}

.import-excel-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.import-excel-summary-item {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
}

.import-excel-summary-item--valid {
  background: #dcfce7;
  color: #15803d;
}

.import-excel-summary-item--error {
  background: #fee2e2;
  color: #b91c1c;
}

.import-excel-summary-item--duplicate {
  background: #fef3c7;
  color: #b45309;
}

.import-duplicate-policy {
  margin-bottom: 0.75rem;
  padding: 0.875rem;
  border: 2px solid #fde68a;
  border-radius: 10px;
  background: #fffbeb;
}

.import-duplicate-policy-title {
  margin: 0 0 0.5rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
}

.import-duplicate-policy-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
}

.import-duplicate-option {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.import-duplicate-option input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.import-excel-preview-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  border: 2px solid var(--border);
  border-radius: 10px;
}

.import-excel-preview-table {
  width: 100%;
  min-width: 640px;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.import-excel-preview-table th,
.import-excel-preview-table td {
  padding: 0.625rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  word-break: keep-all;
}

.import-excel-preview-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

.import-excel-preview-table tbody tr:last-child td {
  border-bottom: none;
}

.import-excel-preview-table tr.is-error {
  background: #fef2f2;
}

.import-excel-preview-table tr.is-duplicate {
  background: #fffbeb;
}

.import-excel-preview-table tr.is-valid {
  background: #fff;
}

.import-status-badge {
  display: inline-block;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}

.import-status-badge--valid {
  background: #dcfce7;
  color: #15803d;
}

.import-status-badge--error {
  background: #fee2e2;
  color: #b91c1c;
}

.import-status-badge--duplicate {
  background: #fef3c7;
  color: #b45309;
}

.import-excel-note {
  color: var(--text-muted);
  font-size: 0.75rem;
  line-height: 1.4;
}

.import-excel-actions {
  flex-shrink: 0;
}

@media (max-width: 767px) {
  .modal-import-excel {
    padding: 0;
    align-items: stretch;
  }

  .modal-import-excel .modal-content-import-excel {
    max-width: none;
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
  }

  .import-excel-actions {
    display: flex;
    gap: 0.5rem;
  }

  .import-excel-actions .modal-btn {
    flex: 1;
    min-height: 44px;
    font-size: 16px;
  }
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  pointer-events: none;
}

.modal.is-open {
  display: flex;
  pointer-events: auto;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 0;
}

.modal-content {
  position: relative;
  z-index: 1;
  background: var(--bg);
  border-radius: 14px;
  padding: 1.5rem;
  width: 100%;
  max-width: 360px;
  text-align: center;
  pointer-events: auto;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.modal-content p {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.modal-product-name {
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 1.25rem !important;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
}

.modal-actions .modal-btn {
  flex: 1;
  width: auto;
  min-width: 0;
  margin-top: 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 0.875rem 1.5rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  z-index: 300;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  max-width: min(calc(100vw - 2rem), 360px);
  text-align: center;
  word-break: keep-all;
  white-space: normal;
  animation: toast-in 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(1rem);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

body.auth-checking #authCheckingScreen {
  display: flex !important;
}

body.auth-checking #authScreen,
body.auth-checking #appScreen,
body.auth-checking #programSelectScreen,
body.auth-checking #excelMergeScreen {
  display: none !important;
}

body.auth-visible #authScreen {
  display: flex !important;
}

body.auth-visible #appScreen,
body.auth-visible #programSelectScreen,
body.auth-visible #excelMergeScreen {
  display: none !important;
}

body.authenticated #authScreen {
  display: none !important;
}

body.authenticated #authCheckingScreen {
  display: none !important;
}

body.authenticated.program-select #programSelectScreen {
  display: block !important;
}

body.authenticated.program-select #appScreen,
body.authenticated.program-select #excelMergeScreen,
body.authenticated.program-select #logisticsScreen {
  display: none !important;
}

body.authenticated.program-inventory #appScreen {
  display: block !important;
}

body.authenticated.program-inventory #programSelectScreen,
body.authenticated.program-inventory #excelMergeScreen,
body.authenticated.program-inventory #logisticsScreen {
  display: none !important;
}

body.authenticated.program-logistics #logisticsScreen {
  display: block !important;
}

body.authenticated.program-logistics #programSelectScreen,
body.authenticated.program-logistics #appScreen,
body.authenticated.program-logistics #excelMergeScreen {
  display: none !important;
}

body.authenticated.program-excel-merge #excelMergeScreen {
  display: block !important;
}

body.authenticated.program-excel-merge #programSelectScreen,
body.authenticated.program-excel-merge #appScreen,
body.authenticated.program-excel-merge #logisticsScreen {
  display: none !important;
}

/* Program selection dashboard */
.program-select-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 1rem 1rem 1.5rem;
  box-sizing: border-box;
}

.program-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  align-items: stretch;
}

.program-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 0.875rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  min-width: 0;
}

.program-card-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
  line-height: 1.35;
  word-break: keep-all;
}

.program-card-desc {
  margin: 0;
  flex: 1 1 auto;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
  word-break: keep-all;
}

.program-card-features {
  margin: 0;
  padding: 0;
  list-style: none;
  flex: 1 1 auto;
}

.program-card-features li {
  position: relative;
  padding-left: 1.125rem;
  margin-bottom: 0.5rem;
  font-size: 0.9375rem;
  color: var(--text-muted);
  line-height: 1.45;
  word-break: keep-all;
}

.program-card-features li:last-child {
  margin-bottom: 0;
}

.program-card-features li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary);
  font-weight: 700;
}

.program-card-btn {
  width: 100%;
  margin-top: auto;
  white-space: normal;
  word-break: keep-all;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  font-size: 0.875rem;
}

.excel-merge-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1rem 2.5rem;
  box-sizing: border-box;
}

.em-section {
  margin-bottom: 1rem;
}

.em-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1rem 1.125rem;
  box-shadow: var(--shadow);
}

.em-section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.em-hint {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.em-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.em-select {
  width: 100%;
  max-width: 320px;
  padding: 0.5rem 0.625rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  background: #fff;
  color: var(--text);
}

.btn-sm {
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Dropzone */
.em-dropzone {
  border: 2px dashed var(--primary-light);
  background: #f8fafc;
  border-radius: 12px;
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.em-dropzone:hover,
.em-dropzone.is-dragover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.em-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.em-dropzone-text {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text);
}

.em-dropzone-hint {
  margin: 0.375rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.em-file-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.em-file-count {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}

.em-file-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.em-file-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
  min-width: 0;
}

.em-file-item.is-error {
  border-color: #fecaca;
  background: #fef2f2;
}

.em-file-info {
  flex: 1 1 auto;
  min-width: 0;
}

.em-file-name {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  word-break: break-all;
}

.em-file-meta {
  display: block;
  margin-top: 0.2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.em-file-error {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--danger);
  word-break: keep-all;
}

.em-file-remove {
  flex: none;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  color: var(--text-muted);
  cursor: pointer;
}

.em-file-remove:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* Merge mode cards */
.em-mode-cards {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.em-mode-card {
  display: block;
  cursor: pointer;
}

.em-mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.em-mode-card-body {
  display: block;
  padding: 0.75rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  transition: border-color 0.15s, background 0.15s;
}

.em-mode-card-body strong {
  display: block;
  font-size: 0.875rem;
  color: var(--primary-dark);
  margin-bottom: 0.25rem;
}

.em-mode-card-body span {
  display: block;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.em-mode-card input:checked + .em-mode-card-body {
  border-color: var(--primary);
  background: var(--primary-light);
}

.em-join-key-wrap {
  margin-top: 0.875rem;
  padding-top: 0.875rem;
  border-top: 1px solid var(--border);
}

/* Column analysis */
.em-column-analysis {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.em-col-file-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.625rem 0.75rem;
  background: #f8fafc;
}

.em-col-file-title {
  margin: 0 0 0.5rem;
  font-size: 0.8125rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

.em-col-rows {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.em-col-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  min-width: 0;
}

.em-col-original {
  flex: 0 0 auto;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  min-width: 4rem;
}

.em-col-badge {
  flex: none;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 0.125rem 0.375rem;
  border-radius: 999px;
}

.em-col-badge--auto {
  background: #dcfce7;
  color: #15803d;
}

.em-col-badge--review {
  background: #fee2e2;
  color: #b91c1c;
}

.em-col-map-select {
  flex: 1 1 140px;
  min-width: 120px;
  max-width: 240px;
  padding: 0.3rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.8125rem;
}

.em-col-map-select.is-review {
  border-color: #fca5a5;
}

/* Cleanup */
.em-cleanup-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem 1rem;
}

.em-check {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text);
  cursor: pointer;
}

.em-check input {
  flex: none;
  accent-color: var(--primary);
}

/* Preview */
.em-preview-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.em-preview-stats {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.em-preview-source-counts {
  margin-bottom: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.em-warnings {
  margin-bottom: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  font-size: 0.8125rem;
  color: #9a3412;
  line-height: 1.45;
}

.em-warnings ul {
  margin: 0.25rem 0 0;
  padding-left: 1.125rem;
}

.em-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 100%;
}

.em-preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.75rem;
  min-width: 480px;
}

.em-preview-table th,
.em-preview-table td {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.em-preview-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  position: sticky;
  top: 0;
}

.em-preview-table th.is-review {
  background: var(--danger);
}

.em-preview-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.em-download-section {
  text-align: center;
}

.em-download-btn {
  min-width: 200px;
}

.em-download-hint {
  margin-top: 0.5rem;
  font-size: 0.8125rem;
}

.em-final-count {
  margin-bottom: 0.75rem;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--primary);
}

/* Inspection summary */
.em-inspect-summary {
  margin-bottom: 1rem;
}

.em-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem 0.75rem;
  margin-bottom: 0.75rem;
}

.em-summary-item {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.625rem;
  background: #f8fafc;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 0.8125rem;
}

.em-summary-label {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.em-status-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .em-status-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

.em-status-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.5rem;
  border-radius: 8px;
  font-size: 0.75rem;
  border: 1px solid var(--border);
}

.em-status-card strong {
  font-size: 1.125rem;
}

.em-status-normal { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.em-status-review { background: #fff7ed; border-color: #fed7aa; color: #9a3412; }
.em-status-exclude { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.em-status-file { background: #f1f5f9; border-color: #cbd5e1; color: #475569; }

.em-mode-card-highlight {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.em-collect-notice {
  margin-bottom: 0.75rem;
  padding: 0.75rem 0.875rem;
  border-radius: 10px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
}

.em-collect-notice-text {
  margin: 0 0 0.625rem;
  font-size: 0.875rem;
  line-height: 1.5;
  color: #1e3a8a;
}

.em-collect-notice-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.em-show-source-label {
  font-size: 0.8125rem;
}

.em-bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin-bottom: 0.75rem;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

.em-file-errors {
  margin-bottom: 0.625rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  font-size: 0.8125rem;
  color: #991b1b;
}

.em-file-errors ul {
  margin: 0.25rem 0 0;
  padding-left: 1.125rem;
}

.em-inspect-table-scroll {
  max-height: min(70vh, 520px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.em-inspect-table th.em-sticky-col,
.em-inspect-table td.em-sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: inherit;
}

.em-inspect-table td.em-row-action {
  left: 2.5rem;
  min-width: 72px;
}

.em-inspect-table th.em-sticky-col:first-child,
.em-inspect-table td.em-row-num {
  left: 0;
  min-width: 2.5rem;
  text-align: center;
  background: #f1f5f9;
  font-weight: 600;
}

.em-inspect-table thead th {
  position: sticky;
  top: 0;
  z-index: 3;
}

.em-inspect-table thead th.em-sticky-col {
  z-index: 4;
}

.em-cell-error {
  background: #fef2f2 !important;
}

.em-cell-review {
  background: #fff7ed !important;
}

.em-cell-edited {
  background: #f0fdf4 !important;
}

.em-cell-hint {
  display: block;
  font-size: 0.625rem;
  color: #64748b;
  margin-top: 0.125rem;
  white-space: normal;
  max-width: 160px;
  line-height: 1.2;
}

.em-row-action-select {
  font-size: 0.6875rem;
  padding: 0.125rem 0.25rem;
  max-width: 64px;
}

.em-cell-edit-input {
  width: 100%;
  min-width: 60px;
  max-width: 140px;
  font-size: 0.75rem;
  padding: 0.125rem 0.25rem;
  border: 1px solid var(--primary);
  border-radius: 4px;
}

.em-row-excluded {
  opacity: 0.55;
}

.em-row-review {
  background: #fffbeb;
}

.em-row-flagged-exclude {
  background: #fef2f2;
}

/* Loading overlay */
.em-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.em-loading-box {
  background: #fff;
  border-radius: 14px;
  padding: 1.5rem 2rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.em-loading-spinner {
  width: 36px;
  height: 36px;
  margin: 0 auto 0.75rem;
  border: 3px solid var(--primary-light);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: em-spin 0.7s linear infinite;
}

@keyframes em-spin {
  to { transform: rotate(360deg); }
}

.em-loading-text {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text);
}

@media (max-width: 640px) {
  .em-cleanup-grid {
    grid-template-columns: 1fr;
  }

  .em-col-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .em-col-map-select {
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 720px) {
  .program-cards {
    grid-template-columns: 1fr;
  }

  .program-select-main {
    padding: 0.875rem 0.875rem 1.25rem;
  }
}

/* Referral */
.label-optional {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.referral-card {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}

.referral-section-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.referral-code-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.referral-code-text {
  flex: 1;
  min-width: 0;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  word-break: break-all;
}

.referral-copy-btn {
  flex: none;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
}

.referral-link-hint {
  margin: 0.625rem 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.referral-progress-text {
  margin: 0 0 0.375rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
}

.referral-progress-text strong {
  color: var(--primary);
}

.referral-progress-hint,
.admin-panel-hint,
.referral-rewards-total {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.45;
  word-break: keep-all;
}

.referral-rewards-total {
  margin-bottom: 0.75rem;
}

.referral-rewards-total strong {
  color: var(--primary);
}

.referral-rewards-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.referral-rewards-list li {
  padding: 0.625rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--text);
}

.referral-rewards-list li:last-child {
  border-bottom: none;
}

.referral-rewards-empty {
  color: var(--text-muted);
  padding: 0.5rem 0;
}

.admin-referral-list,
.admin-payment-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.admin-referral-item,
.admin-payment-item {
  padding: 0.875rem;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #f8fafc;
}

.admin-referral-item-top,
.admin-payment-item-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.admin-referral-email,
.admin-payment-email {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

.admin-referral-status,
.admin-payment-status {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
}

.admin-referral-status--pending,
.admin-payment-status--pending {
  background: #fef3c7;
  color: #b45309;
}

.admin-referral-status--confirmed,
.admin-payment-status--confirmed {
  background: #dcfce7;
  color: #15803d;
}

.admin-payment-status--rejected {
  background: #fee2e2;
  color: #b91c1c;
}

.admin-payment-status--revoked {
  background: #f1f5f9;
  color: #64748b;
}

.admin-payment-section + .admin-payment-section {
  margin-top: 1rem;
}

.admin-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.admin-section-header .referral-section-title {
  margin: 0;
  text-align: left;
}

.admin-refresh-btn {
  flex: none;
  min-height: 34px;
  padding: 0.375rem 0.625rem;
  font-size: 0.8125rem;
  white-space: nowrap;
}

.admin-payment-error {
  margin: 0 0 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: left;
  word-break: break-word;
}

.admin-payment-meta div + div {
  margin-top: 0.125rem;
}

.admin-payment-item--recent {
  background: #fff;
}

.admin-referral-meta,
.admin-payment-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
  line-height: 1.4;
  word-break: keep-all;
}

.admin-referral-actions,
.admin-payment-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.admin-referral-actions .btn,
.admin-payment-actions .btn {
  flex: 1 1 auto;
  min-height: 44px;
  min-width: min(100%, 120px);
}

/* Payment panel */
.payment-section-title {
  margin: 0 0 0.375rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text);
}

.payment-section-hint {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.payment-plans-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
  width: 100%;
  max-width: 100%;
}

@media (min-width: 400px) {
  .payment-plans-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .payment-plan-card {
    padding: 0.75rem 0.375rem;
  }

  .payment-plan-name {
    font-size: 0.875rem;
  }

  .payment-plan-price {
    font-size: 0.9375rem;
    margin-bottom: 0.375rem;
  }

  .payment-plan-limit {
    font-size: 0.6875rem;
    line-height: 1.35;
  }
}

@media (min-width: 768px) {
  .payment-plans-grid {
    gap: 0.75rem;
  }

  .payment-plan-card {
    padding: 1rem 0.875rem;
  }

  .payment-plan-name {
    font-size: 1rem;
  }

  .payment-plan-price {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
  }

  .payment-plan-limit {
    font-size: 0.8125rem;
    line-height: 1.4;
  }
}

.payment-plan-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 1rem 0.875rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #fff;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.payment-plan-card:active,
.payment-plan-card.is-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-light);
}

.payment-plan-name {
  margin: 0 0 0.375rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.payment-plan-price {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
}

.payment-plan-period {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.payment-plan-limit {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.payment-plan-limits {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.payment-plan-limit + .payment-plan-limit {
  margin-top: 0;
}

.payment-selected-plan {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.payment-selected-plan-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.payment-selected-plan-price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
}

.payment-bank-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 2px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  text-align: left;
}

.payment-bank-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.375rem 0;
  font-size: 0.875rem;
}

.payment-bank-row + .payment-bank-row {
  border-top: 1px solid var(--border);
}

.payment-bank-label {
  flex: none;
  color: var(--text-muted);
  font-weight: 600;
}

.payment-bank-value {
  flex: 1;
  min-width: 0;
  text-align: right;
  font-weight: 700;
  color: var(--text);
  word-break: break-all;
}

.payment-bank-value--amount {
  color: var(--primary);
  font-size: 1rem;
}

.payment-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
}

.payment-actions .btn {
  width: 100%;
  min-height: 44px;
}

#payment-detail-view .form-group {
  text-align: left;
  width: 100%;
  max-width: 100%;
}

.payment-pending-card {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  padding: 1.25rem 1rem;
  border: 2px solid var(--primary-light);
  border-radius: 12px;
  background: #eff6ff;
  text-align: center;
}

.payment-pending-badge {
  margin: 0 0 0.5rem;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--primary);
}

.payment-pending-hint {
  margin: 0 0 1rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.45;
}

.payment-pending-details {
  text-align: left;
  border-top: 1px solid var(--border);
  padding-top: 0.75rem;
}

.payment-pending-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.375rem 0;
  font-size: 0.875rem;
  color: var(--text-muted);
}

.payment-pending-row strong {
  color: var(--text);
  font-weight: 700;
  text-align: right;
  word-break: break-all;
}

/* Logistics */
#logisticsScreen {
  display: none;
}

.logistics-main {
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
  box-sizing: border-box;
}

#logisticsScreen .logistics-panel {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 1.25rem 1rem 1.5rem;
}

.logistics-panel .form-group textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  resize: vertical;
  min-height: 3rem;
}

.lg-readonly-code {
  background: var(--bg-muted, #f5f5f5);
  color: var(--text-muted);
}

.lg-unit-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr));
  gap: 0.5rem;
}

.lg-unit-option {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.875rem;
  cursor: pointer;
  user-select: none;
  min-height: 2.25rem;
  box-sizing: border-box;
}

.lg-unit-option:has(input:checked) {
  border-color: var(--primary, #2563eb);
  background: rgba(37, 99, 235, 0.06);
}

.lg-unit-option input {
  margin: 0;
  flex-shrink: 0;
}

.lg-unit-custom-wrap {
  margin-top: 0.65rem;
}

.lg-unit-custom-wrap label {
  display: block;
  font-size: 0.82rem;
  margin-bottom: 0.3rem;
}

.lg-unit-custom-wrap input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.lg-spec-row {
  display: grid;
  grid-template-columns: 1fr minmax(6.5rem, 8rem);
  gap: 0.5rem;
}

.lg-spec-value-input,
.lg-spec-unit-select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.lg-stock-display {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.lg-stock-current-line,
.lg-stock-spec-line {
  font-size: 0.85rem;
}

.lg-stock-spec-line {
  color: var(--text-muted, #64748b);
}

.lg-spec-preview {
  margin: 0.5rem 0 0;
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  background: #eff6ff;
  color: #1e3a8a;
  font-size: 0.85rem;
}

.lg-stock-total-line {
  margin-top: 0.25rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: #ecfdf5;
  color: #065f46;
  font-size: 0.82rem;
  font-weight: 600;
}

#logisticsScreen .list-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

#logisticsScreen .list-toolbar .list-sort {
  margin-bottom: 0;
}

.lg-unit-stocks-panel {
  margin-bottom: 1rem;
}

.lg-unit-stocks-rows {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.lg-unit-stock-row {
  display: grid;
  grid-template-columns: minmax(4rem, 5.5rem) 1fr 1fr;
  gap: 0.5rem;
  align-items: end;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-muted, #f8fafc);
}

.lg-unit-stock-row-label {
  font-weight: 600;
  font-size: 0.9rem;
  padding-bottom: 0.5rem;
  word-break: keep-all;
}

.lg-unit-stock-row .form-group {
  margin: 0;
}

.lg-unit-stock-row .form-group label {
  font-size: 0.78rem;
  margin-bottom: 0.25rem;
}

.lg-unit-stock-row .form-group input {
  width: 100%;
  box-sizing: border-box;
}

.lg-unit-custom-name {
  grid-column: 1 / -1;
}

.lg-unit-custom-name input {
  width: 100%;
  box-sizing: border-box;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.lg-unit-stock-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0.35rem 0 0.5rem;
}

.lg-unit-stock-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.5rem;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  background: var(--bg-muted, #f1f5f9);
  font-size: 0.85rem;
}

.lg-unit-stock-item--low {
  background: #fff7ed;
  border: 1px solid #fdba74;
}

.lg-unit-stock-item--soldout {
  background: #fef2f2;
  border: 1px solid #fecaca;
  opacity: 0.85;
}

.lg-unit-stock-item-name {
  font-weight: 600;
  min-width: 2.5rem;
}

.lg-unit-stock-item-qty {
  color: var(--text-muted, #64748b);
}

.lg-unit-stock-item-badge {
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: #fed7aa;
  color: #9a3412;
}

.lg-movement-unit-select {
  width: 100%;
  box-sizing: border-box;
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
}

.product-type-badge--multi {
  font-size: 0.75rem;
}

@media (max-width: 480px) {
  .lg-unit-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .lg-unit-stock-row {
    grid-template-columns: 1fr 1fr;
  }

  .lg-unit-stock-row-label {
    grid-column: 1 / -1;
    padding-bottom: 0;
  }

  .lg-unit-custom-name {
    grid-column: 1 / -1;
  }
}

@media (min-width: 768px) {
  .lg-unit-options {
    grid-template-columns: repeat(5, 1fr);
  }
}

@media (max-width: 767px) {
  .tab {
    padding: 0.75rem 0.5rem;
    font-size: 0.875rem;
    min-height: 48px;
  }
}

.en-date-wrap {
  position: relative;
  width: 100%;
}

.en-date-wrap .en-date-input {
  width: 100%;
  padding-right: 2.75rem;
  cursor: pointer;
  background: var(--bg);
}

.en-date-toggle {
  position: absolute;
  top: 50%;
  right: 0.5rem;
  transform: translateY(-50%);
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--text-muted);
}

.en-date-popup {
  position: fixed;
  z-index: 400;
  box-sizing: border-box;
  padding: 0.75rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.18);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.en-date-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.en-date-title {
  flex: 1;
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  font-weight: 700;
}

.en-date-nav {
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.en-date-weekdays,
.en-date-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.2rem;
}

.en-date-weekdays span {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.en-date-empty {
  min-height: 2.1rem;
}

.en-date-day {
  min-height: 2.1rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
}

.en-date-day.is-today {
  box-shadow: inset 0 0 0 1.5px var(--primary);
}

.en-date-day.is-selected {
  background: var(--primary);
  color: #fff;
}

.en-date-footer {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

.en-date-footer-btn {
  min-height: 2.25rem;
  padding: 0 0.85rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font-size: 0.875rem;
  cursor: pointer;
}

.en-date-footer-btn--today {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}
