/* ============================================================
   MSG TopUni - 大学专业查询系统
   Design System v1.0
   色调: 金色 / 珍珠 / 深蓝
   ============================================================ */

/* ====== Design Tokens ====== */
:root {
  /* Brand Colors - Gold & Pearl */
  --gold: #c5a572;
  --gold-dark: #a6854e;
  --gold-light: #e0c9a6;
  --gold-bg: #faf5ed;
  --pearl: #faf9f6;
  --pearl-dark: #f5f0e8;

  /* Neutral Colors */
  --navy: #1a2332;
  --navy-light: #2d3a4e;
  --text-primary: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e0d8;
  --border-light: #f0ebe3;
  --white: #ffffff;
  --bg-main: #faf9f6;
  --bg-card: #ffffff;
  --bg-hover: #f9f6f0;
  --bg-active: #f5edd9;

  /* Semantic Colors */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --error: #ef4444;
  --error-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;

  /* Status Colors */
  --status-waiting: #6b7280;
  --status-submitted: #3b82f6;
  --status-admitted-un: #10b981;
  --status-admitted-c: #f59e0b;
  --status-terminal: #9ca3af;

  /* Typography */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 15px;
  --fs-xl: 17px;
  --fs-2xl: 20px;
  --fs-3xl: 24px;
  --fs-4xl: 30px;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;

  /* Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -4px rgba(0,0,0,0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1), 0 8px 10px -6px rgba(0,0,0,0.04);

  /* Transitions */
  --tr-fast: 150ms ease;
  --tr-normal: 250ms ease;
  --tr-slow: 400ms ease;

  /* Layout */
  --nav-height: 56px;
  --sidebar-width: 320px;
}

/* ====== Reset ====== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: var(--fs-base); -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}

a { color: var(--gold-dark); text-decoration: none; transition: color var(--tr-fast); }
a:hover { color: var(--gold); }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: var(--fs-base); }
ul, ol { list-style: none; }

/* ====== Scrollbar ====== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gold-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ============================================================
   NAVBAR
   ============================================================ */
.navbar {
  height: var(--nav-height);
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 100;
  border-bottom: 2px solid var(--gold);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  cursor: pointer;
}

.nav-logo img {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}

.nav-logo .brand-text {
  color: var(--gold-light);
  font-size: var(--fs-md);
  font-weight: 600;
  letter-spacing: 0.5px;
}

.nav-center {
  display: flex;
  gap: var(--sp-1);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.nav-tab {
  padding: var(--sp-2) var(--sp-5);
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.6);
  font-size: var(--fs-md);
  font-weight: 500;
  transition: all var(--tr-fast);
  white-space: nowrap;
}

.nav-tab:hover { color: var(--gold-light); background: rgba(197,165,114,0.15); }

.nav-tab.active {
  color: var(--navy);
  background: var(--gold);
  font-weight: 600;
}

.nav-settings {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: rgba(255,255,255,0.6);
  transition: all var(--tr-fast);
}

.nav-settings:hover { color: var(--gold-light); background: rgba(197,165,114,0.15); }
.nav-settings.active { color: var(--navy); background: var(--gold); }

.nav-settings svg { width: 20px; height: 20px; }

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-container {
  display: flex;
  height: calc(100vh - var(--nav-height));
}

/* ====== Split Panel ====== */
.split-panel {
  display: flex;
  width: 100%;
  height: 100%;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  background: var(--bg-main);
}

/* Override .content-area for major-list + major-detail side-by-side inside #uni-content */
#uni-content.split-major {
  display: flex !important;
  padding: 0 !important;
  overflow: hidden !important;
}

/* ====== Sidebar Header (Search) ====== */
.sidebar-header {
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.search-box svg {
  position: absolute;
  left: var(--sp-3);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.search-box input {
  width: 100%;
  padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-8);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  background: var(--pearl);
  transition: all var(--tr-fast);
  height: 34px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197,165,114,0.12);
  background: var(--white);
}

