:root {
  --color-bg: #f4f5f7;
  --color-panel: #ffffff;
  --color-border: #dcdfe4;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-text: #1f2430;
  --color-muted: #6b7280;
  --color-danger: #dc2626;
  font-family: -apple-system, "Segoe UI", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--color-bg);
  color: var(--color-text);
}

.screen { height: 100%; }
.hidden { display: none !important; }

/* ログイン画面 */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-form {
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 32px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.06);
}

.login-form h1 {
  font-size: 18px;
  margin: 0 0 8px;
  text-align: center;
}

.login-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--color-muted);
}

.login-form input {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
}

.login-form button {
  margin-top: 8px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  font-size: 14px;
  cursor: pointer;
}

.login-form button:hover { background: var(--color-primary-dark); }

.error-text {
  color: var(--color-danger);
  font-size: 13px;
  min-height: 1em;
  margin: 0;
}

/* メイン画面 */
#main-screen {
  display: flex;
  flex-direction: column;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--color-panel);
  border-bottom: 1px solid var(--color-border);
}

.app-header h1 { font-size: 16px; margin: 0; }

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--color-muted);
}

.header-right button {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

.app-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.sidebar {
  width: 320px;
  overflow-y: auto;
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.panel {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 12px;
}

.panel h2 {
  font-size: 13px;
  margin: 0 0 8px;
  color: var(--color-muted);
}

#map {
  flex: 1;
  min-width: 0;
}

.vehicle-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.vehicle-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.vehicle-list li:hover { background: var(--color-bg); }
.vehicle-list li.selected { background: #e8edfc; }

.vehicle-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}

.vehicle-name { font-weight: 600; }
.vehicle-time { color: var(--color-muted); font-size: 11px; margin-left: auto; }
.vehicle-offline { color: var(--color-muted); font-size: 11px; }

.vehicle-status-badge {
  color: white;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

.history-form select,
.history-form input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.history-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.message-log {
  list-style: none;
  margin: 0 0 8px;
  padding: 8px;
  max-height: 55vh;
  min-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--color-bg);
  border-radius: 8px;
}

.message-log li {
  max-width: 75%;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--color-panel);
  align-self: flex-start;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.message-log li.mine {
  align-self: flex-end;
  background: var(--color-primary);
  color: white;
}

.message-log li .meta {
  color: var(--color-muted);
  font-size: 11px;
  display: block;
  margin-top: 4px;
}

.message-log li.mine .meta { color: rgba(255, 255, 255, 0.85); }

.message-log li.empty-hint {
  align-self: center;
  max-width: none;
  background: transparent;
  box-shadow: none;
  color: var(--color-muted);
  padding: 24px 0;
}

.message-form {
  display: flex;
  gap: 6px;
}

.message-form button,
.history-buttons button {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.hidden {
  display: none;
}

.tacho-assignment-picker,

.tacho-assignment-picker button,

.history-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.labor-export-form {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.labor-export-note {
  margin: 0 0 8px;
}

.speed-chart-panel {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--color-border);
}

.speed-threshold-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: var(--color-muted);
  margin-bottom: 6px;
}

.speed-threshold-label input {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

#speed-chart-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.speed-chart-modal-content {
  max-width: 800px;
}

#speed-chart-modal-container svg {
  width: 100%;
  height: auto;
  display: block;
}

.speed-chart-slider {
  width: 100%;
  margin-top: 12px;
}

.history-buttons button:hover,
.message-form button:hover { background: var(--color-primary-dark); }

.status-text {
  font-size: 12px;
  color: var(--color-muted);
  margin: 4px 0 0;
}

.status-config-rows {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 8px;
}

