/* =============================================
   不動産管理システム - カスタムスタイル
   ============================================= */

:root {
  --primary: #1e3a5f;
  --primary-light: #2d5a8e;
  --primary-pale: #e8f0fb;
  --accent: #c8a96e;
  --accent-light: #f5edd8;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --gray-bg: #f7f8fc;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Hiragino Kaku Gothic Pro', 'Yu Gothic', 'Meiryo', sans-serif; background: var(--gray-bg); color: #1a202c; }

/* ---- サイドバー ---- */
#sidebar {
  position: fixed; top: 0; left: 0; width: var(--sidebar-w);
  height: 100vh; background: var(--primary); z-index: 100;
  display: flex; flex-direction: column; overflow-y: auto;
}
#sidebar .logo {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
#sidebar .logo h1 { color: #fff; font-size: 13px; font-weight: 700; line-height: 1.4; }
#sidebar .logo .sub { color: var(--accent); font-size: 10px; margin-top: 2px; }

#sidebar nav { padding: 8px 0; flex: 1; }
#sidebar nav .nav-section { color: rgba(255,255,255,0.4); font-size: 10px; font-weight: 700; letter-spacing: 0.08em; padding: 16px 16px 4px; text-transform: uppercase; }
#sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 16px; color: rgba(255,255,255,0.75); font-size: 13px;
  text-decoration: none; cursor: pointer; transition: all 0.15s;
  border-left: 3px solid transparent;
}
#sidebar nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
#sidebar nav a.active { background: rgba(200,169,110,0.18); color: var(--accent); border-left-color: var(--accent); }
#sidebar nav a i { width: 16px; text-align: center; font-size: 13px; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  background: #f43f5e; color: #fff; border-radius: 10px;
  font-size: 10px; font-weight: 800; line-height: 18px; text-align: center;
}

/* ---- メインコンテンツ ---- */
#main-content { margin-left: var(--sidebar-w); min-height: 100vh; }

/* ---- トップバー ---- */
#topbar {
  position: sticky; top: 0; background: #fff;
  border-bottom: 1px solid #e5e7eb; padding: 0 24px;
  height: 56px; display: flex; align-items: center; justify-content: space-between;
  z-index: 50; box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
#topbar .page-title { font-size: 17px; font-weight: 700; color: var(--primary); }
#topbar .topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ---- ページコンテナ ---- */
.page-container { padding: 24px; max-width: 1400px; }

/* ---- カード ---- */
.card {
  background: #fff; border-radius: 10px; border: 1px solid #e5e7eb;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.card-header {
  padding: 14px 18px; border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 14px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 8px; }
.card-body { padding: 18px; }

/* ---- 統計カード ---- */
.stat-card {
  background: #fff; border-radius: 10px; border: 1px solid #e5e7eb;
  padding: 18px; display: flex; flex-direction: column; gap: 6px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}
