:root {
  --brand: #4F46E5;
  --brand-dark: #4338CA;
  --brand-light: #EEF2FF;
  --bg: #F5F6FA;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-2: #6B7280;
  --text-3: #9CA3AF;
  --border: #E5E7EB;
  --border-2: #F3F4F6;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --shadow-md: 0 4px 12px rgba(16,24,40,.08);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.12);
  --sidebar-w: 232px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 40;
}

.sidebar-brand {
  padding: 18px 18px 14px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border-2);
}
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), #7C3AED);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 15px;
  flex-shrink: 0;
}
.brand-name { font-weight: 600; font-size: 15px; letter-spacing: .2px; }

.org-switch {
  margin: 12px 12px 4px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; background: #fff;
  transition: all .15s;
}
.org-switch:hover { border-color: var(--brand); background: var(--brand-light); }
.org-switch .org-name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.org-switch .org-plan { font-size: 11px; color: var(--brand); background: var(--brand-light); padding: 1px 6px; border-radius: 4px; }

.nav { flex: 1; overflow-y: auto; padding: 10px 12px 20px; }
.nav-group { margin-bottom: 14px; }
.nav-group-title { font-size: 11px; color: var(--text-3); font-weight: 600; padding: 6px 10px; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 11px; border-radius: var(--radius-sm);
  color: var(--text-2); font-size: 13.5px; margin-bottom: 2px;
  transition: all .12s; cursor: pointer;
}
.nav-item:hover { background: var(--border-2); color: var(--text); }
.nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.nav-item .ico { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .badge { margin-left: auto; font-size: 11px; background: var(--border); padding: 0 6px; border-radius: 8px; color: var(--text-2); }
.nav-item.active .badge { background: var(--brand); color: #fff; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border-2); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 7px 8px; border-radius: var(--radius-sm); cursor: pointer; }
.user-chip:hover { background: var(--border-2); }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #8B5CF6);
  color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 600; flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-meta .n { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-meta .r { font-size: 11px; color: var(--text-3); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 24px;
  position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 16.5px; font-weight: 600; }
.topbar .sub { font-size: 12.5px; color: var(--text-3); }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 24px; flex: 1; }
.content-narrow { max-width: 860px; margin: 0 auto; }

/* ---------------- 组件 ---------------- */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); }
.card-pad { padding: 20px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--border-2); display: flex; align-items: center; gap: 10px; }
.card-head h3 { font-size: 14.5px; font-weight: 600; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--brand); color: #fff; border: 1px solid var(--brand);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  transition: all .15s; white-space: nowrap; line-height: 1.4;
}
.btn:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: var(--border-2); border-color: var(--text-3); }
.btn-danger { background: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }
.btn-success { background: var(--success); border-color: var(--success); }
.btn-success:hover { background: #059669; border-color: #059669; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn-lg { padding: 11px 22px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { padding: 7px; width: 33px; height: 33px; }

.input, .select, .textarea {
  width: 100%; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: #fff; transition: all .15s; font-size: 13.5px;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79,70,229,.1);
}
.textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }

