/* ============ 全局变量与重置 ============ */
:root {
  --primary: #1e6fba;
  --primary-dark: #155a99;
  --primary-light: #e8f1fa;
  --topbar-h: 56px;
  --sidebar-w: 220px;
  --border: #d5dbe2;
  --bg: #f0f3f7;
  --text: #333;
  --text-light: #888;
  --danger: #e74c3c;
  --success: #27ae60;
  --warning: #f39c12;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; outline: none; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #b8c3cf; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 登录页 ============ */
.login-page {
  position: fixed; inset: 0;
  background: linear-gradient(135deg, #0f3d66 0%, #1e6fba 55%, #2a86d0 100%);
  display: flex; align-items: center; justify-content: center;
}
.login-page::before {
  content: ""; position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,.12) 0, transparent 40%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,.10) 0, transparent 40%);
}
.login-box {
  position: relative; z-index: 2;
  width: 860px; min-height: 480px;
  background: #fff; border-radius: 12px;
  display: flex; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
}
.login-left {
  width: 430px; padding: 60px 44px;
  background: linear-gradient(160deg, #1a5f9e, #0f3d66);
  color: #fff; display: flex; flex-direction: column; justify-content: center;
}
.login-left h1 { font-size: 26px; margin-bottom: 10px; letter-spacing: 1px; }
.login-left .sub { font-size: 14px; opacity: .8; margin-bottom: 30px; }
.login-left .feature-list { margin-top: 10px; }
.login-left .feature-list li {
  padding: 8px 0; font-size: 13px; opacity: .9;
  display: flex; align-items: center; gap: 10px;
}
.login-left .feature-list li::before {
  content: "✓"; width: 18px; height: 18px; border-radius: 50%;
  background: rgba(255,255,255,.2); font-size: 11px;
  display: inline-flex; align-items: center; justify-content: center;
}
.login-right { flex: 1; padding: 60px 50px; display: flex; flex-direction: column; justify-content: center; }
.login-right h2 { font-size: 22px; color: var(--primary-dark); margin-bottom: 6px; }
.login-right .tip { color: var(--text-light); margin-bottom: 26px; }
.form-item { margin-bottom: 18px; }
.form-item label { display: block; margin-bottom: 6px; color: #555; }
.form-item input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; transition: border .2s, box-shadow .2s;
}
.form-item input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,111,186,.15); }
.captcha-row { display: flex; gap: 10px; }
.captcha-row input { flex: 1; }
.captcha-img {
  width: 108px; height: 40px; border-radius: 6px;
  border: 1px solid var(--border); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-style: italic; font-weight: bold; letter-spacing: 4px;
  color: var(--primary-dark); user-select: none;
  background: repeating-linear-gradient(45deg, #f5f8fb, #f5f8fb 6px, #eef3f8 6px, #eef3f8 12px);
}
.btn-login {
  width: 100%; height: 44px; margin-top: 8px;
  background: linear-gradient(135deg, #1e6fba, #155a99);
  color: #fff; font-size: 16px; border: none; border-radius: 6px;
  transition: opacity .2s;
}
.btn-login:hover { opacity: .92; }
.login-msg { color: var(--danger); font-size: 12px; height: 18px; margin-top: 8px; text-align: center; }

/* ============ 主框架 ============ */
.app { display: flex; flex-direction: column; height: 100vh; }
.topbar {
  height: var(--topbar-h); background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 16px; position: relative; z-index: 20;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.topbar .logo { display: flex; align-items: center; gap: 10px; margin-right: 26px; }
.topbar .logo .logo-icon {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, #1e6fba, #2a86d0);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: bold;
}
.topbar .logo b { font-size: 17px; color: var(--primary-dark); }
.topbar .logo span { font-size: 12px; color: var(--text-light); }
.topbar .nav { display: flex; gap: 2px; flex: 1; }
.topbar .nav a {
  padding: 8px 14px; border-radius: 6px; font-size: 14px;
  color: #444; transition: background .2s;
}
.topbar .nav a:hover { background: var(--primary-light); }
.topbar .nav a.active { background: var(--primary); color: #fff; }
.topbar .user { display: flex; align-items: center; gap: 12px; }
.topbar .user .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: bold;
}
.topbar .user .name { font-size: 13px; }
.topbar .user .logout { color: var(--danger); font-size: 13px; }

.body { display: flex; flex: 1; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); background: #fff; border-right: 1px solid var(--border);
  padding: 10px 8px; overflow-y: auto; flex-shrink: 0;
}
.sidebar .group-title {
  font-size: 12px; color: var(--text-light); padding: 10px 10px 6px; letter-spacing: 1px;
}
.sidebar a.menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 10px 12px; border-radius: 6px; color: #444; font-size: 13px;
  transition: background .2s;
}
.sidebar a.menu-item:hover { background: var(--primary-light); color: var(--primary); }
.sidebar a.menu-item.active { background: var(--primary); color: #fff; }
.sidebar .menu-icon {
  width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.main { flex: 1; overflow-y: auto; padding: 16px 20px; }
.page-title { font-size: 16px; font-weight: bold; margin-bottom: 14px; display: flex; align-items: center; gap: 8px; }
.page-title::before { content: ""; width: 4px; height: 18px; background: var(--primary); border-radius: 2px; }

/* ============ 工具条 ============ */
.toolbar {
  background: #fff; border: 1px solid var(--border); border-bottom: none;
  padding: 10px 12px; border-radius: 8px 8px 0 0;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.toolbar .spacer { flex: 1; }
.toolbar-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 30px; padding: 0 12px; border-radius: 5px;
  border: 1px solid var(--border); background: #fff; color: #444; font-size: 13px;
  transition: all .18s; white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.success:hover { background: #219a53; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger:hover { background: #d03a2b; }
.btn.warning { background: var(--warning); border-color: var(--warning); color: #fff; }
.btn.warning:hover { background: #e08e0b; }
.btn.ghost { border: 1px dashed #b9c6d4; background: transparent; color: #688; }
.btn.ghost:hover { border-color: var(--primary); color: var(--primary); }
.btn.sm { height: 26px; padding: 0 8px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ============ 输入控件 ============ */
.input, .select, .textarea {
  height: 30px; padding: 0 9px; border: 1px solid var(--border);
  border-radius: 5px; font-size: 13px; background: #fff;
  transition: border .2s, box-shadow .2s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,111,186,.12);
}
.textarea { height: auto; padding: 8px 9px; resize: vertical; }
.search-input { width: 200px; }
.label { color: #555; margin-right: 4px; }

/* ============ 数据表格 ============ */
.grid-wrap {
  background: #fff; border: 1px solid var(--border); border-radius: 0 0 8px 8px;
  overflow: auto; position: relative;
}
table.grid {
  width: 100%; border-collapse: collapse; table-layout: auto; font-size: 13px;
}
table.grid thead th {
  background: #f5f8fb; color: #444; font-weight: 600;
  border-bottom: 1px solid var(--border); border-right: 1px solid #e8edf2;
  padding: 9px 8px; white-space: nowrap; position: sticky; top: 0; z-index: 5;
}
table.grid tbody td {
  border-bottom: 1px solid #eef1f5; border-right: 1px solid #f3f5f8;
  padding: 8px; word-break: break-word; vertical-align: middle;
}
table.grid tbody tr:hover { background: var(--primary-light); }
table.grid tbody tr.selected { background: #d8e9f7; }
table.grid .num { color: var(--text-light); text-align: center; width: 40px; }
table.grid .ops { white-space: nowrap; }
table.grid .ops a { color: var(--primary); margin-right: 8px; cursor: pointer; }
table.grid .ops a.danger { color: var(--danger); }
.grid-empty { text-align: center; color: var(--text-light); padding: 40px 0; }
.grid-empty .big { font-size: 40px; margin-bottom: 8px; opacity: .4; }

/* 分页 */
.pager {
  background: #fff; border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 8px 8px; padding: 8px 12px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.pager .page-btns { display: flex; gap: 4px; }
.pager .page-btn {
  min-width: 26px; height: 26px; border: 1px solid var(--border);
  border-radius: 4px; background: #fff; font-size: 12px; padding: 0 6px;
}
.pager .page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pager .info { color: var(--text-light); font-size: 12px; }

/* ============ 标签页 ============ */
.tabs { display: flex; gap: 2px; background: #fff; border: 1px solid var(--border); border-radius: 8px 8px 0 0; padding: 6px 8px 0; }
.tabs .tab {
  padding: 8px 18px; border-radius: 6px 6px 0 0; background: transparent;
  border: 1px solid transparent; color: #666; font-size: 13px; cursor: pointer;
}
.tabs .tab.active { background: #fff; border-color: var(--border); border-bottom-color: #fff; color: var(--primary); font-weight: 600; margin-bottom: -1px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 35, 55, .45);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: 10px; width: 560px; max-width: 94vw;
  max-height: 88vh; display: flex; flex-direction: column;
  box-shadow: 0 16px 50px rgba(0,0,0,.28); animation: popIn .2s ease;
}
@keyframes popIn { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal.lg { width: 860px; }
.modal.sm { width: 400px; }
.modal-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  font-size: 15px; font-weight: bold; color: var(--primary-dark);
}
.modal-close {
  width: 28px; height: 28px; border: none; background: #f2f5f8; border-radius: 50%;
  font-size: 14px; color: #888; transition: background .2s;
}
.modal-close:hover { background: var(--danger); color: #fff; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot {
  padding: 12px 18px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 8px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid label { display: block; margin-bottom: 5px; color: #555; font-size: 12px; }
.form-grid label .req { color: var(--danger); }
.form-grid .input, .form-grid .select, .form-grid .textarea { width: 100%; }

/* ============ 卡片 ============ */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; }
.card {
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  padding: 18px; transition: box-shadow .2s, transform .2s; position: relative; overflow: hidden;
}
.card:hover { box-shadow: 0 6px 20px rgba(30,111,186,.12); transform: translateY(-2px); }
.card .card-icon {
  width: 44px; height: 44px; border-radius: 10px; margin-bottom: 12px;
  display: flex; align-items: center; justify-content: center; font-size: 22px;
}
.card .card-num { font-size: 24px; font-weight: bold; color: var(--primary-dark); }
.card .card-title { color: var(--text-light); font-size: 13px; margin-top: 4px; }
.card .card-link {
  position: absolute; top: 14px; right: 14px; font-size: 12px; color: var(--primary); opacity: 0;
  transition: opacity .2s;
}
.card:hover .card-link { opacity: 1; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat-card {
  background: #fff; border-radius: 10px; padding: 18px 20px; border: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; transition: box-shadow .2s;
}
.stat-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.08); }
.stat-card .icon {
  width: 46px; height: 46px; border-radius: 12px; font-size: 22px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.stat-card .val { font-size: 24px; font-weight: bold; }
.stat-card .txt { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.panel {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 16px;
}
.panel-head {
  padding: 12px 16px; border-bottom: 1px solid var(--border);
  font-size: 14px; font-weight: bold; display: flex; align-items: center; justify-content: space-between;
}
.panel-body { padding: 16px; }

.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.quick-item {
  border: 1px solid var(--border); border-radius: 8px; padding: 14px 12px;
  text-align: center; cursor: pointer; transition: all .2s; background: #fafcff;
}
.quick-item:hover { border-color: var(--primary); background: var(--primary-light); transform: translateY(-2px); }
.quick-item .qi { font-size: 22px; margin-bottom: 6px; }
.quick-item .qt { font-size: 13px; color: #444; }

/* ============ 报价单编辑页 ============ */
.quo-topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 8px 16px;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex-shrink: 0;
}
.quo-toolbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 8px 16px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.quo-toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 6px; }
.editor-area { flex: 1; overflow: hidden; position: relative; background: #e8ebef; display: flex; flex-direction: column; align-items: center; padding: 20px; }
.page-sheet {
  background: #fff; width: 210mm; min-height: 297mm; box-shadow: 0 4px 20px rgba(0,0,0,.15);
  padding: 24mm; position: relative; overflow: visible;
}
.sheet-company { font-size: 22px; font-weight: bold; text-align: center; color: var(--primary-dark); margin-bottom: 2px; }
.sheet-contact { text-align: center; color: #666; font-size: 12px; margin-bottom: 16px; }
.sheet-title { font-size: 20px; font-weight: bold; text-align: center; margin: 14px 0; letter-spacing: 8px; }
.sheet-cust-info { margin-bottom: 14px; font-size: 13px; }
.sheet-cust-info .row { display: flex; gap: 24px; margin-bottom: 6px; }
.sheet-cust-info .row span { white-space: nowrap; }
.sheet-cust-info input, .sheet-cust-info .input {
  border: none; border-bottom: 1px solid #999; height: 24px; border-radius: 0; font-size: 13px; padding: 0 2px;
}
table.sheet-table { width: 100%; border-collapse: collapse; }
table.sheet-table th {
  background: #f2f5f8; border: 1px solid #333; padding: 7px 6px; font-size: 13px; text-align: center;
}
table.sheet-table td { border: 1px solid #333; padding: 6px; font-size: 13px; }
table.sheet-table td input {
  width: 100%; border: none; text-align: center; height: 24px; font-size: 13px; padding: 0;
  background: transparent;
}
table.sheet-table tbody tr.hover-row td { background: var(--primary-light); }
table.sheet-table tfoot td { border: 1px solid #333; padding: 6px; font-weight: bold; }
.sheet-note { margin-top: 16px; font-size: 12px; color: #666; }
.sheet-sign { margin-top: 28px; display: flex; justify-content: space-between; font-size: 13px; }
.sheet-sign .item { text-align: center; }
.sheet-sign .item .line { width: 140px; border-bottom: 1px solid #333; height: 40px; }

.quo-fabs {
  position: fixed; right: 26px; bottom: 26px; z-index: 50;
  display: flex; flex-direction: column; gap: 10px;
}
.fab {
  width: 46px; height: 46px; border-radius: 50%; border: none;
  display: flex; align-items: center; justify-content: center; font-size: 20px;
  box-shadow: 0 6px 16px rgba(0,0,0,.25); transition: transform .2s;
}
.fab:hover { transform: scale(1.1); }

/* 右侧客户/产品选择面板 */
.side-panel {
  position: fixed; right: 0; top: 0; bottom: 0; width: 380px; z-index: 60;
  background: #fff; box-shadow: -4px 0 24px rgba(0,0,0,.2);
  display: none; flex-direction: column; animation: slideIn .25s ease;
}
.side-panel.show { display: flex; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.side-panel .head { padding: 14px 16px; border-bottom: 1px solid var(--border); font-weight: bold; display: flex; justify-content: space-between; align-items: center; }
.side-panel .body { flex: 1; overflow-y: auto; padding: 12px; }
.side-panel .pick-item {
  border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px;
  cursor: pointer; transition: all .18s;
}
.side-panel .pick-item:hover { border-color: var(--primary); background: var(--primary-light); }
.side-panel .pick-item .t { font-weight: bold; }
.side-panel .pick-item .s { font-size: 12px; color: var(--text-light); margin-top: 3px; }

/* 打印 */
@media print {
  .topbar, .sidebar, .quo-toolbar, .quo-topbar, .quo-fabs, .side-panel, .toolbar { display: none !important; }
  .body { display: block; }
  .editor-area { padding: 0; background: #fff; }
  .page-sheet { width: auto; box-shadow: none; padding: 0; }
}

/* ============ 图表容器 ============ */
.chart-box { height: 320px; }
.chart-box.sm { height: 240px; }

/* 徽标 */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px;
}
.badge.blue { background: #e1f0fd; color: #1e6fba; }
.badge.green { background: #e3f6ec; color: #27ae60; }
.badge.orange { background: #fdf0e0; color: #f39c12; }
.badge.red { background: #fde8e6; color: #e74c3c; }
.badge.gray { background: #f0f2f5; color: #777; }

/* 其他工具类 */
.mt8 { margin-top: 8px; } .mb8 { margin-bottom: 8px; } .ml8 { margin-left: 8px; } .mr8 { margin-right: 8px; }
.flex { display: flex; align-items: center; } .between { justify-content: space-between; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.muted { color: var(--text-light); }
.danger-text { color: var(--danger); }
.primary-text { color: var(--primary); }
.empty-tip { text-align: center; color: #aaa; padding: 30px 0; }
