/* ============================================================
 *  app.css - リョヒコンパス テーマ切替対応
 * ============================================================ */

/* ------------------------------------------------------------
 *  共通カラー（テーマに依存しない）
 * ------------------------------------------------------------ */
:root {
  /* グラフ・カテゴリカラー */
  --color-sales:      #5B9FE6;
  --color-profit:     #2ECC71;
  --color-water:      #5DADE2;
  --color-unext:      #F0A04B;
  --color-gas:        #E85D5D;
  --color-travel:     #F4D03F;
  --color-personnel:  #BB8FCE;
  --color-expense:    #F06292;
  --color-other:      #AAB7B8;

  --app-sidebar-width: 260px;
  --app-header-height: 60px;
  --card-radius:      12px;
  --transition-fast:  0.15s ease;
}

/* ============================================================
 *  ダークテーマ（デフォルト）
 * ============================================================ */
[data-theme="dark"] {
  --app-bg:           #0f1117;
  --app-surface:      #1a1d27;
  --app-surface-2:    #222633;
  --app-surface-3:    #2a2f3e;
  --app-border:       #2e3347;
  --app-primary:      #5B9FE6;
  --app-primary-dark: #4A8BD4;
  --app-accent:       #5B9FE6;
  --app-text:         #eef0f5;
  --app-text-muted:   #a0a4b8;
  --app-text-dim:     #6e7290;
  --app-sidebar-bg:   #141720;
  --app-header-bg:    #141720;
  --app-success:      #2ECC71;
  --app-danger:       #E85D5D;
  --app-warning:      #F0A04B;
  --app-card-shadow:  0 2px 8px rgba(0, 0, 0, 0.3);
  --app-card-hover-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  --app-btn-close-filter: invert(1) grayscale(100%) brightness(200%);
  --app-login-glow1:  rgba(91, 159, 230, 0.08);
  --app-login-glow2:  rgba(46, 204, 113, 0.06);
}

/* ============================================================
 *  ライトテーマ
 * ============================================================ */
[data-theme="light"] {
  --app-bg:           #f0f2f5;
  --app-surface:      #ffffff;
  --app-surface-2:    #f7f8fa;
  --app-surface-3:    #eef0f4;
  --app-border:       #dee2e8;
  --app-primary:      #4A8BD4;
  --app-primary-dark: #3a78be;
  --app-accent:       #4A8BD4;
  --app-text:         #1a1d27;
  --app-text-muted:   #6c7389;
  --app-text-dim:     #a0a5b8;
  --app-sidebar-bg:   #1e2333;
  --app-header-bg:    #1e2333;
  --app-success:      #27ae60;
  --app-danger:       #e74c3c;
  --app-warning:      #e67e22;
  --app-card-shadow:  0 2px 8px rgba(0, 0, 0, 0.06);
  --app-card-hover-shadow: 0 6px 20px rgba(0, 0, 0, 0.1);
  --app-btn-close-filter: invert(1) grayscale(100%) brightness(200%);
  --app-login-glow1:  rgba(74, 139, 212, 0.06);
  --app-login-glow2:  rgba(39, 174, 96, 0.04);
}

/* ------------------------------------------------------------
 *  ベースリセット
 * ------------------------------------------------------------ */
*,
*::before,
*::after { box-sizing: border-box; }

body {
  font-family: 'Inter', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--app-bg);
  color: var(--app-text);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.3s, color 0.3s;
}

a { color: var(--app-accent); }
a:hover { color: #7AB8F5; }

/* スクロールバー */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--app-bg); }
::-webkit-scrollbar-thumb { background: var(--app-border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--app-text-dim); }

/* ------------------------------------------------------------
 *  ヘッダー（固定）
 * ------------------------------------------------------------ */
.app-header {
  background: var(--app-header-bg);
  border-bottom: 1px solid var(--app-border);
  height: var(--app-header-height);
  z-index: 1030;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
}

.app-header .navbar-brand {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #fff !important;
}

.app-header .navbar { padding: 0 1rem; height: 100%; }
.app-header .text-white-50,
.app-header .nav-link { color: rgba(255,255,255,0.6) !important; }
.app-header .nav-link:hover { color: #fff !important; }

/* テーマ切替ボタン */
.theme-toggle {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.8);
  border-radius: 8px;
  padding: 0.3rem 0.55rem;
  font-size: 1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}
