/* ============================================================
   日本クラウディア Cloudia HUB — メインスタイル
   Bootstrap 5 ベース
   ============================================================ */

/* ------------------------------------------------------------
   CSS変数（カラーパレット）
   ------------------------------------------------------------ */
:root {
  --sidebar-bg:        #1e3a5f;
  --sidebar-bg-hover:  #2a5080;
  --sidebar-bg-active: #162e4d;
  --sidebar-text:      #bdd5ee;
  --sidebar-text-muted:#6e9abf;
  --sidebar-accent:    #60c0f8;
  --sidebar-width:     210px;
  --sidebar-width-sm:  64px;

  --header-bg:         #ffffff;
  --header-height:     60px;
  --header-border:     #dde8f5;
  --header-shadow:     0 2px 8px rgba(59,130,246,.10);

  --page-bg:           #edf2fb;
  --card-bg:           #ffffff;
  --card-shadow:       0 2px 8px rgba(59,130,246,.08);
  --card-radius:       12px;

  --primary:           #3b82f6;
  --primary-dark:      #2563eb;
  --success:           #22c55e;
  --warning:           #f59e0b;
  --danger:            #ef4444;
  --info:              #06b6d4;

  --text:              #1e293b;
  --text-muted:        #64748b;
  --border:            #dde8f5;

  --transition:        .22s ease;
}

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

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif;
  font-size: 15px;
  color: var(--text);
  background: var(--page-bg);
  background-image: radial-gradient(ellipse at 20% 0%, rgba(59,130,246,.07) 0%, transparent 60%),
                    radial-gradient(ellipse at 80% 100%, rgba(99,102,241,.05) 0%, transparent 60%);
  background-attachment: fixed;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-dark); }

/* ============================================================
   ログイン画面
   ============================================================ */
body.page-login {
  background: linear-gradient(135deg, #1e3a5f 0%, #243447 50%, #1a2a38 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

.login-wrap {
  width: 100%;
  max-width: 400px;
  padding: 24px 16px;
}

.login-card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
  overflow: hidden;
}

.login-card-header {
  background: var(--sidebar-bg);
  padding: 32px 32px 24px;
  text-align: center;
  color: #fff;
}

.login-card-header .system-icon {
  font-size: 40px;
  color: var(--sidebar-accent);
  margin-bottom: 12px;
}

.login-card-header h1 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 4px;
  letter-spacing: .5px;
}

.login-card-header p {
  font-size: 12px;
  color: var(--sidebar-text);
  margin: 0;
  letter-spacing: 1px;
}

.login-card-body {
  padding: 32px;
}

.login-card-body .form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.login-card-body .form-control {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px 10px 40px;
  font-size: 14px;
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.login-card-body .form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.15);
  outline: none;
}

.input-with-icon {
  position: relative;
}

.input-with-icon .field-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
  font-size: 15px;
  pointer-events: none;
}