.status-config-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-config-row input[type="text"] {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.status-color-palette {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.status-color-tile {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.status-color-tile.selected {
  border-color: var(--color-text, #1f2430);
  box-shadow: 0 0 0 1px white inset;
}

#status-config-save,

#status-config-save:hover,

/* 枠の並び替え・削除・kind未設定の警告 */
.status-config-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.status-order-button {
  width: 22px;
  height: 18px;
  line-height: 1;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface, white);
  cursor: pointer;
  font-size: 10px;
}

.status-order-button:disabled {
  opacity: 0.35;
  cursor: default;
}

.address-search-form {
  display: flex;
  gap: 6px;
}

.address-search-form input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.address-search-form button {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.address-search-form button:hover { background: var(--color-primary-dark); }

.address-search-results {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  max-height: 160px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.address-search-results li {
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--color-bg);
  cursor: pointer;
}

.address-search-results li:hover { background: #e8edfc; }

.vehicle-popup-buttons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.vehicle-popup-buttons button {
  padding: 6px 10px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  font-size: 12px;
  cursor: pointer;
}

.vehicle-popup-buttons button:hover { background: var(--color-primary-dark); }

.vehicle-popup-buttons button:disabled {
  background: #b9bec7;
  cursor: not-allowed;
}

.car-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

.car-icon-manual {
  border-radius: 50%;
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.55);
  animation: manual-pulse 1.2s ease-in-out infinite;
}

@keyframes manual-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.55); }
  50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0.25); }
}

.manual-badge {
  color: var(--color-danger);
  font-size: 11px;
  font-weight: 600;
}

#vehicle-admin-button,
#driver-admin-button {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background: var(--color-panel);
  border-radius: 10px;
  padding: 20px;
  width: min(920px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  cursor: move;
  touch-action: none;
}

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

.modal-header button {
  padding: 6px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
}

.vehicle-create-form {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.vehicle-create-form input {
  flex: 1 1 140px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.vehicle-create-form input[type="color"] {
  flex: 0 0 44px;
  padding: 0;
  cursor: pointer;
}

.vehicle-create-form select {
  flex: 1 1 120px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.vehicle-create-form button {
  padding: 6px 14px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  font-size: 13px;
  cursor: pointer;
}

.vehicle-create-form button:hover { background: var(--color-primary-dark); }

.csv-import-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 12px;
}

.csv-import-row a { color: var(--color-primary); }

.csv-import-row input[type="file"] {
  font-size: 12px;
}

.csv-import-row button {
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  background: var(--color-primary);
  color: white;
  font-size: 12px;
  cursor: pointer;
}

.csv-import-row button:hover { background: var(--color-primary-dark); }

.import-result {
  font-size: 12px;
  background: var(--color-bg);
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 8px;
  max-height: 160px;
  overflow-y: auto;
}

.import-result .credential-row {
  font-family: monospace;
}

.import-result .error-row {
  color: var(--color-danger);
}

.vehicle-admin-table-wrap {
  overflow-x: auto;
}

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

.vehicle-admin-table th,
.vehicle-admin-table td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border);
  text-align: left;
  white-space: nowrap;
}

.vehicle-admin-table input {
  width: 100%;
  min-width: 70px;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 12px;
}

.vehicle-admin-table tr.deleted {
  opacity: 0.5;
}

.vehicle-admin-table .row-actions {
  display: flex;
  gap: 4px;
}

.vehicle-admin-table .row-actions button {
  padding: 4px 8px;
  border: none;
  border-radius: 4px;
  background: var(--color-primary);
  color: white;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

.vehicle-admin-table .row-actions button:hover { background: var(--color-primary-dark); }

.vehicle-admin-table .row-actions button.danger { background: var(--color-danger); }
.vehicle-admin-table .row-actions button.danger:hover { background: #b91c1c; }

.modal-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 14px;
}

.modal-tab {
  padding: 8px 14px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-muted);
  font-size: 13px;
  cursor: pointer;
}

.modal-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.labor-card.alert { border-color: var(--color-danger); box-shadow: 0 0 0 1px var(--color-danger); }

