/* 案件管理アプリ — KORACLOUD 共通テーマ（../common/kc-theme.css）の変数で配色 */
:root {
  --row-alt: rgba(255,255,255,0.015);
  --row-lost: rgba(122,131,148,0.10);
  --header-bg: var(--surface2);
  --ok: var(--accent);
  --plan: var(--warn);
}

body.kc { font-size: 14px; }
#app { display: flex; flex-direction: column; min-height: 100vh; }

/* ---- ヘッダー（データ接続） ---- */
.data-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 20px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.data-bar .grow { flex: 1; }
.btn { /* 旧クラス名を共通ボタンに寄せる */
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font-family: var(--font-display); font-weight: 600; font-size: 13px; letter-spacing: .03em;
  border: 1px solid var(--border-strong); background: transparent; color: var(--text);
  padding: 7px 14px; border-radius: var(--radius); transition: opacity .2s, border-color .2s, color .2s, background .2s;
}
.btn:hover { border-color: rgba(255,255,255,.3); color: var(--white); }
.btn:disabled { opacity: .35; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--black); }
.btn-primary:hover { opacity: .85; color: var(--black); border-color: var(--accent); }
.btn-danger { color: var(--danger); }

.status { font-size: 12px; color: var(--muted); }
.status.ok { color: var(--accent); }
.status.saving { color: var(--warn); }
.status.error { color: var(--danger); }

.tabs { display: flex; gap: 2px; padding: 0 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-btn {
  border: none; background: none; cursor: pointer; white-space: nowrap;
  font-family: var(--font-display); font-weight: 600; font-size: 14px; color: var(--muted);
  padding: 12px 16px; border-bottom: 2px solid transparent;
}
.tab-btn:hover { color: var(--white); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }

main { flex: 1; overflow: auto; padding: 18px 20px 40px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.panel-toolbar input[type="text"] { min-width: 260px; }

/* ---- シート風テーブル ---- */
.table-scroll { overflow: auto; max-width: 100%; border: 1px solid var(--border); border-radius: var(--radius-card); background: var(--surface); }
table.sheet-table { border-collapse: collapse; width: 100%; min-width: 900px; }
.sheet-table thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--header-bg); color: var(--muted);
  font-family: var(--font-mono); font-weight: 500; font-size: 11px; letter-spacing: .06em;
  padding: 10px 8px; text-align: left; white-space: nowrap;
  border-bottom: 1px solid var(--border-strong); border-right: 1px solid var(--border);
}
.sheet-table td { border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); padding: 0; vertical-align: middle; }
.sheet-table tbody tr:nth-child(even) { background: var(--row-alt); }
.sheet-table tbody tr:hover { background: var(--surface2); }
.sheet-table tbody tr.row-lost { background: var(--row-lost); color: var(--muted); }
.kc .sheet-table td input, .kc .sheet-table td select {
  width: 100%; min-width: 0; border-radius: 0 !important; border: none; background: transparent; padding: 8px 8px;
  font-size: 13px; font-family: inherit; color: inherit; color-scheme: dark; border-radius: 0;
}
.sheet-table td select option { background: var(--surface2); }
.kc .sheet-table td input:focus, .kc .sheet-table td select:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: var(--surface3); }
.sheet-table td input[type="number"] { text-align: right; font-variant-numeric: tabular-nums; }
.sheet-table td.readonly-cell { padding: 8px; color: var(--muted); white-space: nowrap; }
#revenueTable { min-width: 1560px; }
#projectsTable { min-width: 1280px; }
.sheet-table td.total-cell { padding: 8px; text-align: right; font-weight: 600; color: var(--white); font-variant-numeric: tabular-nums; }
.month-col { width: 90px; }
.sheet-table tfoot td { border-top: 1px solid var(--border-strong); border-right: 1px solid var(--border); padding: 8px; background: var(--surface2); font-weight: 600; text-align: right; color: var(--white); white-space: nowrap; font-variant-numeric: tabular-nums; }
.sheet-table tfoot td.foot-label { text-align: left; }
.sheet-table tfoot tr.foot-target td { font-weight: 500; color: var(--muted); }
.sheet-table tfoot tr.foot-gap td { background: var(--surface); font-size: 12.5px; }
.sheet-table tfoot td.gap-plus, .gap-plus { color: var(--accent); }
.sheet-table tfoot td.gap-minus, .gap-minus { color: var(--danger); }

.row-del-btn { border: none; background: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 4px 8px; border-radius: 3px; }
.row-del-btn:hover { background: var(--danger-bg); color: var(--danger); }

.master-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.master-block h2 { font-size: 15px; margin: 4px 0 10px; }
.master-block .sheet-table { min-width: 0; }

.help-content { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 22px 28px; max-width: 860px; }
.help-content li { margin-bottom: 8px; line-height: 1.8; color: var(--text); }
.help-content b { color: var(--white); }
.help-content code { background: var(--surface3); color: var(--accent); padding: 1px 6px; border-radius: 3px; font-family: var(--font-mono); font-size: 12px; }

