/* ========================================
   再生支援カルテ — スタイルシート
   ======================================== */

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

:root {
  --primary:    #1a3a5c;
  --primary-lt: #2980b9;
  --danger:     #c0392b;
  --warning:    #e67e22;
  --success:    #27ae60;
  --info:       #2980b9;
  --purple:     #8e44ad;
  --bg:         #f0f2f5;
  --card-bg:    #ffffff;
  --border:     #dde1e7;
  --text:       #2c3e50;
  --text-muted: #7f8c8d;
  --sidebar-w:  340px;
}

body {
  font-family: 'Hiragino Sans', 'Meiryo', 'Yu Gothic', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
}

/* ── ヘッダー ── */
.app-header {
  background: var(--primary);
  color: white;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand { display: flex; align-items: center; gap: 10px; }
.brand-icon { font-size: 22px; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .03em; }

/* ── NG バナー ── */
.ng-banner {
  background: var(--danger);
  color: white;
  padding: 8px 24px;
  display: flex;
  gap: 24px;
  font-weight: 700;
  font-size: 13px;
  position: sticky;
  top: 56px;
  z-index: 99;
}

/* ── ダッシュボード ── */
.dashboard {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}
.dashboard-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.dashboard-header h2 { font-size: 20px; }
.search-box {
  margin-left: auto;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  width: 240px;
}
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}
.case-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  display: block;
  overflow: hidden;
  transition: box-shadow .15s, transform .15s;
}
.case-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.12); transform: translateY(-2px); }
.case-card.ball-client { border-left: 4px solid var(--danger); }
.ng-strip {
  background: #fde8e8;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  display: flex;
  gap: 12px;
}
.case-card-header {
  padding: 14px 16px 8px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.name-main { font-size: 17px; font-weight: 700; }
.name-kana { font-size: 12px; color: var(--text-muted); }
.case-badges { display: flex; flex-wrap: wrap; gap: 4px; justify-content: flex-end; }
.status-badge {
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}
.ball-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
}
.ball-client-badge { background: var(--danger); color: white; }
.ball-office-badge { background: #dce8f5; color: var(--primary-lt); }
.case-card-body { padding: 8px 16px 14px; }
.case-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.meta-item {
  font-size: 12px;
  background: #eef2f7;
  padding: 2px 8px;
  border-radius: 4px;
  color: var(--text-muted);
}
.alert-tag { background: #fdf3e3; color: var(--warning); font-weight: 700; }
.risk-tag  { background: #fde8e8; color: var(--danger);  font-weight: 700; }
.doc-progress { }
.progress-label { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.progress-bar {
  height: 6px;
  background: #e8eaec;
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill { height: 100%; background: var(--primary-lt); border-radius: 3px; transition: width .3s; }
.empty-state { text-align: center; padding: 60px; color: var(--text-muted); }
.count-badge {
  background: var(--primary-lt);
  color: white;
  font-size: 12px;
  padding: 1px 8px;
  border-radius: 10px;
  margin-left: 6px;
}

/* ── カルテ ヘッダー ── */
.karte-header {
  background: var(--primary);
  color: white;
  padding: 0 24px;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
}
.back-link { color: #9bb8d4; text-decoration: none; }
.back-link:hover { color: white; }
.karte-id { color: #9bb8d4; }
.header-updated { margin-left: auto; color: #9bb8d4; }

/* ── カルテ レイアウト ── */
.karte-layout {
  display: flex;
  height: calc(100vh - 96px);
  overflow: hidden;
}
.ng-banner ~ .karte-header ~ .karte-layout {
  height: calc(100vh - 130px);
}

/* ── サイドバー ── */
.karte-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 0;
}
.sidebar-section {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.client-info-section {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  background: #f7f9fc;
}
.client-name-main { font-size: 20px; font-weight: 700; }
.client-name-kana { font-size: 12px; color: var(--text-muted); }
.client-age { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.sidebar-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 8px;
}
.sidebar-item {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 4px;
}
.item-label {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.date-target { color: var(--warning); font-weight: 700; }

/* ボール表示 */
.ball-holder-block {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 700;
  margin-bottom: 8px;
}
.ball-holder-block.ball-client {
  background: #fde8e8;
  color: var(--danger);
  border: 1.5px solid var(--danger);
}
.ball-holder-block.ball-office {
  background: #dce8f5;
  color: var(--primary-lt);
  border: 1.5px solid #9bb8d4;
}
.ball-label { font-size: 11px; }
.ball-value { font-size: 15px; }
.status-pill {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
  color: white;
  background: var(--text-muted);
  margin-bottom: 6px;
}
.procedure-block {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}
.procedure-block.kanzan { background: #fdf3e3; color: var(--warning); border: 1px solid var(--warning); }
.procedure-block.doji   { background: #eafaf1; color: var(--success); border: 1px solid var(--success); }
.kanzan-alert {
  margin-top: 6px;
  background: #fdf3e3;
  color: var(--warning);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid #f0c070;
}
.discharge-alert {
  margin-top: 6px;
  background: #fde8e8;
  color: var(--danger);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 4px;
}

/* 書類進捗（サイドバー） */
.doc-progress-sidebar { }
.progress-nums { font-size: 13px; margin-bottom: 4px; }
.progress-bar-large {
  height: 10px;
  background: #e8eaec;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 4px;
}
.progress-bar-large .progress-fill.complete { background: var(--success); }
.progress-bar-large .progress-fill.half { background: var(--primary-lt); }
.progress-bar-large .progress-fill.low { background: var(--warning); }
.progress-pct { font-size: 13px; font-weight: 700; color: var(--primary-lt); }

/* ── メインエリア ── */
.karte-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.tab-nav {
  display: flex;
  background: var(--card-bg);
  border-bottom: 2px solid var(--border);
  padding: 0 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.tab-btn {
  padding: 12px 18px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn:hover { color: var(--primary-lt); }
.tab-btn.active { color: var(--primary-lt); border-bottom-color: var(--primary-lt); font-weight: 700; }
.count-badge-sm {
  background: var(--text-muted);
  color: white;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  margin-left: 4px;
}
.tab-content { display: none; padding: 20px 24px; flex: 1; }
.tab-content.active { display: block; }
.tab-toolbar { margin-bottom: 16px; }

/* ── 書類管理 ── */
.doc-group { margin-bottom: 20px; }
.doc-group-header {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.doc-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  transition: background .1s;
}
.doc-row:hover { background: #f7f9fc; }
.doc-row.received .doc-desc { text-decoration: line-through; color: var(--text-muted); }
.doc-check { display: flex; align-items: center; gap: 8px; cursor: pointer; flex: 1; }
.doc-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }
.doc-desc { font-size: 14px; }
.optional-tag {
  font-size: 10px;
  background: #eee;
  color: var(--text-muted);
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
}
.doc-date { font-size: 11px; color: var(--success); margin-left: auto; }
.doc-row-main {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.doc-note-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 24px;
  margin-top: 4px;
}
.doc-note-input {
  flex: 1;
  font-size: 12px;
  padding: 4px 8px;
  border: 1px solid #e0e5eb;
  border-radius: 4px;
  background: #fafbfc;
  color: var(--text);
  font-family: inherit;
  transition: border-color .15s, background .15s;
}
.doc-note-input:focus {
  outline: none;
  border-color: var(--primary-lt);
  background: white;
}
.doc-note-input::placeholder { color: #b0b8c4; }
.note-saved-msg {
  font-size: 11px;
  color: var(--success);
  min-width: 14px;
}

/* ── サマリーグリッド ── */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
  margin-bottom: 20px;
}
.summary-card {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
}
.summary-card h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--primary);
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.balance-display {
  margin-top: 12px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}
.balance-display.positive { background: #eafaf1; color: var(--success); }
.balance-display.negative { background: #fde8e8; color: var(--danger); }
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

/* ── タイムライン ── */
.timeline-input-form {
  background: #f7f9fc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.timeline-type-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
}
.timeline-author {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  flex: 1;
}
.timeline-textarea {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  resize: vertical;
  font-family: inherit;
}
.timeline-list { display: flex; flex-direction: column; gap: 12px; }
.timeline-item {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
}
.tl-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.tl-type {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
}
.type-電話  { background: #dce8f5; color: var(--info); }
.type-メール { background: #e8f5e9; color: var(--success); }
.type-面談  { background: #f3e5f5; color: var(--purple); }
.type-書類受取 { background: #fff3e0; color: var(--warning); }
.type-メモ  { background: #f5f5f5; color: var(--text-muted); }
.tl-author { font-size: 12px; color: var(--text-muted); }
.tl-date   { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.tl-delete {
  font-size: 11px;
  color: #bbb;
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 6px;
}
.tl-delete:hover { color: var(--danger); }
.tl-content { font-size: 13px; line-height: 1.7; white-space: pre-wrap; }

/* ── フォーム共通 ── */
.form-section {
  margin-bottom: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.form-section h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--primary);
}
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-group { display: flex; flex-direction: column; gap: 5px; flex: 1; min-width: 160px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  background: white;
  transition: border-color .15s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-lt);
  box-shadow: 0 0 0 2px rgba(41,128,185,.15);
}
.section-label { font-size: 12px; font-weight: 600; color: var(--text-muted); display: block; margin-bottom: 6px; }
.ng-flags-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #fff8f8;
  border: 1px solid #f5c6c6;
  border-radius: 6px;
  padding: 12px;
  margin-top: 8px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}
.checkbox-label.danger { color: var(--danger); font-weight: 600; }
.checkbox-label input[type="checkbox"] { width: 15px; height: 15px; cursor: pointer; }
.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 8px;
}
.save-msg { font-size: 13px; color: var(--success); }
.required { color: var(--danger); }

/* ── ボタン ── */
.btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, transform .1s;
}
.btn:hover { opacity: .88; transform: translateY(-1px); }
.btn-primary   { background: var(--primary-lt); color: white; }
.btn-secondary { background: #ecf0f1; color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-edit-small {
  background: none;
  border: 1px solid var(--border);
  border-radius: 5px;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  color: var(--text-muted);
  white-space: nowrap;
}
.btn-edit-small:hover { background: #f0f2f5; }

/* ── モーダル ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal {
  background: white;
  border-radius: 10px;
  width: 520px;
  max-width: 95vw;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  overflow: hidden;
}
.modal-sm { width: 380px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ── 書類ファイルアップロード ── */
.doc-file-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
}
.file-upload-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 10px;
  background: #e8f4fd;
  border: 1.5px solid var(--primary-lt);
  border-radius: 4px;
  cursor: pointer;
  color: var(--primary-lt);
  white-space: nowrap;
  transition: background .15s, color .15s;
}
.file-upload-btn:hover { background: var(--primary-lt); color: white; }
.file-link {
  font-size: 11px;
  color: var(--primary-lt);
  text-decoration: none;
  padding: 3px 9px;
  background: #dce8f5;
  border-radius: 4px;
  white-space: nowrap;
}
.file-link:hover { background: #bee3f8; }
.file-delete-btn {
  background: none;
  border: none;
  color: #bbb;
  cursor: pointer;
  font-size: 13px;
  padding: 2px 5px;
  line-height: 1;
}
.file-delete-btn:hover { color: var(--danger); }
.uploading   { font-size: 11px; color: var(--text-muted); font-style: italic; }
.upload-error { font-size: 11px; color: var(--danger); }

/* ── スクロールバー ── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c0c8d0; border-radius: 3px; }