.labor-bar-fill.ok { background: #22c55e; }
.labor-bar-fill.warn { background: #eab308; }
.labor-bar-fill.danger { background: var(--color-danger); }

/* P-B: 運転時間(N週平均・2日平均)セクション。
   拘束時間とは別系統の規制なので、区切り線と見出しで独立したまとまりに見せる。
   情報量は多めに出し、状態は色で優先順位を付ける()。 */

/* P-L: ログイン画面の法的リンク(位置情報の取扱い)。目立ちすぎず、必ず見える位置に置く */
.login-legal-links { margin-top: 6px; text-align: center; font-size: 11px; }
.login-legal-links a { color: var(--color-muted); }
.login-legal-links a:hover { color: #2563eb; }

/* P-J: 設定ヘルプ。各項目のラベル横に ⓘ を出し、クリックで説明を開く。
   文言は src/help/laborHelp.js が唯一のソース(CSSはここ、文言はあちら)。 */

.labor-settings-form select,

.labor-corrections-filter select,

/* 勤務記録の修正: 理由入力+ステータス修正の詳細行(既定は非表示) */
#labor-corrections-tbody tr.correction-details.hidden { display: none; }

.row-actions .link-button {
  margin-right: 8px;
  font-size: 12px;
}

.assignment-reasons-form select,
.assignment-reasons-form input[type='datetime-local'],

.assignment-reasons-conditional.hidden { display: none; }

.assignment-reasons-conditional input,

/* P-H: 勤務記録の修正のビジュアルタイムライン()。
   1日を選んで大きく表示し、「表示幅」で1画面に見せる時間数(ズーム)を変えられる。
   24時間より狭くすると内側のキャンバスが横に伸びるため、外側の枠を横スクロールさせる。 */

.timeline-day-tab.active {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
  font-weight: 600;
}

.labor-alert-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 6px;
  border-radius: 10px;
  background: var(--color-danger);
  color: white;
  font-size: 10px;
  font-weight: 600;
}

.labor-alerts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 60vh;
  overflow-y: auto;
}

.labor-alerts-list li {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--color-bg);
  font-size: 13px;
  border-left: 3px solid var(--color-muted);
}

.labor-alerts-list li.warning { border-left-color: var(--color-danger); }
.labor-alerts-list li.notice { border-left-color: #eab308; }

/* 本文+日時の行。アクションボタン(下記)は別行にして、幅の狭い右サイドバーでも
   本文とボタンが幅を奪い合ってCJK文字が1文字ずつ縦折り返しになる崩れを防ぐ。 */
.labor-alerts-list .alert-row-header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}

.labor-alerts-list .alert-meta {
  color: var(--color-muted);
  font-size: 11px;
  white-space: nowrap;
}

.labor-alerts-list .alert-body {
  flex: 1;
  min-width: 0;
  /* プラン変更通知(planNotify.js)は改行入りの複数行本文を送るため、既存の単一行アラートの
     見た目を変えずに改行だけ効かせる(pre-lineは連続空白は詰めるが\nは改行として扱う) */
  white-space: pre-line;
}

/* 取消済みアラート(誤検知として管理者が取り消したもの) */
.labor-alerts-list li.alert-retracted {
  opacity: 0.6;
}
.labor-alerts-list li.alert-retracted .alert-body {
  text-decoration: line-through;
}
.labor-alerts-list .alert-retracted-note {
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 2px;
}

.alert-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

@keyframes labor-card-flash {
  0% { box-shadow: 0 0 0 3px var(--color-primary); }
  100% { box-shadow: none; }
}

.link-button {
  color: var(--color-primary);
  font-size: 13px;
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

.link-button:hover { text-decoration: underline; }

.version-footer {
  text-align: center;
  color: #9CA3AF;
  font-size: 11px;
  padding: 12px 0 24px;
}

/* 営業所グルーピング(2026-07-14 アカウントレベル分け対応) */

.office-filter-details {
  margin-bottom: 8px;
  font-size: 12px;
}

.office-filter-details summary {
  cursor: pointer;
  color: var(--color-primary);
}

.office-filter-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 6px 0 2px;
}

.office-filter-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: normal;
  cursor: pointer;
}

.office-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 8px;
}

.office-table th,
.office-table td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--color-border);
  font-size: 13px;
}

.office-table td.actions {
  white-space: nowrap;
}

.office-name-input {
  width: 100%;
  padding: 4px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-size: 13px;
}

.multi-login-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 16px;
  background: #fef3c7;
  color: #92400e;
  font-size: 13px;
  border-bottom: 1px solid #fde68a;
}

.multi-login-banner button {
  padding: 4px 10px;
  border: none;
  border-radius: 6px;
  background: #92400e;
  color: white;
  font-size: 12px;
  cursor: pointer;
}

/* 制限機能はグレーアウト+クリックで案内表示に統一する */
.plan-locked {
  opacity: 0.5;
  cursor: not-allowed;
}

