/*
 * Layer: 整形層 / Display Layer
 * Purpose: APO 共通スタイル (デザイントークン + 再利用コンポーネント)
 * Reference: docs/ui_reference_gemini.html を最大限忠実に再現
 *
 * 主要コンポーネント:
 *   .app-layout / .app-sidebar / .app-main          -- レイアウト
 *   .role-toggle / .role-toggle-btn                  -- ヘッダー職能切替タブ
 *   .shop-target                                     -- 対象店舗表示
 *   .kpi-large                                       -- 経営目標進捗メーター
 *   .team-grid / .team-card                          -- 各チーム達成率
 *   .pl-table                                        -- 月次確定 PL 表
 *   .stack-list / .stack-card / .active-focus / .collapsed
 *                                                    -- タスクスタック (主役)
 *   .progress-bar                                    -- 汎用プログレスバー
 *   .panel / .panel-2 / .section-label               -- 汎用枠
 *   .btn-primary / .btn-action-huge                  -- ボタン
 *   .login-shell / .login-card                       -- ログイン画面
 */

/* =========================================================================
 * デザイントークン
 * ========================================================================= */

:root {
  --bg-base:     #FAFAF7;
  --bg-panel:    #FFFFFF;
  --bg-panel-2:  #F5F4EF;
  --bg-hover:    #F0EFEA;
  --bg-strong:   #1A1A1A;

  --border-faint:  #E8E6DF;
  --border-soft:   #D4D2CC;
  --border-strong: #8A8780;

  --text-primary:   #1A1A1A;
  --text-secondary: #4A4A48;
  --text-tertiary:  #7A7872;
  --text-quiet:     #A8A6A0;
  --text-onstrong:  #FAFAF7;

  --accent-profit:     #057A55;
  --accent-profit-dim: #E8F5EF;
  --accent-ai:         #4338CA;
  --accent-ai-dim:     #EEF0FA;
  --accent-ai-border:  #D4D2EE;
  --accent-bleed:      #B91C1C;
  --accent-bleed-dim:  #FCEBEA;
  --accent-warn:       #B45309;
  --accent-warn-dim:   #FEF3C7;

  --font-base: 'Noto Sans JP', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

  --fs-2xs:  11px;
  --fs-xs:   12px;
  --fs-sm:   14px;
  --fs-base: 16px;
  --fs-md:   18px;
  --fs-lg:   22px;
  --fs-xl:   28px;
  --fs-2xl:  32px;

  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;
  --sp-12: 48px;

  --radius-sm: 2px;
  --radius-md: 4px;

  --sidebar-w:         240px;
  --header-h:          64px;
  --content-min-width: 1400px;

  --shadow-card:  0 1px 3px rgba(26, 26, 26, 0.04);
  --shadow-focus: 0 4px 20px rgba(26, 26, 26, 0.06);
}

/* =========================================================================
 * 基本リセット & ベース
 * ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-base);
  font-size: var(--fs-md);
  font-feature-settings: "palt";
  letter-spacing: 0.01em;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-width: var(--content-min-width);
  overflow-x: auto;
}

/* ログイン画面 / フォーム画面はモバイル可、min-width 解除 */
body.login-shell,
body.form-shell { min-width: auto; overflow-x: hidden; }

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.4; }

.mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* =========================================================================
 * アプリレイアウト (左サイドバー + メイン)
 * ========================================================================= */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* --- サイドバー (単一機能、職能切替はヘッダー側) --- */
.app-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border-faint);
  display: flex; flex-direction: column;
  flex-shrink: 0;
}

.app-sidebar-brand {
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border-faint);
}
.app-sidebar-brand-name {
  font-family: var(--font-mono);
  font-weight: 700; font-size: 18px;
  color: var(--text-primary);
}
.app-sidebar-brand-tag {
  font-size: 10px; color: var(--text-tertiary);
  letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700; margin-top: 4px;
}

.app-sidebar-nav {
  flex: 1; padding: var(--sp-4) 0;
  overflow-y: auto;
}
.app-nav-item {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-5);
  font-size: 14px;
  color: var(--text-secondary);
  border-left: 3px solid transparent;
  transition: background 0.12s, color 0.12s;
}
.app-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.app-nav-item.active {
  background: var(--bg-panel-2);
  color: var(--text-primary);
  border-left-color: var(--text-primary);
  font-weight: 600;
}
.app-nav-item-num {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-quiet);
  width: 22px;
}
.app-nav-item.disabled { opacity: 0.45; cursor: not-allowed; }
.app-nav-item.disabled:hover { background: transparent; color: var(--text-secondary); }

