:root {
  color-scheme: light;
  --bg: #eef2f5;
  --ink: #111418;
  --muted: #69727d;
  --line: #d9e0e7;
  --panel: rgba(255, 255, 255, 0.88);
  --panel-solid: #ffffff;
  --dark: #11161c;
  --accent: #247c8f;
  --ok: #167256;
  --warn: #9b6a14;
  --bad: #a23d35;
  --shadow: 0 28px 78px rgba(17, 22, 28, 0.14);
  --soft-shadow: 0 14px 36px rgba(17, 22, 28, 0.08);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 255, 255, 0.95), transparent 26%),
    linear-gradient(135deg, #f8fafb 0%, #eef2f5 48%, #e5ebf0 100%);
  font-family:
    ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  font-weight: 400;
}

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

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

.app-root {
  min-height: 100vh;
}

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

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 760;
}

.brand.compact {
  position: absolute;
  left: 0;
}

.brand-mark {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, #11161c 0%, #247c8f 100%);
  box-shadow: 0 12px 32px rgba(36, 124, 143, 0.28);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(238, 242, 245, 0.92), rgba(238, 242, 245, 0.76)),
    url("/assets/hero-bg.png") center / cover no-repeat;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 30px;
  display: grid;
  gap: 22px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  animation: panelIn 0.32s ease both;
}

.auth-head h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 760;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 5px;
  background: #edf2f5;
  border-radius: 999px;
}

.segmented button,
.nav-btn {
  min-height: 42px;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 650;
}

.segmented button.active,
.nav-btn.active {
  color: #fff;
  background: var(--dark);
  box-shadow: 0 12px 26px rgba(17, 22, 28, 0.18);
}

.auth-form,
.form-grid {
  display: grid;
  gap: 14px;
}

.auth-form label,
.form-grid label {
  display: grid;
  gap: 8px;
  color: #3f4750;
  font-size: 12px;
  font-weight: 650;
}

input,
textarea,
select {
  width: 100%;
  min-height: 46px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: rgba(36, 124, 143, 0.7);
  box-shadow: 0 0 0 4px rgba(36, 124, 143, 0.12);
}

.primary-btn,
.secondary-btn,
.ghost-btn,
.icon-btn {
  min-height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 680;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.primary-btn {
  color: #fff;
  background: var(--dark);
  box-shadow: 0 14px 30px rgba(17, 22, 28, 0.18);
}

.secondary-btn {
  color: var(--ink);
  background: #e7edf1;
}

.ghost-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
}

.icon-btn {
  width: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  font-size: 22px;
}

.primary-btn:hover:not(:disabled),
.secondary-btn:hover:not(:disabled),
.ghost-btn:hover:not(:disabled),
.icon-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.primary-btn:disabled,
.secondary-btn:disabled {
  opacity: 0.5;
  box-shadow: none;
}

.full-width {
  width: 100%;
}

.site-shell {
  min-height: 100vh;
  padding: 26px clamp(18px, 4vw, 58px) 54px;
}

.floating-nav {
  position: sticky;
  top: 18px;
  z-index: 30;
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 34px;
}

.nav-pill {
  display: inline-grid;
  grid-auto-flow: column;
  gap: 6px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.82);
  border-radius: 999px;
  box-shadow: var(--soft-shadow);
  backdrop-filter: blur(18px);
}

.nav-pill .nav-btn {
  min-width: 92px;
  padding: 0 18px;
}

.logout-btn {
  position: absolute;
  right: 0;
}

.page-wrap {
  max-width: 1180px;
  margin: 0 auto;
  animation: pageIn 0.28s ease both;
}

.home-page,
.shop-page {
  min-height: calc(100vh - 150px);
  display: grid;
  align-items: start;
}

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

.owned-product,
.shop-product,
.admin-item,
.config-item,
.admin-empty {
  background: var(--panel-solid);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius);
  box-shadow: var(--soft-shadow);
}

.owned-product {
  min-height: 360px;
  padding: 26px;
  display: grid;
  gap: 18px;
  align-content: space-between;
}

.product-head h2,
.shop-product h2,
.admin-item h3,
.config-item h3 {
  margin: 10px 0 0;
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1.04;
  font-weight: 720;
}

.product-head p,
.product-desc {
  margin: 12px 0 0;
  max-width: 520px;
  color: var(--muted);
  font-size: 15.5px;
  line-height: 1.7;
  font-weight: 400;
}

