:root {
  --bg-darkest: #07090e;
  --bg-base: #0d121f;
  --bg-surface: #141c2e;
  --bg-card: #18233a;
  --bg-card-hover: #1f2d4a;
  --border-subtle: #243452;
  --border-focus: #38bdf8;
  
  --primary: #38bdf8;
  --primary-hover: #0ea5e9;
  --primary-glow: rgba(56, 189, 248, 0.25);

  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-red: #ef4444;

  /* APEX 段位專屬色彩 */
  --rank-predator: #ef4444;
  --rank-master: #a855f7;
  --rank-diamond: #06b6d4;
  --rank-platinum: #38bdf8;
  --rank-gold: #f59e0b;
  --rank-silver: #94a3b8;
  --rank-bronze: #cd7f32;
  --rank-rookie: #10b981;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-base: 'Noto Sans TC', system-ui, -apple-system, sans-serif;
  --font-display: 'Chakra Petch', sans-serif;

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

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

body {
  background-color: var(--bg-base);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(239, 68, 68, 0.05) 0%, transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(168, 85, 247, 0.06) 0%, transparent 45%);
  color: var(--text-main);
  font-family: var(--font-base);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* 頂欄導覽 */
.navbar {
  background-color: rgba(13, 18, 31, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0.85rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  user-select: none;
}

.brand-icon {
  font-size: 1.9rem;
  filter: drop-shadow(0 0 10px rgba(239, 68, 68, 0.4));
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 1px;
  background: linear-gradient(135deg, #ef4444, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: block;
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-btn:hover {
  color: var(--text-main);
  background-color: var(--bg-surface);
}

.nav-btn.active {
  color: var(--primary);
  background-color: var(--bg-surface);
  border-color: var(--border-subtle);
}

.nav-btn.admin-btn {
  color: var(--accent-amber);
}

.badge-count {
  background: var(--accent-rose);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-full);
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  cursor: pointer;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rank-predator), var(--accent-purple));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.user-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.role-tag {
  font-size: 0.7rem;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-weight: 600;
}

.role-tag.admin {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.role-tag.player {
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* 統計條 */
.stats-bar {
  background-color: var(--bg-darkest);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.65rem 0;
}

.stats-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 1rem;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.stat-label {
  color: var(--text-muted);
}

.stat-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-main);
}

.stat-divider {
  width: 1px;
  height: 16px;
  background-color: var(--border-subtle);
}

/* 主體版面 */
.main-container {
  max-width: 1360px;
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
  flex: 1;
  width: 100%;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
}

.section-desc {
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* 按鈕規範 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.55rem 1.15rem;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, #e11d48, #be123c);
  color: #fff;
  border-color: #f43f5e;
  box-shadow: 0 2px 10px rgba(225, 29, 72, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #be123c, #9f1239);
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.5);
}

.btn-success {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  border-color: #10b981;
}

.btn-success:hover {
  background: linear-gradient(135deg, #047857, #065f46);
}

.btn-outline {
  background: transparent;
  border-color: var(--border-subtle);
  color: var(--text-muted);
}

.btn-outline:hover {
  background: var(--bg-surface);
  color: var(--text-main);
  border-color: var(--primary);
}

.btn-danger-outline {
  background: transparent;
  border-color: rgba(244, 63, 94, 0.4);
  color: var(--accent-rose);
}

.btn-danger-outline:hover {
  background: rgba(244, 63, 94, 0.1);
  border-color: var(--accent-rose);
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.75rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

/* 篩選面板 */
.filter-card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 1rem;
  gap: 0.6rem;
  transition: var(--transition-fast);
}

.search-box:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-box input {
  background: transparent;
  border: none;
  color: var(--text-main);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  font-family: inherit;
}

.filter-category {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.filter-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
}

.sub-tier-select {
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  color: #38bdf8;
  padding: 0.35rem 0.65rem;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
  outline: none;
}

.sub-tier-select:focus {
  border-color: var(--border-focus);
}

.filter-groups {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  border-top: 1px dashed var(--border-subtle);
  padding-top: 0.85rem;
}

.filter-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-inline-label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.pill {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 0.82rem;
  padding: 0.35rem 0.85rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.pill:hover {
  color: var(--text-main);
  background: var(--bg-card-hover);
}

.pill.active {
  background: rgba(56, 189, 248, 0.15);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.pill.pill-predator.active {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--rank-predator);
  color: #fca5a5;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.3);
}

.pill.pill-master.active {
  background: rgba(168, 85, 247, 0.2);
  border-color: var(--rank-master);
  color: #d8b4fe;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.3);
}

.pill.pill-diamond.active {
  background: rgba(6, 182, 212, 0.2);
  border-color: var(--rank-diamond);
  color: #67e8f9;
  box-shadow: 0 0 10px rgba(6, 182, 212, 0.3);
}

/* 帳號卡片網格 */
.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 1.5rem;
}

.account-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.account-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  opacity: 0;
  transition: var(--transition-normal);
}

.account-card:hover {
  transform: translateY(-3px);
  border-color: rgba(244, 63, 94, 0.4);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
}

.account-card:hover::before {
  opacity: 1;
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

/* APEX 段位標籤 */
.rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.rank-predator {
  background: rgba(239, 68, 68, 0.18);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.5);
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.2);
}

.rank-master {
  background: rgba(168, 85, 247, 0.18);
  color: #c084fc;
  border: 1px solid rgba(168, 85, 247, 0.5);
}

.rank-diamond {
  background: rgba(6, 182, 212, 0.18);
  color: #38bdf8;
  border: 1px solid rgba(6, 182, 212, 0.5);
}

.rank-platinum {
  background: rgba(56, 189, 248, 0.15);
  color: #7dd3fc;
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.rank-gold {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.rank-silver {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.4);
}

.rank-bronze {
  background: rgba(205, 127, 50, 0.15);
  color: #e2a76f;
  border: 1px solid rgba(205, 127, 50, 0.4);
}

.rank-rookie {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.platform-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-main);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
}

.status-badge.available {
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.status-badge.in-use {
  background: rgba(245, 158, 11, 0.15);
  color: #fbbf24;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.account-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.4rem;
  line-height: 1.4;
}

/* 英雄預覽列表 (卡片內部) */
.heroes-preview-box {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.75rem;
  margin: 0.6rem 0;
}

.heroes-preview-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.heroes-mini-grid {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}

.hero-mini-avatar {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  border: 1px solid rgba(56, 189, 248, 0.4);
  background: #000;
  transition: transform 0.15s ease;
}

.hero-mini-avatar:hover {
  transform: scale(1.15);
  border-color: #38bdf8;
  box-shadow: 0 0 6px rgba(56, 189, 248, 0.6);
  z-index: 2;
}

.heroes-more-pill {
  font-size: 0.72rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 0.2rem 0.45rem;
  border-radius: 4px;
}

.account-meta {
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
  margin-bottom: 1rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.account-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* 在借卡片 (My Borrowed Card) */
.borrowed-card {
  background: linear-gradient(135deg, rgba(20, 28, 46, 0.95), rgba(27, 38, 63, 0.95));
  border: 1px solid #e11d48;
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(225, 29, 72, 0.25);
}

.borrowed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.credentials-box {
  background: var(--bg-darkest);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin: 1rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.platform-cred-section {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.platform-cred-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 0.85rem;
}

.cred-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.cred-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  min-width: 60px;
}

.cred-val {
  font-family: monospace;
  font-size: 0.95rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  user-select: all;
  word-break: break-all;
}

/* 雙平台輸入區 */
.platform-input-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.9rem;
}

.platform-input-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.platform-hint {
  font-size: 0.78rem;
  color: var(--text-dim);
}

/* 英雄點亮/黯淡選擇器 (Hero Grid Selector) */
.hero-selector-section {
  background: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.hero-selector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.hero-selector-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

.hero-quick-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.hero-count-pill {
  font-family: var(--font-display);
  font-size: 0.82rem;
  font-weight: 700;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 0.2rem 0.65rem;
  border-radius: var(--radius-full);
}

.hero-grid-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(105px, 1fr));
  gap: 0.85rem;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 0.3rem;
}

/* 英雄卡片 (點亮 vs 黯淡) */
.hero-card-item {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.6rem 0.3rem 0.5rem;
  text-align: center;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* 點亮狀態 (Lit - 擁有) */
.hero-card-item.is-lit {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.09);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
  transform: translateY(-2px);
}

.hero-card-item.is-lit .hero-avatar-img {
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.6));
  opacity: 1;
}