.app-nav-section { margin-bottom: var(--sp-5); }
.app-nav-section-label {
  font-size: 10px; color: var(--text-quiet);
  letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700;
  padding: var(--sp-2) var(--sp-5);
}

.app-sidebar-footer {
  padding: var(--sp-3) var(--sp-5);
  border-top: 1px solid var(--border-faint);
  font-size: 10px; color: var(--text-tertiary);
  background: var(--bg-panel-2);
  letter-spacing: 0.04em;
  line-height: 1.6;
}
.app-sidebar-footer strong {
  font-family: var(--font-mono);
  color: var(--text-secondary);
  font-weight: 500;
}

/* --- メインエリア --- */
.app-main {
  flex: 1;
  display: flex; flex-direction: column;
  min-width: 0;
}

.app-header {
  height: var(--header-h);
  border-bottom: 1px solid var(--border-faint);
  background: var(--bg-panel);
  display: flex; align-items: center;
  padding: 0 var(--sp-8);
  gap: var(--sp-5);
  flex-shrink: 0;
}
.app-header-spacer { flex: 1; }
.app-header-logout {
  color: var(--accent-warn);
  font-size: 12px; font-weight: 700;
  letter-spacing: 0.04em;
  margin-left: var(--sp-5);
}
.app-header-logout:hover { text-decoration: underline; }

.app-content {
  flex: 1;
  padding: var(--sp-8);
}
.app-content > * + * { margin-top: var(--sp-6); }

/* =========================================================================
 * ヘッダー: ログイン職能切替トグル + 対象店舗
 * ========================================================================= */

.role-toggle-label {
  font-size: 10px;
  color: var(--text-quiet);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
}

.role-toggle {
  display: inline-flex;
  border: 1px solid var(--border-soft);
  background: var(--bg-panel-2);
  padding: 2px;
  border-radius: var(--radius-sm);
}
.role-toggle-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  background: transparent;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.role-toggle-btn:hover { color: var(--text-primary); }
.role-toggle-btn.active {
  background: var(--bg-strong);
  color: var(--text-onstrong);
}
.role-toggle-btn.active:hover { color: var(--text-onstrong); }

.shop-target {
  font-size: 12px;
  color: var(--text-tertiary);
  font-weight: 500;
  flex-shrink: 0;
}
.shop-target strong {
  color: var(--text-primary);
  font-weight: 700;
  margin-left: var(--sp-2);
}

/* =========================================================================
 * パネル + セクションラベル
 * ========================================================================= */

.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  padding: var(--sp-6);
}
.panel-2 {
  background: var(--bg-panel-2);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  padding: var(--sp-6);
}

.section-label {
  display: flex; align-items: center; gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.section-label-text {
  font-size: 11px; color: var(--text-tertiary);
  letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700;
}
.section-label-line {
  flex: 1; height: 1px; background: var(--border-faint);
}

/* =========================================================================
 * KPI Large (経営目標進捗メーター)
 * ========================================================================= */

.kpi-large {
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  padding: var(--sp-6);
}
.kpi-large-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.kpi-large-label {
  font-size: 11px; color: var(--text-tertiary);
  font-weight: 700; letter-spacing: 0.14em;
  text-transform: uppercase;
}
.kpi-large-value {
  font-family: var(--font-mono);
  font-size: 28px; font-weight: 700;
  color: var(--text-primary);
  margin-top: var(--sp-1);
}
.kpi-large-value.muted { color: var(--text-quiet); }
.kpi-large-value-sub {
  font-size: 16px; color: var(--text-quiet);
  font-weight: 400;
  margin-left: var(--sp-2);
}
.kpi-large-progress {
  font-family: var(--font-mono);
  font-size: 24px; font-weight: 800;
  color: var(--accent-profit);
  white-space: nowrap;
}
.kpi-large-progress.muted { color: var(--text-quiet); }

/* =========================================================================
 * Progress Bar (汎用)
 * ========================================================================= */

.progress-container {
  background: var(--border-faint);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent-profit);
  transition: width 0.4s ease-out;
}
.progress-bar.bar-ai     { background: var(--accent-ai); }
.progress-bar.bar-profit { background: var(--accent-profit); }
.progress-bar.bar-muted  { background: var(--text-quiet); }

