/* ==========================================================================
   锂电池一物一码电子质保卡系统 —— 前台样式
   设计原则：移动端优先（手机），向上适配平板与电脑
   ========================================================================== */

:root {
  --brand-dark: #0d2f4f;
  --brand: #1667c8;
  --brand-light: #4a95e8;
  --energy: #12b886;
  --danger: #e33b3b;
  --warning-bg: #fff8e6;
  --warning-border: #ffd980;
  --warning-text: #8a5a00;
  --text: #1f2d3d;
  --text-muted: #6b7c93;
  --line: #e4e9f0;
  --bg: #f2f5f9;
  --card-bg: #ffffff;
  --radius: 14px;
  --shadow: 0 6px 20px rgba(16, 42, 74, 0.08);
  --shadow-strong: 0 12px 32px rgba(16, 42, 74, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: var(--brand);
  text-decoration: none;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 14px calc(28px + env(safe-area-inset-bottom));
}

/* ------------------------------ 顶部 Banner ----------------------------- */

.site-header {
  position: relative;
  background: linear-gradient(135deg, #0d2f4f 0%, #1667c8 55%, #12b886 130%);
  background-size: cover;
  background-position: center;
  color: #fff;
  padding: calc(20px + env(safe-area-inset-top)) 16px 44px;
}

.site-header::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(6, 24, 42, 0.15), rgba(6, 24, 42, 0.45));
  pointer-events: none;
}

.brand-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  height: 44px;
  width: auto;
  max-width: 190px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  padding: 5px 7px;
  object-fit: contain;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
  flex: 0 0 auto;
}

.brand-text {
  min-width: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

.brand-text p {
  margin: 2px 0 0;
  font-size: 12.5px;
  opacity: 0.9;
}

.header-slogan {
  position: relative;
  z-index: 1;
  margin-top: 18px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
}

.header-sub {
  position: relative;
  z-index: 1;
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.92;
}

/* -------------------------------- 导航栏 -------------------------------- */

.site-nav {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: var(--shadow);
  margin-top: -28px;
  display: flex;
  overflow: hidden;
}

.site-nav a {
  flex: 1;
  text-align: center;
  padding: 15px 8px 13px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 3px solid transparent;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}

.site-nav a:hover {
  color: var(--brand);
  background: #f7fafd;
}

.site-nav a.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}

/* ------------------------------- 通用卡片 ------------------------------- */

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-top: 14px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 12px;
}

.card-title::before {
  content: '';
  width: 4px;
  height: 16px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--brand), var(--energy));
}

/* ------------------------------ 温馨提示 -------------------------------- */

.tip-bar {
  margin-top: 14px;
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  border-left: 4px solid #f0a92c;
  color: var(--warning-text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13.5px;
  line-height: 1.65;
}

.tip-bar strong {
  color: #a36300;
}

/* ---------------------------- 质保卡头部信息 ---------------------------- */

.card-hero {
  background: linear-gradient(120deg, #143c66, #1e6fd9 70%, #17a887);
  color: #fff;
  border-radius: var(--radius);
  padding: 18px 16px;
  margin-top: 14px;
  box-shadow: var(--shadow-strong);
}

.card-hero .hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.card-hero h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.35;
  font-weight: 700;
}

.card-hero .hero-model {
  margin-top: 6px;
  font-size: 13px;
  opacity: 0.92;
}

.card-hero .hero-code {
  margin-top: 14px;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 13px;
  letter-spacing: 1px;
  background: rgba(255, 255, 255, 0.16);
  border: 1px dashed rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  padding: 8px 10px;
  word-break: break-all;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex: 0 0 auto;
}

.badge-pending {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.6);
}

.badge-active {
  background: #e8f9f1;
  color: #0b7a52;
  border: 1px solid #9fe0c4;
}

.badge-warn {
  background: #fff1f0;
  color: #b3261e;
  border: 1px solid #f3b3ae;
}

/* ------------------------------ 信息栅格 -------------------------------- */

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.field-row {
  display: flex;
  gap: 10px;
  background: #fff;
  padding: 11px 12px;
  font-size: 14px;
}

.field-row .label {
  width: 92px;
  flex: 0 0 auto;
  color: var(--text-muted);
}

.field-row .value {
  flex: 1;
  word-break: break-all;
  font-weight: 500;
}

.field-row .value.empty {
  color: #b6c1cf;
  font-weight: 400;
}

/* -------------------------------- 表单 ---------------------------------- */

.form-item {
  margin-bottom: 14px;
}

.form-item label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 7px;
}

.form-item label .required {
  color: var(--danger);
  margin-left: 3px;
}

.form-item .hint {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 6px;
}

