/* =========================================================
   Salon Finance — 美容室向け 社内PL・経営管理システム
   デザイン: 白/ライトグレー基調・余白重視・数字を大きく
   ========================================================= */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e6e8ec;
  --border-strong: #d4d8de;
  --text: #1b1f27;
  --text-2: #5b6472;
  --text-3: #8a93a1;
  --accent: #2f4858;       /* 上品なダークスレート */
  --accent-soft: #e8eef2;
  --gold: #b08d57;         /* アクセント（控えめ） */
  --gold-soft: #f6efe3;
  --positive: #1f8a5b;
  --positive-soft: #e6f4ec;
  --negative: #c4453c;
  --negative-soft: #fbe9e7;
  --warning: #b7791f;
  --warning-soft: #fdf3e1;
  --forecast: #6b6fd1;
  --forecast-soft: #ecedfb;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 32, 0.04), 0 4px 16px rgba(20, 24, 32, 0.04);
  --sidebar-w: 236px;
  --font: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
  --mono: 'Roboto Mono', 'SFMono-Regular', Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- レイアウト ---------- */
#app-root { display: block; width: 100%; }
.app { display: flex; min-height: 100vh; width: 100%; max-width: 100vw; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column; gap: 6px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #4b6a80);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--text-3); }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 500; font-size: 13.5px;
  transition: background .15s, color .15s; cursor: pointer;
}
.nav-item i { width: 18px; text-align: center; color: var(--text-3); font-size: 13px; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); }
.nav-item.active i { color: var(--accent); }
.nav-section { font-size: 11px; color: var(--text-3); padding: 14px 12px 4px; letter-spacing: .06em; text-transform: uppercase; }
.sidebar-footer { margin-top: auto; padding: 10px 12px; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow-x: clip; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 28px; background: rgba(246,247,249,.9); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20; border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.page-title { font-size: 20px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.company-chip { font-size: 12px; color: var(--text-2); background: var(--surface); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.period { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; }

.content { padding: 8px 28px 56px; max-width: 1360px; width: 100%; margin: 0 auto; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.section-title { font-size: 15px; font-weight: 600; }
.section-sub { font-size: 12px; color: var(--text-3); }

/* ---------- カード ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px;
}
.card + .card { margin-top: 16px; }
.card { min-width: 0; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.card-title { font-size: 14px; font-weight: 600; }
.card-meta { font-size: 12px; color: var(--text-3); }
.grid { display: grid; gap: 16px; min-width: 0; }
.grid > * { min-width: 0; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* サマリーカード（大きな数字） */
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); min-width: 0; position: relative; cursor: default;
}
.stat.clickable { cursor: pointer; transition: transform .15s, border-color .15s; }
.stat.clickable:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.stat-label { font-size: 12px; color: var(--text-2); display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 600; margin-top: 8px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 6px; display: flex; gap: 8px; flex-wrap: wrap; }
.stat-value.positive { color: var(--positive); }
.stat-value.negative { color: var(--negative); }

.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; white-space: nowrap; }
.badge-estimate { background: var(--warning-soft); color: var(--warning); }
.badge-forecast { background: var(--forecast-soft); color: var(--forecast); }
.badge-actual { background: var(--accent-soft); color: var(--accent); }
.badge-confirmed { background: var(--positive-soft); color: var(--positive); }
.badge-neutral { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.badge-negative { background: var(--negative-soft); color: var(--negative); }
.badge-sample { background: var(--gold-soft); color: var(--gold); }

.delta { font-size: 12px; font-weight: 600; }
.delta.up { color: var(--positive); }
.delta.down { color: var(--negative); }
.delta.flat { color: var(--text-3); }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text); font-weight: 500; font-size: 13px; cursor: pointer;
  transition: background .15s, border-color .15s; min-height: 38px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #253a47; }
.btn-danger { color: var(--negative); border-color: #efc7c3; }
.btn-danger:hover { background: var(--negative-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { padding: 5px 10px; min-height: 30px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; min-height: 0; border-radius: 8px; }

/* ---------- フォーム ---------- */
.form-grid { display: grid; gap: 14px 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--text-2); font-weight: 500; }
.field .hint { font-size: 11.5px; color: var(--text-3); }
.field .error { font-size: 12px; color: var(--negative); }
.field.has-error .input { border-color: var(--negative); }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface); min-height: 40px; font-size: 14px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,72,88,.12); }
textarea.input { min-height: 72px; resize: vertical; }
.input.num { text-align: right; }
.input-group { display: flex; align-items: center; gap: 8px; }
.input-group .unit { color: var(--text-3); font-size: 13px; }
select.input { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a93a1' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.select-inline { min-height: 36px; padding: 6px 30px 6px 10px; font-size: 13px; width: auto; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.form-alert { background: var(--negative-soft); color: var(--negative); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 13px; margin-bottom: 12px; }
.form-alert ul { padding-left: 16px; list-style: disc; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.checkbox input { width: 16px; height: 16px; }

/* ---------- テーブル ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius-sm); scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
.table-wrap::-webkit-scrollbar { height: 6px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table th { font-size: 11.5px; color: var(--text-3); font-weight: 600; letter-spacing: .03em; background: var(--surface-2); position: sticky; top: 0; }
.table td.num, .table th.num { text-align: right; }
.table tr.total td { font-weight: 600; background: var(--surface-2); }
.table tr.subtotal td { font-weight: 600; }
.table tr.indent td:first-child { padding-left: 28px; color: var(--text-2); }
.table tr.indent2 td:first-child { padding-left: 44px; color: var(--text-3); font-size: 12.5px; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--surface-2); }
.table td.positive, .table span.positive { color: var(--positive); }
.table td.negative, .table span.negative { color: var(--negative); }
.table td.muted { color: var(--text-3); }
.table .row-actions { display: inline-flex; gap: 4px; }
.table td .chev { color: var(--text-3); margin-right: 6px; font-size: 10px; transition: transform .15s; display: inline-block; width: 10px; }
.table tr.open td .chev { transform: rotate(90deg); }
.table tr.hidden-row { display: none; }
.table tr.pl-head td { font-weight: 600; }

/* PL 縦型構造（見る側） */
.pl-line { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border); gap: 10px; }
.pl-line:last-child { border-bottom: none; }
.pl-line .label { display: flex; align-items: center; gap: 8px; min-width: 0; }
.pl-line .amount { font-weight: 600; white-space: nowrap; }
.pl-line.total { font-size: 16px; }
.pl-line.total .amount { font-size: 20px; }
.pl-line.sub { padding-left: 20px; color: var(--text-2); font-size: 13px; border-bottom: none; padding-top: 6px; padding-bottom: 6px; }
.pl-line.sub .amount { font-weight: 500; }
.pl-line.sub2 { padding-left: 40px; color: var(--text-3); font-size: 12.5px; }
.pl-line .sign { color: var(--text-3); font-size: 12px; width: 14px; text-align: center; }
.pl-line.toggle { cursor: pointer; }
.pl-line.toggle:hover { background: var(--surface-2); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 8px; }
.pl-group { border-bottom: 1px solid var(--border); }
.pl-group:last-child { border-bottom: none; }
.pl-group .details { display: none; padding-bottom: 8px; }
.pl-group.open .details { display: block; }
.pl-divider { border-top: 2px solid var(--border-strong); margin: 6px 0; }

/* ---------- チャート ---------- */
.chart-card { padding: 18px 20px; }
.chart-box { position: relative; height: 280px; width: 100%; min-width: 0; }
.chart-box canvas { max-width: 100%; }
.chart-box.tall { height: 340px; }
.chart-box.short { height: 220px; }
.chart-legend-note { font-size: 11.5px; color: var(--text-3); margin-top: 8px; display: flex; gap: 12px; flex-wrap: wrap; }
.chart-empty { position: absolute; inset: 0; display: grid; place-items: center; color: var(--text-3); font-size: 13px; text-align: center; padding: 20px; }

/* ---------- 空状態・注意・ローディング ---------- */
.empty { padding: 28px 16px; text-align: center; color: var(--text-3); font-size: 13px; line-height: 1.7; }
.empty strong { color: var(--text-2); }
.note { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 12.5px; line-height: 1.6; }
.note i { margin-top: 2px; }
.note-warning { background: var(--warning-soft); color: #7a5211; }
.note-info { background: var(--accent-soft); color: var(--accent); }
.note-forecast { background: var(--forecast-soft); color: #4b4fa8; }
.note-danger { background: var(--negative-soft); color: var(--negative); }
.skeleton { background: linear-gradient(90deg, #eef0f3 25%, #f6f7f9 50%, #eef0f3 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: 8px; color: transparent !important; }
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.loading-block { height: 120px; border-radius: var(--radius); }

/* ---------- モーダル / トースト ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(20, 24, 32, .38); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; }
.modal { background: var(--surface); border-radius: var(--radius); width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.2); padding: 22px 24px; margin: auto; }
.modal.narrow { max-width: 440px; }
.modal.wide { max-width: 860px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 600; }
.toast-wrap { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--text); color: #fff; padding: 10px 16px; border-radius: 999px; font-size: 13px; box-shadow: var(--shadow); animation: fadein .2s; max-width: 90vw; }
.toast.error { background: var(--negative); }
.toast.success { background: var(--positive); }
@keyframes fadein { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- タブ / セグメント ---------- */
.segment { display: inline-flex; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px; gap: 2px; }
.segment button { border: none; background: transparent; padding: 6px 12px; border-radius: 999px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.segment button.active { background: var(--accent); color: #fff; }
.month-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; }
.month-strip::-webkit-scrollbar { display: none; }
.month-strip button { flex-shrink: 0; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 6px 12px; font-size: 12.5px; color: var(--text-2); cursor: pointer; }
.month-strip button.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.month-strip button.has-data::after { content: ''; display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--gold); margin-left: 6px; vertical-align: middle; }
.month-strip button.active.has-data::after { background: #fff; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: 13px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; text-align: right; font-weight: 500; }
.progress { height: 6px; background: var(--border); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.chip-list { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; }
.muted { color: var(--text-3); }
.small { font-size: 12px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.flex { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.right { text-align: right; }
.setup-wrap { max-width: 560px; margin: 60px auto; }
.hero-num { font-size: 34px; font-weight: 600; letter-spacing: -0.02em; }
.wizard-list li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; font-size: 13px; color: var(--text-2); }
.wizard-list i { color: var(--positive); margin-top: 3px; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .2s; z-index: 60; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  .sidebar.open { transform: none; }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(20,24,32,.3); z-index: 55; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 4px 16px 80px; }
  .page-title { font-size: 18px; }
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid .span-2 { grid-column: span 1; }
  .card { padding: 16px; }
  .stat-value { font-size: 22px; }
  .chart-box { height: 240px; }
  .modal { padding: 18px 16px; }
  .modal-backdrop { padding: 16px 10px; }
}
@media (max-width: 600px) {
  .grid-4, .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat { padding: 14px 14px; }
  .stat-value { font-size: 19px; }
  .stat-label { font-size: 11.5px; }
  .topbar-left { width: 100%; }
  .period { width: 100%; }
  .period select { flex: 1; }
  .company-chip { display: none; }
  .content { padding: 4px 12px 80px; }
  .pl-line.total .amount { font-size: 17px; }
  .hero-num { font-size: 26px; }
  .form-actions .btn { flex: 1; }
}
@media (max-width: 380px) {
  .grid-4, .grid-3 { grid-template-columns: minmax(0, 1fr); }
  .stat-value { font-size: 20px; }
  .content { padding: 4px 10px 80px; }
  .card { padding: 14px 12px; }
}

/* Ver.2: added menu and form labels */
.sidebar { overflow-y: auto; }
.pl-line .label { flex-wrap: wrap; }
@media(max-width:600px){.stat-label{flex-wrap:wrap;} .kv{gap:8px;} .note{overflow-wrap:anywhere;}}

/* Financial details: visible links, keyboard controls, and in-place filtering. */
.detail-link { border: 0; background: transparent; color: var(--accent); padding: 3px 0; cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: #a8bac6; text-underline-offset: 3px; font: inherit; }
.detail-link:hover { color: #172f40; text-decoration-color: currentColor; }
.detail-link:focus-visible, .drill-filter:focus-visible, .stat.clickable:focus-visible { outline: 3px solid #6e9ebc; outline-offset: 3px; border-radius: 5px; }
.detail-link.pl-line { width: 100%; background: transparent; border: 0; text-align: left; }
.detail-link.pl-line:hover { background: var(--accent-soft); border-radius: 6px; }
.detail-hint { margin-left: 10px; font-size: 12px; font-weight: 400; white-space: nowrap; }
.amount-link { text-align: right; white-space: nowrap; }
.drill-total { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 12px; padding: 16px; background: var(--accent-soft); border-radius: 10px; }
.drill-total strong { font-size: 24px; }
.drill-filters { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 8px; margin-top: 10px; }
.drill-filter { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; padding: 12px; border: 1px solid var(--border-strong); border-radius: 8px; background: var(--surface); cursor: pointer; text-align: left; font-size: 14px; }
.drill-filter[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.drill-filter:hover { border-color: var(--accent); }
@media(max-width:650px) { .drill-filters { grid-template-columns: repeat(2,minmax(0,1fr)); } .drill-total strong { font-size: 20px; } }
@media(max-width:360px) { .drill-filters { grid-template-columns: 1fr; } }
