/* ==========================================================================
   DESIGN VARIABLES & SYSTEM TOKENS (디자인 토큰 정의)
   ========================================================================== */
:root {
  --bg-color: #0b0f19;
  --bg-gradient: radial-gradient(circle at 50% 50%, #151d30 0%, #070a12 100%);
  --card-bg: rgba(20, 30, 54, 0.55);
  --card-border: rgba(255, 255, 255, 0.07);
  --text-color: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-color: #4f46e5; /* Indigo */
  --accent-hover: #4338ca;
  --success-color: #10b981; /* Emerald Green */
  --success-bg: rgba(16, 185, 129, 0.15);
  --danger-color: #f43f5e; /* Rose Red */
  --danger-bg: rgba(244, 63, 94, 0.15);
  --warning-color: #f59e0b; /* Amber */
  --warning-bg: rgba(245, 158, 11, 0.15);
  --shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.4);
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   GLOBAL STYLES & RESET (기본 설정)
   ========================================================================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100%;
}

body {
  font-family: var(--font-family);
  background: var(--bg-color);
  background-image: var(--bg-gradient);
  background-attachment: fixed;
  color: var(--text-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  line-height: 1.5;
}

/* 스크롤바 디자인 */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.15);
}
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   UTILITY & GLASS COMPONENTS (글래스모피즘 공통 구조)
   ========================================================================== */
