@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ********** LOGIN STYLES ********** */
.login-wrapper {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(circle at top right, var(--bg-gradient-end), var(--bg-base));
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-box {
  background: var(--bg-panel);
  width: 100%;
  max-width: 380px;
  padding: 40px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--panel-shadow-hover);
  border: 1px solid var(--border-color);
  animation: slideUp var(--transition-smooth);
}
.login-header {
  text-align: center;
  margin-bottom: 30px;
}
.login-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--accent-blue);
  margin-bottom: 6px;
}

.login-header .brand-logo {
  font-size: 32px !important;
  margin-bottom: 8px;
}
.login-header p {
  color: var(--text-muted);
  font-size: 13px;
}

/* ********** GLOBAL VARIABLES ********** */
:root {
  /* Green Theme (Default Ultron) */
  --bg-base: #0d1b14;
  --bg-panel: #15291f;
  --bg-panel-hover: #1a3326;
  --bg-gradient-end: #0a140f;
  
  --text-primary: #e0f2e9;
  --text-secondary: #81c784;
  --text-muted: #4caf50;
  
  --accent-main: #4caf50;
  --accent-main-glow: rgba(76, 175, 80, 0.2);
  
  --accent-green: #4caf50;
  --accent-green-glow: rgba(76, 175, 80, 0.2);
  --accent-red: #f44336;
  --accent-red-glow: rgba(244, 67, 54, 0.2);
  --accent-blue: var(--accent-main);
  --accent-blue-glow: var(--accent-main-glow);
  --accent-gold: #f59e0b;
  
  --border-color: #2e523e;
  
  --sidebar-width: 280px;
  --border-radius-sm: 12px;
  --border-radius-md: 24px;
  --border-radius-lg: 32px;
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 0.4s cubic-bezier(0.16, 1, 0.3, 1);

  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --panel-shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.7);
  --row-bg: rgba(0, 0, 0, 0.2);
  --row-bg-hover: rgba(255, 255, 255, 0.05);
  --log-bg: #0d1b14;
  --status-card-bg: #15291f;
}

[data-theme="red"] {
  --bg-base: #1b0d0d;
  --bg-panel: #291515;
  --bg-panel-hover: #331a1a;
  --bg-gradient-end: #140a0a;
  --text-primary: #f2e0e0;
  --text-secondary: #e57373;
  --text-muted: #f44336;
  --accent-main: #f44336;
  --accent-main-glow: rgba(244, 67, 54, 0.2);
  --accent-blue: var(--accent-main);
  --accent-blue-glow: var(--accent-main-glow);
  --border-color: #522e2e;
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --panel-shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.7);
  --row-bg: rgba(0, 0, 0, 0.2);
  --row-bg-hover: rgba(255, 255, 255, 0.05);
  --log-bg: #1b0d0d;
  --status-card-bg: #291515;
}

[data-theme="dark"] {
  --bg-base: #0f172a;
  --bg-panel: #1e293b;
  --bg-panel-hover: #334155;
  --bg-gradient-end: #020617;
  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;
  --accent-main: #3b82f6;
  --accent-main-glow: rgba(59, 130, 246, 0.2);
  --accent-blue: var(--accent-main);
  --accent-blue-glow: var(--accent-main-glow);
  --border-color: #334155;
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --panel-shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.7);
  --row-bg: rgba(0, 0, 0, 0.2);
  --row-bg-hover: rgba(255, 255, 255, 0.05);
  --log-bg: #0f172a;
  --status-card-bg: #1e293b;
}

[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-panel: #ffffff;
  --bg-panel-hover: #f1f5f9;
  --bg-gradient-end: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --accent-main: #3b82f6;
  --accent-main-glow: rgba(59, 130, 246, 0.2);
  --accent-blue: var(--accent-main);
  --accent-blue-glow: var(--accent-main-glow);
  --border-color: #e2e8f0;
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
  --panel-shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.1);
  --row-bg: rgba(0, 0, 0, 0.02);
  --row-bg-hover: #f1f5f9;
  --log-bg: #f8fafc;
  --status-card-bg: #ffffff;
}

