/* commex-COS 全局样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --primary: #0e7490;
  --primary-dark: #155e75;
  --primary-light: #ecfeff;
  --bg: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --muted: #64748b;
  --sidebar: #0f2b38;
  --sidebar-active: #0e7490;
}
html, body { height: 100%; }
body {
  font-family: 'Microsoft YaHei', 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #155e75 0%, #0e7490 45%, #0891b2 100%);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: #fff; border-radius: 14px;
  padding: 38px 34px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.login-logo { text-align: center; font-size: 26px; font-weight: 800; color: var(--primary-dark); letter-spacing: 1px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 6px 0 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #475569; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 11px 12px;
  border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none; transition: border .15s;
}
.field input:focus { border-color: var(--primary); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 18px; border: none; border-radius: 8px;
  background: var(--primary); color: #fff; font-size: 14px;
  cursor: pointer; transition: background .15s;
}
.btn:hover { background: var(--primary-dark); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-ghost { background: #fff; color: var(--text); border: 1.5px solid var(--border); }
.btn-ghost:hover { background: #f8fafc; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 6px; }
.login-error { background: #fef2f2; color: #b91c1c; border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 14px; }
.login-hint { text-align: center; color: #94a3b8; font-size: 12px; margin-top: 18px; }

/* ---------- 主框架 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 218px; flex-shrink: 0;
  background: var(--sidebar); color: #cbd5e1;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  padding: 20px 18px; font-size: 19px; font-weight: 800; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08); letter-spacing: .5px;
}
.sidebar-brand small { display: block; font-size: 11px; font-weight: 400; color: #7dd3fc; margin-top: 3px; }
.nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-group { font-size: 11px; color: #64748b; padding: 12px 10px 5px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px;
  color: #cbd5e1; cursor: pointer; font-size: 14px; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 16px; font-weight: 700; }
.topbar-user { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px;
}
.content { padding: 22px; flex: 1; }

/* 合同详情：导航（detail-head + tabs）固定，仅内容区滚动 */
.content.contract-shell { display: flex; flex-direction: column; flex: 0 0 auto; height: calc(100vh - 58px); overflow: hidden; box-sizing: border-box; }
.contract-shell .detail-head { flex: none; margin-bottom: 12px; }
.contract-shell .tabs { flex: none; margin-bottom: 12px; }
.contract-shell #tabBody { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding-right: 4px; }
/* 维修任务页：tabBody 内部再固定，上部工具栏/凑单卡不动、仅清单滚动 */
.contract-shell #tabBody.tasks-shell { overflow: hidden; display: flex; flex-direction: column; padding-right: 0; }
.contract-shell #annModal { flex: none; }

/* ---------- 卡片/统计 ---------- */
.card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 18px; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 14px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; }
.stat .n { font-size: 28px; font-weight: 800; color: var(--primary-dark); }
.stat .l { color: var(--muted); font-size: 13px; margin-top: 4px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; background: #f8fafc; color: #475569; font-weight: 600; padding: 11px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--border); }
.table tr:hover td { background: #fafbfc; }

/* ---------- 徽章 ---------- */
.badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 12px; }
.badge-active { background: #dcfce7; color: #15803d; }
.badge-settled { background: #dbeafe; color: #1d4ed8; }
.badge-archived { background: #f1f5f9; color: #64748b; }
.badge-pending { background: #fef9c3; color: #a16207; }
.badge-done { background: #dcfce7; color: #15803d; }

/* ---------- 工具类 ---------- */
.muted { color: var(--muted); }
.empty { text-align: center; color: #94a3b8; padding: 50px 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.spacer { flex: 1; }

/* ---------- 输入控件 ---------- */
.inp {
  padding: 8px 11px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 13.5px; outline: none; background: #fff; font-family: inherit;
}
.inp:focus { border-color: var(--primary); }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15,43,56,.45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 50px 16px; z-index: 100; overflow-y: auto;
}
.modal {
  width: 100%; max-width: 680px; background: #fff; border-radius: 12px;
  box-shadow: 0 24px 70px rgba(0,0,0,.3);
}
.modal-title { font-size: 16px; font-weight: 700; padding: 17px 20px; border-bottom: 1px solid var(--border); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 700; }
.modal-x { margin-left: auto; cursor: pointer; font-size: 22px; font-weight: 400; line-height: 1; color: #94a3b8; padding: 0 4px; border-radius: 6px; transition: color .15s, background .15s; }
.modal-x:hover { color: #0f172a; background: #f1f5f9; }
.modal-body { padding: 18px 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 16px; }
.fgrid .field { margin: 0; }
.fgrid .ffull { grid-column: 1 / -1; }
.fgrid input, .fgrid select, .fgrid textarea {
  width: 100%; padding: 9px 11px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: 13.5px; outline: none; font-family: inherit; resize: vertical;
}
.fgrid input:focus, .fgrid select:focus, .fgrid textarea:focus { border-color: var(--primary); }
@media (max-width: 600px) { .fgrid { grid-template-columns: 1fr; } }

/* ---------- 详情页头部 ---------- */
.detail-head { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.detail-title { display: flex; flex-direction: column; gap: 3px; }
.dt-name { font-size: 18px; font-weight: 700; display: flex; align-items: center; gap: 10px; }
.dt-sub { font-size: 13px; color: #64748b; }

/* ---------- 标签页 ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab {
  padding: 9px 15px; cursor: pointer; font-size: 14px; color: #64748b;
  border-bottom: 2.5px solid transparent; margin-bottom: -2px; user-select: none;
}
.tab i { font-style: normal; font-size: 11px; color: #cbd5e1; margin-left: 3px; }
.tab.soon { color: #94a3b8; }
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 键值表 ---------- */
.kv-table { width: 100%; border-collapse: collapse; }
.kv-table th {
  text-align: left; width: 130px; padding: 10px 12px; background: #f8fafc;
  color: #475569; font-weight: 600; border: 1px solid var(--border); font-size: 13.5px;
}
.kv-table td { padding: 10px 14px; border: 1px solid var(--border); font-size: 13.5px; }

/* ---------- 费用汇总 ---------- */
.fee-layout { display: grid; grid-template-columns: minmax(320px, 1fr) minmax(340px, 1.1fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .fee-layout { grid-template-columns: 1fr; } }
.fee-form { display: flex; flex-direction: column; gap: 12px; }
.fee-form label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: #475569; font-weight: 600; }
.fee-form input {
  padding: 9px 11px; border: 1.5px solid var(--border); border-radius: 8px;
  font-size: 14px; outline: none;
}
.fee-form input:focus { border-color: var(--primary); }
.fee-tip { font-size: 12px; color: #94a3b8; line-height: 1.6; }
.fee-form .btn { align-self: flex-start; margin-top: 2px; }

.fee-table { width: 100%; border-collapse: collapse; }
.fee-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.fee-table td:first-child { color: #475569; }
.fee-table td:last-child { text-align: right; font-weight: 600; }
.fee-table tr.sum td { background: #f8fafc; }
.fee-table tr.total td {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; font-size: 15px; border-bottom: none;
}
.fee-table tr.total td:first-child { color: #fff; }

/* ---------- 清单分组 ---------- */
.boq-group { padding: 0; overflow: hidden; margin-bottom: 14px; }
.boq-group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 16px; background: #ecfeff; border-bottom: 1px solid var(--border);
  font-weight: 700; color: var(--primary-dark); font-size: 14px;
}
.boq-group-head .muted { font-weight: 400; font-size: 12.5px; }


