:root {
  --bg-color: #0b0f19;
  --card-bg: rgba(22, 28, 45, 0.65);
  --card-border: rgba(255, 255, 255, 0.08);
  --primary: #0ea5e9; /* Sky 500 */
  --primary-grad: linear-gradient(135deg, #38bdf8 0%, #0284c7 100%);
  --success: #10b981; /* Emerald 500 (성공/정상 상태 - 초록색 복구) */
  --success-grad: linear-gradient(135deg, #34d399 0%, #059669 100%);
  --danger: #ef4444; /* Red 500 (에러/경고 상태 - 빨간색 복구) */
  --text-main: #f8fafc; /* Slate 50 */
  --text-muted: #94a3b8; /* Slate 400 */
  --border-light: rgba(255, 255, 255, 0.04);
  
  /* Toss-style Stock price return colors (주가 가격/수익률에만 한정 적용) */
  --stock-up: #f04452;   /* Toss Vibrant Red (양봉) */
  --stock-down: #3182f6; /* Toss Vibrant Blue (음봉) */
}

/* Value change micro-animation (레이아웃 보호를 위해 opacity만 제어) */
@keyframes value-fade {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

.value-update-flash {
  animation: value-fade 0.4s ease-out;
}

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

body {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  padding: 2rem 1.5rem;
  background-image: radial-gradient(circle at 10% 20%, rgba(14, 165, 233, 0.04) 0%, transparent 45%),
                    radial-gradient(circle at 90% 80%, rgba(16, 185, 129, 0.04) 0%, transparent 45%);
  background-attachment: fixed;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
}

/* Header styling */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 1.5rem;
}

.header-left h1 {
  font-size: 2rem;
  font-weight: 700;
  background: linear-gradient(135deg, #f8fafc 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.header-left p {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin-top: 0.2rem;
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.time-display {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: monospace;
}

/* Status Badge & Pulse */
.status-badge {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.status-krx {
  color: var(--success);
  border-color: rgba(16, 185, 129, 0.2);
}
.status-krx .status-dot {
  background-color: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse-krx 1.8s infinite;
}
@keyframes pulse-krx {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  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); }
}

.status-nxt {
  color: #a855f7; /* Violet/Purple */
  border-color: rgba(168, 85, 247, 0.2);
}
.status-nxt .status-dot {
  background-color: #a855f7;
  box-shadow: 0 0 8px #a855f7;
  animation: pulse-nxt 1.8s infinite;
}
@keyframes pulse-nxt {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(168, 85, 247, 0.4); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(168, 85, 247, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(168, 85, 247, 0); }
}

.status-offline {
  color: var(--text-muted);
  border-color: var(--card-border);
}
.status-offline .status-dot {
  background-color: var(--text-muted);
  box-shadow: none;
  animation: none;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  position: relative;
  overflow: hidden;
  transition: transform 0.25s ease, border-color 0.25s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-card .card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.metric-card .card-value {
  font-size: 1.8rem;
  font-weight: 700;
  margin: 0.5rem 0 0.2rem 0;
}

.metric-card .card-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Card highlights */
.metric-card.highlight-blue {
  border-left: 4px solid var(--primary);
}
.metric-card.highlight-green {
  border-left: 4px solid var(--success);
}

/* Dashboard Body layout */
.dashboard-body {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 2rem;
}

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

.chart-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.chart-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(16px);
}

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

.chart-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  border-left: 3px solid var(--primary);
  padding-left: 0.75rem;
}

.chart-wrapper {
  position: relative;
  height: 300px;
  width: 100%;
}

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

.side-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 1.5rem;
  backdrop-filter: blur(16px);
}

.side-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.5rem;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Forms and Controls */
.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.select-control {
  width: 100%;
  background: #111827;
  border: 1px solid var(--card-border);
  border-radius: 8px;
  color: var(--text-main);
  padding: 0.5rem;
  font-size: 0.9rem;
  outline: none;
}

/* Buttons */
.btn {
  display: inline-block;
  text-align: center;
  font-weight: 600;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  background: #1f2937;
  color: var(--text-main);
  transition: all 0.2s ease;
  width: 100%;
}

.btn:hover {
  background: #374151;
}

.btn-primary {
  background: var(--primary-grad);
  color: #0b0f19;
}
.btn-primary:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--success-grad);
  color: #0b0f19;
}
.btn-accent:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

.btn-chart-type {
  width: auto;
  font-size: 0.75rem;
  padding: 0.3rem 0.75rem;
  border-radius: 6px;
  background: transparent;
  border: 1px solid var(--card-border);
  color: var(--text-muted);
  margin-left: 0.25rem;
}

.btn-chart-type.active {
  background: var(--primary);
  color: #0b0f19;
  border-color: var(--primary);
}

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

/* Table */
.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.summary-table td {
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border-light);
}

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

.summary-table td:last-child {
  text-align: right;
}

.val-bold {
  font-weight: 700;
}

.value-up {
  color: var(--stock-up) !important;
}

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

/* Sync messages */
.sync-status-msg {
  font-size: 0.8rem;
  margin-top: 0.75rem;
  padding: 0.5rem;
  border-radius: 6px;
  display: none;
}

.sync-status-success {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success);
  display: block;
}

.sync-status-error {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
  display: block;
}