.theme-toggle:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

/* ------------------------------------------------------------
 *  サイドバー
 * ------------------------------------------------------------ */
.app-sidebar {
  position: fixed;
  top: var(--app-header-height);
  left: 0;
  bottom: 0;
  width: var(--app-sidebar-width);
  background: var(--app-sidebar-bg);
  border-right: 1px solid rgba(255,255,255,0.06);
  overflow-y: auto;
  z-index: 1030;
}

.app-sidebar .sidebar-header {
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 1rem 1.2rem;
}

.sidebar-link {
  color: rgba(255,255,255,0.55);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  margin: 1px 8px;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
}

.sidebar-link i { font-size: 1.05rem; opacity: 0.7; }

.sidebar-link:hover {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.08);
}

.sidebar-link.active {
  color: #fff;
  background: linear-gradient(135deg, var(--app-accent), var(--app-primary-dark));
  box-shadow: 0 2px 8px rgba(91, 159, 230, 0.25);
}
.sidebar-link.active i { opacity: 1; }

/* モバイル用オフキャンバス */
.app-sidebar-offcanvas {
  background-color: var(--app-sidebar-bg) !important;
  border-right: 1px solid rgba(255,255,255,0.06);
  width: var(--app-sidebar-width) !important;
}
.app-sidebar-offcanvas .sidebar-link { color: rgba(255,255,255,0.55); }
.app-sidebar-offcanvas .sidebar-link:hover { color: rgba(255,255,255,0.9); background: rgba(255,255,255,0.08); }
.app-sidebar-offcanvas .sidebar-link.active { color: #fff; background: linear-gradient(135deg, var(--app-accent), var(--app-primary-dark)); }
.sidebar-toggle { padding: 0.25rem 0.5rem; text-decoration: none; }

/* ------------------------------------------------------------
 *  メインコンテンツレイアウト
 * ------------------------------------------------------------ */
.app-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.app-body { display: flex; flex: 1; padding-top: var(--app-header-height); }
.app-main { flex: 1; padding: 1.75rem; min-width: 0; }

@media (min-width: 992px) {
  .app-main { margin-left: var(--app-sidebar-width); }
}

/* ------------------------------------------------------------
 *  カード共通
 * ------------------------------------------------------------ */
.card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--card-radius);
  color: var(--app-text);
  transition: background-color 0.3s, border-color 0.3s;
}
.card-header {
  background: var(--app-surface-2);
  border-bottom: 1px solid var(--app-border);
  color: var(--app-text);
}

/* ------------------------------------------------------------
 *  サマリーカード
 * ------------------------------------------------------------ */
.summary-card {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--card-radius);
  overflow: hidden;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast), background-color 0.3s;
  position: relative;
  box-shadow: var(--app-card-shadow);
}
.summary-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--app-card-hover-shadow);
}
.summary-card .card-body { padding: 1.25rem; }
.summary-card .card-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--app-text) !important;
  margin-bottom: 0.6rem;
  opacity: 0.75;
}
[data-theme="dark"] .summary-card .card-title {
  color: #d0d4e8 !important;
}
.summary-card .card-value {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.2;
  color: var(--app-text);
}
[data-theme="dark"] .summary-card .card-value {
  color: #f5f6fa;
}
.summary-card .card-sub {
  font-size: 0.78rem;
  margin-top: 0.4rem;
  color: var(--app-text-muted);
}
[data-theme="dark"] .summary-card .card-sub {
  color: #9ea3b8;
}
.summary-card .card-icon {
  font-size: 2.4rem;
  opacity: 0.08;
  position: absolute;
  top: 12px;
  right: 16px;
}

