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

body {
  font-family: "Segoe UI", sans-serif;
  background: #f4f6f8;
  color: #2c3e50;
}

.header {
  background: #2c3e50;
  color: white;
  padding: 14px 20px;
}

.app-title {
  font-size: 22px;
}

.main-container {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 14px;
  padding: 14px;
}

.map-section,
.summary-section,
.operation-section,
.outside-list-section {
  background: white;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.section-title {
  font-size: 18px;
  margin-bottom: 10px;
  border-bottom: 2px solid #3498db;
  padding-bottom: 6px;
}

.subsection-title {
  font-size: 15px;
  margin: 12px 0 8px;
}

.map-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 150px);
  min-height: 650px;
  overflow: auto;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f8f9fa;
}

.map-image {
  display: block;
  width: 100%;
  height: auto;
}

.markers-layer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.marker {
  position: absolute;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 12px;
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  cursor: pointer;
  pointer-events: auto;
  z-index: 10;
}

.marker.active,
.marker:hover {
  transform: scale(1.25);
  z-index: 30;
}

.status-in-use {
  background: #3498db;
}

.status-available {
  background: #27ae60;
}

.status-inspection {
  background: #95a5a6;
}

.status-unavailable {
  background: #e74c3c;
}

.marker.expired {
  border-color: #e74c3c;
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: calc(100vh - 90px);
  overflow-y: auto;
}

.summary-cards,
.area-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.summary-card,
.area-card {
  background: #f8f9fa;
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.summary-card h3,
.area-card h4 {
  font-size: 13px;
  color: #666;
}

.summary-value,
.area-value {
  font-size: 22px;
  font-weight: bold;
}

.operation-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-container {
  border-bottom: 1px solid #eee;
  padding-bottom: 12px;
}

.step-title {
  font-size: 15px;
  margin-bottom: 8px;
}

label {
  display: block;
  font-size: 13px;
  margin: 6px 0 4px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 9px;
  border: 1px solid #ccc;
  border-radius: 6px;
}

.area-buttons,
.qr-area-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.area-btn,
.qr-area-buttons button {
  padding: 10px;
  border: 2px solid #ddd;
  background: white;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

.area-btn.selected,
.qr-area-buttons button.selected {
  background: #3498db;
  color: white;
  border-color: #3498db;
}

.selected-area {
  margin-top: 8px;
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
}

.confirm-btn,
#qr-register-btn,
#qr-finish-btn {
  width: 100%;
  padding: 13px;
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
}

.confirm-btn,
#qr-register-btn {
  background: #27ae60;
  color: white;
}

.confirm-btn:disabled,
#qr-register-btn:disabled {
  background: #aaa;
  cursor: not-allowed;
}

#qr-finish-btn {
  background: #e67e22;
  color: white;
  margin-top: 10px;
}

.outside-machine-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.outside-machine {
  padding: 9px;
  background: #f8f9fa;
  border-left: 5px solid #999;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
}

/* 詳細ポップアップ */
.detail-panel {
  display: none;
  position: absolute;
  width: 280px;
  background: white;
  border-radius: 10px;
  padding: 14px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.25);
  z-index: 9999;
}

.detail-panel.show {
  display: block;
}

.close-btn {
  float: right;
  border: none;
  background: none;
  font-size: 24px;
  cursor: pointer;
}

.detail-item {
  margin: 10px 0;
}

.detail-item label {
  color: #666;
}

.detail-item div {
  padding: 8px;
  background: #f8f9fa;
  border-radius: 6px;
  font-weight: bold;
}

.action-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 7px;
  margin-top: 8px;
  color: white;
  font-weight: bold;
}

.btn-available {
  background: #27ae60;
}

.btn-inspection {
  background: #95a5a6;
}

.btn-unavailable {
  background: #e74c3c;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 20px;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.modal-buttons button {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: 8px;
  color: white;
}

.btn-cancel {
  background: #95a5a6;
}

.btn-confirm {
  background: #3498db;
}

/* QR画面 */
.qr-page {
  display: none;
  min-height: 100vh;
  padding: 20px;
}

.qr-card {
  max-width: 430px;
  margin: 0 auto;
  background: white;
  padding: 22px;
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.15);
}

.qr-card h1 {
  font-size: 22px;
  text-align: center;
  margin-bottom: 16px;
}

#qr-machine-name {
  font-size: 30px;
  text-align: center;
  margin-bottom: 12px;
}

#qr-current-status,
#qr-current-area,
.qr-guide,
#qr-message {
  text-align: center;
  margin: 10px 0;
  font-weight: bold;
}

.back-link {
  display: block;
  text-align: center;
  margin-top: 16px;
  color: #3498db;
  font-weight: bold;
}

/* スマホ */
@media (max-width: 768px) {
  .header {
    padding: 12px;
  }

  .app-title {
    font-size: 18px;
  }

  .main-container {
    display: flex;
    flex-direction: column;
    padding: 10px;
  }

  .map-section {
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .map-container {
    width: 95vw;
    max-width: 600px;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }

  .map-image {
    width: 100%;
    height: auto;
    margin-top: 80px;
  }

  .markers-layer {
    margin-top: 80px;
  }

  .side-panel {
    max-height: none;
    overflow: visible;
  }

  .summary-cards,
  .area-cards {
    grid-template-columns: repeat(2, 1fr);
  }

  .detail-panel {
    position: fixed;
    left: 5%;
    right: 5%;
    top: 8%;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
  }
}