.stat-card .stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; margin-bottom: 4px; }
.stat-card .stat-value { font-size: 28px; font-weight: 800; color: var(--primary); line-height: 1; }
.stat-card .stat-label { font-size: 12px; color: #6b7280; }
.stat-card .stat-sub { font-size: 11px; color: #9ca3af; }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: 6px; font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all 0.15s;
  border: none; text-decoration: none; line-height: 1;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #b8955a; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid #d1d5db; }
.btn-outline:hover { background: #f3f4f6; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; border-radius: 4px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

/* ---- バッジ ---- */
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef3c7; color: #b45309; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-gray   { background: #f3f4f6; color: #6b7280; }
.badge-purple { background: #ede9fe; color: #7c3aed; }
.badge-orange { background: #ffedd5; color: #c2410c; }

/* ---- 工程管理バッジ（申込詳細 行程管理） ---- */
.step-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
  border: 1.5px solid #d1d5db;
  background: #ffffff; color: #6b7280;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s, box-shadow 0.15s;
  user-select: none;
}
.step-badge:hover {
  border-color: #9ca3af; background: #f9fafb;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.step-badge.done {
  background: #16a34a; color: #ffffff;
  border-color: #15803d;
  box-shadow: 0 1px 4px rgba(22,163,74,0.25);
}
.step-badge.done:hover {
  background: #15803d; border-color: #166534;
}
.step-badge.pending { /* 未完了はデフォルトのまま */ }
.step-badge[disabled], .step-badge.cursor-default {
  cursor: default; pointer-events: none; opacity: 0.75;
}

/* ---- テーブル ---- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th {
  background: #f9fafb; padding: 10px 12px;
  text-align: left; font-weight: 600; color: #6b7280;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.04em;
  border-bottom: 1px solid #e5e7eb; white-space: nowrap;
}
.data-table td { padding: 11px 12px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafbff; }
.data-table .clickable { cursor: pointer; }

/* ---- フォーム ---- */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: #374151; }
.form-label .required { color: var(--danger); margin-left: 2px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 8px 12px; border: 1px solid #d1d5db;
  border-radius: 6px; font-size: 13px; color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s;
  font-family: inherit;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(45,90,142,0.12);
}
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 11px; color: #9ca3af; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
.form-section-title {
  font-size: 13px; font-weight: 700; color: var(--primary);
  padding: 12px 0 8px; border-bottom: 2px solid var(--primary-pale);
  margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}

/* ---- アコーディオン（更新工程） ---- */
.process-item {
  border: 1px solid #e5e7eb; border-radius: 8px; overflow: hidden;
  transition: all 0.2s;
}
.process-item.completed { border-color: #86efac; background: #f0fdf4; }
.process-item.skipped   { border-color: #e5e7eb; background: #fafafa; opacity: 0.6; }
.process-item.active    { border-color: var(--primary-light); box-shadow: 0 0 0 2px rgba(45,90,142,0.12); }

.process-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; cursor: pointer; transition: background 0.15s;
}
.process-header:hover { background: rgba(0,0,0,0.02); }

.process-number {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; flex-shrink: 0;
  background: #e5e7eb; color: #6b7280;
}
.completed .process-number { background: var(--success); color: #fff; }
.active .process-number    { background: var(--primary); color: #fff; }

.process-title { flex: 1; font-size: 13px; font-weight: 600; color: #374151; }
.completed .process-title { color: var(--success); }

.process-meta { display: flex; gap: 8px; align-items: center; font-size: 11px; color: #9ca3af; }
.process-body {
  padding: 0 16px 16px; border-top: 1px solid #f0f0f0;
  background: #fafbff;
}
.process-body.hidden { display: none; }

/* ---- ガントチャート風バー ---- */
.gantt-bar {
  height: 24px; border-radius: 4px; background: var(--primary);
  display: flex; align-items: center; padding: 0 8px;
  color: #fff; font-size: 11px; font-weight: 600;
  cursor: pointer; transition: opacity 0.15s; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}
.gantt-bar:hover { opacity: 0.85; }
.gantt-bar.completed { background: #86efac; color: #15803d; }
.gantt-bar.overdue   { background: #fca5a5; color: #991b1b; }

/* ---- カレンダー ---- */
.calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: #e5e7eb; border-radius: 8px; overflow: hidden; }
.calendar-day {
  background: #fff; min-height: 90px; padding: 6px;
  display: flex; flex-direction: column; gap: 3px;
}
.calendar-day.other-month { background: #fafafa; }
.calendar-day.today { background: #fffbeb; }
.calendar-day .day-number { font-size: 12px; font-weight: 600; color: #374151; }
.calendar-day.today .day-number { color: var(--primary); font-weight: 800; }
.calendar-day .day-event {
  font-size: 10px; background: var(--primary-pale); color: var(--primary);
  padding: 2px 5px; border-radius: 3px; truncate; overflow: hidden;
  white-space: nowrap; text-overflow: ellipsis; cursor: pointer;
}
.calendar-day .day-event:hover { background: var(--primary); color: #fff; }
.calendar-day .day-event.done { background: #dcfce7; color: #15803d; text-decoration: line-through; }

/* ---- プログレスバー ---- */
.progress-bar { background: #e5e7eb; border-radius: 999px; height: 8px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 999px; background: var(--primary); transition: width 0.4s; }
.progress-fill.complete { background: var(--success); }

/* ---- モーダル ---- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: flex-start; justify-content: center;
  z-index: 200; padding: 40px 16px; overflow-y: auto;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  background: #fff; border-radius: 12px; width: 100%;
  max-width: 700px; box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  animation: modalIn 0.2s ease;
}
.modal-box.modal-lg { max-width: 900px; }
@keyframes modalIn { from { opacity:0; transform:translateY(-20px); } to { opacity:1; transform:translateY(0); } }
.modal-header {
  padding: 18px 20px; border-bottom: 1px solid #f0f0f0;
  display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; cursor: pointer; color: #9ca3af; font-size: 18px; padding: 4px; }
.modal-close:hover { color: #374151; }
.modal-body { padding: 20px; }
.modal-footer { padding: 14px 20px; border-top: 1px solid #f0f0f0; display: flex; justify-content: flex-end; gap: 8px; }

/* ---- トースト通知 ---- */
#toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; padding: 12px 18px;
  border-radius: 8px; font-size: 13px; box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  display: flex; align-items: center; gap: 10px; min-width: 260px;
  animation: toastIn 0.25s ease;
}
.toast.success { background: #15803d; }
.toast.error   { background: #dc2626; }
.toast.warning { background: #d97706; }
@keyframes toastIn { from { opacity:0; transform:translateX(40px); } to { opacity:1; transform:translateX(0); } }

/* ---- ステータスドット ---- */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; }
.dot-green  { background: #22c55e; }
.dot-red    { background: #ef4444; }
.dot-yellow { background: #f59e0b; }
.dot-gray   { background: #d1d5db; }
.dot-blue   { background: #3b82f6; }
.dot-orange { background: #f97316; }

/* ---- ヘッドパネル（更新案件詳細） ---- */
.head-panel {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border-radius: 10px; padding: 20px; color: #fff; margin-bottom: 20px;
}
.head-panel .panel-label { font-size: 11px; color: rgba(255,255,255,0.65); margin-bottom: 2px; }
.head-panel .panel-value { font-size: 14px; font-weight: 700; }
.head-panel .panel-sub { font-size: 12px; color: rgba(255,255,255,0.8); }
.head-panel a { color: var(--accent); text-decoration: none; }
.head-panel a:hover { text-decoration: underline; }

/* ---- タブ ---- */
.tab-bar { display: flex; border-bottom: 2px solid #e5e7eb; gap: 0; }
.tab-btn {
  padding: 10px 20px; font-size: 13px; font-weight: 600; cursor: pointer;
  border: none; background: none; color: #6b7280;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-btn:hover  { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ---- スクロールバー ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---- ローダー ---- */
.loader { display: flex; align-items: center; justify-content: center; padding: 60px; }
.spinner { width: 32px; height: 32px; border: 3px solid #e5e7eb; border-top-color: var(--primary); border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 空室管理タブ ---- */
.vacant-tab { padding: 6px 16px; border-radius: 999px; font-size: 12px; font-weight: 600; cursor: pointer; border: 1px solid #e5e7eb; background: #fff; transition: all 0.15s; }
.vacant-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- AI パネル ---- */
.ai-panel { background: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%); border-radius: 10px; padding: 16px; color: #fff; }
.ai-panel .ai-title { font-size: 13px; font-weight: 700; color: #a5b4fc; display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }

/* ---- 条件変更バナー ---- */
.change-banner { background: var(--accent-light); border: 1px solid var(--accent); border-radius: 8px; padding: 14px 18px; display: flex; align-items: center; gap: 10px; }
.change-banner i { color: var(--accent); font-size: 18px; }

/* ---- レスポンシブ（簡易） ---- */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #main-content { margin-left: 0; }
  .form-row-2, .form-row-3, .form-row-4 { grid-template-columns: 1fr; }
}

/* ---- 金額フィールド ---- */
[data-money] {
  text-align: right;
  letter-spacing: 0.03em;
  font-variant-numeric: tabular-nums;
  padding-right: 10px;
}
[data-money]:focus {
  background: #fffbeb;
}
/* 入力欄の左側に「¥」を重ねる */
.money-wrap {
  position: relative;
}
.money-wrap::before {
  content: '¥';
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}
.money-wrap [data-money] {
  padding-left: 22px;
}

/* ---- ユーティリティ ---- */
.text-primary { color: var(--primary); }
.text-accent  { color: var(--accent); }
.text-muted   { color: #9ca3af; }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.font-bold    { font-weight: 700; }
.font-medium  { font-weight: 500; }
.truncate     { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.divider      { border: none; border-top: 1px solid #e5e7eb; margin: 16px 0; }
.empty-state  { text-align: center; padding: 48px 24px; color: #9ca3af; }
.empty-state i { font-size: 40px; margin-bottom: 12px; display: block; }
.empty-state p { font-size: 14px; }