.search-box input::placeholder { color: var(--text-muted); }

/* ====== Level Toggle (Undergrad / Master) ====== */
.level-toggle {
  display: flex;
  gap: var(--sp-1);
  margin-top: var(--sp-3);
  background: var(--pearl-dark);
  border-radius: var(--radius-md);
  padding: 2px;
}

.level-toggle button {
  flex: 1;
  padding: var(--sp-2);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--tr-fast);
}

.level-toggle button.active {
  background: var(--white);
  color: var(--gold-dark);
  box-shadow: var(--shadow-xs);
  font-weight: 600;
}

/* ====== Sidebar List ====== */
.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2);
}

/* Country Group */
.country-group { margin-bottom: var(--sp-1); }

.country-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background var(--tr-fast);
  user-select: none;
}

.country-header:hover { background: var(--bg-hover); }
.country-header.active { background: var(--bg-active); }

.country-header .country-name {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
}

.country-header .country-count {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  background: var(--pearl-dark);
  padding: 2px 8px;
  border-radius: 10px;
}

.country-header .chevron {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform var(--tr-normal);
  margin-left: var(--sp-2);
}

.country-header.expanded .chevron { transform: rotate(90deg); }

.country-schools {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--tr-normal);
}

.country-group.open .country-schools { max-height: 2000px; }

/* School Item */
.school-item {
  padding: var(--sp-3) var(--sp-4) var(--sp-3) var(--sp-8);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--tr-fast);
  border-left: 3px solid transparent;
  margin: 2px 0;
}

.school-item:hover { background: var(--bg-hover); }

.school-item.selected {
  background: var(--bg-active);
  border-left-color: var(--gold);
}

.school-item .school-cn {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.4;
}

.school-item .school-en {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  line-height: 1.3;
  margin-top: 1px;
}

.school-item .school-qs {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: var(--fs-xs);
  color: var(--gold-dark);
  background: var(--gold-bg);
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: var(--sp-1);
  font-weight: 600;
}

/* Major Item in Sidebar */
.major-item {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--tr-fast);
  border-left: 3px solid transparent;
  margin: 2px 0;
}

.major-item:hover { background: var(--bg-hover); }

.major-item.selected {
  background: var(--bg-active);
  border-left-color: var(--gold);
}

.major-item .major-cn {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--text-primary);
}

.major-item .major-en {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
  margin-top: 1px;
}

/* Student Item in Sidebar */
.student-item {
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--tr-fast);
  border-left: 3px solid transparent;
  margin: 2px 0;
}

.student-item:hover { background: var(--bg-hover); }

.student-item.selected {
  background: var(--bg-active);
  border-left-color: var(--gold);
}

.student-item.terminal {
  opacity: 0.6;
}

.student-item .student-name {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
}

/* Female students: deep pink name */
.student-item[data-gender="女"] .student-name { color: #c2185b; }

.student-item .student-pinyin {
  font-size: var(--fs-xs);
  color: var(--text-secondary);
  font-weight: 400;
}

.student-item .student-status {
  display: inline-block;
  font-size: var(--fs-xs);
  padding: 1px 6px;
  border-radius: 3px;
  margin-top: var(--sp-1);
  font-weight: 500;
}

/* ====== Empty State ====== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-10);
  text-align: center;
  color: var(--text-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: var(--sp-4);
  opacity: 0.4;
}

.empty-state h3 {
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.empty-state p { font-size: var(--fs-base); }

/* ============================================================
   CONTENT AREA - Major Detail
   ============================================================ */
.detail-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-4);
  overflow: hidden;
}

.detail-header {
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 100%);
  color: var(--white);
}

.detail-header h2 {
  font-size: var(--fs-2xl);
  font-weight: 700;
  margin-bottom: var(--sp-1);
}

.detail-header .subtitle {
  font-size: var(--fs-md);
  color: var(--gold-light);
  opacity: 0.9;
}

.detail-header .meta-tags {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}

