/* かんたん経営分析 — スタイル。やさしく・大きく・色でわかる。 */
:root {
  --blue: #1e88e5;
  --red: #e53935;
  --green: #43a047;
  --ink: #243b53;
  --muted: #627d98;
  --bg: #f0f4f8;
  --card: #ffffff;
  --line: #e2e8f0;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(30, 60, 90, 0.08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", "Yu Gothic", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
}

.app-header {
  background: linear-gradient(135deg, #1e88e5, #26c6da);
  color: #fff;
  padding: 28px 20px;
  text-align: center;
}
.app-header h1 { margin: 0 0 6px; font-size: 1.9rem; }
.tagline { margin: 0; opacity: 0.95; font-size: 1rem; }

main { max-width: 1080px; margin: 0 auto; padding: 20px; }

/* ---- ドロップゾーン ---- */
.dropzone {
  background: var(--card);
  border: 3px dashed #b6cce0;
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  transition: 0.2s;
  margin-bottom: 24px;
}
.dropzone.over { border-color: var(--blue); background: #e8f3fe; }
.dropzone.compact { padding: 18px; }
.dropzone.compact .dz-icon, .dropzone.compact h2, .dropzone.compact p { display: none; }
.dz-icon { font-size: 3rem; }
.dropzone h2 { font-size: 1.3rem; margin: 10px 0; }
.dropzone p { color: var(--muted); }
.dz-buttons { margin-top: 16px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  border: none; border-radius: 10px; padding: 12px 22px;
  font-size: 1rem; font-weight: 700; cursor: pointer; transition: 0.15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: #1565c0; }
.btn-ghost { background: #eef2f7; color: var(--ink); }
.btn-ghost:hover { background: #e0e7ef; }

.status { margin-top: 14px; font-weight: 700; color: var(--green); min-height: 1.4em; }
.status.error { color: var(--red); }

.hidden { display: none; }

/* ---- レポート見出し ---- */
.report-head { display: flex; justify-content: space-between; align-items: flex-end; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.report-head h2 { margin: 0; font-size: 1.6rem; }
.period { margin: 2px 0 0; color: var(--muted); font-weight: 700; }
.month-pick { margin-top: 6px; font-weight: 700; }
.month-pick select { font-size: 1rem; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); margin-left: 4px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- ひとことコメント（信号機）---- */
.verdict-box {
  display: flex; align-items: center; gap: 18px;
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 18px 22px; margin: 14px 0 22px; border-left: 8px solid var(--green);
}
.signal { display: flex; flex-direction: column; gap: 6px; padding: 8px; background: #2b2b2b; border-radius: 10px; }
.signal span { width: 22px; height: 22px; border-radius: 50%; background: #555; }
.signal.red span:nth-child(1) { background: #ff5252; box-shadow: 0 0 12px #ff5252; }
.signal.yellow span:nth-child(2) { background: #ffd54f; box-shadow: 0 0 12px #ffd54f; }
.signal.green span:nth-child(3) { background: #69f0ae; box-shadow: 0 0 12px #69f0ae; }
.verdict-text h3 { margin: 0 0 4px; font-size: 1.3rem; }
.verdict-text p { margin: 0; color: var(--muted); }

/* ---- KPI カード ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 22px; }
.kpi-card { display: flex; gap: 14px; background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; border-top: 6px solid var(--line); }
.kpi-blue { border-top-color: var(--blue); }
.kpi-red { border-top-color: var(--red); }
.kpi-green { border-top-color: var(--green); }
.kpi-icon { font-size: 2.2rem; }
.kpi-title { font-weight: 800; font-size: 1.05rem; }
.kpi-sub { color: var(--muted); font-size: 0.85rem; }
.kpi-value { font-size: 1.7rem; font-weight: 900; margin: 6px 0; letter-spacing: -0.5px; }
.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 0.82rem; font-weight: 800; }
.badge-up { background: #e6f4ea; color: var(--green); }
.badge-down { background: #fdeaea; color: var(--red); }
.badge-flat { background: #eef2f7; color: var(--muted); }

/* ---- カード共通 ---- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; }
.card h3 { margin: 0 0 14px; font-size: 1.2rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ---- 内訳の粗さトグル ---- */
.level-toggle { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.level-label { font-weight: 700; color: var(--muted); font-size: 0.9rem; }
.level-toggle button { border: 2px solid var(--line); background: #fff; color: var(--muted); border-radius: 999px; padding: 7px 18px; font-size: 0.95rem; font-weight: 700; cursor: pointer; transition: 0.15s; }
.level-toggle button:hover { border-color: var(--blue); color: var(--blue); }
.level-toggle button.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.bd-block h4 { margin: 0 0 8px; font-size: 1.05rem; }
.bd-table { margin-top: 12px; max-height: 360px; overflow-y: auto; }
.fin-table.bd { font-size: 0.88rem; }
.fin-table.bd th { font-weight: 600; }
.chart-wrap { position: relative; height: 320px; }
.chart-wrap.small { height: 240px; }

/* ---- 指標カード ---- */
.ratio-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; }
.ratio-card { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.ratio-head { display: flex; justify-content: space-between; align-items: baseline; }
.ratio-label { font-weight: 800; }
.ratio-val { font-size: 1.3rem; font-weight: 900; color: var(--blue); }
.gauge { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; margin: 8px 0; }
.gauge-fill { height: 100%; border-radius: 999px; }
.g-ok { background: var(--green); }
.g-warn { background: #ffb300; }
.ratio-desc { font-size: 0.85rem; color: var(--ink); }
.ratio-hint { font-size: 0.78rem; color: var(--muted); margin-top: 4px; }

/* ---- 財務テーブル ---- */
.fin-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.fin-table th, .fin-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); text-align: left; }
.fin-table thead th { background: #eef4fb; font-size: 0.85rem; color: var(--muted); }
.fin-table td { text-align: right; font-variant-numeric: tabular-nums; }
.fin-table td.neg, .fin-table .neg { color: var(--red); }
.fin-table .row-indent th { font-weight: 400; color: var(--muted); }
.fin-table .row-bold th, .fin-table .row-bold td { font-weight: 800; }
.fin-table .row-total { background: #f7fbf8; }
.fin-table .row-total td { border-top: 2px solid #cde3d3; }

.fin-table .row-section th { background: #eef4fb; font-weight: 800; color: var(--ink); padding-top: 12px; }
.fin-table td.muted { color: var(--muted); font-weight: 400; }
.cf-table th { text-align: left; }
.cf-table td { font-weight: 700; }

.note { font-size: 0.85rem; color: var(--muted); background: #fff8e1; border-left: 4px solid #ffca28; padding: 10px 12px; border-radius: 8px; margin-top: 12px; }
.note.ok { background: #e8f5e9; border-left-color: var(--green); color: #2e7d32; }

/* ---- 役割エディタ ---- */
.role-editor { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; }
.role-editor summary { cursor: pointer; font-weight: 700; color: var(--blue); padding: 4px; }
.role-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; margin-top: 10px; max-height: 320px; overflow-y: auto; }
.role-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px; border-bottom: 1px solid #f0f4f8; }
.role-name { flex: 1; font-size: 0.9rem; }
.role-avg { font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.role-row select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 0.85rem; }

.app-footer { text-align: center; color: var(--muted); font-size: 0.82rem; padding: 24px; }

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .app-header h1 { font-size: 1.5rem; }
}

/* ---- 印刷 ---- */
@media print {
  .dropzone, .app-footer, #printBtn, .dz-buttons { display: none !important; }
  body { background: #fff; }
  .card, .kpi-card, .verdict-box { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
}
