:root {
  --red: #c8102e;
  --red-dark: #9e0c24;
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1f2329;
  --muted: #8a9099;
  --ok: #2e7d32;
  --warn: #b26a00;
  --danger: #c8102e;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

/* 侧边栏布局 */
.app-body { display: flex; }
.sidebar {
  width: 200px;
  flex-shrink: 0;
  background: var(--red);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.sidebar .brand { padding: 18px; border-bottom: 1px solid rgba(255,255,255,.18); display: flex; align-items: center; gap: 10px; }
.sidebar .brand-text-wrap { flex: 1; min-width: 0; }
.sidebar .brand-text { font-weight: 800; font-size: 18px; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar .brand-sub { display: none; }
.sidebar .brand-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 6px; background: #fff; flex-shrink: 0; }
.sidebar nav { flex: 1; padding: 12px 10px; }
.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
  padding: 11px 14px;
  border-radius: 8px;
  margin-bottom: 4px;
  opacity: .92;
  font-size: 14px;
  transition: background .15s;
}
.sidebar nav a:hover { background: rgba(255,255,255,.14); opacity: 1; }
.sidebar nav a.active { background: rgba(255,255,255,.22); font-weight: 600; opacity: 1; }
.sidebar nav a .icon { font-size: 15px; opacity: .95; }
.sidebar .side-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.18); font-size: 13px; }
.sidebar .side-foot .who { opacity: .9; margin-bottom: 10px; word-break: break-all; }
.sidebar .side-foot a {
  display: flex; align-items: center; gap: 8px;
  color: #fff; text-decoration: none; opacity: .85;
}
.sidebar .side-foot a:hover { opacity: 1; }

main { flex: 1; width: 100%; max-width: 1400px; padding: 24px 28px 60px; }