.form-item input {
  width: 100%;
  font-size: 16px; /* iOS 下避免聚焦时自动放大 */
  font-family: inherit;
  color: var(--text);
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fbfcfe;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.form-item input:focus {
  border-color: var(--brand-light);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(74, 149, 232, 0.16);
}

.form-item input.invalid {
  border-color: var(--danger);
  background: #fff6f6;
}

.field-error {
  display: none;
  color: var(--danger);
  font-size: 12.5px;
  margin-top: 5px;
}

.field-error.show {
  display: block;
}

/* -------------------------------- 按钮 ---------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 15px 18px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.2s, opacity 0.2s;
}

.btn:active {
  transform: scale(0.985);
}

.btn-primary {
  background: linear-gradient(135deg, #e8452c, #cf2d1c);
  color: #fff;
  box-shadow: 0 8px 20px rgba(207, 45, 28, 0.28);
  letter-spacing: 2px;
}

.btn-primary[disabled] {
  opacity: 0.7;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid var(--brand-light);
  font-size: 15px;
  padding: 12px 16px;
}

/* ------------------------------- 状态卡片 ------------------------------- */

.state-card {
  text-align: center;
  padding: 30px 18px;
}

.state-card .icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
}

.state-card .icon.warn {
  background: #fff1f0;
  color: #d0342c;
}

.state-card .icon.ok {
  background: #e8f9f1;
  color: #0b7a52;
}

.state-card h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.state-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 14px;
}

.activated-note {
  margin-top: 14px;
  background: #e8f9f1;
  border: 1px solid #b7e8d2;
  color: #0b7a52;
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ------------------------------- 弹窗 ---------------------------------- */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(11, 26, 44, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(2px);
}

.modal-mask.show {
  display: flex;
}

.modal {
  background: #fff;
  border-radius: 18px;
  padding: 26px 20px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  animation: pop 0.22s ease-out;
  box-shadow: var(--shadow-strong);
}

@keyframes pop {
  from {
    transform: scale(0.92);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.modal .modal-icon {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: #e8f9f1;
  color: #0b7a52;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  margin: 0 auto 14px;
}

.modal h3 {
  margin: 0 0 8px;
  font-size: 18px;
}

.modal p {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 14px;
}

.modal .btn {
  font-size: 16px;
  padding: 13px;
}

/* ------------------------------ 公司简介 -------------------------------- */

.intro-text {
  font-size: 15px;
  line-height: 1.9;
  color: #2c3e50;
  white-space: pre-wrap;
  word-break: break-word;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.gallery figure {
  margin: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #eef2f7;
  aspect-ratio: 4 / 3;
}

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

.contact-list a {
  font-weight: 600;
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 14.5px;
}

.contact-row:last-child {
  border-bottom: none;
}

.contact-row .ico {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #eef5ff;
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex: 0 0 auto;
}

/* ------------------------------- 页脚 ---------------------------------- */

.site-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  padding: 22px 16px 26px;
  line-height: 1.8;
}

.site-footer .slogan {
  color: var(--brand);
  font-weight: 700;
  letter-spacing: 3px;
  font-size: 13.5px;
}

/* ------------------------------ 加载状态 -------------------------------- */

.loading {
  text-align: center;
  padding: 40px 0;
  color: var(--text-muted);
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #dce5f0;
  border-top-color: var(--brand);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.9s linear infinite;
}

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

.hidden {
  display: none !important;
}

/* ---------------------------- 平板 / 电脑适配 --------------------------- */

@media (min-width: 768px) {
  body {
    font-size: 16px;
  }

  .page {
    max-width: 860px;
    padding: 0 24px 40px;
  }

  .site-header {
    padding: calc(28px + env(safe-area-inset-top)) 28px 56px;
  }

  .brand-logo {
    height: 64px;
    max-width: 250px;
    padding: 6px 9px;
  }

  .brand-text h1 {
    font-size: 22px;
  }

  .header-slogan {
    font-size: 28px;
  }

  .site-nav {
    margin-top: -32px;
  }

  .site-nav a {
    font-size: 16px;
    padding: 17px 12px 15px;
  }

  .field-grid {
    grid-template-columns: 1fr 1fr;
  }

  .field-row.full {
    grid-column: 1 / -1;
  }

  .gallery {
    grid-template-columns: repeat(3, 1fr);
  }

  .card {
    padding: 22px;
  }

  .modal {
    max-width: 380px;
  }
}

@media (min-width: 1024px) {
  .page {
    max-width: 940px;
  }

  .header-slogan {
    font-size: 32px;
  }
}

/* 打印时隐藏导航与页脚，便于打印电子质保卡 */
@media print {
  .site-nav,
  .site-footer,
  .btn {
    display: none !important;
  }

  body {
    background: #fff;
  }
}
