:root {
  --primary: #5B8DEF;
  --primary-light: #EAF1FE;
  --primary-dark: #3E6FD0;
  --success: #52c41a;
  --success-bg: #f6ffed;
  --warning: #faad14;
  --danger: #ff4d4f;
  --text: #1f1f1f;
  --text-secondary: #666;
  --text-muted: #999;
  --border: #e8e8e8;
  --bg: #F0F4FB;
  --bg-white: #fff;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,0.04);
  --sidebar-w: 200px;
  --header-h: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; }

.app-layout { display: flex; min-height: 100vh; }

/* ===== 侧边栏 ===== */
.sidebar { width: var(--sidebar-w); background: var(--bg-white); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; position: sticky; top: 0; height: 100vh; }
.sidebar-brand { height: var(--header-h); display: flex; align-items: center; padding: 0 20px; border-bottom: 1px solid var(--border); gap: 10px; }
.sidebar-brand .logo { width: 32px; height: 32px; border-radius: 8px; background: var(--primary); display: flex; align-items: center; justify-content: center; color: #fff; font-size: 16px; font-weight: 700; }
.sidebar-brand .brand-name { font-size: 16px; font-weight: 700; color: var(--text); }
.sidebar-brand .brand-name span { color: var(--primary); }
.sidebar-nav { flex: 1; padding: 8px; overflow-y: auto; }
.nav-group { margin-bottom: 8px; }
.nav-group-label { font-size: 11px; color: var(--text-muted); padding: 8px 12px 4px; letter-spacing: 0.5px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 6px; cursor: pointer; color: var(--text-secondary); font-size: 13px; transition: all 0.15s; border: none; background: none; width: 100%; text-align: left; }
.nav-item:hover { background: var(--primary-light); color: var(--primary); }
.nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: 500; }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); }
.user-row { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; color: var(--primary); font-weight: 600; font-size: 13px; }
.user-name { font-size: 13px; color: var(--text); }

