/* ==========================================================================
   肥料产品追溯平台 —— 前台样式（移动端优先）
   ========================================================================== */

:root {
    --green-900: #14532d;
    --green-700: #15803d;
    --green-600: #16a34a;
    --green-500: #22c55e;
    --green-100: #dcfce7;
    --green-50: #f0fdf4;
    --amber-600: #d97706;
    --amber-100: #fef3c7;
    --red-600: #dc2626;
    --red-100: #fee2e2;
    --slate-900: #0f172a;
    --slate-700: #334155;
    --slate-500: #64748b;
    --slate-300: #cbd5e1;
    --slate-100: #f1f5f9;
    --slate-50: #f8fafc;
    --white: #ffffff;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 4px 16px rgba(15, 23, 42, .06);
    --shadow-lg: 0 8px 32px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: #f6f8f7;
    color: var(--slate-900);
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; border-radius: var(--radius-sm); }
a { color: var(--green-700); text-decoration: none; }
a:hover { text-decoration: underline; }

.container {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
    padding: 0 14px;
}
.container-wide { max-width: 960px; }

/* ------------------------------------------------------------ Header */
.app-header {
    background: linear-gradient(135deg, var(--green-700), var(--green-900));
    color: #fff;
    padding: 18px 0 22px;
}
.app-header.simple { background: var(--white); color: var(--slate-900); border-bottom: 1px solid var(--slate-100); }
.app-header.simple .brand-title { color: var(--slate-900); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
    width: 34px; height: 34px; flex: none; border-radius: 9px;
    background: rgba(255,255,255,.18); display: grid; place-items: center; font-size: 18px;
}
.simple .brand-logo { background: var(--green-100); }
.brand-title { font-size: 17px; font-weight: 600; color: #fff; }
.brand-sub { font-size: 12px; opacity: .8; margin-top: 1px; }
.app-header .nav-link { color: rgba(255,255,255,.9); font-size: 13px; margin-left: 14px; }
.simple .nav-link { color: var(--slate-500); }

.hero { margin-top: 14px; }
.hero h1 { font-size: 20px; line-height: 1.4; margin: 0 0 6px; font-weight: 700; }
.hero p { margin: 0; font-size: 13px; opacity: .85; }

/* ------------------------------------------------------------ 搜索卡 */
.search-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px;
    margin-top: -12px;
    position: relative;
    z-index: 2;
}
.search-form { display: flex; gap: 8px; }
.search-input {
    flex: 1; height: 44px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
    padding: 0 12px; font-size: 15px; outline: none; background: var(--white); color: var(--slate-900);
}
.search-input:focus { border-color: var(--green-600); box-shadow: 0 0 0 3px var(--green-100); }
.btn {
    border: 0; border-radius: var(--radius-sm); cursor: pointer; font-size: 15px;
    padding: 0 16px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
    gap: 6px; background: var(--slate-100); color: var(--slate-700); transition: .15s;
}
.btn-primary { background: var(--green-600); color: #fff; font-weight: 500; }
.btn-primary:hover { background: var(--green-700); text-decoration: none; }
.btn-block { width: 100%; }
.btn-outline { background: var(--white); border: 1px solid var(--slate-300); color: var(--slate-700); }
.btn-sm { height: 34px; font-size: 13px; padding: 0 12px; }
.btn-danger { background: #fff; border: 1px solid #fecaca; color: var(--red-600); }
.search-hint { margin: 10px 0 0; font-size: 12.5px; color: var(--slate-500); }

/* ------------------------------------------------------------ 卡片 */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px;
    margin: 12px 0;
}
.card-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 15px; font-weight: 600; margin: 0 0 12px;
    padding-bottom: 10px; border-bottom: 1px dashed var(--slate-100);
}
.card-title .bar { width: 3px; height: 15px; background: var(--green-600); border-radius: 2px; }
.card-title .tag-right { margin-left: auto; }

.grid-info { display: grid; grid-template-columns: 1fr; gap: 10px; }
.info-row {
    display: grid; grid-template-columns: 96px 1fr; gap: 10px;
    padding: 7px 0; border-bottom: 1px solid var(--slate-50); font-size: 14px;
}
.info-row:last-child { border-bottom: 0; }
.info-label { color: var(--slate-500); font-size: 13.5px; }
.info-value { color: var(--slate-900); word-break: break-word; white-space: pre-wrap; }
.multiline { white-space: pre-wrap; }

.badge {
    display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 500;
    background: var(--slate-100); color: var(--slate-500);
}
.badge-green { background: var(--green-100); color: var(--green-700); }
.badge-amber { background: var(--amber-100); color: var(--amber-600); }
.badge-red { background: var(--red-100); color: var(--red-600); }

