/* 店舗レイアウト管理 — 共通スタイル（ダークUI） */
:root {
  --bg: #0f1117;
  --surface: #1a1d27;
  --surface2: #242836;
  --border: #2e3345;
  --text: #e4e6ef;
  --text2: #8b8fa7;
  --accent: #d62b24;        /* フジヤレッド */
  --accent-soft: #e0554f;
  --blue: #6c8cff;
  --positive: #34d399;
  --negative: #f87171;
  --warn: #fbbf24;
  --grid-line: #232736;
  --radius: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 13px;
  transition: background .15s, border-color .15s;
}
button:hover { border-color: var(--text2); }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: var(--accent-soft); }
button.ghost { background: none; }
button:disabled { opacity: .45; cursor: default; }
input, select, textarea {
  font-family: inherit;
  font-size: 13px;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--blue); }

/* ── ヘッダー ── */
header.app {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
header.app h1 { font-size: 16px; font-weight: 700; white-space: nowrap; }
header.app h1 a { color: var(--text); text-decoration: none; }
header.app .brand-mark {
  display: inline-block;
  width: 10px; height: 10px;
  background: var(--accent);
  border-radius: 2px;
  margin-right: 8px;
}
header.app .spacer { flex: 1; }
header.app .role-badge {
  font-size: 11px;
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 10px;
}

/* ── ログイン ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 36px;
  width: 340px;
}
.login-card h1 { font-size: 18px; margin-bottom: 4px; }
.login-card p { color: var(--text2); font-size: 12px; margin-bottom: 20px; }
.login-card input { width: 100%; margin-bottom: 12px; padding: 10px; font-size: 15px; }
.login-card button { width: 100%; padding: 10px; font-size: 14px; }
.login-error { color: var(--negative); font-size: 12px; margin-bottom: 10px; min-height: 16px; }

/* ── 店舗一覧 ── */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.store-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 18px;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s, transform .1s;
}
.store-tile:hover { border-color: var(--accent); transform: translateY(-2px); }
.store-tile h2 { font-size: 16px; margin-bottom: 6px; }
.store-tile .meta { color: var(--text2); font-size: 12px; }

/* ── レイアウト画面 ── */
.layout-main {
  display: grid;
  grid-template-columns: 1fr 320px;
  height: calc(100vh - 53px);
}
.canvas-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg);
}
#stage { width: 100%; height: 100%; display: block; touch-action: none; }
#stage:focus { outline: none; }
.canvas-hud {
  position: absolute;
  left: 12px; bottom: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
  background: rgba(26, 29, 39, .88);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--text2);
}
.canvas-hud button { padding: 2px 8px; font-size: 12px; }

.side-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.panel-section h3 {
  font-size: 12px;
  color: var(--text2);
  font-weight: 600;
  letter-spacing: .05em;
  margin-bottom: 8px;
}
.panel-section .search-box { width: 100%; }
.search-count { font-size: 12px; color: var(--text2); margin-top: 6px; min-height: 16px; }

.legend-list { display: flex; flex-direction: column; gap: 2px; }
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  font-size: 13px;
}
.legend-item:hover { background: var(--surface2); }
.legend-item.active { background: var(--surface2); outline: 1px solid var(--blue); }
.legend-chip { width: 13px; height: 13px; border-radius: 3px; flex: none; }
.legend-name { flex: 1; }
.legend-count { color: var(--text2); font-size: 12px; }

/* インスペクタ */
.inspector { display: flex; flex-direction: column; gap: 8px; }
.inspector label { font-size: 11px; color: var(--text2); display: block; margin-bottom: 3px; }
.inspector .row { display: flex; gap: 8px; }
.inspector .row > div { flex: 1; }
.inspector input, .inspector select, .inspector textarea { width: 100%; }
.inspector textarea { resize: vertical; min-height: 48px; }
.inspector .danger { color: var(--negative); border-color: var(--negative); }
.inspector .hint { font-size: 11px; color: var(--text2); }

