/* ============================================================
   ウリカイ - T1 ダッシュボード
   app.css のデザイントークンを踏襲。
============================================================ */

.dash { max-width: 1180px; }

/* ---------- KPIカード ---------- */
.dash-kpi {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}
.dash-kpi-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}
.dash-kpi-card.dash-kpi-action {
  cursor: pointer;
  border-color: var(--color-primary);
  background: linear-gradient(180deg, var(--color-primary-bg) 0%, #fff 60%);
}
.dash-kpi-card.dash-kpi-action:hover { box-shadow: var(--shadow-lg); }

.kpi-label { font-size: 12.5px; color: var(--color-text-sub); font-weight: 500; }
.kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
  margin-top: 6px;
  line-height: 1.1;
  letter-spacing: -0.02em;
}
.kpi-unit { font-size: 15px; font-weight: 600; color: var(--color-text-sub); margin-left: 3px; }
.kpi-sub { font-size: 12px; color: var(--color-text-muted); margin-top: 8px; line-height: 1.5; }

.kpi-delta { font-weight: 600; }
.kpi-delta-up { color: var(--color-success); }
.kpi-delta-down { color: var(--color-danger); }
.kpi-delta-flat { color: var(--color-text-muted); }

/* ---------- 2カラム ---------- */
.dash-cols {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.dash-panel {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.dash-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.dash-panel-head h2 { margin: 0; font-size: 15px; font-weight: 700; }
.dash-panel-sub { font-size: 12px; color: var(--color-text-muted); }
.dash-empty {
  padding: 28px 12px;
  text-align: center;
  font-size: 13px;
  color: var(--color-text-muted);
}

/* ---------- 月次売上グラフ ---------- */
.dash-chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 200px;
  padding-top: 8px;
}
.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}
.chart-amt {
  font-size: 11px;
  color: var(--color-text-sub);
  margin-bottom: 6px;
  white-space: nowrap;
}
.chart-bar-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.chart-bar {
  width: 60%;
  max-width: 46px;
  min-height: 3px;
  background: #BFD9CB;
  border-radius: 5px 5px 0 0;
  transition: background 0.15s ease;
}
.chart-col.is-current .chart-bar { background: var(--color-primary); }
.chart-col.is-current .chart-amt { color: var(--color-primary); font-weight: 700; }
.chart-month { font-size: 12px; color: var(--color-text-sub); margin-top: 8px; }
.chart-col.is-current .chart-month { color: var(--color-primary); font-weight: 600; }

