/* Root Variables & Theme Definition */
:root {
  --bg-color: #080c14;
  --card-bg: rgba(13, 20, 35, 0.6);
  --border-color: rgba(255, 255, 255, 0.07);
  --text-primary: #f3f4f6;
  --text-secondary: #9ca3af;
  --accent-purple: #a855f7;
  --accent-blue: #3b82f6;
  --accent-gradient: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
  --accent-gradient-hover: linear-gradient(135deg, #b56ff9 0%, #4f92f8 100%);
  
  --kospi-color: #3b82f6;
  --kosdaq-color: #10b981;
  --danger-color: #ef4444;
}

/* Global Reset & Base Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: clip;
  overflow-y: auto !important;
  line-height: 1.5;
}

header.sticky {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 50 !important;
}

/* Decorative Background Glows */
.glow-bg {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(150px);
  z-index: -1;
  pointer-events: none;
  opacity: 0.18;
}

.glow-purple {
  background: var(--accent-purple);
  top: -10%;
  left: -10%;
}

.glow-blue {
  background: var(--accent-blue);
  bottom: -10%;
  right: -10%;
}

/* Container & Layout */
.container {
  width: 99%;
  max-width: 1920px;
  margin: 0 auto;
  padding: 0.5rem 0.75rem;
}

/* Dashboard Header */
.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border-color);
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 42px;
  height: 42px;
}

.logo-text h1 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.logo-text .sub {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.3em;
  color: var(--text-secondary);
  font-weight: 500;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.04);
  padding: 0.5rem 1rem;
  border-radius: 50px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  background-color: var(--kosdaq-color);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  animation: pulse 1.6s infinite;
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  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);
  }
}

/* Dashboard Main Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 0.2rem;
  align-items: stretch;
}

@media (max-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: 1fr;
    gap: 0.35rem;
    align-items: start;
  }
  .watchlist-card {
    min-height: 300px;
    max-height: 420px;
  }
  .watchlist-container {
    min-height: 220px;
    max-height: 340px;
    overflow-y: auto;
  }
}

/* Universal Sidebar Collapsed State (Active on all screen resolutions) */
.collapsed-sidebar-strip {
  display: none;
  width: 38px;
  min-width: 38px;
  background: #080d1a;
  border-right: 1px solid rgba(99, 102, 241, 0.25);
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  z-index: 20;
}
.collapsed-sidebar-strip:hover {
  background: rgba(99, 102, 241, 0.18);
  border-right-color: rgba(99, 102, 241, 0.6);
  box-shadow: 2px 0 10px rgba(99, 102, 241, 0.25);
}
.dashboard-grid.sidebar-collapsed .collapsed-sidebar-strip {
  display: flex !important;
}
.btn-expand-strip {
  background: transparent;
  border: none;
  color: #c7d2fe;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  padding: 1rem 0.2rem;
  writing-mode: vertical-rl;
  text-orientation: mixed;
  letter-spacing: 2px;
}
.btn-expand-strip i {
  font-size: 0.75rem;
  writing-mode: horizontal-tb;
  color: #818cf8;
  margin-bottom: 0.2rem;
}

.dashboard-grid.sidebar-collapsed {
  grid-template-columns: 38px 1fr !important;
}
.dashboard-grid.sidebar-collapsed .sidebar-column {
  display: none !important;
}

/* Sidebar Toggle Buttons & Interactive Feedback */
.btn-toggle-sidebar:hover {
  background: rgba(99, 102, 241, 0.35) !important;
  color: #ffffff !important;
  border-color: rgba(99, 102, 241, 0.6) !important;
  transform: translateY(-1px);
}
.btn-toggle-sidebar.is-collapsed {
  background: rgba(99, 102, 241, 0.4) !important;
  border-color: #818cf8 !important;
  color: #ffffff !important;
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.45) !important;
}


/* Card Styles (Glassmorphism) */
.card {
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 12px;
  border: 1px solid var(--border-color);
  padding: 0.85rem 1.15rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-color);
}

.card-header.justify-between {
  justify-content: space-between;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.card-icon {
  width: 24px;
  height: 24px;
  color: var(--accent-purple);
}

.card-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
}

/* Form Styles */
.filter-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

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

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

.filter-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-form input[type="number"] {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.45rem 0.65rem;
  color: var(--text-primary);
  font-size: 0.8rem;
  font-family: inherit;
  transition: all 0.3s ease;
  width: 100%;
}

