@charset "UTF-8";

/* =========================
   Base
   ========================= */

html,
body {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family:
    "Yu Gothic",
    "YuGothic",
    "Hiragino Kaku Gothic ProN",
    "Hiragino Sans",
    "Meiryo",
    sans-serif
  ;
  background: #f3f4f6;
  color: #111827;
  margin: 0;
}

/* =========================
   Login Page
   ========================= */

body.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow-x: hidden;
  box-sizing: border-box;
}

/* PC 版：中央固定 */
body.login-page:not(.is-mobile) {
  padding: 0;
}

/* モバイル版：画面幅にフィット */
body.login-page.is-mobile {
  padding: 16px 16px 24px;
}

/* iOS 自動ズーム対策 */
body.login-page.is-mobile input[type="text"],
body.login-page.is-mobile input[type="password"] {
  font-size: 16px;
}

/* 背景 */
.login-bg {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(59, 130, 246, 0.18), transparent 55%),
    radial-gradient(circle at bottom right, rgba(16, 185, 129, 0.18), transparent 55%),
    #0f172a;
  z-index: -1;
}

/* ログインカード */
.login-container {
  width: 340px;
  max-width: calc(100% - 32px);
  background: #f9fafb;
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.45),
    0 0 0 1px rgba(148, 163, 184, 0.25);
  padding: 22px 22px 18px;
  box-sizing: border-box;
}

/* モバイル時は少し広めに */
body.login-page.is-mobile .login-container {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 20px 18px 16px;
  border-radius: 16px;
}

/* ヘッダー部分 */
.login-header {
  margin-bottom: 18px;
}

.login-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.login-logo img {
  width: 50%;
  margin-bottom: 10px;
}

.login-title {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 4px;
  color: #111827;
}

.login-subtitle {
  margin: 0;
  font-size: 12px;
  color: #6b7280;
}

/* フォーム */
.login-form {
  margin-top: 8px;
}

.field {
  margin-bottom: 12px;
}

label {
  font-size: 12px;
  display: block;
  margin-bottom: 4px;
  color: #4b5563;
}

/* 共通インプット */
input[type="text"],
input[type="password"],
input[type="email"],
input[type="search"],
select {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  box-sizing: border-box;
  font-size: 14px;
  background: #f9fafb;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="search"]:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

/* エラー表示 */
.errors {
  background: #fef2f2;
  color: #b91c1c;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 12px;
  margin-bottom: 10px;
  border: 1px solid #fecaca;
}

.errors ul {
  padding-left: 16px;
  margin: 0;
}

/* =========================
   Button (共通)
   ========================= */

/* プライマリボタン（新規ユーザー追加など） */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #f9fafb;
  cursor: pointer;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition:
    transform 0.07s ease,
    filter 0.15s ease; /* ★ box-shadow は削除 */
  width: auto;
}

/* ホバー・アクティブ時も影なし */
.btn-primary:hover {
  filter: brightness(1.03);
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

/* ログイン画面では全幅ボタン */
body.login-page .btn-primary {
  width: 100%;
  margin-top: 4px;
  padding: 9px 0;
}

/* 共通ボタン */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  background: #e5e7eb;
  color: #111827;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    transform 0.05s ease;
}

.btn:hover {
  background: #d1d5db;
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-secondary {
  background: #e5e7eb;
  border-color: #e5e7eb;
}

.btn-outline {
  background: transparent;
  border-color: #d1d5db;
}

.btn-danger {
  background: #ef4444;
  border-color: #ef4444;
  color: #f9fafb;
}

.btn-danger:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.btn-sm {
  padding: 4px 8px;
  font-size: 11px;
}

.btn-edit {
  border-radius: 10px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid #ccc;
}

/* フッターテキスト */
.login-footnote {
  margin-top: 10px;
  font-size: 11px;
  text-align: center;
  color: #9ca3af;
}

/* =========================
   App Layout (ダッシュボード共通)
   ========================= */

body.app-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
.app-header {
  background: #0f172a;
  color: #f9fafb;
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.4);
  position: sticky;
  top: 0;
  z-index: 10;
}

.app-brand img {
  padding:5px 0 0 0;
  width: auto;
  height: 30px;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 12px;
}

.app-user {
  opacity: 0.8;
}

/* 上ナビリンク */
.nav-link {
  color: #e5e7eb;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid transparent;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease;
}

.nav-link:hover {
  background: rgba(148, 163, 184, 0.3);
  border-color: rgba(148, 163, 184, 0.7);
}

.nav-link--logout {
  background: #ef4444;
  border-color: #ef4444;
  color: #f9fafb;
}

.nav-link--logout:hover {
  background: #dc2626;
  border-color: #dc2626;
}

/* テーマ切り替えトグル */
.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  font-size: 11px;
  color: #374151;
  cursor: pointer;
  margin-right: 8px;
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.05s ease;
}

.theme-toggle__icon {
  font-size: 13px;
}

.theme-toggle__label {
  letter-spacing: 0.02em;
}

.theme-toggle:hover {
  background: #e5e7eb;
  border-color: #d1d5db;
  box-shadow: 0 4px 10px rgba(148, 163, 184, 0.4);
  transform: translateY(-1px);
}

.theme-toggle:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(148, 163, 184, 0.35);
}

