/* デイトレ帳 PWA — 最小構成のスタイル */
:root {
  --bg: #f9fafb;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --green: #16a34a;
  --red: #dc2626;
  --accent: #111827;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1220;
    --card: #111827;
    --text: #f3f4f6;
    --muted: #9ca3af;
    --border: #1f2937;
    --accent: #f3f4f6;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 76px;
}
.app-header {
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--accent);
  color: var(--bg);
}
.app-header h1 { margin: 0; font-size: 18px; font-weight: 700; }
main { padding: 12px; max-width: 560px; margin: 0 auto; }

.view { display: none; }
.view.active { display: block; }

/* カレンダー */
.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.month-title { font-size: 17px; font-weight: 700; }
.nav-btn {
  width: 40px; height: 40px; font-size: 22px; border: 1px solid var(--border);
  background: var(--card); color: var(--text); border-radius: 10px; cursor: pointer;
}
.dow-row, .calendar-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
}
.dow-row span { text-align: center; font-size: 12px; color: var(--muted); padding: 2px 0; }
.dow-row .sat { color: #2563eb; }
.dow-row .sun { color: var(--red); }
.cal-cell {
  background: var(--card); border: 1px solid var(--border); border-radius: 8px;
  min-height: 56px; padding: 4px 3px; cursor: pointer; text-align: center;
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
}
.cal-cell.empty { background: transparent; border: none; cursor: default; }
.cal-cell.selected { outline: 2px solid var(--accent); }
.cal-cell .dnum { font-size: 11px; color: var(--muted); }
.cal-cell .pnl { font-size: 13px; font-weight: 700; margin-top: 3px; word-break: break-all; }
.pos { color: var(--green); }
.neg { color: var(--red); }

.day-detail { margin-top: 16px; }
.day-detail h2, .card h2 { font-size: 15px; margin: 0 0 8px; }

/* 一覧行 */
.trade-row, .pool-row, .tag-row {
  background: var(--card); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 8px;
}
.trade-row { cursor: pointer; }
.trade-row .t-head { display: flex; justify-content: space-between; font-weight: 700; }
.trade-row .t-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pool-row { display: flex; justify-content: space-between; align-items: center; }
.pool-row .p-sub { font-size: 12px; color: var(--muted); }
.tag-row { display: flex; justify-content: space-between; align-items: baseline; }
.tag-row .tag-name { font-weight: 600; }
.tag-row .tag-sub { font-size: 12px; color: var(--muted); }
.empty-note { color: var(--muted); font-size: 13px; padding: 6px 2px; }

/* 集計 */
.card {
  background: var(--card); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px; margin-bottom: 12px;
}
.card-head { display: flex; justify-content: space-between; align-items: center; }
.summary-list { margin: 0; }
.summary-list > div { display: flex; justify-content: space-between; padding: 4px 0; }
.summary-list dt { color: var(--muted); }
.summary-list dd { margin: 0; font-weight: 700; }
.worst-tag { font-size: 13px; margin: 0 0 8px; }
.small-btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; cursor: pointer;
}
.del-btn {
  border: none; background: transparent; color: var(--red); font-size: 16px; cursor: pointer; padding: 4px 6px;
}

/* タブバー / FAB */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; background: var(--card); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
.tab {
  flex: 1; padding: 14px 0; font-size: 15px; border: none; background: transparent;
  color: var(--muted); cursor: pointer;
}
.tab.active { color: var(--text); font-weight: 700; }
.fab {
  position: fixed; right: 16px; bottom: calc(76px + env(safe-area-inset-bottom));
  width: 56px; height: 56px; border-radius: 50%; border: none; z-index: 21;
  background: var(--accent); color: var(--bg); font-size: 28px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.25);
}

/* モーダル */
.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal.hidden { display: none; }
.modal-sheet {
  background: var(--card); width: 100%; max-width: 560px; max-height: 92vh; overflow-y: auto;
  border-radius: 16px 16px 0 0; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.modal-head h2 { font-size: 16px; margin: 0; }
.close-btn { border: none; background: transparent; color: var(--text); font-size: 18px; cursor: pointer; padding: 6px; }
form label { display: block; font-size: 13px; color: var(--muted); margin-top: 12px; }
form input, form select {
  width: 100%; margin-top: 4px; padding: 10px; font-size: 16px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text);
}
.row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.segmented { display: flex; gap: 8px; margin-top: 14px; }
.segmented .seg {
  flex: 1; padding: 10px; font-size: 15px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted);
}
.segmented .seg.active { background: var(--accent); color: var(--bg); font-weight: 700; }
.stock-results { margin-top: 6px; }
.stock-result {
  width: 100%; text-align: left; padding: 10px 12px; margin-bottom: 6px; cursor: pointer;
  background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px;
}
.stock-result .code { font-weight: 700; margin-right: 8px; }
.profit-preview { font-size: 14px; margin: 16px 0 4px; }
.primary-btn {
  width: 100%; margin-top: 12px; padding: 13px; font-size: 16px; font-weight: 700;
  border: none; border-radius: 10px; background: var(--accent); color: var(--bg); cursor: pointer;
}
.danger-btn {
  width: 100%; margin-top: 10px; padding: 11px; font-size: 14px;
  border: 1px solid var(--red); border-radius: 10px; background: transparent; color: var(--red); cursor: pointer;
}
.hidden { display: none !important; }
