@charset "UTF-8";

/* =========================
   共通初期化
========================= */
* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  width: 100%;
  margin: 0;
  padding: 12px;
  font-family: sans-serif;
  line-height: 1.5;
  background: #ffffff;
  color: #222222;
}

@media screen and (min-width: 641px) {
  body {
    width: 400px;
    margin: 0 auto;
  }
}

/* =========================
   レイアウト
========================= */
header {
  margin-bottom: 16px;
}

main {
  width: 100%;
}

/* =========================
   見出し
========================= */
h1 {
  margin: 0;
  font-size: 24px;
  text-align: center;
  line-height: 1.4;
}

/* =========================
   段落
========================= */
p {
  margin: 0 0 12px;
}

/* =========================
   ラベル
========================= */
label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 16px;
}

/* =========================
   フォーム
========================= */
form {
  margin: 0;
}

input[type="text"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="email"],
select,
textarea {
  width: 100%;
  font-size: 16px;
  padding: 12px;
  border: 1px solid #999999;
  border-radius: 6px;
  background: #ffffff;
  color: #222222;
  margin-bottom: 12px;
  appearance: none;
  -webkit-appearance: none;
}

input,
select,
textarea,
button {
  font-size: 16px;
}

::placeholder {
  color: #999999;
}

/* =========================
   状態表示
========================= */
.status-box {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid #cccccc;
  border-radius: 6px;
  background: #f8f8f8;
  min-height: 120px;
}

.status-box p:last-child {
  margin-bottom: 0;
}

.gps-line {
  margin-bottom: 10px;
  font-weight: bold;
}

/* =========================
   共通状態
========================= */
.disabled-label {
  color: #999999;
}

.temp-ok {
  color: #0a4f9c;
  font-weight: bold;
}

/* =========================
   鍵フォーム ラジオ関連
========================= */
.action-row {
  display: inline-flex;
  align-items: center;
  margin: 8px 16px 8px 0;
  vertical-align: middle;
}

.action-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  min-height: 36px;
  padding: 2px 2px;
  -webkit-tap-highlight-color: transparent;
  margin-bottom: 0;
}

.action-label input[type="radio"] {
  width: 18px;
  height: 18px;
  margin: 0;
  flex-shrink: 0;
  transform: scale(1.1);
}

/* =========================
   複数選択
========================= */
.option-box {
  margin: 12px 0;
  padding: 10px;
  border: 1px solid #ccc;
  background: #fafafa;
  display: none;
}

.option-box.show {
  display: block;
}

.sub-box {
  margin-top: 12px;
  padding: 10px;
  border: 1px dashed #bbb;
  background: #fff;
}

.multiple-mode-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
}

.multiple-mode-box p {
  margin: 0;
  flex: 0 0 auto;
}

.multiple-mode-box .action-label {
  min-height: 36px;
}

.multiple-status-text {
  margin-top: 8px;
  color: #666;
}

.key-grid {
  display: block;
  margin-top: 10px;
}

.key-grid-page {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  width: 100%;
}

.multiple-key-pager {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: stretch;
  gap: 8px;
  margin: 8px 0;
}

.multiple-key-pager-top {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 4px 0;
  background: #fff;
}

.multiple-page-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 38px;
  min-height: 36px;
  padding: 0;
  margin: 0;
  border-radius: 6px;
  font-size: 24px;
  line-height: 1;
}

.multiple-page-button:disabled {
  opacity: 0.35;
}

.multiple-range-select-wrap {
  display: block;
  min-width: 0;
  height: 38px;
}

.multiple-range-select {
  width: 100%;
  height: 38px;
  min-height: 38px;
  box-sizing: border-box;
  margin-top: 0;
  padding: 0 10px;
  font-size: 16px;
  font-weight: bold;
  line-height: 38px;
  text-align: center;
  text-align-last: center;
}

.key-item {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  min-height: 64px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  min-width: 0;
}

.key-item input[type="checkbox"] {
  flex: 0 0 auto;
  transform: scale(1.15);
  margin-right: 8px;
}