[data-theme="ocean"] {
  --bg-base: #08111a;
  --bg-panel: #0d1e30;
  --bg-panel-hover: #132a42;
  --bg-gradient-end: #04090d;
  --text-primary: #e0f2fe;
  --text-secondary: #38bdf8;
  --text-muted: #0284c7;
  --accent-main: #0ea5e9;
  --accent-main-glow: rgba(14, 165, 233, 0.2);
  --accent-blue: var(--accent-main);
  --accent-blue-glow: var(--accent-main-glow);
  --border-color: #1e3a5f;
  --panel-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  --panel-shadow-hover: 0 15px 40px rgba(0, 0, 0, 0.8);
  --row-bg: rgba(14, 165, 233, 0.05);
  --row-bg-hover: rgba(14, 165, 233, 0.1);
  --log-bg: #08111a;
  --status-card-bg: #0d1e30;
}

[data-theme="breeze"] {
  --bg-base: #f0f9ff;
  --bg-panel: #ffffff;
  --bg-panel-hover: #f8fafc;
  --bg-gradient-end: #e0f2fe;
  --text-primary: #0369a1;
  --text-secondary: #0284c7;
  --text-muted: #7dd3fc;
  --accent-main: #0ea5e9;
  --accent-main-glow: rgba(14, 165, 233, 0.2);
  --accent-blue: var(--accent-main);
  --accent-blue-glow: var(--accent-main-glow);
  --border-color: #bae6fd;
  --panel-shadow: 0 10px 30px rgba(2, 132, 199, 0.08);
  --panel-shadow-hover: 0 15px 40px rgba(2, 132, 199, 0.12);
  --row-bg: rgba(14, 165, 233, 0.03);
  --row-bg-hover: rgba(14, 165, 233, 0.08);
  --log-bg: #f0f9ff;
  --status-card-bg: #ffffff;
}

/* ********** RESET & BASE ********** */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Google Sans', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-weight: 600;
  color: var(--text-primary);
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-base);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ********** LAYOUT ********** */
.app-wrapper {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ********** SIDEBAR ********** */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-panel);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.2);
}

.sidebar-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-color);
}



.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 20px 0;
}

.sidebar-nav ul {
  list-style: none;
}

.mobile-menu-toggle {
  display: flex;
}

.sidebar {
  transition: width var(--transition-smooth);
  overflow-x: hidden;
}

.sidebar.collapsed {
  width: 0;
  border-right: none;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 999;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity var(--transition-fast);
}
.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 14px 24px;
  margin: 4px 12px;
  border-radius: var(--border-radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 16px;
  font-weight: 500;
}

.nav-item i {
  font-size: 18px;
  width: 20px;
  text-align: center;
}

.nav-item:hover {
  background-color: var(--bg-panel-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background-color: var(--accent-blue-glow);
  color: var(--accent-blue);
  box-shadow: inset 3px 0 0 var(--accent-blue);
}

.sidebar-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-base);
}

.system-status {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--accent-green);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 10px var(--accent-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(14, 203, 129, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(14, 203, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(14, 203, 129, 0); }
}

/* ********** MAIN CONTENT ********** */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  position: relative;
  background: radial-gradient(circle at top right, var(--bg-gradient-end), var(--bg-base));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 40px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
  border-bottom: 1px solid transparent;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.wallet-balance {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  margin-right: 12px;
}

.wallet-balance .balance-label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wallet-balance .balance-value {
  font-size: 16px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-primary);
}

.profile-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  margin-left: 8px;
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.title-container {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title-container h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-logo {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-weight: 800 !important;
  font-size: 26px !important;
  letter-spacing: 0px !important;
  color: var(--text-primary) !important;
  text-transform: uppercase;
}

.brand-logo span {
  color: #69f0ae !important;
}

.title-container .subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-blue);
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--accent-blue-glow);
  padding: 4px 8px;
  border-radius: 4px;
  align-self: flex-start;
}