.vehicle-watch-badge.labor-watch-row-notice,
li.labor-watch-row-notice { background: #fef3c7; }
.vehicle-watch-badge.labor-watch-row-danger,
li.labor-watch-row-danger { background: #fee2e2; }

@keyframes labor-watch-halo-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}
.labor-watch-halo-pulse { animation: labor-watch-halo-pulse 1.2s ease-in-out infinite; }

/* ---- ヘッダー左側(ハンバーガー+タイトル)・アイコンボタン共通 ---- */
.header-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.icon-btn:hover { background: var(--color-bg); }

#mobile-sidebar-toggle { display: none; }

/* ---- 左サイドバー: 開閉(アイコンレールに収束) ---- */
.app-body {
  position: relative; /* モバイル時のオーバーレイ配置の基準 */
}

.sidebar {
  width: 320px;
  min-width: 320px;
  overflow: hidden;
  background: var(--color-panel);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  padding: 0;
  gap: 0;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar-header {
  display: flex;
  justify-content: flex-end;
  padding: 8px 8px 0;
  flex: none;
}

.sidebar-toggle-btn {
  width: 26px;
  height: 26px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  flex: none;
}

.sidebar-toggle-btn:hover { background: var(--color-bg); }

.sidebar-rail {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 4px 0 12px;
  flex: none;
}

.sidebar-rail-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  font-size: 15px;
}

.sidebar-rail-btn:hover { background: var(--color-bg); }

.sidebar-panels {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 12px 12px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.sidebar.collapsed {
  width: 48px;
  min-width: 48px;
}

.sidebar.collapsed .sidebar-header { justify-content: center; }
.sidebar.collapsed .sidebar-panels { display: none; }
.sidebar.collapsed .sidebar-rail { display: flex; }

/* パネルのアコーディオン化(旧.panel相当の見た目をdetails/summaryへ) */
.panel-details {
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
  flex: none;
}

.panel-details > summary {
  list-style: none;
  cursor: pointer;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--color-panel);
}

.panel-details > summary::-webkit-details-marker { display: none; }

.panel-details > summary::after {
  content: '▸';
  color: var(--color-muted);
  transition: transform 0.15s;
}

.panel-details[open] > summary::after { transform: rotate(90deg); }

.panel-details .panel-body {
  padding: 0 12px 12px;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 890;
}

.sidebar-backdrop.active { display: block; }

/* ---- レスポンシブ: 900px未満はサイドバーをオーバーレイドロワー化 ---- */
@media (max-width: 900px) {
  #mobile-sidebar-toggle { display: inline-flex; }

  .sidebar-header { display: none; } /* デスクトップの収束トグルは使わない */

  .sidebar,
  .sidebar.collapsed {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 900;
    width: 85vw;
    max-width: 340px;
    min-width: 0;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: 2px 0 12px rgba(0, 0, 0, 0.2);
  }

  .sidebar.mobile-open { transform: translateX(0); }

  .sidebar-rail { display: none !important; }
  .sidebar.collapsed .sidebar-panels,
  .sidebar-panels { display: flex; }
}

/* ---- このアプリについて ---- */
.about-modal-content { width: min(420px, 92vw); }

.about-app-name {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 4px;
}

.about-body hr {
  border: none;
  border-top: 1px solid var(--color-border);
  margin: 12px 0;
}

.about-contact {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 13px;
}

.about-contact dt { color: var(--color-muted); }
.about-contact dd { margin: 0; }
.about-contact a { color: var(--color-primary); text-decoration: none; }
.about-contact a:hover { text-decoration: underline; }

.about-attribution {
  font-size: 11px;
  color: var(--color-muted);
  line-height: 1.6;
  margin: 0;
}

.login-about-link {
  margin-top: 4px;
  align-self: center;
}

/* ---- 右サイドバー: メッセージ/アラート統合() ---- */

.right-sidebar {
  width: 360px;
  min-width: 360px;
  border-right: none;
  border-left: 1px solid var(--color-border);
}

.right-sidebar .sidebar-header { justify-content: flex-start; }
.right-sidebar.collapsed .sidebar-header { justify-content: center; }
.right-sidebar.collapsed { width: 56px; min-width: 56px; }
.right-sidebar.collapsed .right-sidebar-panels { display: none; }
.right-sidebar.collapsed .right-rail { display: flex; }

.right-rail { position: relative; }

.rail-badge {
  position: absolute;
  top: -4px;
  right: 2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: 8px;
  background: var(--color-danger);
  color: white;
  font-size: 9px;
  line-height: 16px;
  text-align: center;
}

.right-sidebar-panels {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 0;
}

.right-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  flex: none;
}

.right-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--color-muted);
  font-size: 13px;
  cursor: pointer;
}

.right-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

