/* ================================
   内部售后服务平台 · H5 样式
   ================================ */
:root {
    --primary: #165DFF;
    --primary-dark: #0E42D2;
    --primary-soft: #E8F0FF;
    --secondary: #0FC6C2;
    --success: #00B42A;
    --success-soft: #E8FFEA;
    --warning: #FF7D00;
    --warning-soft: #FFF7E8;
    --danger: #F53F3F;
    --danger-soft: #FFECE8;
    --text: #1D2129;
    --text-2: #4E5969;
    --muted: #86909C;
    --border: #E5E8EF;
    --bg: #F2F5FA;
    --card: #FFFFFF;
    --radius: 14px;
    --shadow: 0 2px 10px rgba(29, 33, 41, .06);
    --shadow-lg: 0 16px 40px rgba(29, 33, 41, .16);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }
button, input, select, textarea { font-family: inherit; }
a { color: var(--primary); text-decoration: none; }
code {
    padding: 1px 6px;
    border-radius: 5px;
    background: rgba(22, 93, 255, .08);
    color: var(--primary-dark);
    font-family: "SFMono-Regular", Consolas, monospace;
    font-size: 12px;
    word-break: break-all;
}

.hidden { display: none !important; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ---------- 通用控件 ---------- */
.input {
    display: block;
    width: 100%;
    height: 44px;
    padding: 0 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 15px;
    outline: none;
    transition: border-color .18s, box-shadow .18s;
}
.input::placeholder { color: #A9B0BF; }
.input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(22, 93, 255, .12);
}
.textarea {
    height: auto;
    min-height: 104px;
    padding: 11px 13px;
    line-height: 1.6;
    resize: vertical;
}

/* ---------- 输入框清空按钮 ---------- */
.input-clear-wrap { position: relative; }
.input-clear-wrap .input { padding-right: 86px; }
.input-clear-wrap .clear-input {
    position: absolute;
    right: 6px;
    top: 50%;
    height: 30px;
    padding: 0 8px;
    transform: translateY(-50%);
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-2);
    font-size: 11px;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: color .18s, border-color .18s;
}
.input-clear-wrap .clear-input:hover { color: var(--primary); border-color: var(--primary); }
.input-clear-wrap .clear-input:active { color: var(--primary-dark); }
.input-clear-wrap.is-textarea .clear-input { top: 10px; transform: none; }