/* カード左ボーダーバー */
.summary-card--sales     { border-left: 4px solid var(--color-sales); }
.summary-card--profit    { border-left: 4px solid var(--color-profit); }
.summary-card--cost      { border-left: 4px solid var(--color-expense); }
.summary-card--rate      { border-left: 4px solid var(--color-personnel); }
.summary-card--water     { border-left: 4px solid var(--color-water); }
.summary-card--unext     { border-left: 4px solid var(--color-unext); }
.summary-card--gas       { border-left: 4px solid var(--color-gas); }
.summary-card--travel    { border-left: 4px solid var(--color-travel); }
.summary-card--personnel { border-left: 4px solid var(--color-personnel); }
.summary-card--expense   { border-left: 4px solid var(--color-expense); }
.summary-card--predicted { border-left: 4px solid var(--color-unext); }

.trend-up   { color: var(--app-success); }
.trend-down { color: var(--app-danger); }
.trend-flat { color: var(--app-text-dim); }

/* ------------------------------------------------------------
 *  テーブル
 * ------------------------------------------------------------ */
.app-table {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--card-radius);
  overflow: hidden;
  transition: background-color 0.3s;
}
.app-table table { margin-bottom: 0; color: var(--app-text); }
.app-table thead th {
  background: var(--app-surface-2);
  color: var(--app-text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--app-border);
  white-space: nowrap;
  padding: 0.75rem 0.9rem;
}
.app-table tbody td {
  vertical-align: middle;
  font-size: 0.875rem;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--app-border);
}
.app-table tbody tr { transition: background var(--transition-fast); }
.app-table tbody tr:hover { background: var(--app-surface-2); }
.app-table tbody tr:last-child td { border-bottom: none; }
.app-table .text-right,
.app-table .text-end { text-align: right; }

.table { --bs-table-bg: transparent; --bs-table-color: var(--app-text); }
.table-bordered { border-color: var(--app-border); }
.table > :not(caption) > * > * { border-bottom-color: var(--app-border); }

/* ------------------------------------------------------------
 *  チャートコンテナ
 * ------------------------------------------------------------ */
.chart-container {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  border-radius: var(--card-radius);
  padding: 1.25rem;
  transition: background-color 0.3s;
}
.chart-container canvas { max-height: 340px; }

/* ------------------------------------------------------------
 *  フォームコントロール
 * ------------------------------------------------------------ */