.glass-container {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.glass-container:hover {
  border-color: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   AUTH PAGE & CARDS (로그인 및 회원가입 페이지)
   ========================================================================== */
.auth-page {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  padding: 40px 32px;
  animation: fadeIn 0.6s ease-out;
}

.auth-header {
  text-align: center;
  margin-bottom: 30px;
}

.logo-area {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.logo-icon {
  color: var(--success-color);
  width: 32px;
  height: 32px;
}

.auth-header h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.auth-subtitle {
  color: var(--text-muted);
  font-size: 14px;
}

.tab-buttons {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 8px;
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  transition: var(--transition);
}

.tab-btn.active {
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ==========================================================================
   INPUTS & LABELS (입력 필드 디자인)
   ========================================================================== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.input-group label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.input-group label i {
  width: 14px;
  height: 14px;
}

.input-group input,
.input-group select {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 12px 16px;
  color: #fff;
  font-size: 14px;
  transition: var(--transition);
  width: 100%;
}

.input-group select option {
  background: #151d30;
  color: #fff;
}

.input-group input:focus,
.input-group select:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

.input-help {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.readonly-input {
  background: rgba(255, 255, 255, 0.05) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}

.form-row {
  display: flex;
  gap: 16px;
}

/* ==========================================================================
   BUTTONS (버튼 디자인)
   ========================================================================== */
.submit-btn {
  background: var(--accent-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

.submit-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.submit-btn:active {
  transform: translateY(1px);
}

.submit-btn:disabled {
  background: #334155;
  color: #64748b;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.signup-btn {
  background: #1e293b;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: none;
}

.signup-btn:hover {
  background: #334155;
  border-color: rgba(255, 255, 255, 0.25);
  box-shadow: none;
}

/* ==========================================================================
   ALERT BOX (메시지 알림 상자)
   ========================================================================== */
.alert-box {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  animation: slideIn 0.3s ease-out;
  border: 1px solid transparent;
}

.alert-box.error {
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, 0.2);
  color: #fda4af;
}

.alert-box.success {
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   MAIN DASHBOARD LAYOUT (메인 대시보드 구조)
   ========================================================================== */
.main-header {
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  padding: 10px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
}

.user-control {
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-greeting {
  font-size: 14px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-greeting strong {
  color: var(--text-color);
}

.user-greeting i {
  width: 16px;
  height: 16px;
}

.logout-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.logout-btn:hover {
  background: var(--danger-bg);
  border-color: rgba(244, 63, 94, 0.3);
  color: #ff859b;
}

.logout-btn i {
  width: 14px;
  height: 14px;
}

.settings-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-color);
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.settings-btn:hover {
  background: rgba(79, 70, 229, 0.15);
  border-color: rgba(79, 70, 229, 0.3);
  color: #a5b4fc;
}

.settings-btn i {
  width: 14px;
  height: 14px;
}

.admin-btn {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
  color: #a7f3d0;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.admin-btn:hover {
  background: var(--success-bg);
  border-color: rgba(16, 185, 129, 0.4);
  color: var(--success-color);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.15);
}

.admin-btn i {
  width: 14px;
  height: 14px;
}

.admin-approve-btn {
  background: var(--success-bg);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #6ee7b7;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-right: 6px;
}

.admin-approve-btn:hover {
  background: rgba(16, 185, 129, 0.3);
  color: var(--success-color);
}

.admin-reject-btn {
  background: var(--danger-bg);
  border: 1px solid rgba(244, 63, 94, 0.3);
  color: #fda4af;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.admin-reject-btn:hover {
  background: rgba(244, 63, 94, 0.3);
  color: var(--danger-color);
}

/* 설정 탭 인터페이스 스타일 */
.settings-tabs {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  padding: 4px;
  border-radius: 8px;
  margin-top: 12px;
  margin-bottom: 20px;
}

.settings-tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition);
}

.settings-tab-btn i {
  width: 14px;
  height: 14px;
}

.settings-tab-btn.active {
  background: var(--accent-color);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

.settings-tab-btn#tab-settings-danger.active {
  background: var(--danger-color);
  box-shadow: 0 4px 12px rgba(244, 63, 94, 0.3);
}

.settings-pane {
  display: flex;
  flex-direction: column;
  animation: fadeIn 0.3s ease-out;
}

.settings-section {
  display: flex;
  flex-direction: column;
}

.settings-section h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  margin-bottom: 4px;
}

.section-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}

.dashboard-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 24px;
  max-width: 1600px;
  margin: 0 auto;
  width: 100%;
  animation: fadeIn 0.8s ease-out;
}

/* ==========================================================================
   KPI DASHBOARD & CARDS (상단 3열 요약 대시보드)
   ========================================================================== */
.kpi-dashboard {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  width: 100%;
}

.kpi-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  position: relative;
  overflow: hidden;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.kpi-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

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

.kpi-value-wrapper {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 8px;
}

.kpi-val {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.kpi-val.highlight {
  font-size: 22px;
  background: linear-gradient(135deg, #fff 0%, #cbd5e1 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* 손익 & 수익률 정렬용 */
.profit-loss-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.kpi-badge {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.kpi-badge.up {
  background: var(--success-bg);
  color: var(--success-color);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.kpi-badge.down {
  background: var(--danger-bg);
  color: var(--danger-color);
  border: 1px solid rgba(244, 63, 94, 0.2);
}

.kpi-badge.zero {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Live Pulse Dot */
.live-pulse-dot {
  width: 10px;
  height: 10px;
  background: var(--success-color);
  border-radius: 50%;
  position: relative;
  display: inline-block;
  align-self: center;
  box-shadow: 0 0 8px var(--success-color);
  transition: var(--transition);
}

.live-pulse-dot::after {
  content: '';
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  background: var(--success-color);
  border-radius: 50%;
  transform: scale(1);
  animation: pulse-ring 2.2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}

@keyframes pulse-ring {
  0% {
    transform: scale(0.6);
    opacity: 0.9;
  }
  80%, 100% {
    transform: scale(3.5);
    opacity: 0;
  }
}

/* 시세 갱신 섬광(Flash) 효과 */
.live-pulse-dot.flash, .live-indicator .dot.flash {
  animation: pulse-flash 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes pulse-flash {
  0% {
    transform: scale(1.2);
    box-shadow: 0 0 30px 15px var(--success-color);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 8px var(--success-color);
  }
}

/* 하단 메인 콘텐츠 그리드 (기존 2컬럼 레이아웃 복원) */
.main-content-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  align-items: stretch;
  width: 100%;
}

/* 차트 카드 고도화 */
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
}

.chart-header h3 {
  margin: 0 !important;
}

.chart-top-asset {
  font-size: 11px;
  font-weight: 700;
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.2) 0%, rgba(6, 182, 212, 0.2) 100%);
  color: #818cf8;
  border: 1px solid rgba(129, 140, 248, 0.3);
  padding: 4px 10px;
  border-radius: 20px;
  letter-spacing: -0.2px;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.1);
}

.chart-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none; /* 마우스 인터랙션을 캔버스로 패스 */
  z-index: 5;
  text-align: center;
  margin-top: -12px; /* 라벨 패딩 높이 보정 */
}

.chart-center-text .center-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}

.chart-center-text .center-value {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-color);
  letter-spacing: -0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 150px;
}

/* 모바일 등 반응형 미디어 쿼리 */
@media (max-width: 1024px) {
  .kpi-dashboard {
    grid-template-columns: 1fr;
  }
  .main-content-grid {
    grid-template-columns: 1fr;
  }
}

.left-section {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.chart-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.chart-wrapper {
  position: relative;
  width: 100%;
  height: 260px;
  min-height: 200px;
  display: block;
}

.chart-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  gap: 12px;
  width: 100%;
  height: 100%;
}

.placeholder-icon {
  width: 48px;
  height: 48px;
  color: rgba(255, 255, 255, 0.08);
}

.chart-placeholder p {
  font-size: 13px;
  line-height: 1.5;
}

/* ==========================================================================
   RIGHT SECTION: STOCKS TABLE (우측 섹션)
   ========================================================================== */
.stocks-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
}

