/**
 * 孙武广告平台 · 公共样式（框架 + 所有子页面共享）
 * 视觉规范对齐 v45（木杉风格）：主色 #C83C3C、导航强调色 #d94343
 */
:root {
  --ad-color-primary: #C83C3C;
  --ad-color-primary-hover: #a83232;
  --ad-color-primary-light: #fdf0f0;
  --ad-color-primary-border: #f5c6c6;
  --ad-text-primary: #1f2937;
  --ad-text-secondary: #667085;
  --ad-text-tertiary: #98a2b3;
  --ad-bg-page: #f5f5f5;
  --ad-bg-card: #ffffff;
  --ad-bg-subtle: #f8fafc;
  --ad-border-subtle: #d9d9d9;
  --ad-radius: 6px;
  --ad-shadow-card: 0 6px 18px rgba(31, 41, 55, 0.06);
  --ad-nav-accent: #d94343;
  --ad-font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", Arial, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ad-text-primary); background: var(--ad-bg-page);
  font-family: var(--ad-font); font-size: 14px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

/* ===== Topbar（框架） ===== */
.ad-topbar { height: 48px; padding: 0 24px 0 14px; display: flex; align-items: center; justify-content: space-between; background: #fff; border-bottom: 1px solid #ececec; position: sticky; top: 0; z-index: 40; }
.ad-brand { display: flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 700; color: #252525; }
.ad-brand-mark { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #b93636; color: #fff; font-size: 10px; font-weight: 600; }
.ad-admin { color: #999; font-size: 14px; }

/* ===== Shell / Sidebar（框架） ===== */
.ad-shell { display: flex; min-height: calc(100vh - 48px); }
.ad-sidebar { width: 242px; flex: 0 0 242px; background: #fff; border-right: 1px solid #ececec; padding: 10px 8px 24px; position: sticky; top: 48px; align-self: flex-start; height: calc(100vh - 48px); overflow-y: auto; }
.ad-sidebar::-webkit-scrollbar { width: 6px; }
.ad-sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
.ad-sidebar::-webkit-scrollbar-track { background: transparent; }

.nav-welcome { padding: 6px 16px 14px; color: #777; cursor: pointer; min-height: 38px; display: flex; align-items: center; border-radius: 6px; }
.nav-welcome:hover { color: var(--ad-nav-accent); background: #fff6f6; }

.nav-group-head { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding: 0 16px; color: #666; cursor: pointer; user-select: none; border-radius: 6px; }
.nav-group-head:hover { color: var(--ad-nav-accent); background: #fff6f6; }
.nav-group.open > .nav-group-head { color: var(--ad-nav-accent); font-weight: 600; }
.nav-group-head .caret { font-size: 14px; color: inherit; flex-shrink: 0; }
.nav-sub { max-height: 0; overflow: hidden; transition: max-height .25s ease; }
.nav-group.open > .nav-sub { max-height: 600px; }

.nav-item { display: flex; align-items: center; gap: 8px; min-height: 38px; border-radius: 6px; padding: 0 16px 0 32px; margin: 2px 0; color: #666; cursor: pointer; user-select: none; }
.nav-item:hover { background: #fff6f6; color: var(--ad-nav-accent); }
.nav-item.active { background: #fff0f0; color: var(--ad-nav-accent); }
.nav-item-top { padding-left: 16px; }
.nav-item-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.demo-badge { flex-shrink: 0; font-size: 11px; line-height: 1; padding: 2px 7px; border-radius: 999px; background: var(--ad-nav-accent); color: #fff; font-weight: 500; }

/* ===== Main / 面包屑 / 卡片（框架 + 子页面） ===== */
.ad-main { flex: 1; padding: 26px 38px 40px; min-width: 0; overflow-x: hidden; }
@media (max-width: 1280px) {
  .ad-main { padding: 26px 20px 40px; }
}
.breadcrumb { margin-bottom: 22px; color: #7d7d7d; font-size: 14px; }
.breadcrumb strong { color: #333; font-weight: 500; }

.ad-card { position: relative; background: #fff; border-radius: 6px; overflow: hidden; }
.ad-section { padding: 16px 34px 26px; border-bottom: 1px solid #ededed; }
@media (max-width: 1280px) {
  .ad-section { padding: 16px 20px 26px; }
}
.ad-section-heading { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; padding-left: 9px; border-left: 3px solid var(--ad-nav-accent); font-size: 15px; font-weight: 700; }
.ad-collapse { border: 0; background: transparent; color: var(--ad-nav-accent); font-size: 13px; padding: 0; }
.ad-section-body { overflow: hidden; max-height: 2400px; transition: max-height .25s ease; }
.ad-section.collapsed .ad-section-body { max-height: 0; }

/* ===== 表单控件（子页面） ===== */
.ad-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px 60px; }
.ad-field { min-width: 0; }
.ad-field label { display: block; margin-bottom: 8px; color: #333; }
.required::before { content: '*'; color: var(--ad-nav-accent); margin-right: 4px; }
.ad-field.span-2 { grid-column: 1 / -1; }

.ad-input { width: 100%; max-width: 500px; height: 32px; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); padding: 6px 10px; color: #333; background: #fff; outline: none; transition: border-color .18s, box-shadow .18s; }
.ad-input::placeholder { color: #aaa; }
.ad-input:hover { border-color: var(--ad-color-primary-border); }
.ad-input:focus { border-color: var(--ad-color-primary); box-shadow: 0 0 0 3px rgba(200, 60, 60, .12); }

.ad-select { width: 100%; max-width: 500px; position: relative; }
.ad-select-trigger { height: 32px; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 10px; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); background: #fff; cursor: pointer; transition: border-color .18s, box-shadow .18s; }
.ad-select-trigger:hover { border-color: var(--ad-color-primary-border); }
.ad-select-trigger.focused { border-color: var(--ad-color-primary); box-shadow: 0 0 0 3px rgba(200, 60, 60, .12); }
.ad-select-value { font-size: 14px; color: #333; flex: 1; min-width: 0; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ad-select-placeholder { font-size: 14px; color: #aaa; flex: 1; min-width: 0; text-align: left; }
.ad-select-caret { color: #98a2b3; font-size: 12px; flex-shrink: 0; }
.ad-select-dropdown { position: absolute; top: calc(100% + 4px); left: 0; right: 0; background: #fff; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); box-shadow: 0 18px 40px rgba(15, 23, 42, .16); max-height: 256px; overflow-y: auto; z-index: 50; display: none; padding: 4px; }
.ad-select.open .ad-select-dropdown { display: block; }
.ad-select-option { min-height: 32px; display: flex; align-items: center; padding: 0 10px; border-radius: 4px; font-size: 13px; color: #344054; cursor: pointer; transition: background .15s; }
.ad-select-option:hover { background: #f8fafc; }
.ad-select-option.selected { background: var(--ad-color-primary-light); color: var(--ad-color-primary); font-weight: 600; }

.ad-switch { position: relative; width: 36px; height: 20px; border-radius: 999px; background: #d0d5dd; cursor: pointer; transition: background .2s; border: none; padding: 0; }
.ad-switch.on { background: var(--ad-color-primary); }
.ad-switch::after { content: ""; position: absolute; width: 16px; height: 16px; left: 2px; top: 2px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.ad-switch.on::after { transform: translateX(16px); }

.ad-radio-group { display: flex; gap: 16px; }
.ad-radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-size: 14px; color: #555; user-select: none; }
.ad-radio input { display: none; }
.ad-radio-dot { width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--ad-border-subtle); background: #fff; position: relative; flex-shrink: 0; transition: border-color .15s; }
.ad-radio input:checked + .ad-radio-dot { border-color: var(--ad-color-primary); }
.ad-radio input:checked + .ad-radio-dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--ad-color-primary); }

.ad-date-range { width: 100%; max-width: 500px; height: 32px; padding: 6px 10px; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); background: #fff; display: flex; align-items: center; justify-content: space-between; gap: 8px; cursor: pointer; color: #aaa; font-size: 14px; transition: border-color .18s; }
.ad-date-range:hover { border-color: var(--ad-color-primary-border); }
.ad-date-range svg { width: 14px; height: 14px; color: #b8bbc1; flex-shrink: 0; }

.ad-multiselect { width: 100%; max-width: 500px; min-height: 32px; padding: 4px 10px; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); background: #fff; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; cursor: pointer; transition: border-color .18s; }
.ad-multiselect:hover { border-color: var(--ad-color-primary-border); }
.ad-multiselect-placeholder { color: #aaa; font-size: 14px; }
.ad-tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border: 1px solid var(--ad-color-primary-border); border-radius: 999px; background: var(--ad-color-primary-light); color: var(--ad-color-primary); font-size: 11px; white-space: nowrap; }

.ad-link-field { width: 100%; max-width: 500px; display: flex; align-items: center; gap: 8px; }
.ad-link-input { flex: 1; min-width: 0; height: 32px; padding: 6px 10px; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); background: #fff; display: flex; align-items: center; color: #333; font-size: 14px; }
.ad-link-input.placeholder { color: #aaa; }
.ad-link-btn { width: 30px; height: 30px; flex-shrink: 0; display: inline-flex; align-items: center; justify-content: center; border: 1px solid #d1d5db; border-radius: var(--ad-radius); background: #fff; color: #374151; cursor: pointer; transition: all .15s; }
.ad-link-btn:hover { background: var(--ad-color-primary-light); border-color: var(--ad-color-primary-border); color: var(--ad-color-primary); }
.ad-link-btn svg { width: 14px; height: 14px; }

/* ===== 按钮 ===== */
.ad-btn { min-width: 88px; min-height: 36px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 16px; border: 1px solid var(--ad-border-subtle); border-radius: var(--ad-radius); background: #fff; color: #374151; font-size: 14px; white-space: nowrap; transition: all .2s; }
.ad-btn:hover { border-color: var(--ad-color-primary-border); color: var(--ad-color-primary); background: var(--ad-color-primary-light); }
.ad-btn-primary { border-color: var(--ad-color-primary); background: var(--ad-color-primary); color: #fff; box-shadow: 0 6px 14px rgba(200, 60, 60, .22); }
.ad-btn-primary:hover { border-color: var(--ad-color-primary-hover); background: var(--ad-color-primary-hover); color: #fff; }
.ad-btn-sm { min-width: 0; min-height: 30px; padding: 0 10px; font-size: 12px; }

/* ===== Toast（框架） ===== */
.ad-toast { position: fixed; z-index: 70; top: 22px; left: 50%; transform: translate(-50%, -12px); display: none; min-width: 240px; padding: 10px 14px; border-radius: var(--ad-radius); background: #111827; color: #fff; box-shadow: 0 12px 30px rgba(15, 23, 42, .24); text-align: center; opacity: 0; transition: opacity .18s, transform .18s; font-size: 14px; }
.ad-toast.show { display: block; opacity: 1; transform: translate(-50%, 0); }

/* ===== 页脚（框架） ===== */
.update-record { height: 120px; display: flex; align-items: center; justify-content: center; color: #98a2b3; font-size: 14px; }

/* ===== 子页面 iframe（file:// 模式） ===== */
.ad-page-frame { width: 100%; height: calc(100vh - 48px - 26px); border: 0; display: block; background: transparent; }
