:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f9fbff;
  --border: #e5e9f2;
  --border-strong: #d7ddea;
  --text: #1f2937;
  --text-secondary: #667085;
  --text-light: #98a2b3;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success-bg: #ecfdf3;
  --success-text: #027a48;
  --warning-bg: #fff7ed;
  --warning-text: #c2410c;
  --muted-bg: #f2f4f7;
  --muted-text: #667085;
  --shadow-sm: 0 4px 14px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.10);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --topbar-height: 72px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}

body {
  min-width: 0;
}

img {
  display: block;
  max-width: 100%;
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.hidden {
  display: none !important;
}

.app-shell {
  min-height: 100vh;
  width: 100%;
}

/* 顶部固定表头 */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  z-index: 1000;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 28px;
  min-width: 0;
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 12px;
  transition: background 0.2s ease;
  flex-shrink: 0;
}

.brand-btn:hover {
  background: #f3f6fb;
}

.brand-avatar-wrap {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8eefc;
  flex-shrink: 0;
}

.brand-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}

.nav-link {
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-link:hover {
  background: #eef4ff;
  color: var(--primary);
}

.nav-link.active {
  background: #e8f0ff;
  color: var(--primary);
}

.topbar-right {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.user-menu {
  position: relative;
}

.user-menu-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}

.user-menu-trigger:hover {
  background: #f1f5f9;
}

.user-menu-arrow {
  font-size: 12px;
  color: var(--text-secondary);
}

.user-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 160px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 8px;
}

.dropdown-item {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-align: left;
}

.dropdown-item:hover {
  background: #f8fafc;
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: #fef2f2;
}

/* 主体区域 */
.page-main {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: calc(var(--topbar-height) + 28px) 24px 32px;
}

/* 通用按钮 */
.primary-btn,
.secondary-btn,
.ghost-btn,
.manage-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
}

.primary-btn {
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.secondary-btn {
  background: #eef4ff;
  color: var(--primary);
  border: 1px solid #dbe8ff;
}

.secondary-btn:hover {
  background: #e3edff;
}

.ghost-btn {
  background: #fff;
  color: var(--text-secondary);
  border: 1px solid var(--border);
}

.ghost-btn:hover {
  background: #f8fafc;
}

.manage-btn {
  min-height: 36px;
  padding: 0 14px;
  background: #eef4ff;
  color: var(--primary);
  border: 1px solid #dbe8ff;
}

.manage-btn:hover {
  background: #e3edff;
}

.icon-close-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 24px;
  line-height: 1;
}

.icon-close-btn:hover {
  background: #f4f6fa;
  color: var(--text);
}

/* 通用弹窗 */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
}

.modal-mask {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
}

.modal-dialog {
  position: relative;
  margin: 0 auto;
  top: 50%;
  transform: translateY(-50%);
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 2;
}

.modal-sm {
  width: 460px;
  max-width: calc(100vw - 32px);
}

.modal-md {
  width: 640px;
  max-width: calc(100vw - 32px);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 20px 20px;
  border-top: 1px solid var(--border);
}

.modal-footer.single-action {
  justify-content: center;
}

/* 通用卡片 */
.table-card,
.content-card {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
}