.stocks-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.stocks-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stocks-title-area h3 {
  margin: 0;
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--success-color);
  background: var(--success-bg);
  padding: 3px 8px;
  border-radius: 20px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.live-indicator .dot {
  width: 6px;
  height: 6px;
  background: var(--success-color);
  border-radius: 50%;
  animation: pulse 1.6s infinite;
}

.live-indicator.manual {
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.05);
}

.live-indicator.manual .dot {
  background: var(--text-muted);
  animation: none;
}

.action-buttons {
  display: flex;
  gap: 10px;
}

.refresh-interval-select {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  padding: 0 12px;
  height: 38px;
  border-radius: 8px;
  font-family: var(--font-family);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  outline: none;
}

.refresh-interval-select:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-color);
}

.refresh-interval-select option {
  background: #151d30;
  color: #fff;
}

.refresh-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.refresh-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
}

.refresh-btn i {
  width: 16px;
  height: 16px;
}

.refresh-btn.spinning i {
  animation: spin 0.8s linear infinite;
}

.add-stock-btn {
  background: var(--accent-color);
  color: #fff;
  border: none;
  padding: 0 16px;
  height: 38px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
}

.add-stock-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.add-stock-btn i {
  width: 16px;
  height: 16px;
}

/* 테이블 구조 */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.stocks-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.stocks-table th {
  color: var(--text-muted);
  font-weight: 500;
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stocks-table td {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  vertical-align: middle;
}

.stocks-table tbody tr {
  transition: var(--transition);
}

.stocks-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

.stock-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stock-name {
  font-weight: 600;
  color: var(--text-color);
}

.stock-symbol {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px !important;
  color: var(--text-muted);
}

.empty-state i {
  width: 48px;
  height: 48px;
  stroke-width: 1.5;
  margin-bottom: 16px;
  color: rgba(255, 255, 255, 0.1);
}

.empty-state p {
  font-size: 13px;
}

/* 색상 코딩 */
.value-up {
  color: var(--success-color) !important;
}

.value-down {
  color: var(--danger-color) !important;
}

.value-zero {
  color: var(--text-color) !important;
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}

.badge.up {
  background: var(--success-bg);
  color: var(--success-color);
}

.badge.down {
  background: var(--danger-bg);
  color: var(--danger-color);
}

.badge.zero {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
}

/* 액션 컬럼 */
.actions-cell {
  display: flex;
  gap: 8px;
}

.stocks-table th:last-child,
.stocks-table td:last-child {
  text-align: center;
}

.stocks-table td:last-child .actions-cell {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto;
  width: max-content;
}

.row-edit-btn, .row-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.row-edit-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
}