.right-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* 新規送信・チャットメニュー共通のドロップダウン */
.dropdown-wrap { position: relative; }

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 180px;
  z-index: 20;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-item {
  padding: 8px 10px;
  border: none;
  border-radius: 6px;
  background: none;
  text-align: left;
  font-size: 13px;
  cursor: pointer;
  color: var(--color-text);
}

.dropdown-item:hover { background: var(--color-bg); }

/* 会話一覧(ビューA) */
.conversation-list-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 10px;
}

.conversation-list-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex: none;
}

#conversation-search {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
}

.conversation-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.conversation-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 6px;
  border-radius: 8px;
  cursor: pointer;
}

.conversation-list li:hover { background: var(--color-bg); }
.conversation-list li.broadcast-row { border-bottom: 1px solid var(--color-border); margin-bottom: 4px; padding-bottom: 10px; }

.conversation-list .conv-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex: none;
}

.conversation-list .conv-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conversation-list .conv-name {
  font-size: 13px;
  font-weight: 600;
}

.conversation-list .conv-preview {
  font-size: 12px;
  color: var(--color-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-list .conv-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex: none;
}

.conversation-list .conv-time {
  font-size: 11px;
  color: var(--color-muted);
}

.conversation-list .conv-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #22c55e;
  color: white;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
}

/* チャット(ビューB) */
.chat-view {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  padding: 10px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex: none;
}

.chat-peer-name {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-view .message-log {
  flex: 1;
  min-height: 0;
  max-height: none;
}

.date-separator {
  align-self: center;
  font-size: 11px;
  color: var(--color-muted);
  margin: 4px 0;
}

.message-log li .broadcast-tag {
  display: inline-block;
  font-size: 10px;
  color: var(--color-primary);
  margin-bottom: 2px;
}

.message-log li.mine .broadcast-tag { color: rgba(255, 255, 255, 0.85); }

.read-receipt {
  display: block;
  font-size: 10px;
  color: var(--color-muted);
  margin-top: 2px;
  text-align: right;
}

.read-receipt.clickable { cursor: pointer; text-decoration: underline; }

.chat-view .message-form textarea {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  line-height: 1.4;
}

/* アラートフィード(ビューC) */
#right-panel-alerts {
  padding: 10px;
  overflow-y: auto;
}

#right-panel-alerts .labor-alerts-list li { cursor: pointer; }
#right-panel-alerts .labor-alerts-list li.unread { box-shadow: 0 0 0 1px var(--color-primary) inset; }

/* 既読者/未読者一覧モーダル */
.read-status-modal-content { width: min(480px, 92vw); }

.read-status-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.read-status-columns h3 {
  font-size: 12px;
  color: var(--color-muted);
  margin: 0 0 6px;
}

.read-status-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  max-height: 40vh;
  overflow-y: auto;
}

.read-status-list .read-status-time {
  display: block;
  font-size: 11px;
  color: var(--color-muted);
}

/* ---- レスポンシブ: 右サイドバーもモバイルではオーバーレイドロワー ---- */
@media (max-width: 900px) {
  #right-sidebar-toggle { display: none; }

  .right-sidebar,
  .right-sidebar.collapsed {
    position: fixed;
    top: 0;
    right: 0;
    left: auto;
    height: 100%;
    z-index: 900;
    width: 100vw;
    max-width: none;
    min-width: 0;
    transform: translateX(100%);
    transition: transform 0.2s ease;
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.2);
  }

  .right-sidebar.mobile-open { transform: translateX(0); }
  .right-rail { display: none !important; }
  .right-sidebar.collapsed .right-sidebar-panels,
  .right-sidebar-panels { display: flex; }

  #mobile-right-sidebar-toggle { display: inline-flex; }
}

#mobile-right-sidebar-toggle { display: none; position: relative; }

/* ---- 製品版で利用できる機能(OSS版ではグレーアウト) ---- */
/* ボタンは残して押せる状態にしておく(disabledにするとクリックを拾えず、
   案内モーダルを出せないため)。見た目だけ「使えない」ことを伝える。 */
/* ボタンのcursor: pointer が後勝ちしないよう !important で押さえる */
.oss-locked,
.oss-locked:hover {
  cursor: not-allowed !important;
  filter: grayscale(100%);
}

.oss-locked {
  opacity: 0.45;
}

.oss-locked:hover {
  opacity: 0.6;
}

.oss-upsell-content {
  max-width: 480px;
}