.field-label {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    color: var(--text-2);
}
.form-field { margin-bottom: 14px; }
.form-field label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-2);
}
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 14px;
}
.form-actions { display: flex; gap: 10px; align-items: center; }
.inline-form {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}
.inline-form .form-field { margin-bottom: 0; }
.inline-form .grow { flex: 1; min-width: 0; }
.grow { flex: 1; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 42px;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #fff;
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    transition: background .18s, border-color .18s, transform .12s, box-shadow .18s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary {
    background: linear-gradient(135deg, #2E6BFF, var(--primary));
    color: #fff;
    box-shadow: 0 6px 16px rgba(22, 93, 255, .22);
}
.btn-primary:hover { background: linear-gradient(135deg, #1E5CF2, var(--primary-dark)); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #E96F00; }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #FFE0DA; }
.btn-ghost {
    background: #fff;
    border-color: var(--border);
    color: var(--text-2);
}
.btn-ghost:hover { border-color: #C9D2E3; color: var(--text); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn-block { display: flex; width: 100%; }

.alert {
    padding: 11px 14px;
    margin-bottom: 14px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
}
.alert-danger { background: var(--danger-soft); color: #C62F2F; }
.alert-success { background: var(--success-soft); color: #07801F; }

/* ---------- 登录 / 安装 ---------- */
.page-login, .page-install {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 10%, rgba(22, 93, 255, .16), transparent 45%),
        radial-gradient(circle at 85% 90%, rgba(15, 198, 194, .18), transparent 45%),
        #EEF3FB;
}
.login-shell, .install-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 28px 16px;
}
.login-card, .install-card {
    width: 100%;
    max-width: 420px;
    padding: 30px 26px;
    background: var(--card);
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
}
.install-card { max-width: 560px; }
.login-brand, .install-head { text-align: center; margin-bottom: 22px; }
.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, #2E6BFF, var(--primary));
    color: #fff;
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 1px;
    box-shadow: 0 10px 24px rgba(22, 93, 255, .28);
}
.brand-mark.small { width: 38px; height: 38px; font-size: 17px; border-radius: 11px; box-shadow: none; }
.login-brand h1, .install-head h1 {
    margin: 14px 0 4px;
    font-size: 21px;
    font-weight: 700;
}
.login-brand p, .install-head p { color: var(--muted); font-size: 13px; }
.login-form { margin-top: 8px; }
.login-form .btn { margin-top: 8px; height: 46px; font-size: 16px; letter-spacing: 2px; }
.login-tip {
    margin-top: 18px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
}
.install-head { text-align: center; }
.install-divider {
    position: relative;
    margin: 22px 0 16px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}
.install-divider::before {
    content: "";
    position: absolute;
    left: 0; right: 0; top: 50%;
    height: 1px;
    background: var(--border);
}
.install-divider span {
    position: relative;
    padding: 0 10px;
    background: #fff;
}

/* ---------- 应用外壳 ---------- */
.mock-banner {
    padding: 8px 16px;
    background: var(--warning-soft);
    color: #A35A00;
    font-size: 12px;
    text-align: center;
    border-bottom: 1px solid #FFE3C2;
}
.page-app { background: #E9EEF7; }
.app-shell {
    max-width: 900px;
    margin: 0 auto;
    min-height: 100vh;
    background: var(--bg);
    box-shadow: 0 0 40px rgba(29, 33, 41, .08);
}
.app-header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .94);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.app-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px 10px;
}
.app-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 700; white-space: nowrap; }
.brand-text span { font-size: 11px; color: var(--muted); white-space: nowrap; }
.app-user { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.user-name { font-size: 13px; color: var(--text-2); max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.logout-form { margin: 0; }
.role-tag {
    display: inline-flex;
    align-items: center;
    height: 22px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}
.role-admin { background: var(--primary-soft); color: var(--primary); }
.role-subadmin { background: #FFF4E5; color: #B25E00; }
.role-dealer { background: #E8F7EE; color: #1E7B45; }
.role-staff { background: #EEF1F6; color: var(--text-2); }

.tabs {
    display: flex;
    gap: 4px;
    padding: 0 10px 10px;
    overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    height: 38px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--text-2);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: color .18s, background .18s;
}
.tab-btn .icon { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.7; }
.tab-btn:hover { color: var(--primary); background: rgba(22, 93, 255, .06); }
.tab-btn.active {
    color: var(--primary);
    background: var(--primary-soft);
    border-color: rgba(22, 93, 255, .16);
}
.app-main { padding: 14px 14px 6px; }
.panel { display: none; animation: fade .2s ease; }
.panel.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.app-footer {
    padding: 18px 16px 26px;
    text-align: center;
    color: var(--muted);
    font-size: 11px;
}

/* ---------- 卡片 ---------- */
.card {
    padding: 16px;
    margin-bottom: 12px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.card-head { margin-bottom: 14px; }
.card-head h2 { font-size: 16px; font-weight: 700; }
.card-head p { margin-top: 3px; font-size: 12px; color: var(--muted); }
.card-head .count { color: var(--primary); font-weight: 600; }

/* ---------- 结果区 ---------- */
.result {
    margin-top: 14px;
    padding: 13px;
    background: #F8FAFD;
    border: 1px solid #EDF1F7;
    border-radius: 11px;
    font-size: 13px;
}
.result-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}
.result-note { margin-top: 10px; font-size: 12px; color: var(--muted); }
.loading, .empty {
    padding: 22px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}
.password-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 0;
    padding: 9px 12px;
    background: var(--success-soft);
    border: 1px dashed #A9E6B5;
    border-radius: 9px;
}
.password-box code {
    background: transparent;
    font-size: 16px;
    letter-spacing: 1px;
    color: #06741C;
    font-weight: 700;
}
.copy-btn {
    border: none;
    background: #fff;
    color: var(--primary);
    border-radius: 6px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

.field-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 9px;
}
.field-item {
    padding: 9px 11px;
    background: #fff;
    border: 1px solid #EDF1F7;
    border-radius: 9px;
}
.field-item .k { display: block; font-size: 11px; color: var(--muted); }
.field-item .v { display: block; margin-top: 2px; font-size: 14px; font-weight: 600; word-break: break-all; }

.binding {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 12px;
    padding: 9px 12px;
    background: #fff;
    border: 1px solid #EDF1F7;
    border-radius: 9px;
    font-size: 12px;
    color: var(--text-2);
}
.binding b { color: var(--text); font-weight: 600; }

.device-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.device-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    background: #fff;
    border-radius: 8px;
    font-size: 13px;
}
.device-item .no { font-family: "SFMono-Regular", Consolas, monospace; word-break: break-all; }

.badge {
    display: inline-flex;
    align-items: center;
    height: 21px;
    padding: 0 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}
.badge.success { background: var(--success-soft); color: #06741C; }
.badge.info { background: var(--primary-soft); color: var(--primary); }
.badge.warning { background: var(--warning-soft); color: #A35A00; }
.badge.danger { background: var(--danger-soft); color: #C62F2F; }
.badge.muted { background: #EEF1F6; color: var(--text-2); }

details.raw-data { margin-top: 12px; }
details.raw-data summary {
    cursor: pointer;
    font-size: 12px;
    color: var(--primary);
    user-select: none;
}
details.raw-data pre {
    margin: 8px 0 0;
    padding: 10px;
    max-height: 260px;
    overflow: auto;
    background: #101827;
    color: #D6E2F5;
    border-radius: 9px;
    font-size: 11px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
}

/* 设备测试数据（与原始数据分开的独立数据框） */
.testdata-card { margin-top: 18px; }
.testdata-card .card-head { padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.testdata-card .card-head h3 { font-size: 13px; color: var(--text-1); margin: 0 0 2px; }
.testdata-card .card-head p { margin: 0; font-size: 12px; color: var(--text-2); }
details.testdata-run {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #FAFBFD;
}
details.testdata-run summary {
    list-style: none;
    cursor: pointer;
    padding: 9px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    background: linear-gradient(180deg, #FFFFFF, #F4F6FA);
    font-size: 12px;
}
details.testdata-run summary::-webkit-details-marker { display: none; }
details.testdata-run summary::before {
    content: '▶';
    font-size: 9px;
    color: var(--text-2);
    transition: transform .15s;
}
details.testdata-run[open] summary::before { transform: rotate(90deg); }
.testdata-meta { padding: 10px 12px 0; }
.table-scroll { overflow-x: auto; padding: 8px 12px 12px; }
.testdata-table { width: 100%; border-collapse: collapse; font-size: 11px; min-width: 640px; }
.testdata-table th,
.testdata-table td {
    border: 1px solid var(--border);
    padding: 5px 7px;
    text-align: left;
    vertical-align: top;
}
.testdata-table th {
    background: #F4F6FA;
    color: var(--text-2);
    font-weight: 600;
    white-space: nowrap;
}
.testdata-table td { color: var(--text-1); }
.testdata-table .cell-data { max-width: 220px; word-break: break-all; }

/* 设备售后记录 */
.aftersales-card { margin-top: 18px; }
.aftersales-card .card-head { padding-bottom: 8px; border-bottom: 1px dashed var(--border); }
.aftersales-card .card-head h3 { font-size: 13px; color: var(--text-1); margin: 0 0 2px; }
.aftersales-card .card-head p { margin: 0; font-size: 12px; color: var(--text-2); }
details.aftersales-item {
    margin: 8px 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: #FAFBFD;
}
details.aftersales-item summary {
    list-style: none;
    cursor: pointer;
    padding: 9px 12px;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    background: linear-gradient(180deg, #FFFFFF, #F4F6FA);
    font-size: 12px;
}
details.aftersales-item summary::-webkit-details-marker { display: none; }
details.aftersales-item summary::before {
    content: '▶';
    font-size: 9px;
    color: var(--text-2);
    transition: transform .15s;
}
details.aftersales-item[open] summary::before { transform: rotate(90deg); }
details.aftersales-item .field-grid { padding: 10px 12px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border-radius: 10px; border: 1px solid #EDF1F7; }
table.data-table {
    width: 100%;
    min-width: 620px;
    border-collapse: collapse;
    background: #fff;
    font-size: 12.5px;
}
.data-table th, .data-table td {
    padding: 9px 11px;
    text-align: left;
    border-bottom: 1px solid #F0F3F8;
    vertical-align: top;
}
.data-table th {
    background: #F8FAFD;
    color: var(--text-2);
    font-weight: 600;
    white-space: nowrap;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table td.wrap { min-width: 180px; word-break: break-word; }
.data-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.user-cell { display: flex; flex-direction: column; }
.user-cell small { color: var(--muted); font-size: 11px; }

.pager {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--text-2);
}

/* ---------- 弹窗 / Toast ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, .48);
}
.modal-card {
    width: 100%;
    max-width: 420px;
    padding: 18px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.modal-head h3 { font-size: 16px; }
.modal-close {
    border: none;
    background: transparent;
    font-size: 22px;
    line-height: 1;
    color: var(--muted);
    cursor: pointer;
}
.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 80;
    max-width: 86vw;
    padding: 10px 18px;
    transform: translateX(-50%);
    border-radius: 10px;
    background: rgba(29, 33, 41, .92);
    color: #fff;
    font-size: 13px;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .2);
    text-align: center;
}
.toast.success { background: #06741C; }
.toast.fail { background: #C62F2F; }

/* ---------- 响应式 ---------- */
@media (min-width: 720px) {
    .app-main { padding: 18px 20px 8px; }
    .card { padding: 20px; margin-bottom: 16px; }
}
@media (max-width: 640px) {
    .form-row { grid-template-columns: 1fr; }
    .inline-form { flex-direction: column; align-items: stretch; }
    .inline-form .btn { width: 100%; }
    .app-user .user-name { display: none; }
    .brand-text span { display: none; }
    .login-card { padding: 26px 20px; }
    .date-range { display: flex; align-items: center; gap: 6px; }
    .date-range .input { padding: 0 8px; }
}
@media (min-width: 641px) {
    .date-range { display: flex; align-items: center; gap: 8px; }
}