.row-delete-btn:hover {
  background: var(--danger-bg);
  color: #ff859b;
}

.row-edit-btn i, .row-delete-btn i {
  width: 15px;
  height: 15px;
}

/* ==========================================================================
   MODAL DIALOG OVERLAY (모달 윈도우 스타일)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(5, 8, 16, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  animation: fadeIn 0.3s ease-out;
}

.modal-content {
  width: 100%;
  max-width: 460px;
  padding: 30px;
  animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.modal-header h2 i {
  width: 20px;
  height: 20px;
  color: var(--accent-color);
}

.close-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 24px;
}

.cancel-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-color);
  padding: 10px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.cancel-btn:hover {
  background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   ANIMATIONS & KEYFRAMES (애니메이션 효과)
   ========================================================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

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

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* 로딩 스피너 */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

/* ==========================================================================
   RESPONSIVE DESIGN (반응형 화면 분기점)
   ========================================================================== */
@media (max-width: 1024px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
    padding: 20px;
  }
  
  .left-section {
    flex-direction: row;
  }
  
  .summary-card, .chart-card {
    flex: 1;
  }
}

@media (max-width: 768px) {
  .main-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px 12px;
  }
  
  .user-control {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .user-greeting {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100% - 90px);
  }

  .admin-btn span,
  .settings-btn span,
  .logout-btn span {
    display: none;
  }
  
  .admin-btn,
  .settings-btn,
  .logout-btn {
    padding: 8px !important;
    width: 36px;
    height: 36px;
    justify-content: center;
    flex-shrink: 0;
  }
  
  .dashboard-layout {
    padding: 16px 12px;
    gap: 16px;
    grid-template-columns: 1fr;
  }
  
  .left-section {
    flex-direction: column;
    gap: 16px;
    width: 100%;
  }

  .right-section {
    width: 100%;
    min-width: 0;
  }

  .summary-card, .chart-card, .stocks-card {
    padding: 16px;
  }
  
  .summary-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .chart-card {
    height: 340px;
  }

  .chart-wrapper {
    height: 220px;
    min-height: auto;
    display: block;
  }

  .stocks-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .stocks-header .action-buttons {
    width: 100%;
    justify-content: flex-end;
  }

  .modal-content {
    width: 95% !important;
    padding: 20px 16px !important;
  }

  .form-row {
    flex-direction: column;
    gap: 16px;
  }

  .stocks-table, 
  .stocks-table thead, 
  .stocks-table tbody, 
  .stocks-table th, 
  .stocks-table td, 
  .stocks-table tr {
    display: block;
  }
  
  .stocks-table thead {
    display: none; /* 헤더 숨기기 */
  }

  .stocks-table tbody tr {
    display: grid;
    grid-template-columns: 1.2fr 1fr auto;
    gap: 2px 10px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  }

  .stocks-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.04);
  }

  .stocks-table td {
    display: flex;
    flex-direction: row; /* 라벨과 값을 한 줄에 표시 */
    align-items: center;
    padding: 0 !important;
    border-bottom: none !important;
    font-size: 11px !important;
    text-align: left;
    height: 18px;
  }

  /* 1. 계좌 - Row 2, Col 1 */
  .stocks-table td:nth-child(1) {
    grid-column: 1;
    grid-row: 2;
  }
  .stocks-table td:nth-child(1) .badge {
    padding: 2px 6px !important;
    font-size: 10px !important;
  }

  /* 2. 종목명 - Row 1, Col 1 */
  .stocks-table td:nth-child(2) {
    grid-column: 1;
    grid-row: 1;
    font-size: 12px !important;
    height: 20px;
  }
  .stocks-table td:nth-child(2) .stock-info {
    text-align: left;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
  }
  .stocks-table td:nth-child(2) .stock-name {
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px; /* 1.2fr 영역 크기를 감안해 텍스트 오버플로우 방지 */
    display: block;
  }
  .stocks-table td:nth-child(2) .stock-symbol {
    font-size: 10px;
    color: var(--text-muted);
  }

  /* 3. 평단가 - Row 4, Col 1 */
  .stocks-table td:nth-child(3) {
    grid-column: 1;
    grid-row: 4;
  }

  /* 4. 현재가 - Row 4, Col 2 */
  .stocks-table td:nth-child(4) {
    grid-column: 2;
    grid-row: 4;
    align-items: center;
    justify-content: flex-end;
  }

  /* 5. 보유 수량 - Row 3, Col 1 */
  .stocks-table td:nth-child(5) {
    grid-column: 1;
    grid-row: 3;
  }

  /* 6. 평가 금액 - Row 1, Col 2 */
  .stocks-table td:nth-child(6) {
    grid-column: 2;
    grid-row: 1;
    align-items: center;
    justify-content: flex-end;
    font-size: 12px !important;
    height: 20px;
  }

  .stocks-table td:nth-child(2),
  .stocks-table td:nth-child(6) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    padding-bottom: 4px !important;
    margin-bottom: 4px;
    height: auto !important;
  }

  /* 7. 평가 손익 - Row 3, Col 2 */
  .stocks-table td:nth-child(7) {
    grid-column: 2;
    grid-row: 3;
    align-items: center;
    justify-content: flex-end;
  }

  /* 8. 수익률 - Row 2, Col 2 */
  .stocks-table td:nth-child(8) {
    grid-column: 2;
    grid-row: 2;
    align-items: center;
    justify-content: flex-end;
  }

  /* 9. 관리 - 맨 우측 세로 중앙 배치 (전체 행에 걸침) */
  .stocks-table td:nth-child(9) {
    grid-column: 3;
    grid-row: 1 / span 4;
    align-self: center;
    justify-self: center; /* 그리드 셀 내에서 수평 중앙 정렬 */
    height: 100%;
    margin-left: 8px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-bottom: none !important;
  }
  .stocks-table td:nth-child(9) .actions-cell {
    display: flex !important;
    flex-direction: column !important; /* 세로 배치 */
    gap: 8px !important; /* 간격 확대 */
    justify-content: center !important;
    align-items: center !important; /* 수평 정렬 */
    width: auto !important;
    height: auto !important;
    margin: 0 auto !important;
  }
  .stocks-table td:nth-child(9) .row-edit-btn,
  .stocks-table td:nth-child(9) .row-delete-btn {
    width: 26px;
    height: 26px;
    border-radius: 4px;
  }

  .stocks-table td::before {
    content: attr(data-label) ": ";
    font-weight: 500;
    color: var(--text-muted);
    font-size: 9px;
    margin-right: 4px;
  }

  /* 불필요한 라벨 제거 */
  .stocks-table td:nth-child(1)::before,
  .stocks-table td:nth-child(2)::before,
  .stocks-table td:nth-child(6)::before,
  .stocks-table td:nth-child(9)::before {
    display: none;
  }

  .stocks-table td .stock-info {
    text-align: right;
  }

  .stocks-table td .actions-cell {
    justify-content: flex-end;
  }

  /* 빈 상태 예외 처리 */
  .stocks-table td.empty-state {
    display: block;
    grid-column: 1 / span 2;
    text-align: center;
    padding: 40px 0 !important;
    border: none;
  }

  .stocks-table td.empty-state::before {
    display: none;
  }
  
  .live-indicator {
    font-size: 10px;
  }

  .last-updated {
    display: block;
    margin-left: 0;
    margin-top: 4px;
  }
}

