body{font-family:Arial,"Hiragino Kaku Gothic ProN","Yu Gothic",Meiryo,sans-serif;margin:20px;color:#222;background:#fff}
.container{max-width:1280px;margin:0 auto}
.header{display:flex;justify-content:space-between;align-items:flex-start;gap:16px;margin-bottom:16px}
.header-left h1{margin:0 0 6px;font-size:24px}
.header-left p{margin:0;color:#666;font-size:14px}
.header-right{display:flex;flex-direction:column;gap:10px}
.switch-box{border:1px solid #ccc;padding:8px 10px;background:#fff}
.switch-box legend{font-size:12px;padding:0 4px}
.switch-box label{font-size:13px;margin-right:10px;white-space:nowrap}
#pageTitle {
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.25;
  margin: 0;
}
.header h1 {
  margin: 0;
}

.section{margin-bottom:20px;border:1px solid #ccc;padding:14px;background:#fafafa}
.block-title{margin:0 0 12px;font-size:18px}
.label{font-size:12px;margin-bottom:4px}
.row{display:flex;gap:10px;flex-wrap:wrap;align-items:flex-end}
.col{display:flex;flex-direction:column}
.stack{display:flex;flex-direction:column;gap:10px}

.small{width:120px}
.medium{width:170px}
.large{width:240px}
.xlarge{width:320px}
.w-full{width:100%}
.flex-1-280{flex:1 1 280px}

.hidden{display:none !important}
.disabled{background:#eee !important;color:#888 !important}
.no-margin{margin:0}
.mt-8{margin-top:8px}
.mt-10{margin-top:10px}
.mt-12{margin-top:12px}
.align-end{align-items:flex-end}
.help-note{max-width:520px;margin-top:6px}

.main-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px;align-items:start}

input,select,button{padding:6px;font-size:14px;border:1px solid #bbb;background:#fff;box-sizing:border-box}
button{cursor:pointer}
button[disabled]{cursor:not-allowed;opacity:1;background:#eee;color:#888}

.btn-sm{padding:6px 12px;font-size:13px;display:inline-flex;align-items:center;justify-content:center}

.primary-btn{background:#222;color:#fff;border-color:#222}
.secondary-btn{background:#fff;border:1px solid #bbb}
.sub-btn{background:#f6f6f6}
.warning-btn{background:#fff;border:1px solid #d33;color:#d33}

.mode-badge{display:inline-block;padding:4px 8px;border:1px solid #ccc;background:#fff;font-size:12px;line-height:1.2}
.history-tools{display:flex;justify-content:space-between;align-items:center;gap:10px;flex-wrap:nowrap;margin-bottom:10px}
.history-tools .block-title{margin:0}
.history-tools .mode-badge,
.history-tools .inline-note{margin-left:auto;flex:0 0 auto}

.gender-inline{display:flex;align-items:center;gap:14px;min-height:32px}
.gender-inline label{display:inline-flex;align-items:center;gap:6px;white-space:nowrap;margin:0}

#apbIdInput{height:32px}
#inputDate{height:32px}
#bodyweight{width:110px;height:32px}
#sportSelect,#otherInput,#disciplineSelect,#positionSelect,#competitionLevelSelect{height:38px}
#loadHistoryBtn,#repairBtn,#repairConfirmBtn{min-height:32px}

.action-row{margin-top:12px}
.toolbar-vertical{display:flex;flex-direction:column;gap:10px;align-items:flex-start}
.result-action-row{display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-top:12px}
.result-action-row .primary-btn,.result-action-row .warning-btn{min-width:88px}
.result-action-row button{flex:1 1 0}

#inputTable,#resultTable,#historyTable{width:100%;border-collapse:collapse;background:#fff}
#inputTable th,#inputTable td,#resultTable th,#resultTable td,#historyTable th,#historyTable td{border:1px solid #ccc;padding:8px 10px;text-align:center;vertical-align:middle}
#inputTable th:first-child,#inputTable td:first-child,#resultTable th:first-child,#resultTable td:first-child,#historyTable th:first-child,#historyTable td:first-child{text-align:left}
#inputTable th:nth-child(1),#inputTable td:nth-child(1){width:18%}
#inputTable th:nth-child(2),#inputTable td:nth-child(2){width:22%}
#inputTable th:nth-child(3),#inputTable td:nth-child(3){width:30%}
#inputTable th:nth-child(4),#inputTable td:nth-child(4){width:14%}
.weight-input{width:72%}
.reps-input{width:94%}

.result-box{padding:10px;border:1px solid #ccc;background:#fff;font-size:24px;font-weight:700;letter-spacing:0.06em}
.muted-box{padding:8px 10px;border:1px solid #ddd;background:#fff;color:#666}
.status-note{margin-top:10px;color:#666;font-size:13px}
.inline-note{font-size:12px;color:#666}

.save-result-wrap{margin-top:12px;border:1px solid #ddd;background:#fff;padding:10px}
.save-result-item{display:grid;grid-template-columns:120px 1fr;gap:10px;padding:4px 0}
.save-result-item .k{color:#666;font-size:13px}
.save-result-item .v{font-weight:600;word-break:break-all}

.history-empty{padding:16px;border:1px dashed #ccc;background:#fff;color:#666}
.result-flash{animation:flash 0.9s ease}
@keyframes flash{0%{background:#fff8d8}100%{background:#fff}}

.input-error{border:1px solid #c33 !important;background:#fff5f5 !important}
.gender-error-label{display:inline-block;padding:2px 4px;border:1px solid #c33;background:#fff5f5;border-radius:3px}
.locked-row input:disabled,.locked-row select:disabled{background:#eee;color:#888}
.np-row td{background:#f2f2f2;color:#777}
.np-row input[type="number"],.np-row input[type="text"]{background:#eee;color:#888}

.repair-panel{border:1px solid #cfcfcf;background:#f7f7f7;padding:12px 14px;border-radius:4px}
.repair-message{padding:8px 10px;border:1px solid #d6d6d6;background:#fcfcfc;color:#666;font-size:13px;min-width:280px}

/* FIXED HISTORY TABLE */
#historyTable{
  table-layout:auto;
  min-width:820px;
}

#historyTable th,
#historyTable td{
  font-size:13px;
  padding:10px 12px;
  white-space:nowrap;
}

#historyTable th{
  font-weight:600;
}

/* Keep key columns wide enough on mobile */
#historyDateHeader,
#historyIndexHeader,
#historyBwHeader{
  white-space:nowrap;
}

#historyDateHeader{width:120px; min-width:120px;}
#historyIndexHeader{width:110px; min-width:110px;}
#historyBwHeader{width:90px; min-width:90px;}

#historyTable tbody td:nth-child(1){min-width:120px;}
#historyTable tbody td:nth-child(2){min-width:110px;}
#historyTable tbody td:nth-child(3){min-width:90px;}

#historyTable thead th{position:sticky;top:0;background:#fff;z-index:1}
#historyTable thead tr:nth-child(2) th{text-align:center !important}
.history-scroll{overflow-x:auto}
.lock-target.unlockable{transition:background .15s ease,color .15s ease,border-color .15s ease}

/* 日付ロック表示 */
input[type="date"]:disabled{background-color:#eee !important;color:#888 !important}
input[type="date"]:disabled::-webkit-calendar-picker-indicator{opacity:0.3}

@media (max-width:900px){
  .header{flex-direction:column}
  .main-grid{grid-template-columns:1fr}
  .save-result-item{grid-template-columns:100px 1fr}
  .history-tools{flex-wrap:wrap}
  .history-tools .mode-badge,
  .history-tools .inline-note{margin-left:0}
}

.input-note{margin-top:8px;font-size:12px;color:#666;line-height:1.4}


.note{margin-top:10px;color:#666;font-size:13px;line-height:1.5}

.consent-block{
  margin-top:14px;
  padding:10px 12px;
  border:1px solid #ddd;
  background:#fff;
}
.consent-label{
  display:flex;
  align-items:flex-start;
  gap:8px;
  margin:0;
  font-weight:600;
  line-height:1.5;
}
.consent-label input[type="checkbox"]{
  margin:2px 0 0;
  flex:0 0 auto;
}
.consent-label span{
  display:block;
}
.consent-note{
  margin-top:6px;
  margin-left:24px;
  color:#666;
  font-size:13px;
  line-height:1.5;
}
#consentStateNote{
  margin-top:8px;
  margin-left:24px;
}
#editLimitNote{
  margin-top:8px;
  line-height:1.5;
}

body.repair-no-data #calcBtn,
body.repair-no-data #saveBtn,
body.repair-no-data #consentCheck{
  pointer-events:none;
}

.calc-btn{
    background:#2563eb;
    color:#fff;
    font-weight:600;
}

.calc-btn.attention{
  box-shadow:0 0 0 4px rgba(37,99,235,0.4);
  transform:translateY(-1px);
}

@media (max-width:900px){
  .consent-note,
  #consentStateNote{
    margin-left:22px;
  }


}