.key-item-text {
  min-width: 0;
  overflow-wrap: anywhere;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.key-item.disabled-label {
  background: #f3f3f3;
}

/* =========================
   管理者エリア（折り畳み）
========================= */
.admin-box {
  margin-top: 20px;
  border: 1px solid #99b;
  background: #f7f9ff;
  display: none;
}

.admin-box.show {
  display: block;
}

.admin-heading {
  padding: 12px;
  font-size: 16px;
  font-weight: bold;
  border-bottom: 1px solid #ccd3f0;
  background: #f2f5ff;
}


.admin-section:first-of-type {
  border-top: none;
}

.admin-section-summary {
  display: block;
  list-style: none;
  cursor: pointer;
  padding: 12px;
  font-size: 16px;
  font-weight: bold;
  user-select: none;
  background: #f7f9ff;
}

.admin-section-summary::-webkit-details-marker {
  display: none;
}

.admin-section-summary::after {
  content: "▼";
  margin-left: 8px;
  font-size: 14px;
}

.admin-section[open] .admin-section-summary::after {
  content: "▲";
}

.admin-section[open] .admin-section-summary {
  border-bottom: 1px solid #ccd3f0;
}

.admin-box-inner {
  padding: 12px;
}

.admin-title {
  padding: 10px 16px;
  font-size: 16px;
  font-weight: bold;
  border-bottom: 1px solid #ccd3f0;
  background: #f5f7ff;
}

/* =========================
   管理者横並び
========================= */
.admin-inline-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: nowrap;
  margin-bottom: 10px;
}

.admin-field {
  display: flex;
  flex-direction: column;
  margin-bottom: 0;
}

.admin-field > span {
  display: block;
  margin-bottom: 4px;
  font-size: 16px;
  line-height: 1.4;
}

.admin-field-key,
.admin-field-minutes {
  flex: 1 1 0;
  min-width: 0;
}

.admin-input-row {
  display: flex;
  align-items: center;
  width: 100%;
}

.admin-input-short {
  width: 100%;
  min-width: 0;
  max-width: none;
  padding: 8px;
  margin: 0;
}

.admin-select {
  width: 100%;
  min-height: 42px;
  padding: 8px;
  font-size: 16px;
  box-sizing: border-box;
}

.admin-setting-row {
  margin: 10px 0;
  font-size: 16px;
}

.admin-gps-check-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: center;
  gap: 8px 12px;
  min-height: 30px;
}

.admin-gps-check-row label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 30px;
  line-height: 1.2;
  white-space: nowrap;
  min-width: 0;
  font-size: 16px;
}

.admin-gps-check-row input[type="checkbox"] {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  margin: 0;
  box-sizing: border-box;
  appearance: none;
  -webkit-appearance: none;
  display: inline-grid;
  place-content: center;
  border: 1px solid #777777;
  border-radius: 2px;
  background: #ffffff;
  vertical-align: middle;
}

.admin-gps-check-row input[type="checkbox"]::after {
  content: "";
  width: 8px;
  height: 5px;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #ffffff;
  transform: rotate(-45deg) scale(0);
  transform-origin: center;
}

.admin-gps-check-row input[type="checkbox"]:checked {
  border-color: #0d6efd;
  background: #0d6efd;
}

.admin-gps-check-row input[type="checkbox"]:checked::after {
  transform: rotate(-45deg) scale(1);
}

.admin-mode-subsection {
  margin-top: 8px;
}

.admin-mode-subsection:first-of-type {
  margin-top: 0;
}

.admin-user-role-field {
  margin-top: 14px;
}

.admin-key-master-field {
  margin-top: 14px;
}

.admin-key-master-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.admin-key-number-mode {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: stretch;
  margin: 8px 0 10px;
}

.admin-key-number-mode .admin-select {
  height: 52px;
  min-height: 52px;
}

.admin-key-number-mode button {
  width: 92px;
  height: 52px;
  min-height: 52px;
  padding: 8px;
  margin: 0;
  font-size: 15px;
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

.admin-gps-location-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.admin-key-master-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
  padding: 8px;
  border: 1px solid #d0d6f0;
  border-radius: 6px;
  background: #fff;
}

.admin-key-master-header {
  display: grid;
  grid-template-columns: 3em minmax(0, 1fr);
  gap: 8px;
  align-items: center;
}

.admin-key-master-no {
  font-weight: bold;
  text-align: center;
}

.admin-key-master-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.admin-key-master-controls input,
.admin-key-master-controls select {
  width: 100%;
  min-height: 38px;
  margin: 0;
  box-sizing: border-box;
  font-size: 15px;
}

.admin-key-master-token {
  font-size: 12px;
  color: #555;
  word-break: break-all;
  line-height: 1.4;
}