.filter-form select {
  background: rgba(17, 24, 39, 0.9);
  border: 1px solid rgba(168, 85, 247, 0.45);
  border-radius: 6px;
  padding: 0.42rem 0.55rem;
  color: var(--text-primary);
  font-size: 0.78rem;
  font-weight: 600;
  font-family: inherit;
  transition: all 0.2s ease;
  width: 100%;
  cursor: pointer;
}

.filter-form select optgroup {
  font-size: 0.73rem;
  font-weight: 700;
  color: #c084fc;
  background: #0f172a;
  padding: 4px 2px;
}

.filter-form select option {
  font-size: 0.75rem;
  font-weight: 500;
  color: #f1f5f9;
  background: #111827;
  padding: 5px 6px;
}

.filter-form input[type="number"]:focus,
.filter-form select:focus {
  outline: none;
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15);
}

.input-note {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Custom Checkbox */
.form-group-checkbox {
  margin: 0.5rem 0;
}

.checkbox-container {
  display: block;
  position: relative;
  padding-left: 2rem;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500 !important;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-container input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.checkmark {
  position: absolute;
  top: 1px;
  left: 0;
  height: 18px;
  width: 18px;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  transition: all 0.2s ease;
}

.checkbox-container:hover input ~ .checkmark {
  background-color: rgba(255, 255, 255, 0.1);
}

.checkbox-container input:checked ~ .checkmark {
  background: var(--accent-gradient);
  border-color: transparent;
}

.checkmark:after {
  content: "";
  position: absolute;
  display: none;
}

.checkbox-container input:checked ~ .checkmark:after {
  display: block;
}

.checkbox-container .checkmark:after {
  left: 6px;
  top: 2px;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Button Component */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.3);
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.45);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: rgba(255, 255, 255, 0.06);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-icon {
  width: 18px;
  height: 18px;
}

/* Table Quick Action Button */
.btn-table {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: 6px;
}

/* Count & Badges */
.count-badge {
  background: var(--accent-purple);
  color: white;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 30px;
}

.badge-market {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 4px;
}

.badge-kospi {
  background-color: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.25);
}

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

/* Empty State & Blank States */
.blank-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 5rem 2rem;
  text-align: center;
}

.blank-icon {
  width: 64px;
  height: 64px;
  color: rgba(255, 255, 255, 0.15);
  margin-bottom: 1.5rem;
}

.blank-state h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.blank-state p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 320px;
}

/* Results Content States */
.results-card {
  min-height: 500px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* Loading Indicator Screen */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-grow: 1;
  padding: 3rem 0;
}