.detail-header .meta-tag {
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(197,165,114,0.25);
  color: var(--gold-light);
  font-weight: 500;
}

.detail-body {
  padding: 8px 12px;
}

/* Info Grid */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 2px 8px;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.info-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.info-value {
  font-size: 11px;
  color: var(--text-primary);
  font-weight: 500;
}

.info-value-row {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.info-copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s;
}

.info-copy-btn:hover {
  background: var(--gold-bg);
  border-color: var(--gold);
  color: var(--gold-dark);
}

.info-copy-btn.copied {
  background: var(--gold-light);
  border-color: var(--gold);
  color: var(--gold-dark);
}

.info-copy-btn svg { width: 11px; height: 11px; }

.info-value a {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--gold-dark);
}

.info-value a:hover { text-decoration: underline; }

.info-value a svg { width: 12px; height: 12px; }

/* Notes Section */
.notes-section {
  margin-top: 10px;
  padding: 10px 14px;
  background: var(--gold-bg);
  border-radius: var(--radius-md);
  border: 1px dashed var(--gold-light);
}

.notes-section .notes-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold-dark);
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.notes-section .notes-label svg { width: 12px; height: 12px; }

.notes-section .notes-content {
  font-size: var(--fs-sm);
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
}

/* ============================================================
   CONTENT AREA - Student Detail
   ============================================================ */
.student-detail {
  position: relative;
}

.student-detail .btn-add {
  position: absolute;
  top: 0;
  right: 0;
}

/* Application Card */
.app-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--sp-4);
  overflow: hidden;
  transition: all var(--tr-normal);
}

.app-card:hover { box-shadow: var(--shadow-md); }

.app-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--pearl);
  border-bottom: 1px solid var(--border);
}

.app-card-header .app-title {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.app-card-header .app-title .app-main-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.app-card-header .app-title .app-major {
  font-size: 13px;
  font-weight: 700;
  color: var(--gold-dark);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.app-major-en {
  font-weight: 500;
  color: var(--text-secondary);
}

.app-card-header .app-title .app-school {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-secondary);
}

.app-card-body {
  padding: 12px 16px;
}

/* Compact credential row in app cards (view mode) */
.app-creds-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.cred-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
}

.cred-item .cred-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  min-width: 24px;
}