.delivery-content {
  padding: 18px;
  min-height: 118px;
  color: #1c242b;
  background: #f5f8fa;
  border: 1px solid var(--line);
  border-radius: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.7;
}

.product-actions,
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.empty-home {
  min-height: calc(100vh - 180px);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 18px;
  text-align: center;
}

.empty-home h1 {
  margin: 0;
  font-size: clamp(42px, 8vw, 82px);
  line-height: 1;
  font-weight: 720;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.shop-product {
  min-height: 430px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.shop-product::after {
  content: "";
  position: absolute;
  inset: auto -28% -24% 26%;
  height: 180px;
  background: radial-gradient(circle, rgba(36, 124, 143, 0.18), transparent 70%);
  pointer-events: none;
}

.shop-product:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow);
}

.shop-product.purchased {
  color: #7a838d;
  background: #edf2f5;
  box-shadow: none;
}

.shop-product.pending {
  border-color: rgba(155, 106, 20, 0.24);
}

.badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  color: #3c4650;
  background: #eef3f6;
  font-size: 12px;
  font-weight: 650;
}

.badge.ok {
  color: var(--ok);
  background: #dff2ea;
}

.badge.warn {
  color: var(--warn);
  background: #f5ead4;
}

.badge-row,
.product-switches {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(13, 18, 24, 0.5);
  backdrop-filter: blur(12px);
  animation: fadeIn 0.18s ease both;
}

.modal-panel {
  width: min(500px, 100%);
  max-height: min(760px, 92vh);
  overflow: auto;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.3);
  animation: modalIn 0.22s ease both;
}

.modal-head,
.modal-body,
.modal-actions {
  padding: 22px;
}

.modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h2,
.processing-state h3 {
  margin: 0;
  font-size: 26px;
  font-weight: 720;
}

.modal-head span,
.processing-state span,
.admin-item span {
  color: var(--muted);
  font-size: 13px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-top: 1px solid var(--line);
}

.qr-box {
  min-height: 320px;
  display: grid;
  place-items: center;
  background: #f4f7f9;
  border: 1px solid var(--line);
  border-radius: 16px;
}

.qr-box img {
  width: min(270px, 78vw);
  height: auto;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--soft-shadow);
}

.processing-state {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
}

.loader-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(36, 124, 143, 0.18);
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

.admin-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.72fr);
  gap: 18px;
}

.admin-column,
.admin-list {
  display: grid;
  gap: 14px;
  align-content: start;
}

.admin-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.admin-title h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 720;
}

.admin-item,
.config-item,
.admin-empty {
  padding: 18px;
}

.admin-item {
  display: grid;
  gap: 14px;
}

.user-admin-item {
  grid-template-columns: minmax(0, 1fr);
}

.form-grid {
  margin-top: 14px;
}

.qr-preview {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.qr-thumb {
  width: 84px;
  min-height: 84px;
  display: grid;
  place-items: center;
}

.qr-preview img {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: 14px;
}

.upload-meter {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.upload-meter[hidden] {
  display: none;
}

.upload-meter div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e5ebef;
}

.upload-meter span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--dark), var(--accent));
  transition: width 0.16s ease;
}

.upload-meter b {
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.toast {
  position: fixed;
  z-index: 90;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  padding: 12px 14px;
  color: #fff;
  background: rgba(17, 22, 28, 0.94);
  border-radius: 14px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 980px) {
  .site-shell {
    padding: 16px 14px 34px;
  }

  .floating-nav {
    min-height: 112px;
    align-items: start;
    margin-bottom: 18px;
  }

  .brand.compact {
    left: 0;
    top: 0;
  }

  .logout-btn {
    top: 0;
  }

  .nav-pill {
    margin-top: 54px;
    width: 100%;
    grid-template-columns: 1fr 1fr;
  }

  .nav-pill .nav-btn {
    min-width: 0;
  }

  .shop-grid,
  .owned-grid,
  .admin-page {
    grid-template-columns: 1fr;
  }

  .shop-product {
    min-height: 300px;
  }

  .auth-page {
    padding: 16px;
  }

  .auth-panel {
    padding: 24px;
  }
}

@media (max-width: 560px) {
  .product-head h2,
  .shop-product h2 {
    font-size: 34px;
  }

  .modal-actions,
  .product-actions,
  .row-actions {
    display: grid;
  }

  .modal-actions button,
  .product-actions button,
  .row-actions button {
    width: 100%;
  }

  .qr-preview {
    grid-template-columns: 1fr;
  }
}