/* ==========================================================================
   INTEGRATED CURRENCY TOGGLE STYLES (통합 통화 토글)
   ========================================================================== */
.summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  width: 100%;
}

.summary-header h3 {
  margin-bottom: 0 !important;
}

.currency-toggle {
  display: flex;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.currency-toggle-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-family);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
}

.currency-toggle-btn.active {
  background: var(--accent-color);
  color: var(--text-color);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.4);
}

.currency-toggle-btn:hover:not(.active) {
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.05);
}

/* ==========================================================================
   UI IMPROVEMENTS (갱신 표시 및 에러 알림 아이콘)
   ========================================================================== */
.last-updated {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: 8px;
  font-weight: normal;
}

.price-error-container {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--warning-color);
  cursor: help;
}

.price-error-icon {
  width: 14px;
  height: 14px;
  stroke: var(--warning-color);
  stroke-width: 2.5;
  display: inline-block;
  vertical-align: middle;
}
/* ==========================================================================
   ACCOUNT TABS STYLES (계좌별 탭 분류 및 관리)
   ========================================================================== */
.account-tabs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  margin-bottom: 20px;
  overflow-x: auto;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  width: 100%;
}

.account-tabs::-webkit-scrollbar {
  height: 4px;
}

.tab-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-item.active {
  background: var(--accent-color);
  color: var(--text-color);
  border-color: var(--accent-color);
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.3);
}