/* ハンバーガー */
.nav-toggle {
  border: none;
  background: transparent;
  padding: 4px 6px;
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.nav-toggle__bar {
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: #e5e7eb;
  margin: 3px 0;
}

/* ハンバーガー用オーバーレイ */
.nav-backdrop {
  display: none;
}

/* シェル */
.app-shell {
  flex: 1;
  display: flex;
  min-height: 0;
}

/* サイドバー (PC) */
.sidebar {
  width: 220px;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  padding: 16px 12px;
  box-shadow: 4px 0 12px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6b7280;
  margin-bottom: 6px;
  padding: 0 8px;
}

.sidebar-link {
  display: block;
  padding: 8px 10px;
  border-radius: 999px;
  text-decoration: none;
  font-size: 13px;
  color: #374151;
  transition:
    background 0.15s ease,
    color 0.15s ease,
    transform 0.07s ease;
}

.sidebar-link:hover {
  background: #e5f0ff;
  color: #1d4ed8;
  transform: translateX(2px);
}

.sidebar-link.is-active {
  background: #2563eb;
  color: #ffffff;
}

/* メイン */
.app-main {
  flex: 1;
  padding: 24px 32px;
  min-width: 0;
}

.card {
  background: #ffffff;
  padding: 18px 20px 24px;  /* ★ 下だけ +6px */
  border-radius: 14px;
  box-shadow:
    0 18px 40px rgba(15, 23, 42, 0.12),
    0 0 0 1px rgba(226, 232, 240, 0.6);
  max-width: 1120px;  /* ★ 880px → 1120px に拡張 */
  margin: 0 auto;     /* ★ 左右の余白を自動で揃えて中央寄せ */
}



.card--wide {
  max-width: none;
}

.card-title {
  font-size: 22px;
  margin: 0 0 8px;
  font-weight: 600;
}

/* カードヘッダー行（タイトル＋ボタン） */
.card-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

/* カード右上のボタンが横いっぱいにならないように */
.card-header-row .btn-primary {
  width: auto;
}

/* =========================
   ページ上部ツールバー（入管/表示件数/検索/新規追加）
   - PC：タイトルだけ左寄せ、他は右寄せ（順番は維持）
   - Mobile：現状の2段を維持
   ========================= */
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}

/* タイトルは余白をリセット（既存は下マージンあり） */
.page-toolbar .card-title {
  margin: 0;
  white-space: nowrap;
}

/* 右寄せグループの起点（表示件数＋検索＋新規追加） */
.page-toolbar .table-toolbar {
  margin-left: auto;        /* ★ 追加：ここから右寄せに寄る */
  justify-content: flex-start;
  margin-bottom: 0;
}

/* -------------------------
   モバイル（現状の2段を維持）
   タイトル＋新規追加が上段、表示件数＋検索が下段
   ------------------------- */
.app-body.is-mobile .page-toolbar {
  flex-wrap: wrap;
  gap: 10px;
}

.app-body.is-mobile .page-toolbar .card-title {
  order: 1;
}

.app-body.is-mobile .page-toolbar #immigration-create-open {
  order: 2;
  margin-left: auto;
  width: auto;
}

.app-body.is-mobile .page-toolbar .table-toolbar {
  order: 3;
  width: 100%;
  margin-left: 0;           /* ★ 念のため：PCの右寄せ起点を無効化 */
}



/* レスポンシブ（PCブラウザ幅が狭い場合） */
@media (max-width: 900px) {
  .app-main {
    padding: 16px;
  }

  .user-page-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
  }
}

/* =========================
   User Management / Forms
   ========================= */

.user-page-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 24px;
  align-items: flex-start;
}

/* フォーム */
.user-form-title {
  font-size: 16px;
  margin: 0 0 10px;
  font-weight: 600;
}

.user-form-body {
  margin-top: 4px;
}

.form-row {
  margin-bottom: 10px;
}

.form-row label {
  font-size: 12px;
  color: #4b5563;
  display: block;
  margin-bottom: 4px;
}

.form-row input,
.form-row select {
  width: 100%;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  box-sizing: border-box;
  font-size: 13px;
  background: #f9fafb;
  transition:
    border-color 0.15s ease,
    box-shadow 0.15s ease,
    background 0.15s ease;
}

.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* メッセージ */
.message {
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  margin-bottom: 10px;
}

.message ul {
  margin: 0;
  padding-left: 18px;
}

.message--success {
  background: #ecfdf5;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.message--error {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

/* テーブルツールバー：表示件数＋検索ボックスを横一列に */
.table-toolbar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

/* ラベルの余白をリセットして縦位置を揃える */
.table-length label {
  margin: 0;                    /* ここ重要！ */
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #4b5563;
}

/* テーブルツールバー内の入力を完全に同じ見た目に */
.table-toolbar select,
.table-toolbar input[type="search"] {
  height: 32px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 12px;
  line-height: 1.4;
  box-sizing: border-box;
}

/* 検索ボックスは幅だけ少し広めに */
.table-toolbar input[type="search"] {
  min-width: 210px;
}

/* 表示件数セレクトの矢印を自前で描画 */
.table-toolbar select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;

  padding-right: 28px;
  background-image:
    url("data:image/svg+xml;utf8,<svg fill='gray' height='12' width='12' viewBox='0 0 20 20' xmlns='http://www.w3.org/2000/svg'><polygon points='5,7 15,7 10,12'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}

/* フォーカス時の反応も統一 */
.table-toolbar select:focus,
.table-toolbar input[type="search"]:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

.theme-dark .table-toolbar select,
.theme-dark .table-toolbar input[type="search"] {
  background: #020617;
  border-color: #374151;
  color: #e5e7eb;
}

.theme-dark .table-toolbar select:focus,
.theme-dark .table-toolbar input[type="search"]:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
  background: #020617;
}



/* テーブル */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  overflow-y: auto;
  /* ★ 画面高さに応じてできるだけ広く */
  max-height: calc(100vh - 220px);
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
}
/* スクロールバーの主張を弱くする（Firefox） */
.table-wrapper {
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.6) transparent;
}
/* WebKit用カスタムスクロールバー */
.table-wrapper::-webkit-scrollbar {
  width: 6px;   /* 縦スクロール幅 */
  height: 6px;  /* 横スクロール高さ */
}

/* トラックは透明で、テーブルに干渉させない */
.table-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

/* つまみ部分は細く・丸く・控えめな色 */
.table-wrapper::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.5);
  border-radius: 999px;
}

/* ホバー時だけ少し濃く */
.table-wrapper:hover::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.8);
}


/* モバイルはもう少し広め＆vhベース */
.app-body.is-mobile .table-wrapper {
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 180px);
}

/* ユーザー管理ではカードいっぱいの幅で */
.card .table-wrapper--full {
  width: 100%;
}