.spinner-outer {
  width: 50px;
  height: 50px;
  border: 3px solid rgba(255, 255, 255, 0.05);
  border-top: 3px solid var(--accent-purple);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-status-text {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.progress-bar-container {
  width: 250px;
  height: 6px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  width: 10%;
  height: 100%;
  background: var(--accent-gradient);
  border-radius: 10px;
  transition: width 0.4s ease;
  box-shadow: 0 0 10px var(--accent-purple);
}

/* Table Area styling */
.table-container {
  overflow-x: auto;
  overflow-y: visible;
  margin-top: 0.5rem;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.25rem;
}

.stocks-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.7rem;
  table-layout: auto;
}

.stocks-table thead th {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #0b1120 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  padding: 0.28rem 0.25rem !important;
  border-bottom: 1px solid rgba(99, 102, 241, 0.35);
  color: #94a3b8;
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.stocks-table td {
  padding: 0.22rem 0.25rem !important;
  border-bottom: 1px solid rgba(255, 255, 255, 0.035);
  color: var(--text-primary);
  vertical-align: middle;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-size: 0.71rem;
}

.stocks-table tbody tr {
  transition: background-color 0.2s ease, transform 0.2s ease;
}

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

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

.stock-code-cell {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.stock-link {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease, border-bottom 0.2s ease;
  border-bottom: 1px dashed transparent;
}

.stock-link:hover {
  color: var(--accent-purple);
  border-bottom-color: var(--accent-purple);
}

.action-cell {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: nowrap;
}

/* Utility Hidden class - Scoped to avoid breaking Tailwind CSS responsive utilities */
.modal-overlay.hidden,
.accordion-panel.hidden,
#loading-state.hidden,
#blank-state.hidden,
#table-container.hidden,
#draft-progress-toast.hidden {
  display: none !important;
}

/* Modal Overlay & Box (Glassmorphic Window) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-box {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  width: 90%;
  max-width: 900px;
  height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  animation: modalScaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalScaleUp {
  0% { transform: scale(0.9) translateY(20px); opacity: 0; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}

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

.modal-badge {
  background-color: rgba(168, 85, 247, 0.15);
  color: #c084fc;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
  display: inline-block;
}

.modal-title-area h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.3rem;
  font-weight: 600;
}

.btn-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: color 0.2s ease;
}

.btn-close:hover {
  color: var(--text-primary);
}

.btn-maximize {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease;
}

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

.btn-maximize .icon-shrink,
.btn-maximize.is-maximized .icon-expand {
  display: none !important;
}

.btn-maximize.is-maximized .icon-shrink {
  display: block !important;
}

/* Maximized Modal Box style */
.modal-box.maximized {
  width: 96% !important;
  max-width: 1400px !important;
  height: 94vh !important;
  transition: width 0.3s ease, height 0.3s ease, max-width 0.3s ease;
}

.modal-body {
  padding: 1.75rem;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 1.25rem 1.75rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* Modal Loading (DNA style bounce) */
.modal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
}

.dna-spinner {
  width: 60px;
  height: 60px;
  position: relative;
  margin-bottom: 2rem;
}

.double-bounce1, .double-bounce2 {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: var(--accent-purple);
  opacity: 0.6;
  position: absolute;
  top: 0;
  left: 0;
  animation: sk-bounce 2.0s infinite ease-in-out;
}

.double-bounce2 {
  background-color: var(--accent-blue);
  animation-delay: -1.0s;
}

@keyframes sk-bounce {
  0%, 100% { transform: scale(0.0) }
  50% { transform: scale(1.0) }
}

.modal-loading h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.modal-loading p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  max-width: 400px;
}

/* Markdown Rendering Custom Styles inside modal */
.markdown-body {
  font-size: 1rem;
  color: #cbd5e1;
  line-height: 1.7;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  font-family: 'Outfit', sans-serif;
  color: white;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.markdown-body h1 {
  font-size: 1.5rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.markdown-body h2 {
  font-size: 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  padding-bottom: 0.25rem;
}

.markdown-body h3 {
  font-size: 1.1rem;
}

.markdown-body p {
  margin-bottom: 1rem;
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 1rem;
  padding-left: 1.5rem;
}

.markdown-body li {
  margin-bottom: 0.4rem;
}

.markdown-body code {
  background-color: rgba(255, 255, 255, 0.08);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85rem;
  color: #f472b6;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.9rem;
}

.markdown-body th {
  background-color: rgba(255, 255, 255, 0.03);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  font-weight: 600;
  color: white;
}

.markdown-body td {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
}

.markdown-body blockquote {
  border-left: 4px solid var(--accent-purple);
  background: rgba(168, 85, 247, 0.05);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.5rem;
  border-radius: 0 8px 8px 0;
}

.markdown-body blockquote p {
  margin-bottom: 0;
}

/* Sidebar Column Layout */
.sidebar-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Terminal Console Layout in Modal */
.modal-terminal {
  background-color: #050811;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.8), 0 8px 24px rgba(0, 0, 0, 0.4);
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 350px;
}

.terminal-header {
  background-color: #111827;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.terminal-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
}

.terminal-dot.red { background-color: #ef4444; }
.terminal-dot.yellow { background-color: #f59e0b; }
.terminal-dot.green { background-color: #10b981; }

.terminal-title {
  font-family: monospace;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 0.5rem;
}

.terminal-logs {
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  color: #a7f3d0;
  padding: 1.25rem;
  overflow-y: auto;
  flex-grow: 1;
  white-space: pre-wrap;
  word-break: break-all;
  height: 300px;
  text-align: left;
  line-height: 1.6;
}

/* Custom Scrollbar for Terminal */
.terminal-logs::-webkit-scrollbar {
  width: 6px;
}
.terminal-logs::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
}
.terminal-logs::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}
.terminal-logs::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Action Button Adjustments */
.btn-regenerate {
  width: 28px;
  height: 28px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-regenerate:hover {
  background: rgba(255, 255, 255, 0.15);
  color: var(--text-primary);
  transform: rotate(180deg);
}

.btn-regenerate-icon {
  width: 14px;
  height: 14px;
}

/* ──────────────────────────────────────────────────────────────
   Viewport-height Dashboard & Maximize Screen Optimization
   ────────────────────────────────────────────────────────────── */

/* ──────────────────────────────────────────────────────────────
   Screener Layout Harmonized with Main Tabs (Natural Page Scroll)
   ────────────────────────────────────────────────────────────── */

header.sticky {
  flex-shrink: 0;
  width: 100%;
  position: sticky !important;
  top: 0 !important;
  z-index: 50 !important;
}

.container {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 auto;
  padding: 0.25rem 0.25rem 0.4rem 0.25rem;
  box-sizing: border-box;
}

.dashboard-header {
  margin-bottom: 0.35rem;
  padding-bottom: 0.25rem;
}

@media (min-width: 1025px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 0.2rem;
    align-items: stretch;
    transition: grid-template-columns 0.25s ease;
  }
  .dashboard-grid.sidebar-collapsed {
    grid-template-columns: 38px 1fr !important;
  }
  .dashboard-grid.sidebar-collapsed .sidebar-column {
    display: none !important;
  }
  .sidebar-column {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    width: 260px;
    min-width: 260px;
    height: 100%;
    min-height: 0;
  }
  .sidebar-column .filter-card {
    flex-shrink: 0;
  }
  .sidebar-column .card {
    background-color: #0b101a !important;
    padding: 0.4rem 0.35rem !important;
  }
  .watchlist-card {
    flex: 1 1 0 !important;
    min-height: 650px !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
  }
  .watchlist-container {
    flex: 1 1 0 !important;
    min-height: 570px !important;
    max-height: 720px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
  }
  
  .results-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.35rem 0.3rem !important;
    height: 100%;
  }
  .results-card .card-header {
    flex-shrink: 0;
    margin-bottom: 0.35rem;
    padding-bottom: 0.25rem;
  }
  .table-container {
    flex: 1 1 0;
    min-height: 940px;
    max-height: 1050px;
    overflow-y: auto;
    overflow-x: auto;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: #080d1a;
  }

  /* Maximized Modal Layout: 2-Column Professional Report */
  .modal-box.maximized {
    width: 98% !important;
    max-width: 100% !important;
    height: 96vh !important;
    margin: 2vh auto !important;
  }
  .modal-box.maximized .modal-content {
    column-count: 2;
    column-gap: 3.5rem;
    column-rule: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0 1rem;
    text-align: justify;
  }
  .modal-box.maximized .modal-content h1,
  .modal-box.maximized .modal-content h2,
  .modal-box.maximized .modal-content h3 {
    break-inside: avoid;
    break-after: avoid;
  }
  .modal-box.maximized .modal-content table,
  .modal-box.maximized .modal-content blockquote,
  .modal-box.maximized .modal-content ul,
  .modal-box.maximized .modal-content ol,
  .modal-box.maximized .modal-content .card {
    break-inside: avoid;
  }
}

/* Modern Ultra-Slim Neon-Indigo Scrollbar (Minimal Space, Sleek Aesthetics) */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: rgba(8, 13, 26, 0.6);
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.38);
  border-radius: 9999px;
  border: 1px solid rgba(99, 102, 241, 0.2);
  transition: all 0.2s ease;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.85);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.7);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

