/* =========================
   基本トークン（ライト基準）
   ========================= */
:root {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e5e7eb;

  --profit: #2a7bff;
  --loss: #ef4444;

  --accent-blue: #1769ff;
  --accent-blue-weak: #eaf1ff;

  --card-bg: #ffffff;
  --shadow: 0 6px 20px rgba(0,0,0,.06);

  --today-bg: #fff3cd; /* ライト時の今日セル背景 */
}

/* =========================
   自動ダークモード（OS依存）
   ========================= */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #121a2b;
    --text: #e6edf6;
    --muted: #93a0b5;
    --border: #1e2a3f;

    --profit: #2a7bff;
    --loss: #f87171;

    --accent-blue: #2a7bff;
    --accent-blue-weak: #0f1c33;

    --card-bg: #0f1628;
    --shadow: 0 6px 20px rgba(0,0,0,.35);

    --today-bg: #333a20; /* ダーク時の今日セル背景 */
  }
}

/* =========================
   強制オーバーライド（管理画面の選択）
   ========================= */
html.myfx-theme-light {
  --bg: #ffffff;
  --surface: #f7f8fa;
  --text: #0f172a;
  --muted: #6b7280;
  --border: #e5e7eb;

  --profit: #2a7bff;
  --loss: #ef4444;

  --accent-blue: #1769ff;
  --accent-blue-weak: #eaf1ff;

  --card-bg: #ffffff;
  --shadow: 0 6px 20px rgba(0,0,0,.06);

  --today-bg: #fff3cd;
}

html.myfx-theme-dark {
  --bg: #0b1020;
  --surface: #121a2b;
  --text: #e6edf6;
  --muted: #93a0b5;
  --border: #1e2a3f;

  --profit: #2a7bff;
  --loss: #f87171;

  --accent-blue: #2a7bff;
  --accent-blue-weak: #0f1c33;

  --card-bg: #0f1628;
  --shadow: 0 6px 20px rgba(0,0,0,.35);

  --today-bg: #333a20;
}

/* =========================
   レイアウトとスタイル
   ========================= */
html, body {
  background: var(--bg);
  color: var(--text);
}

/*.calendar-container {
  max-width: 400px;
  margin: 24px auto 48px;
  padding: 12px 16px 0;
  background: color-mix(in srgb, var(--surface) 60%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}*/

/* === containerの枠/影を無くす === */
.calendar-container {
  max-width: 400px;
  margin: 24px auto 48px;
  padding: 0;                     /* 余白も最小化 */
  background: transparent;        /* 背景なし */
  border: none;                   /* 枠線なし */
  box-shadow: none;               /* 影なし */
}

/* ヘッダー */
.calendar-header {
  background: var(--accent-blue);
  color: #fff;
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  /*position: sticky;*/
  top: 0;
  z-index: 10;
}
.calendar-title {
  flex: 1;
  text-align: center;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .02em;
}
.calendar-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  transition: background .2s ease;
}
.calendar-btn:hover { background: rgba(255,255,255,0.25); }
.calendar-btn:active { background: rgba(255,255,255,0.35); }
@media (min-width: 641px) {
  .calendar-header { padding: 12px 14px; min-height: 48px; }
  .calendar-title { font-size: 18px; }
}

/* テーブル */
.calendar-container table {
  width: 100%;
  /*max-width: 360px;*/
  max-width: 100%;
  margin: 0 auto;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 11px;
  background: var(--card-bg);
  box-shadow: var(--shadow);
  border-radius: 10px;
  overflow: hidden;
}
.calendar-container th,
.calendar-container td {
  background: var(--card-bg);
  border: 1px solid var(--border);
  height: 40px;
  text-align: center;
  vertical-align: middle;
  padding: 4px;
}

/* 今日セルは変数ベース */
.calendar-container td.today {
  background-color: var(--today-bg) !important;
}

/* 金額色 */
.calendar-container .profit { color: var(--profit); font-weight: 700; }
.calendar-container .loss   { color: var(--loss); font-weight: 700; }

/* 合計/注釈 */
.month-total {
  margin: 12px 4px 6px;
  font-size: 16px;
  font-weight: 700;
}
.rate-note {
  text-align: center;
  font-size: 12px;
  color: #666;
  margin-top: 8px;
}
@media (prefers-color-scheme: dark) {
  .rate-note { color: var(--muted); }
}

/* ===== ea-card 上書き（最終定義） ===== */
.ea-summary .ea-card {
  background: var(--card-bg) !important;
  border: 1px solid var(--border) !important;
  border-radius: 14px !important;
  padding: 14px !important;
  box-shadow: var(--shadow) !important;
  color: var(--text) !important;
  transition: background .2s ease, border-color .2s ease;
  /* レイアウトを縦積みにしている場合の間隔 */
  margin-bottom: 12px;
}

.ea-summary .ea-header {
  display: flex;
  align-items: center;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}

.ea-summary .ea-icon {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-right: 6px; /* gap を使わない版 */
}

.ea-summary .ea-values div {
  display: flex; justify-content: space-between;
  padding: 6px 0;
  color: var(--text);
}

.ea-summary .profit { color: var(--profit) !important; font-weight: 700; }
.ea-summary .loss   { color: var(--loss)   !important; font-weight: 700; }

/* ダウンロード行の見た目 */
.download-row {
  display: flex;
  justify-content: center;
  margin: 10px 0 16px;
}
.download-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
  font-size: 13px;
}
.download-btn:active { transform: translateY(1px); }