/* ===== 主区域 ===== */
.main-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: var(--header-h); background: var(--bg-white); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 24px; flex-shrink: 0; position: sticky; top: 0; z-index: 10; }
.topbar-left { display: flex; align-items: center; gap: 16px; }
.topbar-title { font-size: 15px; font-weight: 600; }
.topbar-stats { display: flex; gap: 16px; }
.topbar-stat { font-size: 12px; color: var(--text-muted); }
.topbar-stat strong { color: var(--primary); font-size: 14px; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.workspace { flex: 1; padding: 16px; max-width: 900px; overflow-y: auto; }

/* ===== 步骤卡片 ===== */
.step-section { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; margin-bottom: 12px; box-shadow: var(--shadow); transition: all 0.2s; }
.step-section.active { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.step-section.done { border-left: 3px solid var(--success); }
.step-section.disabled { opacity: 0.5; pointer-events: none; }
.step-header { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.step-number { width: 26px; height: 26px; border-radius: 50%; background: var(--bg); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; color: var(--text-muted); border: 2px solid var(--border); flex-shrink: 0; }
.step-section.active .step-number { background: var(--primary); color: #fff; border-color: var(--primary); }
.step-label { font-size: 13px; font-weight: 600; }
.step-hint { font-size: 11px; color: var(--text-muted); }
.step-status { margin-left: auto; font-size: 12px; padding: 2px 10px; border-radius: 12px; font-weight: 500; }
.step-status.waiting { background: var(--bg); color: var(--text-muted); }
.step-status.processing { background: var(--primary-light); color: var(--primary); }
.step-status.done { background: var(--success-bg); color: var(--success); }

/* ===== 上传区 ===== */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 24px 16px; text-align: center; cursor: pointer; transition: all 0.2s; background: var(--bg); }
.upload-zone:hover { border-color: var(--primary); background: var(--primary-light); }
.upload-zone.dragover { border-color: var(--primary); background: var(--primary-light); }
.upload-icon { font-size: 40px; margin-bottom: 12px; }
.upload-text { font-size: 14px; color: var(--text-secondary); }
.upload-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
#fileInput { display: none; }
.upload-preview img { max-width: 100%; max-height: 220px; border-radius: 6px; }
.upload-preview { position: relative; }
.upload-preview-actions { position: absolute; top: 8px; right: 8px; }
.upload-remove { width: 28px; height: 28px; border-radius: 50%; background: rgba(0,0,0,0.5); color: #fff; border: none; font-size: 14px; }
.recognizing { display: flex; flex-direction: column; align-items: center; padding: 20px; gap: 12px; }
.recognizing .spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 表单 ===== */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.form-grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.form-field { display: flex; flex-direction: column; gap: 4px; }
.form-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.form-input, .form-select { height: 40px; padding: 0 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; color: var(--text); background: var(--bg-white); transition: border-color 0.15s; outline: none; width: 100%; }
.form-input:focus, .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.form-input:disabled { background: var(--bg); color: var(--text-muted); }
.form-select { cursor: pointer; appearance: none; }
.form-hint { font-size: 11px; color: var(--text-muted); }

/* ===== 费率卡片 ===== */
.fee-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 10px; }
.fee-card { background: var(--bg); border-radius: var(--radius); padding: 12px; text-align: center; border: 1px solid var(--border); }
.fee-card-label { font-size: 11px; color: var(--text-muted); margin-bottom: 6px; }
.fee-card-rate { display: flex; align-items: center; justify-content: center; gap: 4px; margin-bottom: 6px; }
.rate-input { width: 64px; height: 36px; text-align: center; border: 1px solid var(--border); border-radius: 6px; font-size: 16px; font-weight: 600; color: var(--primary); outline: none; background: var(--bg-white); }
.rate-input:focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.rate-suffix { font-size: 14px; color: var(--text-secondary); }
.fee-card-result { font-size: 13px; color: var(--text-secondary); }
.fee-card-result strong { color: var(--text); font-size: 15px; }

.fee-info-row { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.fee-info-row .form-input { width: 140px; height: 36px; flex-shrink: 0; }
.fee-info-row .form-select { width: 120px; height: 36px; flex-shrink: 0; }
.fee-total-section { margin-left: auto; display: flex; align-items: baseline; gap: 8px; }
.fee-total-inline { font-size: 13px; color: var(--primary-dark); font-weight: 500; white-space: nowrap; }
.fee-total-amount-inline { font-size: 22px; font-weight: 700; color: var(--primary-dark); }

.step-actions { display: flex; gap: 8px; margin-top: 10px; }
.fee-actions-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }

/* ===== 按钮 ===== */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 18px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-white); color: var(--text); font-size: 13px; cursor: pointer; transition: all 0.15s; white-space: nowrap; font-weight: 500; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-outline { background: transparent; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* ===== 渠道选择器（并行交互） ===== */
.channel-panel { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.channel-panel .form-select { width: 180px; }

/* ===== 识别结果提示 ===== */
.ocr-status { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-muted); }
.ocr-status .spinner { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; display: inline-block; }

/* ===== Toast ===== */
.result-toast { position: fixed; top: 24px; left: 50%; transform: translateX(-50%); background: var(--success); color: #fff; padding: 10px 24px; border-radius: 8px; font-size: 14px; font-weight: 500; z-index: 100; box-shadow: 0 4px 12px rgba(0,0,0,0.15); }
.result-toast.error { background: var(--danger); }

/* ===== 历史记录 ===== */
.history-section { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow); margin-bottom: 12px; overflow: hidden; }
.history-header { display: flex; align-items: center; gap: 10px; padding: 12px 16px; cursor: pointer; user-select: none; }
.history-header:hover { background: var(--bg); }
.history-title { font-size: 13px; font-weight: 600; }
.history-count { font-size: 11px; color: var(--text-muted); background: var(--bg); padding: 1px 8px; border-radius: 10px; }
.history-toggle { margin-left: auto; font-size: 11px; color: var(--primary); }
.history-list { max-height: 400px; overflow-y: auto; border-top: 1px solid var(--border); }
.history-empty { text-align: center; padding: 24px; color: var(--text-muted); font-size: 13px; }
.history-item { border-bottom: 1px solid var(--border); cursor: pointer; }
.history-item:hover { background: var(--bg); }
.history-item-header { display: flex; align-items: center; gap: 8px; padding: 10px 16px; }
.history-item-plate { font-weight: 600; font-size: 13px; color: var(--text); min-width: 90px; }
.history-item-insurer { font-size: 12px; color: var(--text-secondary); background: var(--bg); padding: 1px 8px; border-radius: 4px; }
.history-item-fee { margin-left: auto; font-size: 13px; font-weight: 600; color: var(--primary-dark); }
.history-item-time { font-size: 11px; color: var(--text-muted); min-width: 70px; text-align: right; }
.history-item-detail { display: none; padding: 0 16px 10px; font-size: 12px; color: var(--text-secondary); border-top: 1px dashed var(--border); }
.history-item-detail.show { display: block; }
.history-detail-row { display: flex; gap: 16px; padding: 5px 0; }
.history-detail-label { color: var(--text-muted); min-width: 72px; }

/* ===== 费率政策页 ===== */
.policy-list { display: flex; flex-direction: column; gap: 10px; }
.policy-card { background: var(--bg-white); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.policy-card-title { font-weight: 600; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.policy-company-tag { font-size: 11px; background: var(--primary-light); color: var(--primary); padding: 2px 8px; border-radius: 10px; font-weight: 500; }
.policy-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.policy-table th, .policy-table td { border: 1px solid var(--border); padding: 6px 8px; text-align: center; }
.policy-table th { background: var(--bg); color: var(--text-secondary); font-weight: 500; }
.policy-notice { background: var(--warning); color: #5d4037; padding: 10px 14px; border-radius: 6px; font-size: 12px; margin-bottom: 12px; }

/* ===== 个人中心抽屉 ===== */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 200; display: none; }
.drawer-mask.show { display: block; }
.drawer { position: fixed; top: 0; right: 0; width: 360px; max-width: 90vw; height: 100vh; background: var(--bg-white); z-index: 201; box-shadow: -4px 0 16px rgba(0,0,0,0.1); transform: translateX(100%); transition: transform 0.25s; display: flex; flex-direction: column; }
.drawer.show { transform: translateX(0); }
.drawer-header { padding: 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 12px; }
.drawer-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--primary-light); display: flex; align-items: center; justify-content: center; color: var(--primary); font-size: 20px; font-weight: 700; }
.drawer-title { font-size: 15px; font-weight: 600; }
.drawer-sub { font-size: 12px; color: var(--text-muted); }
.drawer-close { margin-left: auto; background: none; border: none; font-size: 20px; color: var(--text-muted); }
.drawer-body { flex: 1; padding: 20px; overflow-y: auto; }
.credit-box { background: var(--primary-light); border-radius: var(--radius); padding: 16px; text-align: center; margin-bottom: 16px; }
.credit-num { font-size: 28px; font-weight: 700; color: var(--primary); }
.credit-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.credit-bar { height: 6px; background: #fff; border-radius: 3px; margin-top: 10px; overflow: hidden; }
.credit-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width 0.3s; }
.drawer-section-title { font-size: 12px; color: var(--text-muted); margin: 16px 0 8px; }
.log-item { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 13px; }
.log-item .log-remark { color: var(--text); }
.log-item .log-amount { font-weight: 600; }
.log-item .log-amount.plus { color: var(--success); }
.log-item .log-amount.minus { color: var(--danger); }
.drawer-footer { padding: 16px 20px; border-top: 1px solid var(--border); }
.logout-btn { width: 100%; }

.page-placeholder { text-align: center; padding: 80px 20px; }
.page-placeholder .ph-icon { font-size: 56px; margin-bottom: 16px; }

.app-footer { text-align: center; padding: 12px 24px; color: var(--text-muted); font-size: 12px; border-top: 1px solid var(--border); background: var(--bg-white); }
.app-footer a { color: var(--text-muted); }
.app-footer a:hover { color: var(--primary); }

/* ===== 登录页 ===== */
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #5B8DEF 0, #3E6FD0 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; padding: 40px; width: 400px; max-width: 100%; text-align: center; box-shadow: 0 8px 32px rgba(0,0,0,0.15); }
.login-logo { width: 56px; height: 56px; border-radius: 14px; background: var(--primary); color: #fff; font-size: 28px; font-weight: 700; display: flex; align-items: center; justify-content: center; margin: 0 auto 16px; }
.login-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-sub { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.qr-box { width: 220px; height: 220px; margin: 0 auto 16px; border: 1px solid var(--border); border-radius: 12px; display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative; }
.qr-box img { width: 100%; height: 100%; object-fit: contain; }
.qr-placeholder { color: var(--text-muted); font-size: 13px; }
.qr-mask { position: absolute; inset: 0; background: rgba(255,255,255,0.85); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; font-size: 13px; color: var(--text-secondary); }
.login-tip { font-size: 12px; color: var(--text-muted); margin-bottom: 16px; }
.login-tip code { background: var(--bg); padding: 2px 6px; border-radius: 4px; }
.phone-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0; color: var(--text-muted); font-size: 12px; }
.phone-divider::before, .phone-divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }
