/* ============================================================
   警用无人机执法平台 v4.0
   公安蓝白配色 · 明亮干净
   =========================================================== */

/* ----- CSS 变量 ----- */
:root {
    --bg:             #f4f6f9;
    --white:          #fff;
    --border:         #e1e6ed;
    --border-light:   #eef1f6;
    --text:           #1e293b;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;
    --placeholder:    #94a3b8;   /* 新增 */

    /* 公安蓝 */
    --primary:        #1e5eb8;
    --primary-dark:   #0f2d52;
    --primary-light:  #3b82f6;
    --primary-bg:     #eef4fc;
    --primary-border: #c5d9f2;

    /* 金色点缀 */
    --gold:           #c8940c;
    --gold-light:     #fdf8ed;

    /* 红色警示 */
    --danger:         #dc2626;
    --danger-hover:   #b91c1c;
    --danger-bg:      #fef2f2;

    /* 状态 */
    --success:        #16a34a;
    --success-bg:     #f0fdf4;
    --warning:        #ea580c;

    --tag-bg:         #f1f5f9;
    --tag-selected-bg:#1e5eb8;
    --tag-selected-text:#fff;

    --shadow:         0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
    --shadow-md:      0 4px 6px rgba(0,0,0,.05), 0 2px 4px rgba(0,0,0,.04);
    --radius:         10px;
    --radius-sm:      6px;
    --font-base:      15px;
    --font-sm:        13px;
    --font-xs:        11px;
}

