/* ==========================================================================
   医联 · 智汇门户 —— 共用样式
   ========================================================================== */
:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e5e8ec;
  --border-strong: #d4d9e0;
  --text: #111827;
  --text-2: #475467;
  --muted: #6b7280;
  --faint: #98a2b3;
  --primary: #2563eb;
  --primary-ink: #1d4ed8;
  --primary-soft: #eff4ff;
  --danger: #dc2626;
  --ok: #059669;
  --grad: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, .08);
  --shadow-lg: 0 18px 44px rgba(16, 24, 40, .16);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.6;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ------------------------------------------------------------------ 通用控件 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-weight: 500;
  transition: all .15s ease;
  white-space: nowrap;
}
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .28);
}
.btn-primary:hover { color: #fff; filter: brightness(1.06); }
.btn-danger { color: var(--danger); border-color: #fbd5d5; }
.btn-danger:hover { background: #fef2f2; border-color: var(--danger); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.input, .textarea, .select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 74px; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
.hint { font-size: 12px; color: var(--faint); margin-top: 5px; }

.badge {
  display: inline-flex;
  align-items: center;
  height: 21px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--primary-soft);
  color: var(--primary-ink);
  font-weight: 500;
}
.badge-gray { background: #f1f3f6; color: var(--muted); }
.badge-ok { background: #e7f6ef; color: var(--ok); }
.badge-warn { background: #fef3e2; color: #b45309; }

/* ==========================================================================
   登录页
   ========================================================================== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: #fff;
}
.login-brand {
  position: relative;
  background: var(--grad);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  right: -140px; bottom: -160px;
  width: 460px; height: 460px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
}
.login-brand::before {
  content: "";
  position: absolute;
  right: 60px; top: -120px;
  width: 260px; height: 260px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .08);
}
.login-brand h1 { font-size: 34px; margin: 0 0 12px; letter-spacing: -.5px; }
.login-brand p { opacity: .9; margin: 0; font-size: 15px; max-width: 380px; }
.brand-mark {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 600; letter-spacing: .5px; font-size: 16px;
}
.brand-mark i {
  width: 34px; height: 34px; border-radius: 10px;
  background: rgba(255, 255, 255, .22);
  display: inline-flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 17px;
  backdrop-filter: blur(4px);
}
.login-features { position: relative; z-index: 1; }
.login-features div {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 0; font-size: 14px; opacity: .92;
}
.login-form-side {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 32px;
}
.login-box { width: 100%; max-width: 352px; }
.login-box h2 { font-size: 24px; margin: 0 0 6px; letter-spacing: -.3px; }
.login-box .sub { color: var(--muted); margin: 0 0 28px; font-size: 13.5px; }
.login-box .btn { width: 100%; height: 42px; margin-top: 6px; }
.login-err {
  display: none;
  background: #fef2f2;
  border: 1px solid #fbd5d5;
  color: var(--danger);
  border-radius: 9px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.login-foot {
  margin-top: 26px; padding-top: 18px;
  border-top: 1px solid var(--border);
  color: var(--faint); font-size: 12px; text-align: center;
}

/* ==========================================================================
   门户
   ========================================================================== */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  height: 62px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 650; font-size: 15.5px; letter-spacing: -.2px;
  flex-shrink: 0;
}
.logo i {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--grad); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-style: normal; font-size: 16px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, .3);
}
.logo small {
  display: block; font-weight: 400; font-size: 11px;
  color: var(--faint); letter-spacing: .3px; line-height: 1.2;
}
.searchbox {
  flex: 1;
  max-width: 420px;
  position: relative;
}
.searchbox input {
  width: 100%; height: 38px;
  padding: 0 14px 0 38px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: #fafbfc;
  outline: none;
  transition: all .15s;
}
.searchbox input:focus {
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .1);
}
.searchbox svg { position: absolute; left: 12px; top: 11px; opacity: .45; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--grad); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
}
.user-name { font-weight: 550; font-size: 13.5px; }
.user-menu { position: relative; }
.user-menu > button {
  display: flex; align-items: center; gap: 9px;
  padding: 4px 8px 4px 4px;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent; cursor: pointer;
}
.user-menu > button:hover { background: #f4f6f9; border-color: var(--border); }
.dropdown {
  display: none;
  position: absolute; right: 0; top: calc(100% + 8px);
  min-width: 200px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 60;
}
.dropdown.open { display: block; }
.dropdown .who { padding: 9px 10px 7px; border-bottom: 1px solid var(--border); margin-bottom: 5px; }
.dropdown .who b { display: block; font-size: 13.5px; }
.dropdown .who span { font-size: 12px; color: var(--faint); }
.dropdown a, .dropdown button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  padding: 8px 10px; border-radius: 8px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text); font-size: 13.5px;
}
.dropdown a:hover, .dropdown button:hover { background: #f4f6f9; }
.dropdown button.danger { color: var(--danger); }

.shell { max-width: 1320px; margin: 0 auto; padding: 26px 24px 70px; }

.hero {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 20px; flex-wrap: wrap; margin-bottom: 22px;
}
.hero h1 { font-size: 23px; margin: 0 0 5px; letter-spacing: -.4px; }
.hero p { margin: 0; color: var(--muted); font-size: 13.5px; }
.hero-stats { display: flex; gap: 26px; }
.hero-stat b { display: block; font-size: 21px; letter-spacing: -.4px; }
.hero-stat span { font-size: 12px; color: var(--faint); }

.cat-nav {
  display: flex; gap: 8px; flex-wrap: wrap;
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.cat-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 13px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: #fff; color: var(--text-2);
  cursor: pointer; font-size: 13px;
  transition: all .15s;
}
.cat-chip:hover { border-color: var(--primary); color: var(--primary); }
.cat-chip.active { background: var(--grad); border-color: transparent; color: #fff; font-weight: 500; }
.cat-chip .n { opacity: .6; font-size: 12px; }

.group { margin-bottom: 34px; }
.group-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; margin: 0 0 14px; letter-spacing: -.1px;
}
.group-title .dot { width: 4px; height: 16px; border-radius: 2px; background: var(--grad); }
.group-title .n {
  font-size: 12px; color: var(--faint); font-weight: 400;
  background: #eef1f5; padding: 1px 8px; border-radius: 999px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(276px, 1fr));
  gap: 14px;
}

.card {
  position: relative;
  display: flex; gap: 13px;
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease;
  overflow: hidden;
}
.card::before {
  content: ""; position: absolute; inset: 0 auto 0 0;
  width: 3px; background: var(--c, var(--primary));
  opacity: 0; transition: opacity .16s;
}
.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}
.card:hover::before { opacity: 1; }
.card-icon {
  flex-shrink: 0;
  width: 42px; height: 42px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1;
  background: color-mix(in srgb, var(--c, #2563eb) 11%, #fff);
  border: 1px solid color-mix(in srgb, var(--c, #2563eb) 18%, #fff);
}
.card-body { min-width: 0; flex: 1; }
.card-name {
  font-weight: 600; font-size: 14.5px;
  display: flex; align-items: center; gap: 6px;
  letter-spacing: -.1px;
}
.card-name .pin { color: #f59e0b; font-size: 12px; }
.card-desc {
  color: var(--muted); font-size: 12.5px; line-height: 1.55;
  margin: 3px 0 9px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.card-host {
  font-size: 11.5px; color: var(--faint);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-go {
  font-size: 12px; color: var(--primary); font-weight: 500;
  opacity: 0; transform: translateX(-4px); transition: all .16s;
  white-space: nowrap;
}
.card:hover .card-go { opacity: 1; transform: none; }
.card-tags { display: flex; gap: 5px; margin-bottom: 8px; flex-wrap: wrap; }

.empty {
  text-align: center; padding: 70px 20px; color: var(--faint);
}
.empty .em { font-size: 40px; display: block; margin-bottom: 12px; opacity: .6; }

/* ==========================================================================
   弹窗 / 修改密码
   ========================================================================== */
.modal-mask {
  display: none;
  position: fixed; inset: 0; z-index: 90;
  background: rgba(16, 24, 40, .48);
  backdrop-filter: blur(2px);
  align-items: center; justify-content: center;
  padding: 24px;
}
.modal-mask.open { display: flex; }
.modal {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 440px;
  box-shadow: var(--shadow-lg);
  max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .18s ease;
}
.modal.wide { max-width: 620px; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } }
.modal-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head .x {
  border: 0; background: transparent; cursor: pointer;
  font-size: 20px; color: var(--faint); line-height: 1;
  padding: 2px 6px; border-radius: 7px;
}
.modal-head .x:hover { background: #f4f6f9; color: var(--text); }
.modal-body { padding: 20px; overflow: auto; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}

.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translate(-50%, 20px);
  background: #101828; color: #fff;
  padding: 10px 20px; border-radius: 10px;
  font-size: 13.5px; box-shadow: var(--shadow-lg);
  opacity: 0; pointer-events: none; transition: all .22s ease; z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #b42318; }

/* ==========================================================================
   管理后台
   ========================================================================== */
.admin-layout { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }
.admin-side {
  background: #fff; border-right: 1px solid var(--border);
  padding: 18px 14px; position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.admin-side .logo { margin: 0 6px 20px; }
.admin-nav { display: flex; flex-direction: column; gap: 3px; }
.admin-nav button {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 12px; border-radius: 9px;
  border: 0; background: transparent; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; text-align: left;
}
.admin-nav button:hover { background: #f4f6f9; }
.admin-nav button.active { background: var(--primary-soft); color: var(--primary-ink); font-weight: 550; }
.admin-side .back { margin-top: auto; }

.admin-main { padding: 26px 30px 70px; max-width: 1180px; }
.admin-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.admin-head h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.3px; }
.admin-head p { margin: 0; color: var(--muted); font-size: 13px; }
.admin-actions { display: flex; gap: 9px; flex-wrap: wrap; }

.panel {
  background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
  overflow: hidden; margin-bottom: 22px;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.panel-head h3 { margin: 0; font-size: 14.5px; }
.panel-head .sub { font-size: 12px; color: var(--faint); font-weight: 400; }

table.tbl { width: 100%; border-collapse: collapse; }
table.tbl th, table.tbl td {
  padding: 11px 18px; text-align: left;
  border-bottom: 1px solid var(--border); font-size: 13px;
  vertical-align: middle;
}
table.tbl th {
  background: #fafbfc; color: var(--muted);
  font-weight: 550; font-size: 12px; letter-spacing: .2px;
  white-space: nowrap;
}
table.tbl tbody tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: #fbfcfd; }
table.tbl td.acts { text-align: right; white-space: nowrap; }
table.tbl .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; color: var(--muted);
}
table.tbl .switch { cursor: pointer; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-grid .full { grid-column: 1 / -1; }
.chk-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.chk-row input { width: 16px; height: 16px; accent-color: var(--primary); }

.zone-picker { display: flex; gap: 7px; flex-wrap: wrap; }
.zone-picker label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--border-strong); cursor: pointer;
  font-size: 13px; background: #fff;
}
.zone-picker input { display: none; }
.zone-picker input:checked + span { color: var(--primary-ink); font-weight: 550; }
.zone-picker label:has(input:checked) {
  border-color: var(--primary); background: var(--primary-soft);
}

.scan-list { max-height: 320px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.scan-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
.scan-item:last-child { border-bottom: 0; }
.scan-item input { width: 16px; height: 16px; accent-color: var(--primary); }

/* ==========================================================================
   响应式
   ========================================================================== */
@media (max-width: 980px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-side {
    position: static; height: auto;
    flex-direction: row; align-items: center; gap: 10px;
    overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border);
    padding: 12px 14px;
  }
  .admin-side .logo { margin: 0 12px 0 0; }
  .admin-nav { flex-direction: row; }
  .admin-side .back { margin-top: 0; margin-left: auto; }
  .admin-main { padding: 20px 18px 60px; }
  .form-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .topbar-inner { height: auto; padding: 12px 16px; flex-wrap: wrap; gap: 12px; }
  .searchbox { order: 3; max-width: none; flex-basis: 100%; }
  .shell { padding: 18px 16px 60px; }
  .grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 19px; }
  .hero-stats { gap: 20px; }
  .logo small { display: none; }
  .user-name { display: none; }
  .card-go { opacity: 1; transform: none; }
}