/* ---- セグメント ---- */
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius); overflow: hidden; }
.seg-btn { border: none; background: none; padding: 6px 14px; cursor: pointer; font-size: 12px; font-weight: 600; font-family: var(--font-display); color: var(--muted); border-left: 1px solid var(--border-strong); }
.seg-btn:first-child { border-left: none; }
.seg-btn:hover { color: var(--white); }
.seg-btn.active { background: var(--accent-12); color: var(--accent); }
.btn-link { border: none; background: none; color: var(--accent); padding: 4px 6px; font-size: 12.5px; cursor: pointer; }
.btn-link:hover { color: var(--white); background: none; }

/* 計画モードは表をアンバーで縁取りして、実績との取り違えを防ぐ */
.tab-panel.mode-plan .table-scroll { box-shadow: inset 0 0 0 2px rgba(224,176,74,.45); }
.tab-panel.mode-plan .sheet-table thead th { background: rgba(224,176,74,.14); color: var(--warn); }

/* ---- 目標設定 ---- */
.target-panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 12px 16px; margin-bottom: 12px; }
.target-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.target-annual-field { font-weight: 600; color: var(--white); }
.target-annual-field input { width: 160px; text-align: right; }
.target-annual-field .unit { font-weight: 400; color: var(--muted); }
.target-note { font-size: 12px; color: var(--muted); }
.target-note.warn { color: var(--warn); }
.target-months { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; margin-top: 12px; }
.target-month { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--muted); }
.target-month input { text-align: right; width: 100%; padding: 5px 8px; }
.target-month.is-auto input { color: var(--muted); }
.target-month:not(.is-auto) input { border-color: var(--accent); font-weight: 600; color: var(--white); }
.target-hint { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* ---- ダッシュボード ---- */
#dashBody { display: flex; flex-direction: column; gap: 14px; max-width: 1400px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 16px 18px; }
.viz-card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--white); font-family: var(--font-display); }
.dash-top { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: stretch; }
.hero-card { display: flex; flex-direction: column; justify-content: center; position: relative; overflow: hidden; }
.hero-card::after { content: ""; position: absolute; width: 360px; height: 360px; right: -160px; top: -160px; background: radial-gradient(circle, rgba(46,204,142,.12) 0%, transparent 70%); pointer-events: none; }
.hero-figure { font-family: var(--font-display); font-size: 52px; font-weight: 600; line-height: 1.05; margin: 6px 0 12px; color: var(--white); }
.hero-gap { font-size: 14px; font-weight: 600; margin-top: 10px; }
.hero-note { font-size: 12px; color: var(--muted); margin-top: 4px; }
.meter { height: 8px; border-radius: 99px; background: var(--surface3); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 99px; transition: width .2s ease; }
.kpi-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-card); padding: 14px 16px; }
.stat-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: .08em; color: var(--muted); }
.stat-value { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-top: 4px; color: var(--white); font-variant-numeric: tabular-nums; }
.stat-sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.viz-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.viz-svg { width: 100%; height: auto; display: block; overflow: visible; }
.viz-tick { font-size: 10.5px; fill: var(--muted); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.viz-cat { font-size: 11.5px; fill: var(--text); font-family: var(--font-body); }
.viz-value { font-size: 11px; fill: var(--text); font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.viz-svg [data-tip] { cursor: default; }
.viz-svg [data-tip]:hover { opacity: .82; }
.viz-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.viz-legend-item { display: inline-flex; align-items: center; gap: 6px; }
.viz-legend-item b { font-weight: 600; color: var(--white); font-variant-numeric: tabular-nums; }
.viz-swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; flex: none; }
.viz-swatch.is-dash { height: 0; width: 14px; border-radius: 0; border-top: 2px dashed var(--text); background: none !important; }
.viz-empty { padding: 26px 10px; text-align: center; color: var(--muted); font-size: 13px; }
.viz-tip { position: fixed; z-index: 100; pointer-events: none; background: var(--surface3); color: var(--white); border: 1px solid var(--border-strong); padding: 6px 10px; border-radius: 6px; font-size: 12px; line-height: 1.5; max-width: 260px; box-shadow: var(--shadow); }
.dash-foot { font-size: 12px; color: var(--muted); margin: 0 0 4px; }

/* デモ案内 */
.demo-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 20px 0; padding: 12px 16px; border: 1px solid var(--accent-30); background: var(--accent-08); border-radius: var(--radius-card); font-size: 13px; }
.demo-banner b { color: var(--accent); }

@media (max-width: 1180px) { .dash-top { grid-template-columns: 1fr; } .viz-grid-2 { grid-template-columns: 1fr; } }
@media (max-width: 900px) {
  .master-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .target-months { grid-template-columns: repeat(3, 1fr); }
  .data-bar, .tabs, main { padding-left: 14px; padding-right: 14px; }
}