.table-users {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.table-users th,
.table-users td {
  padding: 1px 1px;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
}

.table-users th {
  text-align: center;
  font-weight: 600;
  background: #f9fafb;
  position: sticky;
  top: 0;
  z-index: 1;
}

.table-users tbody tr:nth-child(odd) {
  background: #f9fafb;
}

.table-users tbody tr:hover {
  background: #eff6ff;
}

/* テーブルアクション列 */
.table-actions {
  white-space: nowrap;
}

/* ソート可能ヘッダー（PCのみ使用） */
.th-sortable {
  position: relative;
  cursor: pointer;

  /* ★ テキストと矢印が重ならない最低限の余白を必ず確保する */
  padding-right: 28px !important; 
}

/* ソート矢印 */
.th-sortable::after {
  content: '⇅';
  position: absolute;
  right: 8px;          /* ← テキストと絶対に被らない距離 */
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: #9ca3af;
  pointer-events: none; /* ← 親クリックだけ反応させる */
}

/* 昇順 */
.th-sortable[data-sort-dir="asc"]::after {
  content: '▲';
}

/* 降順 */
.th-sortable[data-sort-dir="desc"]::after {
  content: '▼';
}


/* 権限タグ */
.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
}

.tag-admin {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.tag-user {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

/* ユーザー管理テーブル：ドラッグ中のヘッダー */
.table-users th.is-dragging {
  opacity: 0.6;
  cursor: grabbing;
}

.table-users th[draggable="true"] {
  cursor: grab;
}

/* =========================
   Dark Theme
   ========================= */

.app-body.theme-dark {
  background: #020617;
  color: #e5e7eb;
}

/* ヘッダー */
.theme-dark .app-header {
  background: #1e293b;
  border-bottom-color: #0f172a;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.9),
    0 1px 0 rgba(15, 23, 42, 1);
}

.theme-dark .app-brand {
  color: #e5e7eb;
}

.theme-dark .app-nav .nav-link {
  color: #e5e7eb;
}

.theme-dark .app-nav .nav-link:hover {
  background: rgba(248, 250, 252, 0.06);
}

.theme-dark .nav-link--logout {
  color: #fecaca;
}

.theme-dark .nav-link--logout:hover {
  background: rgba(248, 113, 113, 0.16);
}

/* テーマトグル */
.theme-dark .theme-toggle {
  background: #020617;
  border-color: #1f2937;
  color: #e5e7eb;
}

/* サイドバー */
.theme-dark .sidebar {
  background: #0b1120;
  border-right-color: #020617;
  box-shadow: 8px 0 24px rgba(0, 0, 0, 0.7);
}

.theme-dark .sidebar-title {
  color: #9ca3af;
}

.theme-dark .sidebar-link {
  color: #e5e7eb;
}

.theme-dark .sidebar-link:hover {
  background: rgba(148, 163, 184, 0.22);
}

.theme-dark .sidebar-link.is-active {
  background: rgba(37, 99, 235, 0.32);
  color: #bfdbfe;
}

/* メイン背景 */
.theme-dark .app-main {
  background: radial-gradient(circle at top, #020617 0, #020617 35%, #000000 100%);
}

/* カード */
.theme-dark .card {
  background: #020617;
  border-color: #1f2937;
  box-shadow:
    0 18px 50px rgba(15, 23, 42, 0.8),
    0 0 0 1px rgba(31, 41, 55, 0.8);
}

.theme-dark .card-title {
  color: #e5e7eb;
}

/* フォーム */
.theme-dark .form-row label {
  color: #9ca3af;
}

.theme-dark .form-row input,
.theme-dark .form-row select {
  background: #020617;
  border-color: #374151;
  color: #e5e7eb;
}

.theme-dark .form-row input:focus,
.theme-dark .form-row select:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
  background: #020617;
}

/* ボタン類 */
.theme-dark .btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border-color: #1d4ed8;
  color: #e5e7eb;
}

.theme-dark .btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
}

.theme-dark .btn-secondary {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

.theme-dark .btn-outline {
  background: transparent;
  border-color: #4b5563;
  color: #e5e7eb;
}

.theme-dark .btn-danger {
  background: #b91c1c;
  border-color: #b91c1c;
}

.theme-dark .btn-danger:hover {
  background: #991b1b;
  border-color: #991b1b;
}

/* メッセージ */
.theme-dark .message--success {
  background: rgba(16, 185, 129, 0.1);
  border-color: rgba(16, 185, 129, 0.4);
  color: #6ee7b7;
}

.theme-dark .message--error {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.5);
  color: #fecaca;
}

/* テーブル */
.theme-dark .table-wrapper {
  background: #020617;
  border-color: #1f2937;
}

.theme-dark .table-users {
  color: #e5e7eb;
}

.theme-dark .table-users th {
  background: #020617;
  border-bottom-color: #1f2937;
}

.theme-dark .table-users td {
  border-bottom-color: #1f2937;
}

.theme-dark .table-users tbody tr:nth-child(odd) {
  background: #020617;
}

.theme-dark .table-users tbody tr:hover {
  background: #0f172a;
}

/* テーブル検索 */
.theme-dark .table-search input {
  background: #020617;
  border-color: #374151;
  color: #e5e7eb;
}

.theme-dark .table-search input:focus {
  border-color: #60a5fa;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.4);
}

/* ソートマーク */
.theme-dark .th-sortable::after {
  color: #9ca3af;
}

/* 権限タグ */
.theme-dark .tag-admin {
  background: rgba(37, 99, 235, 0.3);
  color: #bfdbfe;
}

.theme-dark .tag-user {
  background: rgba(16, 185, 129, 0.3);
  color: #a7f3d0;
}

/* モーダル（ダーク） */
.theme-dark .modal {
  background: #020617;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(31, 41, 55, 0.9);
}

.theme-dark .modal-header h2 {
  color: #e5e7eb;
}

.theme-dark .modal-close {
  color: #9ca3af;
}

.theme-dark .modal-close:hover {
  color: #e5e7eb;
}

/* ハンバーガー */
.theme-dark .nav-toggle__bar {
  background: #e5e7eb;
}

/* =========================
   Mobile Layout (App)
   ========================= */