.tab-item:hover:not(.active) {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-color);
}

.tab-edit-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: var(--transition);
}

.tab-edit-btn:hover {
  color: var(--text-color);
  background: rgba(255, 255, 255, 0.1);
}

.tab-edit-btn i {
  width: 12px;
  height: 12px;
}

/* ==========================================================================
   SEARCH DROPDOWN STYLES (종목 검색 자동완성 스타일)
   ========================================================================== */
.search-group {
  position: relative;
}

.search-results-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 300;
  margin-top: 4px;
  box-shadow: var(--shadow);
}

.search-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  transition: var(--transition);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.search-result-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.search-result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-color);
  text-align: left;
}

.search-result-symbol {
  font-size: 11px;
  color: var(--text-muted);
  text-align: left;
}

.search-result-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.search-result-exch {
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.search-result-type {
  font-size: 10px;
  color: var(--success-color);
  background: var(--success-bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
}

/* ==========================================================================
   REMEMBER ME CHECKBOX STYLES (자동 로그인 체크박스 스타일)
   ========================================================================== */
.remember-me-group {
  display: flex;
  align-items: center;
  margin-top: -6px;
  margin-bottom: 4px;
}

.remember-me-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.remember-me-label:hover {
  color: var(--text-color);
}

.remember-me-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-color);
  cursor: pointer;
}

/* 매수 평단가 통화 단위 표시 */
.currency-prefix-label {
  display: inline-block !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  padding: 2px 8px !important;
  border-radius: 6px !important;
  margin-left: 6px !important;
  vertical-align: middle !important;
  background: rgba(99, 102, 241, 0.25) !important;
  color: #c4b5fd !important;
  border: 1px solid rgba(99, 102, 241, 0.6) !important;
  letter-spacing: 0.05em !important;
  transition: all 0.2s !important;
  white-space: nowrap !important;
}

.currency-prefix-label.krw {
  background: rgba(16, 185, 129, 0.25) !important;
  border-color: rgba(16, 185, 129, 0.6) !important;
  color: #6ee7b7 !important;
}

.currency-prefix-label.usd {
  background: rgba(59, 130, 246, 0.25) !important;
  border-color: rgba(59, 130, 246, 0.6) !important;
  color: #93c5fd !important;
}

/* ==========================================================================
   LIVE PRICE PULSE ANIMATIONS (시세 변동 펄스 애니메이션)
   ========================================================================== */
.price-up-pulse {
  animation: price-up-flash 0.8s ease-out;
}
.price-down-pulse {
  animation: price-down-flash 0.8s ease-out;
}

