:root {
  --blue: #1668dc; --blue-dark: #0e4faf; --orange: #ff7d26; --green: #00b578;
  --red: #f5455c; --bg: #f2f6fc; --card: #ffffff; --line: #e6ecf5;
  --text: #22303f; --muted: #7a8aa0;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { text-decoration: none; color: inherit; }

/* ---- 布局 ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: linear-gradient(180deg,#0d4fb3,#0a3a8c); color: #fff; padding: 14px 0; flex-shrink: 0; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.logo { display: flex; align-items: center; gap: 10px; padding: 6px 18px 16px; border-bottom: 1px solid rgba(255,255,255,.15); }
.logo .badge { background: linear-gradient(135deg,#25d366,#0fbf6e); color: #00391d; font-weight: 800; font-style: italic; padding: 4px 9px; border-radius: 8px; font-size: 15px; }
.logo .name { font-weight: 700; font-size: 15px; line-height: 1.25; }
.logo .name small { display: block; font-weight: 400; font-size: 11px; opacity: .75; }
.nav-group { margin-top: 12px; }
.nav-group .grp { font-size: 11px; color: rgba(255,255,255,.5); padding: 8px 20px 4px; letter-spacing: 2px; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 20px; cursor: pointer; color: rgba(255,255,255,.82); border-left: 3px solid transparent; }
.nav-item:hover { background: rgba(255,255,255,.08); }
.nav-item.active { background: rgba(255,255,255,.14); border-left-color: #ffd21e; color: #fff; font-weight: 600; }
.nav-item .ic { width: 18px; text-align: center; }

.main { flex: 1; min-width: 0; }
.header { background: var(--card); border-bottom: 1px solid var(--line); padding: 12px 24px; display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 10; }
.header h1 { font-size: 18px; color: var(--blue-dark); }
.header .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.header .right { display: flex; gap: 10px; align-items: center; }
.content { padding: 20px 24px 40px; }

/* ---- 组件 ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--card); border-radius: 12px; padding: 16px 18px; box-shadow: 0 2px 8px rgba(22,104,220,.07); border-top: 3px solid var(--blue); position: relative; overflow: hidden; }
.kpi .t { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 26px; font-weight: 800; margin-top: 6px; color: var(--text); font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 11px; color: var(--muted); margin-top: 4px; }
.kpi.c1 { border-top-color: var(--blue); } .kpi.c1 .v { color: var(--blue); }
.kpi.c2 { border-top-color: var(--orange); } .kpi.c2 .v { color: var(--orange); }
.kpi.c3 { border-top-color: var(--green); } .kpi.c3 .v { color: var(--green); }
.kpi.c4 { border-top-color: var(--red); } .kpi.c4 .v { color: var(--red); }
.kpi.c5 { border-top-color: #8a5cf6; } .kpi.c5 .v { color: #8a5cf6; }

.panel { background: var(--card); border-radius: 12px; box-shadow: 0 2px 8px rgba(22,104,220,.07); padding: 16px 18px; margin-bottom: 18px; }
.panel h3 { font-size: 15px; color: var(--blue-dark); margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.panel h3 .extra { font-size: 12px; font-weight: 400; color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 1100px) { .grid-2 { grid-template-columns: 1fr; } }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th { background: #eef4fd; color: var(--blue-dark); text-align: left; padding: 8px 10px; font-size: 12px; white-space: nowrap; position: sticky; top: 0; }
/* 列头点击排序（升序▲/降序▼/第三次还原） */
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { background: #dbe8fb; }
.tbl th .sort-ind { color: var(--blue); font-size: 10px; }
.tbl td { padding: 7px 10px; border-bottom: 1px solid #f0f4fa; white-space: nowrap; }
.tbl tr:hover td { background: #f7fafe; }
/* 工单列表 结算状态 行级高亮（已结清/未结清/未结算 三档） */
.tbl tr.tr-settled    td { background: #f6fbf6; }                     /* 已结清：极浅绿 */
.tbl tr.tr-partial    td { background: #fffaef; }                     /* 未结清：极浅黄 */
.tbl tr.tr-unsettled  td { background: #fafafa; }                     /* 未结算：极浅灰 */
.tbl tr.tr-voided     td { background: #f5f5f5; color: #999; text-decoration: line-through; }
.tbl-wrap { max-height: 620px; overflow: auto; border: 1px solid var(--line); border-radius: 8px; }
.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl .money { color: var(--orange); font-weight: 600; text-align: right; }
.tbl .money-in { color: var(--red); font-weight: 600; text-align: right; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.tag-blue { background: #e8f1ff; color: var(--blue); }
.tag-green { background: #e4f8ef; color: var(--green); }
.tag-orange { background: #fff1e6; color: var(--orange); }
.tag-red { background: #ffecef; color: var(--red); }
.tag-gray { background: #f0f3f8; color: var(--muted); }

.btn { display: inline-flex; align-items: center; gap: 6px; border: none; border-radius: 8px; padding: 8px 16px; font-size: 13px; cursor: pointer; font-family: inherit; }
.btn-pri { background: var(--blue); color: #fff; }
.btn-pri:hover { background: var(--blue-dark); }
.btn-ghost { background: #fff; color: var(--blue); border: 1px solid var(--blue); }
.btn-warn { background: var(--orange); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.filter-bar select, .filter-bar input { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; background: #fff; font-family: inherit; }
.month-picker { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(13,42,80,.45); display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 40px 16px; overflow-y: auto; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 640px; max-width: 100%; padding: 22px 24px; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal h3 { color: var(--blue-dark); margin-bottom: 14px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.form-grid .full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.fld input, .fld select, .fld textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit; }
.modal .foot { margin-top: 18px; display: flex; justify-content: flex-end; gap: 10px; }

.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); background: #123d78; color: #fff; padding: 10px 22px; border-radius: 30px; z-index: 200; display: none; font-size: 13px; box-shadow: 0 4px 20px rgba(0,0,0,.25); }
.toast.err { background: var(--red); }

.chart { width: 100%; height: 300px; }
.empty { text-align: center; color: var(--muted); padding: 30px; }
tr.row-link { cursor: pointer; }
tr.row-link:hover td { background: #f2f7ff; }
.muted { color: var(--muted); }
.hint-card { background: linear-gradient(120deg,#e8f1ff,#f0fbf4); border: 1px solid #cfe3ff; border-radius: 12px; padding: 14px 18px; margin-bottom: 18px; font-size: 13px; line-height: 1.8; }
.hint-card b { color: var(--blue-dark); }
.qr-note { font-family: Consolas, monospace; background: #f4f8ff; border: 1px dashed var(--blue); border-radius: 8px; padding: 10px 14px; display: inline-block; }

/* ---- 报表专有样式 ---- */
.report-tbl { font-size: 12px; }
.report-tbl th { text-align: center; background: #dde9fb; }
.report-tbl td { text-align: center; }
.report-tbl td:nth-child(1) { text-align: left; background: #fafcff; }
.report-tbl .row-accident td { background: #fff5f5; }
.report-tbl .row-claim td { background: #fffaf0; }
.report-tbl .row-total td { background: #e6f7ee !important; color: var(--green); font-weight: 700; }
.report-tbl tfoot td { background: #e6f7ee; }

/* ---- 工单左列表右详情布局 ---- */
.split-layout { display: grid; grid-template-columns: 1.3fr 1fr; gap: 14px; }
.split-layout .split-left, .split-layout .split-right { margin-bottom: 0; max-height: calc(100vh - 200px); overflow: auto; }
@media (max-width: 1100px) { .split-layout { grid-template-columns: 1fr; } }
.kv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 13px; }
.kv-grid > div { display: flex; gap: 6px; padding: 5px 0; border-bottom: 1px dashed #f0f4fa; }
.kv-grid .k { color: var(--muted); min-width: 70px; }
.kv-grid .v { color: var(--text); font-weight: 500; }

/* 维修工单必填提示 + 当前账号 tag */
.hint-line { margin: 8px 0 4px; padding: 8px 12px; font-size: 12px; color: var(--muted); background: #fafbff; border: 1px dashed #d8e2ff; border-radius: 8px; }
.readonly-tag { background: linear-gradient(90deg,#eef5ff,#f7fbff); border: 1px dashed #b8d0f5; border-radius: 8px; padding: 8px 12px; color: #1d3f7a; font-size: 13px; }
.readonly-tag b { color: var(--blue-dark); margin: 0 4px; }

/* ---- 月报表可展开子集行 ---- */
.report-tbl .cat-row { cursor: pointer; }
.report-tbl .cat-row:hover td { background: #eef4ff; }
.sub-toggle { display: inline-block; margin-left: 6px; color: var(--blue); font-size: 11px; transition: transform .15s; }
.sub-row > td { padding: 0 !important; background: #f8fafd !important; }
.sub-tbl { font-size: 12px; margin: 0; }
.sub-tbl th { background: #eef3fb; text-align: center; }
.sub-tbl td { text-align: center; padding: 6px 10px; border-bottom: 1px solid #f0f4fa; }
.sub-tbl .sub-name { font-weight: 700; color: var(--blue-dark); background: #fafcff; text-align: left !important; }
.sub-tbl tr:last-child td { border-bottom: none; }

/* ---- 仪表盘毛利率预警 ---- */
.alert-panel { border: 1px solid #ffd7dc; background: linear-gradient(120deg,#fff7f8,#fffdf6); }
.alert-panel h3 { color: #c62828; }
.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 9px 12px;
  background: #fff; border: 1px solid #ffe3e6; border-left: 4px solid var(--red); border-radius: 8px; font-size: 13px; }
.alert-item .alert-no { color: var(--blue-dark); min-width: 52px; }
.alert-item .alert-plate { font-weight: 700; }
.alert-item .alert-ratio { font-weight: 800; min-width: 150px; }
.alert-item .alert-desc { flex: 1; min-width: 260px; }
.alert-item .btn { margin-left: auto; }

/* ---- 侧栏用户卡 ---- */
.user-chip { display: flex; align-items: center; gap: 10px; margin-top: auto;
  padding: 12px 14px; border-top: 1px solid #e8eef7; }
.user-chip .avatar { width: 36px; height: 36px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #1668dc, #6ea8ff); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700; }
.user-chip .u-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.user-chip .u-meta b { font-size: 13px; }
.user-chip .u-meta span { font-size: 11px; color: var(--muted); }
.sidebar { display: flex; flex-direction: column; }
.user-chip { border-top: 1px solid rgba(255,255,255,.15); }
.user-chip .u-meta b { color: #fff; }
.user-chip .u-meta span { color: rgba(255,255,255,.7); }
