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

:root {
  --primary: #1D4ED8;
  --primary-light: #DBEAFE;
  --primary-hover: #1E40AF;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-500: #64748B;
  --gray-700: #334155;
  --gray-900: #0F172A;
  --red: #DC2626;
  --red-light: #FEE2E2;
  --green: #16A34A;
  --green-light: #DCFCE7;
  --amber: #D97706;
  --amber-light: #FEF3C7;
  --purple: #7C3AED;
  --purple-light: #EDE9FE;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
}

body {
  font-family: 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  font-size: 14px;
  line-height: 1.6;
}

/* ========== ログイン ========== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1D4ED8 0%, #1E3A8A 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 380px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  background: var(--primary-light);
  border-radius: 14px;
  font-size: 24px;
  margin-bottom: 12px;
}

.login-logo h1 { font-size: 18px; font-weight: 700; color: var(--gray-900); }
.login-logo p { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* ========== ヘッダー ========== */
.header {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  color: var(--primary);
}

.header-brand .badge {
  background: var(--primary-light);
  color: var(--primary);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info {
  font-size: 13px;
  color: var(--gray-700);
}

/* ========== レイアウト ========== */
.container { max-width: 1100px; margin: 0 auto; padding: 24px 24px; }
.container-sm { max-width: 760px; margin: 0 auto; padding: 24px 24px; }

/* ========== フォーム ========== */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-label .required { color: var(--red); margin-left: 3px; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--gray-900);
  background: white;
  transition: border-color .15s;
  outline: none;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}

.form-textarea { resize: vertical; min-height: 90px; }

.form-file-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed var(--gray-300);
  border-radius: 8px;
  cursor: pointer;
  color: var(--gray-500);
  transition: border-color .15s, background .15s;
}

.form-file-label:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary); }
.form-file-input { display: none; }
.form-file-name { font-size: 13px; color: var(--gray-700); margin-top: 6px; }

/* ========== ボタン ========== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: all .15s;
  text-decoration: none;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--green); color: white; }
.btn-success:hover { background: #15803D; }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { background: #B91C1C; }
.btn-ghost { background: transparent; color: var(--gray-500); }
.btn-ghost:hover { background: var(--gray-100); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ========== カード ========== */
.card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 700; color: var(--gray-900); }
.card-body { padding: 20px; }

/* ========== ステータスバッジ ========== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-status::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.status-申請済み { background: var(--primary-light); color: var(--primary); }
.status-申請済み::before { background: var(--primary); }
.status-受領済み { background: var(--amber-light); color: var(--amber); }
.status-受領済み::before { background: var(--amber); }
.status-アップロード済み { background: var(--purple-light); color: var(--purple); }
.status-アップロード済み::before { background: var(--purple); }
.status-規程一覧更新済み { background: var(--green-light); color: var(--green); }
.status-規程一覧更新済み::before { background: var(--green); }

/* ========== テーブル ========== */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }
th {
  background: var(--gray-50);
  padding: 10px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  font-size: 13px;
}
tr:hover td { background: var(--gray-50); }
tr:last-child td { border-bottom: none; }

.clickable { cursor: pointer; }
.clickable:hover td { background: #EFF6FF; }

/* ========== 統計カード ========== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.stat-label { font-size: 12px; font-weight: 600; color: var(--gray-500); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--gray-900); }
.stat-value.blue { color: var(--primary); }
.stat-value.amber { color: var(--amber); }
.stat-value.purple { color: var(--purple); }
.stat-value.green { color: var(--green); }

/* ========== ステップバー ========== */
.step-bar {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
}

.step-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 16px;
  left: 50%;
  width: 100%;
  height: 2px;
  background: var(--gray-200);
  z-index: 0;
}

.step-item.done:not(:last-child)::after { background: var(--primary); }

.step-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--gray-200);
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-300);
  z-index: 1;
  position: relative;
}

.step-item.done .step-circle {
  border-color: var(--primary);
  background: var(--primary);
  color: white;
}

.step-item.current .step-circle {
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
}

.step-label {
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 6px;
  text-align: center;
  white-space: nowrap;
}

.step-item.done .step-label, .step-item.current .step-label {
  color: var(--primary);
  font-weight: 600;
}

.step-date {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 2px;
  text-align: center;
}

/* ========== モーダル ========== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: white;
  border-radius: 14px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 50px rgba(0,0,0,.25);
}

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--gray-500); font-size: 20px; line-height: 1; padding: 4px; }
.modal-close:hover { color: var(--gray-900); }
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ========== 詳細情報 ========== */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.detail-item label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 4px;
}

.detail-item .value {
  font-size: 14px;
  color: var(--gray-900);
  font-weight: 500;
}

.detail-desc {
  background: var(--gray-50);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--gray-700);
  margin-bottom: 16px;
  white-space: pre-wrap;
}

/* ========== ログ ========== */
.log-list { display: flex; flex-direction: column; gap: 8px; }

.log-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.log-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  margin-top: 5px;
  flex-shrink: 0;
}

.log-content { flex: 1; }
.log-status { font-size: 13px; font-weight: 600; color: var(--gray-900); }
.log-meta { font-size: 11px; color: var(--gray-500); margin-top: 1px; }
.log-comment { font-size: 12px; color: var(--gray-600); margin-top: 3px; background: var(--gray-50); padding: 4px 8px; border-radius: 6px; }

/* ========== フィルターバー ========== */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.filter-bar .form-input, .filter-bar .form-select { width: auto; }

/* ========== アラート ========== */
.alert {
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-error { background: var(--red-light); color: var(--red); border: 1px solid #FECACA; }
.alert-success { background: var(--green-light); color: var(--green); border: 1px solid #BBF7D0; }
.alert-info { background: var(--primary-light); color: var(--primary); border: 1px solid #BFDBFE; }

/* ========== 空状態 ========== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-500);
}

.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ========== タブ ========== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 20px;
}

.tab-btn {
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-500);
  background: none;
  border: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s;
}

.tab-btn:hover { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ========== ページタイトル ========== */
.page-title { font-size: 20px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: var(--gray-500); margin-bottom: 24px; }

/* ========== 区切り ========== */
.divider { border: none; border-top: 1px solid var(--gray-200); margin: 20px 0; }

/* ========== ローディング ========== */
.loading { text-align: center; padding: 40px; color: var(--gray-500); font-size: 13px; }

@media (max-width: 640px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
}
