/* ═══════════════════════════════════════════════════════
   style.css — 全体スタイル
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@300;400;500;700&family=DM+Mono:wght@400;500&display=swap');

/* ── CSS変数 ─────────────────────────────────────────── */
:root {
  --bg:    #0d0f14;
  --sf:    #161922;
  --sf2:   #1e2330;
  --bd:    #2a3045;
  --tx:    #e8eaf0;
  --tx2:   #8892a4;
  --tx3:   #4a5568;
  --curr:  #e84040;
  --cdemo: #f5b942;
  --prev:  #4f9cf9;
  --pdemo: #a3c4f0;
  --grn:   #10b981;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Noto Sans JP', sans-serif; background: var(--bg); color: var(--tx); min-height: 100vh; }

/* ── 認証画面 ────────────────────────────────────────── */
#auth-screen { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 24px; }
.auth-card   { background: var(--sf); border: 1px solid var(--bd); border-radius: 16px; padding: 48px 40px; max-width: 400px; width: 100%; text-align: center; }
.auth-logo   { font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: .12em; color: var(--curr); background: rgba(232,64,64,.1); border: 1px solid rgba(232,64,64,.3); padding: 3px 9px; border-radius: 4px; display: inline-block; margin-bottom: 24px; }
.auth-title  { font-size: 20px; font-weight: 500; margin-bottom: 8px; }
.auth-sub    { font-size: 12px; color: var(--tx2); line-height: 1.7; margin-bottom: 32px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.auth-divider::before,
.auth-divider::after { content: ''; flex: 1; height: 1px; background: var(--bd); }
.auth-divider span   { font-size: 11px; color: var(--tx3); }
.auth-domain  { font-size: 11px; color: var(--tx3); margin-top: 16px; }
.auth-domain span { color: var(--curr); }
.auth-error  { background: rgba(232,64,64,.08); border: 1px solid rgba(232,64,64,.3); border-radius: 8px; padding: 12px 16px; font-size: 12px; color: #ff6b6b; margin-top: 16px; display: none; text-align: left; line-height: 1.6; }
.google-signin-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 11px 20px; background: #fff; color: #3c4043; border: 1px solid #dadce0; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer; transition: box-shadow .2s, background .2s; font-family: 'Noto Sans JP', sans-serif; }
.google-signin-btn:hover { background: #f8f9fa; box-shadow: 0 1px 3px rgba(0,0,0,.2); }

/* ── ヘッダー ────────────────────────────────────────── */
.header        { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px; border-bottom: 1px solid var(--bd); background: var(--sf); position: sticky; top: 0; z-index: 200; }
.header-left   { display: flex; align-items: center; gap: 12px; }
.logo          { font-family: 'DM Mono', monospace; font-size: 11px; font-weight: 500; letter-spacing: .12em; color: var(--curr); background: rgba(232,64,64,.1); border: 1px solid rgba(232,64,64,.3); padding: 3px 9px; border-radius: 4px; }
.header-title  { font-size: 14px; font-weight: 500; }
.header-right  { display: flex; align-items: center; gap: 12px; }
.user-badge    { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border: 1px solid var(--bd); border-radius: 20px; background: var(--sf2); }
.user-avatar   { width: 22px; height: 22px; border-radius: 50%; object-fit: cover; }
.user-avatar-placeholder { width: 22px; height: 22px; border-radius: 50%; background: var(--curr); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; color: #fff; }
.user-name     { font-size: 11px; color: var(--tx2); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-logout    { font-size: 11px; color: var(--tx3); background: none; border: none; cursor: pointer; padding: 2px 4px; transition: color .15s; }
.btn-logout:hover { color: var(--curr); }

/* ── アップロード画面 ────────────────────────────────── */
#upload-screen { max-width: 640px; margin: 60px auto; padding: 0 24px; display: none; }
.upload-title  { font-size: 20px; font-weight: 500; margin-bottom: 6px; }
.upload-sub    { font-size: 12px; color: var(--tx2); margin-bottom: 36px; line-height: 1.7; }
.upload-cards  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 24px; }
.upload-card   { background: var(--sf); border: 1.5px dashed var(--bd); border-radius: 12px; padding: 22px 18px; cursor: pointer; transition: all .2s; position: relative; text-align: left; }
.upload-card:hover     { border-color: var(--curr); background: rgba(232,64,64,.04); }
.upload-card.loaded    { border-style: solid; border-color: var(--grn); background: rgba(16,185,129,.05); }
.upload-card input     { display: none; }
.uc-num   { font-family: 'DM Mono', monospace; font-size: 10px; color: var(--curr); margin-bottom: 7px; letter-spacing: .1em; }
.uc-title { font-size: 13px; font-weight: 500; margin-bottom: 5px; }
.uc-desc  { font-size: 11px; color: var(--tx2); line-height: 1.6; }
.uc-status { font-size: 11px; margin-top: 10px; }
.uc-wait  { color: var(--tx3); }
.uc-ok    { color: var(--grn); }
.uc-err   { color: var(--curr); }
.uc-check { position: absolute; top: 10px; right: 10px; width: 18px; height: 18px; background: var(--grn); border-radius: 50%; display: none; align-items: center; justify-content: center; font-size: 10px; }
.upload-card.loaded .uc-check { display: flex; }
.btn-run  { background: var(--curr); color: #fff; border: none; padding: 13px 36px; border-radius: 8px; font-family: 'Noto Sans JP', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: opacity .2s; letter-spacing: .04em; }
.btn-run:disabled    { opacity: .3; cursor: not-allowed; }
.btn-run:hover:not(:disabled) { opacity: .85; }
.demo-btn { margin-top: 10px; background: none; border: 1px solid var(--bd); color: var(--tx2); padding: 8px 20px; border-radius: 6px; cursor: pointer; font-family: 'Noto Sans JP', sans-serif; font-size: 12px; }

/* ── ページタブ ──────────────────────────────────────── */
#page-tabs { display: flex; gap: 2px; padding: 12px 28px 0; background: var(--sf); border-bottom: 1px solid var(--bd); overflow-x: auto; }
.page-tab  { padding: 8px 18px; border-radius: 6px 6px 0 0; border: 1px solid transparent; background: none; color: var(--tx2); font-family: 'Noto Sans JP', sans-serif; font-size: 12px; cursor: pointer; white-space: nowrap; transition: all .15s; border-bottom: none; }
.page-tab:hover  { color: var(--tx); background: var(--sf2); }
.page-tab.active { background: var(--bg); color: var(--tx); border-color: var(--bd); border-bottom-color: var(--bg); }

/* ── ダッシュボード ──────────────────────────────────── */
#dashboard   { display: none; }
.dash-content { padding: 24px 28px; }

/* ── 共通 ────────────────────────────────────────────── */
.section-label { font-size: 11px; color: var(--tx2); letter-spacing: .08em; text-transform: uppercase; margin-bottom: 10px; margin-top: 22px; }
.up   { color: var(--grn) !important; }
.down { color: #ef4444 !important; }
.btn  { padding: 5px 12px; border-radius: 5px; border: 1px solid var(--bd); background: var(--sf); color: var(--tx2); font-family: 'Noto Sans JP', sans-serif; font-size: 12px; cursor: pointer; transition: all .15s; }
.btn:hover   { border-color: var(--tx2); color: var(--tx); }
.btn.on      { background: var(--sf2); border-color: #6b7280; color: var(--tx); }
.sep  { width: 1px; height: 22px; background: var(--bd); }
.card { background: var(--sf); border: 1px solid var(--bd); border-radius: 12px; padding: 20px; margin-bottom: 16px; }
.ch   { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.ct   { font-size: 13px; font-weight: 500; }
.cs   { font-size: 11px; color: var(--tx2); margin-top: 2px; }

/* ── サマリーブロック ────────────────────────────────── */
.summary-block { border: 1px solid var(--bd); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.sb-header     { display: flex; align-items: center; gap: 10px; padding: 9px 15px; background: var(--sf2); border-bottom: 1px solid var(--bd); }
.sb-tag        { font-family: 'DM Mono', monospace; font-size: 10px; letter-spacing: .1em; text-transform: uppercase; padding: 2px 8px; border-radius: 3px; }
.tag-actual    { background: rgba(79,156,249,.15);  color: #4f9cf9; border: 1px solid rgba(79,156,249,.3); }
.tag-sim       { background: rgba(245,185,66,.15);  color: #f5b942; border: 1px solid rgba(245,185,66,.3); }
.sb-title      { font-size: 13px; font-weight: 500; }
.sb-body       { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--sf); }
.sb-kpi        { padding: 13px 16px; border-right: 1px solid var(--bd); }
.sb-kpi:last-child { border-right: none; }
.kl { font-size: 11px; color: var(--tx2); margin-bottom: 5px; }
.kv { font-family: 'DM Mono', monospace; font-size: 19px; font-weight: 500; }
.ku { font-size: 11px; color: var(--tx2); margin-left: 3px; }
.kd { font-size: 11px; margin-top: 3px; font-family: 'DM Mono', monospace; color: var(--tx3); }
.sb-note { font-size: 11px; color: var(--tx3); padding: 7px 16px 9px; background: var(--sf); border-top: 1px solid var(--bd); line-height: 1.6; }

/* ── チャートグリッド ────────────────────────────────── */
.chart-grid    { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; margin-bottom: 16px; }
.chart-wrap    { position: relative; height: 260px; }
.chart-wrap-lg { position: relative; height: 360px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; }
.li  { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--tx2); }
.ll  { width: 20px; height: 3px; border-radius: 2px; }
.ll.dash { border-top: 2px dashed; height: 0; background: none; }

/* ── テーブル ────────────────────────────────────────── */
.tbl-wrap { background: var(--sf); border: 1px solid var(--bd); border-radius: 12px; overflow: hidden; margin-bottom: 14px; }
.tbl-hd   { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--bd); font-size: 13px; font-weight: 500; }
table { width: 100%; border-collapse: collapse; }
th    { padding: 8px 12px; text-align: right; font-size: 11px; font-weight: 500; color: var(--tx2); background: var(--sf2); white-space: nowrap; }
th:first-child { text-align: left; }
td    { padding: 10px 12px; text-align: right; font-size: 12px; border-top: 1px solid var(--bd); white-space: nowrap; font-family: 'DM Mono', monospace; }
td:first-child { text-align: left; font-family: 'Noto Sans JP', sans-serif; }
tr:hover td { background: rgba(79,156,249,.03); }
.dot  { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }

/* ── コントロール ────────────────────────────────────── */
.controls { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.cl { font-size: 11px; color: var(--tx2); letter-spacing: .08em; text-transform: uppercase; }
.cg { display: flex; gap: 3px; }

/* ── カラム選択モーダル ──────────────────────────────── */
.col-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 500; display: flex; align-items: center; justify-content: center; }
.col-modal-box     { background: var(--sf); border: 1px solid var(--bd); border-radius: 14px; padding: 32px 28px; width: 100%; max-width: 420px; }
.col-modal-title   { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.col-modal-sub     { font-size: 11px; color: var(--tx2); line-height: 1.7; margin-bottom: 24px; }
.col-modal-row     { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.col-modal-label   { font-size: 12px; color: var(--tx2); width: 80px; flex-shrink: 0; }
.col-modal-select  { flex: 1; background: var(--sf2); border: 1px solid var(--bd); border-radius: 6px; color: var(--tx); font-family: 'Noto Sans JP', sans-serif; font-size: 12px; padding: 7px 10px; outline: none; cursor: pointer; }
.col-modal-select:focus { border-color: var(--curr); }
.col-modal-btn     { margin-top: 20px; width: 100%; background: var(--curr); color: #fff; border: none; padding: 11px; border-radius: 8px; font-family: 'Noto Sans JP', sans-serif; font-size: 14px; font-weight: 500; cursor: pointer; transition: opacity .2s; }
.col-modal-btn:disabled { opacity: .3; cursor: not-allowed; }
.col-modal-btn:hover:not(:disabled) { opacity: .85; }