.btn-icon {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-size: 18px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

.btn-icon:hover {
  color: var(--accent-main);
  border-color: var(--accent-main);
  background: var(--accent-main-glow);
  transform: translateY(-2px);
}

.view-toggles .btn-icon.active {
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.card-container {
  max-height: none !important;
  height: auto !important;
  overflow-y: visible !important;
  flex: none !important;
}
.card-container::-webkit-scrollbar {
  width: 6px;
}
.card-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

/* ********** TABLE PAGINATION & CONTROLS ********** */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: color var(--transition-fast);
}
th.sortable:hover {
  color: var(--accent-blue);
}
.sort-icon {
  display: inline-block;
  margin-left: 6px;
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.3;
}
th.sortable:not(.asc):not(.desc) .sort-icon::before {
  content: "\f0dc";
}
th.sortable.asc .sort-icon::before {
  content: "\f0de";
  opacity: 1;
  color: var(--accent-blue);
}
th.sortable.desc .sort-icon::before {
  content: "\f0dd";
  opacity: 1;
  color: var(--accent-blue);
}

.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.table-pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding-right: 8px;
}
.page-btn {
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.page-btn:hover:not(:disabled) {
  background: var(--bg-panel-hover);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}
.page-btn.active {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
  box-shadow: 0 2px 8px var(--accent-blue-glow);
}
.page-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ********** DASHBOARD GRID ********** */
.dash-panel {
  cursor: grab;
  aspect-ratio: 1 / 1;
  overflow: hidden;
}

.dash-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.dash-content div[id^="desc-"] {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.dragging-panel {
  transform: scale(0.98);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5) !important;
  z-index: 100;
  transition: none !important;
}

.panel button, .panel input, .panel select, .panel a, .panel .data-table, .panel .vertical-scroll-container, .panel .log-container {
  cursor: auto;
}

.vertical-scroll-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  height: 0; /* 강제 높이 제한으로 내부 콘텐츠가 부모 영역을 뚫고 나가는 것을 원천 차단 */
  padding-right: 4px;
  margin-top: 12px;
}
.vertical-scroll-container::-webkit-scrollbar {
  width: 4px;
}
.vertical-scroll-container::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}
.vertical-scroll-item {
  background: var(--row-bg);
  padding: 10px 12px;
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color);
  font-size: 12px;
  line-height: 1.5;
  word-break: keep-all;
}

.dashboard-grid {
  padding: 24px 40px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  grid-auto-flow: dense;
  gap: 24px;
  animation: slideUp var(--transition-smooth);
}

/* 모바일이 아닌 환경에서 대시보드 위젯 리사이징 지원 */
@media (min-width: 1025px) {
  .dash-panel {
    resize: both;
    min-width: 380px;
    min-height: 380px;
  }
}

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

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  padding: 24px;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--panel-shadow);
}

.panel:hover {
  transform: translateY(-2px);
  box-shadow: var(--panel-shadow-hover);
  border-color: var(--accent-blue);
}

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

.panel-title-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
}

.panel-icon {
  font-size: 20px;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
}

.panel-header h2 {
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
}

.panel-header h2 i {
  color: var(--accent-blue);
}

.badge {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.badge { background: rgba(255,255,255,0.05); color: var(--text-secondary); }
.badge.ai { background: var(--accent-blue-glow); color: var(--accent-blue); }
.badge.success { background: var(--accent-green-glow); color: var(--accent-green); border: 1px solid rgba(14,203,129,0.3); }

/* ********** ISSUE MONITORING PANEL ********** */
.issue-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn-secondary {
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-secondary:hover {
  background: var(--bg-panel-hover);
  color: var(--accent-blue);
  border-color: var(--accent-blue);
}

.issue-input-area {
  display: flex;
  gap: 12px;
}

.form-input {
  flex: 1;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition-fast);
}
.form-input:focus {
  border-color: var(--accent-blue);
}

.table-container {
  width: 100%;
  overflow-x: auto;
  overflow-y: visible !important;
  max-height: none !important;
  height: auto !important;
  flex: none !important;
  -webkit-overflow-scrolling: touch;
}
.table-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.data-table {
  width: 100%;
  min-width: max-content; /* 테이블 내용이 길면 늘어나도록 설정 */
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap; /* 원본 형태 유지를 위해 줄바꿈 방지 */
}
.data-table.layout-fixed {
  table-layout: fixed;
}
.data-table.layout-fixed td:not([colspan]) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.data-table th, .data-table td {
  padding: 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}
.data-table th {
  background: var(--bg-base);
  color: var(--text-muted);
  font-weight: 600;
  position: sticky;
  top: 0;
}
.data-table tbody tr {
  cursor: pointer;
  transition: background var(--transition-fast);
}
.data-table tbody tr:hover {
  background: var(--row-bg-hover);
}

/* Table Column Resizer */
th.resizable {
  position: relative;
}
.resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 8px;
  height: 100%;
  cursor: col-resize;
  user-select: none;
  z-index: 10;
  background-color: transparent;
  transition: background-color var(--transition-fast);
}
.resizer:hover, .resizer.resizing {
  background-color: var(--accent-blue);
  opacity: 0.7;
}

/* 가로 스크롤 시 첫 열(체크박스) 및 종목명 고정 기능 */
.data-table.sticky-cols th:nth-child(1),
.data-table.sticky-cols tbody td:nth-child(1):not([colspan]) {
  position: sticky;
  left: 0;
  z-index: 2;
  background-color: var(--bg-panel);
  width: 40px !important;
  min-width: 40px !important;
  max-width: 40px !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  box-sizing: border-box;
}

