/* H5 证书查询 - 移动优先样式 */
:root {
    --primary: #0F52BA;
    --primary-dark: #0A3D8F;
    --skill: #10B981;
    --ability: #F59E0B;
    --bg: #F0F4F8;
    --card: #FFFFFF;
    --text: #1E293B;
    --muted: #64748B;
    --border: #E2E8F0;
    --danger: #EF4444;
    --success: #10B981;
    --radius: 14px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --topbar-h: 52px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", "Helvetica Neue", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; border: none; outline: none; background: none; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }

.app {
    min-height: 100vh;
    min-height: 100dvh;
    padding-top: calc(var(--topbar-h) + var(--safe-top));
    padding-bottom: calc(24px + var(--safe-bottom));
    max-width: 480px;
    margin: 0 auto;
    position: relative;
}

/* ---- 顶栏 ---- */
.topbar {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 480px;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding: var(--safe-top) 12px 0;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    z-index: 100;
}

.topbar-back {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: var(--text);
    flex-shrink: 0;
}
.topbar-back:active { background: var(--bg); }
.topbar-back[hidden] { display: none; }

.topbar-brand {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.topbar-logo {
    height: 28px;
    width: auto;
    max-width: 100px;
    object-fit: contain;
    border-radius: 4px;
}

.topbar-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.topbar-title {
    font-size: 16px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-pc {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    font-size: 16px;
    flex-shrink: 0;
}
.topbar-pc:active { background: var(--bg); }

/* ---- 视图切换 ---- */
.view { display: none; padding: 0 16px; }
.view-active { display: block; animation: fadeIn 0.25s ease; }

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

/* ---- Hero ---- */
.hero {
    position: relative;
    margin: 0 -16px 16px;
    padding: 28px 20px 36px;
    overflow: hidden;
    color: #fff;
}

.hero-bg {
    position: absolute;
    inset: 0;
    background:
        linear-gradient(145deg, #0F52BA 0%, #1E40AF 45%, #0A3D8F 100%);
}
.hero-bg::after {
    content: '';
    position: absolute;
    right: -40px;
    top: -40px;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
}
.hero-bg::before {
    content: '';
    position: absolute;
    left: -30px;
    bottom: -50px;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.hero-content {
    position: relative;
    z-index: 1;
    text-align: center;
}
.hero-content h1 {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 0.02em;
    margin-bottom: 6px;
}
.hero-content p {
    font-size: 14px;
    opacity: 0.85;
}

/* ---- 面板 ---- */
.panel {
    background: var(--card);
    border-radius: var(--radius);
    padding: 20px 16px;
    box-shadow: 0 4px 20px rgba(15, 82, 186, 0.06);
    margin-top: -20px;
    position: relative;
    z-index: 2;
}

.panel-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 12px;
}

/* ---- 类型切换 ---- */
.type-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.type-tab {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 14px 8px;
    border-radius: 12px;
    border: 1.5px solid var(--border);
    background: #fff;
    color: var(--muted);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-height: 72px;
}
.type-tab i { font-size: 22px; }
.type-tab.active {
    border-color: var(--primary);
    background: rgba(15, 82, 186, 0.06);
    color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}
.type-tab[data-type="skill"].active {
    border-color: var(--skill);
    background: rgba(16, 185, 129, 0.08);
    color: var(--skill);
    box-shadow: 0 0 0 1px var(--skill);
}
.type-tab[data-type="ability"].active {
    border-color: var(--ability);
    background: rgba(245, 158, 11, 0.08);
    color: #D97706;
    box-shadow: 0 0 0 1px var(--ability);
}
.type-tab:active { transform: scale(0.97); }

/* ---- 搜索表单 ---- */
.search-form { display: flex; flex-direction: column; gap: 14px; }

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.input-wrap > i.fa-search {
    position: absolute;
    left: 14px;
    color: var(--muted);
    font-size: 16px;
    pointer-events: none;
}
.input-wrap input {
    width: 100%;
    height: 48px;
    padding: 0 40px 0 42px;
    border: 1.5px solid var(--border);
    border-radius: 12px;
    background: #F8FAFC;
    font-size: 16px;
    color: var(--text);
    transition: border-color 0.2s;
}
.input-wrap input:focus {
    border-color: var(--primary);
    background: #fff;
}
.input-wrap input::placeholder { color: #94A3B8; }

.input-clear {
    position: absolute;
    right: 10px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94A3B8;
    font-size: 16px;
}
.input-clear[hidden] { display: none; }

.btn-primary {
    height: 48px;
    border-radius: 12px;
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 4px 14px rgba(15, 82, 186, 0.3);
    transition: background 0.2s, transform 0.15s;
}
.btn-primary:active {
    background: var(--primary-dark);
    transform: scale(0.98);
}
.btn-primary:disabled {
    opacity: 0.65;
    pointer-events: none;
}
.btn-sm {
    height: 40px;
    padding: 0 24px;
    font-size: 14px;
    display: inline-flex;
    width: auto;
    margin: 0 auto;
}

.tips {
    margin-top: 16px;
    padding: 12px 14px;
    background: rgba(15, 82, 186, 0.05);
    border-radius: 10px;
    border: 1px solid rgba(15, 82, 186, 0.1);
}
.tips p {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.7;
}
.tips i { color: var(--primary); margin-right: 4px; }

/* ---- 其它项目 ---- */
.projects {
    margin-top: 24px;
    padding-bottom: 8px;
}
.project-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.project-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 12px;
    background: var(--card);
    border-radius: 12px;
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
    transition: background 0.15s;
}
.project-item:active { background: #F1F5F9; }
.project-item i {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: rgba(15, 82, 186, 0.08);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

/* ---- 结果列表 ---- */
.result-meta {
    padding: 14px 0 10px;
    font-size: 13px;
    color: var(--muted);
}
.result-meta strong { color: var(--primary); font-weight: 600; }

.result-list { display: flex; flex-direction: column; gap: 12px; }

.result-card {
    background: var(--card);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
    border: 1px solid var(--border);
    transition: transform 0.15s;
}
.result-card:active { transform: scale(0.985); }

.result-card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}
.result-card-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    word-break: break-word;
    flex: 1;
    min-width: 0;
}

.badge {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    line-height: 1.4;
}
.badge-valid { background: #D1FAE5; color: #065F46; }
.badge-invalid { background: #FEE2E2; color: #991B1B; }
.badge-paused { background: #FEF3C7; color: #92400E; }
.badge-other { background: #F1F5F9; color: #475569; }

.result-card-rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.result-row {
    display: flex;
    font-size: 13px;
    gap: 8px;
}
.result-row .label {
    color: var(--muted);
    flex-shrink: 0;
    width: 72px;
}
.result-row .value {
    color: var(--text);
    word-break: break-all;
    flex: 1;
}

.result-card-arrow {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--primary);
    gap: 4px;
}

/* ---- 空状态 ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
}
.empty-state i {
    font-size: 48px;
    color: #CBD5E1;
    margin-bottom: 16px;
}
.empty-state h3 {
    font-size: 17px;
    margin-bottom: 8px;
}
.empty-state p {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 20px;
}

/* ---- 详情 ---- */
.detail-card {
    background: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.05);
    margin-top: 12px;
    border: 1px solid var(--border);
}

.detail-head {
    padding: 20px 16px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
}
.detail-head.skill {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}
.detail-head.ability {
    background: linear-gradient(135deg, #D97706 0%, #B45309 100%);
}
.detail-head h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
    word-break: break-word;
    line-height: 1.4;
}
.detail-head .cert-no {
    font-size: 13px;
    opacity: 0.9;
    word-break: break-all;
}
.detail-head .badge {
    margin-top: 10px;
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.detail-body { padding: 8px 0; }

.detail-field {
    display: flex;
    padding: 12px 16px;
    border-bottom: 1px solid #F1F5F9;
    gap: 12px;
}
.detail-field:last-child { border-bottom: none; }
.detail-field .label {
    width: 80px;
    flex-shrink: 0;
    font-size: 13px;
    color: var(--muted);
}
.detail-field .value {
    flex: 1;
    font-size: 14px;
    font-weight: 500;
    word-break: break-word;
}

.detail-alert {
    margin: 12px 16px 16px;
    padding: 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
}
.detail-alert.warning {
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    color: #92400E;
}
.detail-alert.info {
    background: #F0F9FF;
    border: 1px solid #BAE6FD;
    color: #075985;
}

.detail-verify {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 14px 16px;
    background: #F8FAFC;
    font-size: 12px;
    color: var(--muted);
    border-top: 1px solid var(--border);
}
.detail-verify i { color: var(--primary); }

/* ---- Loading / Toast ---- */
.loading {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}
.loading[hidden] { display: none; }
.loading p { font-size: 14px; color: var(--muted); }

.loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(80px + var(--safe-bottom));
    transform: translateX(-50%);
    max-width: 80%;
    padding: 10px 18px;
    background: rgba(30, 41, 59, 0.92);
    color: #fff;
    font-size: 13px;
    border-radius: 24px;
    z-index: 300;
    text-align: center;
    animation: toastIn 0.25s ease;
}
.toast[hidden] { display: none; }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---- 页脚 ---- */
.app-footer {
    text-align: center;
    padding: 28px 16px 8px;
    font-size: 11px;
    color: #94A3B8;
    line-height: 1.8;
}

/* 桌面端居中预览 */
@media (min-width: 481px) {
    body { background: #E2E8F0; }
    .app {
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.08);
        background: var(--bg);
    }
}
