/* ==========================================================================
   机构管理后台 · 视觉系统（1440 桌面）
   ========================================================================== */

:root {
  --primary: #014DB2;
  --primary-600: #0A5FD4;
  --primary-soft: #EAF1FB;
  --navy: #0A1628;
  --bg: #F7F8FA;
  --card: #FFFFFF;
  --line: #EAEAEA;
  --line-2: #F1F2F4;
  --text: #0A1628;
  --text-2: #6B7280;
  --text-3: #9AA3AE;
  --ok: #10B981; --ok-bg: #E7F7EF; --ok-text: #0E9F6E;
  --warn: #F59E0B; --warn-bg: #FEF3E2; --warn-text: #B45309;
  --danger: #EF4444; --danger-bg: #FDECEC; --danger-text: #DC2626;
  --info-text: #35507A;
  --radius: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

html, body { margin: 0; height: 100%; }

body {
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono { font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, monospace; }
.hidden { display: none !important; }

/* ------------------------------- 登录 ------------------------------- */
#loginScreen {
  min-height: 100vh; display: grid; place-items: center;
  background: linear-gradient(150deg, #0457C6 0%, #013F92 45%, #062247 100%);
}
.login-card {
  width: 400px; padding: 36px; background: #fff; border-radius: 18px;
  box-shadow: 0 24px 70px rgba(4, 20, 48, 0.35);
}
.login-card .logo { width: 46px; height: 46px; border-radius: 13px; background: var(--primary); display: grid; place-items: center; margin-bottom: 18px; }
/* 品牌英文副标：登录页标题下方一行，颜色取可读的深灰（白底 5.4:1），不抢标题视觉 */
.brand-en { font-size: 11.5px; color: #5A6B85; letter-spacing: .04em; margin: 6px 0 0; font-family: Inter, 'Segoe UI', system-ui, sans-serif; }
.login-card h1 { margin: 0 0 6px; font-size: 21px; font-weight: 700; }
.login-card .sub { margin: 0 0 24px; font-size: 12.5px; color: var(--text-2); line-height: 1.6; }

/* ------------------------------- 布局 ------------------------------- */
#shell { display: none; min-height: 100vh; }
#shell.active { display: flex; }

.sidebar {
  width: 236px; flex: none; background: #fff; border-right: 1px solid var(--line-2);
  display: flex; flex-direction: column; padding: 20px; gap: 8px;
  position: sticky; top: 0; height: 100vh;
}
.logo-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.logo-badge { width: 34px; height: 34px; flex: none; border-radius: 10px; background: var(--primary); display: grid; place-items: center; }
.logo-name { font-size: 13px; font-weight: 600; }
.logo-sub { font-size: 10.5px; color: var(--text-3); margin-top: 1px; }

.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 12px;
  border-radius: var(--radius-sm); border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 500; font-family: inherit; color: var(--text-2); text-align: left;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: #F5F7FA; color: var(--navy); }
.nav-item.active { background: var(--primary); color: #fff; }
.nav-item svg { flex: none; }
.sidebar .spacer { flex: 1; }
.user-card {
  padding: 12px 10px 10px;
  margin-top: 2px;
  border-top: 1px solid var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.user-row { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; flex: none; border-radius: 50%;
  background: linear-gradient(135deg, #E8F1FF, #D5E6FF);
  border: 1px solid #C9DDFB;
  display: grid; place-items: center;
}
.user-name {
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-role {
  font-size: 10.5px; color: var(--text-3); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.user-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.user-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 30px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: 8px;
  background: #fff; color: var(--text-2);
  font-size: 12px; font-weight: 500; cursor: pointer;
  transition: all .15s ease;
}
.user-btn:hover { color: var(--primary); border-color: #B9D4FA; background: var(--primary-soft); }
.user-btn svg { flex: none; }
.user-btn-danger:hover { color: #D93025; border-color: #F3C1BD; background: #FDF0EE; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.top-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 22px 28px 16px; background: var(--bg); position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 20px; font-weight: 700; margin: 0; letter-spacing: -0.3px; }
.page-sub { font-size: 12px; color: var(--text-2); margin: 4px 0 0; }
.toolbar { display: flex; align-items: center; gap: 10px; }
.view-body { padding: 0 28px 28px; }

/* ------------------------------- 组件 ------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500; font-family: inherit; cursor: pointer;
  border: 1px solid transparent; transition: opacity .15s, background .15s; white-space: nowrap;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-ghost { background: #fff; color: var(--navy); border-color: var(--line); }
.btn-ghost:hover { background: #F7F8FA; }
.btn-danger { background: #fff; color: var(--danger-text); border-color: #F3C9C9; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 8px; }

.input, .select, textarea.input {
  width: 100%; height: 38px; padding: 0 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: #fff; font-size: 13px; font-family: inherit; color: var(--text);
  outline: none; transition: border-color .15s;
}
.input:focus, .select:focus { border-color: var(--primary); }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; min-height: 76px; }
.input.search { width: 260px; }
.field { margin-bottom: 14px; }
.field > label { display: block; font-size: 12px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.field .hintline { font-size: 11px; color: var(--text-3); margin-top: 5px; line-height: 1.5; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-title { font-size: 15px; font-weight: 600; margin: 0; }
.card-sub { font-size: 11.5px; color: var(--text-3); }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px;
}
.stat .k { font-size: 11.5px; color: var(--text-2); }
.stat .v { font-size: 23px; font-weight: 700; margin-top: 6px; letter-spacing: -0.5px; }
.stat .s { font-size: 10.5px; margin-top: 5px; }
.stat .s.ok { color: var(--ok-text); }
.stat .s.warn { color: var(--warn-text); }
.stat .s.danger { color: var(--danger-text); }
.stat .s.mute { color: var(--text-3); }

.band {
  display: flex; align-items: center; gap: 28px; padding: 22px 24px; margin-bottom: 16px;
  border-radius: var(--radius); color: #fff;
  background: linear-gradient(135deg, #014DB2 0%, #013F92 60%, #062247 100%);
}
.band .bl { width: 300px; flex: none; }
.band .bl h3 { margin: 0 0 6px; font-size: 15px; font-weight: 600; }
.band .bl p { margin: 0; font-size: 11px; line-height: 1.6; opacity: .72; }
.band .metric { flex: 1; }
.band .metric .v { font-size: 22px; font-weight: 700; letter-spacing: -0.4px; }
.band .metric .k { font-size: 11px; opacity: .72; margin-top: 3px; }

/* 表格 */
.table-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; }
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; font-size: 11.5px; font-weight: 500; color: var(--text-2);
  background: var(--bg); padding: 10px 12px; white-space: nowrap;
}
thead th:first-child { border-radius: 8px 0 0 8px; }
thead th:last-child { border-radius: 0 8px 8px 0; }
tbody td { padding: 12px; border-bottom: 1px solid var(--line-2); font-size: 12.5px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FCFCFD; }
.cell-main { font-weight: 500; font-size: 13px; }
.cell-sub { font-size: 10.5px; color: var(--text-3); margin-top: 3px; }
.ellipsis { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 6px; }
.table-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; font-size: 11.5px; color: var(--text-3); }

.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 7px; border-radius: 7px; font-size: 11px; font-weight: 500; white-space: nowrap; }
.badge .bdot { width: 6px; height: 6px; border-radius: 50%; }
.badge-ok { background: var(--ok-bg); color: var(--ok-text); } .badge-ok .bdot { background: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn-text); } .badge-warn .bdot { background: var(--warn); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); } .badge-danger .bdot { background: var(--danger); }
.badge-mute { background: var(--line-2); color: var(--text-2); } .badge-mute .bdot { background: var(--text-3); }
.badge-info { background: var(--primary-soft); color: var(--primary); } .badge-info .bdot { background: var(--primary); }

/* 分栏 */
.split { display: grid; grid-template-columns: 400px 1fr; gap: 16px; align-items: start; }
.account-list { display: flex; flex-direction: column; gap: 6px; max-height: 620px; overflow-y: auto; }
.account-item {
  display: flex; align-items: center; gap: 10px; padding: 11px 12px;
  border-radius: var(--radius-sm); cursor: pointer; border: 1px solid transparent;
  transition: background .15s;
}
.account-item:hover { background: #F7F8FA; }
.account-item.active { background: var(--primary-soft); border-color: #CBDCF3; }
.account-item .nm { font-size: 12.5px; font-weight: 600; }
.account-item .ac { font-size: 10.5px; color: var(--text-2); margin-top: 2px; }
.account-item .tag { font-size: 10px; font-weight: 500; color: var(--primary); white-space: nowrap; }

.perm-row {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px;
  background: var(--bg); border-radius: var(--radius-sm); margin-bottom: 6px;
}
.perm-row label { display: flex; align-items: center; gap: 11px; flex: 1; cursor: pointer; min-width: 0; }
.perm-row input[type="checkbox"] { width: 17px; height: 17px; accent-color: var(--primary); flex: none; margin: 0; }

.note { display: flex; gap: 10px; align-items: flex-start; padding: 14px; background: var(--primary-soft); border-radius: 12px; }
.note p { margin: 0; font-size: 11.5px; line-height: 1.6; color: var(--info-text); }

.alert { display: none; gap: 9px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; margin-bottom: 14px; font-size: 12.5px; }
.alert.show { display: flex; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }

.empty { padding: 44px 20px; text-align: center; color: var(--text-3); font-size: 12.5px; }
.empty strong { display: block; font-size: 14px; color: var(--text-2); margin-bottom: 6px; }

.progress { height: 6px; border-radius: 3px; background: #E9EBEF; overflow: hidden; }
.progress .fill { height: 100%; background: var(--primary); transition: width .3s; }
.progress .fill.warn { background: var(--warn); }
.progress .fill.danger { background: var(--danger); }

.kv { display: flex; align-items: center; justify-content: space-between; padding: 11px 0; border-bottom: 1px solid var(--line-2); font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv .k { color: var(--text-3); }
.kv .v { font-weight: 500; }

pre.cmd {
  margin: 0; padding: 14px; background: #0A1628; color: #B9D4FF; border-radius: 10px;
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; line-height: 1.7;
  overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}
pre.cmd .k { color: #7FB2FF; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(10, 22, 40, .45); z-index: 100;
  display: none; align-items: flex-start; justify-content: center; padding: 60px 20px; overflow-y: auto;
}
.modal-mask.show { display: flex; }
.modal {
  width: 560px; max-width: 100%; background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 24px 70px rgba(10, 22, 40, .3);
}
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 22px 0; }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 700; }
.modal-head p { margin: 5px 0 0; font-size: 11.5px; color: var(--text-3); }
.modal-close { border: none; background: none; cursor: pointer; color: var(--text-3); padding: 4px; }
.modal-body { padding: 20px 22px; max-height: 62vh; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 0 22px 20px; }

.toast {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%) translateY(16px);
  background: rgba(10, 22, 40, .92); color: #fff; font-size: 13px; padding: 12px 20px;
  border-radius: 10px; opacity: 0; transition: all .22s; z-index: 200; pointer-events: none; max-width: 70vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.spin { width: 15px; height: 15px; border: 2px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

@media (max-width: 1200px) {
  .split { grid-template-columns: 1fr; }
  .band { flex-wrap: wrap; gap: 18px; }
  .band .bl { width: 100%; }
}
/* ============================ 广告管理（左窄选位 + 右宽编辑/预览） ============================ */

.ad-manage-layout { display: grid; grid-template-columns: 250px 1fr; gap: 16px; align-items: start; }
@media (max-width: 960px) { .ad-manage-layout { grid-template-columns: 1fr; } }

.ad-manage-side {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; position: sticky; top: 24px; display: flex; flex-direction: column; gap: 8px;
}
.ad-side-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; color: var(--text-3); padding: 2px 6px 4px; }
.ad-slot-item {
  display: flex; flex-direction: column; gap: 4px; text-align: left; cursor: pointer;
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  padding: 10px 12px; font-family: inherit; transition: border-color .15s, box-shadow .15s, background .15s;
}
.ad-slot-item:hover { border-color: #C9D6EC; }
.ad-slot-item.active { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.ad-slot-item .t { font-weight: 600; font-size: 14px; color: var(--text); }
.ad-slot-item .d { font-size: 12px; color: var(--text-2); }
.ad-slot-item .m { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.ad-side-tip { font-size: 12px; color: var(--text-3); line-height: 1.7; padding: 8px 6px 2px; border-top: 1px dashed var(--line); }

/* 手机样机预览 */
.ad-prev-phone {
  width: 280px; border-radius: 28px; border: 8px solid #0A1628; background: #0A1628;
  box-shadow: 0 12px 28px rgba(10,22,40,.18); overflow: hidden;
}
.ad-prev-screen { position: relative; height: 480px; background: #F4F6FA; display: flex; flex-direction: column; overflow: hidden; }
.ad-prev-page {
  flex: 1; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 12px; letter-spacing: .1em;
  background: repeating-linear-gradient(45deg, #EEF1F6 0 12px, #F6F8FB 12px 24px);
}
.ad-prev-bar { height: 50px; background: #fff; border-bottom: 1px solid var(--line-2); overflow: hidden; display: flex; }
.ad-prev-bar:last-child { border-bottom: none; border-top: 1px solid var(--line-2); }
.ad-prev-bar img, .ad-prev-bar iframe { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.ad-prev-splash { position: absolute; inset: 0; background: #05080F; z-index: 5; }
.ad-prev-splash img, .ad-prev-splash iframe { width: 100%; height: 100%; object-fit: contain; border: 0; display: block; }
.ad-prev-skip {
  position: absolute; top: 10px; right: 10px; padding: 3px 10px; border: none; border-radius: 12px;
  background: rgba(255,255,255,.22); color: #fff; font-size: 11px;
}
.ad-prev-empty {
  width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); font-size: 11px;
}
/* 广告编辑区：文本框左对齐 + 宽度自适应 */
.ad-fields .kv { justify-content: flex-start; gap: 14px; }
.ad-fields .kv .k { flex: 0 0 auto; min-width: 76px; }
.ad-fields .kv .v { flex: 1 1 auto; min-width: 0; }
.ad-fields .kv .input.set-field { width: 100% !important; max-width: 640px; }
/* 顶行（启用/类型/时长）保持紧凑，不参与拉伸 */
.ad-fields .ad-inline-row { gap: 24px; }
.ad-fields .ad-inline-row .kv { padding: 4px 0; border-bottom: none; }
.ad-fields .ad-inline-row .input.set-field { width: 150px !important; max-width: none; }

/* 系统设置分区：kv 行整体靠左，输入框紧跟标签，宽度适中自适应 */
.set-fields .kv { justify-content: flex-start; gap: 16px; }
.set-fields .kv .k { flex: 0 0 auto; min-width: 150px; }
.set-fields .kv .v { flex: 1 1 auto; min-width: 0; justify-content: flex-start; }
.set-fields .kv .input.set-field { width: 260px !important; max-width: 100%; }

/* 用户与权限页顶部标签切换（账号授权 / 角色管理） */
.seg-tabs { display: inline-flex; align-items: center; gap: 2px; background: var(--primary-soft); border: 1px solid var(--line-2); border-radius: 9px; padding: 3px; }
.seg-tab { border: 0; background: transparent; padding: 6px 16px; font-size: 12.5px; font-family: inherit; font-weight: 500; border-radius: 7px; cursor: pointer; color: var(--text-2); transition: all .15s; }
.seg-tab:hover { color: var(--primary); }
.seg-tab.active { background: #fff; color: var(--primary); font-weight: 600; box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
