* { box-sizing: border-box; }
:root {
  --bg: #f4f6f9; --panel: #fff; --line: #e3e8ef; --text: #1f2937;
  --muted: #8a94a6; --primary: #2563eb; --primary-d: #1d4ed8; --danger: #dc2626;
}
body {
  margin: 0; font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px; line-height: 1.6;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- レイアウト ---- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px; background: #111827; color: #cbd5e1; display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand { font-weight: 700; color: #fff; padding: 20px 18px; font-size: 16px; border-bottom: 1px solid #1f2a3a; }
.sidebar nav { display: flex; flex-direction: column; padding: 8px 0; flex: 1; }
.sidebar nav a { color: #cbd5e1; padding: 11px 18px; }
.sidebar nav a:hover { background: #1f2a3a; text-decoration: none; }
.sidebar nav a.on { background: var(--primary); color: #fff; }
.sidebar .logout { color: #94a3b8; padding: 14px 18px; border-top: 1px solid #1f2a3a; }
.main { flex: 1; min-width: 0; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 14px 28px; }
.topbar h1 { margin: 0; font-size: 18px; }
.content { padding: 24px 28px; }

/* ---- カード/グリッド ---- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.deal-no { font-variant-numeric: tabular-nums; font-weight: 600; }
.sort-link { color: inherit; text-decoration: none; white-space: nowrap; cursor: pointer; }
.sort-link:hover { text-decoration: underline; }
.sort-link.active { font-weight: 700; }
.sort-arrow { font-size: 0.85em; }
.kanban-filter { margin-bottom: 12px; }
.kanban-filter select { margin-left: 6px; }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.head-actions .inline-form.right { margin-left: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.stack > .card:last-child { margin-bottom: 0; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
/* ダッシュボード: 左1/3（リスト群）・右2/3（今日の対応履歴） */
.dash-grid { grid-template-columns: 1fr 2fr; }
@media (max-width: 900px) { .dash-grid { grid-template-columns: 1fr; } }
/* ダッシュボード下段: 3カード（画面幅に応じて自動で折り返し） */
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 18px; align-items: start; }
/* 主役カード（今日の対応履歴）を少し強調 */
.hero-card { border-color: #c7d2fe; box-shadow: 0 1px 3px rgba(37,99,235,.08); margin-bottom: 18px; }
.hero-card > .card-head { margin-bottom: 14px; }
.count-badge { font-size: 12px; font-weight: 700; color: var(--primary); background: #eef2ff; border-radius: 999px; padding: 2px 9px; margin-left: 8px; vertical-align: middle; }

/* ---- KPI ---- */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 280px)); gap: 14px; margin-bottom: 18px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 16px; }
.kpi.alert { border-color: #fca5a5; background: #fef2f2; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 26px; font-weight: 700; margin-top: 4px; }
.kpi-value span { font-size: 13px; font-weight: 400; margin-left: 2px; }
@media (max-width: 900px) { .kpi-row { grid-template-columns: 1fr 1fr; } }

/* ---- テーブル ---- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 12px; }
tr.done td { color: var(--muted); text-decoration: line-through; }
/* データ行のホバー強調（見出し行 th は対象外） */
tr:hover > td { background: #f8fafc; }
/* 行全体をクリック可能にした表（案件一覧など） */
tr.row-link { cursor: pointer; }
.muted { color: var(--muted); font-size: 12px; }
.danger { color: var(--danger); }

/* ---- バッジ ---- */
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #eef2ff; color: #3730a3; }
.badge.ghost { background: #f1f5f9; color: #475569; }
.s-見込み { background: #fef9c3; color: #854d0e; }
.s-商談中 { background: #dbeafe; color: #1e40af; }
.s-契約 { background: #dcfce7; color: #166534; }
.s-失注 { background: #fee2e2; color: #991b1b; }
.d-成約 { background: #dcfce7; color: #166534; }
.d-失注 { background: #fee2e2; color: #991b1b; }
.d-自社契約 { background: #dcfce7; color: #166534; }
.d-他社契約 { background: #fef9c3; color: #854d0e; }
.p-高 { background: #fee2e2; color: #991b1b; }
.p-中 { background: #fef9c3; color: #854d0e; }
.p-低 { background: #f1f5f9; color: #475569; }

/* ---- フォーム ---- */
.form label { display: block; margin-bottom: 12px; font-size: 13px; color: #374151; }
.form .row { display: flex; gap: 14px; }
.form .row label { flex: 1; }
.form input, .form select, .form textarea, .filters input, .filters select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 14px; font-family: inherit; margin-top: 3px; background: #fff;
}
.req { color: var(--danger); font-size: 11px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

button, .btn {
  display: inline-block; background: var(--primary); color: #fff; border: none;
  padding: 9px 16px; border-radius: 7px; font-size: 14px; cursor: pointer; font-family: inherit;
}
button:hover, .btn:hover { background: var(--primary-d); text-decoration: none; }
.btn.ghost { background: #fff; color: var(--text); border: 1px solid var(--line); }
.btn.ghost:hover { background: #f8fafc; }
.btn.danger, button.danger { background: var(--danger); }
.check { background: none; color: var(--text); padding: 0; font-size: 18px; }
.check:hover { background: none; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filters input { width: 240px; }
.filters select { width: auto; }

.inline-form summary { cursor: pointer; }
.inline-form.right { margin-left: auto; }
.inline-form[open] { margin-top: 12px; }
.inline-form > .form { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ---- 詳細 ---- */
.detail-head { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; }

/* 顧客詳細：対応履歴を主役にした2カラム（左袖＝情報 / 広い右＝履歴） */
.cust-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.cust-detail .cust-side { order: 1; }
.cust-detail .history-card { order: 2; }
@media (max-width: 900px) {
  .cust-detail { grid-template-columns: 1fr; }
  /* 縦積み時は履歴を先頭に（重視する情報を上に） */
  .cust-detail .history-card { order: 0; }
}
/* 常時表示の記録フォーム（履歴カードの先頭に固定） */
.record-form { background: #f8fafc; border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; margin-bottom: 18px; }
.record-form > button[type="submit"] { margin-top: 4px; }
.history-card .timeline { margin-top: 2px; }
/* 右袖：基本情報の読み取りサマリー（編集はdetailsで開く） */
.info-summary { display: grid; grid-template-columns: auto 1fr; gap: 5px 12px; font-size: 13px; margin: 0 0 4px; }
.info-summary dt { color: var(--muted); white-space: nowrap; }
.info-summary dd { margin: 0; word-break: break-word; }
.info-summary dd.memo { white-space: pre-wrap; }
/* 袖の中のフォームは幅が狭いので2列の row を縦積みに */
.cust-side .form .row { flex-direction: column; gap: 0; }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 14px; margin-left: 4px; position: relative; }
.timeline li::before { content: ""; position: absolute; left: -5px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--primary); }
.t-date { font-size: 12px; color: var(--muted); margin-right: 6px; }
.t-head { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.t-ops { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.t-ops form { display: inline; margin: 0; }

.flash { background: #dcfce7; color: #166534; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }

/* ---- ログイン ---- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: #111827; }
.login-card { background: #fff; padding: 36px 32px; border-radius: 14px; width: 340px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.3); }
.login-logo { font-size: 20px; font-weight: 700; margin-bottom: 22px; }
.login-card input { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px; margin-bottom: 14px; }
.login-card button { width: 100%; padding: 12px; font-size: 15px; }
.login-error { background: #fee2e2; color: #991b1b; padding: 9px; border-radius: 8px; margin-bottom: 14px; font-size: 13px; }

/* ---- タスク：表示切り替えタブ ---- */
.view-tabs { display: flex; align-items: center; gap: 8px; }
.vt-btn { background: #fff; color: var(--text); border: 1px solid var(--line); padding: 6px 14px; font-size: 13px; border-radius: 8px; }
.vt-btn:hover { background: #f8fafc; }
.vt-btn.on { background: var(--primary); color: #fff; border-color: var(--primary); }
.view-tabs .muted { margin-left: 6px; font-size: 12px; }

/* ---- タスク：カンバン ---- */
.kanban { display: flex; gap: 8px; align-items: start; overflow-x: auto; padding-bottom: 8px; }
.kcol { flex: 0 0 170px; background: #f4f6f9; border: 1px solid var(--line); border-radius: 10px; padding: 7px; min-height: 120px; }
.kcol-head { font-size: 13px; font-weight: 700; color: #334155; padding: 2px 4px 10px; display: flex; align-items: center; gap: 6px; }
.kcol-grip { cursor: grab; color: #94a3b8; user-select: none; font-size: 12px; line-height: 1; }
.kcol.col-dragging { opacity: .5; outline: 2px dashed var(--primary); outline-offset: -2px; }
.kcol-name { flex: 0 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcol-ops { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.kcol-ops button { background: none; border: none; cursor: pointer; font-size: 13px; padding: 2px 4px; color: var(--muted); }
.kcol-ops button:hover { color: var(--text, #111); }
.kcol-ops form { display: inline; margin: 0; }
.kcol-add { background: transparent; border: 1px dashed var(--line); display: flex; align-items: flex-start; }
/* タスク画面: 左プロジェクトメニュー + 右メイン の2ペイン */
.tasks-layout { display: flex; align-items: flex-start; gap: 16px; }
.tasks-main { flex: 1 1 auto; min-width: 0; }
.project-menu { flex: 0 0 200px; align-self: stretch; }
.pm-head { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin-bottom: 8px; }
.pm-list { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.pm-item { display: flex; align-items: center; gap: 6px; padding: 8px 10px; border-radius: 8px; color: #334155; text-decoration: none; font-size: 14px; }
.pm-item:hover { background: #f1f5f9; }
.pm-item.on { background: var(--primary); color: #fff; font-weight: 600; }
.pm-grip { cursor: grab; color: #94a3b8; font-size: 12px; line-height: 1; user-select: none; flex: 0 0 auto; }
.pm-item.on .pm-grip { color: rgba(255,255,255,.75); }
.pm-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-item.proj-dragging { opacity: .5; outline: 2px dashed var(--primary); outline-offset: -2px; }
.pm-add { width: 100%; }
.pm-current-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.pm-current { margin: 0; font-size: 18px; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pm-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.pm-actions form { display: inline; margin: 0; }
@media (max-width: 720px) {
  .tasks-layout { flex-direction: column; }
  .project-menu { flex-basis: auto; width: 100%; }
  .pm-list { flex-direction: row; flex-wrap: wrap; }
}
.kcount { background: #e2e8f0; color: #475569; font-size: 11px; font-weight: 600; border-radius: 999px; padding: 1px 8px; }
.kcol-body { display: flex; flex-direction: column; gap: 8px; min-height: 60px; border-radius: 8px; padding: 2px; transition: background .12s; }
.kcol-body.over { background: #e0e7ff; outline: 2px dashed var(--primary); outline-offset: -2px; }
/* 会社名（前株/後株 選択＋名称）。.form の width:100% を上書きして横並びにする */
/* 業種・主たる業務（左半分に縦積み）と業務内容（右半分）を50/50で並べる */
.biz-left { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
/* プロジェクト→ボードのリストは常に横並び1行（右袖の縦積み指定より優先） */
.cust-side .form .row.list-picker,
.form .row.list-picker { display: flex; flex-direction: row; gap: 8px; align-items: flex-end; }
.row.list-picker > label { flex: 1 1 0; min-width: 0; margin-bottom: 12px; }
.company-input { display: flex; gap: 6px; align-items: center; }
.company-input select { flex: 0 0 auto; width: auto; }
.company-input input { flex: 1 1 auto; width: auto; min-width: 0; }
/* 前付/後付 ラジオ（縦並び。テキスト入力の flex:1 を受けないようにする） */
.company-input .pos-radio { flex: 0 0 auto; display: inline-flex; flex-direction: column; align-items: flex-start; gap: 4px; white-space: nowrap; }
.company-input .pos-opt { display: inline-flex; align-items: center; gap: 3px; font-size: 13px; }
.company-input .pos-radio input { flex: 0 0 auto; width: auto; min-width: 0; margin: 0; }

/* 案件一覧の「タスク」列バッジ */
.badge.t-open { background: #eef2ff; color: #3730a3; text-decoration: none; }
.badge.t-done { background: #ecfdf5; color: #047857; text-decoration: none; }
.badge.t-od { background: #fee2e2; color: #b91c1c; }

/* 案件詳細のタスク進捗バー */
.task-progress { margin-bottom: 10px; }
.tp-bar { height: 8px; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.tp-bar span { display: block; height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s; }
.tp-label { font-size: 12px; color: var(--muted); margin-top: 4px; }
.tp-od { color: #b91c1c; }

/* 基本情報カード内のサブ見出し（資料・添付など） */
.subsection { font-size: 14px; margin: 16px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); }

/* 顧客の添付ファイル */
.attach-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 10px; }
.attach-item { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; }
.attach-thumb { width: 48px; height: 48px; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); display: block; }
.attach-icon { font-size: 28px; width: 48px; text-align: center; }
.attach-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.attach-main a { word-break: break-all; }
.attach-main .muted { font-size: 11px; }
.amsg-error { color: #b91c1c; font-size: 13px; margin: 0 0 8px; }

/* タスク: 「すべてのプロジェクト」メニュー項目 */
.pm-item.pm-all { font-weight: 600; margin-bottom: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }

/* 対応履歴の「タスクあり」リンク */
.badge.task-link { background: #ecfdf5; color: #047857; text-decoration: none; cursor: pointer; }
.badge.task-link:hover { background: #d1fae5; }
/* 「タスクあり」から遷移したカードの一時ハイライト */
.kcard.kfocus { outline: 2px solid var(--primary); outline-offset: 1px; box-shadow: 0 0 0 4px rgba(79,70,229,.18); animation: kfocus-pulse 1s ease-in-out 2; }
@keyframes kfocus-pulse { 0%,100% { box-shadow: 0 0 0 4px rgba(79,70,229,.18); } 50% { box-shadow: 0 0 0 8px rgba(79,70,229,.28); } }

/* 対応記録フォーム内の「タスクも追加」サブフォーム */
.subform { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px 10px; margin-top: 4px; }
.subform legend { font-size: 12px; color: var(--muted); padding: 0 4px; }

/* 取り込みパレット（既存タスクを列へドラッグ） */
.palette { width: min(420px, 80vw); }
.modal-box .palette { width: auto; }
/* 取り込み先リスト選択 */
.import-target { display: block; font-size: 13px; color: #374151; margin-bottom: 8px; }
.import-target select { margin-left: 6px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; background: #fff; }
/* 各タスクの「取り込む」ボタンは右端に寄せる */
.palette-item .pi-import { margin-left: auto; flex: 0 0 auto; align-self: center; }
.palette-hint { margin: 0 0 8px; }
.palette-filters { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.palette-filters select { flex: 1 1 auto; min-width: 110px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px; font-family: inherit; background: #fff; }
.palette-list { max-height: 320px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.palette-item { display: flex; align-items: flex-start; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px; }
.palette-item.in-current { background: #f8fafc; }
.pi-grip { color: var(--muted); cursor: grab; user-select: none; line-height: 1.4; }
.pi-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pi-content { font-size: 13px; word-break: break-word; }
.pi-content.pi-done { color: var(--muted); text-decoration: line-through; }
.pi-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; font-size: 11px; }
.pi-cust { color: var(--muted); }
.pi-due { color: var(--muted); }
.kcard { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 7px; box-shadow: 0 1px 2px rgba(0,0,0,.04); cursor: grab; }
.kcard:active { cursor: grabbing; }
.kcard.dragging { opacity: .5; }
.kcard.kdone .kcard-content { color: var(--muted); text-decoration: line-through; }
/* 完了に移したら期限切れ表示を隠す（完了から戻せば再表示される） */
.kcard.kdone .od-mark,
tr.done .od-mark,
.g-row.g-done .od-mark { display: none; }
.kcard.kdone.overdue { border-left-color: var(--line); background: var(--panel); }
.kcard.kdone .kdue.od { color: var(--muted); }
.g-row.g-done .g-name.od { color: inherit; }
.g-bar.over.done { outline: none; }
.kcard.touch-source { opacity: .35; }
.kcard.touch-floating { position: fixed; left: 0; top: 0; z-index: 1000; width: auto; max-width: 80vw; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,.25); transform: rotate(1.5deg); }
.kcard-content { font-size: 13px; font-weight: 600; margin-bottom: 6px; word-break: break-word; }
.kcard-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 11px; color: var(--muted); }
.kdue { color: #b45309; }
.kanban-hint { margin: 12px 2px 0; font-size: 12px; }
@media (max-width: 900px) { .kanban { grid-template-columns: 1fr 1fr; } }

/* ---- タスク：ガントチャート ---- */
.gantt { border: 1px solid var(--line); border-radius: 10px; overflow-x: auto; }
.g-row { display: flex; align-items: stretch; border-bottom: 1px solid var(--line); min-width: 880px; }
.g-row:last-child { border-bottom: none; }
.g-label { flex: 0 0 200px; width: 200px; padding: 8px 10px; border-right: 1px solid var(--line); background: #fff; position: sticky; left: 0; z-index: 2; box-sizing: border-box; }
.g-name { display: block; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.g-cust { font-size: 11px; }
.g-track { position: relative; flex: 1 1 auto; display: flex; min-width: 660px; }
.g-day, .g-cell { flex: 1 1 0; min-width: 22px; border-right: 1px solid #eef1f5; box-sizing: border-box; }
.g-day:last-child, .g-cell:last-child { border-right: none; }
.g-day { text-align: center; padding: 4px 0; font-size: 11px; color: #64748b; line-height: 1.2; }
.g-day .g-dom { display: block; font-weight: 600; color: #334155; }
.g-day.we, .g-cell.we { background: #f8fafc; }
.g-day.today .g-dom { color: #fff; background: var(--primary); border-radius: 4px; }
.g-cell.today { background: rgba(37,99,235,.08); box-shadow: inset 1px 0 0 var(--primary); }
.g-day.mstart { box-shadow: inset 2px 0 0 #cbd5e1; }
.g-head { background: #f8fafc; position: sticky; top: 0; z-index: 3; }
.g-head .g-label { background: #f8fafc; }
.g-bar { position: absolute; top: 7px; height: 20px; border-radius: 5px; background: var(--primary); color: #fff; font-size: 11px; line-height: 20px; padding: 0 7px; overflow: hidden; white-space: nowrap; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.g-bar span { overflow: hidden; text-overflow: ellipsis; }
.g-name.od { color: #b91c1c; }
.g-sub { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.g-bar.p-高 { background: #dc2626; }
.g-bar.p-中 { background: #2563eb; }
.g-bar.p-低 { background: #64748b; }
.g-bar.over { background: var(--danger); outline: 2px solid #7f1d1d; outline-offset: 1px; font-weight: 700; }
.g-bar.done { opacity: .45; text-decoration: line-through; }
.g-empty { padding: 16px; width: 100%; }
.g-outside { margin-top: 12px; }
.g-outside ul { margin: 8px 0 0; padding-left: 6px; list-style: none; }
.g-outside li { padding: 4px 0; font-size: 13px; }

/* 案件タグ（対応履歴・タスクに表示） */
.badge.deal { background: #ecfeff; color: #0e7490; }
a .badge.deal { cursor: pointer; }

/* フォームのエラー通知（重複ガード等） */
.notice-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; }
.notice-error a { color: #991b1b; font-weight: 600; text-decoration: underline; margin-left: 6px; }
.notice-error .muted { color: #b45353; margin-top: 4px; font-size: 12px; }
.check-inline { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.check-inline input { width: auto; }

/* 操作列（編集・削除） */
.btn.mini, button.mini { padding: 4px 10px; font-size: 12px; }
td.ops { white-space: nowrap; }
td.ops form { display: inline-block; }
td.ops .btn.mini, td.ops button.mini { margin-left: 4px; }
/* 編集フォームはテーブル全幅の行として開く（セル内に詰め込まない） */
.edit-row > td { background: #f8fafc; padding: 14px; }
.edit-row .form { max-width: 680px; margin: 0; }

/* 期限切れタスクの強調 */
.kcard.overdue { border-left: 3px solid var(--danger); background: #fffafa; }
.kcard .od-flag { color: #b91c1c; font-weight: 700; font-size: 11px; }
.kdue.od { color: #b91c1c; font-weight: 600; }
.badge.od { background: #fee2e2; color: #991b1b; }
tr.od-row > td { background: #fff7f7; }
tr.od-row.done > td { background: transparent; }

/* タスクのメモ表示 */
.kcard-memo { font-size: 11px; color: #64748b; margin-bottom: 6px; white-space: pre-wrap; word-break: break-word; }
.cell-memo { font-size: 11px; color: var(--muted); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }

/* タスク編集モーダル */
.modal { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 12px; padding: 22px; width: 420px; max-width: 92vw; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-box h3 { margin: 0 0 14px; font-size: 16px; }
/* カード・ガントの編集ボタン */
.kedit, .gedit { background: none; border: none; color: var(--muted); cursor: pointer; padding: 1px 4px; font-size: 13px; line-height: 1; border-radius: 5px; }
.kedit:hover, .gedit:hover { color: var(--primary); background: #eef2ff; }
.kcard-meta .kedit { margin-left: auto; }

/* =========================================================
   レスポンシブ（スマホ対応）
   ========================================================= */
.topbar { display: flex; align-items: center; gap: 6px; }
.hamburger { display: none; background: none; border: none; color: var(--text); font-size: 22px; line-height: 1; padding: 4px 8px 4px 0; cursor: pointer; }
.hamburger:hover { background: none; color: var(--primary); }
.nav-overlay { display: none; }

@media (max-width: 768px) {
  /* サイドメニューを引き出し式に */
  .hamburger { display: inline-block; }
  .sidebar { position: fixed; left: 0; top: 0; width: 240px; height: 100vh;
    transform: translateX(-100%); transition: transform .22s ease; z-index: 200; }
  body.nav-open .sidebar { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.45); }
  .nav-overlay { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 150; }
  .nav-overlay[hidden] { display: none; }

  /* 余白を詰める */
  .topbar { padding: 12px 16px; }
  .topbar h1 { font-size: 16px; }
  .content { padding: 16px; }
  .card { padding: 14px; }

  /* フォームの横並びを縦積みに */
  .form .row { flex-direction: column; gap: 0; }
  .filters { flex-direction: column; align-items: stretch; }
  .filters input, .filters select { width: 100%; }

  /* 幅の広いテーブルは横スクロール可能に */
  .card { overflow-x: auto; }

  /* KPIは2列 */
  .kpi-row { grid-template-columns: 1fr 1fr; }

  /* モーダルは画面いっぱい寄りに */
  .modal-box { width: 94vw; padding: 18px; }
}

@media (max-width: 640px) {
  /* カンバンは縦積みせず横並び＋横スクロール */
  .kanban {
    display: flex;
    grid-template-columns: none;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 6px;
    scroll-snap-type: x proximity;
  }
  .kcol { flex: 0 0 78%; scroll-snap-align: start; }
  /* ドラッグ中はsnapを無効化（自動スクロールが引き戻されないように） */
  .kanban.drag-scrolling { scroll-snap-type: none; }
  /* ガントの左ラベルを少し狭く */
  .g-label { flex: 0 0 140px; width: 140px; }
  /* KPIも1～2列で見やすく */
  .kpi-value { font-size: 22px; }
}
