.tool-page-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.back-to-home {
  max-width: 600px;
  width: 100%;
  margin-bottom: 10px;
  margin-left: auto;
  margin-right: auto;
  text-align: left;
  padding: 0 20px;
  box-sizing: border-box;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  background-color: #6c757d;
  color: #fff;
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 1em;
  transition: background-color 0.3s ease, transform 0.2s ease;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.back-btn:hover {
  background-color: #5a6268;
  transform: translateY(-2px);
}

.back-btn i {
  margin-right: 8px;
  font-size: 1.1em;
}

.card-container {
  display: block;
  width: 100%;
  max-width: 600px;
}

.card-section {
  background-color: #ffffff;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  padding: 30px;
  margin-bottom: 30px;
}

.card-section h2 {
  font-size: 1.3em;
  margin-bottom: 20px;
  color: #34495e;
  text-align: left;
}

.input-group {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  gap: 10px; /* 元素间距 */
}

.date-fields {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.input-group label {
  font-size: 1.1em;
  font-weight: bold;
  color: #34495e;
}

.input-group input,
.input-group select {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1em;
  max-width: 100px;
  box-sizing: border-box;
}
.input-group input[type="file"] {
  padding: 10px;
  font-size: 1em;
  border: 1px solid #ccc;
  border-radius: 8px;
  max-width: 100%;
  box-sizing: border-box;
  background-color: #fff;
  cursor: pointer;
}

.set-today-btn {
  background-color: #007bff;
  color: #fff;
  padding: 10px 15px;
  border: none;
  border-radius: 8px;
  font-size: 0.95em;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

.set-today-btn:hover {
  background-color: #0056b3;
}

.calculate-btn,
.clear-btn {
  width: 100%;
  padding: 15px 20px;
  font-size: 1.1em;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  margin-top: 10px;
}

.calculate-btn {
  background-color: #28a745;
  color: white;
}

.calculate-btn:hover {
  background-color: #218838;
}

.clear-btn {
  background-color: #dc3545;
  color: white;
}

.clear-btn:hover {
  background-color: #c82333;
}

.result-group textarea {
  width: 100%;
  min-height: 60px;
  padding: 12px;
  font-size: 1em;
  border: 1px solid #ddd;
  border-radius: 8px;
  background-color: #f8f9fa;
  font-family: 'Courier New', Courier, monospace;
  resize: vertical;
}

.upload-btn {
  display: inline-flex;
  align-items: center;
  background-color: #007bff;
  color: #fff;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 1em;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease;
  border: none;
  text-decoration: none;
}

.upload-btn:hover {
  background-color: #0056b3;
}

.upload-btn i {
  margin-right: 8px;
}

#reader-wrapper {
  position: relative;
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  border: 2px solid #ccc;
  border-radius: 8px;
  overflow: hidden;
}

.camera-box {
  width: 100%;
  aspect-ratio: 1;
  position: relative;
}

.focus-box {
  position: absolute;
  top: 25%;
  left: 25%;
  width: 50%;
  height: 50%;
  border: 2px dashed #28a745;
  box-shadow: 0 0 10px rgba(40, 167, 69, 0.3);
  z-index: 10;
  pointer-events: none;
}

.scan-status {
  margin-top: 12px;
  font-size: 0.95em;
  text-align: center;
  color: #555;
}
/* Tab styles */
.tabs {
  display: flex;
  margin-bottom: -1px; /* Overlap with content border */
  width: 100%;
  max-width: 600px;
  background-color: #f8f9fa;
  border-radius: 8px 8px 0 0;
  overflow: hidden; /* For rounded corners on tabs */
}

.tab-button {
  flex: 1;
  padding: 15px 20px;
  background-color: #e9ecef;
  color: #495057;
  border: 1px solid #dee2e6;
  border-bottom: none; /* No bottom border */
  cursor: pointer;
  font-size: 1.05em;
  font-weight: bold;
  transition: background-color 0.3s ease, color 0.3s ease;
  text-align: center;
  /* white-space: nowrap; Removed to allow text wrapping on small screens */
  border-radius: 8px 8px 0 0; /* Rounded top corners */
  margin: 0 2px; /* Small gap between tabs */
  z-index: 1; /* Ensure tabs are above content */
  box-sizing: border-box; /* Include padding/border in flex calculations */
}

.tab-button:first-child {
  margin-left: 0;
}

.tab-button:last-child {
  margin-right: 0;
}

.tab-button:hover {
  background-color: #e2e6ea;
  color: #212529;
}

.tab-button.active {
  background-color: #ffffff;
  color: #34495e;
  border-color: #dee2e6;
  border-bottom-color: #ffffff; /* Hide bottom border for active tab */
  z-index: 2; /* Active tab on top */
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.05); /* Slight shadow for active tab */
}

.tab-content {
  background-color: #ffffff;
  border: 1px solid #dee2e6;
  border-top: none; /* No top border, as tabs provide it */
  border-radius: 0 0 12px 12px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
  padding: 30px;
  display: none; /* Hidden by default */
  width: 100%;
  max-width: 600px;
  box-sizing: border-box; /* Include padding in width */
  /*margin-bottom: 30px; /* Space below the tab container */
}

.tab-content.active {
  display: block; /* Show active content */
}
/* Ensure the wrapper uses a fixed aspect ratio */
.reader-container {
    width: 100%; /* Or set a max-width if desired, e.g., max-width: 400px; */
    max-width: 400px; /* This ensures it doesn't get too wide on large screens */
    margin: 0 auto;
    position: relative; /* Crucial for absolute positioning of #reader */
    /* Calculate padding-bottom for aspect ratio: height / width * 100% */
    /* Common camera aspect ratios: */
    /* 4:3 -> (3 / 4) * 100% = 75% */
    /* 16:9 -> (9 / 16) * 100% = 56.25% */
    /* You might try 75% for better compatibility across devices, or adjust based on your needs. */
    /* padding-bottom: 75%; /* This creates the height based on width */
    background-color: #f0f0f0; /* Show the background before video loads */
    border: 1px solid #ddd;
    overflow: hidden;
}

/* Position #reader absolutely within its relative parent */
#reader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    /* No need for background-color, border, overflow here, as it's on the container */
}

/* Optional: Improve styling of the generated video element if needed */
#reader video {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ensures video fills the container without distortion, may crop slightly */
    /* object-fit: contain; /* Ensures entire video is visible, may add black bars */
}
/* 响应式调整 */
@media (max-width: 768px) {
  .card-section {
    padding: 20px;
  }

  .input-group label {
    font-size: 1em;
  }

  .set-today-btn,
  .calculate-btn,
  .clear-btn {
    font-size: 1em;
    padding: 10px 15px;
  }
}

@media (max-width: 600px) {
  .back-to-home {
    padding: 0 15px;
    margin-bottom: 20px;
  }

  .back-btn {
    padding: 8px 15px;
    font-size: 0.9em;
  }
}
