:root {
  --vh: 1vh;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: #fff;
  color: #0b2a44;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif;
  font-size: 16px;
}

body {
  min-height: calc(var(--vh) * 100);
}

/* ===== ヘッダー・タブ ===== */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #0b2a44;
  color: #fff;
}

.brand {
  font-weight: 700;
}

.brand small {
  font-weight: 400;
  margin-left: 0.5em;
  opacity: 0.85;
}

.menu {
  background: transparent;
  color: #fff;
  border: 0;
  font-size: 24px;
}

.tabs {
  display: flex;
  gap: 8px;
  padding: 10px;
  background: #eef4fb;
  border-bottom: 1px solid #d7e1ee;
}

.tabs button {
  flex: 1;
  padding: 10px;
  border: 1px solid #9bb3cc;
  background: #c9d6e6;
  color: #0b2a44;
  border-radius: 6px;
}

.tabs button.active {
  background: #0b2a44;
  color: #fff;
  border-color: #0b2a44;
}

/* ===== メインレイアウト ===== */

main {
  padding: 14px;
}

.screen {
  display: none;
}

.screen.show {
  display: block;
}

/* ===== フォーム共通 ===== */

.field {
  display: grid;
  gap: 6px;
  margin: 12px 0;
}

label {
  font-weight: 700;
}

select,
input {
  padding: 12px;
  border: 1px solid #0b2a44;
  border-radius: 8px;
  font-size: 16px;
  background: #fff;
  color: #0b2a44;
}

/* 検定式のプレビュー */
.preview {
  margin: 8px 0 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ===== 入力グリッド ===== */

.grid {
  --rows: 6;
  --cols: 8;
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr); /* JSから --cols=4 にされる */
  gap: 8px;
  margin-top: 10px;
}

.grid input {
  width: 100%;
  padding: 10px 8px;
  border: 1px solid #0b2a44;
  border-radius: 6px;
  text-align: right;
}

.grid .hdr {
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
}

/* 「状況」ボタン */
.grid .status-btn {
  width: 100%;
  padding: 10px 8px;
  border: 1px solid #0b2a44;
  border-radius: 6px;
  background: #e3edf8;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* データあり（アイコン表示）のとき少し強調 */
.grid .status-btn.has-data {
  background: #0b2a44;
  color: #fff;
}

/* Material Symbols アイコン */
.material-symbols-outlined {
  font-variation-settings:
    "FILL" 0,
    "wght" 400,
    "GRAD" 0,
    "opsz" 24;
  font-size: 24px;
}

/* 入力タブ全体の下にボタンぶんの余白を確保 */
#screen-input {
  padding-bottom: 72px; /* ボタン高さ + 余白。必要なら調整してOK */
}

/* 入力タブの確定・クリアボタンを左下固定表示 */
#screen-input .actions {
  position: fixed;
  left: 12px;
  bottom: 12px;
  margin-top: 0;
  display: flex;
  gap: 8px;
  background: #ffffff;
  padding: 6px;
  z-index: 100; /* 表より手前に出す */
}

/* ===== 出力タブ ===== */

h2 {
  font-size: 18px;
  margin: 8px 0 12px;
}

pre {
  background: #f6f8fb;
  border: 1px solid #dbe6f5;
  border-radius: 8px;
  padding: 12px;
  min-height: 5lh;
  white-space: pre-wrap;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

button {
  padding: 10px 12px;
  border: 1px solid #0b2a44;
  border-radius: 8px;
  background: #fff;
  color: #0b2a44;
}

button.primary {
  background: #0b2a44;
  color: #fff;
}

/* ===== モーダル ===== */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  z-index: 1000;
}

.modal.show {
  display: flex;
}

.modal-panel {
  width: min(640px, 100%);
  background: #fff;
  color: #0b2a44;
  border-radius: 14px;
  border: 1px solid #dfe7f3;
  padding: 12px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #e7eef9;
  padding-bottom: 8px;
  margin-bottom: 10px;
}

/* タイトル小さめ */
.modal-header h3 {
  margin: 0;
  font-size: 0.9rem;
}

.modal-close {
  background: transparent;
  border: 0;
  font-size: 24px;
  line-height: 1;
  padding: 4px 8px;
  color: #0b2a44;
}

/* 2カラム×2行フォーム */
.trial-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2カラム */
  gap: 8px 12px;
}

.trial-field {
  display: grid;
  gap: 3px;
}

/* 小さめラベル＆入力 */
.trial-field label {
  font-weight: 700;
  font-size: 0.8rem;
}

.trial-field input {
  padding: 4px 6px;
  border: 1px solid #0b2a44;
  border-radius: 8px;
  font-size: 0.9rem;
  width: 95%;
}

.modal-note {
  min-height: 1.25em;
  color: #4d6c2f;
  margin: 8px 0;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 6px;
}

body.modal-open {
  overflow: hidden;
}

/* モーダル内のDW / 氷境ボタンが選択状態のときの色 */
#trialDw.selected,
#trialIce.selected {
  background: #0b2a44;
  color: #fff;
}

/* 例：モーダル内で selected が付いたボタンは色変更 */
.modal-actions button.selected {
  /* 元の DW ボタンと同じ色 */
  background-color: #0b2a44;
  color: #fff;
}


/**/


.qav-summary-table,
.qav-main-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  table-layout: fixed;
}

/* 全セル 1px の線 */
.qav-summary-table th,
.qav-summary-table td,
.qav-main-table th,
.qav-main-table td {
  border: 1px solid #d0d3d8;
  padding: 2px 4px;
  text-align: center;
}

/* サマリー部分 */
.qav-summary-table th {
  background: #f7f7f7;
  font-weight: normal;
}
.qav-summary-table td {
  height: 24px;
}

/* メイン表ヘッダ */
.qav-main-table .group-header {
  background: #f7f7f7;
  font-weight: normal;
}

.qav-main-table thead tr:nth-child(2) th,
.qav-main-table thead tr:nth-child(3) th {
  background: #fafafa;
  font-weight: normal;
}

/* データ行の縞模様（ざっくり） */
.qav-main-table tbody tr:nth-child(odd) td {
  background: #fafafa;
}

.qav-main-table tbody tr:nth-child(even) td {
  background: #ffffff;
}

/* ===== 出力テーブル：横スクロール用ラッパー ===== */

.qav-main-scroll {
  margin-top: 8px;
}

/* スマホなど横幅が狭いときに横スクロール＋フォント小さめ */
@media (max-width: 768px) {
  .qav-main-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .qav-main-table {
    min-width: 1100px; /* 列数に合わせて必要なら調整 */
    font-size: 11px;
  }

  .qav-main-table th,
  .qav-main-table td {
    padding: 2px 3px;
    white-space: nowrap; /* 折り返さず横に流す */
  }
}
