* { box-sizing: border-box; }

body {
  font-family: "Noto Sans CJK JP", -apple-system, sans-serif;
  margin: 0;
  background: #f7f7f8;
  color: #222;
}

.site-header {
  background: #2c3e50;
  color: #fff;
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.site-header h1 { font-size: 18px; margin: 0; }

.site-header nav a {
  color: #fff;
  margin-left: 16px;
  text-decoration: none;
  font-size: 14px;
}

.site-header nav a:hover { text-decoration: underline; }

/* --- ログイン中ユーザー・ログアウト --- */
.site-header { flex-wrap: wrap; gap: 8px 0; }
.site-header nav { margin-left: auto; }

.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: 20px;
  padding-left: 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 13px;
}

.header-user form { margin: 0; }

.logout-button {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
}

.logout-button:hover { background: rgba(255, 255, 255, 0.12); }

/* --- ログイン画面 --- */
.login-main { max-width: 380px; margin-top: 64px; }
.login-card h2 { font-size: 17px; margin-bottom: 14px; }
.login-card label { display: block; font-size: 13px; color: #555; margin: 10px 0 4px; }
.login-card input[type="text"],
.login-card input[type="password"] {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 14px;
}
.login-submit {
  width: 100%;
  margin-top: 18px;
  padding: 9px;
  background: #2c3e50;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  cursor: pointer;
}
.login-submit:hover { background: #3d566e; }
.login-message { font-size: 13px; padding: 8px 10px; border-radius: 4px; margin: 0 0 6px; }
.login-error { background: #fdecea; color: #a12a1c; border: 1px solid #f3c2bb; }
.login-info  { background: #e9f5ec; color: #1e6b34; border: 1px solid #bfe1c8; }

@media (max-width: 640px) {
  .site-header nav { margin-left: 0; width: 100%; }
  .site-header nav a { margin: 0 16px 0 0; }
  .header-user { margin-left: 0; padding-left: 0; border-left: none; width: 100%; justify-content: space-between; }
}

main { max-width: 900px; margin: 24px auto; padding: 0 16px; }

.card {
  background: #fff;
  border-radius: 8px;
  padding: 16px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h2 { margin-top: 0; margin-bottom: 10px; font-size: 15px; }

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 10px;
}

/* --- 基本情報：氏名・フリガナ・生年月日・性別・住所・最寄り駅は表形式 --- */
.kihon-fields-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  margin-bottom: 10px;
}

.kihon-fields-table th {
  width: 13%;
  text-align: left;
  padding: 3px 10px 3px 0;
  vertical-align: middle;
}

.kihon-fields-table th label {
  font-size: 12px;
  color: #555;
  font-weight: 600;
}

.kihon-fields-table td {
  width: 20.3%;
  padding: 3px 14px 3px 0;
  vertical-align: middle;
}

.kihon-fields-table input,
.kihon-fields-table select {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1.3;
}

.field-block { margin-bottom: 10px; }

.field-block label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 2px;
}

.field-block textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1.35;
  overflow: hidden;
}

.field-block-collapsible { margin-bottom: 10px; }

.field-block-collapsible label {
  display: block;
  font-size: 12px;
  color: #555;
  margin-bottom: 2px;
  cursor: pointer;
}

.field-block-collapsible textarea {
  width: 100%;
  box-sizing: border-box;
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1.35;
  overflow: hidden;
}

.field-block-collapsible[data-empty="true"] label::after {
  content: "（クリックして入力）";
  font-size: 11px;
  color: #999;
  margin-left: 6px;
  font-weight: 400;
}

.field-block-collapsible[data-empty="true"] textarea { display: none; }

@media (max-width: 640px) {
  .kihon-fields-table, .kihon-fields-table tbody, .kihon-fields-table tr, .kihon-fields-table th, .kihon-fields-table td {
    display: block;
    width: 100%;
  }
  .kihon-fields-table th { padding: 8px 0 2px; }
  .kihon-fields-table td { padding: 0 0 8px; }
}

.form-grid label {
  display: flex;
  flex-direction: column;
  font-size: 12px;
  color: #555;
  gap: 2px;
}

.form-grid .full { grid-column: 1 / -1; }

.form-grid input,
.form-grid select,
.form-grid textarea {
  font-size: 13px;
  padding: 4px 6px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-family: inherit;
  line-height: 1.35;
}

.form-grid fieldset {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 5px 10px;
}

.form-grid fieldset legend { font-size: 11px; color: #666; padding: 0 4px; }

.checkbox {
  flex-direction: row !important;
  display: inline-flex !important;
  align-items: center;
  gap: 4px !important;
  font-size: 12px;
  margin-right: 10px;
}

.form-grid .actions { grid-column: 1 / -1; }

button {
  cursor: pointer;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  background: #2c3e50;
  color: #fff;
  font-size: 13px;
}

button.danger { background: #c0392b; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.inline-form { display: inline-block; margin-right: 6px; margin-top: 4px; }

.anken-item {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

.anken-item summary { cursor: pointer; font-weight: 600; }
.anken-item.new summary { color: #2c3e50; }
.anken-item summary { display: flex; align-items: center; gap: 10px; }
.anken-summary-text { flex: 1; }

/* PDF出力「表示しない」の案件 */
.pdf-hidden-badge {
  display: none;
  font-size: 11px;
  font-weight: 500;
  color: #fff;
  background: #95a5a6;
  border-radius: 3px;
  padding: 1px 6px;
}
.anken-item.is-pdf-hidden { background: #f4f4f4; border-style: dashed; }
.anken-item.is-pdf-hidden .anken-summary-text { color: #888; }
.anken-item.is-pdf-hidden .pdf-hidden-badge { display: inline-block; }
.hidden-anken-note { font-size: 12px; color: #666; margin: 4px 0; }

.anken-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}

.anken-actions-move { display: flex; gap: 6px; }

.anken-actions .inline-form { margin: 0; }

/* --- 自動保存の状態表示 --- */
.save-status {
  font-size: 12px;
  font-weight: 500;
  color: #999;
}
.save-status.is-pending { color: #b8860b; }
.save-status.is-saving { color: #777; }
.save-status.is-saved { color: #2e7d32; }
.save-status.is-error { color: #c0392b; font-weight: 700; }

h2 .save-status { margin-left: 8px; font-weight: 500; }

/* --- レイアウト切替バー（プレビュー画面のみ） --- */
.layout-switcher {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.layout-tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  overflow-x: auto;
  background: #e6e9ec;
  padding: 4px;
  border-radius: 10px;
}

.layout-tab {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 9px 16px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: #5a6570;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.layout-tab:hover { background: rgba(255, 255, 255, 0.6); color: #2c3e50; }

.layout-tab.active {
  background: #fff;
  color: #2c3e50;
  box-shadow: 0 1px 3px rgba(20, 30, 40, 0.18), 0 1px 2px rgba(20, 30, 40, 0.08);
}

.layout-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn-mask {
  flex: 0 0 auto;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid #d5d8dc;
  background: #fff;
  color: #5a6570;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.btn-mask:hover { border-color: #2c3e50; color: #2c3e50; }

.btn-mask.active {
  background: #2c3e50;
  border-color: #2c3e50;
  color: #fff;
}

.mask-note {
  font-size: 12px;
  color: #93690a;
  background: #fdf1d6;
  border-radius: 6px;
  padding: 6px 10px;
  margin: 0 0 12px;
}

.btn-pdf {
  flex: 0 0 auto;
  padding: 10px 22px;
  border-radius: 8px;
  background: linear-gradient(180deg, #d64a3c, #c0392b);
  color: #fff;
  text-decoration: none;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(192, 57, 43, 0.35);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.btn-pdf:hover {
  box-shadow: 0 4px 10px rgba(192, 57, 43, 0.45);
  transform: translateY(-1px);
}

.btn-pdf:active {
  box-shadow: 0 1px 3px rgba(192, 57, 43, 0.35);
  transform: translateY(0);
}

.layout-desc {
  font-size: 12px;
  color: #777;
  margin-bottom: 16px;
}

.preview-stage {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

@media print {
  .site-header, .layout-switcher, .layout-desc { display: none; }
  .preview-stage { box-shadow: none; padding: 0; }
}

/* ===== 期間チェック（/timeline） ===== */
body.page-wide main { max-width: 1100px; }

.timeline-note { font-size: 13px; color: #666; margin-top: 0; }

.timeline-ok { color: #1e7e34; font-size: 13px; }

.badge {
  display: inline-block;
  font-size: 11px;
  border-radius: 3px;
  padding: 1px 7px;
  margin: 0 4px 4px 0;
}
.badge-error { background: #fbe4e4; color: #a83232; }
.badge-warning { background: #fdf1d6; color: #93690a; }
.badge-info { background: #dceefb; color: #1c5a86; }

.timeline-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.timeline-table th,
.timeline-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #eee;
  text-align: left;
  vertical-align: top;
}
.timeline-table th { color: #555; font-weight: 700; }
.timeline-table tfoot td { font-weight: 700; border-top: 2px solid #ddd; border-bottom: none; }
.timeline-table tr.row-error { background: #fdf3f3; }
.timeline-table tr.row-warning { background: #fdf9ee; }
.timeline-notes { display: flex; flex-wrap: wrap; }

/* 横線グラフ（簡易ガントチャート） */
.gantt-wrapper { overflow-x: auto; margin-bottom: 18px; }
.gantt { min-width: 600px; }

.gantt-row {
  display: flex;
  align-items: center;
  min-height: 26px;
}
.gantt-label {
  flex: 0 0 160px;
  font-size: 12px;
  color: #444;
  padding-right: 10px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.gantt-track {
  flex: 1;
  position: relative;
  height: 16px;
  background: #f1f2f4;
  border-radius: 3px;
}
.gantt-period {
  flex: 0 0 170px;
  font-size: 12px;
  color: #666;
  padding-left: 10px;
}

.gantt-axis-row { min-height: 18px; }
.gantt-axis-track { background: none; height: 14px; }
.gantt-tick {
  position: absolute;
  top: 0;
  border-left: 1px solid #ddd;
  height: 100%;
}
.gantt-tick-label {
  position: absolute;
  top: -14px;
  left: 2px;
  font-size: 10px;
  color: #999;
}
.gantt-gridline {
  position: absolute;
  top: 0;
  bottom: 0;
  border-left: 1px solid #eee;
}

.gantt-bar {
  position: absolute;
  top: 2px;
  height: 12px;
  border-radius: 3px;
  background: #2c3e50;
}
.gantt-bar-ongoing { background: #1c6fa8; }
.gantt-bar-warning { background: #d9a441; }
.gantt-bar-error { background: #c0392b; }