.app-body.is-mobile {
  font-size: 14px;
  overflow-x: hidden;
}

/* ヘッダー：1行配置 */
.app-body.is-mobile .app-header {
  padding: 10px 12px;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.app-body.is-mobile .app-brand {
  font-size: 18px;
  flex-shrink: 0;
}

/* ナビ */
.app-body.is-mobile .app-nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex: 1;
  flex-wrap: nowrap;
  gap: 6px;
}

.app-body.is-mobile .theme-toggle,
.app-body.is-mobile .nav-link {
  padding: 4px 8px;
  font-size: 11px;
  white-space: nowrap;
}

/* モバイルではユーザー名非表示 */
.app-body.is-mobile .app-user {
  display: none;
}

/* PC 用ヘッダーメニューとハンバーガー切り替え */
.nav-link--desktop {
  display: inline-flex;
}

.nav-toggle {
  display: none;
}

.app-body.is-mobile .nav-link--desktop {
  display: none;
}

.app-body.is-mobile .nav-toggle {
  display: inline-flex;
}

/* レイアウト：サイドバーのスペースを取らず、メインは全幅 */
.app-body.is-mobile .app-shell {
  flex-direction: column;
}

.app-body.is-mobile .app-main {
  padding: 12px 10px 18px;
}

/* カードを画面幅にフィット */
.app-body.is-mobile .card,
.app-body.is-mobile .card--wide {
  max-width: 100%;
  padding: 16px 14px;
  border-radius: 12px;
}

/* ユーザー管理：フォームとテーブルを縦並びに */
.app-body.is-mobile .user-page-grid {
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

/* テーブルは横スクロール */
.app-body.is-mobile .table-wrapper {
  -webkit-overflow-scrolling: touch;
}

.app-body.is-mobile .table-users th,
.app-body.is-mobile .table-users td {
  padding: 1px 1px;
  font-size: 11px;
}

/* モバイル用サイドメニュー（スライドイン） */

.app-body.is-mobile .nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
  z-index: 30;
}

.app-body.is-mobile.nav-open .nav-backdrop {
  opacity: 1;
  pointer-events: auto;
}

/* ドロワーとしてのサイドバー */
.app-body.is-mobile .sidebar {
  position: fixed;
  top: 56px; /* ヘッダー高さに合わせて必要なら調整 */
  left: 0;
  height: calc(100vh - 56px);
  width: 260px;
  max-width: 80%;
  background: #ffffff;
  border-right: 1px solid #e5e7eb;
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.35);
  padding: 14px 10px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 4px;
  transform: translateX(-110%);
  transition: transform 0.18s ease-out;
  z-index: 40;
}

/* モバイル ダークテーマ時サイドバー */
.app-body.is-mobile.theme-dark .sidebar {
  background: #0b1120;
  border-right-color: #020617;
  box-shadow: 12px 0 32px rgba(0, 0, 0, 0.8);
}

/* nav-open 時にドロワーを開く */
.app-body.is-mobile.nav-open .sidebar {
  transform: translateX(0);
}

/* サイドバー内リンクは縦 1 列 */
.app-body.is-mobile .sidebar-link {
  flex: 0 0 auto;
  display: block;
  width: 100%;
  white-space: nowrap;
  text-align: left;
  margin-right: 0;
}

/* 区切り線 */
.sidebar-divider {
  margin: 8px 0 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.35);
}

/* =========================
   モバイル版：ログアウトボタン
   ========================= */

/* PC ではサイドバーのログアウト非表示 */
.app-body:not(.is-mobile) .sidebar-link--logout {
  display: none;
}

/* モバイル共通スタイル */
.app-body.is-mobile .sidebar-link--logout {
  display: block;
  margin: 6px 0;
  padding: 6px 12px;
  width: auto;
  max-width: 180px;
  border-radius: 999px;
  background: #ef4444;
  color: #f9fafb !important;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid #ef4444;
  align-self: flex-start;
}

/* ダークテーマ時 */
.app-body.is-mobile.theme-dark .sidebar-link--logout {
  background: #b91c1c;
  border-color: #b91c1c;
  color: #fee2e2 !important;
}

/* ホバー */
.app-body.is-mobile .sidebar-link--logout:hover {
  background: #dc2626;
  border-color: #dc2626;
}

.app-body.is-mobile.theme-dark .sidebar-link--logout:hover {
  background: #991b1b;
  border-color: #991b1b;
}

/* アクティブメニュー強調（飛び出し防止） */
.app-body.is-mobile .sidebar-link.is-active {
  margin-left: 0;
  padding-left: 12px;
  border-left: none;
}

/* =========================
   Modal (User Create/Edit)
   ========================= */

/* オーバーレイ全体 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  z-index: 2000;
}

/* hidden 属性が付いている時だけ非表示にする */
.modal-overlay[hidden] {
  display: none;
}

