:root {
  --bg: #0f1115;
  --panel: #181b22;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #4f8cff;
  --font-sans: 'IBM Plex Sans JP', sans-serif;
  --font-mono: 'IBM Plex Mono', monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
}

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

.site-head h1 { font-size: 18px; font-weight: 700; }

.sync-status {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--muted);
}

#app { padding: 24px; max-width: 1200px; margin: 0 auto; }

.placeholder {
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  line-height: 1.9;
}

.source-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}

.source-section h2 {
  font-size: 16px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.source-section h3 {
  font-size: 14px;
  color: var(--muted);
  margin: 20px 0 8px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.kpi-label { font-size: 12px; color: var(--muted); }

.kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 600;
}

.kpi-value small {
  font-size: 12px;
  color: var(--muted);
  margin-left: 4px;
}

.chart-area canvas { margin: 12px 0; max-height: 280px; }

.history-links {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 8px;
}

.history-links a { color: var(--accent); }

#chat-panel {
  max-width: 1200px;
  margin: 0 auto 48px;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
}

#chat-panel h2 { font-size: 16px; margin-bottom: 4px; }

.chat-hint { font-size: 13px; color: var(--muted); margin-bottom: 16px; }

#chat-log {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.chat-message {
  border-radius: 10px;
  padding: 10px 14px;
  max-width: 85%;
}

.chat-message.user {
  background: rgba(79, 140, 255, 0.15);
  align-self: flex-end;
}

.chat-message.assistant {
  background: var(--bg);
  border: 1px solid var(--border);
  align-self: flex-start;
}

.chat-role {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.chat-body {
  font-size: 14px;
  line-height: 1.8;
  white-space: pre-wrap;
  word-break: break-word;
}

#chat-form { display: flex; gap: 8px; }

#chat-form textarea {
  flex: 1;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  resize: vertical;
}

.btn {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 8px 20px;
}

.btn.primary { background: var(--accent); border-color: var(--accent); }

.btn:disabled { opacity: 0.5; cursor: wait; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th { color: var(--muted); font-weight: 500; }
