:root {
  --bg: #0f1419;
  --panel: #1a2129;
  --line: #2a333d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #3fb950;
  --over: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  background: var(--bg);
  color: var(--text);
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--line);
}

header h1 { font-size: 1.2rem; margin: 0; }
.controls { display: flex; gap: 0.5rem; align-items: center; }
.controls label { color: var(--muted); font-size: 0.85rem; }

select, button {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-size: 0.9rem;
  cursor: pointer;
}

main { padding: 1.5rem; max-width: 1000px; margin: 0 auto; }
.status { color: var(--muted); min-height: 1.2em; }

.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.75rem; margin-bottom: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 0.9rem; }
.card-label { color: var(--muted); font-size: 0.8rem; }
.card-value { font-size: 1.4rem; font-weight: 600; margin-top: 0.25rem; }

.gauge { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; height: 14px; overflow: hidden; }
.gauge-fill { height: 100%; background: var(--accent); width: 0%; transition: width 0.3s; }
.gauge-fill.over { background: var(--over); }
.gauge-caption { color: var(--muted); font-size: 0.85rem; margin: 0.4rem 0 1.2rem; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 1rem; margin-bottom: 0.75rem; }
.panel.wide { grid-column: 1 / -1; }
.panel h2 { font-size: 0.95rem; margin: 0 0 0.6rem; color: var(--muted); font-weight: 600; }

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { text-align: left; padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

.note { color: var(--muted); font-size: 0.8rem; margin-top: 1.5rem; }

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

/* 損益(PnL) */
.pos { color: #1a7f37; }   /* プラス収支 */
.neg { color: #cf222e; }   /* マイナス収支 */
h2#pnl-title { margin: 18px 0 6px; }

/* 損益推移チャート */
#trend-chart { width: 100%; height: auto; }
#trend-chart .bar.pos { fill: #1a7f37; }
#trend-chart .bar.neg { fill: #cf222e; }
#trend-chart .cum-line { stroke: #0969da; stroke-width: 2; }
#trend-chart .axis { fill: #666; font-size: 11px; }
.chart-legend { display: flex; gap: 16px; align-items: center; margin-top: 6px; font-size: 13px; }
.chart-legend .lg::before { content: ""; display: inline-block; width: 12px; height: 12px;
  margin-right: 5px; vertical-align: middle; }
.chart-legend .lg-bar::before { background: #1a7f37; }
.chart-legend .lg-line::before { background: #0969da; }

/* --- オペレーション・パネル --- */
#ops-section .ops-controls { margin: 8px 0; display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
#ops-section .ops-controls input { padding: 4px 6px; }
#ops-section .ops-buttons { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0 12px; }
#ops-section .ops-buttons button { padding: 8px 12px; cursor: pointer; border: 1px solid #888; border-radius: 6px; background: #f6f6f6; }
#ops-section .ops-buttons button:hover { background: #e8effa; }
#ops-jobs-table { width: 100%; border-collapse: collapse; font-size: 13px; }
#ops-jobs-table th, #ops-jobs-table td { border-bottom: 1px solid #eee; padding: 4px 6px; text-align: left; vertical-align: top; }
.ops-log { margin: 0; max-height: 5em; overflow: auto; white-space: pre-wrap; word-break: break-all; font-size: 11px; color: #444; background: #fafafa; }
.ops-st { font-weight: 600; }
.ops-running { color: #b26a00; } .ops-done { color: #1a7f37; } .ops-failed { color: #c22; } .ops-queued { color: #555; } .ops-canceled { color: #999; }
.ops-cancel { cursor: pointer; }