.hero-card-item.is-lit .hero-status-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.4);
}

/* 黯淡狀態 (Dimmed - 未解鎖) */
.hero-card-item.is-dimmed {
  border-color: rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.3);
  opacity: 0.4;
}

.hero-card-item.is-dimmed:hover {
  opacity: 0.75;
  border-color: var(--border-subtle);
}

.hero-card-item.is-dimmed .hero-avatar-img {
  filter: grayscale(1);
}

.hero-card-item.is-dimmed .hero-status-badge {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

/* 歸還時新購買點亮標籤 */
.hero-card-item.is-new-unlocked {
  border-color: #f59e0b !important;
  background: rgba(245, 158, 11, 0.15) !important;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.5) !important;
}

.hero-card-item.is-new-unlocked .hero-status-badge {
  background: rgba(245, 158, 11, 0.3) !important;
  color: #fef08a !important;
  border: 1px solid #f59e0b !important;
  font-weight: 700;
}

.hero-avatar-img {
  width: 64px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
  margin-bottom: 0.35rem;
  background: #000;
  transition: all 0.2s ease;
}

.hero-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-main);
  display: block;
  line-height: 1.2;
}

.hero-role {
  font-size: 0.68rem;
  color: var(--text-dim);
  display: block;
  margin-bottom: 0.25rem;
}