/* Firefox Scrollbar Support */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.38) rgba(8, 13, 26, 0.6);
}

.table-container,
.watchlist-container {
  scrollbar-width: thin;
  scrollbar-color: rgba(99, 102, 241, 0.45) rgba(8, 13, 26, 0.75);
}
.table-container::-webkit-scrollbar,
.watchlist-container::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
.table-container::-webkit-scrollbar-track,
.watchlist-container::-webkit-scrollbar-track {
  background: rgba(8, 13, 26, 0.75);
  border-radius: 9999px;
}
.table-container::-webkit-scrollbar-thumb,
.watchlist-container::-webkit-scrollbar-thumb {
  background: rgba(99, 102, 241, 0.45);
  border-radius: 9999px;
  border: 1px solid rgba(99, 102, 241, 0.25);
}
.table-container::-webkit-scrollbar-thumb:hover,
.watchlist-container::-webkit-scrollbar-thumb:hover {
  background: rgba(129, 140, 248, 0.9);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.8);
}

/* History lookup select styles */
.history-select {
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.75rem;
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.history-select:hover, .history-select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 4px rgba(168, 85, 247, 0.3);
}

/* Accordion Button Styling */
.btn-accordion-toggle {
  width: 100%;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 0.2s ease;
  margin-bottom: 0.5rem;
}