.cred-item .cred-value {
  color: var(--text-primary);
  font-family: 'SF Mono', 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 2px 6px;
  background: var(--pearl);
  border-radius: 3px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cred-item .cred-copy {
  width: 22px;
  height: 22px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 3px;
  transition: all var(--tr-fast);
}

.cred-item .cred-copy:hover {
  color: var(--gold);
  background: var(--bg-hover);
}

.cred-item .cred-copy svg { width: 13px; height: 13px; }

/* Compact links row */
.app-links-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.link-btn-1 { background: #fef9f0; border-color: #f5e6cc; }
.link-btn-2 { background: #fdf0db; border-color: #f0d9a8; }
.link-btn-3 { background: #fae3be; border-color: #e8c885; }

.link-btn-1:hover { background: #fdf0db; }
.link-btn-2:hover { background: #fae3be; }
.link-btn-3:hover { background: #f5d494; }

.app-actions {
  display: flex;
  gap: var(--sp-2);
}

/* Copy Button */
.copy-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  transition: all var(--tr-fast);
  flex-shrink: 0;
}

.copy-btn:hover { color: var(--gold-dark); background: var(--pearl-dark); }
.copy-btn.copied { color: var(--success); }
.copy-btn svg { width: 13px; height: 13px; }

/* ============================================================
   STATUS BADGES
   ============================================================ */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: var(--fs-xs);
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 600;
  white-space: nowrap;
}

.status-badge.waiting { color: var(--status-waiting); background: #f3f4f6; }
.status-badge.submitted { color: var(--status-submitted); background: var(--info-bg); }
.status-badge.admitted-un { color: var(--status-admitted-un); background: var(--success-bg); }
.status-badge.admitted-c { color: var(--status-admitted-c); background: var(--warning-bg); }
.status-badge.terminal { color: var(--status-terminal); background: #f9fafb; }

/* Source Channel Badge (student list sidebar) */
.source-badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 3px;
  font-weight: 700;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 3px;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  font-weight: 500;
  transition: all var(--tr-fast);
  white-space: nowrap;
  border: 1px solid transparent;
  height: 34px;
}

.btn svg { width: 14px; height: 14px; }

.btn-primary {
  background: var(--gold);
  color: var(--white);
  border-color: var(--gold);
}

.btn-primary:hover {
  background: var(--gold-dark);
  border-color: var(--gold-dark);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--white);
  color: var(--text-primary);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--pearl-dark);
  border-color: var(--gold-light);
}

.btn-danger {
  background: var(--error);
  color: var(--white);
}

.btn-danger:hover { background: #dc2626; box-shadow: var(--shadow-md); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: var(--sp-1) var(--sp-2);
  height: auto;
}

.btn-ghost:hover { color: var(--gold-dark); background: var(--pearl-dark); }

.btn-sm { padding: var(--sp-1) var(--sp-3); font-size: var(--fs-sm); height: 28px; }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: var(--fs-lg); height: 42px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(26,35,50,0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--tr-normal);
}

.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(20px);
  transition: transform var(--tr-normal);
}

.modal-overlay.show .modal { transform: translateY(0); }

.modal.modal-lg { max-width: 720px; }
.modal.modal-xl { max-width: 960px; }

/* data-dynamic wrapper must be a flex column so modal-body/ modal-footer partition space */
[data-dynamic] {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  transition: all var(--tr-fast);
}

.modal-close:hover { color: var(--error); background: var(--error-bg); }
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  background: var(--pearl);
}

/* ====== Password Modal ====== */
.password-modal .modal-body {
  text-align: center;
  padding: var(--sp-8) var(--sp-6);
}

.password-modal .lock-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-4);
  color: var(--gold);
}

.password-modal h3 {
  font-size: var(--fs-xl);
  font-weight: 700;
  margin-bottom: var(--sp-2);
}

.password-modal p {
  color: var(--text-secondary);
  font-size: var(--fs-md);
  margin-bottom: var(--sp-5);
}

.password-modal input {
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
  text-align: center;
  padding: var(--sp-3);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-xl);
  letter-spacing: 4px;
  background: var(--pearl);
  transition: all var(--tr-fast);
}

.password-modal input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(197,165,114,0.1);
}

.password-error {
  color: var(--error);
  font-size: var(--fs-sm);
  margin-top: var(--sp-3);
  display: none;
}

.password-error.show { display: block; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: var(--sp-4);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}

.form-label {
  display: block;
  font-size: var(--fs-sm);
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}

.form-label .required { color: var(--error); }

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-md);
  background: var(--white);
  transition: all var(--tr-fast);
  color: var(--text-primary);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(197,165,114,0.12);
}

.form-textarea { resize: vertical; min-height: 80px; }

/* Tighter form elements inside app-card (edit modal) */
.app-card-body .form-group {
  margin-bottom: 6px;
}
.app-card-body .form-label {
  font-size: 11px;
  margin-bottom: 2px;
}
.app-card-body .form-input,
.app-card-body .form-select,
.app-card-body .form-textarea {
  padding: 5px 10px;
  font-size: 12px;
  height: 30px;
}
.app-card-body .form-textarea {
  height: auto;
  min-height: 48px;
}