.hero-status-badge {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  display: inline-block;
}

/* 歸還摘要區 */
.return-summary-box {
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

/* 表單容器 */
.form-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 860px;
  margin: 0 auto;
}

.styled-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-row.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

@media (max-width: 640px) {
  .form-row.two-cols {
    grid-template-columns: 1fr;
  }
}

label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-main);
}

.required {
  color: var(--accent-rose);
}

input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  background-color: var(--bg-darkest);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.9rem;
  color: var(--text-main);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: var(--transition-fast);
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

select {
  cursor: pointer;
}

.security-card {
  background: rgba(225, 29, 72, 0.05);
  border: 1px solid rgba(225, 29, 72, 0.25);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.security-card-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: #f43f5e;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

/* 標籤頁導覽 */
.tabs-nav,
.admin-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.sub-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.sub-tab:hover {
  color: var(--text-main);
}

.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.sub-view {
  display: none;
}

.sub-view.active {
  display: block;
  animation: fadeIn 0.2s ease;
}

/* 資料表格 */
.table-container {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.table-toolbar {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.15);
}

.table-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.table-subtitle {
  font-size: 0.8rem;
  color: var(--text-dim);
  margin-left: 0.5rem;
}

.custom-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.custom-table th {
  background-color: rgba(7, 9, 14, 0.6);
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
}

.custom-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(36, 52, 82, 0.5);
  color: var(--text-main);
  vertical-align: middle;
}

.custom-table tr:hover td {
  background-color: var(--bg-card);
}

.code-badge {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.1);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  display: inline-block;
}