/* =========================================================================
 * Team Grid (各チーム達成率カード、2 カラム)
 * ========================================================================= */

.team-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--sp-4);
}
.team-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  padding: var(--sp-5);
  display: flex; flex-direction: column;
  gap: var(--sp-3);
}
.team-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--sp-3);
}
.team-card-title {
  font-size: 13px; font-weight: 700;
  color: var(--text-primary);
}
.team-card-pct {
  font-family: var(--font-mono);
  font-size: 13px; font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}
.team-card-pct.muted { color: var(--text-quiet); }
.team-card-caption {
  font-size: 11px; color: var(--text-tertiary);
  line-height: 1.6;
}
.team-card-caption strong {
  color: var(--text-secondary);
  font-weight: 600;
}

/* =========================================================================
 * PL Table (月次確定損益計算書)
 * ========================================================================= */

.pl-table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.pl-table {
  width: 100%;
  border-collapse: collapse;
}
.pl-table th {
  text-align: left;
  padding: 12px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-panel-2);
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-faint);
}
.pl-table th:last-child { border-right: none; }
.pl-table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-faint);
  border-right: 1px solid var(--border-faint);
  color: var(--text-secondary);
}
.pl-table td:last-child { border-right: none; }
.pl-table tr:last-child td { border-bottom: none; }
.pl-cell-num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.pl-cell-num.muted { color: var(--text-quiet); }
.pl-row-section td {
  background: var(--bg-base);
  font-size: 10px;
  color: var(--text-tertiary);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 6px 14px;
}
.pl-row-total td {
  background: rgba(26, 26, 26, 0.03);
  font-weight: 600;
  border-top: 2px solid var(--border-strong);
}
.pl-th-forecast { background: rgba(67, 56, 202, 0.04); color: var(--accent-ai); }
.pl-cell-forecast { color: var(--accent-ai); font-weight: 500; }

/* =========================================================================
 * スタックカード (主役: タスクリスト)
 *
 * Step 2 セットアップ版と Step 5 改善タスク本物版で同じクラスを使う。
 * ========================================================================= */

.stack-list > * + * { margin-top: var(--sp-3); }

.stack-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-soft);
  border-left: 4px solid var(--text-quiet);
  border-radius: var(--radius-sm);
  padding: var(--sp-6);
  display: block;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.stack-card.active-focus {
  border-color: var(--text-primary);
  border-left-color: var(--accent-ai);
  box-shadow: var(--shadow-focus);
  padding: var(--sp-6) var(--sp-8);
}

.stack-card.collapsed {
  padding: var(--sp-4) var(--sp-6);
  background: var(--bg-panel-2);
  border-left-color: var(--text-quiet);
  opacity: 0.9;
}

.stack-card.preview {
  background: var(--bg-panel-2);
  border-style: dashed;
}

.stack-card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.stack-card.collapsed .stack-card-head { margin-bottom: var(--sp-2); }

.stack-card-head-left {
  display: flex; align-items: center; gap: var(--sp-3);
  flex-wrap: wrap;
}

.stack-badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}
.stack-badge.now    { background: var(--accent-ai-dim);     color: var(--accent-ai); }
.stack-badge.locked { background: var(--bg-hover);          color: var(--text-quiet); }
.stack-badge.quiet  { background: var(--bg-hover);          color: var(--text-tertiary); }
.stack-badge.profit { background: var(--accent-profit-dim); color: var(--accent-profit); }
.stack-badge.bleed  { background: var(--accent-bleed-dim);  color: var(--accent-bleed); }
.stack-badge.bid    { background: var(--bg-hover);          color: var(--text-primary); }

.stack-card-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
  margin: 0;
}
.stack-card.active-focus .stack-card-title { font-size: 22px; }
.stack-card.collapsed .stack-card-title {
  font-size: 15px;
  color: var(--text-secondary);
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--sp-3);
  margin: var(--sp-1) 0 0;
  font-weight: 600;
}
.stack-card.collapsed .stack-card-title .arrow {
  color: var(--text-quiet);
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 400;
}

.stack-card-divider {
  height: 1px;
  background: var(--border-faint);
  margin: var(--sp-4) 0;
}

