/* ╔══════════════════════════════════════════════════════════════════════════╗
   ║  HCT.Server · BS 管理端样式（工业风 · 触屏友好 · 参考 ACS admin 风格）      ║
   ╚══════════════════════════════════════════════════════════════════════════╝ */
:root {
  --primary: #1E88E5;
  --primary-dark: #1565C0;
  --primary-soft: #E3F2FD;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --text: #1F2937;
  --muted: #6B7280;
  --border: #E5E7EB;
  --ok: #16A34A;
  --warn: #D97706;
  --bad: #DC2626;
  --sidebar: #0F172A;
  --sidebar-hover: #1E293B;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 8px 24px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; }
/* v1.3：修复隐藏失效——.app-view/.login-view 的 display 会覆盖 HTML hidden 属性，
   导致登录成功后登录框仍固定在最上层；统一用 !important 保证 hidden 生效。 */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }

/* ─── 登录页 ─── */
.login-view {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1E3A8A 0%, #0F172A 55%, #020617 100%);
  z-index: 50;
}
.login-panel {
  width: 380px; max-width: calc(100vw - 40px); background: var(--surface);
  border-radius: 16px; padding: 32px 30px 26px; box-shadow: 0 24px 64px rgba(2, 6, 23, .45);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #1E88E5, #0D47A1);
  color: #fff; font-weight: 700; font-size: 20px; display: flex; align-items: center; justify-content: center;
  flex: none;
}
.login-brand h1 { font-size: 18px; margin: 0; }
.login-brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
.field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; height: 42px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: 8px; background: #FBFCFE; outline: none; transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: 76px; padding: 10px 12px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 136, 229, .12); background: #fff;
}
.form-error { color: var(--bad); font-size: 13px; min-height: 18px; margin: 6px 0 12px; }
/* v1.4：免密登录勾选项 */
.remember-line {
  display: flex; align-items: center; gap: 8px; margin: -4px 0 14px;
  font-size: 13px; color: var(--muted); cursor: pointer; user-select: none;
}
.remember-line input { width: 17px; height: 17px; margin: 0; accent-color: var(--primary); }