/* 响应式：小屏侧边栏变顶栏 */
@media (max-width: 760px) {
  .app-body { flex-direction: column; }
  .sidebar { width: 100%; min-height: auto; }
  .sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 10px; }
  .sidebar nav a { margin-bottom: 0; }
  .sidebar .side-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .sidebar .side-foot .who { margin-bottom: 0; }
  main { padding: 16px; }
}

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; line-height: 1.6; white-space: nowrap; }
.badge.ok { background: #e6f4e6; color: var(--ok); }
.badge.bad { background: #fdecef; color: var(--danger); }
.badge.st-意向 { background: #eef3ff; color: #2b59c3; }
.badge.st-签约 { background: #e6f4e6; color: var(--ok); }
.badge.st-运营中 { background: #fff3e0; color: var(--warn); }
.badge.st-待续费 { background: #fdecef; color: var(--danger); }
.badge.st-流失 { background: #eceff3; color: var(--muted); }
.badge.team { background: #e8f0fe; color: #174ea6; }
.health { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.health .hb { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.health .hb h3 { margin: 0 0 10px; font-size: 15px; color: var(--red-dark); }
.health .hb-status { margin-bottom: 8px; font-size: 13px; }
.health .hb ul { margin: 0; padding-left: 18px; }
.health .hb li { font-size: 13px; margin-bottom: 4px; }
.health .hb-note { font-size: 12px; color: var(--warn); margin: 4px 0 8px; }
.health .hb-big { font-size: 22px; font-weight: 700; color: var(--text); word-break: break-all; margin-bottom: 8px; }
.health .hb-key { border-left: 4px solid var(--red); }
@media (max-width: 960px) { .health { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .health { grid-template-columns: 1fr; } }
h2 { margin: 0 0 16px; font-size: 20px; }
.muted { color: var(--muted); font-size: 13px; font-weight: 400; }
.flash {
  background: #fff4f4;
  border: 1px solid #f3c2c2;
  color: var(--red-dark);
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.btn {
  display: inline-block;
  background: var(--red);
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}
.btn:hover { background: var(--red-dark); }
.btn-ghost {
  display: inline-block;
  background: transparent;
  color: var(--red);
  border: 1px solid var(--red);
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
}
.btn-ghost:hover { background: #fdecef; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-outline { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn-outline:hover { background: #fdecef; }
.btn-danger { background: #fff; color: #c9302c; border: 1px solid #e0b4b4; }
.btn-danger:hover { background: #fceeee; }
.row-between { display: flex; align-items: center; justify-content: space-between; }
.search { display: flex; gap: 8px; margin-bottom: 16px; }
.search input { flex: 1; }
input, select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--text);
}
input:focus, select:focus { outline: none; border-color: var(--red); }
.table-wrap { width: 100%; overflow-x: auto; }
.tbl { width: 100%; min-width: 1100px; border-collapse: collapse; background: var(--card); border-radius: 10px; overflow: hidden; }
.tbl th, .tbl td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { background: #fafbfc; font-weight: 600; color: var(--muted); font-size: 13px; }
.tbl tr:last-child td { border-bottom: none; }
.tbl a { color: var(--red); text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
.tbl td.multi-line { white-space: normal; line-height: 1.7; padding: 9px 14px; }
.tbl td.multi-line > div, .tbl td.multi-line > span { white-space: nowrap; display: block; }
.tbl td.multi-line > span.badge { display: inline-block; margin: 1px 0; }
.tbl td.multi-line .muted { color: var(--muted); font-size: 12px; }
.ops { white-space: nowrap; }
.ops form { display: inline; }
.col-check { width: 36px; text-align: center; }
.col-num { width: 46px; text-align: center; color: var(--muted); }
.batch-bar {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; margin-bottom: 12px;
}
.batch-bar select { width: auto; min-width: 130px; padding: 7px 10px; }
.batch-check { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; cursor: pointer; }
.batch-count { color: var(--muted); font-size: 13px; margin-right: 6px; }
.link-danger {
  background: none; border: none; color: var(--danger);
  cursor: pointer; padding: 0 0 0 10px; font-size: 14px;
}
.tbl tr.danger { background: #fdecef; }
.tbl tr.warn { background: #fff6e8; }
.tbl tr.ok { background: #eef7ee; }
.empty { color: var(--muted); padding: 30px; text-align: center; background: var(--card); border-radius: 10px; }
/* Tab 标签页 */
.tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.tab {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.tab:hover { border-color: var(--red); color: var(--red); }
.tab.active { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }
.tab-panel { display: none; animation: fadeIn .18s ease; }
.tab-panel.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* 服务器信息内部子 Tab */
.server-subtabs { display: flex; gap: 10px; margin: 4px 0 14px; }
.subtab {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 18px;
  font-size: 14px;
  color: var(--text);
  cursor: pointer;
  transition: all .15s;
}
.subtab:hover { border-color: var(--red); color: var(--red); }
.subtab.active { background: var(--red); color: #fff; border-color: var(--red); font-weight: 600; }

.card-form fieldset {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin: 0 0 16px;
  padding: 16px 18px 18px;
}
.card-form legend { font-weight: 600; padding: 0 8px; color: var(--red-dark); }
.card-form label { display: block; margin-bottom: 12px; font-size: 13px; color: #4a525c; }
.card-form label input, .card-form label select, .card-form label textarea { margin-top: 5px; }
.card-form label textarea { width: 100%; padding: 10px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; font-family: inherit; resize: vertical; }
.card-form label textarea:focus { outline: none; border-color: var(--red); }

/* 两列字段布局 */
.card-form fieldset.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  align-items: start;
}
.card-form fieldset.two-cols legend { grid-column: 1 / -1; }
.card-form fieldset.two-cols label { margin-bottom: 0; }
.card-form fieldset.two-cols .copy-wrap { width: 100%; }
.card-form fieldset.two-cols .site-assign { grid-column: 1 / -1; }
.card-form fieldset.two-cols label:has(+ .site-assign) { grid-column: 1 / -1; margin-bottom: 0; }
@media (max-width: 720px) {
  .card-form fieldset.two-cols { grid-template-columns: 1fr; }
  .card-form fieldset.two-cols label:has(+ .site-assign) { grid-column: auto; margin-bottom: 12px; }
}

.inline-two { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
@media (max-width: 560px) { .inline-two { grid-template-columns: 1fr; } }

.sd-list { margin-bottom: 12px; }
.sd-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; background: #fff; }
.sd-main { flex: 1; font-size: 13px; line-height: 1.6; }
.sd-main .badge { margin-left: 6px; }
.sd-ops { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.sd-ops select { width: auto; min-width: 110px; }
.sd-add { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; align-items: end; }
@media (max-width: 560px) { .sd-add { grid-template-columns: 1fr; } }
.sd-add input { margin-bottom: 0; }
.actions { display: flex; gap: 10px; align-items: center; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card);
  padding: 36px 32px;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,.08);
  width: 340px;
  text-align: center;
}
.login-card h1 { margin: 0 0 6px; font-size: 20px; color: var(--red); }
.login-card .sub { color: var(--muted); margin: 0 0 18px; }
.login-card input { margin-bottom: 14px; }
.login-card button {
  width: 100%; background: var(--red); color: #fff; border: none;
  padding: 11px; border-radius: 8px; font-size: 15px; cursor: pointer;
}
.login-card button:hover { background: var(--red-dark); }
.login-card .hint { margin-top: 14px; }
.raw-box { margin-top: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 12px 16px; }
.raw-box summary { cursor: pointer; font-weight: 600; color: var(--red-dark); font-size: 14px; }
.raw-box pre { margin: 12px 0 0; white-space: pre-wrap; word-break: break-all; font-size: 12px; color: var(--muted); max-height: 360px; overflow: auto; line-height: 1.7; }

/* 服务器按服务商分区 */
.server-block { border-left: 4px solid var(--line); }
.server-block legend { display: flex; align-items: center; gap: 8px; }
.server-block legend::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; }
.server-tc { border-left-color: #0052d9; background: #f8fbff; }
.server-tc legend { color: #0052d9; }
.server-tc legend::before { background: #0052d9; }
.server-ali { border-left-color: #ff6a00; background: #fff9f5; }
.server-ali legend { color: #ff6a00; }
.server-ali legend::before { background: #ff6a00; }

/* 一键复制 */
.copy-wrap { display: flex; gap: 8px; align-items: center; margin-top: 5px; }
.copy-wrap input { flex: 1; margin-top: 0; }
.copy-btn {
  flex-shrink: 0;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--red);
  border-radius: 6px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}
.copy-btn:hover { background: #fdecef; border-color: var(--red); }

/* 站点分配 */
.site-assign { display: flex; gap: 16px; margin: 6px 0 12px; padding: 8px 10px; background: #fff; border: 1px solid var(--line); border-radius: 8px; }
.site-check { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); margin-bottom: 0; cursor: pointer; }
.site-check input { width: auto; margin-top: 0; }

/* 跟进记录时间线 */
.timeline-box { margin-top: 22px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 16px 18px; }
.timeline-box h3 { margin: 0 0 14px; font-size: 16px; color: var(--red-dark); }
.follow-form { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 16px; }
.follow-form textarea { flex: 1; margin-top: 0; resize: vertical; }
.follow-form button { flex-shrink: 0; }
.timeline { position: relative; padding-left: 22px; border-left: 2px solid var(--line); }
.timeline-item { position: relative; margin-bottom: 16px; }
.timeline-dot { position: absolute; left: -27px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--red); border: 2px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.timeline-meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.timeline-content { font-size: 14px; line-height: 1.6; white-space: pre-wrap; word-break: break-all; }
.timeline-del { margin-top: 4px; }

/* 列表操作区与导入导出按钮 */
.row-actions { display: flex; gap: 8px; align-items: center; }
.tbl a { margin-right: 8px; }

/* 模板示例 / 导出文档 */
.tpl-sample { background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; font-size: 12px; line-height: 1.7; white-space: pre-wrap; word-break: break-all; color: #3a414b; }
.export-doc { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 22px 26px; max-width: 920px; }
.export-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; border-bottom: 2px solid var(--red); padding-bottom: 12px; }
.export-title { font-size: 18px; font-weight: 800; color: var(--red-dark); }
.export-logo { max-height: 44px; max-width: 160px; object-fit: contain; }
.export-doc section { margin-bottom: 18px; }
.export-doc h3 { font-size: 15px; color: var(--red-dark); border-left: 4px solid var(--red); padding-left: 8px; margin: 0 0 10px; }
.exp-tbl { width: 100%; border-collapse: collapse; }
.exp-tbl th, .exp-tbl td { border: 1px solid var(--line); padding: 7px 10px; font-size: 13px; text-align: left; vertical-align: top; word-break: break-all; }
.exp-tbl th { background: #fafbfc; color: var(--muted); font-weight: 600; width: 120px; white-space: nowrap; }

/* 证件网格缩略图 */
.cert-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 760px) { .cert-grid { grid-template-columns: repeat(2, 1fr); } }
.cert-cell { border: 1px solid var(--line); border-radius: 8px; padding: 10px; text-align: center; background: #fff; }
.cert-label { font-size: 13px; font-weight: 600; color: var(--red-dark); margin-bottom: 8px; }
.cert-thumb { max-width: 100%; max-height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 4px; }
.cert-empty { color: var(--muted); font-size: 13px; padding: 20px 0; }

/* 证件编辑页：清单式卡片网格 */
.cert-edit-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin: 14px 0; }
@media (max-width: 900px) { .cert-edit-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .cert-edit-grid { grid-template-columns: 1fr; } }
.cert-edit-card { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; display: flex; flex-direction: column; align-items: center; text-align: center; }
.cert-edit-title { font-size: 14px; font-weight: 600; color: var(--red-dark); margin-bottom: 10px; }
.cert-edit-preview { width: 100%; height: 150px; display: flex; align-items: center; justify-content: center; background: #f8f9fb; border-radius: 6px; margin-bottom: 10px; overflow: hidden; border: 1px dashed #e0e3e8; }
.cert-edit-thumb { max-width: 100%; max-height: 148px; object-fit: contain; cursor: zoom-in; }
.cert-edit-placeholder { color: var(--muted); font-size: 13px; }
.cert-edit-file { font-size: 13px; color: var(--red); word-break: break-all; }
.cert-edit-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.cert-file-label { position: relative; overflow: hidden; cursor: pointer; margin: 0; }
.cert-file-label input[type=file] { position: absolute; left: -9999px; }
.cert-edit-filename { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 18px; word-break: break-all; }
.cert-form .actions { margin-top: 18px; margin-bottom: 32px; }

/* 大图查看浮层 */
.cert-lightbox { display: none; position: fixed; z-index: 2000; left: 0; top: 0; width: 100%; height: 100%; background: rgba(0,0,0,.85); align-items: center; justify-content: center; }
.cert-lightbox img { max-width: 90%; max-height: 90%; object-fit: contain; border-radius: 4px; }
.cert-lightbox-close { position: absolute; top: 18px; right: 28px; color: #fff; font-size: 36px; font-weight: 300; cursor: pointer; line-height: 1; }

/* 附件库 */
.attach-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 900px) { .attach-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px) { .attach-grid { grid-template-columns: repeat(2, 1fr); } }
.attach-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fff; text-align: center; }
.attach-thumb { max-width: 100%; max-height: 110px; object-fit: contain; border: 1px solid var(--line); border-radius: 4px; margin-bottom: 8px; }
.attach-file { display: block; padding: 24px 0; font-size: 14px; color: var(--red); }
.attach-name { font-size: 13px; word-break: break-all; }
.attach-note { font-size: 12px; color: var(--warn); margin: 4px 0; }
.attach-meta { font-size: 11px; color: var(--muted); margin-bottom: 6px; }

/* 设置页 LOGO 预览 */
.logo-preview { max-height: 48px; max-width: 200px; object-fit: contain; border: 1px solid var(--line); border-radius: 6px; }

/* 客户分类管理 */
.inline-add-row { display: flex; gap: 8px; margin-top: 6px; }
.inline-add-row input { flex: 1; }
.cat-list { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 10px; }
.cat-item { display: flex; align-items: center; gap: 8px; background: #f8f9fb; border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; }
.cat-name { font-size: 14px; font-weight: 600; color: var(--red-dark); }
.check-line { display: flex; align-items: center; gap: 8px; }
.check-line input { width: auto; margin-top: 0; }

/* 域名管理 */
.page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.page-header h1 { margin: 0; font-size: 22px; }
.page-header .count { color: var(--muted); font-size: 16px; font-weight: 400; margin-left: 8px; }
.badge.warn { background: #fff3e0; color: var(--warn); }
.badge.danger { background: #fdecef; color: var(--danger); }
.req { color: var(--danger); }