.btn-login {
  width: 100%;
  padding: 11px;
  font-size: 15px;
  font-weight: 600;
  background: linear-gradient(135deg, #4f90f8, #2563eb);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(59,130,246,.4);
  transition: filter var(--transition), transform .1s, box-shadow var(--transition);
  letter-spacing: .3px;
}

.btn-login:hover  { filter: brightness(1.08); box-shadow: 0 6px 20px rgba(59,130,246,.5); }
.btn-login:active { transform: scale(.98); }

.login-alert {
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 6px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.login-alert i { margin-top: 2px; flex-shrink: 0; }

.login-maintenance {
  font-size: 13px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #fff7ed;
  border: 1px solid #fdba74;
  color: #9a3412;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.7;
  font-weight: 600;
}
.login-maintenance i {
  margin-top: 3px;
  flex-shrink: 0;
  font-size: 16px;
  color: #c2410c;
}

.login-footer {
  text-align: center;
  margin-top: 20px;
  font-size: 12px;
  color: rgba(255,255,255,.45);
}

.login-forgot {
  text-align: center;
  margin-top: 16px;
  font-size: 13px;
}
.login-forgot a {
  color: #64748b;
  text-decoration: none;
  border-bottom: 1px dotted #cbd5e1;
  padding-bottom: 1px;
  transition: color var(--transition), border-color var(--transition);
}
.login-forgot a:hover {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* パスワード再設定画面：パスワード提案 */
.rp-suggest-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.rp-btn-suggest {
  background: #eef2ff;
  color: #4338ca;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: background .15s;
}
.rp-btn-suggest:hover { background: #e0e7ff; }
.rp-pw-preview {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: #f0fdf4;
  border: 1px solid #86efac;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
}
.rp-pw-preview-label { font-size: 12px; color: #15803d; font-weight: 700; }
.rp-pw-preview-value {
  font-family: 'Courier New', Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  color: #1e293b;
  background: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #86efac;
  letter-spacing: .5px;
}
.rp-btn-copy {
  background: #fff;
  color: #15803d;
  border: 1px solid #86efac;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  cursor: pointer;
  margin-left: auto;
  transition: background .15s;
}
.rp-btn-copy:hover { background: #ecfdf5; }
.rp-btn-copy.is-copied { background: #86efac; color: #065f46; }

/* ============================================================
   管理画面レイアウト
   ============================================================ */

/* --- ヘッダー --- */
#app-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: linear-gradient(to right, var(--sidebar-bg) var(--sidebar-width), #ffffff var(--sidebar-width));
  border-bottom: 1px solid var(--header-border);
  box-shadow: var(--header-shadow);
  display: flex;
  align-items: center;
  z-index: 1000;
  padding: 0 20px 0 0;
}

.header-brand {
  width: var(--sidebar-width);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 100%;
  background: transparent;
  text-decoration: none;
  transition: width var(--transition);
}

.header-brand .brand-icon {
  font-size: 20px;
  color: var(--sidebar-accent);
  flex-shrink: 0;
}

.header-brand .brand-text {
  margin-left: 10px;
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity var(--transition), max-width var(--transition);
  max-width: 200px;
  letter-spacing: .3px;
}

.header-sidebar-toggle {
  margin-left: 16px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  transition: background var(--transition), color var(--transition);
  line-height: 1;
  display: none;  /* PC では非表示（サイドバーは常に開いた状態）。モバイルでは @media で再表示 */
}

.header-sidebar-toggle:hover {
  background: #f1f5f9;
  color: var(--primary);
}

.header-spacer { flex: 1; display: flex; align-items: center; min-width: 0; }

.header-hint {
  display: inline-flex;
  align-items: center;
  margin-left: 18px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  white-space: nowrap;
  letter-spacing: .3px;
  box-shadow: 0 1px 2px rgba(37, 99, 235, .08);
}
.header-hint i { color: #f59e0b; }

/* ============================================================
   状態誘導ハイライト（パルス）
   ユーザーを次のアクションに誘導するために、カード外枠やボタンを
   一定周期で光らせる。`is-guide-pulse` クラスを JS で付け外しする。
   二重の box-shadow（内側のリング + 外側の広がり）で太めに強調。
   ============================================================ */
@keyframes guidePulse {
  0% {
    box-shadow:
      0 0 0  0px rgba(37, 99, 235, .85),
      0 0 0  0px rgba(59, 130, 246, .45);
  }
  50% {
    box-shadow:
      0 0 0  8px rgba(37, 99, 235, .55),
      0 0 0 20px rgba(59, 130, 246, .15);
  }
  100% {
    box-shadow:
      0 0 0  0px rgba(37, 99, 235, 0),
      0 0 0  0px rgba(59, 130, 246, 0);
  }
}
.is-guide-pulse {
  position: relative;
  animation: guidePulse 1.8s ease-in-out infinite;
  border-radius: inherit;
}
/* カード本体に適用された場合は外枠も強調 */
.app-card.is-guide-pulse {
  border-color: #2563eb;
  border-width: 2px;
}

/* ------------------------------------------------------------
   overflow:hidden な親（.app-card）の内側に配置される要素用の
   パルス。外向き box-shadow は親に切り取られ、inset box-shadow は
   子要素の背景（thead/tfoot）に隠れるため、疑似要素オーバーレイで
   最前面に描画する。
   .app-card-body（テーブル領域）と .summary-grid が対象。
   ------------------------------------------------------------ */
@keyframes guideBorderPulse {
  0%, 100% {
    border-color: rgba(37, 99, 235, .55);
    box-shadow: inset 0 0 0 0 rgba(59, 130, 246, 0);
  }
  50% {
    border-color: rgba(37, 99, 235, 1);
    box-shadow: inset 0 0 18px 2px rgba(59, 130, 246, .35);
  }
}
.app-card-body.is-guide-pulse,
.summary-grid.is-guide-pulse {
  position: relative;
  animation: none;           /* 基底 .is-guide-pulse の外向き animation を無効化 */
  outline: none;
  border-radius: 8px;
}
.app-card-body.is-guide-pulse::after,
.summary-grid.is-guide-pulse::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  box-sizing: border-box;
  border: 3px solid rgba(37, 99, 235, 1);
  border-radius: 8px;
  pointer-events: none;
  z-index: 3;
  animation: guideBorderPulse 1.4s ease-in-out infinite;
}

/* ボタンは発光でフォーカスされるよう上に重ねる */
button.is-guide-pulse {
  position: relative;
  z-index: 1;
}

/* ============================================================
   ステータスバッジ統一パレット（全画面共通）
   業務報告書／経費精算／交通費精算／ダッシュボード／報告管理 で
   同じステータスが同じ色で表示されるよう、共通カラーを定義する。

   確定済 (confirmed)  : 緑系
   提出済 (submitted)  : 青系
   差し戻し (returned) : オレンジ系
   未提出 (draft/saved/none) : 薄いグレー
   精算なし (no_settlement)  : 濃いグレー
   ============================================================ */
.status-confirmed-color  { background: #f0fdf4; color: #15803d; border: 1px solid #86efac; }
.status-submitted-color  { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.status-returned-color   { background: #fff7ed; color: #c2410c; border: 1px solid #fdba74; }
.status-draft-color      { background: #f1f5f9; color: #64748b; border: 1px solid #e2e8f0; }
.status-nosettle-color   { background: #e2e8f0; color: #334155; border: 1px solid #94a3b8; }

/* 経費精算 OCR 完了後の確認メッセージ（画像プレビュー直下） */
.exp-ocr-notice {
  margin-top: 8px;
  padding: 8px 12px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 3px solid #2563eb;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #1d4ed8;
  line-height: 1.5;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text);
}

.header-user .user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
}

.header-user .user-name {
  font-weight: 600;
  font-size: 14px;
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn-logout:hover {
  background: #fef2f2;
  color: var(--danger);
  border-color: #fecaca;
}

/* --- サイドバー --- */
#app-sidebar {
  position: fixed;
  top: var(--header-height);
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  overflow-y: auto;
  overflow-x: hidden;
  /* サイドバー内のホイール／タッチスクロールが body 側に伝播してメインコンテンツが
     一緒にスクロールするのを防止（スクロールチェーン抑止） */
  overscroll-behavior: contain;
  z-index: 900;
  transition: width var(--transition);
  display: flex;
  flex-direction: column;
}

#app-sidebar::-webkit-scrollbar { width: 4px; }
#app-sidebar::-webkit-scrollbar-thumb { background: #2a5080; border-radius: 4px; }

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--sidebar-text-muted);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 16px 20px 6px;
  white-space: nowrap;
  overflow: hidden;
}

.nav-item {
  list-style: none;
  margin: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--sidebar-text);
  font-size: 15px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  position: relative;
}

.nav-link:hover {
  background: var(--sidebar-bg-hover);
  color: #fff;
}

/* 現在閲覧中メニュー：オレンジのグラデーション背景＋bold＋下線（二重線）。
   左端には光るシェブロン（>）。テキストシャドウで発光させ、緩やかに明滅。 */
.nav-link.active {
  background: linear-gradient(to right, rgba(251,146,60,.30), rgba(251,146,60,.04));
  color: #fff;
  font-weight: 700;
}

.nav-link.active::before {
  content: '\f054'; /* Font Awesome fa-chevron-right (solid) */
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 4px;
  top: 0;
  bottom: 0;
  width: 14px;
  font-size: 11px;
  color: #fb923c;
  background: none;
  border-radius: 0;
  text-shadow:
    0 0 6px rgba(251,146,60,.85),
    0 0 12px rgba(251,146,60,.45);
  animation: navActiveChevron 1.8s ease-in-out infinite;
  pointer-events: none;
}

@keyframes navActiveChevron {
  0%, 100% {
    color: #f59e0b;
    text-shadow:
      0 0 4px rgba(245,158,11,.55),
      0 0 10px rgba(245,158,11,.20);
  }
  50% {
    color: #fde68a;
    text-shadow:
      0 0 8px rgba(251,191,36,1),
      0 0 18px rgba(251,146,60,.55);
  }
}

/* 現在閲覧中メニュー名：太字＋二重下線（オフホワイトで品よく） */
.nav-link.active .nav-label,
.sub-nav .nav-link.active .nav-label {
  text-decoration: underline double;
  text-decoration-color: rgba(255,255,255,.7);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  font-weight: 700;
}

.nav-link .nav-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
  color: var(--sidebar-text-muted);
  transition: color var(--transition);
}

.nav-link:hover .nav-icon,
.nav-link.active .nav-icon {
  color: var(--sidebar-accent);
}

.nav-link .nav-label {
  flex: 1;
  overflow: hidden;
  transition: opacity var(--transition);
}

/* 親メニュー（has-sub）：<button> 要素として描画。
   行全体がクリック領域でサブメニューの折りたたみ／展開をトグルする（リンク機能はなし）。
   背景は付与せず、文字色とアイコン色だけで親であることを軽く示す。 */
.nav-item.has-sub .nav-link.nav-parent {
  color: #fff;
}
.nav-item.has-sub .nav-link.nav-parent .nav-icon {
  color: var(--sidebar-accent);
}

/* 親メニュー右端のシェブロン（インライン要素）
   クリック判定は親メニュー全体に乗っているため、これは視覚的なインジケータのみ。
   折りたたみ中は -90° 回転して上向き（▷ → ▽ の逆方向）になる。 */
.nav-submenu-chevron {
  margin-left: auto;     /* label の flex:1 で既に右寄せされるが冗長性確保 */
  font-size: 11px;
  color: var(--sidebar-text-muted);
  flex-shrink: 0;
  transition: transform .2s ease, color .2s ease;
  pointer-events: none;  /* ボタン全体のクリックを拾うため、子要素はイベントを拾わせない */
}
.nav-link.nav-parent:hover .nav-submenu-chevron {
  color: #fff;
}
.nav-item.has-sub.is-submenu-collapsed .nav-submenu-chevron {
  transform: rotate(-90deg);
}
.nav-item.has-sub.is-submenu-collapsed > .sub-nav {
  display: none;
}

/* サブメニュー：既定では展開状態。折りたたみは .is-submenu-collapsed で制御 */
.sub-nav {
  list-style: none;
  padding: 0;
  margin: 0;
  background: rgba(0,0,0,.12);
}
/* 初期描画時のチラつき抑制（クラス付与前のトランジション無効化） */
body.nav-preload .sub-nav,
body.nav-preload .nav-link,
body.nav-preload .nav-icon,
body.nav-preload .nav-submenu-chevron { transition: none !important; }

.sub-nav .nav-link {
  padding: 9px 20px 9px 52px;
  font-size: 14px;
  font-weight: 400;
  position: relative;
}

/* 全ての子メニューに「┗」を表示し、親メニューのサブであることを視覚化。
   通常時はミュートカラー、現在閲覧中はオレンジで発光。 */
.sub-nav .nav-link::before {
  content: '\2517'; /* ┗ HEAVY UP AND RIGHT (Box Drawings) */
  font-family: inherit;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 28px;
  top: 0;
  bottom: 0;
  width: 14px;
  font-size: 14px;
  color: rgba(255,255,255,.40);
  background: none;
  border-radius: 0;
  text-shadow: none;
  animation: none;
  pointer-events: none;
}

/* 現在閲覧中の子メニュー：オレンジ・グラデーション背景。
   ┗ も明るくオレンジで発光させ、現在地であることを強調する。 */
.sub-nav .nav-link.active {
  background: linear-gradient(to right, rgba(251,146,60,.30), rgba(251,146,60,.04));
  color: #fff;
  font-weight: 700;
}
.sub-nav .nav-link.active::before {
  content: '\2517'; /* ┗ */
  font-family: inherit;
  font-weight: 700;
  color: #fb923c;
  font-size: 14px;
  text-shadow:
    0 0 6px rgba(251,146,60,.85),
    0 0 12px rgba(251,146,60,.45);
  animation: navActiveChevron 1.8s ease-in-out infinite;
}
.sub-nav .nav-link.active .nav-icon {
  color: var(--sidebar-accent);
}

/* サイドバー：未提出／差し戻しの注意バッジ
   nav-link の右端でパルス。子メニュー（sub-nav）にも親メニューにも使用 */
.nav-link .nav-alert-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-left: 8px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
  animation: nav-alert-pulse 1.5s ease-in-out infinite;
}
.nav-link .nav-alert-badge::before {
  content: "";
}
@keyframes nav-alert-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0.7); transform: scale(1); }
  60%  { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);   transform: scale(1.08); }
  100% { box-shadow: 0 0 0 0   rgba(239, 68, 68, 0);   transform: scale(1); }
}

/* --- メインコンテンツ --- */
#app-main {
  margin-left: var(--sidebar-width);
  margin-top: var(--header-height);
  min-height: calc(100vh - var(--header-height) - 48px);
  padding: 32px 32px 0;
  transition: margin-left var(--transition);
}