.admin-key-master-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.admin-key-master-actions button {
  min-height: 38px;
  padding: 8px;
  font-size: 14px;
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

.admin-key-master-actions button:nth-child(2) {
  background: linear-gradient(to bottom, #9a9a9a 0%, #707070 100%);
}

.admin-key-master-actions .admin-key-master-qr-button {
  grid-column: 1 / -1;
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

.admin-user-role-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.admin-user-role-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid #d0d6f0;
  border-radius: 6px;
  background: #fff;
}

.admin-user-role-name {
  min-width: 0;
  line-height: 1.4;
}

.admin-user-role-name small {
  display: block;
  color: #555;
}

.admin-user-role-row select {
  justify-self: center;
  align-self: center;
  width: 100px;
  min-height: 38px;
  margin: 0;
  font-size: 15px;
  text-align: center;
  text-align-last: center;
}

/* =========================
   管理者ボタン
========================= */
.admin-box button {
  display: inline-block;
  width: 100%;
  min-height: 44px;
  padding: 14px 24px;
  font-size: 18px;
  line-height: 1.2;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  margin-top: 4px;
  background: linear-gradient(to bottom, #eeeeee 0%, #dddddd 100%);
}

.admin-mode-subsection > .admin-section-toggle {
  background: linear-gradient(to bottom, #0f766e 0%, #115e59 100%);
}

.admin-box button:hover {
  opacity: 0.95;
}

.admin-box button:active {
  transform: translateY(1px);
}

.admin-box button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.admin-box .admin-key-number-mode {
  align-items: start;
}

.admin-box .admin-key-number-mode .admin-select,
.admin-box .admin-key-number-mode button {
  height: 52px;
  min-height: 52px;
  box-sizing: border-box;
  margin: 0;
  line-height: 1.2;
}

.admin-box .admin-key-number-mode .admin-select {
  padding: 0 8px;
}

.admin-box .admin-key-number-mode button {
  width: 84px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.admin-box .multiple-page-button {
  display: flex;
  width: 44px;
  min-height: 36px;
  padding: 0;
  margin: 0;
  color: #111;
  border: 1px solid #cfcfcf;
  background: linear-gradient(to bottom, #f7f7f7 0%, #e5e5e5 100%);
}

#captureGpsLocationBtn,
#saveAdminSettingsBtn,
#saveRegistrationModeBtn,
#applyKeyNumberModeBtn {
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

.admin-box .admin-key-master-actions button:first-child,
.admin-box .admin-key-master-actions .admin-key-master-qr-button {
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

#issueTempAuthBtn,
#issueRegistrationInviteBtn {
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
  margin-bottom: 8px;
}

#copyTempAuthBtn,
#copyRegistrationInviteBtn {
  background: linear-gradient(to bottom, #9a9a9a 0%, #707070 100%);
}

.admin-result {
  margin-top: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.6;
  min-height: calc(1.6em * 2);
}

#registrationInviteResult {
  min-height: calc(1.6em * 5);
}

.stale-registration-invite-list {
  margin-top: 10px;
}

.stale-registration-invite-title {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: bold;
  color: #555;
}

.stale-registration-invite-row {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) 4.7em minmax(4.8em, 1fr) 4.1em;
  gap: 5px;
  align-items: center;
  padding: 6px;
  border: 1px solid #d0d6f0;
  border-radius: 6px;
  background: #fff;
  margin-top: 6px;
}

.stale-registration-invite-issuer,
.stale-registration-invite-remaining {
  min-width: 0;
  font-size: 14px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.stale-registration-invite-remaining {
  text-align: center;
  white-space: nowrap;
}

.stale-registration-invite-row button {
  min-height: 34px;
  padding: 6px 4px;
  margin: 0;
  font-size: 14px;
  background: linear-gradient(to bottom, #9a9a9a 0%, #707070 100%);
}

.stale-registration-invite-row .stale-registration-invite-qr-button {
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

#adminModeResult:empty {
  min-height: 0;
  margin-top: 0;
}

.key-qr-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 24px;
  background: rgba(0, 0, 0, 0.55);
  box-sizing: border-box;
}

.key-qr-modal.show {
  display: flex;
}

.key-qr-modal-panel {
  width: min(82vw, 340px);
  aspect-ratio: 1 / 1;
  padding: 18px;
  border-radius: 8px;
  background: #fff;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
}

.key-qr-modal-panel img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  -webkit-touch-callout: default;
  user-select: auto;
}

.key-qr-modal-close {
  width: 52px;
  height: 52px;
  min-height: 52px;
  padding: 0;
  border: 2px solid #fff;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.15);
  color: #fff;
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
}

.action-choice-modal .key-qr-modal-panel {
  width: min(88vw, 380px);
  height: auto;
  min-height: 0;
  aspect-ratio: auto;
  padding: 22px;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
}

.action-choice-modal h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.35;
  text-align: center;
}

.action-choice-modal p {
  margin: 0;
  line-height: 1.7;
}

.action-choice-modal textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 92px;
  margin: 0;
  padding: 10px;
  resize: vertical;
}

.action-choice-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-choice-buttons button {
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  font-weight: bold;
  background: linear-gradient(to bottom, #4c8df6 0%, #2a6ad9 100%);
}

.action-choice-buttons .secondary-button {
  grid-column: 1 / -1;
  background: linear-gradient(to bottom, #9a9a9a 0%, #707070 100%);
}

/* =========================
   QR表示
========================= */
.qr-area {
  margin: 12px auto 0;
  width: 240px;
  height: 240px;
  padding: 16px;
  border: 1px solid #ddd;
  background: #fff;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-align: center;
}

.qr-area > div,
.qr-area canvas,
.qr-area img {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

/* =========================
   鍵貸出返却状況
========================= */

.admin-status-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.admin-status-row {
  display: grid;
  grid-template-columns: minmax(4em, 8em) 7em auto;
  gap: 16px;

  width: calc(100% - 24px);
  margin: 0 auto 10px;

  padding: 10px;
  background: #ffffff;
  border-radius: 6px;
  border: 1px solid #d0d6f0;

  text-decoration: none; /* ←リンクの下線消す */
  color: inherit;        /* ←色を通常に戻す */
}

.admin-status-row:active {
  background: #e8edff;
}

.admin-status-key {
  display: inline-block;
  min-width: 0;
  text-align: right;
  font-weight: bold;
  color: #333;
  overflow-wrap: anywhere;
}

.admin-status-name {
  font-weight: 600;
  display: inline-block;
  min-width: 7em;
}

.admin-status-tel a {
  color: #0057ff;
  font-weight: bold;
  text-decoration: none;
}

.admin-status-tel a:active {
  opacity: 0.6;
}

/* =========================
   送信ボタン
========================= */
input[type="submit"],
#submitButton {
  display: inline-block;
  width: 100%;
  min-height: 44px;
  padding: 14px 24px;
  font-size: 20px;
  line-height: 1.2;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  background: linear-gradient(to bottom, #d93a3a 0%, #b30000 100%);
  appearance: none;
  -webkit-appearance: none;
}

input[type="submit"]:hover,
#submitButton:hover {
  opacity: 0.95;
}

input[type="submit"]:active,
#submitButton:active {
  transform: translateY(1px);
}

input[type="submit"]:disabled,
#submitButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================
   結果メッセージ
========================= */
#result {
  margin-top: 12px;
  font-size: 15px;
  word-break: break-word;
}

/* =========================
   利用者情報など
========================= */
#userInfo,
#keyDisplay,
#statusText,
#borrowerText {
  word-break: break-word;
}

/* =========================
   スマホ微調整
========================= */
@media screen and (max-width: 640px) {
  h1 {
    font-size: 24px;
  }

  .action-label {
    font-size: 17px;
    min-height: 48px;
  }

  .multiple-mode-box {
    gap: 6px 18px;
  }

  .multiple-mode-box .action-label {
    min-height: 44px;
  }

  input[type="submit"],
  #submitButton {
    font-size: 20px;
    padding: 14px 24px;
  }

  .admin-box button {
    font-size: 18px;
    padding: 14px 24px;
  }

  .admin-box .multiple-page-button {
    width: 44px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    font-size: 24px;
  }
}

@media (max-width: 480px) {
  .key-grid-page {
    grid-template-columns: repeat(3, minmax(60px, 1fr));
  }

  .admin-box button {
    width: 100%;
    margin-bottom: 8px;
  }

  .admin-box .multiple-page-button {
    width: 44px;
    margin-bottom: 0;
  }

  .qr-area {
    width: 220px;
    height: 220px;
  }
}

@media (max-width: 360px) {
  .admin-gps-check-row {
    grid-template-columns: 1fr;
  }

  .admin-input-row {
    flex-wrap: wrap;
    align-items: flex-start;
  }
}