.stack-card-desc {
  font-size: 14px;
  line-height: 1.8;
  color: var(--text-secondary);
  margin: 0 0 var(--sp-5);
}
.stack-card-desc strong.evidence-label {
  color: var(--accent-ai); font-weight: 700;
  margin-right: var(--sp-1);
}

/* =========================================================================
 * ボタン
 * ========================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--sp-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-base);
  font-size: 15px; font-weight: 600;
  padding: var(--sp-3) var(--sp-5);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  border: 2px solid transparent;
  text-decoration: none;
}
.btn-primary {
  background: var(--bg-strong); color: var(--text-onstrong);
  border-color: var(--bg-strong);
}
.btn-primary:hover { background: #2D2D2D; border-color: #2D2D2D; }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border-color: var(--border-soft);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-action-huge {
  display: inline-flex; align-items: center; gap: var(--sp-3);
  background: var(--bg-strong); color: var(--text-onstrong);
  font-size: 15px; font-weight: 700;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  border: 2px solid var(--bg-strong);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s;
}
.btn-action-huge:hover { background: #2D2D2D; border-color: #2D2D2D; }
.btn-action-huge:disabled,
.btn-action-huge.disabled {
  background: var(--bg-hover); color: var(--text-quiet);
  border-color: var(--border-soft);
  cursor: not-allowed;
}
.btn-action-huge .arrow {
  font-family: var(--font-mono);
  font-size: 16px;
  transition: transform 0.15s;
}
.btn-action-huge:hover:not(.disabled) .arrow { transform: translateX(4px); }

.btn-block { width: 100%; }

/* =========================================================================
 * フォーム
 * ========================================================================= */

.form-group { margin-bottom: var(--sp-4); }
.form-label {
  display: block;
  font-size: 11px; color: var(--text-tertiary);
  font-weight: 700; letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: var(--sp-2);
}
.form-input {
  width: 100%; box-sizing: border-box;
  padding: var(--sp-3) var(--sp-4);
  font-family: var(--font-base);
  font-size: 16px;
  color: var(--text-primary);
  background: var(--bg-base);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.form-input:focus {
  outline: none;
  border-color: var(--text-primary);
  background: var(--bg-panel);
}

/* =========================================================================
 * アラート / プレースホルダー
 * ========================================================================= */

.alert {
  padding: var(--sp-3) var(--sp-4);
  font-size: 14px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-4);
}
.alert-error {
  background: var(--accent-bleed-dim);
  color: var(--accent-bleed);
  border: 1px solid #FCA5A5;
}

.placeholder-box {
  background: var(--bg-panel-2);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
}
.placeholder-box-tag {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px; font-weight: 700;
  padding: 3px 10px; border-radius: var(--radius-sm);
  background: var(--accent-ai-dim); color: var(--accent-ai);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-bottom: var(--sp-3);
}
.placeholder-box-title {
  font-size: 14px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
}
.placeholder-box-desc {
  font-size: 13px; color: var(--text-tertiary);
  line-height: 1.7;
}

/* =========================================================================
 * データテーブル (マスタ一覧画面用)
 * ========================================================================= */

.data-table-wrap {
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
}
.data-table th {
  text-align: left;
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-tertiary);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: var(--bg-panel-2);
  border-bottom: 1px solid var(--border-soft);
  border-right: 1px solid var(--border-faint);
  white-space: nowrap;
}
.data-table th:last-child { border-right: none; }
.data-table th.num { text-align: right; }
.data-table td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-faint);
  border-right: 1px solid var(--border-faint);
  color: var(--text-secondary);
  vertical-align: middle;
}
.data-table td:last-child { border-right: none; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }
.data-table tr.inactive td {
  color: var(--text-quiet);
  background: var(--bg-panel-2);
}
.data-table .num {
  font-family: var(--font-mono);
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.data-table .actions { white-space: nowrap; }
.data-table .actions a,
.data-table .actions button {
  color: var(--accent-ai);
  font-size: 12px;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  margin-right: var(--sp-4);
  font-family: inherit;
}
.data-table .actions button.danger { color: var(--accent-bleed); }
.data-table .actions a:hover,
.data-table .actions button:hover { text-decoration: underline; }
.data-table-status-active {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--accent-profit-dim); color: var(--accent-profit);
  letter-spacing: 0.08em; text-transform: uppercase;
}
.data-table-status-inactive {
  display: inline-block;
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-sm);
  background: var(--bg-hover); color: var(--text-quiet);
  letter-spacing: 0.08em; text-transform: uppercase;
}