/* モーダル本体 */
.modal {
  width: 360px;
  max-width: calc(100% - 32px);
  background: #f9fafb;
  border-radius: 18px;
  box-shadow:
    0 24px 60px rgba(15, 23, 42, 0.55),
    0 0 0 1px rgba(148, 163, 184, 0.25);
  padding: 14px 16px 16px;
  box-sizing: border-box;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.modal-header h2 {
  font-size: 16px;
  margin: 0;
}

.modal-close {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  color: #6b7280;
}

.modal-close:hover {
  color: #111827;
}

.modal-body {
  margin-top: 4px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

/* =========================
   モバイル最適化（中央表示 + はみ出し防止）
   ========================= */

.app-body.is-mobile .modal-overlay {
  align-items: center;
  justify-content: center;
  padding: 16px 12px;
  box-sizing: border-box;
}

.app-body.is-mobile .modal {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  border-radius: 16px;
  padding: 14px 16px 16px;
  box-sizing: border-box;
}

.app-body.is-mobile .modal-header {
  margin-bottom: 12px;
}

.app-body.is-mobile .modal-header h2 {
  font-size: 17px;
}

/* 縦方向にはみ出す場合は中身をスクロールさせる */
.app-body.is-mobile .modal-body {
  max-height: calc(100vh - 150px);
  overflow-y: auto;
  padding-right: 2px;
}

/* 入力のタップしやすさ・文字サイズ（iOS自動ズーム対策含む） */
.app-body.is-mobile .modal-body .form-row {
  margin-bottom: 12px;
}

.app-body.is-mobile .modal-body label {
  font-size: 12px;
}

.app-body.is-mobile .modal-body input,
.app-body.is-mobile .modal-body select {
  font-size: 16px;
  padding: 9px 11px;
}

/* ボタンも少し大きめに */
.app-body.is-mobile .modal-actions {
  gap: 8px;
  margin-top: 10px;
}

.app-body.is-mobile .modal-actions .btn-primary {
  padding: 9px 14px;
  font-size: 14px;
}

.app-body.is-mobile .modal-actions .btn {
  font-size: 14px;
  font-weight: 600;
  padding: 7px 12px;
}

/* 閉じるボタンのタップ領域も少し広げる */
.app-body.is-mobile .modal-close {
  padding: 4px 8px;
  font-size: 20px;
}

/* ダークテーマ時のモーダル */
.theme-dark .modal {
  background: #020617;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(31, 41, 55, 0.9);
}

.theme-dark .modal-header h2 {
  color: #e5e7eb;
}

.theme-dark .modal-close {
  color: #9ca3af;
}

.theme-dark .modal-close:hover {
  color: #e5e7eb;
}

/* =========================
   テーブル下 ページネーション
   ========================= */

/* ページ送りボタンを少し丸く＆コンパクトに */
.table-pagination .btn.btn-sm {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
}

/* 無効時（先頭ページ / 最終ページ）はグレーアウト＆ホバー無効 */
.table-pagination .btn[disabled] {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.table-pagination .btn[disabled]:hover {
  background: #e5e7eb; /* デフォルトのまま */
}

/* ダークテーマ用 */
.theme-dark .table-pagination__info {
  color: #9ca3af;
}

.theme-dark .table-pagination .btn[disabled] {
  opacity: 0.4;
}

/* =========================
   ページネーション（前へ / 次へ）の最終調整
   ========================= */

/* PC / モバイル共通：常に横一列 */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
  font-size: 12px;
  flex-wrap: nowrap;        /* ★ ここで必ず横並びに */
}

/* 情報テキストも横幅を取りすぎないように */
.table-pagination__info {
  min-width: auto;
  white-space: nowrap;      /* 折り返さない */
}

/* ボタンはコンパクトにして横に収まるように */
.table-pagination .btn.btn-sm {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 4px 10px;
  border-radius: 999px;
}

/* モバイルでも右寄せ＆横一列を維持 */
.app-body.is-mobile .table-pagination {
  justify-content: flex-end;
  flex-wrap: nowrap;        /* ★ モバイル用 wrap 指定を上書き */
  gap: 6px;
}

.app-body.is-mobile .table-pagination__info {
  flex: 0 0 auto;           /* 100%幅を取らないように上書き */
  text-align: right;
}

/* モバイル専用 カラム移動ボタン（デスクトップでは非表示） */
.column-move-controls {
  display: none;
}

.app-body.is-mobile .column-move-controls {
  display: inline-flex;
  gap: 4px;
  margin-left: 6px;
}

.column-move-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: #e5e7eb;
  color: #374151;
  border: 1px solid #d1d5db;
  font-size: 10px;
  cursor: pointer;
}

.column-move-btn:hover {
  background: #d1d5db;
}

/* ダークテーマ */
.theme-dark .column-move-btn {
  background: #111827;
  border-color: #374151;
  color: #e5e7eb;
}

.theme-dark .column-move-btn:hover {
  background: #1f2937;
}

/* =========================
   Dashboard Message
   ========================= */
  .dashboard-message-bottom {
    display: flex;
    gap: 16px;
    margin-top: 16px;
  }
  .dashboard-sub {
    flex: 1 1 0;
    padding: 0;
    border: none;
    background: none;
    box-shadow: none;
  }
  @media (max-width: 920px) {
    .dashboard-message-bottom {
      flex-direction: column;
    }
  }
  .card.dashboard-message-box h2.dashboard-message-title {
    font-weight: bold;
    margin:0;
    padding:0 0 10px 0;
    text-indent: 0;
  }
  .card.dashboard-message-box .dashboard-message-content {
    background: #f3f3f3;
    border: 1px solid #d0d0d0;
    margin:0;
    padding:10px;
    border-radius: 4px;
    white-space: normal;
    word-break: break-word;
    text-indent: 0;
  }

  .card.dashboard-message-box .dashboard-message-form input[name="title"],
  .card.dashboard-message-box .dashboard-message-form textarea[name="body"] {
    width: 100%;
    background: #f3f3f3;
    border: 1px solid #d0d0d0;
    padding: 10px 12px;
    border-radius: 4px;
    box-sizing: border-box;
  }

  /* この card は縦スクロール可（既存の overflow 制限を上書き） */
  .card.dashboard-message-box {
    overflow-y: auto !important;
    overflow-x: hidden;
    max-height: none !important;
  }

.dashboard-message-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0;
  margin-bottom: 10px;
}

.dashboard-message-meta {
  display: flex;
  flex-direction: column;
  gap: 0;
  font-size: 12px;
  color: #6b7280;
}

.dashboard-message-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #9ca3af;
}

.dashboard-message-updated {
  font-size: 12px;
}