@keyframes price-up-flash {
  0% {
    color: #34d399;
    text-shadow: 0 0 10px rgba(52, 211, 153, 0.6);
    transform: scale(1.05);
  }
  100% {
    color: inherit;
    text-shadow: none;
    transform: scale(1);
  }
}

@keyframes price-down-flash {
  0% {
    color: #fb7185;
    text-shadow: 0 0 10px rgba(251, 113, 133, 0.6);
    transform: scale(1.05);
  }
  100% {
    color: inherit;
    text-shadow: none;
    transform: scale(1);
  }
}

/* ==========================================================================
   TABLE SORTING INTERFACE (테이블 헤더 정렬 스타일)
   ========================================================================== */
.stocks-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}
.stocks-table th.sortable:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-color);
}
.stocks-table th.sortable::after {
  content: ' ↕';
  font-size: 10px;
  color: rgba(255, 255, 255, 0.2);
  vertical-align: middle;
}
.stocks-table th.sortable.asc::after {
  content: ' ▲';
  color: var(--success-color);
}
.stocks-table th.sortable.desc::after {
  content: ' ▼';
  color: var(--danger-color);
}

/* ==========================================================================
   MOBILE COMPACT CAROUSEL & BOTTOM SHEET (모바일 전용 고도화)
   ========================================================================== */
@media (max-width: 768px) {
  /* KPI 카드 모바일 3열 그리드 배치 (한 화면에 다 보여주기) */
  .hide-mobile {
    display: none !important;
  }

  .kpi-dashboard {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 10px !important;
    padding: 0 !important;
    width: 100% !important;
  }
  
  .kpi-dashboard .kpi-card {
    padding: 14px 12px !important;
    border-radius: 12px !important;
    min-height: 90px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: space-between !important;
    gap: 6px !important;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2) !important;
  }

  .kpi-dashboard .kpi-card:first-child {
    grid-column: span 2 !important;
  }

  .kpi-dashboard .kpi-header {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .kpi-dashboard .kpi-card:not(:first-child) .kpi-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }

  .kpi-dashboard .kpi-label {
    font-size: 11px !important;
    letter-spacing: -0.2px !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
  }

  .kpi-dashboard .currency-toggle {
    padding: 2px !important;
    border-radius: 6px !important;
  }

  .kpi-dashboard .currency-toggle-btn {
    padding: 3px 6px !important;
    font-size: 10px !important;
    border-radius: 4px !important;
  }

  .kpi-dashboard .kpi-card:first-child .kpi-value-wrapper {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 8px !important;
    width: 100% !important;
  }

  .kpi-dashboard .kpi-card:not(:first-child) .kpi-value-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    justify-content: flex-start !important;
    gap: 4px !important;
    width: 100% !important;
  }

  .kpi-dashboard .kpi-val {
    font-size: 13px !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
  }

  .kpi-dashboard .kpi-val.highlight {
    font-size: 18px !important;
  }

  .kpi-dashboard .profit-loss-wrapper {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 4px !important;
  }

  .kpi-dashboard .kpi-badge {
    padding: 3px 6px !important;
    font-size: 10px !important;
    border-radius: 4px !important;
    white-space: nowrap !important;
  }

  .kpi-dashboard .live-pulse-dot {
    width: 8px !important;
    height: 8px !important;
    margin-top: 0 !important;
  }

  /* 모바일 바텀 시트 모달 */
  .modal-overlay {
    align-items: flex-end;
    background: rgba(5, 8, 16, 0.6);
  }
  .modal-content {
    width: 100% !important;
    max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    border-bottom: none !important;
    padding: 24px 20px 32px 20px !important;
    animation: slideUp 0.35s cubic-bezier(0.25, 1, 0.5, 1) !important;
    box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  }
  @keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }
}

/* 계정 분실 링크 호버 효과 */
.forgot-link:hover {
  color: var(--accent-color) !important;
  text-decoration: underline !important;
}