/* --- 空状態 --- */
.data-table-empty {
  background: var(--bg-panel);
  border: 1px dashed var(--border-soft);
  border-radius: var(--radius-sm);
  padding: var(--sp-10) var(--sp-6);
  text-align: center;
}
.data-table-empty-title {
  font-size: 15px; font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-3);
}
.data-table-empty-desc {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-5);
  line-height: 1.7;
}

/* --- 検索バー --- */
.search-bar {
  display: flex; gap: var(--sp-3); align-items: center;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.search-bar .form-input {
  margin: 0;
  padding: 8px 10px;
  font-size: 14px;
  flex: 0 1 240px;
}
.search-bar select.form-input { flex: 0 0 160px; }
.search-bar label.inline {
  font-size: 13px;
  color: var(--text-tertiary);
  display: flex; align-items: center; gap: 6px;
  cursor: pointer;
}
.search-bar .spacer { flex: 1; }

/* --- ページヘッダー (タイトル + アクション) --- */
.page-header {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.page-header-title {
  font-size: 22px; font-weight: 700;
  color: var(--text-primary);
}
.page-header-meta {
  font-size: 12px; color: var(--text-tertiary);
}

/* =========================================================================
 * フォームシェル (中央寄せ、上揃え)
 * ========================================================================= */

body.form-shell {
  background: var(--bg-base);
  padding: var(--sp-8) var(--sp-6) var(--sp-12);
  display: flex; flex-direction: column;
  align-items: center;
}
.form-container {
  width: 100%; max-width: 680px;
}
.form-back {
  margin-bottom: var(--sp-4);
}
.form-back a {
  font-size: 13px;
  color: var(--text-tertiary);
  letter-spacing: 0.02em;
}
.form-back a:hover { color: var(--text-primary); }
.form-card-title {
  font-size: 20px; font-weight: 700;
  margin: 0 0 var(--sp-1);
  color: var(--text-primary);
}
.form-card-subtitle {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-tertiary);
  letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700;
  margin: 0 0 var(--sp-6);
}
.form-row-2 {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: var(--sp-4);
}
/* form-help / form-error は input の直下、form-group の bottom margin 内に配置 */
.form-help {
  font-size: 11px; color: var(--text-tertiary);
  margin-top: 6px;
  margin-bottom: 0;
  line-height: 1.65;
}
.form-help p {
  margin: 0 0 4px;
}
.form-help p:last-child {
  margin-bottom: 0;
}
/* 例示の強調 (例: 売上¥1,000、広告費¥200 → ACOS 20%) */
.form-help-ex {
  font-weight: 500;
  color: var(--text-secondary);
}
/* 業界目安など補足情報。元 help と視覚的に分離 */
.form-help-tip {
  display: block;
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px dashed var(--border-faint);
  color: var(--text-quiet);
  font-size: 10.5px;
}
.form-error {
  font-size: 12px; color: var(--accent-bleed);
  margin-top: 6px;
  margin-bottom: 0;
  font-weight: 600;
  line-height: 1.5;
}
/* placeholder は明示色 (text-quiet) で help との混同を防ぐ */
.form-input::placeholder {
  color: var(--text-quiet);
  opacity: 1;
}
.form-actions {
  display: flex; gap: var(--sp-3); justify-content: flex-end;
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-faint);
}
.form-actions-delete {
  display: flex; gap: var(--sp-3); justify-content: flex-start;
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-faint);
}
.btn-danger {
  background: var(--bg-panel); color: var(--accent-bleed);
  border-color: #FCA5A5;
}
.btn-danger:hover {
  background: var(--accent-bleed-dim);
  border-color: var(--accent-bleed);
}

.form-input.is-error {
  border-color: var(--accent-bleed);
  background: var(--accent-bleed-dim);
}
.form-checkbox {
  display: flex; align-items: center; gap: var(--sp-2);
  font-size: 14px; color: var(--text-secondary);
  margin-bottom: var(--sp-4);
}

/* =========================================================================
 * ツールチップ (form-label 内の "i" アイコン、CSS only / :hover & :focus-within)
 * ========================================================================= */