.data-table.sticky-cols th:nth-child(2),
.data-table.sticky-cols tbody td:nth-child(2):not([colspan]) {
  position: sticky;
  left: 40px;
  z-index: 2;
  background-color: var(--bg-panel);
  border-right: 2px solid var(--border-color);
}

.data-table.sticky-cols th:nth-child(1),
.data-table.sticky-cols th:nth-child(2) {
  z-index: 3;
  background-color: var(--bg-base);
}

.data-table.sticky-cols tbody tr:hover td:nth-child(1):not([colspan]),
.data-table.sticky-cols tbody tr:hover td:nth-child(2):not([colspan]) {
  background-color: var(--bg-panel-hover);
}

.text-center { text-align: center; }

.line-clamp-2 {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  white-space: normal !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  line-height: 1.5;
  max-height: 3em;
}

/* ********** MARKET DATA PANEL ********** */
.data-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  background: var(--row-bg);
  border-radius: var(--border-radius-sm);
  border: 1px solid transparent;
  transition: all var(--transition-fast);
}

.data-row:hover {
  background: var(--row-bg-hover);
  border-color: var(--border-color);
}

.asset-name {
  font-weight: 500;
  font-size: 14px;
}

.asset-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.asset-value.up { color: var(--accent-green); }
.asset-value.down { color: var(--accent-red); }

/* ********** AI LOGS PANEL ********** */
.log-container {
  flex: 1;
  min-height: 0;
  max-height: none !important;
  overflow-y: auto !important;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 8px;
}

.log-entry {
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  padding: 12px;
  background: var(--log-bg);
  border-radius: var(--border-radius-sm);
  border-left: 3px solid var(--border-color);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  word-break: break-word;
}

.log-entry.buy { border-left-color: var(--accent-green); }
.log-entry.sell { border-left-color: var(--accent-red); }
.log-entry.scan { border-left-color: var(--accent-blue); }

.log-time {
  color: var(--text-muted);
  white-space: nowrap;
}

.log-action {
  font-weight: 700;
  width: 45px;
}

.log-entry.buy .log-action { color: var(--accent-green); }
.log-entry.sell .log-action { color: var(--accent-red); }
.log-entry.scan .log-action { color: var(--accent-blue); }

.log-desc {
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ********** TRADING STATUS PANEL ********** */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-right: 4px;
}
.status-grid::-webkit-scrollbar {
  width: 4px;
}
.status-grid::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 10px;
}

.status-card {
  background: var(--status-card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 8px;
  transition: border-color var(--transition-fast);
}

.status-card:hover {
  border-color: var(--accent-blue);
}

.status-label {
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status-value {
  font-size: 22px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
}

.status-value.profit { color: var(--accent-green); text-shadow: 0 0 15px var(--accent-green-glow); }
.status-value.neutral { color: var(--text-primary); }
.status-value.highlight { color: var(--accent-gold); text-shadow: 0 0 15px rgba(243, 186, 47, 0.2); }

/* ********** SETTINGS MODAL ********** */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: none; /* Hidden by default */
  justify-content: center;
  align-items: center;
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

.modal-overlay.active {
  display: flex;
  opacity: 1;
}

.modal-window {
  background: var(--bg-panel);
  width: 100%;
  max-width: 480px;
  height: auto;
  max-height: 85vh;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  transform: scale(0.95);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
}

#settings-modal .modal-window {
  max-width: 960px;
  height: 85vh; /* 시스템 설정창은 탭 전환 시 높이 유지를 위해 고정 */
}

.modal-overlay.active .modal-window {
  transform: scale(1);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

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

.modal-title .modal-icon {
  font-size: 20px;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
}

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

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  transition: color var(--transition-fast);
}

.btn-close:hover {
  color: var(--accent-red);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1; /* 스크롤 유지 영역으로 확장 */
}

/* 모달창(상세보기) 내에서는 말줄임(line-clamp) 강제 해제하여 전체 텍스트 표시 */
.modal-body .line-clamp-2,
.modal-body div[style*="-webkit-line-clamp"] {
  display: block !important;
  -webkit-line-clamp: unset !important;
  max-height: none !important;
  overflow: visible !important;
  text-overflow: clip !important;
  white-space: pre-wrap !important;
}

.modal-instruction {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.menu-editor-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.menu-edit-item {
  background: var(--row-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-sm);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: grab;
  transition: background var(--transition-fast);
}

.menu-edit-item:hover {
  background: var(--bg-panel-hover);
}

.menu-edit-item:active {
  cursor: grabbing;
}

.drag-handle {
  color: var(--text-muted);
  cursor: inherit;
}

.icon-preview {
  color: var(--accent-blue);
  width: 20px;
  text-align: center;
}

.btn-toggle-visibility {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  transition: color var(--transition-fast);
  padding: 4px;
}

.btn-toggle-visibility:hover {
  color: var(--accent-blue);
}

.menu-edit-item.hidden-menu {
  opacity: 0.6;
}

/* Settings Tabs */
.settings-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 8px;
}
.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.tab-btn:hover {
  background: var(--bg-panel-hover);
  color: var(--accent-blue);
}
.tab-btn.active {
  background: var(--accent-blue-glow);
  color: var(--accent-blue);
}
.tab-content {
  display: none;
}
.tab-content.active {
  display: block;
}

.menu-name-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  border-bottom: 1px solid transparent;
  padding: 4px 0;
  transition: border-color var(--transition-fast);
}