/* 站長卡片 */
.admin-action-card {
  background: var(--bg-surface);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card-head {
  margin-bottom: 1rem;
}

.card-head h3 {
  font-size: 1.1rem;
  color: #fbbf24;
}

.card-tip {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.inline-form {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  flex-wrap: wrap;
}

/* 彈窗 Dialog */
.styled-dialog {
  margin: auto;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 0;
  color: var(--text-main);
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  outline: none;
}

.styled-dialog.dialog-lg {
  max-width: 780px;
}

.styled-dialog::backdrop {
  background: rgba(7, 9, 14, 0.75);
  backdrop-filter: blur(6px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.dialog-header h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

.dialog-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--text-main);
}

.dialog-body {
  padding: 1.5rem;
  max-height: 80vh;
  overflow-y: auto;
}

.dialog-form {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  max-height: 80vh;
  overflow-y: auto;
}

.dialog-tip {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
}

.dialog-footer-switch {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.dialog-footer-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 600;
}

.dialog-footer-switch a:hover {
  text-decoration: underline;
}

.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  line-height: 1.5;
}

.alert-info {
  background: rgba(56, 189, 248, 0.1);
  border: 1px solid rgba(56, 189, 248, 0.3);
  color: #7dd3fc;
}

/* Toast 提示 (最上層置頂顯示，保證在對話框 Top Layer 依然清楚可見) */
.toast-container,
.dialog-top-toast-box {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  z-index: 2147483647;
  pointer-events: none;
  width: 100%;
  max-width: 520px;
  padding: 0 1rem;
}

.toast {
  pointer-events: auto;
  background: rgba(18, 24, 38, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-left: 5px solid var(--primary);
  color: var(--text-main);
  padding: 0.85rem 1.35rem;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.65), 0 0 15px rgba(255, 255, 255, 0.05);
  font-size: 0.92rem;
  font-weight: 600;
  min-width: 280px;
  max-width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  animation: toastDropIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast.toast-success {
  border-left-color: var(--accent-emerald);
}

.toast.toast-error {
  border-left-color: var(--accent-rose);
  background: rgba(26, 16, 24, 0.97);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7), 0 0 20px rgba(244, 63, 94, 0.25);
}

.toast.toast-warning {
  border-left-color: var(--accent-amber);
}

@keyframes toastDropIn {
  from { transform: translateY(-30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.text-success { color: var(--accent-emerald) !important; }
.text-warning { color: var(--accent-amber) !important; }
.text-cyan { color: var(--accent-cyan) !important; }
.text-lead { font-size: 1.05rem; font-weight: 600; }
.loading-spinner {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 0;
  color: var(--text-muted);
}

/* 頭像系統樣式 */
.user-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--accent-cyan);
  background: #111;
  display: block;
}

.profile-avatar-preview-wrap {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--accent-cyan);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.35);
  background: var(--bg-card);
}

.profile-avatar-preview {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* 角色標籤樣式 */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.role-badge.super-admin {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.role-badge.level-1 {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.role-badge.level-2 {
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.4);
}

.role-badge.player {
  background: rgba(148, 163, 184, 0.15);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.3);
}

/* 管理員權限 Checkbox 表格樣式 */
.perm-checkbox-group {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.35rem 0.75rem;
  font-size: 0.8rem;
  text-align: left;
}

.perm-cb-label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  cursor: pointer;
  color: #cbd5e1;
  user-select: none;
}

.perm-cb-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
  cursor: pointer;
}

.perm-cb-label:hover {
  color: #fff;
}

.btn-xs {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
}

/* 彈窗內部的醒目即時錯誤警告框 (免按確定、置於最上層) */
.dialog-alert-banner {
  background: rgba(225, 29, 72, 0.15);
  border: 1px solid rgba(225, 29, 72, 0.45);
  border-left: 4px solid var(--accent-rose);
  color: #fecdd3;
  padding: 0.85rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.92rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  animation: toastDropIn 0.2s ease;
  box-shadow: 0 4px 15px rgba(225, 29, 72, 0.15);
}

/* 預設權限範本彈窗樣式 */
.role-templates-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

@media (max-width: 900px) {
  .role-templates-grid {
    grid-template-columns: 1fr;
  }
}

.role-template-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.role-template-head {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255, 255, 255, 0.02);
}

.role-template-head.tier-l1 {
  border-top: 3px solid #f59e0b;
}

.role-template-head.tier-l2 {
  border-top: 3px solid #38bdf8;
}

.role-template-head.tier-player {
  border-top: 3px solid #94a3b8;
}

.role-template-head h4 {
  font-size: 0.92rem;
  margin: 0;
  color: var(--text-main);
}

.role-template-body {
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  font-size: 0.84rem;
}

.perm-checkbox-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  cursor: pointer;
  color: #cbd5e1;
  line-height: 1.4;
  user-select: none;
}

.perm-checkbox-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
  margin-top: 2px;
  cursor: pointer;
  flex-shrink: 0;
}

.perm-checkbox-item:hover {
  color: #fff;
}

.perm-checkbox-item span strong {
  color: #f1f5f9;
}