.form-tooltip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px;
  margin-left: 6px;
  border-radius: 50%;
  background: var(--bg-panel-2);
  border: 1px solid var(--border-soft);
  color: var(--text-tertiary);
  font-family: var(--font-base);
  font-size: 10px; font-weight: 700; font-style: italic;
  line-height: 1;
  letter-spacing: 0; text-transform: none;
  cursor: help;
  position: relative;
  vertical-align: middle;
  user-select: none;
}
.form-tooltip:hover,
.form-tooltip:focus,
.form-tooltip:focus-within {
  background: var(--bg-base);
  border-color: var(--text-tertiary);
  color: var(--text-secondary);
  outline: none;
}
.form-tooltip-content {
  display: none;
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  width: 300px;
  max-width: 80vw;
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-base);
  border: 1px solid var(--border-soft);
  border-radius: 2px;
  box-shadow: var(--shadow-card);
  color: var(--text-secondary);
  font-family: var(--font-base);
  font-size: 12px; font-weight: 400;
  line-height: 1.65;
  letter-spacing: 0; text-transform: none;
  text-align: left;
  white-space: normal;
  z-index: 50;
  cursor: default;
}
.form-tooltip:hover .form-tooltip-content,
.form-tooltip:focus .form-tooltip-content,
.form-tooltip:focus-within .form-tooltip-content {
  display: block;
}
/* ▼ 矢印 (二重三角で枠線+塗りを再現) */
.form-tooltip-content::after {
  content: '';
  position: absolute;
  top: 100%; left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid var(--border-soft);
}
.form-tooltip-content::before {
  content: '';
  position: absolute;
  top: calc(100% - 1px); left: 50%;
  transform: translateX(-50%);
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid var(--bg-base);
  z-index: 1;
}
.form-tooltip-content p {
  margin: 0 0 6px;
}
.form-tooltip-content p:last-child {
  margin-bottom: 0;
}
.form-tooltip-content .num {
  font-family: var(--font-mono);
  font-weight: 500;
  color: var(--text-primary);
}
.form-tooltip-tip {
  margin-top: 8px !important;
  padding-top: 6px;
  border-top: 1px dashed var(--border-faint);
  font-size: 11px;
  color: var(--text-tertiary);
}

/* input 直下の 1 行ヒント (詳細はツールチップ側) */
.form-help-mini {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
  line-height: 1.5;
}

/* =========================================================================
 * フォーム内セクション区切り (例: 「商品の状態」見出し)
 * ========================================================================= */
.form-section-divider {
  margin: var(--sp-6) 0 var(--sp-3);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border-faint);
}
.form-section-label {
  display: inline-block;
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--text-tertiary);
}
.form-checkbox-section {
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-panel-2);
  border: 1px solid var(--border-faint);
  border-radius: 2px;
}
.form-checkbox-section .form-checkbox {
  margin-bottom: 0;
  font-size: 15px;
  color: var(--text-primary);
  cursor: pointer;
}
.form-checkbox-section .form-checkbox strong {
  font-weight: 700;
}
.form-checkbox-section .form-help-mini {
  margin-top: 8px;
  padding-left: 24px; /* checkbox 幅 + gap 分のインデント */
}

/* --- フラッシュ通知 --- */
.flash {
  padding: var(--sp-3) var(--sp-4);
  font-size: 13px;
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-4);
}
.flash-success {
  background: var(--accent-profit-dim);
  color: var(--accent-profit);
  border: 1px solid #6EE7B7;
}

/* =========================================================================
 * ログイン画面専用
 * ========================================================================= */

.login-shell {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-base);
  padding: var(--sp-6);
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-faint);
  border-radius: var(--radius-sm);
  padding: var(--sp-10);
  width: 440px;
  max-width: 100%;
  box-shadow: var(--shadow-card);
}
.login-title {
  font-size: 22px; font-weight: 700;
  margin: 0 0 var(--sp-1);
  letter-spacing: 0.01em;
}
.login-subtitle {
  font-family: var(--font-mono);
  font-size: 11px; color: var(--text-tertiary);
  letter-spacing: 0.14em; text-transform: uppercase;
  font-weight: 700;
  margin: 0 0 var(--sp-6);
}
.login-footer {
  font-family: var(--font-mono);
  font-size: 10px; color: var(--text-quiet);
  text-align: center;
  margin-top: var(--sp-5);
  letter-spacing: 0.12em;
}