.form-control,
.form-select {
  background-color: var(--app-surface-2);
  border: 1px solid var(--app-border);
  color: var(--app-text);
  transition: background-color 0.3s, border-color 0.3s, color 0.3s;
}
.form-control:focus,
.form-select:focus {
  background-color: var(--app-surface-3);
  border-color: var(--app-accent);
  color: var(--app-text);
  box-shadow: 0 0 0 0.2rem rgba(91, 159, 230, 0.2);
}
.form-control::placeholder { color: var(--app-text-dim); }
.form-label { color: var(--app-text-muted); font-weight: 500; }
[data-theme="dark"] .form-label { color: #b8bcd0; }
[data-theme="dark"] .chart-container h6,
[data-theme="dark"] .card h6 { color: #dde0ea; }
[data-theme="dark"] .table-light { --bs-table-bg: rgba(255,255,255,0.03); --bs-table-color: var(--app-text); }
[data-theme="dark"] .table-secondary { --bs-table-bg: rgba(255,255,255,0.06); --bs-table-color: var(--app-text); }
[data-theme="dark"] .table-dark { --bs-table-bg: #1a1d27; --bs-table-color: #eef0f5; }
[data-theme="dark"] .bg-light { background-color: rgba(255,255,255,0.03) !important; }
[data-theme="dark"] th.bg-light { background-color: var(--app-surface-2) !important; color: var(--app-text); }
[data-theme="dark"] .text-muted { color: #a0a4b8 !important; }
.form-text { color: var(--app-text-dim); }
.form-check-input { background-color: var(--app-surface-2); border-color: var(--app-border); }
.form-check-input:checked { background-color: var(--app-accent); border-color: var(--app-accent); }

/* ------------------------------------------------------------
 *  ボタン
 * ------------------------------------------------------------ */
.btn-primary {
  background: linear-gradient(135deg, var(--app-accent), var(--app-primary-dark));
  border: none;
  font-weight: 600;
  color: #fff;
}
.btn-primary:hover {
  background: linear-gradient(135deg, #7AB8F5, var(--app-accent));
  box-shadow: 0 4px 12px rgba(91, 159, 230, 0.3);
  color: #fff;
}
.btn-outline-secondary {
  border-color: var(--app-border);
  color: var(--app-text-muted);
}
.btn-outline-secondary:hover {
  background: var(--app-surface-2);
  border-color: var(--app-text-dim);
  color: var(--app-text);
}

/* ------------------------------------------------------------
 *  モーダル
 * ------------------------------------------------------------ */
.modal-content {
  background: var(--app-surface);
  border: 1px solid var(--app-border);
  color: var(--app-text);
}
.modal-header { border-bottom: 1px solid var(--app-border); }
.modal-footer { border-top: 1px solid var(--app-border); }
.btn-close { filter: var(--app-btn-close-filter); }

/* ------------------------------------------------------------
 *  Badge
 * ------------------------------------------------------------ */
.badge { font-weight: 600; font-size: 0.75rem; }

/* ------------------------------------------------------------
 *  ログインページ
 * ------------------------------------------------------------ */
/* --- ログイン画面: サイバー風デザイン --- */
@keyframes loginBgShift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes loginCardIn {
  from { opacity: 0; transform: translateY(30px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes loginGlow {
  0%, 100% { box-shadow: 0 0 30px rgba(91,159,230,0.15), 0 0 80px rgba(91,159,230,0.05), inset 0 0 30px rgba(91,159,230,0.02); }
  50%      { box-shadow: 0 0 50px rgba(91,159,230,0.25), 0 0 120px rgba(91,159,230,0.08), inset 0 0 40px rgba(91,159,230,0.04); }
}
@keyframes loginLogoGlow {
  0%, 100% { text-shadow: 0 0 8px rgba(91,159,230,0.4); }
  50%      { text-shadow: 0 0 20px rgba(91,159,230,0.7), 0 0 40px rgba(91,159,230,0.3); }
}
@keyframes scanline {
  0%   { top: -10%; }
  100% { top: 110%; }
}
@keyframes floatOrb {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.5; }
  33%      { transform: translate(30px, -40px) scale(1.1); opacity: 0.8; }
  66%      { transform: translate(-20px, 20px) scale(0.9); opacity: 0.4; }
}

.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #060810;
  background-image:
    radial-gradient(ellipse at 15% 80%, rgba(91,159,230,0.25) 0%, transparent 55%),
    radial-gradient(ellipse at 85% 15%, rgba(46,204,113,0.18) 0%, transparent 55%),
    radial-gradient(ellipse at 50% 50%, rgba(91,159,230,0.10) 0%, transparent 60%),
    radial-gradient(circle at 30% 30%, rgba(100,80,230,0.15) 0%, transparent 45%);
  background-size: 200% 200%;
  animation: loginBgShift 12s ease infinite;
  position: relative;
  overflow: hidden;
}

/* グリッドライン */
.login-wrapper::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(91,159,230,0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(91,159,230,0.08) 1px, transparent 1px);
  background-size: 50px 50px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
  -webkit-mask-image: radial-gradient(ellipse at center, black 40%, transparent 80%);
  pointer-events: none;
}

/* スキャンライン */
.login-wrapper::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, rgba(91,159,230,0.3), transparent);
  animation: scanline 6s linear infinite;
  pointer-events: none;
  z-index: 0;
}

/* 浮遊オーブ（JSなしでCSSのみ） */
.login-orb {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(40px);
  animation: floatOrb 8s ease-in-out infinite;
}
.login-orb--1 {
  width: 300px; height: 300px;
  background: rgba(91,159,230,0.20);
  top: 10%; left: 5%;
  animation-delay: 0s;
  animation-duration: 10s;
}
.login-orb--2 {
  width: 250px; height: 250px;
  background: rgba(46,204,113,0.15);
  top: 55%; right: 8%;
  animation-delay: -3s;
  animation-duration: 12s;
}
.login-orb--3 {
  width: 180px; height: 180px;
  background: rgba(100,80,230,0.18);
  bottom: 10%; left: 35%;
  animation-delay: -5s;
  animation-duration: 9s;
}

.login-card {
  width: 100%;
  max-width: 440px;
  background: rgba(18, 21, 30, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(91,159,230,0.2);
  border-radius: 20px;
  box-shadow: 0 0 30px rgba(91,159,230,0.15), 0 0 80px rgba(91,159,230,0.05);
  animation: loginCardIn 0.6s ease-out, loginGlow 4s ease-in-out infinite;
  position: relative;
  z-index: 1;
}
.login-card .card-header {
  background: transparent;
  border-bottom: 1px solid rgba(91,159,230,0.15);
  text-align: center;
  padding: 2.2rem 1.5rem 1.4rem;
}
.login-card .card-header h4 {
  margin-bottom: 0;
  font-weight: 800;
  font-size: 1.5rem;
  color: #fff;
  animation: loginLogoGlow 3s ease-in-out infinite;
}
.login-card .card-header h4 i {
  color: #5B9FE6;
}
.login-card .card-header .login-subtitle {
  color: #7a8bb5;
  font-size: 0.85rem;
  margin-top: 0.5rem;
  letter-spacing: 0.08em;
}
.login-card .card-header .text-muted { color: #7a8bb5 !important; }
.login-card .card-body { padding: 2rem 1.75rem; }

/* ログインフォーム入力欄のネオン風フォーカス */
.login-card .form-control {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(91,159,230,0.15);
  color: #eef0f5;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
  transition: all 0.2s ease;
}
.login-card .form-control:focus {
  background: rgba(255,255,255,0.06);
  border-color: #5B9FE6;
  box-shadow: 0 0 0 3px rgba(91,159,230,0.15), 0 0 15px rgba(91,159,230,0.1);
  color: #fff;
}
.login-card .form-control::placeholder {
  color: #4a5070;
}
.login-card .form-label {
  color: #8e9cc0;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* ログインボタン */
.login-card .btn-primary {
  background: linear-gradient(135deg, #5B9FE6 0%, #3a6fc4 50%, #5B9FE6 100%);
  background-size: 200% auto;
  border: none;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.7rem;
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.login-card .btn-primary:hover {
  background-position: right center;
  box-shadow: 0 4px 20px rgba(91,159,230,0.4);
  transform: translateY(-1px);
}

/* ロゴ画像がある場合のスペース */
.login-logo-img {
  width: 56px;
  height: 56px;
  margin-bottom: 0.75rem;
  filter: drop-shadow(0 0 12px rgba(91,159,230,0.5));
}

.mock-user-btn {
  border: 2px solid var(--app-border);
  border-radius: 10px;
  padding: 0.75rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  background: var(--app-surface-2);
  color: var(--app-text-muted);
}
.mock-user-btn:hover { border-color: var(--app-accent); background: var(--app-surface-3); color: var(--app-text); }
.mock-user-btn.selected { border-color: var(--app-accent); background: rgba(91, 159, 230, 0.1); color: var(--app-text); }

/* ------------------------------------------------------------
 *  トースト
 * ------------------------------------------------------------ */
#toast-container { z-index: 1090; }

/* ------------------------------------------------------------
 *  タブ
 * ------------------------------------------------------------ */
.nav-tabs { border-bottom-color: var(--app-border); }
.nav-tabs .nav-link { color: var(--app-text-muted); border: 1px solid transparent; }
.nav-tabs .nav-link:hover { border-color: var(--app-border); color: var(--app-text); }
.nav-tabs .nav-link.active {
  background: var(--app-surface);
  border-color: var(--app-border) var(--app-border) var(--app-surface);
  color: var(--app-accent);
  font-weight: 600;
}

/* ------------------------------------------------------------
 *  ページネーション
 * ------------------------------------------------------------ */
.page-link { background: var(--app-surface); border-color: var(--app-border); color: var(--app-text-muted); }
.page-link:hover { background: var(--app-surface-2); border-color: var(--app-border); color: var(--app-text); }
.page-item.active .page-link { background: var(--app-accent); border-color: var(--app-accent); color: #fff; }
.page-item.disabled .page-link { background: var(--app-surface); border-color: var(--app-border); color: var(--app-text-dim); }

/* ------------------------------------------------------------
 *  アコーディオン
 * ------------------------------------------------------------ */
.accordion-item { background: var(--app-surface); border-color: var(--app-border); }
.accordion-button { background: var(--app-surface-2); color: var(--app-text); }
.accordion-button:not(.collapsed) { background: var(--app-surface-3); color: var(--app-accent); }

/* ------------------------------------------------------------
 *  ドロップダウン
 * ------------------------------------------------------------ */
.dropdown-menu { background: var(--app-surface); border: 1px solid var(--app-border); }
.dropdown-item { color: var(--app-text); }
.dropdown-item:hover { background: var(--app-surface-2); color: var(--app-text); }

/* ============================================================
 *  レスポンシブ: タブレット (≤991px)
 * ============================================================ */
@media (max-width: 991.98px) {
  .app-sidebar { display: none; }
  .app-main { margin-left: 0; padding: 1rem; }
  .summary-card .card-value { font-size: 1.3rem; }

  /* ヘッダー: ブランド名を短縮表示用 */
  .app-header .navbar-brand { font-size: 0.95rem; }
  .app-header .navbar { padding: 0 0.5rem; }
}

/* ============================================================
 *  レスポンシブ: スマートフォン (≤767px)
 * ============================================================ */
@media (max-width: 767.98px) {
  /* --- ヘッダー --- */
  .app-header {
    height: 50px;
  }
  .app-body {
    padding-top: 50px;
  }
  .app-header .navbar {
    padding: 0 0.4rem;
    height: 50px;
  }
  .app-header .navbar-brand {
    font-size: 0.85rem;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .app-header .btn-outline-light {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
  }
  .app-header .text-white {
    font-size: 0.8rem;
  }
  .theme-toggle {
    padding: 0.2rem 0.4rem;
    font-size: 0.85rem;
  }
  /* ログアウトボタンテキスト非表示（アイコンのみ） */
  #btn-logout .btn-text-sp { display: none; }

  /* --- メインコンテンツ --- */
  .app-main {
    padding: 0.75rem;
  }

  /* --- ページタイトル --- */
  .app-main h4.fw-bold {
    font-size: 1.05rem;
  }
  .app-main .d-flex.flex-wrap {
    gap: 0.5rem;
  }

  /* --- サマリーカード --- */
  .summary-card .card-body { padding: 0.75rem; }
  .summary-card .card-title { font-size: 0.65rem; margin-bottom: 0.3rem; }
  .summary-card .card-value { font-size: 1.1rem; }
  .summary-card .card-sub { font-size: 0.68rem; }
  .summary-card .card-icon { font-size: 1.6rem; top: 6px; right: 8px; }

  /* --- テーブル: 横スクロール対応 --- */
  .app-table { border-radius: 8px; overflow: visible; }
  .app-table thead th {
    font-size: 0.7rem;
    padding: 0.5rem 0.4rem;
    letter-spacing: 0;
    white-space: nowrap;
  }
  .app-table tbody td {
    font-size: 0.78rem;
    padding: 0.45rem 0.4rem;
    white-space: nowrap;
  }
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto !important;
    overflow-y: visible;
    margin: 0 -0.25rem;
    padding: 0 0.25rem;
  }
  .table th, .table td {
    font-size: 0.78rem;
    padding: 0.4rem 0.35rem;
    white-space: nowrap;
  }
  /* table-responsiveでないテーブルも横スクロール可能にする */
  .card-body > .table,
  .card-body > table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* --- チャート --- */
  .chart-container {
    padding: 0.75rem;
    border-radius: 8px;
  }
  .chart-container h6 { font-size: 0.85rem; }
  .chart-container canvas { max-height: 220px; }

  /* --- カード --- */
  .card { border-radius: 8px; }
  .card-body { padding: 0.85rem; }
  .card h6 { font-size: 0.88rem; }

  /* --- フォーム --- */
  .form-control, .form-select {
    font-size: 0.88rem;
    padding: 0.5rem 0.6rem;
  }
  .form-label { font-size: 0.82rem; }
  .form-control-sm, .form-select-sm {
    font-size: 0.82rem;
    padding: 0.35rem 0.5rem;
  }

  /* --- ボタン --- */
  .btn { font-size: 0.85rem; }
  .btn-sm { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

  /* --- フィルタ行: 縦スタック --- */
  .app-main > .d-flex.flex-wrap {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 0.5rem;
  }
  /* セレクタ群を縦積み */
  .filter-row,
  .d-flex.align-items-center.gap-2.mt-2.mt-md-0 {
    display: flex !important;
    flex-direction: column !important;
    width: 100%;
    gap: 0.35rem;
  }
  .filter-row select,
  .filter-row .form-select,
  .d-flex.align-items-center.gap-2 select,
  .d-flex.align-items-center.gap-2 .form-select {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    font-size: 0.85rem;
  }
  .d-flex.align-items-center.gap-2 label {
    margin-bottom: 0;
  }

  /* --- モーダル --- */
  .modal-dialog { margin: 0.5rem; }
  .modal-content { border-radius: 12px; }

  /* --- 承認画面 --- */
  .btn-approve, .btn-reject { padding: 0.2rem 0.35rem; }

  /* --- レポートフォーム動的行: 縦スタック --- */
  .sales-row, .expense-row {
    flex-wrap: wrap;
  }
  .sales-row > div, .expense-row > div {
    flex: 0 0 100% !important;
    max-width: 100% !important;
  }
  .sales-row .btn-remove-row,
  .expense-row .btn-remove-row {
    width: 100%;
    margin-top: 0.25rem;
  }

  /* --- ページタイトル+フィルタ: 縦スタック --- */
  .app-main > .d-flex:first-child {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.5rem;
  }
  .app-main > .d-flex:first-child > .d-flex {
    width: 100%;
  }

  /* row内のcol-mdをスマホで縦並びに */
  .row.g-3 > [class*="col-md-"],
  .row.g-2 > [class*="col-md-"] {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* ============================================================
 *  レスポンシブ: 小型スマートフォン (≤400px)
 * ============================================================ */
@media (max-width: 400px) {
  .app-header .navbar-brand {
    max-width: 100px;
    font-size: 0.75rem;
  }
  .app-main { padding: 0.5rem; }
  .summary-card .card-value { font-size: 0.95rem; }
  .summary-card .card-title { font-size: 0.6rem; }
  .summary-card .card-body { padding: 0.55rem; }

  .chart-container canvas { max-height: 180px; }

  .table th, .table td {
    font-size: 0.7rem;
    padding: 0.3rem 0.25rem;
    white-space: nowrap;
  }

  /* フィルタを1列に */
  .d-flex.align-items-center.gap-2 {
    grid-template-columns: 1fr !important;
  }
}

/* ============================================================
 *  レスポンシブ: ログイン画面 スマホ対応
 * ============================================================ */
@media (max-width: 767.98px) {
  .login-wrapper { padding: 1rem; }
  .login-card {
    max-width: 100%;
    border-radius: 16px;
  }
  .login-card .card-header {
    padding: 1.5rem 1.25rem 1rem;
  }
  .login-card .card-header h4 { font-size: 1.25rem; }
  .login-card .card-body { padding: 1.25rem; }
  .login-orb { display: none; }
}

/* ============================================================
 *  カレンダーセル共通
 * ============================================================ */
.cal-cell {
  height: 70px;
}
.cal-day {
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 1px;
}
.cal-worker {
  font-size: 0.6rem;
  line-height: 1.15;
  color: var(--app-accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cal-star {
  color: #F0A04B;
  font-size: 1.1rem;
}

/* ============================================================
 *  レスポンシブ: カレンダー スマホ対応
 * ============================================================ */
@media (max-width: 767.98px) {
  #calendar-container .table {
    table-layout: fixed;
    width: 100%;
  }
  #calendar-container .table th {
    font-size: 0.65rem;
    padding: 0.25rem 0;
  }
  .cal-cell {
    height: auto;
    min-height: 44px;
    padding: 1px !important;
  }
  .cal-day {
    font-size: 0.65rem;
    margin-bottom: 0;
  }
  .cal-worker {
    font-size: 0.45rem;
    line-height: 1.1;
  }
  .cal-star {
    font-size: 0.8rem;
  }
}

/* ============================================================
 *  オフキャンバス（モバイルサイドバー）強化
 * ============================================================ */
.app-sidebar-offcanvas {
  max-width: 85vw;
}
@media (max-width: 767.98px) {
  .app-sidebar-offcanvas {
    width: 260px !important;
    top: 0 !important;
    padding-top: 0;
  }
  .app-sidebar-offcanvas .offcanvas-header {
    height: 50px;
    min-height: 50px;
    padding: 0 1rem;
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--app-sidebar-bg);
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .app-sidebar-offcanvas .offcanvas-body {
    padding-top: 0.5rem;
    overflow-y: auto;
  }
  .app-sidebar-offcanvas .sidebar-link {
    padding: 0.7rem 0.9rem;
    font-size: 0.9rem;
  }
}
/* オフキャンバスがAppBarの上に表示されるよう z-index を確保 */
.offcanvas.app-sidebar-offcanvas {
  z-index: 1060 !important;
}
.offcanvas-backdrop {
  z-index: 1055 !important;
}

/* ------------------------------------------------------------
 *  ユーティリティ
 * ------------------------------------------------------------ */
.text-sales      { color: var(--color-sales) !important; }
.text-profit     { color: var(--color-profit) !important; }
.text-water      { color: var(--color-water) !important; }
.text-unext      { color: var(--color-unext) !important; }
.text-gas        { color: var(--color-gas) !important; }
.text-travel     { color: var(--color-travel) !important; }
.text-personnel  { color: var(--color-personnel) !important; }
.text-expense    { color: var(--color-expense) !important; }
.text-other      { color: var(--color-other) !important; }

h4.fw-bold { color: var(--app-text); }
h5 { color: var(--app-text); }
.cursor-pointer { cursor: pointer; }
.nowrap { white-space: nowrap; }

/* ============================================================
 *  ページヘッダー + フィルタコントロール
 * ============================================================ */
.page-header-block {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}
.filter-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.filter-item {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.filter-item label {
  white-space: nowrap;
  margin-bottom: 0 !important;
}
.filter-period {
  flex-wrap: nowrap;
}

/* スマホ: 縦スタック */
@media (max-width: 767.98px) {
  .page-header-block {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
  }
  .filter-item {
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem;
  }
  .filter-item select,
  .filter-item .form-select {
    width: 100% !important;
  }
  .filter-period {
    display: flex;
    gap: 0.3rem;
  }
  .filter-period select {
    flex: 1;
    min-width: 0;
  }
}

/* テーブル横スクロールヒント */
.table-responsive { position: relative; }
.table-responsive::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: 20px;
  background: linear-gradient(90deg, transparent, var(--app-surface));
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.table-responsive.is-scrollable::after { opacity: 1; }

/* ============================================================
 *  ユーティリティ: inline style 代替クラス
 * ============================================================ */

/* ログイン画面アイコン */
.login-compass-icon { font-size: 2.5rem; color: #5B9FE6; filter: drop-shadow(0 0 12px rgba(91,159,230,0.5)); }

/* 汎用非表示 */
.d-none-init { display: none; }

/* DEV テストユーザーセクション */
.dev-section { border-top: 1px solid var(--app-border); }
.dev-label { color: var(--app-text-dim); }

/* チャートコンテナ高さ */
.chart-h-300 { height: 300px; }
.chart-h-280 { height: 280px; }

/* フィードバックカード */
.feedback-card { max-width: 700px; }

/* フォーム入力幅制限 */
.input-w-200 { max-width: 200px; }

/* セレクト幅自動 */
.select-w-auto { width: auto; min-width: 150px; }
.select-w-auto-lg { width: auto; min-width: 180px; }

/* テーブルレイアウト固定 */
.table-fixed { table-layout: fixed; }

/* カレンダーセル */
.cal-cell-top { vertical-align: top; padding: 2px; overflow: hidden; word-break: break-all; }
.cal-cell-active { background: rgba(91,159,230,0.08); }

/* ソートカーソル */
.sort-header { cursor: pointer; user-select: none; }

/* 承認テーブルヘッダー幅 */
.th-w-40 { width: 40px; }
.th-w-40pct { width: 40%; }
.th-w-100 { width: 100px; }

/* カレンダー曜日幅 */
.cal-day-col { width: 14.28%; }
