:root {
  --navy: #12263f;
  --navy-2: #1b3552;
  --navy-3: #24425f;
  --accent: #2f7dd1;
  --accent-soft: #e8f1fb;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e3e8ef;
  --text: #1f2d3d;
  --muted: #6b7c93;
  --green: #1f9d6b;
  --green-soft: #e6f6ef;
  --amber: #b87503;
  --amber-soft: #fdf3e2;
  --red: #c0392b;
  --red-soft: #fdecea;
  --blue-soft: #e8f1fb;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(18, 38, 63, .06), 0 8px 24px rgba(18, 38, 63, .05);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.layout { display: flex; min-height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 224px;
  background: linear-gradient(180deg, var(--navy) 0%, #0e1f33 100%);
  color: #cfe0f2;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand .logo {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .5px;
  color: #fff;
}
.brand .sub { font-size: 11px; color: #89a6c4; margin-top: 4px; letter-spacing: .5px; }
.nav { padding: 12px 10px; overflow-y: auto; flex: 1; }
.nav-group { font-size: 11px; color: #7895b3; padding: 14px 12px 6px; letter-spacing: 1px; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cfe0f2;
  padding: 9px 12px;
  border-radius: 8px;
  margin-bottom: 2px;
  font-size: 13.5px;
  text-decoration: none;
}
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: var(--accent); color: #fff; box-shadow: 0 4px 12px rgba(47,125,209,.35); }
.nav .icon { width: 18px; text-align: center; opacity: .9; font-size: 14px; }
.nav .count {
  margin-left: auto;
  background: #d9534f;
  color: #fff;
  font-size: 11px;
  padding: 0 6px;
  border-radius: 9px;
  line-height: 18px;
}
.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #6f8cab; border-top: 1px solid rgba(255,255,255,.08); }

/* 主区域 */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 600; }
.topbar .spacer { flex: 1; }
.userbox { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600;
}
.userbox .who { line-height: 1.25; }
.userbox .who b { display: block; font-size: 13px; }
.userbox .who span { font-size: 11px; color: var(--muted); }
.content { padding: 22px 26px 40px; max-width: 1500px; width: 100%; }

/* 卡片 */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 12px;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 600; }
.card-head .sub { color: var(--muted); font-size: 12px; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

/* 统计卡 */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 20px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 700; margin-top: 4px; letter-spacing: .3px; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.stat .bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--accent); }
.stat.green .bar { background: var(--green); }
.stat.amber .bar { background: #e8a33d; }
.stat.red .bar { background: #d9534f; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 11px 14px; background: #f8fafc;
  color: #52657c; font-weight: 600; font-size: 12px; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.data tbody tr:hover { background: #f9fbfd; }
table.data tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }

/* 徽标 */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.badge-success { background: var(--green-soft); color: var(--green); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-danger { background: var(--red-soft); color: var(--red); }
.badge-info { background: var(--blue-soft); color: var(--accent); }
.badge-muted { background: #eef1f5; color: #66788e; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--text);
  padding: 7px 14px; border-radius: 8px; font-size: 13px; cursor: pointer;
  text-decoration: none; white-space: nowrap; transition: all .15s;
}
.btn:hover { border-color: #c8d2de; background: #f8fafc; text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #2870bd; border-color: #2870bd; color: #fff; }
.btn-danger { background: #fff; border-color: #e6b8b3; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px 22px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12.5px; color: #52657c; margin-bottom: 5px; font-weight: 500; }
.field label .req { color: var(--red); }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid #d7dfe8; border-radius: 8px;
  padding: 8px 11px; font-size: 13.5px; background: #fff; color: var(--text);
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,125,209,.12);
}
.field textarea { min-height: 78px; resize: vertical; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.form-actions { display: flex; gap: 10px; justify-content: flex-end; padding: 16px 18px; border-top: 1px solid var(--line); }

/* 筛选条 */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .field { min-width: 130px; }
.filters .field input, .filters .field select { padding: 6px 10px; font-size: 13px; }
.filters .grow { flex: 1; min-width: 190px; }

/* 提示 */
.flash { padding: 10px 14px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }
.flash-success { background: var(--green-soft); color: #17734e; border: 1px solid #bfe8d7; }
.flash-error { background: var(--red-soft); color: #a53024; border: 1px solid #f3c6c0; }

/* 分页 */
.pager { display: flex; gap: 6px; align-items: center; padding: 14px 18px; border-top: 1px solid var(--line); }
.pager a, .pager span {
  padding: 4px 10px; border-radius: 6px; font-size: 12.5px; border: 1px solid var(--line);
  color: var(--text);
}
.pager .cur { background: var(--accent); border-color: var(--accent); color: #fff; }
.pager .info { border: none; color: var(--muted); margin-left: auto; }

/* 详情 */
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.detail-head h2 { margin: 0; font-size: 20px; font-weight: 650; }
.detail-head .meta { color: var(--muted); font-size: 12.5px; margin-top: 4px; display: flex; gap: 14px; flex-wrap: wrap; }
.detail-head .spacer { flex: 1; }
.kv { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 24px; }
.kv .k { font-size: 11.5px; color: var(--muted); }
.kv .v { font-size: 13.5px; margin-top: 2px; word-break: break-all; }
.amount { font-size: 22px; font-weight: 700; color: var(--navy); }

/* 时间线 */
.timeline { position: relative; padding-left: 18px; }
.timeline:before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 2px; background: #e4eaf1; }
.timeline-item { position: relative; padding: 0 0 16px 12px; }
.timeline-item:before {
  content: ""; position: absolute; left: -18px; top: 6px; width: 9px; height: 9px;
  border-radius: 50%; background: #fff; border: 2px solid var(--accent);
}
.timeline-item .t { font-size: 13px; font-weight: 600; }
.timeline-item .m { font-size: 12px; color: var(--muted); }

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 18px; }
.tabs a {
  padding: 11px 14px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent;
}
.tabs a.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--accent); }

/* 登录页 */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 10%, #1d3f63 0%, #12263f 45%, #0b1828 100%);
  padding: 20px;
}
.login-card {
  width: 880px; max-width: 100%; background: #fff; border-radius: 16px; overflow: hidden;
  display: grid; grid-template-columns: 1.1fr .9fr; box-shadow: 0 30px 80px rgba(0,0,0,.35);
}
.login-side { padding: 46px 42px; background: linear-gradient(160deg, #16324f, #0f2337); color: #dbe9f7; }
.login-side h2 { font-size: 24px; margin: 0 0 10px; color: #fff; }
.login-side p { color: #9fb9d3; font-size: 13px; line-height: 1.8; }
.login-side ul { padding-left: 18px; color: #b8cde2; font-size: 12.5px; line-height: 2; }
.login-form { padding: 46px 40px; }
.login-form h3 { margin: 0 0 4px; font-size: 20px; }
.login-form .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 22px; }
.login-form .field { margin-bottom: 14px; }
.login-form .btn { width: 100%; padding: 10px; font-size: 14px; }
.demo-users { margin-top: 18px; font-size: 11.5px; color: var(--muted); line-height: 1.9; }
.demo-users code { background: #f2f5f9; padding: 1px 5px; border-radius: 4px; color: #3c5470; }

/* 打印 */
.print-only { display: none; }
@media print {
  .sidebar, .topbar, .filters, .pager, .no-print, .flash, .actions, .tabs { display: none !important; }
  body { background: #fff; }
  .content { padding: 0; max-width: none; }
  .card { box-shadow: none; border-color: #ccc; }
  .print-only { display: block; }
  table.data th { background: #eee !important; }
}

/* 空态 */
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .35; }

/* 计划行 */
.plan-row td, .material-row td { padding: 6px 8px; }
.plan-row input, .plan-row select, .material-row input, .material-row select {
  padding: 6px 8px; font-size: 12.5px;
}
.icon-btn {
  border: 1px solid var(--line); background: #fff; border-radius: 6px; width: 28px; height: 28px;
  cursor: pointer; color: var(--muted);
}
.icon-btn:hover { color: var(--red); border-color: #e6b8b3; }

@media (max-width: 1100px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .kv { grid-template-columns: repeat(2, 1fr); }
  .login-card { grid-template-columns: 1fr; }
  .login-side { display: none; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
}

/* 购销主体模糊查询下拉 */
.combo { position: relative; }
.combo-menu {
  position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px);
  max-height: 280px; overflow-y: auto; background: #fff;
  border: 1px solid #d8dee9; border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .16); display: none;
}
.combo-menu.open { display: block; }
.combo-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 8px 12px; border: 0; background: transparent;
  text-align: left; cursor: pointer; font: inherit; color: inherit;
}
.combo-item:hover, .combo-item:focus { background: #f1f5fb; outline: none; }
.combo-meta { color: #7b8794; font-size: 12px; white-space: nowrap; }
.combo-empty { padding: 10px 12px; color: #7b8794; font-size: 13px; }
/* 合同产品/配件明细的物料模糊查询 */
.material-combo .combo-menu { right: auto; min-width: 300px; max-width: 460px; }
.material-combo .combo-item > span:first-child {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* 安装明细的设备名称 / 型号模糊查询 */
.install-combo .combo-menu { right: auto; min-width: 240px; max-width: 420px; }