.menu-name-input:focus {
  border-bottom-color: var(--accent-blue);
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  background: rgba(0,0,0,0.1);
  border-bottom-left-radius: var(--border-radius-md);
  border-bottom-right-radius: var(--border-radius-md);
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: var(--border-radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 4px 12px var(--accent-blue-glow);
  white-space: nowrap;
  flex-shrink: 0;
}

.btn-primary:hover {
  background: #1e4bd8;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--accent-blue-glow);
}

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

/* ********** RESPONSIVE ********** */
@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

.instruction-box {
  display: flex;
  gap: 12px;
  padding: 12px 16px;
  background: rgba(41, 98, 255, 0.1);
  border-left: 3px solid var(--accent-blue);
  border-radius: var(--border-radius-sm);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-secondary);
}

.instruction-box i {
  color: var(--accent-blue);
  margin-top: 2px;
}

@media (max-width: 768px) {
  .app-wrapper {
    flex-direction: column;
  }
  
  .sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100%;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    border-right: 1px solid var(--border-color);
    border-bottom: none;
    z-index: 1000;
    transition: left var(--transition-smooth);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar.open {
    left: 0;
  }

  .sidebar-header, .sidebar-footer {
    display: flex;
  }

  .sidebar-nav {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
    padding: 20px 0 80px 0;
    -webkit-overflow-scrolling: touch;
  }

  .sidebar-nav ul {
    display: flex;
    flex-direction: column;
  }

  .nav-item {
    white-space: normal;
    margin: 4px 12px;
    padding: 14px 24px;
  }

  .topbar {
    padding: 16px 20px;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-menu-toggle {
    display: flex;
  }

  .topbar-actions {
    width: 100%;
    justify-content: flex-end;
    display: flex;
    gap: 12px;
  }

  .dashboard-grid {
    display: flex !important;
    flex-direction: column !important;
    padding: 16px 20px 20px;
    gap: 16px;
    overflow-x: hidden;
  }

  /* 그리드를 완전히 포기하고 Flex로 수직 배치하여 겹침, 크기 붕괴 원천 차단 */
  .panel, .dash-panel {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: auto !important;
    min-height: min-content !important;
    overflow: visible !important;
  }

  /* 내부 콘텐츠 강제 압축 해제 (스크롤 허용 및 내용물 전부 표출) */
  .dash-content, 
  .dash-content div[id^="desc-"], 
  .vertical-scroll-container,
  .log-container {
    height: auto !important;
    max-height: 400px !important;
    flex: none !important;
    min-height: min-content !important;
    overflow-y: auto !important;
  }

  /* 포트폴리오 요약 등 상태 카드는 모바일에서 보기 좋게 2열 배치 유지 */
  .status-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .panel {
    padding: 16px;
    width: 100%;
    max-width: 100vw;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  .panel-header {
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }
  .panel-header::-webkit-scrollbar {
    height: 0px;
    background: transparent;
  }

  .panel-title-wrapper {
    flex-shrink: 0;
    white-space: nowrap;
  }

  .panel-header h2 {
    font-size: 13px !important;
    line-height: 1.4;
    word-break: keep-all;
    white-space: nowrap;
  }

  .dash-content .status-value {
    font-size: 16px !important;
  }

  .dash-content div[id^="desc-"] {
    font-size: 11px !important;
  }

  .issue-actions {
    display: flex;
    flex-wrap: nowrap;
    width: auto;
    flex-shrink: 0;
    gap: 8px;
  }
  
  .market-tabs {
    flex-wrap: nowrap !important;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 4px !important;
    -webkit-overflow-scrolling: touch;
  }
  .market-tabs::-webkit-scrollbar {
    height: 0px;
    background: transparent;
  }

  .table-controls {
    overflow-x: auto;
    padding-bottom: 4px;
    margin-bottom: 12px !important;
    -webkit-overflow-scrolling: touch;
  }
  .table-controls::-webkit-scrollbar {
    height: 0px;
    background: transparent;
  }
  
  .table-controls > div {
    flex-wrap: nowrap;
    width: max-content;
    min-width: 100%;
    gap: 8px !important;
  }

  .table-controls input.search-input {
    max-width: 160px !important;
    width: 160px;
    flex-shrink: 0;
  }
}

/* AI Chatbot Styles */
.chatbot-fab {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--accent-blue);
  color: #fff;
  border: none;
  box-shadow: 0 4px 15px var(--accent-blue-glow);
  font-size: 24px;
  cursor: pointer;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
}
.chatbot-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--accent-blue-glow);
}
.chatbot-window {
  position: fixed;
  bottom: 100px;
  right: 30px;
  width: 360px;
  height: 500px;
  min-width: 300px;
  min-height: 400px;
  max-width: 800px;
  max-height: 90vh;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--panel-shadow-hover);
  display: none;
  flex-direction: column;
  z-index: 1000;
  overflow: hidden;
  resize: both;
  animation: slideUp var(--transition-smooth);
}
.chatbot-window.active {
  display: flex;
}
.chatbot-window.maximized {
  top: 10px !important;
  left: 10px !important;
  right: auto !important;
  bottom: auto !important;
  width: calc(100% - 20px) !important;
  height: calc(100% - 20px) !important;
  max-width: none !important;
  max-height: none !important;
  border-radius: 8px !important;
  z-index: 10000 !important;
}
.chatbot-header {
  padding: 16px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: grab;
}
.chatbot-header:active {
  cursor: grabbing;
}
.chatbot-title {
  font-weight: 600;
  color: var(--accent-blue);
  display: flex;
  align-items: center;
  gap: 8px;
}
.chatbot-messages {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-base);
}
.chat-message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}
.chat-message.ai-message {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.chat-message.user-message {
  background: var(--accent-blue);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.chatbot-image-preview {
  display: flex;
  padding: 8px 12px;
  background: var(--bg-base);
  border-top: 1px solid var(--border-color);
  gap: 8px;
  overflow-x: auto;
}
.chat-preview-img-wrapper {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}
.chat-preview-img-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.chat-preview-img-wrapper .btn-remove-img {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-msg-img {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 8px;
  border: 1px solid rgba(255,255,255,0.1);
}
.chatbot-input-area {
  display: flex;
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-panel);
  gap: 8px;
  align-items: flex-end;
}
.chatbot-input-area textarea {
  flex: 1;
  border: 1px solid var(--border-color);
  background: var(--bg-base);
  color: var(--text-primary);
  border-radius: 16px;
  padding: 9px 16px;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  overflow-y: auto;
  min-height: 38px;
  max-height: 120px;
  line-height: 1.4;
  box-sizing: border-box;
  transition: height 0.1s ease;
}
.chatbot-input-area textarea:focus {
  border-color: var(--accent-blue);
}
.chatbot-input-area textarea::-webkit-scrollbar {
  width: 4px;
}
.chatbot-input-area button {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.chatbot-input-area button:hover {
  background: #1e4bd8;
}

/* Toast Notification */
#toast-container {
  position: fixed;
  bottom: 30px;
  left: 30px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-msg {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 20px;
  border-radius: var(--border-radius-sm);
  box-shadow: var(--panel-shadow);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  font-weight: 500;
  animation: slideUpToast 0.3s ease forwards;
  transition: all 0.3s ease;
  pointer-events: auto;
}

.toast-success { border-left: 4px solid var(--accent-green); }
.toast-success i { color: var(--accent-green); font-size: 16px; }

.toast-warning, .toast-error { border-left: 4px solid var(--accent-red); }
.toast-warning i, .toast-error i { color: var(--accent-red); font-size: 16px; }

.toast-info { border-left: 4px solid var(--accent-blue); }
.toast-info i { color: var(--accent-blue); font-size: 16px; }

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