/* ===== Figma-based Light Dashboard Theme ===== */
:root {
  --bg-body: #f0f2f5;
  --bg-white: #ffffff;
  --bg-sidebar: #1e2a3a;
  --bg-sidebar-hover: #2a3a4e;
  --border: #e2e8f0;
  --border-light: #edf2f7;
  --text-primary: #1a202c;
  --text-secondary: #718096;
  --text-muted: #a0aec0;
  --accent-green: #38a169;
  --accent-red: #e53e3e;
  --accent-blue: #4299e1;
  --accent-purple: #805ad5;
  --accent-orange: #ed8936;
  --radius: 16px;
  --radius-sm: 12px;
  --radius-xs: 8px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --sidebar-width: 240px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Inter", sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
}

/* ===== サイドバー ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  z-index: 100;
  padding: 24px 16px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px 28px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  margin-bottom: 24px;
}

.logo-icon {
  font-size: 1.8rem;
  color: #63b3ed;
}

.logo-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.logo-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
  margin-top: 2px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-xs);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.88rem;
  font-weight: 500;
  transition: all 0.15s;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: #fff;
}

.nav-item.active {
  background: var(--accent-green);
  color: #fff;
}

.nav-item.logout {
  color: rgba(255,255,255,0.4);
}
.nav-item.logout:hover {
  color: rgba(255,255,255,0.8);
}

/* ===== メインコンテンツ ===== */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 32px 40px;
  min-height: 100vh;
}

/* ページヘッダー */
.page-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.page-updated {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ローディング */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 50vh;
  gap: 16px;
  color: var(--text-muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== ヒーローカード ===== */
.hero-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.hero-card {
  border-radius: var(--radius);
  padding: 24px 28px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.hero-card::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -10%;
  width: 160px;
  height: 160px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
}

.hero-purple {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.hero-green {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
}

.hero-label {
  font-size: 0.82rem;
  font-weight: 500;
  opacity: 0.85;
  margin-bottom: 8px;
}

.hero-value {
  font-size: 2.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.hero-sub {
  font-size: 0.85rem;
  margin-top: 6px;
  opacity: 0.8;
}

/* ===== スタットカード ===== */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s;
}

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

.stat-label {
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 500;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.stat-change {
  font-size: 0.75rem;
  font-weight: 600;
  margin-top: 6px;
}

.stat-change.positive { color: var(--accent-green); }
.stat-change.negative { color: var(--accent-red); }
.stat-change.neutral { color: var(--accent-blue); }

.stat-icon-box {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.icon-blue { background: #ebf8ff; color: var(--accent-blue); }
.icon-green { background: #f0fff4; color: var(--accent-green); }
.icon-purple { background: #faf5ff; color: var(--accent-purple); }
.icon-orange { background: #fffaf0; color: var(--accent-orange); }

/* ===== チャートエリア ===== */
.chart-row {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-bottom: 24px;
}

.chart-main {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.section-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

.chart-container {
  height: 320px;
  position: relative;
}

/* ===== ターゲットパネル ===== */
.target-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.target-card {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.target-card:first-child {
  background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
  color: #fff;
  border: none;
}

.target-label {
  font-size: 0.78rem;
  font-weight: 500;
  opacity: 0.7;
  margin-bottom: 8px;
}

.target-value {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 16px;
}

.target-progress-wrap {
  margin-top: 4px;
}

.target-progress-bar {
  width: 100%;
  height: 8px;
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.target-progress-fill {
  height: 100%;
  background: var(--accent-blue);
  border-radius: 4px;
  transition: width 0.6s ease;
}

.target-progress-text {
  font-size: 0.75rem;
  opacity: 0.6;
}

.target-days-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* ===== トレードテーブル ===== */
.trades-section {
  background: var(--bg-white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.trades-table-wrap {
  overflow-x: auto;
}

.trades-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.trades-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.trades-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
  color: var(--text-primary);
}

.trades-table tbody tr:hover {
  background: #f7fafc;
}

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

.type-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 0.72rem;
  font-weight: 600;
}

.type-buy {
  background: #f0fff4;
  color: var(--accent-green);
}

.type-sell {
  background: #fff5f5;
  color: var(--accent-red);
}

.profit-positive {
  color: var(--accent-green);
  font-weight: 600;
}

.profit-negative {
  color: var(--accent-red);
  font-weight: 600;
}

/* ===== レスポンシブ ===== */
@media (max-width: 1200px) {
  .chart-row {
    grid-template-columns: 1fr;
  }
  .target-panel {
    flex-direction: row;
  }
  .target-card {
    flex: 1;
  }
}

@media (max-width: 1024px) {
  .stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }
  .hero-cards {
    grid-template-columns: 1fr;
  }
  .stat-cards {
    grid-template-columns: 1fr 1fr;
  }
  .hero-value {
    font-size: 1.6rem;
  }
  .target-panel {
    flex-direction: column;
  }
}

@media (max-width: 480px) {
  .stat-cards {
    grid-template-columns: 1fr;
  }
}
