/* ============================================================
   SIM商城 设计系统
   色板：
     --ink   #0B1220  深墨蓝，页头/页脚/强调背景
     --teal  #17C3B2  信号青，主强调色（连接、在线）
     --amber #FFB020  信号橙，行动点（价格/按钮高光）
     --paper #F5F7FA  纸白，页面底色
     --slate #5B6B79  次要文字
     --line  #E2E8F0  分隔线/描边
   字体：
     display: Space Grotesk（标题，几何感/科技感）
     body:    Inter（正文/界面）
     mono:    IBM Plex Mono（价格、库存、卡号类数据）
   签名元素：
     「信号格」— 用四条递增高度的竖条表示库存/连接强度，
     贯穿页头装饰与商品库存指示，是功能性的，不是纯装饰。
   ============================================================ */

:root {
  --ink: #0b1220;
  --ink-soft: #141d2e;
  --teal: #17c3b2;
  --teal-dark: #109c8e;
  --amber: #ffb020;
  --paper: #f5f7fa;
  --paper-2: #ffffff;
  --slate: #5b6b79;
  --slate-light: #8a99a6;
  --line: #e2e8f0;
  --danger: #e5484d;
  --radius: 14px;
  --font-display: "Space Grotesk", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "Inter", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ---------- 信号格 signature component ---------- */
.signal {
  display: inline-flex;
  align-items: flex-end;
  gap: 3px;
  height: 16px;
}

.signal .bar {
  width: 4px;
  background: var(--line);
  border-radius: 1px;
}

.signal .bar:nth-child(1) { height: 40%; }
.signal .bar:nth-child(2) { height: 60%; }
.signal .bar:nth-child(3) { height: 80%; }
.signal .bar:nth-child(4) { height: 100%; }

.signal.level-0 .bar { background: var(--line); }
.signal.level-1 .bar:nth-child(1) { background: var(--danger); }
.signal.level-2 .bar:nth-child(1),
.signal.level-2 .bar:nth-child(2) { background: var(--amber); }
.signal.level-3 .bar:nth-child(1),
.signal.level-3 .bar:nth-child(2),
.signal.level-3 .bar:nth-child(3) { background: var(--teal); }
.signal.level-4 .bar { background: var(--teal); }

.signal--hero .bar {
  background: rgba(255, 255, 255, 0.18);
  animation: pulse 1.8s ease-in-out infinite;
}
.signal--hero .bar:nth-child(1) { animation-delay: 0s; }
.signal--hero .bar:nth-child(2) { animation-delay: 0.15s; }
.signal--hero .bar:nth-child(3) { animation-delay: 0.3s; }
.signal--hero .bar:nth-child(4) { animation-delay: 0.45s; }

@keyframes pulse {
  0%, 100% { background: rgba(23, 195, 178, 0.25); }
  50% { background: var(--teal); }
}

/* ---------- Header ---------- */
.site-header {
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 40;
}

.site-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 68px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 0.02em;
}

.brand .signal .bar { background: var(--teal); }

.nav {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
}

.nav a:hover { color: #fff; }

.cart-btn {
  position: relative;
  background: var(--teal);
  color: var(--ink);
  border: none;
  border-radius: 999px;
  padding: 9px 18px;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease;
}

.cart-btn:hover { background: var(--teal-dark); color: #fff; }

.cart-count {
  position: absolute;
  top: -6px;
  right: -6px;
  background: var(--amber);
  color: var(--ink);
  font-size: 11px;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ---------- Hero ---------- */
.hero {
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-soft) 60%, #1b2a40 100%);
  color: #fff;
  padding: 72px 0 88px;
}

.hero .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 48px;
}

.hero-copy { max-width: 560px; }

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 18px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: 44px;
  line-height: 1.15;
  margin: 0 0 18px;
  font-weight: 700;
}

.hero p {
  color: rgba(255, 255, 255, 0.72);
  font-size: 16px;
  line-height: 1.7;
  margin: 0 0 28px;
}

.hero-actions { display: flex; gap: 14px; }

.btn-primary {
  background: var(--teal);
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 13px 26px;
  font-weight: 700;
  font-size: 15px;
  transition: transform 0.12s ease, background 0.15s ease;
}
.btn-primary:hover { background: #fff; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 10px;
  padding: 13px 26px;
  font-size: 15px;
}
.btn-ghost:hover { border-color: var(--teal); color: var(--teal); }

.hero-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  padding: 28px;
  min-width: 260px;
}

.hero-card .signal--hero {
  height: 34px;
  margin-bottom: 16px;
}
.hero-card .signal--hero .bar { width: 8px; }

.hero-card .stat-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 4px;
}
.hero-card .stat-value {
  font-family: var(--font-display);
  font-size: 26px;
  margin-bottom: 18px;
}

/* ---------- Product grid ---------- */
.section {
  padding: 64px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 32px;
}

.section-head h2 {
  font-family: var(--font-display);
  font-size: 28px;
  margin: 0;
}

.section-head span {
  color: var(--slate);
  font-size: 14px;
}

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

