/* ============================================================
   チバリヨ - P2 目標設定画面 スタイル
============================================================ */

.p2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.p2-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--color-text);
}
.p2-header-actions {
  display: flex;
  gap: 12px;
}
.p2-header .btn {
  width: auto;
  padding: 8px 16px;
}

.p2-error {
  background: var(--color-danger-bg);
  color: var(--color-danger);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}
.p2-success {
  background: var(--color-success-bg);
  color: var(--color-success);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}

.p2-loading, .p2-empty {
  text-align: center;
  padding: 32px;
  color: var(--color-text-sub);
  font-size: 14px;
}

.p2-content {
  background: #FFFFFF;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 20px 24px;
}

.p2-period-info {
  font-size: 14px;
  color: var(--color-text-sub);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
}
.p2-period-info strong {
  color: var(--color-text);
}

/* ----- マトリクス ----- */
.p2-matrix-wrapper {
  overflow-x: auto;
}

.p2-matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.p2-matrix th,
.p2-matrix td {
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  text-align: center;
  vertical-align: middle;
}

.p2-matrix thead th {
  background: #F7F8FA;
  font-weight: 600;
  font-size: 12px;
  color: var(--color-text-sub);
  letter-spacing: 0.02em;
}

.p2-th-member { text-align: left; width: 140px; }
.p2-th-indicator { width: 60px; }
.p2-th-month { width: 80px; }
.p2-th-total { width: 80px; background: #EEF2F7 !important; }

.p2-td-member {
  text-align: left;
  background: #FAFBFC;
}
.p2-member-name {
  font-weight: 500;
  color: var(--color-text);
}
.p2-member-job {
  font-size: 11px;
  color: var(--color-text-sub);
  margin-top: 2px;
}

.p2-td-indicator {
  font-weight: 500;
  font-size: 12px;
  color: var(--color-text-sub);
  background: #FAFBFC;
}

.p2-row-appointment .p2-td-indicator {
  color: var(--color-primary);
}
.p2-row-quote .p2-td-indicator {
  color: var(--color-success);
}

.p2-td-cell {
  cursor: pointer;
  font-weight: 500;
  color: var(--color-text);
  transition: background 0.15s ease;
}
.p2-td-cell:hover {
  background: var(--color-primary-bg);
}
.p2-td-cell.is-unset {
  color: var(--color-text-muted);
  font-style: italic;
}

.p2-td-total {
  background: #F7F8FA;
  font-weight: 600;
  color: var(--color-text);
}

.p2-hint {
  margin-top: 12px;
  font-size: 12px;
  color: var(--color-text-muted);
}

/* ----- セル編集モーダル ----- */
.p2-edit-info {
  background: #F7F8FA;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 14px;
}
.p2-edit-indicator {
  margin-top: 4px;
  color: var(--color-text-sub);
  font-size: 12px;
}

.p2-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.p2-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.p2-field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text-sub);
}
.p2-required { color: var(--color-danger); }
.p2-field-hint {
  font-size: 11px;
  color: var(--color-text-muted);
}

.p2-form input[type="number"],
.p2-form textarea {
  padding: 9px 11px;
  font-family: inherit;
  font-size: 14px;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  color: var(--color-text);
}
.p2-form input:focus,
.p2-form textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(12, 68, 124, 0.12);
}
.p2-form textarea {
  resize: vertical;
  min-height: 60px;
}

.p2-readonly-value {
  padding: 9px 11px;
  background: #F7F8FA;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--color-text);
  font-weight: 500;
}

.p2-tag-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.p2-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--color-border-strong);
  border-radius: 18px;
  background: #FFFFFF;
  color: var(--color-text-sub);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.p2-tag-chip:hover {
  background: #F2F4F7;
}
.p2-tag-chip input {
  display: none;
}
.p2-tag-chip:has(input:checked) {
  background: var(--color-primary-bg);
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.p2-form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}
.p2-form-actions .btn {
  width: auto;
  padding: 8px 16px;
}

/* ----- 履歴パネル ----- */
.p2-history-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  justify-content: flex-end;
  z-index: 1000;
  animation: p2FadeIn 0.15s ease;
}
@keyframes p2FadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.p2-history-panel {
  width: 100%;
  max-width: 480px;
  background: #FFFFFF;
  height: 100vh;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 24px rgba(15, 23, 42, 0.15);
  animation: p2SlideIn 0.2s ease;
}
@keyframes p2SlideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.p2-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}
.p2-history-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.p2-history-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--color-text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.p2-history-close:hover {
  background: #F2F4F7;
  color: var(--color-text);
}

.p2-history-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.p2-history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.p2-history-item {
  background: #FAFBFC;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
  line-height: 1.6;
}
.p2-history-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--color-text-muted);
}
.p2-history-type {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 10px;
}
.p2-history-type-initial {
  background: var(--color-success-bg);
  color: var(--color-success);
}
.p2-history-type-update {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}
.p2-history-main {
  color: var(--color-text);
  margin-bottom: 4px;
}
.p2-history-values {
  font-size: 14px;
  color: var(--color-text);
  margin-bottom: 6px;
  font-family: monospace;
}
.p2-history-values strong {
  color: var(--color-primary);
}
.p2-history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}
.p2-history-tag {
  background: #EEF2F7;
  color: var(--color-text-sub);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
}
.p2-history-reason {
  color: var(--color-text-sub);
  font-size: 12px;
  white-space: pre-wrap;
}