.form-select { cursor: pointer; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

.form-hint {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* ====== Form section divider ====== */
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gold-dark);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-bottom: var(--sp-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
  margin-top: 10px;
}

.form-section-title:first-child { margin-top: 0; }

/* Tighter section title inside app cards */
.app-card-body .form-section-title {
  margin-top: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  border-bottom: none;
  padding-bottom: 0;
}

/* ====== Copy field (email/account/password) ====== */
.copy-field {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.copy-field .form-input { flex: 1; }

.copy-field .copy-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* ============================================================
   TABLE (Settings page)
   ============================================================ */
.data-table-wrap {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.data-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
}

.data-table-header h3 {
  font-size: var(--fs-lg);
  font-weight: 700;
}

.data-table-actions {
  display: flex;
  gap: var(--sp-2);
}

.data-table-scroll {
  overflow-x: auto;
  max-height: calc(100vh - 280px);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

.data-table th {
  position: sticky;
  top: 0;
  background: var(--pearl);
  padding: var(--sp-3) var(--sp-3);
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  z-index: 1;
}

.data-table td {
  padding: var(--sp-3);
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: top;
}

.data-table tr:hover td { background: var(--bg-hover); }

.data-table tr:last-child td { border-bottom: none; }

.data-table .action-cell {
  display: flex;
  gap: var(--sp-1);
  white-space: nowrap;
}

.table-link {
  color: var(--gold-dark);
  font-size: var(--fs-xs);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ============================================================
   TOAST
   ============================================================ */
.toast-container {
  position: fixed;
  top: var(--sp-6);
  right: var(--sp-6);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-md);
  font-weight: 500;
  background: var(--white);
  border-left: 4px solid var(--gold);
  animation: slideIn var(--tr-normal);
  max-width: 400px;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
.toast.warning { border-left-color: var(--warning); }

.toast svg { width: 18px; height: 18px; flex-shrink: 0; }
.toast.success svg { color: var(--success); }
.toast.error svg { color: var(--error); }
.toast.warning svg { color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.hide {
  animation: slideOut var(--tr-normal) forwards;
}

@keyframes slideOut {
  to { transform: translateX(120%); opacity: 0; }
}

/* ============================================================
   LOADING
   ============================================================ */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--pearl-dark);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   SETTINGS PAGE
   ============================================================ */
.settings-container {
  max-width: 1200px;
  margin: 0 auto;
}

.settings-section {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  margin-bottom: var(--sp-5);
  overflow: hidden;
}

.settings-section-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.settings-section-header h3 {
  font-size: var(--fs-lg);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.settings-section-header h3 svg { width: 18px; height: 18px; color: var(--gold); }

.settings-section-body { padding: var(--sp-5); }

/* File Upload */
.file-upload-area {
  border: 2px dashed var(--gold-light);
  border-radius: var(--radius-lg);
  padding: var(--sp-8);
  text-align: center;
  cursor: pointer;
  transition: all var(--tr-fast);
  background: var(--gold-bg);
}

.file-upload-area:hover, .file-upload-area.dragover {
  border-color: var(--gold);
  background: var(--pearl-dark);
}

.file-upload-area svg {
  width: 40px;
  height: 40px;
  color: var(--gold);
  margin-bottom: var(--sp-3);
}

.file-upload-area h4 {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--sp-1);
}

.file-upload-area p {
  font-size: var(--fs-sm);
  color: var(--text-secondary);
}

.file-upload-area input { display: none; }

/* Password Setting Card */
.password-section-body {
  display: flex;
  gap: var(--sp-4);
  flex-wrap: wrap;
  padding: var(--sp-4);
  max-height: 240px;
  overflow-y: auto;
}

.password-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 1 1 320px;
  padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--pearl);
}

.password-card .pc-info h4 {
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
}

.password-card .pc-info p {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  margin-top: 1px;
}

/* ============================================================
   CONFIRM DIALOG
   ============================================================ */
.confirm-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto var(--sp-4);
  color: var(--warning);
}

.confirm-text {
  text-align: center;
  font-size: var(--fs-md);
  color: var(--text-primary);
  line-height: 1.7;
  margin-bottom: var(--sp-2);
}

.confirm-warning {
  color: var(--error);
  font-weight: 600;
}

/* ============================================================
   UTILITY
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-gold { color: var(--gold-dark); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-width: 260px; }
  .nav-logo .brand-text { display: none; }
  .form-row { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
  .nav-center { position: static; transform: none; }
}