/* ツールバー（編集モード） */
.toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.toolbar .sep { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.toolbar label.chk {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: var(--text2); cursor: pointer;
}

/* モードタブ */
.mode-tabs {
  display: flex;
  gap: 3px;
  background: var(--bg);
  border-radius: 7px;
  padding: 3px;
}
.mode-tabs button {
  border: none;
  background: none;
  color: var(--text2);
  padding: 5px 14px;
  border-radius: 5px;
}
.mode-tabs button.active { background: var(--accent); color: #fff; }

/* SVG什器 */
g.fixture { cursor: default; }
.mode-edit g.fixture:not(.locked) { cursor: grab; }
g.fixture text {
  pointer-events: none;
  fill: #10131a;
  font-family: "Hiragino Sans", "Noto Sans JP", sans-serif;
}
g.fixture.facility rect { fill: #3a4052; stroke-dasharray: none; }
g.fixture.facility text { fill: #c5c9d6; }
g.fixture.selected rect { stroke: #fff; stroke-width: 1.6; }
g.fixture.overlap rect { stroke: var(--warn); stroke-dasharray: 4 3; stroke-width: 1.6; }
svg.searching g.fixture { opacity: .15; transition: opacity .15s; }
svg.searching g.fixture.hit { opacity: 1; }
svg.searching g.fixture.hit rect { stroke: #fff; stroke-width: 1.6; }
.ghost rect { fill-opacity: .5; stroke: #fff; stroke-width: 1.2; }
.ghost.invalid rect { stroke: var(--negative); stroke-dasharray: 5 3; }
.handle { fill: #fff; stroke: #10131a; cursor: nwse-resize; }
.handle[data-dir="e"] { cursor: ew-resize; }
.handle[data-dir="s"] { cursor: ns-resize; }
.marquee { fill: rgba(108, 140, 255, .15); stroke: var(--blue); stroke-dasharray: 4 3; }

/* 差分表示 */
g.fixture.diff-added rect { stroke: var(--positive); stroke-width: 2; }
g.fixture.diff-removed rect { stroke: var(--negative); stroke-width: 2; stroke-dasharray: 5 3; }
g.fixture.diff-moved rect { stroke: var(--warn); stroke-width: 2; }
g.fixture.diff-edited rect { stroke: var(--blue); stroke-width: 2; }
.diff-arrow { stroke: var(--warn); stroke-width: 1.5; marker-end: url(#arrowhead); }
.diff-list { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.diff-item {
  padding: 5px 8px;
  border-radius: 5px;
  border-left: 3px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
}
.diff-item.added { border-left-color: var(--positive); }
.diff-item.removed { border-left-color: var(--negative); }
.diff-item.moved { border-left-color: var(--warn); }
.diff-item.edited { border-left-color: var(--blue); }
.diff-summary { font-size: 12px; color: var(--text2); margin-bottom: 6px; }

/* ダイアログ */
dialog {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 22px;
  min-width: 320px;
  max-width: 90vw;
}
dialog::backdrop { background: rgba(0, 0, 0, .55); }
dialog h3 { font-size: 15px; margin-bottom: 12px; }
dialog .dialog-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
dialog .field { margin-bottom: 10px; }
dialog .field label { font-size: 12px; color: var(--text2); display: block; margin-bottom: 4px; }
dialog .field input, dialog .field select { width: 100%; }

/* トースト */
#toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
  z-index: 50;
}
#toast.show { opacity: 1; }
#toast.error { border-color: var(--negative); color: var(--negative); }

/* 履歴パネル */
.snapshot-list { display: flex; flex-direction: column; gap: 4px; font-size: 12px; }
.snapshot-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 8px;
  background: var(--surface2);
  border-radius: 5px;
}
.snapshot-item .when { flex: 1; }
.snapshot-item button { padding: 2px 8px; font-size: 11px; }

/* 分析ページ */
.analysis-wrap { max-width: 1100px; margin: 0 auto; padding: 22px; }
.analysis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.card h2 { font-size: 14px; margin-bottom: 12px; }
.card .sub { font-size: 12px; color: var(--text2); margin-bottom: 10px; }
.gap-list { display: flex; flex-direction: column; gap: 6px; }
.gap-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.gap-row .name { width: 90px; flex: none; }
.gap-row .bar-wrap { flex: 1; height: 16px; position: relative; background: var(--bg); border-radius: 3px; }
.gap-row .bar { position: absolute; top: 0; height: 100%; border-radius: 3px; }
.gap-row .val { width: 70px; text-align: right; font-variant-numeric: tabular-nums; flex: none; }
.pos { color: var(--positive); }
.neg { color: var(--negative); }

@media (max-width: 900px) {
  .layout-main { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .side-panel { border-left: none; border-top: 1px solid var(--border); max-height: 40vh; }
  .analysis-grid { grid-template-columns: 1fr; }
}