/* ----- Reset ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Microsoft YaHei", "Helvetica Neue", sans-serif;
    font-size: var(--font-base);
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    line-height: 1.5;
}

/* ----- 工具类 ----- */
.hidden       { display: none !important; }
.flex         { display: flex; gap: 10px; }
.flex-1       { flex: 1; min-width: 0; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-wrap    { display: flex; flex-wrap: wrap; gap: 6px; }

/* ----- 页面容器 ----- */
.page {
    padding: 14px;
    max-width: 600px;
    margin: 0 auto;
    min-height: calc(100vh - 100px);
}

/* ----- 顶栏 ----- */
.header {
    background: var(--primary-dark);
    color: #fff;
    padding: 13px 16px;
    font-size: 17px;
    font-weight: 700;
    text-align: center;
    letter-spacing: 1px;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 2px solid var(--gold);
}

/* ----- 标签栏 ----- */
.tab-bar {
    display: flex;
    background: var(--white);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 9;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.tab-item {
    flex: 1; min-width: 56px;
    padding: 12px 4px; text-align: center;
    font-size: var(--font-sm); font-weight: 600;
    color: var(--text-secondary); cursor: pointer;
    white-space: nowrap;
    border-bottom: 3px solid transparent;
    transition: color .15s, border-color .15s;
    user-select: none;
}
.tab-item.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* ----- 卡片 ----- */
.card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.card-title {
    font-weight: 700;
    font-size: 15px;
    color: var(--primary-dark);
    margin-bottom: 10px;
}

/* ----- 按钮 ----- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    width: 100%; padding: 12px 20px; border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff; font-size: 15px; font-weight: 600;
    cursor: pointer; transition: background .15s;
    user-select: none;
}
.btn:active  { background: #1650a0; }
.btn:disabled { background: #94a3b8; cursor: not-allowed; }
.btn-sm       { width: auto; padding: 7px 14px; font-size: var(--font-sm); }
.btn-outline  {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 10px 18px;
    border: 1.5px solid var(--primary-border);
    border-radius: var(--radius-sm);
    background: var(--white);
    color: var(--primary);
    font-size: 14px; font-weight: 600;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    user-select: none;
}
.btn-outline:active { background: var(--primary-bg); border-color: var(--primary); }
.btn-outline.btn-sm { padding: 7px 14px; font-size: var(--font-sm); }
.btn-danger { background: var(--danger); color: #fff; border: none; }
.btn-danger:active { background: var(--danger-hover); }

/* ----- 表单 ----- */
input, select, textarea {
    width: 100%; padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px; color: var(--text);
    background: var(--white);
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(30,94,184,.12);
}
input::placeholder, textarea::placeholder { color: #b0bcc8; }
input:disabled, select:disabled { background: #f8fafc; color: #94a3b8; }
label {
    display: block; font-size: var(--font-sm);
    font-weight: 600; color: var(--text-secondary);
    margin: 8px 0 4px;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 12px center;
    padding-right: 36px;
}

/* ----- ★ checkbox ----- */
input[type="checkbox"] {
    width: 20px; height: 20px; min-width: 20px;
    appearance: none; -webkit-appearance: none;
    border: 2px solid #c5d5e8; border-radius: 4px;
    background: #fff; cursor: pointer; position: relative;
    transition: all .15s; padding: 0; margin: 0;
    vertical-align: middle; flex-shrink: 0;
}
input[type="checkbox"]:checked {
    background: var(--primary); border-color: var(--primary);
}
input[type="checkbox"]:checked::after {
    content: ""; position: absolute; left: 5px; top: 2px;
    width: 6px; height: 10px;
    border: 2px solid #fff; border-top: none; border-left: none;
    transform: rotate(45deg);
}

/* ----- ★ fw-* 按钮（步骤3）----- */
.fw-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 4px; padding: 9px 14px; border-radius: var(--radius-sm);
    font-size: var(--font-sm); font-weight: 600; cursor: pointer;
    transition: all .15s; white-space: nowrap;
    border: 1.5px solid var(--primary-border);
    background: var(--white); color: var(--primary);
}
.fw-btn:active       { background: var(--primary-bg); border-color: var(--primary); }
.fw-btn--ai          { border-color: var(--primary); background: var(--primary); color: #fff; }
.fw-btn--ai:active   { background: #1650a0; }
.fw-btn:disabled     { border-color: #e1e6ed; background: #f8fafc; color: #b0bcc8; cursor: not-allowed; }
.fw-btn--ai:disabled { border-color: #e1e6ed; background: #f8fafc; color: #b0bcc8; }

/* ----- ★ fw-* 输入框 ----- */
.fw-inp {
    width: 100%; padding: 9px 11px;
    border: 1px solid #dce3ed; border-radius: var(--radius-sm);
    font-size: 16px; color: var(--text);
    background: #f9fafc;
    transition: border-color .15s, box-shadow .15s;
}
.fw-inp:focus        { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,94,184,.08); background: #fff; }
.fw-inp::placeholder { color: #b0bcc8; }

/* ----- ★ fw-* 卡片（步骤3）----- */
.fw-card {
    background: var(--white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px;
    box-shadow: var(--shadow);
}
.fw-card-hd    { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.fw-card-tt    { font-weight: 600; font-size: 14px; color: var(--primary-dark); }
.fw-card-st    { font-size: 10px; color: var(--text-muted); letter-spacing: .5px; font-weight: 500; }
.fw-card-st.done { color: var(--success); }
.fw-row        { display: flex; gap: 12px; }
.fw-preview    {
    width: 96px; min-width: 96px; height: 96px;
    border: 2px dashed #d0dae8; border-radius: 8px;
    background: #f9fafc; display: flex; align-items: center;
    justify-content: center; cursor: pointer; overflow: hidden;
    transition: border-color .2s, background .2s;
}
.fw-preview:active     { border-color: var(--primary); background: var(--primary-bg); }
.fw-preview.has-photo  { border: 2px solid var(--primary-light); background: #fff; }
.fw-actions   { flex: 1; display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.fw-result    { margin-top: 2px; font-size: var(--font-xs); color: var(--text-secondary); min-height: 16px; line-height: 1.4; font-weight: 500; }
.fw-result.ok { color: var(--success); }
.fw-result.err{ color: var(--danger); }
.fw-ids       { display: flex; gap: 6px; }
.fw-ids .fw-inp { flex: 1; }

/* ----- ★ fw-* 弹窗选项 ----- */
.fw-pick-opt {
    cursor: pointer; padding: 18px 22px;
    border: 1.5px solid #e1e6ed; border-radius: 10px;
    text-align: center; transition: .15s;
    background: #fff; min-width: 90px;
}
.fw-pick-opt:hover   { background: var(--primary-bg); border-color: var(--primary-border); }
.fw-pick-opt:active  { background: #dce8f6; }

/* ----- 标签 / 问题选项 ----- */
.tag {
    display: inline-block; padding: 6px 14px;
    border: 1.5px solid #dce3ed;
    background: var(--tag-bg); border-radius: 20px;
    font-size: var(--font-sm); cursor: pointer;
    user-select: none; transition: all .15s;
    color: var(--text-secondary);
}
.tag.selected, .tag:active {
    background: var(--tag-selected-bg);
    color: var(--tag-selected-text);
    border-color: var(--tag-selected-bg);
}

/* ----- 步骤条 ----- */
.step-bar {
    display: flex; align-items: center;
    padding: 14px 20px; background: var(--white);
    border-bottom: 1px solid var(--border);
    justify-content: center; max-width: 600px; margin: 0 auto;
}
.step-dot {
    width: 30px; height: 30px; border-radius: 50%;
    background: #e8edf4; color: #94a3b8;
    font-size: var(--font-sm); font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0; transition: background .2s, color .2s;
}
.step-dot.active { background: var(--primary); color: #fff; box-shadow: 0 0 0 4px rgba(30,94,184,.15); }
.step-dot.done   { background: var(--gold); color: #fff; }
.step-line {
    flex: 1; height: 3px; background: #e8edf4;
    min-width: 12px; margin: 0 2px; transition: background .2s;
}
.step-line.done { background: var(--primary-light); }

/* ----- 照片网格 ----- */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-slot {
    position: relative; aspect-ratio: 1;
    background: #f9fafc; border: 2px dashed #dce3ed; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; overflow: hidden;
    font-size: 32px; color: #c8d4e4;
    transition: border-color .15s;
}
.photo-slot:active { border-color: var(--primary); }
.photo-slot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.delete-photo {
    position: absolute; top: 4px; right: 4px;
    width: 22px; height: 22px; border-radius: 50%;
    background: rgba(220,38,38,.85); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; cursor: pointer; line-height: 1;
}

/* ----- 弹窗 ----- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(15,45,82,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 20px;
}
.modal {
    background: var(--white); border-radius: 14px;
    padding: 20px; width: 100%; max-width: 420px;
    max-height: 85vh; overflow-y: auto;
    box-shadow: 0 8px 40px rgba(15,45,82,.15);
}
.modal-header {
    font-size: 17px; font-weight: 700;
    margin-bottom: 14px; color: var(--primary-dark);
}

/* ----- Toast ----- */
.toast {
    position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
    padding: 10px 24px; border-radius: 20px;
    font-size: 14px; font-weight: 600; color: #fff;
    z-index: 200; opacity: 0; pointer-events: none;
    transition: opacity .25s; max-width: 90vw; text-align: center;
}
.toast.show       { opacity: 1; }
.toast.success    { background: var(--success); }
.toast.error      { background: var(--danger); }
.toast.info       { background: var(--primary); }

/* ----- Loading ----- */
.loading-overlay {
    position: fixed; inset: 0;
    background: rgba(244,246,249,.8);
    display: flex; align-items: center; justify-content: center;
    z-index: 150;
}
.spinner {
    width: 36px; height: 36px;
    border: 4px solid #dce3ed;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- 签名画布 ----- */
.sign-canvas {
    width: 100%; max-width: 400px; height: 140px;
    border: 2px dashed #d0dae8; border-radius: 8px;
    background: #fafbfd; cursor: crosshair; display: block;
    touch-action: none;
}

/* ----- 快捷选择 ----- */
.quick-select { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.quick-select-item {
    padding: 5px 12px; border: 1px solid #dce3ed;
    border-radius: 16px; font-size: var(--font-sm);
    cursor: pointer; background: #f9fafc; user-select: none;
    transition: all .15s; color: var(--text-secondary);
    display: inline-block; margin: 2px;
}
.quick-select-item.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
.quick-select-item:active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ----- 登录页 ----- */
#loginPage {
    background: linear-gradient(180deg, #eaf0f8 0%, #f4f6f9 100%);
    min-height: 100vh; min-height: 100dvh;
}

/* ----- collect-input ----- */
.collect-input {
    width: 100%; padding: 9px 11px;
    border: 1px solid #dce3ed; border-radius: var(--radius-sm);
    font-size: 16px; color: var(--text);
    background: #f9fafc;
    transition: border-color .15s;
}
.collect-input:focus { outline: none; border-color: var(--primary); background: #fff; }

/* ----- 小屏 ----- */
@media (max-width: 380px) {
    .page { padding: 10px; }
    .card { padding: 12px 14px; }
    .photo-grid { grid-template-columns: repeat(2, 1fr); }
    .fw-preview { width: 80px; min-width: 80px; height: 80px; }
    .fw-row { gap: 8px; }
}

/* ----- 大屏 ----- */
@media (min-width: 768px) {
    .page { padding: 20px; max-width: 900px; }
}

/* ----- 草稿提示栏 ----- */
.draft-banner {
    background: #fef9e7;
    border: 1px solid #f9e076;
    border-radius: var(--radius);
    padding: 10px 14px;
    margin: 0 14px 10px 14px;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.draft-banner-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 13px;
    color: #7d6608;
}
.draft-banner-inner b {
    color: var(--primary-dark);
}
.draft-banner-btns {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}
.btn-danger-outline {
    display: inline-flex; align-items: center; justify-content: center; gap: 4px;
    padding: 7px 14px;
    border: 1.5px solid #e74c3c;
    border-radius: var(--radius-sm);
    background: var(--white);
    color: #e74c3c;
    font-size: var(--font-sm); font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    user-select: none;
}
.btn-danger-outline:active { background: #fef2f2; }

/* ----- 草稿历史卡片 ----- */
.draft-card { padding: 12px 14px; }
.draft-card-top {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 8px;
}
.draft-step-badge {
    background: var(--primary-bg);
    color: var(--primary-dark);
    padding: 3px 10px; border-radius: 12px;
    font-size: 12px; font-weight: 600;
}
.draft-time { font-size: 11px; color: var(--text-muted); }
.draft-card-body { margin-bottom: 10px; }
.draft-info-row {
    display: flex; align-items: baseline; gap: 6px;
    font-size: 13px; margin-bottom: 2px;
}
.draft-label {
    color: var(--text-muted); font-size: 11px;
    min-width: 56px; flex-shrink: 0;
}
.draft-value {
    color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.draft-tags {
    display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px;
}
.draft-mini-tag {
    display: inline-block;
    padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 500;
    background: #eef4fc; color: var(--primary);
}
.draft-mini-tag--empty {
    background: #f5f5f5; color: #bbb;
}
.draft-card-actions {
    display: flex; gap: 8px; border-top: 1px solid var(--border-light);
    padding-top: 10px;
}