.card {
  background: var(--paper-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
}

.card .thumb {
  height: 130px;
  border-radius: 10px;
  background: linear-gradient(135deg, #eef2f6, #e2e8f0);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card .thumb img { width: 100%; height: 100%; object-fit: cover; }

.card .thumb .placeholder-icon {
  color: var(--slate-light);
  font-family: var(--font-mono);
  font-size: 12px;
}

.card h3 {
  font-family: var(--font-display);
  font-size: 17px;
  margin: 0;
}

.card .desc {
  color: var(--slate);
  font-size: 13px;
  line-height: 1.6;
  margin: 0;
  flex: 1;
}

.card .meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.price {
  font-family: var(--font-mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}
.price::before { content: "¥"; font-size: 13px; margin-right: 2px; color: var(--slate); }

.stock-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--slate-light);
}

.add-btn {
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 0;
  font-weight: 600;
  font-size: 14px;
  transition: background 0.15s ease;
}
.add-btn:hover { background: var(--teal-dark); }
.add-btn:disabled {
  background: var(--line);
  color: var(--slate-light);
  cursor: not-allowed;
}

.empty-state {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  color: var(--slate);
  font-size: 14px;
}

/* ---------- Cart drawer ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 18, 32, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 50;
}
.overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(380px, 92vw);
  background: #fff;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 51;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 30px rgba(0, 0, 0, 0.12);
}
.drawer.open { transform: translateX(0); }

.drawer-head {
  padding: 20px 22px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.drawer-head h3 { margin: 0; font-family: var(--font-display); }
.drawer-close { background: none; border: none; font-size: 20px; color: var(--slate); }

.drawer-items { flex: 1; overflow-y: auto; padding: 12px 22px; }

.cart-item {
  display: flex;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.cart-item .info { flex: 1; }
.cart-item h4 { margin: 0 0 4px; font-size: 14px; }
.cart-item .row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--slate); }
.cart-item .qty-ctrl { display: flex; align-items: center; gap: 8px; }
.cart-item .qty-ctrl button {
  width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line);
  background: #fff; font-size: 13px;
}
.cart-item .remove { color: var(--danger); font-size: 12px; background: none; border: none; }

.drawer-foot {
  padding: 20px 22px;
  border-top: 1px solid var(--line);
}
.drawer-foot .total-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 16px;
  margin-bottom: 14px;
}
.checkout-btn {
  width: 100%;
  background: var(--amber);
  color: var(--ink);
  border: none;
  border-radius: 10px;
  padding: 13px 0;
  font-weight: 700;
  font-size: 15px;
}
.checkout-btn:hover { background: #ffc44d; }
.checkout-hint {
  margin-top: 10px;
  font-size: 12px;
  color: var(--slate-light);
  text-align: center;
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--ink);
  color: rgba(255, 255, 255, 0.55);
  padding: 32px 0;
  font-size: 13px;
}
.site-footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 10px);
  background: var(--ink);
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============================================================
   Admin 后台
   ============================================================ */
.admin-body {
  background: var(--paper);
  min-height: 100vh;
}

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  padding: 24px;
}

.login-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 380px;
}

.login-card .brand {
  color: var(--ink);
  margin-bottom: 6px;
}
.login-card .brand .signal .bar { background: var(--teal); }

.login-card p.subtitle {
  color: var(--slate);
  font-size: 13px;
  margin: 0 0 28px;
}

.field {
  margin-bottom: 16px;
}
.field label {
  display: block;
  font-size: 13px;
  color: var(--slate);
  margin-bottom: 6px;
}
.field input, .field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus, .field textarea:focus {
  border-color: var(--teal);
  outline: none;
}

.login-error {
  background: #fdecec;
  color: var(--danger);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

.btn-block {
  width: 100%;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 0;
  font-weight: 600;
  font-size: 14px;
}
.btn-block:hover { background: var(--teal-dark); }

.admin-header {
  background: var(--ink);
  color: #fff;
}
.admin-header .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}
.admin-header .who {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
}
.logout-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
}
.logout-btn:hover { border-color: var(--teal); color: var(--teal); }

.admin-main { padding: 32px 0 64px; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 28px;
}
.panel h2 {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 18px;
}

.add-form {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 2fr auto;
  gap: 12px;
  align-items: end;
}
.add-form .field { margin-bottom: 0; }
.add-form button {
  background: var(--teal);
  color: var(--ink);
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  font-weight: 600;
  font-size: 14px;
  height: 42px;
}
.add-form button:hover { background: var(--teal-dark); color: #fff; }

table.product-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.product-table th {
  text-align: left;
  font-size: 12px;
  color: var(--slate);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
table.product-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
table.product-table input {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
  width: 100%;
  font-family: var(--font-mono);
}
table.product-table input.name-input { font-family: inherit; }

.row-actions { display: flex; gap: 8px; white-space: nowrap; }
.row-actions button {
  border: none;
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
}
.btn-save { background: var(--teal); color: var(--ink); }
.btn-save:hover { background: var(--teal-dark); color: #fff; }
.btn-delete { background: #fdecec; color: var(--danger); }
.btn-delete:hover { background: var(--danger); color: #fff; }

.toggle-enabled {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--slate);
}

@media (max-width: 860px) {
  .hero .container { flex-direction: column; }
  .add-form { grid-template-columns: 1fr 1fr; }
  .admin-main .container { padding: 0 12px; }
  table.product-table { display: block; overflow-x: auto; }
}