/* ---------- 承認待ちアクション ---------- */
.dash-action-list { list-style: none; margin: 0; padding: 0; }
.dash-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.dash-action:hover { background: var(--color-primary-bg); border-color: var(--color-primary); }
.dash-action-main { min-width: 0; }
.dash-action-no { font-weight: 700; font-size: 13px; }
.dash-action-title {
  display: block;
  font-size: 12.5px;
  color: var(--color-text-sub);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 220px;
}
.dash-action-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  font-size: 12.5px;
}
.dash-action-client { color: var(--color-text-muted); }
.dash-action-amt { font-weight: 600; }
.dash-action-more {
  list-style: none;
  text-align: center;
  font-size: 12.5px;
  color: var(--color-primary);
  padding: 8px;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.dash-action-more:hover { background: var(--color-primary-bg); }

/* 見積ステータスバッジ（quotes.css 未読込時のフォールバックも兼ねる） */
.q-status { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.q-status-draft { background: #EEF0F3; color: var(--color-text-muted); }
.q-status-pending { background: var(--color-dev-bg); color: var(--color-dev); }
.q-status-approved { background: var(--color-success-bg); color: var(--color-success); }
.q-status-rejected { background: var(--color-danger-bg); color: var(--color-danger); }

/* ---------- アラート ---------- */
.dash-alerts {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.alert-tile {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  background: #FAFBFC;
}
.alert-tile.is-active { background: #fff; }
.alert-tile-overdue.is-active { border-color: var(--color-danger); }
.alert-tile-unbilled.is-active { border-color: var(--color-dev); }
.alert-tile-expired.is-active { border-color: var(--color-text-sub); }

.alert-tile-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.alert-count { font-size: 26px; font-weight: 700; line-height: 1; }
.alert-tile-overdue.is-active .alert-count { color: var(--color-danger); }
.alert-tile-unbilled.is-active .alert-count { color: var(--color-dev); }
.alert-unit { font-size: 13px; font-weight: 600; margin-left: 2px; color: var(--color-text-sub); }
.alert-label { font-size: 12.5px; color: var(--color-text-sub); line-height: 1.4; }
.alert-total { font-weight: 700; color: var(--color-text); font-size: 13px; }

.alert-list { list-style: none; margin: 0 0 8px; padding: 0; }
.alert-list li {
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  border-top: 1px solid var(--color-border);
  font-size: 12.5px;
}
.alert-list li > span:first-child { font-weight: 600; }
.alert-li-sub { color: var(--color-text-muted); font-size: 11.5px; margin-top: 1px; }
.alert-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  color: var(--color-dev);
  background: var(--color-dev-bg);
  padding: 1px 6px;
  border-radius: 999px;
  margin-left: 4px;
}
.alert-empty { font-size: 12.5px; color: var(--color-text-muted); padding: 6px 0; }
.alert-link {
  background: transparent;
  border: none;
  color: var(--color-primary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0 0;
}
.alert-link:hover { text-decoration: underline; }

/* ---------- 受注管理（確度パイプライン） ---------- */
.deal-kpi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.deal-kpi-card {
  background: #fff;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.deal-kpi-card > span { font-size: 12px; color: var(--color-text-sub); }
.deal-kpi-card > strong { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.deal-kpi-card > em { font-size: 11.5px; color: var(--color-text-muted); font-style: normal; }

.deal-select {
  font-family: inherit;
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  /* 選択肢の最長文言（受注（要紐づけ）等）で幅が広がらないよう固定 */
  width: 96px;
}
.deal-select:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(21,115,71,0.12); }
.deal-select-won    { background: var(--color-success-bg); color: var(--color-success); border-color: var(--color-success); }
.deal-select-high   { background: #E6F1FB; color: #0C447C; border-color: #9CC3E6; }
.deal-select-medium { background: var(--color-dev-bg); color: var(--color-dev); border-color: #E0C088; }
.deal-select-low    { background: #EEF0F3; color: var(--color-text-sub); }
.deal-select-lost   { background: var(--color-danger-bg); color: var(--color-danger); border-color: #E0A0A0; }
.deal-select-none   { background: #fff; color: var(--color-text-muted); }

/* 顧客発注書アップロードのモーダル内一覧 */
.po-list { list-style: none; margin: 0; padding: 0; }
.po-list li { padding: 8px 0; border-top: 1px solid var(--color-border); font-size: 13px; }
.po-list li:first-child { border-top: none; }
.po-list a { color: var(--color-primary); font-weight: 600; word-break: break-all; }
.po-meta { color: var(--color-text-muted); font-size: 11.5px; margin-left: 8px; }

/* 顧客発注書: ドラッグ&ドロップ アップロード領域 */
.po-drop {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.po-drop.is-dragover { border-color: var(--color-primary); background: var(--color-primary-bg); }
.po-drop-text { margin: 0 0 10px; font-size: 13px; color: var(--color-text-sub); line-height: 1.6; }
.po-filename { margin-top: 8px; font-size: 12.5px; color: var(--color-text-muted); min-height: 1.2em; word-break: break-all; }

/* 案件管理: 進捗ステージのバッジ（見積→入金） */
.prog { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.prog-draft     { background: #EEF0F3; color: var(--color-text-muted); }
.prog-pending   { background: var(--color-dev-bg); color: var(--color-dev); }
.prog-rejected  { background: var(--color-danger-bg); color: var(--color-danger); }
.prog-lost      { background: #EEF0F3; color: var(--color-text-sub); }
.prog-approved  { background: #E6F1FB; color: #0C447C; }
.prog-won       { background: #E1F5EE; color: #0F6E56; }
.prog-delivered { background: #FAEEDA; color: #854F0B; }
.prog-invoiced  { background: #EEEDFE; color: #3C3489; }
.prog-paid      { background: var(--color-success-bg); color: var(--color-success); border: 1px solid var(--color-success); }

/* 受注行の発注関連ボタン群 */
.deal-actions { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }

/* 仕入先発注モーダルの仕入先グループ */
.so-group { margin-bottom: 18px; }
.so-group-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.so-group-btns { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 1080px) {
  .dash-kpi { grid-template-columns: repeat(2, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .dash-alerts { grid-template-columns: 1fr; }
  .deal-kpi { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dash-kpi { grid-template-columns: 1fr; }
}