.btn-accordion-toggle:hover {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-primary);
  border-color: rgba(168, 85, 247, 0.4);
}

.accordion-arrow {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  transition: transform 0.2s ease;
}

.btn-accordion-toggle.active .accordion-arrow {
  transform: rotate(180deg);
  color: var(--accent-purple);
}

/* Accordion Panel (Body) */
.accordion-panel {
  background: rgba(15, 23, 42, 0.3);
  border: 1px dashed rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 0.75rem;
  margin-bottom: 0.75rem;
}

/* Watchlist Sidebar Styles */
.watchlist-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 0.72rem;
  transition: background-color 0.2s ease;
}

.watchlist-item:hover {
  background-color: rgba(255, 255, 255, 0.03);
}

.watchlist-item-left {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  flex-grow: 1; /* 가용 공간 전체 점유 */
  padding-right: 0.5rem;
  min-width: 0;
}

.watchlist-item-name {
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color 0.15s ease;
}

.watchlist-item-left:hover .watchlist-item-name {
  color: var(--accent-purple);
  text-decoration: underline;
}

.watchlist-item-code {
  font-size: 0.65rem;
  color: var(--text-secondary);
  font-family: monospace;
  text-decoration: none;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.watchlist-item-code:hover {
  color: #818cf8;
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.4);
  text-decoration: underline;
}

.watchlist-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-mini {
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

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

.btn-mini.btn-mini-analyze:hover {
  color: #c084fc; /* light purple */
}

.btn-mini.btn-mini-delete:hover {
  color: #ef4444; /* red */
}

.watchlist-empty {
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.7rem;
}

/* Clickable Table Column Sorting Styles */
th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background-color 0.2s ease;
}

th.sortable:hover {
  background-color: rgba(255, 255, 255, 0.08) !important;
}

.sort-indicator {
  font-size: 0.65rem;
  margin-left: 0.25rem;
  color: var(--text-secondary);
  display: inline-block;
  vertical-align: middle;
  transition: color 0.15s ease;
}

th.sortable:hover .sort-indicator {
  color: var(--accent-purple);
}

.badge-report-tag {
  display: inline-block;
  vertical-align: middle;
  transition: all 0.15s ease;
}

.stock-name-cell .stock-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.stock-name-cell .stock-link:hover {
  color: #c084fc !important;
  text-decoration: underline;
}

.stock-name-cell .stock-link:hover .badge-report-tag {
  transform: scale(1.08);
  box-shadow: 0 0 6px rgba(168, 85, 247, 0.4);
}

/* ==========================================================================
   Live Major Stock Realtime Tick Flashing Animations
   ========================================================================== */
@keyframes tickGlowUp {
  0% {
    background-color: rgba(244, 63, 94, 0.22);
    color: #e11d48;
    transform: scale(1.025);
  }
  60% {
    background-color: rgba(244, 63, 94, 0.10);
  }
  100% {
    background-color: transparent;
    color: inherit;
    transform: scale(1);
  }
}

@keyframes tickGlowDown {
  0% {
    background-color: rgba(59, 130, 246, 0.22);
    color: #2563eb;
    transform: scale(1.025);
  }
  60% {
    background-color: rgba(59, 130, 246, 0.10);
  }
  100% {
    background-color: transparent;
    color: inherit;
    transform: scale(1);
  }
}

.tick-flash-up {
  animation: tickGlowUp 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  border-radius: 6px;
  display: inline-block;
  padding: 0 2px;
}

.tick-flash-down {
  animation: tickGlowDown 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  border-radius: 6px;
  display: inline-block;
  padding: 0 2px;
}

/* Local Environment Only: M-Score & Z-Score Forensic Risk Alert Elements */
.local-only-forensic {
  display: none !important;
}
html.is-local-env .local-only-forensic {
  display: inline-flex !important;
}
html.is-local-env div.local-only-forensic-bar {
  display: flex !important;
}
html.is-local-env section.local-only-forensic {
  display: block !important;
}