.dashboard-message-title {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.dashboard-message-body {
  margin: 0;
  font-size: 13px;
  line-height: 1;
  white-space: normal; 
}

.dashboard-message-empty {
  color: #9ca3af;
}

.dashboard-message-form textarea {
  width: 100%;
  min-height: 120px;
  resize: vertical;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  padding: 8px 10px;
  font-size: 13px;
  box-sizing: border-box;
}

.dashboard-message-form textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

/* Dark theme */
body.theme-dark .card.dashboard-message-box .card-body {
  background: #020617;
  border-color: #1f2937;
}
body.theme-dark .card.dashboard-message-box .dashboard-message-content {
  background: transparent;
  color: #e5e7eb;
}

.theme-dark .dashboard-message-title {
  color: #e5e7eb;
}

.theme-dark .dashboard-message-body {
  color: #e5e7eb;
}

.theme-dark .dashboard-message-meta {
  color: #9ca3af;
}

.theme-dark .dashboard-message-label {
  color: #6b7280;
}

body.theme-dark .card.dashboard-message-box .dashboard-message-form input[name="title"],
body.theme-dark .card.dashboard-message-box .dashboard-message-form textarea[name="body"] {
  background: #020617;
  border-color: #374151;
  color: #e5e7eb;
}


/* ===== Dashboard Edit Button Bigger ===== */

#dashboard-edit-toggle {
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 999px;
  font-weight: 500;
}

.theme-dark #dashboard-edit-toggle {
  background: #1f2937;
  color: #e5e7eb;
}

/* ===== Mobile: Dashboard Message Header Layout ===== */
@media (max-width: 640px) {
  .dashboard-message-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  #dashboard-edit-toggle {
    align-self: flex-end;
    margin-top: 4px;
  }
}

/* ===== Fix iPhone Safari auto zoom on input/textarea ===== */
.dashboard-message-form input,
.dashboard-message-form textarea {
  font-size: 16px !important;
  max-width: 100%;
  box-sizing: border-box;
}

/* === immigration用モーダルのスクロール改善 === */

.modal {
  max-width: 900px;
  width: 90%;
  max-height: 90vh;        /* 画面の高さの9割まで */
  display: flex;
  flex-direction: column;  /* header / body / actions を縦並びに */
  overflow: hidden;        /* 角丸などがある場合に中身をはみ出さない */
}

.modal-header {
  flex: 0 0 auto;
}

.modal-body {
  flex: 1 1 auto;
  overflow-y: auto;        /* フォーム部分をスクロール可能にする */
}

/* ボタン群が下に張り付くようにする（必要であれば） */
.modal-actions {
  flex: 0 0 auto;
}

/* immigration モーダル用 テキストエリア */
.textarea-full {
  width: 100%;
  box-sizing: border-box;
}

.textarea-modern {
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.6rem 0.8rem;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  background-color: #ffffff;
}

.textarea-modern:focus {
  outline: none;
  border-color: rgba(33, 150, 243, 0.7);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.16);
}

/* 着手日の date 入力をモダンに */
.input-modern {
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  padding: 0.5rem 0.75rem;
  font-size: 0.95rem;
  line-height: 1.4;
  background-color: #ffffff;
  box-sizing: border-box;
}

.input-modern:focus {
  outline: none;
  border-color: rgba(33, 150, 243, 0.7);
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.16);
}

/* 優先度：行全体のハイライト */
.table-users tbody tr.priority-high td {
  background: rgba(255, 193, 7, 0.18);
}

.table-users tbody tr.priority-low td {
  background: rgba(0, 0, 0, 0.06);
}

/* hover がある場合の見た目を自然に（任意） */
.table-users tbody tr.priority-high:hover td {
  background: rgba(255, 193, 7, 0.26);
}

.table-users tbody tr.priority-low:hover td {
  background: rgba(0, 0, 0, 0.10);
}


/* ===============================
   PC版：テーブルを横スクロールなしで収める
   =============================== */
@media (min-width: 1024px) {
  .table-wrapper {
    overflow-x: hidden;
  }

  .table-users {
    width: 100%;
    table-layout: fixed; /* ← これが核心 */
  }

  .table-users th,
  .table-users td {
    word-break: break-word;      /* 日本語・英数字対応 */
    overflow-wrap: anywhere;     /* 長い英数字も強制改行 */
    white-space: normal;         /* nowrap を解除 */
  }
}

@media (min-width: 1024px) {
  .table-users td {
    line-height: 1.6;
  }
}

/* ===============================
   優先度：ダークモード時の行色
   =============================== */
@media (prefers-color-scheme: dark) {
  /* high：暗背景でも分かる黄系の薄ハイライト */
  .table-users tbody tr.priority-high td {
    background: rgba(255, 193, 7, 0.22);
  }

  /* low：暗背景でも見える“少し明るいグレー” */
  .table-users tbody tr.priority-low td {
    background: rgba(255, 255, 255, 0.06);
  }

  /* hover（任意） */
  .table-users tbody tr.priority-high:hover td {
    background: rgba(255, 193, 7, 0.30);
  }
  .table-users tbody tr.priority-low:hover td {
    background: rgba(255, 255, 255, 0.10);
  }
}

/* =========================
   PC版：サイドバー 完全開閉（左下ボタン）
   ========================= */
@media (min-width: 961px) {
  :root {
    --sidebar-w: 200px; /* 通常時の幅（狭くしたいならここを調整） */
  }

  /* PCサイドバー幅を上書き */
  .app-body:not(.is-mobile) .sidebar {
    width: var(--sidebar-w);
    position: relative;
    transition: width 180ms ease, padding 180ms ease, border-color 180ms ease;
  }

  /* 左下：閉じるボタン（サイドバー内） */
  .sidebar-collapse-wrap {
    margin-top: auto;
    padding-top: 10px;
  }

  .sidebar-collapse-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 10px;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(255, 255, 255, 0.6);
    color: #374151;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.05s ease;
  }

  .sidebar-collapse-btn:hover {
    background: rgba(229, 231, 235, 0.9);
  }

  .sidebar-collapse-btn:active {
    transform: translateY(1px);
  }

  /* ダークテーマ時（見た目調整） */
  .app-body.theme-dark .sidebar-collapse-btn {
    border-color: rgba(148, 163, 184, 0.35);
    background: rgba(2, 6, 23, 0.25);
    color: #e5e7eb;
  }

  .app-body.theme-dark .sidebar-collapse-btn:hover {
    background: rgba(148, 163, 184, 0.18);
  }

  /* 折りたたみ：完全に閉じる（幅0） */
  .app-body:not(.is-mobile).sidebar-collapsed .sidebar {
    width: 0;
    padding: 0;
    border-right: 0;
    overflow: hidden;
  }

  /* 画面左下：戻すボタン（閉じた時だけ表示） */
  .sidebar-restore-btn {
    display: none;
  }

  .app-body:not(.is-mobile).sidebar-collapsed .sidebar-restore-btn {
    display: inline-flex;
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 60;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.55);
    background: rgba(255, 255, 255, 0.92);
    color: #111827;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    transition: transform 0.08s ease, background 0.15s ease;
  }

  .app-body:not(.is-mobile).sidebar-collapsed .sidebar-restore-btn:hover {
    background: rgba(229, 231, 235, 0.95);
    transform: translateY(-1px);
  }

  .app-body:not(.is-mobile).sidebar-collapsed.theme-dark .sidebar-restore-btn {
    background: rgba(2, 6, 23, 0.92);
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, 0.35);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  }

  .app-body:not(.is-mobile).sidebar-collapsed.theme-dark .sidebar-restore-btn:hover {
    background: rgba(15, 23, 42, 0.92);
  }
}