/* --- フッター --- */
#app-footer {
  margin-left: var(--sidebar-width);
  padding: 16px 32px;
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  background: var(--page-bg);
  transition: margin-left var(--transition);
  margin-top: 32px;
}

/* ============================================================
   カード・パネル
   ============================================================ */
.app-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  margin-bottom: 24px;
  overflow: hidden;
}

.app-card-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(to right, #f0f7ff, #fafcff);
  border-left: 4px solid var(--primary);
}

.app-card-header i {
  color: var(--primary);
  font-size: 16px;
}
.app-card-header .btn-primary-sm i,
.app-card-header .btn-secondary-sm i,
.app-card-header .btn-period i {
  color: inherit;
}

.app-card-header-toggle {
  transition: background var(--transition);
  user-select: none;
}
.app-card-header-toggle:hover {
  background: linear-gradient(to right, #e0efff, #f0f7ff);
}
.app-card-header-toggle.is-open {
  background: linear-gradient(to right, #f0f7ff, #fafcff);
}

.app-card-body {
  padding: 24px;
}

/* ============================================================
   サマリーカード（ダッシュボード）
   ============================================================ */
.stat-card {
  background: var(--card-bg);
  border-radius: var(--card-radius);
  box-shadow: var(--card-shadow);
  border: 1px solid var(--border);
  padding: 20px 22px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  overflow: hidden;
  transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(to right, var(--primary), #818cf8);
  opacity: 0;
  transition: opacity var(--transition);
}

.stat-card:hover {
  box-shadow: 0 6px 24px rgba(59,130,246,.15);
  transform: translateY(-2px);
}

.stat-card:hover::after { opacity: 1; }

.stat-card-icon {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon-blue   { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #2563eb; }
.stat-icon-green  { background: linear-gradient(135deg, #dcfce7, #bbf7d0); color: #16a34a; }
.stat-icon-orange { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #d97706; }
.stat-icon-red    { background: linear-gradient(135deg, #fee2e2, #fecaca); color: #dc2626; }

.stat-card-body { flex: 1; }

.stat-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-value small {
  font-size: 15px;
  font-weight: 500;
}

.stat-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ============================================================
   テーブル sticky ヘッダ
   一覧が長くなった場合に縦スクロールしても項目名が常に見えるよう、
   thead を画面上端（または固定ヘッダの直下）に貼り付ける。
   - 通常画面：ページヘッダ（fixed・60px）の直下にスティック
   - 管理者ビュー（#app-header 非表示時）：各ページの <style> 側で
     `--sticky-th-top: 0px` に上書きして top: 0 にスティック
   `position: sticky !important` は .exp-sortable / .trn-sortable /
   .app-sortable の position: relative を確実に上書きするため。
   sticky 自体が positioning context を提供するので ::after の
   sort arrow（position: absolute）は引き続き正しく動作する。
   ============================================================ */
:root { --sticky-th-top: var(--header-height); }

/* sticky thead を実際に機能させるには、ancestor の overflow:hidden を解除する必要がある。
   .app-card は既定で overflow:hidden（角丸クリッピングと is-guide-pulse 内部疑似要素のため）
   だが、sticky を使うカードでは visible に上書きする。
   .app-card.is-guide-pulse のアウター box-shadow は親 overflow に影響されないため、
   guide pulse 機能は引き続き正常動作する。 */
.app-card.has-sticky-table { overflow: visible; }
.app-card.has-sticky-table .app-card-body { overflow: visible; }

/* sticky を <th> に適用。border-collapse: collapse のテーブルでも Chrome 91+ /
   Firefox 87+ / Safari 14+ で正常動作。!important は .exp-sortable / .trn-sortable /
   .app-sortable の position: relative を確実に上書きするため。
   sticky 自体が positioning context を提供するので ::after の sort arrow
   （position: absolute）は引き続き正しく動作する。 */
.has-sticky-table .app-table thead th,
.has-sticky-table .exp-table thead th,
.has-sticky-table .trn-table thead th,
.has-sticky-table .report-table thead th,
.has-sticky-table .oex-table thead th {
  position: sticky !important;
  top: var(--sticky-th-top);
  z-index: 5;
  /* th 自体に背景を持たせる（collapse のテーブルでも sticky 時に下層が透けないよう保証） */
  background-clip: padding-box;
}

/* ============================================================
   sticky カードヘッダ（月ナビを含むヘッダ全体を固定）
   業務報告書／経費精算／交通費精算／その他経費精算 の社員ビューのみ
   .has-sticky-header クラスを付与して有効化（admin view 子画面は除外）。
   - card-header を画面上部（ページヘッダ直下）にスティック
   - thead の top を calc(--sticky-th-top + --card-header-h) に上書きして
     card-header の真下に積み重ねる
   - card-header の実高さ（モバイル wrap で変化する）は app.js が
     ResizeObserver で --card-header-h に反映する
   ============================================================ */
.app-card.has-sticky-header .app-card-header {
  position: sticky;
  top: var(--sticky-th-top);
  z-index: 6;          /* thead (z-index:5) より前面 */
  background: var(--card-bg, #fff);
}
.has-sticky-header .app-table thead th,
.has-sticky-header .exp-table thead th,
.has-sticky-header .trn-table thead th,
.has-sticky-header .report-table thead th,
.has-sticky-header .oex-table thead th {
  top: calc(var(--sticky-th-top) + var(--card-header-h, 0px));
}

/* ============================================================
   テーブル
   ============================================================ */
.app-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.app-table th {
  background: linear-gradient(to bottom, #f0f7ff, #f8fafc);
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.app-table td {
  padding: 13px 18px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: var(--text);
}

.app-table tbody tr:last-child td { border-bottom: none; }

.app-table tbody tr:hover { background: #f0f7ff; }
.app-table tbody tr.summary-row { cursor: pointer; }
.app-table tbody tr.summary-row:hover { background: #e8f3ff; }

.app-table tfoot th {
  background: #f1f5f9;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

/* ステータスバッジ */
.badge-ok      { color: #166534; background: linear-gradient(135deg, #dcfce7, #bbf7d0); border-radius: 20px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.badge-fail    { color: #991b1b; background: linear-gradient(135deg, #fee2e2, #fecaca); border-radius: 20px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.badge-info-soft   { color: #075985; background: linear-gradient(135deg, #e0f2fe, #bae6fd); border-radius: 20px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.badge-warn-soft   { color: #78350f; background: linear-gradient(135deg, #fef3c7, #fde68a); border-radius: 20px; padding: 3px 12px; font-size: 13px; font-weight: 700; }
.badge-danger-soft { color: #991b1b; background: linear-gradient(135deg, #fee2e2, #fecaca); border-radius: 20px; padding: 3px 12px; font-size: 13px; font-weight: 700; }

/* ============================================================
   お知らせリスト
   ============================================================ */
.notice-list { list-style: none; margin: 0; padding: 0; }

.notice-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #f1f5f9;
  font-size: 14px;
}

.notice-list li:last-child { border-bottom: none; }

.notice-list .notice-tag {
  flex-shrink: 0;
  margin-top: 1px;
}

.notice-list .notice-text { flex: 1; color: var(--text); }

.notice-list .notice-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-top: 1px;
}

/* ============================================================
   日時バー
   ============================================================ */
.datetime-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 24px;
}

.datetime-bar i { color: var(--primary); }

/* ============================================================
   汎用ソートヘッダー（任意のテーブル <th> に .app-sortable を付与）
   ・無指定：薄いダブルアロー（ニュートラル）
   ・.is-asc：青の下向きトライアングル（昇順）
   ・.is-desc：青の上向きトライアングル（降順）
   既存の .exp-table .exp-sortable と同じ視覚デザインを共通化したもの。
   新規導入ページは th に .app-sortable + data-sort="フィールド名" を付ける。
   ・table.app-table th.app-sortable / table.ra-table th.app-sortable は
     その親テーブル側 padding（shorthand）に上書きされないよう同等以上の
     詳細度で padding-right を確保している。
   ============================================================ */
th.app-sortable,
table.app-table th.app-sortable,
table.ra-table th.app-sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 22px;
}
th.app-sortable:hover,
table.app-table th.app-sortable:hover,
table.ra-table th.app-sortable:hover { background: #dbeafe; }
th.app-sortable::after {
  content: '';
  position: absolute;
  right: 8px; top: 50%;
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #cbd5e1;
  border-bottom: 5px solid #cbd5e1;
  transform: translateY(-50%);
  opacity: .4;
}
th.app-sortable.is-asc::after {
  border-top: none;
  border-bottom: 5px solid #2563eb;
  opacity: 1;
}
th.app-sortable.is-desc::after {
  border-bottom: none;
  border-top: 5px solid #2563eb;
  opacity: 1;
}

/* ============================================================
   源泉所得税納付書（partner_invoice 内のカード）
   ============================================================ */
.wt-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  background: #fafbfc;
}
.wt-drop-zone {
  flex: 1 1 auto;
  min-height: 56px;
  padding: 8px 12px;
  border: 1.5px dashed #cbd5e1;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  font-size: 13px;
  text-align: center;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  line-height: 1.4;
  transition: background-color .12s, border-color .12s;
  user-select: none;
}
.wt-drop-zone:hover { background: #f1f5f9; border-color: #94a3b8; }
.wt-drop-zone.is-dragover {
  background: #eff6ff;
  border-color: #2563eb;
  color: #2563eb;
}
.wt-drop-zone.has-file {
  background: #ecfdf5;
  border-color: #10b981;
  border-style: solid;
  color: #047857;
  font-weight: 600;
  text-align: left;
  justify-content: flex-start;
  cursor: default;
}
.wt-drop-text {
  display: inline-block;
}
.wt-drop-filename {
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}
.wt-row-clear-file {
  border: 1px solid #fca5a5;
  background: #fff5f5;
  color: #ef4444;
  border-radius: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 12px;
  margin-left: auto;
  transition: background-color .12s, color .12s;
}
.wt-row-clear-file:hover { background: #ef4444; color: #fff; }

#wt-tbody .wt-open-file {
  color: #2563eb;
  text-decoration: none;
}
#wt-tbody .wt-open-file:hover { text-decoration: underline; }

/* ---- 源泉所得税納付書 アップロードプログレスバー ---- */
.wt-progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: 5px;
  overflow: hidden;
  position: relative;
}
.wt-progress-bar {
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #3b82f6, #2563eb);
  border-radius: 5px;
  transition: width 0.18s ease;
}
.wt-progress-bar.is-indeterminate {
  width: 100% !important;
  background: linear-gradient(90deg,
              #2563eb 0%, #2563eb 30%,
              #93c5fd 50%,
              #2563eb 70%, #2563eb 100%);
  background-size: 200% 100%;
  animation: wtProgressStripe 1.1s linear infinite;
}
@keyframes wtProgressStripe {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ============================================================
   レスポンシブ（スマートフォン対応）
   ============================================================ */
@media (max-width: 1024px) {
  #app-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition), width var(--transition);
    width: var(--sidebar-width) !important;
  }

  body.mobile-menu-open #app-sidebar {
    transform: translateX(0);
  }

  .header-brand { width: auto; padding: 0 16px; }
  .header-brand .brand-text { max-width: 140px; }

  #app-main,
  #app-footer {
    margin-left: 0 !important;
  }
}

/* ============================================================
   モーダル（ポップアップ）
   ============================================================ */

/* オーバーレイ：画面全体を暗くして中央にポップアップ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 2000;
  display: none;               /* 通常は非表示 */
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* display:flex で中央ポップアップとして表示 */
.modal-overlay[style*="display: flex"],
.modal-overlay[style*="display:flex"] {
  display: flex !important;
}

/* ダイアログ本体 */
.modal-dialog-custom {
  background: #fff;
  border-radius: 12px;
  width: 100%;
  max-width: 620px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
  animation: modalPopIn .2s ease;
  position: relative;
}

@keyframes modalPopIn {
  from { opacity: 0; transform: scale(.94) translateY(-12px); }
  to   { opacity: 1; transform: scale(1)  translateY(0);      }
}

/* ドラッグ対応モーダルはサイズ変更も可能（右下のグリップを掴んで拡縮）
   - .is-draggable-modal は app.js の enableModalDragOn() が付与
   - resize:both には overflow が visible 以外であることが必要
   - 初期表示の幅・高さは各モーダルのインライン style="max-width:540px;" 等を尊重する。
     ユーザーがリサイズ操作を始めると app.js 側の MutationObserver が inline max-width
     /max-height を 100vw / 100vh に拡張し、画面いっぱいまで広げられるようにする */
.modal-dialog-custom.is-draggable-modal {
  resize: both;
  overflow: hidden;
  min-width: 320px;
  min-height: 220px;
}
/* WebKit / Blink 系のリサイズグリップを少し見やすく */
.modal-dialog-custom.is-draggable-modal::-webkit-resizer {
  background-color: #cbd5e1;
  background-image:
    linear-gradient(135deg, transparent 50%, #94a3b8 50%);
  border-bottom-right-radius: 12px;
}

.modal-header-custom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  border-radius: 12px 12px 0 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--danger); }

.modal-body-custom {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
}

.modal-footer-custom {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  border-radius: 0 0 12px 12px;
}

/* フォーム共通 */
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

.form-group-custom { margin-bottom: 16px; }

.form-label-custom {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  letter-spacing: .3px;
}

.form-label-custom .required { color: var(--danger); margin-left: 2px; }
.req { color: #ef4444; margin-left: 2px; font-weight: 700; }

.form-input-custom {
  display: block;
  width: 100%;
  padding: 9px 13px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color var(--transition), box-shadow var(--transition);
  font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif;
}
.form-input-custom:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
textarea.form-input-custom { min-height: 64px; resize: vertical; }

.form-error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 8px;
}

/* モーダルボタン */
.btn-modal-cancel {
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 500;
  background: #f1f5f9;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-modal-cancel:hover { background: #e2e8f0; }

.btn-modal-save {
  display: inline-flex;
  align-items: center;
  padding: 9px 24px;
  font-size: 14px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition);
}
.btn-modal-save:hover { background: var(--primary-dark); }

/* モーダル内 削除ボタン（アウトライン → ホバー反転） */
.btn-modal-delete {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .02em;
  color: #e11d48;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .12s;
}
.btn-modal-delete:hover {
  background: #e11d48;
  color: #fff;
  border-color: #e11d48;
  box-shadow: 0 4px 14px rgba(225, 29, 72, .28);
}
.btn-modal-delete:active { transform: translateY(1px); box-shadow: 0 2px 6px rgba(225, 29, 72, .25); }
.btn-modal-delete:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn-modal-delete i { font-size: 12px; }

/* トースト通知 */
.app-toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  padding: 14px 22px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0,0,0,.18);
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .25s, transform .25s;
  max-width: 360px;
  /* メッセージ内の \n を改行として表示（2 行以上の警告対応） */
  white-space: pre-line;
}
.app-toast.is-show { opacity: 1; transform: none; }
.app-toast-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.app-toast-error   { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.app-toast-warning { background: #fffbeb; color: #92400e; border: 1px solid #fcd34d; }

/* フォームエラーメッセージ */
.form-error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 6px;
  margin-top: 8px;
}

/* 売上管理テーブル */
.sale-no {
  font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif;
  font-size: 12px;
  background: #f1f5f9;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-muted);
}

.type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}
.type-subscription { background: #eff6ff; color: #2563eb; }
.type-consulting    { background: #f0fdf4; color: #15803d; }
.type-development   { background: #fdf4ff; color: #7e22ce; }
.type-other         { background: #f8fafc; color: #64748b; }

.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 12px;
  transition: background var(--transition), color var(--transition);
  margin: 0 2px;
}
.action-edit    { background: #eff6ff; color: #3b82f6; }
.action-approve { background: #f0fdf4; color: #22c55e; }
.action-reject  { background: #fef9c3; color: #a16207; }
.action-delete  { background: #fef2f2; color: #ef4444; }
.action-edit:hover    { background: #3b82f6; color: #fff; }
.action-approve:hover { background: #22c55e; color: #fff; }
.action-reject:hover  { background: #f59e0b; color: #fff; }
.action-delete:hover  { background: #ef4444; color: #fff; }

@media (max-width: 640px) {
  .form-row-2, .form-row-3 { grid-template-columns: 1fr; }
}

/* ============================================================
   ボタン共通
   ============================================================ */
.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  font-size: 14px;
  font-weight: 600;
  background: linear-gradient(135deg, #4f90f8, #3b82f6);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(59,130,246,.35);
  transition: box-shadow var(--transition), transform .1s, filter .1s;
  letter-spacing: .2px;
}
.btn-primary-sm:hover  { filter: brightness(1.1); box-shadow: 0 4px 14px rgba(59,130,246,.45); }
.btn-primary-sm:active { transform: scale(.97); }

.btn-primary-sm.btn-accent {
  background: linear-gradient(135deg, #34d399, #059669);
  box-shadow: 0 2px 8px rgba(5,150,105,.35);
}
.btn-primary-sm.btn-accent:hover { box-shadow: 0 4px 14px rgba(5,150,105,.45); }

.btn-secondary-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
  background: #fff;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
}
.btn-secondary-sm:hover { background: var(--surface-alt); border-color: #b0b8c9; }

/* 危険系ボタン（赤）— 一括削除など */
.btn-danger-sm {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 700;
  background: #fff;
  color: #ef4444;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), opacity .2s;
  white-space: nowrap;
}
.btn-danger-sm:hover:not(:disabled) { background: #fef2f2; border-color: #f87171; }
.btn-danger-sm:disabled { opacity: .4; cursor: not-allowed; }

/* その他売上 編集モーダル */
.etc-edit-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
}
.etc-edit-grid .form-group-custom { margin-bottom: 0; }

.etc-items-section { margin-top: 18px; }
.etc-items-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.etc-items-table { font-size: 13px; }
.etc-items-table input[type="text"],
.etc-items-table input[type="number"] {
  width: 100%;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  box-sizing: border-box;
}
.etc-items-table .etc-row-num   { text-align: center; color: var(--text-muted); }
.etc-items-table .etc-amount    { text-align: right; font-weight: 600; color: var(--primary); white-space: nowrap; }
.etc-items-table .etc-cell-mnt  { text-align: center; }
.etc-items-table .etc-cell-del  { text-align: center; }
.etc-items-table .btn-row-del   {
  background: transparent;
  border: 0;
  color: #ef4444;
  cursor: pointer;
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 4px;
}
.etc-items-table .btn-row-del:hover { background: #fef2f2; }

.etc-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px 12px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
}
.etc-summary-grid .lbl {
  font-size: 12px;
  color: var(--text-muted);
  display: block;
}
.etc-summary-grid .val {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  font-family: 'DM Mono', monospace;
}
.etc-summary-grid .val-strong { color: #059669; font-size: 16px; }

.invoice-search-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* 売上テーブル ヘッダー */
.sales-table-header {
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
}
.sales-header-title {
  white-space: nowrap;
}
.sales-header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 期間ショートカット */
.period-shortcuts {
  display: inline-flex;
  gap: 4px;
}
.btn-period {
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  background: #fff;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  white-space: nowrap;
}
.btn-period:hover { background: #eff6ff; color: var(--primary); border-color: var(--primary); }
.btn-period.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.invoice-no-label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: .5px;
  margin-top: 2px;
}

/* 操作ボタングループ */
.action-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}

/* 請求書ダウンロードボタン（青） */
.btn-invoice {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-invoice:hover {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.btn-invoice i { font-size: 12px; }

/* 売上削除ボタン（赤系） */
.btn-delete-sale {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #be123c;
  background: #fff1f2;
  border: 1px solid #fecdd3;
  border-radius: 6px;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.btn-delete-sale:hover {
  background: #e11d48;
  color: #fff;
  border-color: #e11d48;
}
.btn-delete-sale i { font-size: 12px; }

/* 編集ボタン（紫系）— 請求書（青）・削除（赤）と並べて識別 */
.btn-edit-sale {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #6366f1;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  white-space: nowrap;
}
.btn-edit-sale:hover {
  background: #6366f1;
  color: #fff;
  border-color: #6366f1;
}
.btn-edit-sale i { font-size: 12px; }

/* セクション開閉トグルボタン */
.btn-section-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  line-height: 1;
  white-space: nowrap;
}
.btn-section-toggle:hover {
  background: #dbeafe;
  border-color: #93c5fd;
}
.btn-section-toggle.is-open {
  color: var(--text-muted);
  background: #f1f5f9;
  border-color: var(--border);
}
.btn-section-toggle i {
  font-size: 11px;
  transition: transform var(--transition);
}

/* ============================================================
   SC売上管理
   ============================================================ */

/* 課金設定グリッド */
.sc-config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 32px;
}

.sc-config-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid #f1f5f9;
}

.sc-config-label {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  min-width: 160px;
}

.sc-config-input-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sc-config-input {
  width: 170px;
  padding: 8px 12px;
  font-size: 14px;
  font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif;
  font-weight: 600;
  color: var(--text);
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: border-color var(--transition), background var(--transition);
}

.sc-config-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}

.sc-config-unit {
  font-size: 13px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* 保存メッセージ */
.sc-save-msg {
  font-size: 14px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
}
.sc-save-msg.msg-ok   { background: #f0fdf4; color: #15803d; }
.sc-save-msg.msg-info { background: #f8fafc; color: var(--text-muted); }
.sc-save-msg.msg-err  { background: #fef2f2; color: #dc2626; }

/* 変更履歴 */
.sc-log-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.sc-log-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.sc-log-empty {
  font-size: 14px;
  color: var(--text-muted);
  padding: 6px 0;
}

.sc-log-row {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  padding: 7px 0;
  border-bottom: 1px solid #f8fafc;
  flex-wrap: wrap;
}

.log-date  { color: var(--text-muted); white-space: nowrap; }
.log-user  { font-weight: 600; color: var(--text); }
.log-field { color: var(--primary); font-weight: 600; }
.log-old   { color: #dc2626; }
.log-new   { color: #15803d; font-weight: 700; }

/* 売上サマリーテーブル */
.btn-expand {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.btn-expand:hover,
.btn-expand.expanded {
  background: linear-gradient(135deg, #4f90f8, #3b82f6);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(59,130,246,.35);
}

.ym-label {
  font-weight: 600;
  font-size: 14px;
}

.pv-cell {
  font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif;
  font-size: 13px;
  color: var(--text-muted);
}

/* 詳細行 */
.detail-row > .detail-cell {
  padding: 0 !important;
  background: #f8fafc;
  border-bottom: 2px solid var(--primary);
}

.detail-loading,
.detail-empty {
  padding: 16px 24px;
  font-size: 13px;
  color: var(--text-muted);
}

/* 明細テーブル */
.detail-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.detail-table th {
  background: #eef2f7;
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: .4px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}

.detail-table td {
  padding: 11px 16px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: middle;
}

.detail-table tbody tr:last-child td { border-bottom: none; }
.detail-table tfoot td, .detail-table tfoot th {
  background: #f1f5f9;
  border-top: 1px solid var(--border);
}

.detail-order  { font-size: 16px; text-align: center; color: var(--primary); }
.detail-name   { font-weight: 600; }
.detail-qty    { text-align: right; color: var(--text-muted); }
.detail-unit   { text-align: right; color: var(--text-muted); font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif; }
.detail-amount { text-align: right; font-weight: 700; font-family: Meiryo, 'Meiryo UI', 'Yu Gothic UI', 'MS PGothic', sans-serif; color: var(--primary); }

@media (max-width: 1024px) {
  .sc-config-grid { grid-template-columns: 1fr; }
  .sc-config-input { width: 130px; }
}

/* ============================================================
   警告モーダル（上書き確認）
   ============================================================ */
.modal-warn .modal-warn-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #fef3c7;
  background: linear-gradient(135deg, #fffbeb 0%, #fef9ec 100%);
  border-radius: 10px 10px 0 0;
}

.modal-warn-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 22px;
  color: #d97706;
}

.modal-warn-title {
  font-size: 16px;
  font-weight: 700;
  color: #92400e;
}

.modal-warn-subtitle {
  font-size: 11px;
  color: #b45309;
  margin-top: 2px;
  font-weight: 500;
}

.modal-warn-msg {
  margin: 0;
  font-size: 14px;
  line-height: 1.8;
  color: var(--text);
  padding: 4px 0;
}

.btn-modal-warn-ok {
  display: inline-flex;
  align-items: center;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(245,158,11,.35);
  transition: filter var(--transition), box-shadow var(--transition);
  letter-spacing: .2px;
}
.btn-modal-warn-ok:hover { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(245,158,11,.5); }

/* ============================================================
   削除確認モーダル（赤系）
   ============================================================ */
.modal-danger .modal-danger-header {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid #fecdd3;
  background: linear-gradient(135deg, #fff1f2 0%, #fef2f4 100%);
  border-radius: 10px 10px 0 0;
}

.modal-danger-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fecdd3;
  border: 2px solid #e11d48;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 20px;
  color: #be123c;
}

.modal-danger-title {
  font-size: 16px;
  font-weight: 700;
  color: #881337;
}

.modal-danger-subtitle {
  font-size: 11px;
  color: #be123c;
  margin-top: 2px;
  font-weight: 500;
}

.btn-modal-danger-ok {
  display: inline-flex;
  align-items: center;
  padding: 9px 22px;
  font-size: 14px;
  font-weight: 700;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(225,29,72,.35);
  transition: filter var(--transition), box-shadow var(--transition);
  letter-spacing: .2px;
}
.btn-modal-danger-ok:hover { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(225,29,72,.5); }

/* ============================================================
   明細モーダル
   ============================================================ */
.modal-detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: 10px 10px 0 0;
}
.modal-detail-title {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}
.btn-modal-icon-close {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.8);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  line-height: 1;
  transition: background var(--transition), color var(--transition);
}
.btn-modal-icon-close:hover {
  background: rgba(255,255,255,.2);
  color: #fff;
}

/* ============================================================
   スタイリッシュなチェックボックス
   （社員一覧 / 経費精算 / 交通費精算 / お知らせ一覧で使用）
   ============================================================ */
.app-table input[type="checkbox"],
.exp-table input[type="checkbox"],
.trn-table input[type="checkbox"],
.ntc-table input[type="checkbox"],
#staff-table input[type="checkbox"] {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  cursor: pointer;
  position: relative;
  vertical-align: middle;
  flex-shrink: 0;
  transition: background .18s ease, border-color .18s ease, box-shadow .18s ease, transform .12s ease;
  outline: none;
}

.app-table input[type="checkbox"]:hover:not(:disabled),
.exp-table input[type="checkbox"]:hover:not(:disabled),
.trn-table input[type="checkbox"]:hover:not(:disabled),
.ntc-table input[type="checkbox"]:hover:not(:disabled),
#staff-table input[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 4px rgba(59,130,246,.10);
}

.app-table input[type="checkbox"]:focus-visible,
.exp-table input[type="checkbox"]:focus-visible,
.trn-table input[type="checkbox"]:focus-visible,
.ntc-table input[type="checkbox"]:focus-visible,
#staff-table input[type="checkbox"]:focus-visible {
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 4px rgba(59,130,246,.22);
}

.app-table input[type="checkbox"]:active:not(:disabled),
.exp-table input[type="checkbox"]:active:not(:disabled),
.trn-table input[type="checkbox"]:active:not(:disabled),
.ntc-table input[type="checkbox"]:active:not(:disabled),
#staff-table input[type="checkbox"]:active:not(:disabled) {
  transform: scale(.94);
}

.app-table input[type="checkbox"]:checked,
.exp-table input[type="checkbox"]:checked,
.trn-table input[type="checkbox"]:checked,
.ntc-table input[type="checkbox"]:checked,
#staff-table input[type="checkbox"]:checked {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #2563eb;
  box-shadow: 0 2px 4px rgba(37,99,235,.28);
}

.app-table input[type="checkbox"]:checked::after,
.exp-table input[type="checkbox"]:checked::after,
.trn-table input[type="checkbox"]:checked::after,
.ntc-table input[type="checkbox"]:checked::after,
#staff-table input[type="checkbox"]:checked::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 5px;
  width: 4px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* 一部選択（indeterminate）状態 */
.app-table input[type="checkbox"]:indeterminate,
.exp-table input[type="checkbox"]:indeterminate,
.trn-table input[type="checkbox"]:indeterminate,
.ntc-table input[type="checkbox"]:indeterminate,
#staff-table input[type="checkbox"]:indeterminate {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: #2563eb;
  box-shadow: 0 2px 4px rgba(37,99,235,.28);
}

.app-table input[type="checkbox"]:indeterminate::after,
.exp-table input[type="checkbox"]:indeterminate::after,
.trn-table input[type="checkbox"]:indeterminate::after,
.ntc-table input[type="checkbox"]:indeterminate::after,
#staff-table input[type="checkbox"]:indeterminate::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 3px;
  width: 9px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transform: none;
}

.app-table input[type="checkbox"]:disabled,
.exp-table input[type="checkbox"]:disabled,
.trn-table input[type="checkbox"]:disabled,
.ntc-table input[type="checkbox"]:disabled,
#staff-table input[type="checkbox"]:disabled {
  opacity: .4;
  cursor: not-allowed;
  background: #f1f5f9;
  border-color: #e2e8f0;
  box-shadow: none;
}
.app-table input[type="checkbox"]:disabled:checked,
.exp-table input[type="checkbox"]:disabled:checked,
.trn-table input[type="checkbox"]:disabled:checked,
.ntc-table input[type="checkbox"]:disabled:checked,
#staff-table input[type="checkbox"]:disabled:checked {
  background: #94a3b8;
  border-color: #94a3b8;
}

/* ============================================================
   年月ナビ + 月ピッカー（共通）
   ※ expense / transport / dashboard など既存ページはページ内 <style>
      に同等の定義を持っており、そちらが優先される。
   ============================================================ */
.month-nav { display:flex; align-items:center; gap:12px; }
.month-nav-btn {
  width:34px; height:34px;
  border:1px solid var(--border); background:#fff; border-radius:8px;
  cursor:pointer; font-size:14px; color:var(--text-muted);
  transition:background .2s, color .2s;
  display:flex; align-items:center; justify-content:center;
}
.month-nav-btn:hover { background:var(--primary); color:#fff; border-color:var(--primary); }
.month-nav-btn:disabled { opacity:.35; cursor:not-allowed; }
.month-nav-btn:disabled:hover { background:#fff; color:var(--text-muted); border-color:var(--border); }
.month-nav-label-wrap { position:relative; }
.month-label {
  font-size:18px; font-weight:700; color:var(--text);
  min-width:130px; text-align:center;
  background:none; border:1px solid transparent; border-radius:8px;
  cursor:pointer; padding:4px 10px;
  transition:background .15s, border-color .15s;
  display:inline-flex; align-items:center; gap:6px;
  font-family:inherit;
}
.month-label::after {
  content:'\f078'; font-family:'Font Awesome 6 Free'; font-weight:900;
  font-size:11px; color:var(--text-muted);
}
.month-label:hover, .month-label.is-open {
  background:var(--surface-alt,#f8fafc); border-color:var(--border);
}
.month-picker-popup {
  position:fixed;
  background:#fff; border:1px solid var(--border); border-radius:12px;
  box-shadow:0 8px 28px rgba(0,0,0,.13);
  padding:14px; z-index:9999; width:230px;
}
.mp-year-nav { display:flex; align-items:center; justify-content:space-between; margin-bottom:10px; }
.mp-year-nav button {
  width:30px; height:30px; border:none; background:none;
  cursor:pointer; border-radius:6px;
  color:var(--text-muted); font-size:13px; transition:background .15s;
}
.mp-year-nav button:hover { background:var(--surface-alt,#f8fafc); color:var(--primary); }
.mp-year-nav button:disabled { opacity:.35; cursor:not-allowed; }
.mp-year-nav button:disabled:hover { background:none; color:var(--text-muted); }
.mp-year-label { font-size:15px; font-weight:700; color:var(--text); }
.mp-months { display:grid; grid-template-columns:repeat(4,1fr); gap:4px; }
.mp-month-btn {
  padding:7px 0; border:1px solid transparent; background:none; border-radius:7px;
  font-size:13px; cursor:pointer; color:var(--text);
  transition:background .15s, border-color .15s, color .15s;
  text-align:center; font-family:inherit;
}
.mp-month-btn:hover:not(.is-current):not(:disabled) {
  background:#eff6ff; border-color:var(--primary); color:var(--primary);
}
.mp-month-btn.is-current { background:var(--primary); color:#fff; font-weight:700; border-color:var(--primary); }
.mp-month-btn:disabled { color:#cbd5e1; cursor:not-allowed; background:transparent; }

/* ============================================================
   請求データ作成中 ローディング（sales_manage_sc.php）
   ============================================================ */
.sc-loading-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
  padding: 36px 56px;
  min-width: 280px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.sc-loading-spinner {
  font-size: 38px;
  color: var(--primary);
  margin-bottom: 6px;
}
.sc-loading-text {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.sc-loading-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ============================================================
   テーブル内セルの折り返し禁止（横幅は内容に合わせて広がる）
   ============================================================ */
.app-table-nowrap td,
.app-table-nowrap th {
  white-space: nowrap;
}

/* 請求金額の下に出す税込み額の小表示 */
.amount-inctax-label {
  display: block;
  font-size: 11px;
  font-weight: 400;
  color: var(--text-muted);
  margin-top: 2px;
  letter-spacing: .3px;
}
/* 保守費用 9% 強調表示（SC 売上画面・各行／合計） */
.amount-inctax-label.is-pct9 {
  font-size: 13px;
  font-weight: 700;
  color: #d97706;
  text-decoration: underline;
  text-decoration-color: #d97706;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

/* ============================================================
   売上データ一覧 CHECK / DONE / INVOICE ボタン
   ============================================================ */
.btn-rv-check {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 14px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: #1d4ed8; background: #eff6ff; border: 1px solid #bfdbfe;
  border-radius: 6px; cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-family: inherit;
}
.btn-rv-check:hover:not(:disabled) {
  background: #2563eb; color: #fff; border-color: #2563eb;
}
.btn-rv-check:disabled {
  color: #9ca3af; background: #f1f5f9; border-color: #e2e8f0;
  cursor: not-allowed;
}

/* SC 売上 売上データ一覧：列が多くて改行・横スクロールが起きやすいので
   .app-table 既定（th 12px 18px / td 13px 18px）よりも padding を大幅に詰める。
   font-size も 1pt 落として横幅を稼ぐ。 */
#revenue-table th { padding: 6px 6px; font-size: 12px; }
#revenue-table td { padding: 4px 6px; font-size: 13px; }

.rv-done-box {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
}
.rv-done-label {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: #166534; background: #dcfce7; border: 1px solid #86efac;
  border-radius: 6px;
  font-family: inherit;
}
/* DONE をボタンで描画する場合（解除可能） */
button.rv-done-label {
  cursor: pointer;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
button.rv-done-label:hover {
  background: #fee2e2; color: #be123c; border-color: #fca5a5;
}

/* ============================================================
   協力会社設定ページ（mnt_partner_settings.php）
   ============================================================ */
.partner-info-note {
  padding: 10px 14px;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  font-size: 12px;
  color: #1e40af;
}
.partner-info-note code {
  background: #dbeafe;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.partner-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 16px;
}

.partner-info-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 18px;
}

.partner-info-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #e2e8f0;
  letter-spacing: .3px;
}

.partner-info-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.partner-info-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 13px;
}

.partner-info-k {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 12px;
  padding-top: 2px;
}

.partner-info-v {
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.partner-info-v code {
  background: #e2e8f0;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
}

.partner-hanko-preview {
  display: inline-block;
  padding: 8px 14px;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 6px;
  min-width: 80px;
}
.partner-hanko-preview img {
  max-height: 70px;
  max-width: 150px;
  display: block;
}

@media (max-width: 600px) {
  .partner-info-row { grid-template-columns: 1fr; gap: 2px; }
  .partner-info-k { padding-top: 0; }
}
.rv-done-date {
  font-size: 11px; color: var(--text-muted); letter-spacing: .3px;
}

.rv-invoice-group {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

/* 保守確認：協力会社ごとに 2 段（CHK ボタン＋解除日）を縦並び */
.rv-maint-stack {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.rv-maint-block {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-width: 88px;
}

/* インボイス：協力会社ごとのダウンロードボタンを縦並び */
.rv-invoice-stack {
  display: inline-flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
}

.btn-rv-invoice {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  min-width: 92px;
  padding: 5px 12px;
  font-size: 12px; font-weight: 700; letter-spacing: .5px;
  color: #6d28d9; background: #f5f3ff; border: 1px solid #ddd6fe;
  border-radius: 6px; cursor: pointer; text-decoration: none;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
  font-family: inherit;
}
.btn-rv-invoice:hover:not(:disabled):not(.is-disabled) {
  background: #7c3aed; color: #fff; border-color: #7c3aed;
}
.btn-rv-invoice:disabled,
.btn-rv-invoice.is-disabled {
  color: #9ca3af; background: #f1f5f9; border-color: #e2e8f0;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================================
   モバイル端末（スマホ）レスポンシブ対応
   - PC（>768px）には影響を出さないこと
   - iPhone / Android などタッチ端末で破綻しない最低限のレイアウト調整
   - 画面要素ごとに：余白圧縮 / グリッド1列化 / テーブル横スクロール /
     モーダル全幅化 / サイドバードロワー化 / ヘッダー省スペース化
   ============================================================ */
@media (max-width: 1024px) {

  /* ---- ベース ---- */
  body { font-size: 14px; }

  /* ---- メイン領域：左右パディングを大幅に詰める ---- */
  #app-main {
    padding: 16px 12px 0 !important;
  }
  #app-footer {
    padding: 12px 16px;
    margin-top: 18px;
    margin-left: 0 !important;
    font-size: 12px;
    justify-content: center;
    text-align: center;
  }

  /* ---- ヘッダー ----
     モバイルではサイドバーが画面外（ドロワー）になるので、
     PC のような左側ナビ色のストライプは不要。ヘッダー全体を白基調に揃える。
     並びは「三線（メニュー）→ ブランドロゴ」とし、三線ボタンは
     左端でタップしやすい大きさ（約44px）にする。 */
  #app-header {
    padding: 0 8px;
    background: #ffffff;
  }
  .header-sidebar-toggle {
    display: inline-flex;  /* モバイルではハンバーガー表示 */
    order: -1;             /* ブランドの左に表示 */
    margin-left: 0;
    margin-right: 4px;
    padding: 10px 12px;    /* タップ領域を広げる */
    font-size: 20px;
    color: var(--primary);
  }
  .header-sidebar-toggle:hover,
  .header-sidebar-toggle:active {
    background: #eff6ff;
    color: var(--primary-dark);
  }
  .header-brand {
    width: auto;
    padding: 0 10px 0 6px;
    min-width: 0;
    margin-left: 0;
  }
  .header-brand .brand-icon {
    font-size: 18px;
    color: var(--primary);   /* 白背景でも視認できる青系に */
  }
  .header-brand .brand-text {
    font-size: 13px;
    max-width: 120px;
    margin-left: 8px;
    color: var(--text);      /* 白背景で読めるダーク色に */
  }
  .header-spacer { display: none; }
  .header-hint   { display: none; }

  /* ヘッダースペーサーを非表示にした分、右側ブロックを右端へ寄せる */
  .header-right { gap: 6px; margin-left: auto; }
  .header-user { gap: 6px; min-width: 0; }
  .header-user .user-avatar { width: 32px; height: 32px; font-size: 14px; }
  /* 社員名は表示するが、長い名前で折り返さないように省略表示 */
  .header-user .user-name {
    font-size: 12.5px;
    max-width: 7em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ログアウトはアイコンのみ（テキスト非表示） */
  .btn-logout {
    padding: 6px 10px;
    font-size: 12px;
    gap: 0;
  }
  .btn-logout .btn-logout-label { display: none; }
  .btn-logout i { font-size: 13px; }

  /* ---- サイドバー：オーバーレイ式ドロワー ---- */
  #app-sidebar {
    box-shadow: 4px 0 20px rgba(0, 0, 0, .25);
  }
  /* 開いている時の暗幕（要素を増やさず疑似要素で実装） */
  body.mobile-menu-open::before {
    content: '';
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, .45);
    z-index: 850;
    animation: mobileBackdropFade .18s ease;
  }
  @keyframes mobileBackdropFade {
    from { opacity: 0; }
    to   { opacity: 1; }
  }
  /* タップ領域を確保 */
  .nav-link { padding: 13px 20px; }
  .sub-nav .nav-link { padding: 11px 20px 11px 48px; }

  /* ---- カード ---- */
  .app-card { margin-bottom: 16px; border-radius: 10px; }
  .app-card-header {
    padding: 12px 14px;
    font-size: 14px;
    flex-wrap: wrap;
    gap: 6px;
  }
  .app-card-body { padding: 16px 14px; }
  .app-card-body.p-0 { padding: 0; }

  /* ---- テーブル：横スクロール領域に内包 ---- */
  /* 一部のページ (staff_manage.php) は inline で overflow-x:hidden を持つため
     モバイルでは強制的にスクロール可にする。PC側は影響なし */
  .app-card-body { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
  .app-table { font-size: 13px; }
  .app-table th, .app-table td { padding: 10px 12px; }
  /* exp/trn/ntc 専用テーブルにも横スクロールを伝播 */
  .exp-table, .trn-table, .ntc-table { font-size: 13px; }

  /* ---- モバイル sticky thead（JS 連携） ----
     モバイルでは .app-card-body に overflow-x:auto !important が付くため
     カードボディがスクロールコンテナ化し、純 CSS の position:sticky では
     thead がビューポートではなくカードボディにスコープされ機能しない
     （カードボディには max-height が無いため内部スクロールも発生しない）。
     そこでモバイル時は thead の CSS sticky を無効化し、app.js の
     initMobileStickyTable() が translateY で擬似 sticky を担当する。
     translateY は table 内 thead でも layout を壊さずに動作する。
     card-header は祖先にスクロールコンテナが無いためネイティブ sticky で
     機能する（CSS sticky 維持）。ただしモバイルで wrap して高さが
     可変になる分、thead を JS で都度追従させる必要がある。 */
  .has-sticky-table .app-table thead th,
  .has-sticky-table .exp-table thead th,
  .has-sticky-table .trn-table thead th,
  .has-sticky-table .report-table thead th,
  .has-sticky-table .oex-table thead th,
  .has-sticky-header .app-table thead th,
  .has-sticky-header .exp-table thead th,
  .has-sticky-header .trn-table thead th,
  .has-sticky-header .report-table thead th,
  .has-sticky-header .oex-table thead th {
    position: static !important;
    top: auto !important;
  }
  /* JS が translateY で thead を擬似 sticky 化する際、行を覆い隠せるよう
     thead を独立した stacking context にする。background-clip:padding-box は
     border-collapse 由来の半透明領域を防ぐため。 */
  .has-sticky-table .app-card-body table thead {
    position: relative;
    z-index: 5;
    will-change: transform;
  }
  .has-sticky-table .app-card-body table thead th {
    background-clip: padding-box;
  }

  /* ---- ステータスバッジ：折り返し抑止 ---- */
  .badge-ok, .badge-fail, .badge-info-soft, .badge-warn-soft, .badge-danger-soft {
    font-size: 12px; padding: 2px 9px; white-space: nowrap;
  }

  /* ---- 日時バー ---- */
  .datetime-bar {
    flex-wrap: wrap;
    justify-content: flex-start;
    font-size: 12px;
    margin-bottom: 14px;
  }

  /* ---- モーダル：周囲に余白を確保しつつ縦スクロール ----
     インラインで max-width:520px, width:96% 等が指定されたモーダル（プロフィール、
     社員追加・編集 など）はその値を尊重するため !important は付けない。
     画面いっぱいになりすぎないよう、オーバーレイ余白＋max-height を確保する。 */
  .modal-overlay { padding: 16px; }
  .modal-dialog-custom {
    max-width: 100%;
    width: 100%;
    max-height: calc(100vh - 80px);
    border-radius: 10px;
  }
  .modal-header-custom {
    padding: 14px 16px;
    font-size: 14px;
    border-radius: 10px 10px 0 0;
  }
  .modal-body-custom { padding: 16px 14px; }
  /* モバイル幅ではリサイズ不要（モーダルは画面幅一杯になるため） */
  .modal-dialog-custom.is-draggable-modal { resize: none; }
  .modal-footer-custom {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
    border-radius: 0 0 10px 10px;
    justify-content: stretch !important;
  }
  /* モーダルフッターのボタン群を均等分配（2系統あるパターンも考慮） */
  .modal-footer-custom > div {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
  }
  .btn-modal-cancel,
  .btn-modal-save,
  .btn-modal-delete,
  .btn-modal-warn-ok,
  .btn-modal-danger-ok {
    padding: 9px 16px;
    font-size: 13px;
  }

  /* ---- フォーム共通：1カラム ---- */
  .form-row-2,
  .form-row-3 { grid-template-columns: 1fr !important; gap: 10px !important; }
  .form-input-custom { font-size: 14px; padding: 10px 12px; }

  /* ---- ボタン共通：詰める ---- */
  .btn-primary-sm,
  .btn-secondary-sm,
  .btn-danger-sm {
    padding: 8px 14px;
    font-size: 13px;
  }
  /* 期間ショートカットなど：折り返し許可 */
  .period-shortcuts { flex-wrap: wrap; }
  .sales-table-header,
  .sales-header-controls,
  .action-btn-group { flex-wrap: wrap !important; gap: 6px; }

  /* ---- トースト：左右に余白 ---- */
  .app-toast {
    left: 14px;
    right: 14px;
    bottom: 14px;
    max-width: none;
    padding: 12px 16px;
    font-size: 13px;
  }

  /* ---- プロフィール変更モーダル：項目1カラム ---- */
  #hp-modal .hp-row-2 { grid-template-columns: 1fr; gap: 10px; }
  #hp-modal .hp-avatar { width: 80px; height: 80px; font-size: 32px; }
  #hp-modal .hp-avatar-edit { left: calc(50% + 28px); width: 30px; height: 30px; }
  #hp-modal .hp-avatar-delete { left: calc(50% + 60px); width: 30px; height: 30px; }
  #hp-upload-modal .hp-crop-area { height: 280px; }

  /* ---- ダッシュボード ---- */
  .dash-card { margin-bottom: 12px; }
  .dash-card-head {
    padding: 12px 14px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .dc-link { margin-left: auto; }
  .dash-card-body { flex-direction: column; }
  .dc-metric {
    flex: 1 1 100%;
    min-width: 0;
    border-right: none !important;
    border-bottom: 1px solid #f1f5f9;
    padding: 12px 14px;
  }
  .dc-metric:last-child { border-bottom: none; }
  /* 業務報告書サマリーは2列に */
  #body-work {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  #body-work .dc-metric {
    border-right: 1px solid #f1f5f9 !important;
    border-bottom: 1px solid #f1f5f9 !important;
    padding: 10px 12px;
  }
  #body-work .dc-metric:nth-child(2n) { border-right: none !important; }
  #body-work .dc-metric:nth-last-child(-n+2) { border-bottom: none !important; }
  .dc-metric-value { font-size: 17px; }
  .dc-head-remain { font-size: 11px; }
  .dash-side-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .mgr-stats-grid { grid-template-columns: 1fr !important; gap: 12px; }
  .mgr-stat-body { gap: 10px; }
  .mgr-stat-body canvas { width: 96px !important; height: 96px !important; }

  /* セクションヘッダ・月ナビ */
  .dash-section-header {
    gap: 8px;
    margin: 16px 0 10px;
  }
  .dash-section-header .month-nav {
    flex-wrap: wrap;
    gap: 6px;
  }
  .month-nav { gap: 8px; flex-wrap: wrap; }
  .month-nav-btn { width: 32px; height: 32px; }
  /* report.php / expense_manage.php / transport_manage.php の検索ナビ：
     ボタンが多くてモバイルで切れるため、右側ブロックを横幅いっぱい使って折り返す */
  .app-card-header > .month-nav { width: 100%; justify-content: flex-start; }
  .month-label {
    min-width: 110px;
    font-size: 16px;
    padding: 4px 8px;
  }
  .mn-today { padding: 5px 10px; font-size: 12px; }
  .month-picker-popup { width: 220px; }

  /* 警告グリッド：1列＆余白圧縮 */
  .warn-grid {
    grid-template-columns: 1fr !important;
    gap: 8px;
  }
  .warn-item { padding: 10px 14px; font-size: 12px; }

  /* ---- SC売上設定：1カラム化（既存と整合） ---- */
  .sc-config-grid { grid-template-columns: 1fr; }
  .sc-config-input { width: 100%; max-width: 220px; }
  .sc-config-row { flex-wrap: wrap; gap: 6px; padding: 9px 0; }
  .sc-config-label { min-width: 0; flex: 1 1 100%; }

  /* ---- 協力会社設定（既存:600px 用ルールがあるので768pxは中間調整） ---- */
  .partner-info-grid { grid-template-columns: 1fr; }

  /* ---- ステータスカード（statカード） ---- */
  .stat-card {
    padding: 14px 16px;
    gap: 12px;
    margin-bottom: 14px;
  }
  .stat-card-icon { width: 44px; height: 44px; font-size: 18px; border-radius: 8px; }
  .stat-value { font-size: 22px; }

  /* ---- ETC編集グリッド：1カラム ---- */
  .etc-edit-grid { grid-template-columns: 1fr; gap: 10px; }
  .etc-summary-grid { grid-template-columns: repeat(2, 1fr); }

  /* ---- 状態誘導パルス：太枠縮小（モバイルで邪魔にならないよう） ---- */
  .app-card.is-guide-pulse { border-width: 1.5px; }

  /* ---- 月ピッカー：画面端でのはみ出し抑制 ---- */
  .month-picker-popup { max-width: calc(100vw - 24px); }

  /* ---- 横長になりがちなツールバー要素 ---- */
  .tpc-toolbar { gap: 6px; }
  .tpc-search-input { min-width: 0; flex: 1 1 100%; }
  .exp-header { gap: 8px; }

  /* ---- 入力フィールドの iOS 自動ズーム防止（16px以上で抑制） ---- */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  select,
  textarea {
    font-size: 16px;
  }
}

/* ============================================================
   さらに小さい画面（iPhone SE 等：max-width 480px）
   ============================================================ */
@media (max-width: 480px) {
  #app-main { padding: 14px 10px 0 !important; }
  .app-card-body { padding: 14px 12px; }
  .app-card-header { padding: 11px 12px; font-size: 13.5px; }
  .modal-header-custom { padding: 12px 14px; font-size: 13.5px; }
  .modal-body-custom  { padding: 14px 12px; }
  .modal-footer-custom { padding: 10px 12px; }

  .header-brand .brand-text { display: none; }
  .header-brand { padding: 0 8px 0 12px; }

  .month-label { min-width: 90px; font-size: 15px; }
  .stat-value { font-size: 20px; }

  .etc-summary-grid { grid-template-columns: 1fr; }

  /* 非常に狭い画面では縦並び確実化 */
  .modal-footer-custom > div { width: 100%; }
  .btn-modal-cancel,
  .btn-modal-save,
  .btn-modal-delete { flex: 1 1 auto; justify-content: center; }
}

/* ========================================
   報告管理 子画面 タイトルバー 前後ナビ（↑ / ↓）
   report.php / expense_manage.php / transport_manage.php / other_expense.php
   の管理者ビュー（?staff_id=N）でのみ表示。assets/js/admin_view_nav.js が動的に挿入する。
======================================== */
.adm-nav-controls {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: auto;
}
.adm-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border: 1px solid #cbd5e1; background: #fff; color: #475569;
  border-radius: 8px; cursor: pointer; font-size: 13px;
  transition: background .15s, color .15s, border-color .15s;
  font-family: inherit;
}
.adm-nav-btn:hover:not(:disabled) {
  background: #2563eb; color: #fff; border-color: #2563eb;
}
.adm-nav-btn:disabled { opacity: .4; cursor: not-allowed; }
.adm-nav-pos {
  font-size: 12px; font-weight: 700; color: var(--text-muted);
  min-width: 56px; text-align: center; letter-spacing: .3px;
}