.switch { position: relative; display: inline-block; width: 38px; height: 21px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; cursor: pointer; inset: 0;
  background: #D1D5DB; border-radius: 21px; transition: .2s;
}
.switch .slider:before {
  content: ""; position: absolute; height: 15px; width: 15px;
  left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s;
}
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider:before { transform: translateX(17px); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab {
  padding: 9px 14px; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; cursor: pointer; transition: all .15s; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

.badge-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500;
}
.badge-draft { background: #F3F4F6; color: #6B7280; }
.badge-published { background: #D1FAE5; color: #047857; }
.badge-paused { background: #FEF3C7; color: #B45309; }
.badge-closed { background: #FEE2E2; color: #B91C1C; }
.badge-archived { background: #E5E7EB; color: #4B5563; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 17px 19px;
}
.stat .label { font-size: 12.5px; color: var(--text-2); margin-bottom: 7px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 25px; font-weight: 700; letter-spacing: -.5px; }
.stat .foot { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.stat .value.brand { color: var(--brand); }

.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 14px; font-size: 12.5px;
  color: var(--text-2); font-weight: 600; background: #FAFBFC;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid var(--border-2); font-size: 13.5px; vertical-align: middle; }
.table tbody tr:hover { background: #FAFBFC; }
.table .actions { display: flex; gap: 6px; opacity: 0; transition: opacity .15s; }
.table tr:hover .actions { opacity: 1; }

.empty { text-align: center; padding: 56px 20px; color: var(--text-3); }
.empty .ico { font-size: 42px; margin-bottom: 12px; opacity: .35; }
.empty h3 { font-size: 15px; color: var(--text-2); font-weight: 600; margin-bottom: 6px; }
.empty p { font-size: 13px; margin-bottom: 18px; }

.flash-stack { position: fixed; top: 16px; right: 16px; z-index: 200; display: flex; flex-direction: column; gap: 9px; max-width: 380px; }
.flash {
  padding: 11px 15px; border-radius: var(--radius-sm); background: #fff;
  box-shadow: var(--shadow-lg); border-left: 3px solid var(--info);
  font-size: 13.5px; display: flex; gap: 9px; align-items: flex-start;
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.flash.error { border-left-color: var(--danger); }
.flash.success { border-left-color: var(--success); }
.flash.warning { border-left-color: var(--warning); }
.flash .close { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 16px; line-height: 1; }

.modal-mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.45);
  display: none; align-items: center; justify-content: center; z-index: 300; padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 520px;
  max-height: 88vh; overflow: hidden; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg); animation: popIn .2s ease;
}
@keyframes popIn { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }
.modal.wide { max-width: 760px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--border-2); display: flex; align-items: center; }
.modal-head h3 { font-size: 15px; font-weight: 600; }
.modal-head .x { margin-left: auto; cursor: pointer; color: var(--text-3); font-size: 20px; line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--border-2); display: flex; gap: 9px; justify-content: flex-end; }

.progress-bar { height: 5px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s; }

.dropdown {
  position: absolute; background: #fff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  min-width: 170px; padding: 5px; z-index: 100; display: none;
}
.dropdown.show { display: block; }
.dropdown-item { padding: 8px 11px; border-radius: 6px; font-size: 13.5px; cursor: pointer; display: flex; align-items: center; gap: 8px; color: var(--text-2); }
.dropdown-item:hover { background: var(--border-2); color: var(--text); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border-2); margin: 5px 0; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 400; }
.toast > div {
  background: #111827; color: #fff; padding: 10px 18px; border-radius: 22px;
  font-size: 13.5px; box-shadow: var(--shadow-lg); animation: popIn .2s;
}

/* ---------------- 登录页 ---------------- */
.auth-wrap { min-height: 100vh; display: flex; background: #fff; }
.auth-left {
  flex: 1; background: linear-gradient(140deg, #4F46E5 0%, #7C3AED 55%, #A855F7 100%);
  color: #fff; padding: 56px; display: flex; flex-direction: column; position: relative; overflow: hidden;
}
.auth-left:after {
  content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%;
  background: rgba(255,255,255,.09); right: -180px; bottom: -180px;
}
.auth-left h2 { font-size: 31px; font-weight: 700; line-height: 1.35; margin-bottom: 14px; letter-spacing: -.5px; }
.auth-left p { font-size: 15px; opacity: .9; line-height: 1.8; max-width: 420px; }
.auth-features { margin-top: auto; display: grid; gap: 13px; position: relative; z-index: 2; }
.auth-feature { display: flex; gap: 11px; align-items: flex-start; font-size: 14px; }
.auth-feature .dot { width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.22); display: grid; place-items: center; font-size: 11px; flex-shrink: 0; margin-top: 1px; }
.auth-right { width: 480px; display: flex; align-items: center; justify-content: center; padding: 40px; }
.auth-form { width: 100%; max-width: 356px; }
.auth-form h1 { font-size: 23px; font-weight: 700; margin-bottom: 6px; }
.auth-form .lead { color: var(--text-2); font-size: 13.5px; margin-bottom: 26px; }
.auth-form .foot { text-align: center; font-size: 13px; color: var(--text-2); margin-top: 20px; }
.divider-or { display: flex; align-items: center; gap: 12px; color: var(--text-3); font-size: 12px; margin: 18px 0; }
.divider-or:before, .divider-or:after { content: ""; flex: 1; height: 1px; background: var(--border); }
.pwd-meter { display: flex; gap: 4px; margin-top: 7px; }
.pwd-meter span { flex: 1; height: 3px; border-radius: 2px; background: var(--border); transition: background .2s; }

@media (max-width: 900px) {
  .auth-left { display: none; }
  .auth-right { width: 100%; }
}