/* =========================
   PC＋サイドバー閉：メインをフル幅寄せ
   ========================= */
@media (min-width: 961px) {
  .app-body:not(.is-mobile).sidebar-collapsed .app-main {
    /* まずメイン全体の余白を減らす */
    padding-left: 12px;
    padding-right: 12px;
  }

  /* ページ内の共通コンテナが最大幅を持っている場合は解除 */
  .app-body:not(.is-mobile).sidebar-collapsed .container,
  .app-body:not(.is-mobile).sidebar-collapsed .content,
  .app-body:not(.is-mobile).sidebar-collapsed .main-content,
  .app-body:not(.is-mobile).sidebar-collapsed .page-content {
    max-width: none;
    width: 100%;
  }

  /* systemなどで使っている <section class="card"> の余白も詰める */
  .app-body:not(.is-mobile).sidebar-collapsed .card {
    margin-left: 0;
    margin-right: 0;
  }

  /* テーブル外枠のwrapperが余白を持っている場合に備えて */
  .app-body:not(.is-mobile).sidebar-collapsed .table-wrapper {
    margin-left: 0;
    margin-right: 0;
  }
}

/* =========================
   PC：サイドバー開閉
   ========================= */

.sidebar-spacer {
  flex: 1;
}

/* サイドバー下固定の閉じるボタン */
.sidebar-collapse {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(15, 23, 42, 0.12);
  background: #f9fafb;
  color: #0f172a;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  transition: transform 0.06s ease, background 0.15s ease, border-color 0.15s ease;
}

.sidebar-collapse:hover {
  background: #eef2ff;
  border-color: rgba(37, 99, 235, 0.35);
}

.sidebar-collapse:active {
  transform: translateY(1px);
}

/* PC時：サイドバーを「下まで」伸ばして下固定を成立させる */
.app-body:not(.is-mobile) .sidebar {
  min-height: calc(100vh - 56px); /* ヘッダーが56px想定 */
}

/* 閉じた時に出る「戻す」ボタン（左下固定） */
.sidebar-restore {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 1000;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(10px);
  color: #0f172a;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
}

/* 通常は非表示。閉じた時だけ出す */
.sidebar-restore[hidden] {
  display: none;
}

/* ダークモード */
.app-body.theme-dark .sidebar-collapse {
  background: rgba(2, 6, 23, 0.5);
  border-color: rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
}

.app-body.theme-dark .sidebar-collapse:hover {
  background: rgba(30, 41, 59, 0.55);
  border-color: rgba(96, 165, 250, 0.4);
}

.app-body.theme-dark .sidebar-restore {
  background: rgba(2, 6, 23, 0.66);
  border-color: rgba(148, 163, 184, 0.25);
  color: #e5e7eb;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.55);
}

/* =========================
   Fixed FAB: shape is always identical
   ========================= */

.sidebar-fab {
  display: none;
}