.product-hero { display: flex; gap: 12px; align-items: flex-start; }
.product-hero img { width: 92px; height: 92px; object-fit: cover; flex: none; }
.product-hero h2 { font-size: 18px; margin: 0 0 4px; }
.product-meta { font-size: 12.5px; color: var(--slate-500); }

/* ------------------------------------------------------------ 正品核验 */
.scan-box {
    background: linear-gradient(135deg, var(--green-50), var(--green-100));
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.scan-box .verify-ok { font-size: 19px; font-weight: 800; color: var(--green-700); line-height: 1.3; }
.scan-box .verify-time { margin-top: 6px; font-size: 13px; color: var(--slate-500); }

/* ------------------------------------------------------------ 提示 */
.alert {
    border-radius: var(--radius-sm); padding: 10px 12px; margin: 12px 0; font-size: 13.5px;
    border: 1px solid transparent;
}
.alert-warning { background: var(--amber-100); color: #92400e; border-color: #fde68a; }
.alert-danger { background: var(--red-100); color: #991b1b; border-color: #fecaca; }
.alert-success { background: var(--green-100); color: var(--green-700); border-color: #bbf7d0; }
.alert-info { background: var(--slate-100); color: var(--slate-700); border-color: var(--slate-300); }

/* ------------------------------------------------------------ 图片画廊 */
.gallery { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.gallery figure { margin: 0; }
.gallery figcaption { font-size: 12px; color: var(--slate-500); margin-top: 4px; text-align: center; }
.gallery img { width: 100%; aspect-ratio: 3/4; object-fit: cover; cursor: zoom-in; }

/* ------------------------------------------------------------ 联系条 */
.contact-bar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.contact-item {
    background: var(--slate-50); border: 1px solid var(--slate-100); border-radius: var(--radius-sm);
    padding: 10px; font-size: 13px; text-align: center; color: var(--slate-700);
}
.contact-item strong { display: block; font-size: 14px; color: var(--slate-900); margin-bottom: 2px; }

/* ------------------------------------------------------------ 表单 */
.field { margin-bottom: 12px; }
.field-label { display: block; font-size: 13px; color: var(--slate-500); margin-bottom: 6px; }
input[type=text], input[type=number], input[type=date], input[type=email], textarea, select {
    width: 100%; padding: 10px 12px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
    font-size: 14.5px; font-family: inherit; background: var(--white); color: var(--slate-900);
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--green-600); box-shadow: 0 0 0 3px var(--green-100); }
textarea { resize: vertical; min-height: 88px; }

/* ------------------------------------------------------------ 产品列表 */
.product-grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.product-item { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.product-item .thumb { height: 150px; background: var(--slate-100); object-fit: cover; width: 100%; }
.product-item .body { padding: 12px; }
.product-item h3 { margin: 0 0 6px; font-size: 15px; }
.product-item p { margin: 0; font-size: 12.5px; color: var(--slate-500); }

/* ------------------------------------------------------------ 底部 */
.app-footer { padding: 20px 0 40px; text-align: center; color: var(--slate-500); font-size: 12px; }
.app-footer .links { margin-bottom: 6px; }
.app-footer .links a { margin: 0 8px; color: var(--slate-500); }

/* ------------------------------------------------------------ 状态页 */
.status-page { text-align: center; padding: 40px 10px; }
.status-icon { font-size: 46px; margin-bottom: 12px; }
.status-page h2 { font-size: 19px; margin: 0 0 8px; }
.status-page p { color: var(--slate-500); font-size: 14px; margin: 0 0 18px; }

/* ------------------------------------------------------------ 工具条 */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.toolbar .grow { flex: 1; }

.section-title { margin: 22px 0 10px; font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
.section-title .bar { width: 3px; height: 14px; background: var(--green-600); border-radius: 2px; }

.muted { color: var(--slate-500); font-size: 13px; }
.divider { height: 1px; background: var(--slate-100); margin: 14px 0; }

/* 图片查看全屏遮罩 */
.lightbox {
    position: fixed; inset: 0; background: rgba(15,23,42,.92); display: none; z-index: 99;
    align-items: center; justify-content: center; padding: 16px;
}
.lightbox.active { display: flex; }
.lightbox img { max-width: 100%; max-height: 92vh; border-radius: 8px; }

@media (min-width: 640px) {
    body { font-size: 15.5px; }
    .product-grid { grid-template-columns: repeat(2, 1fr); }
    .info-row { grid-template-columns: 120px 1fr; }
    .gallery { grid-template-columns: repeat(3, 1fr); }
}
