:root {
  --primary:       #2563eb;
  --primary-hover: #1d4ed8;
  --primary-bg:    #eff6ff;
  --success:       #16a34a;
  --success-bg:    #f0fdf4;
  --danger:        #dc2626;
  --danger-bg:     #fef2f2;
  --warning:       #d97706;
  --bg:            #f1f5f9;
  --surface:       #ffffff;
  --border:        #e2e8f0;
  --text:          #0f172a;
  --muted:         #64748b;
  --nav-bg:        #0f172a;
  --radius:        8px;
  --shadow:        0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow-md:     0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── 線画アイコン（nav.js の icon()）── */
.ic {
  width: 1.1em; height: 1.1em;
  vertical-align: -0.18em;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0;
}
.empty-icon .ic { width: 40px; height: 40px; stroke-width: 1.5; color: #94a3b8; }
.nav-brand .ic { color: #60a5fa; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Meiryo', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Nav ── */
.nav {
  background: var(--nav-bg);
  height: 54px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-shrink: 0;
}
.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  text-decoration: none;
  white-space: nowrap;
}
.nav-links { display: flex; gap: 2px; list-style: none; }
.nav-links a {
  white-space: nowrap;
  color: #94a3b8;
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
  transition: color .15s, background .15s;
}
.nav-links a:hover  { color: #fff; background: rgba(255,255,255,.08); }
.nav-links a.active { color: #fff; background: rgba(255,255,255,.12); }

/* ── Department selector ── */
.dept-sel {
  height: 32px;
  padding: 0 30px 0 12px;
  background-color: #1e293b;
  /* 下向き矢印（線画） */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23cbd5e1' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
  color: #fff;
  border: 1px solid #475569;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  min-width: 112px;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .15s, background-color .15s;
}
.dept-sel:hover { border-color: #94a3b8; background-color: #273449; }
.dept-sel:focus { outline: none; border-color: #60a5fa; box-shadow: 0 0 0 3px rgba(96,165,250,.3); }
/* 開いたときの選択肢は白背景・濃い文字で読みやすく */
.dept-sel option { background: #fff; color: #0f172a; font-weight: 500; }
.dept-label { color: #94a3b8; font-size: 12px; font-weight: 600; white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }
@media (max-width: 768px) {
  /* iPhone はフォーム部品の文字が16px未満だとタップ時に拡大されるため16px */
  .dept-sel { font-size: 16px; height: 38px; min-width: 116px; padding: 0 32px 0 12px; background-position: right 10px center; background-size: 16px; }
  .dept-label-text { display: none; }
}
@media (max-width: 1100px) {
  .dept-label-text { display: none; }
}

/* ── Layout ── */
.main {
  flex: 1;
  padding: 24px;
  max-width: 1280px;
  margin: 0 auto;
  width: 100%;
}

/* ── Page header ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.page-title    { font-size: 20px; font-weight: 700; }
.page-subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ── Card ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-body { padding: 20px; }

/* ── KPI grid ── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 30px; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.kpi-sub   { font-size: 11px; color: var(--muted); margin-top: 3px; }
.kpi-card.blue   .kpi-value { color: var(--primary); }
.kpi-card.green  .kpi-value { color: var(--success); }
.kpi-card.orange .kpi-value { color: #ea580c; }
.kpi-card.red    .kpi-value { color: var(--danger); }

/* ── Charts ── */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(460px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.chart-wrap { position: relative; height: 240px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background .15s, opacity .15s;
  white-space: nowrap;
  line-height: 1;
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover  { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-danger  { background: var(--danger);  color: #fff; }
.btn-danger:hover  { background: #b91c1c; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }

/* ── Filter bar ── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  margin-bottom: 14px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.fg { display: flex; flex-direction: column; gap: 4px; }
.fg label { font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.filter-control {
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  min-width: 120px;
}
.filter-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }

/* ── Form ── */
.form-card { max-width: 860px; }
.form-card .card-body { padding: 16px; }
.form-section {
  margin-bottom: 16px;
  padding: 16px 18px;
  border-radius: 10px;
  border-left: 4px solid var(--border);
  background: var(--bg);
}
.form-section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

/* セクション別カラー */
.fs-basic     { background: #eff6ff; border-left-color: #2563eb; }
.fs-calls     { background: #f5f3ff; border-left-color: #7c3aed; }
.fs-meetings  { background: #fff7ed; border-left-color: #ea580c; }
.fs-contracts { background: #f0fdf4; border-left-color: #16a34a; }
.fs-cancel    { background: #fef2f2; border-left-color: #dc2626; }
.fs-memo      { background: #f8fafc; border-left-color: #94a3b8; }

.fs-basic     .form-section-title { color: #1d4ed8; border-bottom-color: #bfdbfe; }
.fs-calls     .form-section-title { color: #6d28d9; border-bottom-color: #ddd6fe; }
.fs-meetings  .form-section-title { color: #c2410c; border-bottom-color: #fed7aa; }
.fs-contracts .form-section-title { color: #15803d; border-bottom-color: #bbf7d0; }
.fs-cancel    .form-section-title { color: #b91c1c; border-bottom-color: #fecaca; }
.fs-memo      .form-section-title { color: #475569; border-bottom-color: #cbd5e1; }

/* セクション内の input 背景をセクション色に合わせる */
.fs-basic .form-control,
.fs-calls .form-control,
.fs-meetings .form-control,
.fs-contracts .form-control,
.fs-cancel .form-control,
.fs-memo .form-control { background: rgba(255,255,255,.85); }
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full { grid-column: 1 / -1; }
.form-label { font-size: 12px; font-weight: 600; }
.form-label .req { color: var(--danger); margin-left: 2px; }
.form-control {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-bg); }
.form-control[type="number"] { text-align: right; }
textarea.form-control { height: auto; min-height: 80px; padding: 8px 10px; resize: vertical; }

/* ── Table ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead tr { border-bottom: 2px solid var(--border); }
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:hover { background: #f8fafc; }
tbody tr:last-child { border-bottom: none; }
tfoot tr { border-top: 2px solid var(--border); background: #f8fafc; }
th {
  padding: 9px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}
td { padding: 9px 12px; white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { font-weight: 700; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px;
  border-top: 1px solid var(--border);
}
.pg-btn {
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  transition: all .15s;
}
.pg-btn:hover    { background: var(--bg); }
.pg-btn.active   { background: var(--primary); color: #fff; border-color: var(--primary); }
.pg-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Misc ── */
.avatar {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--primary-bg);
  color: var(--primary);
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.person-cell { display: flex; align-items: center; gap: 7px; font-weight: 500; }

.alert {
  padding: 10px 14px;
  border-radius: 6px;
  margin-bottom: 14px;
  font-size: 13px;
  display: none;
}
.alert.show { display: block; }
.alert-success { background: var(--success-bg); color: #166534; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fecaca; }

.empty { text-align: center; padding: 48px 24px; color: var(--muted); }
.empty-icon { font-size: 36px; margin-bottom: 10px; }
.empty-text { font-size: 15px; font-weight: 600; }
.empty-sub  { font-size: 13px; margin-top: 4px; }

.loading-cell { text-align: center; padding: 32px; color: var(--muted); }

.actions { display: flex; gap: 6px; }

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  gap: 0;
}
.tab {
  padding: 9px 20px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border: none;
  background: transparent;
  white-space: nowrap;
  position: relative;
  bottom: -2px;
  border-bottom: 2px solid transparent;
  transition: color .15s;
}
.tab:hover  { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Progress bar ── */
.goal-row { margin-bottom: 14px; }
.goal-row:last-child { margin-bottom: 0; }
.goal-header { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; font-size: 13px; }
.goal-name   { font-weight: 500; }
.goal-nums   { color: var(--muted); font-size: 12px; }
.goal-pct    { font-weight: 700; margin-left: 6px; }
.progress-bar  { background: var(--border); border-radius: 99px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; transition: width .4s ease; min-width: 2px; }

/* ── Tasks ── */
.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-check {
  flex-shrink: 0;
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--surface);
  cursor: pointer;
  margin-top: 2px;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  transition: all .15s;
}
.task-check.in_progress { border-color: var(--primary); background: var(--primary); color: white; }
.task-check.done        { border-color: var(--success); background: var(--success); color: white; }
.task-body  { flex: 1; min-width: 0; }
.task-title { font-weight: 500; font-size: 14px; }
.task-title.done    { text-decoration: line-through; color: var(--muted); }
.task-title.overdue { color: var(--danger); font-weight: 700; }
.task-overdue { background: rgba(220,38,38,.04); border-left: 3px solid var(--danger); padding-left: 9px; margin-left: -3px; border-radius: 4px; }

/* ── 担当者選択 部署タブ ── */
.person-selector-wrap { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.person-dept-tabs { display: flex; overflow-x: auto; background: var(--bg); border-bottom: 1px solid var(--border); scrollbar-width: none; }
.person-dept-tabs::-webkit-scrollbar { display: none; }
.person-dept-tab { padding: 6px 14px; font-size: 12px; font-weight: 600; border: none; border-bottom: 2px solid transparent; background: none; cursor: pointer; color: var(--muted); white-space: nowrap; transition: all .15s; }
.person-dept-tab:hover { color: var(--text); }
.person-dept-tab.active { color: var(--primary); border-bottom-color: var(--primary); background: var(--surface); }
.task-meta  { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; gap: 10px; flex-wrap: wrap; }
.task-memo  { font-size: 12px; color: var(--muted); margin-top: 3px; }

.task-editing { background: var(--bg); border-radius: 8px; padding: 12px; }
.task-edit-form { width: 100%; }
.task-edit-row { margin-bottom: 10px; }
.task-edit-label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 4px; }
.task-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

.status-badge { display: inline-flex; align-items: center; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 600; }
.s-pending     { background: #f1f5f9; color: var(--muted); }
.s-in_progress { background: var(--primary-bg); color: var(--primary); }
.s-checking    { background: #fef3c7; color: #92400e; }
.s-done        { background: var(--success-bg); color: var(--success); }

/* ── テーブル列幅クラス (colgroup で使用) ── */
.col-date   { width: 86px; }
.col-person { width: 120px; }
.col-num    { width: 62px; }
.col-yen    { width: 92px; }
.col-memo   { /* auto stretch */ }
.col-action { width: 128px; }

/* 日報一覧テーブル */
.list-table { table-layout: fixed; min-width: 1120px; }
.list-table th { white-space: normal; }

/* ダッシュボード担当者別テーブル */
.person-table { table-layout: fixed; min-width: 760px; }
.person-table th { white-space: normal; }

/* ── モーダル ── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 1000; padding: 16px; }
.modal-box { background: var(--surface); border-radius: 12px; width: 100%; max-width: 480px; box-shadow: 0 20px 60px rgba(0,0,0,.25); overflow: hidden; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-title { font-weight: 700; font-size: 15px; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 20px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg); }

/* ── 担当者セレクター（トグルボタン） ── */
.person-selector { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; }
.person-btn {
  padding: 5px 12px; border-radius: 99px; font-size: 12px; font-weight: 600;
  border: 2px solid var(--border); background: var(--surface); color: var(--muted);
  cursor: pointer; transition: all .15s;
}
.person-btn:hover { border-color: var(--p-color, var(--primary)); color: var(--p-color, var(--primary)); }
.person-btn.selected {
  background: var(--p-color, var(--primary));
  border-color: var(--p-color, var(--primary));
  color: #fff;
}
.all-btn { --p-color: #64748b; }
.person-badge {
  display: inline-flex; align-items: center; padding: 1px 7px;
  border-radius: 99px; font-size: 11px; font-weight: 600;
}

/* ── 朝礼ページ ── */
.briefing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.briefing-section {
  border-radius: 10px;
  border-left: 4px solid var(--border);
  padding: 14px 16px;
  background: var(--bg);
}
.briefing-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.briefing-items { min-height: 32px; margin-bottom: 10px; }
.briefing-item { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid rgba(0,0,0,.06); }
.briefing-item:last-child { border-bottom: none; }
.briefing-item-person { font-weight: 700; font-size: 12px; white-space: nowrap; min-width: 76px; flex-shrink: 0; padding-top: 2px; }
.briefing-item-content { flex: 1; font-size: 13px; line-height: 1.6; word-break: break-all; white-space: pre-wrap; }
.briefing-item-del  { flex-shrink: 0; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; transition: color .15s; }
.briefing-item-del:hover  { color: var(--danger); }
.briefing-item-edit { flex-shrink: 0; background: none; border: none; color: var(--muted); cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; transition: color .15s; }
.briefing-item-edit:hover { color: var(--primary); }
.briefing-item-track { flex-shrink: 0; background: none; border: none; cursor: pointer; font-size: 13px; line-height: 1; padding: 0 2px; opacity: .3; color: var(--muted); transition: opacity .15s, color .15s; }
.briefing-item-track:hover { opacity: .7; }
.briefing-item-track.is-tracked { opacity: 1; color: var(--danger); }
.briefing-item-editing { background: rgba(37,99,235,.04); border-radius: 6px; padding: 4px 2px; gap: 6px; align-items: center; }
.briefing-add-row  { display: flex; gap: 6px; align-items: flex-start; margin-top: 6px; }
.briefing-add-wrap { margin-top: 8px; }
.briefing-add-textarea { resize: vertical; min-height: 72px; padding-bottom: 36px !important; }
.briefing-add-btn {
  position: absolute; bottom: 12px; right: 12px;
  padding: 4px 12px; font-size: 12px; font-weight: 600;
  background: var(--primary); color: #fff;
  border: none; border-radius: 6px; cursor: pointer;
  transition: background .15s;
}
.briefing-add-btn:hover { background: var(--primary-hover); }
.briefing-person-sel { height: 34px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; padding: 0 8px; flex-shrink: 0; background: rgba(255,255,255,.8); }

.bs-company  { background: #eff6ff; border-left-color: #2563eb; }
.bs-client   { background: #f0fdf4; border-left-color: #16a34a; }
.bs-approval { background: #fff7ed; border-left-color: #ea580c; }
.bs-other    { background: #f8fafc; border-left-color: #94a3b8; }

.bs-company  .briefing-title { color: #1d4ed8; border-bottom-color: #bfdbfe; }
.bs-client   .briefing-title { color: #15803d; border-bottom-color: #bbf7d0; }
.bs-approval .briefing-title { color: #c2410c; border-bottom-color: #fed7aa; }
.bs-other    .briefing-title { color: #475569; border-bottom-color: #cbd5e1; }

@media (max-width: 768px) {
  .briefing-grid { grid-template-columns: 1fr; }
  #lower-grid    { grid-template-columns: 1fr !important; }

  /* 入力要素：iOS タップ時のズーム防止（16px 未満でズームが発生） */
  .form-control,
  .filter-control,
  .briefing-person-sel { font-size: 16px; }

  /* コンテンツテキストの統一 */
  .page-title            { font-size: 18px; }
  .briefing-title        { font-size: 13px; }
  .briefing-item-person  { font-size: 13px; }
  .briefing-item-content { font-size: 14px; }
  .task-meta             { font-size: 12px; }
  .task-memo             { font-size: 13px; }
}

/* ── 業務区分バッジ ── */
.task-type-badge { display:inline-flex;align-items:center;padding:1px 7px;border-radius:99px;font-size:10px;font-weight:700;flex-shrink:0; }
.tt-業務 { background:#f1f5f9; color:#475569; }
.tt-指示 { background:#dbeafe; color:#1e40af; }
.tt-確認 { background:#fef3c7; color:#92400e; }
.tt-連絡 { background:#dcfce7; color:#166534; }
.tt-共有 { background:#ede9fe; color:#5b21b6; }

/* 業務区分セレクター */
.type-selector { display:flex; flex-wrap:wrap; gap:5px; }
.type-btn { padding:4px 10px; border-radius:99px; font-size:11px; font-weight:700; border:2px solid var(--border); background:var(--surface); color:var(--muted); cursor:pointer; transition:all .15s; }
.type-btn:hover { opacity:.8; }
.type-btn.selected { border-color:currentColor; }
.type-btn[data-type="業務"].selected  { background:#f1f5f9; color:#475569; border-color:#94a3b8; }
.type-btn[data-type="指示"].selected  { background:#dbeafe; color:#1e40af; border-color:#93c5fd; }
.type-btn[data-type="確認"].selected  { background:#fef3c7; color:#92400e; border-color:#fcd34d; }
.type-btn[data-type="連絡"].selected  { background:#dcfce7; color:#166534; border-color:#86efac; }
.type-btn[data-type="共有"].selected  { background:#ede9fe; color:#5b21b6; border-color:#c4b5fd; }

/* ── 定型タスク行 ── */
.rec-row { display:flex; align-items:center; gap:10px; padding:7px 0; border-bottom:1px solid var(--border); }
.rec-row:last-of-type { border-bottom:none; }
.rec-badge { font-size:10px; font-weight:600; padding:1px 6px; border-radius:99px; white-space:nowrap; flex-shrink:0; }

/* ── 担当者並び替え ── */
.drag-handle { cursor: grab; color: var(--muted); font-size: 18px; line-height: 1; user-select: none; padding: 0 2px; flex-shrink: 0; }
.drag-handle:active { cursor: grabbing; }
.person-edit-row { transition: background .15s; border-radius: 6px; }
.person-edit-row.drag-over { background: var(--primary-bg); outline: 2px dashed var(--primary); outline-offset: -2px; }
.person-edit-row.dragging { opacity: .4; }

/* ── 担当者カラーピッカー ── */
.color-swatch-label { cursor: pointer; position: relative; display: inline-flex; }
.color-input { position: absolute; width: 0; height: 0; opacity: 0; pointer-events: none; }
.color-swatch {
  display: inline-block; width: 26px; height: 26px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.8); box-shadow: 0 0 0 2px rgba(0,0,0,.12);
  transition: transform .15s, box-shadow .15s;
}
.color-swatch-label:hover .color-swatch { transform: scale(1.18); box-shadow: 0 0 0 3px rgba(0,0,0,.2); }

/* ── ビュー切り替え ── */
.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.view-btn { padding: 5px 14px; font-size: 13px; font-weight: 500; background: var(--surface); color: var(--muted); border: none; cursor: pointer; transition: all .15s; }
.view-btn:hover { background: var(--bg); color: var(--text); }
.view-btn.active { background: var(--primary); color: #fff; }

/* ── カレンダー ── */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.cal-title { font-size: 16px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.cal-weekday { background: var(--bg); text-align: center; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 0; }
.cal-weekday.cal-weekend { color: #e04040; }
.cal-cell { background: var(--surface); min-height: 90px; padding: 6px; vertical-align: top; min-width: 0; overflow: hidden; }
.cal-cell.cal-other { background: var(--bg); }
.cal-cell.cal-today { background: #eff6ff; }
.cal-cell.cal-weekend .cal-day-num { color: #e04040; }
.cal-cell.cal-other .cal-day-num { color: #ccc; }
.cal-day-num { font-size: 12px; font-weight: 600; margin-bottom: 4px; }
.cal-cell.cal-today .cal-day-num { background: var(--primary); color: #fff; width: 20px; height: 20px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.cal-task-chip { font-size: 11px; padding: 2px 6px; border-radius: 4px; margin-bottom: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 4px; transition: filter .1s, opacity .15s; border-left: 3px solid; }
.cal-task-chip:hover { filter: brightness(.93); }
.cal-task-chip[draggable="true"] { cursor: grab; }
.cal-task-chip[draggable="true"]:active { cursor: grabbing; }
.cal-task-chip.done-chip { opacity: .55; text-decoration: line-through; }
.cal-cell.drag-over { background: var(--primary-bg) !important; outline: 2px dashed var(--primary); outline-offset: -3px; }
.cal-task-avatar { flex-shrink: 0; width: 14px; height: 14px; border-radius: 50%; font-size: 8px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; color: #fff; }
.cal-nodue-section { margin-top: 16px; }
.cal-nodue-header { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 6px; }
.cal-nodue-header::before { content: ''; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }
.cal-nodue-chips { display: flex; flex-wrap: wrap; gap: 6px; }

/* ── ハンバーガーナビ ── */
.nav-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 4px;
  flex-shrink: 0;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: #94a3b8;
  border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(7px) rotate(45deg); background: #fff; }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); background: #fff; }

/* ── ナビ：960px 以下はハンバーガーメニュー ── */
@media (max-width: 960px) {
  .nav { padding: 0 16px; flex-wrap: nowrap; position: relative; z-index: 200; }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none;
    position: absolute;
    top: 54px; left: 0; right: 0;
    background: var(--nav-bg);
    flex-direction: column;
    padding: 6px 16px 14px;
    border-top: 1px solid rgba(255,255,255,.08);
    box-shadow: 0 6px 16px rgba(0,0,0,.25);
    z-index: 200;
  }
  .nav-links.open { display: flex; }
  /* メニュー項目：横幅いっぱい・高さ52pxの行にしてタップしやすく */
  .nav-links li { display: block; }
  .nav-links li + li { border-top: 1px solid rgba(255,255,255,.07); }
  .nav-links a {
    display: flex; align-items: center;
    width: 100%; min-height: 52px;
    padding: 0 14px; font-size: 16px;
    border-radius: 8px;
    -webkit-tap-highlight-color: transparent;
  }
  .nav-links a:active { background: rgba(255,255,255,.14); }
  .nav-links a.active { color: #fff; background: rgba(37,99,235,.35); box-shadow: inset 3px 0 0 #60a5fa; }
  .nav-links { padding: 6px 12px 12px; max-height: calc(100dvh - 54px); overflow-y: auto; }
  /* メニューを開くボタン：44×44px */
  .nav-toggle { width: 44px; height: 44px; align-items: center; padding: 0; margin-right: -8px; border-radius: 8px; }
  .nav-toggle:active { background: rgba(255,255,255,.1); }
  /* メニュー表示中は背景を暗くする（タップで閉じる） */
  body.menu-open::after {
    content: ''; position: fixed; inset: 54px 0 0 0;
    background: rgba(15,23,42,.45); z-index: 150;
  }

}

/* ── Responsive 768px ── */
@media (max-width: 768px) {
  /* レイアウト */
  .main { padding: 12px; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .card-body { padding: 14px; }
  .card-header { padding: 11px 14px; }

  /* KPI */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .kpi-value { font-size: 24px; }
  .kpi-card { padding: 13px 14px; }

  /* チャート */
  .charts-grid { grid-template-columns: 1fr; }
  .chart-wrap { height: 200px; }

  /* ダッシュボード中段グリッド（インラインスタイル上書き） */
  #mid-grid { grid-template-columns: 1fr !important; }

  /* テーブル */
  .table-wrap { -webkit-overflow-scrolling: touch; }
  .person-table { min-width: 680px; }

  /* フォーム */
  .form-card { max-width: 100%; }
  .form-grid { grid-template-columns: 1fr 1fr; }
  .form-section { margin-bottom: 20px; }

  /* フィルターバー */
  .filter-bar { padding: 12px; gap: 8px; }
  .fg { flex: 1 1 calc(50% - 4px); }
  .filter-control { min-width: 0; width: 100%; }

  /* ビュー切り替え（フィルターバー内） */
  .view-toggle-fg { flex: 1 1 100%; display: flex; justify-content: flex-end; }

  /* タスク追加フォームグリッド（インラインスタイル上書き） */
  #task-add-grid { grid-template-columns: 1fr !important; }
  #task-add-grid .form-group:last-child { align-items: flex-end; }

  /* タスク item */
  .task-item { align-items: flex-start; }

  /* 担当者セレクター */
  .person-selector { gap: 5px; }
  .person-btn { font-size: 11px; padding: 4px 9px; }

  /* モーダル：下から出るシート形式 */
  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal-box { width: 100%; max-width: 100%; border-radius: 16px 16px 0 0; max-height: 92dvh; overflow-y: auto; }

  /* カレンダー */
  .cal-cell { min-height: 60px; padding: 3px; }
  .cal-weekday { font-size: 10px; padding: 5px 0; }
  .cal-day-num { font-size: 10px; margin-bottom: 2px; }
  .cal-cell.cal-today .cal-day-num { width: 18px; height: 18px; font-size: 9px; }
  .cal-task-chip { font-size: 10px; padding: 1px 3px; margin-bottom: 2px; }
  .cal-task-avatar { width: 12px; height: 12px; font-size: 7px; }

  /* タブ（分析） */
  .tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 1px; }
  .tab { white-space: nowrap; flex-shrink: 0; }

  /* 目標達成バー */
  .goal-row { margin-bottom: 12px; }

  /* 設定ページ */
  .color-swatch { width: 22px; height: 22px; }
}

/* ── Responsive 480px ── */
@media (max-width: 480px) {
  .main { padding: 10px; }
  .nav-brand { font-size: 13px; }

  /* KPI */
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-value { font-size: 20px; }
  .kpi-label { font-size: 11px; }
  .kpi-card { padding: 11px 12px; }

  /* フォーム */
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.cols-2 { grid-template-columns: 1fr; }

  /* テーブル */
  .list-table { min-width: 800px; }

  /* カレンダー小画面：チップはタイトルを省略 */
  .cal-cell { min-height: 50px; }
  .cal-task-chip { gap: 2px; }

  /* 日報入力：数値欄は2列を維持（入力の縦スクロールを減らす） */
  .form-card .form-grid:not(.cols-2) { grid-template-columns: 1fr 1fr; gap: 10px; }
}

/* ── スマホ最適化（追加分） ── */
/* グリッド内の横長テーブルがカラムを押し広げないようにする */
#lower-grid > *, #mid-grid > * { min-width: 0; }

@media (max-width: 768px) {
  /* ページヘッダー：タイトルとボタンは横並び、フィルターは次の行に全幅で */
  .page-header { flex-direction: row; align-items: center; justify-content: space-between; }
  .page-header > .filter-bar { width: 100%; }

  /* 営業報告：日付ナビ */
  .briefing-date-nav { width: 100%; display: grid !important; grid-template-columns: repeat(6, 1fr); gap: 6px !important; }
  .briefing-date-nav .btn { grid-column: span 2; justify-content: center; }
  .briefing-date-nav .filter-control { grid-column: span 3; max-width: none !important; width: 100%; min-width: 0; }

  /* カードヘッダー内の要素が多い場合は折り返す */
  .card-header { flex-wrap: wrap; gap: 8px; }

  /* タップしやすいサイズ */
  .btn    { min-height: 40px; }
  .btn-sm { min-height: 34px; padding: 6px 12px; }
  .pg-btn { width: 38px; height: 38px; font-size: 13px; }
  .view-btn { padding: 8px 14px; }
  .modal-close { font-size: 26px; padding: 4px 8px; }

  /* 横スクロール表：先頭列（担当者・期間）を固定 */
  .table-wrap table:not(.stack-table) th:first-child,
  .table-wrap table:not(.stack-table) td:first-child {
    position: sticky; left: 0; z-index: 1;
    background: var(--surface);
    box-shadow: 1px 0 0 var(--border);
  }
  .table-wrap table:not(.stack-table) tfoot td:first-child { background: #f8fafc; }
  .table-wrap table:not(.stack-table) td[colspan] { position: static; box-shadow: none; }
  #period-tbody td:first-child { word-break: keep-all; min-width: 6.5em; }

  /* 表 → カード表示（日報一覧・契約一覧） */
  .stack-table { display: block; min-width: 0 !important; table-layout: auto; }
  .stack-table colgroup, .stack-table thead { display: none; }
  .stack-table tbody { display: block; }
  .stack-table tbody tr {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px 8px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
  }
  .stack-table tbody tr:hover { background: transparent; }
  .stack-table td {
    display: flex; flex-direction: column;
    padding: 4px 0; white-space: normal; text-align: left;
    min-width: 0; max-width: none !important; overflow: visible !important;
  }
  .stack-table td.num { text-align: left; font-weight: 600; }
  .stack-table td > span { align-self: flex-start; }
  .stack-table td[data-label]::before {
    content: attr(data-label);
    font-size: 10px; font-weight: 600; color: var(--muted);
    letter-spacing: .02em; line-height: 1.4;
  }
  .stack-table td[colspan] { grid-column: 1 / -1; display: block; }
  .stack-table td.st-head::before { display: none; }
  .stack-table td.st-head { font-weight: 700; font-size: 14px; justify-content: center; }
  .stack-table td.st-wide { grid-column: span 2; }
  .stack-table td.st-full { grid-column: 1 / -1; }
  .stack-table td.st-memo { word-break: break-all; }
  .stack-table td.st-hide { display: none; }
  .stack-table td.st-actions::before { display: none; }
  .stack-table td.st-actions .actions { justify-content: flex-end; }
  .stack-table td.st-actions .btn { min-width: 72px; justify-content: center; }

  /* 日報入力：保存ボタンを画面下に固定 */
  .form-actions {
    position: sticky; bottom: 0; z-index: 50;
    background: var(--surface);
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: 0 -4px 12px rgba(0,0,0,.06);
    padding: 12px 14px calc(12px + env(safe-area-inset-bottom)) !important;
  }
  .form-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  /* フィルターは2列に（縦に長くなりすぎないように） */
  .fg { flex: 1 1 calc(50% - 4px); }
}