@media (min-width: 961px) {
  .app-body:not(.is-mobile) .sidebar-fab {
    display: inline-flex;
    position: fixed;
    left: 12px;
    bottom: 12px;
    z-index: 1200;

    /* ★外形を固定 */
    height: 40px;
    min-width: 120px; /* ラベル幅に負けないように固定 */
    padding: 0 12px;  /* 高さ固定なので上下paddingは0 */
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.55);

    align-items: center;
    justify-content: center;

    background: rgba(255, 255, 255, 0.94);
    color: #111827;

    font-size: 12px;
    font-weight: 800;
    line-height: 1;

    cursor: pointer;
    user-select: none;

    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
    transition: background 0.15s ease, transform 0.08s ease;
  }

  .app-body:not(.is-mobile) .sidebar-fab:hover {
    background: rgba(229, 231, 235, 0.96);
    transform: translateY(-1px);
  }

  /* ダーク */
  .app-body:not(.is-mobile).theme-dark .sidebar-fab {
    background: rgba(2, 6, 23, 0.76);
    color: #e5e7eb;
    border-color: rgba(148, 163, 184, 0.28);
    box-shadow: 0 16px 34px rgba(0, 0, 0, 0.45);
  }

  .app-body:not(.is-mobile).theme-dark .sidebar-fab:hover {
    background: rgba(15, 23, 42, 0.86);
  }

  /* 中身：2つのラベルを同じ場所に重ねる */
  .sidebar-fab {
    position: fixed;
  }

  .sidebar-fab .fab-label {
    position: absolute;
    inset: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* 使わないなら削除 */
    opacity: 0;
    pointer-events: none;
  }

  /* デフォルト（開いてる）：閉じるを表示 */
  .app-body:not(.is-mobile) .sidebar-fab .fab-label--close {
    opacity: 1;
  }

  /* 閉じた状態：メニューを表示 */
  .app-body:not(.is-mobile).sidebar-collapsed .sidebar-fab .fab-label--close {
    opacity: 0;
  }

  .app-body:not(.is-mobile).sidebar-collapsed .sidebar-fab .fab-label--open {
    opacity: 1;
  }

  /* 閉じた時：メインを広く */
  .app-body:not(.is-mobile).sidebar-collapsed .app-main {
    padding-left: 12px;
    padding-right: 12px;
  }

  .app-body:not(.is-mobile).sidebar-collapsed .card,
  .app-body:not(.is-mobile).sidebar-collapsed .card--wide {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

/* 旧ボタンは無効化（残ってても表示されない） */
.sidebar-restore,
.sidebar-collapse {
  display: none !important;
}

/* =========================
   サイドバー閉時：横スクロールを出さない
   ========================= */
@media (min-width: 961px) {
  /* レイアウト押し出し防止（超重要） */
  .app-shell,
  .app-main,
  .card,
  .table-wrapper {
    min-width: 0;
  }

  /* サイドバー閉時：ページ全体の横はみ出しを抑止 */
  .app-body:not(.is-mobile).sidebar-collapsed {
    overflow-x: hidden;
  }

  /* サイドバー閉時：wrapper は横スクロールを許可しない */
  .app-body:not(.is-mobile).sidebar-collapsed .table-wrapper {
    overflow-x: hidden;
  }

  /* テーブルは画面幅に合わせて折り返す（横スクロール回避） */
  .app-body:not(.is-mobile).sidebar-collapsed .table-users {
    width: 100%;
    table-layout: fixed;
    min-width: 0 !important; /* 既存の min-width:860px 等を無効化 */
  }

  .app-body:not(.is-mobile).sidebar-collapsed .table-users th,
  .app-body:not(.is-mobile).sidebar-collapsed .table-users td {
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
}

/* =========================
  PC：サイドバー閉時のメイン幅・余白（最終決定）
  - 余白は app-main でのみ管理
  - card/body/content の左右paddingは触らない
========================= */
@media (min-width: 961px) {
  .app-body:not(.is-mobile).sidebar-collapsed .app-main {
    padding-left: 16px;
    padding-right: 16px;
  }

  .app-body:not(.is-mobile).sidebar-collapsed .card,
  .app-body:not(.is-mobile).sidebar-collapsed .card--wide {
    max-width: none;
    width: 100%;
    margin-left: 0;
    margin-right: 0;
  }
}

.app-main,
.card {
  box-sizing: border-box;
}

/* =========================
  PC：card を画面高さにフィット（上下同じ余白）
  - ページ全体は極力スクロールさせない
  - card 内（テーブル周り）だけをスクロール
========================= */
@media (min-width: 961px) {
  :root {
    --app-header-h: 56px;  /* ヘッダー高さ（違うなら調整） */
    --main-pad-y: 24px;    /* app-main の上下余白（あなたの値に合わせる） */
  }

  /* app-main 上下余白を変数化（既存値があるなら合わせる） */
  .app-main {
    padding-top: var(--main-pad-y);
    padding-bottom: var(--main-pad-y);
  }

  /* card 自体を「画面に収める」 */
  .card {
    /* ヘッダー + app-main上下padding分を除いた高さにする */
    max-height: calc(100vh - var(--app-header-h) - (var(--main-pad-y) * 2));
    height: calc(100vh - var(--app-header-h) - (var(--main-pad-y) * 2));

    /* 内部レイアウトを縦に分割（ヘッダー/ツールバー/テーブル） */
    display: flex;
    flex-direction: column;

    /* card 自体はスクロールさせない（中身だけスクロール） */
    overflow: hidden;
  }

  /* テーブル周辺のwrapperを「残り全部」＋スクロールにする
     どちらか一方でも当たるように保険で複数指定 */
  .card .table-wrapper,
  .card .table-area,
  .card .card-body {
    flex: 1 1 auto;
    min-height: 0;       /* ← flex内スクロールで必須 */
    overflow: auto;
  }

  /* テーブルヘッダーを固定して見やすく（任意：既にやってるなら不要） */
  .card .table-users th {
    position: sticky;
    top: 0;
    z-index: 2;
  }
}

/* =========================
  PC：ブラウザ側の縦スクロール(微小はみ出し)を抑止
========================= */
@media (min-width: 961px) {
  html,
  body {
    height: 100%;
  }

  /* 1pxはみ出し等で出るスクロールバーを抑える */
  body.app-body {
    overflow-y: hidden;
  }

  /* その代わり、メイン側だけスクロール可能にする（必要な場合） */
  .app-main {
    overflow: hidden;
  }
}

/* =========================
  Mobile: date input overflow hard-fix（iOS対策：縮められるようにする）
========================= */
@media (max-width: 960px) {
  .form-row input[type="date"] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;

    /* 見た目を他の input と揃える（.form-row input と同じ） */
    padding: 7px 10px !important;
    border-radius: 10px !important;
    font-size: 13px !important;

    /* iOSで“中身が縮まない”のを抑止 */
    -webkit-appearance: none !important;
    appearance: none !important;
    background: #f9fafb !important;
  }

  /* iOS内部の表示が右に押し出すのを抑える（効く環境だけ効く） */
  .form-row input[type="date"]::-webkit-date-and-time-value {
    text-align: left;
    margin: 0;
    padding: 0;
    white-space: nowrap;
  }
}

/* date切替方式：見た目を統一して崩れ防止 */
.js-date-switch {
  width: 100%;
  box-sizing: border-box;
  padding: 0 12px;
  border-radius: 8px; /* input-modernと同じに */
}

/* モバイルでもはみ出し防止 */
@media (max-width: 960px) {
  .form-row {
    min-width: 0;
  }

  .form-row .js-date-switch {
    max-width: 100%;
    min-width: 0;
    display: block;
  }
}

/* toast化：中央固定（通常は非表示） */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  width:75%;
  transform: translate(-50%, -50%) translateY(8px);
  z-index: 9999;

  opacity: 0;
  pointer-events: none;

  transition: opacity 240ms ease, transform 240ms ease;
}

/* 表示状態 */
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0);
}

/* フェードアウト状態（見た目は is-visible を外すだけでもOKだが、状態を分けたい場合） */
.toast.is-hiding {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(8px);
}

/* サイズ感（任意：中央トーストっぽくする） */
.toast.message {
  margin-bottom: 0;          /* fixedなので余白いらない */
  max-width: min(92vw, 560px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}