/* ─── 主框架 ─── */
.app-view { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 216px; flex: none; background: var(--sidebar); color: #CBD5E1;
  display: flex; flex-direction: column; padding: 16px 12px;
}
.sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.sidebar .brand strong { color: #F8FAFC; font-size: 15px; letter-spacing: .5px; }
.sidebar .brand small { display: block; color: #64748B; font-size: 11px; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }
.nav button {
  display: flex; align-items: center; gap: 10px; width: 100%; height: 42px; padding: 0 12px;
  border: 0; border-radius: 8px; background: transparent; color: #CBD5E1; cursor: pointer;
  text-align: left; font-size: 14px; transition: background .15s, color .15s;
}
.nav button:hover { background: var(--sidebar-hover); color: #F1F5F9; }
.nav button.active { background: var(--primary); color: #fff; }
.nav .ico { width: 20px; text-align: center; flex: none; }
.sidebar .foot { margin-top: auto; padding: 12px 8px 4px; font-size: 11px; color: #475569; line-height: 1.6; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 60px; flex: none; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px; padding: 0 20px;
}
.topbar h1 { font-size: 18px; margin: 0; flex: none; }
.topbar .spacer { flex: 1; }
.topbar .tenant { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.topbar .tenant select { height: 34px; border: 1px solid var(--border); border-radius: 8px; padding: 0 8px; background: #fff; }
.user-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 20px;
  background: var(--primary-soft); color: var(--primary-dark); font-size: 13px;
}
.user-chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); }
.content { flex: 1; overflow: auto; padding: 20px; }

/* ─── 按钮 ─── */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid transparent;
  background: #EEF2F7; color: #334155; cursor: pointer; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s;
}
.button:hover { background: #E2E8F0; }
.button.primary { background: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.ghost { background: transparent; border-color: var(--border); color: var(--text); }
.button.ghost:hover { background: #F1F5F9; }
.button.danger { background: transparent; border-color: #FECACA; color: var(--bad); }
.button.danger:hover { background: #FEF2F2; }
.button.small { height: 30px; padding: 0 10px; font-size: 13px; }
.button.wide { width: 100%; height: 44px; }
.button:disabled { opacity: .55; cursor: not-allowed; }

/* ─── 卡片/表格 ─── */
.page-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head .spacer { flex: 1; }
.page-head .hint { color: var(--muted); font-size: 13px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.card .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
.card .value { font-size: 30px; font-weight: 700; margin-top: 8px; letter-spacing: .5px; }
.card .sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.card .value.ok { color: var(--ok); }
.card .value.warn { color: var(--warn); }
.card .value.bad { color: var(--bad); }

.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; margin-bottom: 18px;
}
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 18px;
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.panel-head h2 { font-size: 15px; margin: 0; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 0; }

.filter-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.filter-bar input, .filter-bar select {
  height: 36px; padding: 0 10px; border: 1px solid var(--border); border-radius: 8px; background: #FBFCFE; min-width: 130px;
}
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30,136,229,.1); }
.filter-bar label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }

.table-wrap { width: 100%; overflow: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 760px; }
table.data thead th {
  position: sticky; top: 0; z-index: 1; background: #F8FAFC; color: #475569;
  font-weight: 600; font-size: 13px; text-align: left; padding: 11px 12px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid #F1F5F9; vertical-align: middle; }
table.data tbody tr:hover { background: #F8FBFF; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .empty { text-align: center; color: var(--muted); padding: 36px 12px; }
table.data .mono { font-family: Consolas, "Courier New", monospace; }
table.data .actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.null { color: #CBD5E1; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px; border-radius: 11px; font-size: 12px; }
.badge.ok { background: #DCFCE7; color: #15803D; }
.badge.warn { background: #FEF3C7; color: #B45309; }
.badge.bad { background: #FEE2E2; color: #B91C1C; }
.badge.gray { background: #F1F5F9; color: #64748B; }
.badge.blue { background: var(--primary-soft); color: var(--primary-dark); }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 18px; border-top: 1px solid var(--border); }
.pager .label { color: var(--muted); font-size: 13px; }

/* 趋势柱状图 */
.chart { display: flex; align-items: flex-end; gap: 18px; height: 180px; padding: 18px 22px 10px; }
.chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 6px; height: 100%; }
.chart .bars { display: flex; align-items: flex-end; gap: 4px; height: 130px; width: 100%; justify-content: center; }
.chart .bar { width: 16px; min-height: 2px; border-radius: 4px 4px 0 0; background: var(--primary); transition: height .3s; }
.chart .bar.pass { background: var(--ok); }
.chart .day { font-size: 11px; color: var(--muted); }
.chart .num { font-size: 11px; color: #94A3B8; }

/* 状态页 */
.status-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px dashed #EEF2F7; font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv span:first-child { color: var(--muted); }
.kv span:last-child { font-family: Consolas, monospace; }

/* ─── 弹窗 ─── */
.modal-mask { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 60; padding: 20px; }
.modal {
  width: 620px; max-width: 100%; max-height: calc(100vh - 40px); background: var(--surface);
  border-radius: 14px; box-shadow: 0 28px 80px rgba(2, 6, 23, .35); display: flex; flex-direction: column;
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: scale(.97); opacity: .6; } to { transform: scale(1); opacity: 1; } }
.modal header { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 16px; flex: 1; }
.modal header button { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal .body { padding: 18px 20px; overflow: auto; }
.modal .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.modal footer { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); }
.modal .field { margin-bottom: 14px; }
.modal .field.span2 { grid-column: span 2; }
.check-line { display: flex; align-items: center; gap: 8px; height: 42px; }
.check-line input { width: 18px; height: 18px; }
.help { font-size: 12px; color: var(--muted); margin-top: 4px; }
.help.bad { color: var(--bad); }

/* 详情键值 */
.detail-grid { display: grid; grid-template-columns: 140px 1fr; gap: 8px 12px; font-size: 13px; }
.detail-grid .k { color: var(--muted); }
.detail-grid .v { font-family: Consolas, monospace; word-break: break-all; }
pre.raw { background: #0F172A; color: #E2E8F0; border-radius: 8px; padding: 12px; font-size: 12px; overflow: auto; max-height: 260px; white-space: pre-wrap; word-break: break-all; }

/* ─── Toast ─── */
#toast { position: fixed; right: 24px; bottom: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 80; }
.toast {
  min-width: 220px; max-width: 420px; padding: 12px 16px; border-radius: 10px; color: #fff;
  background: #334155; box-shadow: 0 12px 32px rgba(2, 6, 23, .3); font-size: 13px;
  animation: slide .18s ease-out;
}
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
@keyframes slide { from { transform: translateY(8px); opacity: .5; } to { transform: translateY(0); opacity: 1; } }

/* 页面水印层 */
#watermark { position: fixed; inset: 0; pointer-events: none; z-index: 40; opacity: .55; }

/* ─── 响应式 ─── */
@media (max-width: 900px) {
  .sidebar { width: 64px; padding: 14px 8px; }
  .sidebar .brand strong, .sidebar .brand small, .nav button span.txt, .sidebar .foot { display: none; }
  .nav button { justify-content: center; padding: 0; }
  .topbar h1 { font-size: 16px; }
  .topbar .tenant { display: none; }
  .content { padding: 14px; }
  .modal .grid2 { grid-template-columns: 1fr; }
  .modal .field.span2 { grid-column: span 1; }
}

/* v1.4 手机端：侧栏改底部图标导航，顶栏自动换行，解决用户名竖排与横向溢出 */
@media (max-width: 700px) {
  html, body { overflow-x: hidden; }
  .app-view { height: 100vh; height: 100dvh; flex-direction: column; }
  .sidebar {
    order: 2; width: 100%; height: 58px; flex-direction: row; padding: 0;
    border-top: 1px solid #1E293B;
  }
  .sidebar .brand, .sidebar .foot { display: none; }
  .nav {
    flex-direction: row; width: 100%; height: 100%; gap: 2px; padding: 4px 6px;
    overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav button {
    flex: 0 0 auto; width: auto; min-width: 56px; height: 50px; padding: 4px 8px;
    flex-direction: column; justify-content: center; gap: 2px; text-align: center; font-size: 11px;
  }
  .nav .ico { width: auto; font-size: 18px; line-height: 1; }
  .nav button span.txt { display: block; }   /* 覆盖 900px 断点下的隐藏 */
  .main { order: 1; flex: 1; min-height: 0; }
  .topbar { height: auto; min-height: 52px; padding: 8px 10px; gap: 6px; flex-wrap: wrap; }
  .topbar h1 { font-size: 16px; }
  .topbar .spacer { display: none; }
  .topbar .tenant { display: flex; font-size: 12px; gap: 4px; }
  .topbar .tenant > span { display: none; }
  .topbar .tenant select { height: 30px; max-width: 118px; }
  .user-chip { max-width: 42vw; padding: 4px 8px; font-size: 12px; }
  .user-chip #userChip { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar .button.small { height: 30px; padding: 0 8px; font-size: 12px; }
  .content { padding: 10px; }
  .cards { grid-template-columns: 1fr 1fr; gap: 10px; }
  .card { padding: 12px; }
  .card .label { font-size: 12px; }
  .card .value { font-size: 24px; }
  .card .sub { font-size: 11px; }
  .panel { margin-bottom: 12px; border-radius: 10px; }
  .panel-head { padding: 10px 12px; }
  .panel-head h2 { font-size: 14px; }
  .filter-bar { padding: 10px 12px; gap: 8px; }
  .filter-bar input, .filter-bar select { min-width: 0; flex: 1 1 130px; }
  .filter-bar label { flex: 1 1 130px; }
  .filter-bar input[type="date"] { width: 100%; }
  .pager { flex-wrap: wrap; justify-content: center; gap: 8px; padding: 10px 12px; }
  .table-wrap { -webkit-overflow-scrolling: touch; }
  table.data { min-width: 680px; }
  .chart { gap: 8px; padding: 14px 10px 8px; }
  .chart .bar { width: 10px; }
  .chart .num { display: none; }
  .login-panel { padding: 24px 18px 20px; border-radius: 14px; }
  .modal { width: 100%; max-height: calc(100dvh - 24px); }
  .modal .body { padding: 14px; }
  .detail-grid { grid-template-columns: 96px 1fr; }
  #toast { left: 12px; right: 12px; bottom: 74px; }
  .toast { min-width: 0; width: 100%; max-width: none; }
}
