body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f5f7fa;
  color: #333;
}

/* Utility classes to control visibility based on screen size. These are used
   to show/hide elements when the viewport is narrow (mobile) or wide.
   mobile-only: visible on screens up to 700px, hidden on larger screens.
   desktop-only: visible on larger screens, hidden on small screens. */
.mobile-only {
  display: none;
}
.desktop-only {
  display: inline-block;
}

@media (max-width: 700px) {
  .mobile-only {
    display: inline-block;
  }
  .desktop-only {
    display: none;
  }
}

#app {
  display: flex;
  height: 100vh;
}

/* Style the sidebar logo image. On mobile, reduce its size and center it. */
.logo-image {
  max-width: 90%;
  margin: 10px auto;
  display: block;
}

@media (max-width: 700px) {
  .logo-image {
    max-width: 60%;
    margin-top: 1rem;
  }
}

.sidebar {
  width: 250px;
  background: #2b3a51;
  color: #fff;
  overflow-y: auto;
  flex-shrink: 0;
}

/* Mobile sidebar behaviour: hide by default and display when active */
@media (max-width: 700px) {
  .sidebar {
    display: none;
    position: fixed;
    top: 3rem;
    left: 0;
    height: calc(100vh - 3rem);
    z-index: 2000;
    width: 80%;
    max-width: 300px;
    overflow-y: auto;
  }
  .sidebar.active {
    display: block;
  }
}
}

.sidebar h2 {
  padding: 1rem;
  margin: 0;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.serial-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.serial-list li {
  padding: 0.5rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.serial-list li:hover, .serial-list li.active {
  background: rgba(255,255,255,0.1);
}

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.topbar {
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.content {
  padding: 1rem;
  overflow-y: auto;
}

.hidden {
  display: none;
}

.button {
  padding: 0.4rem 0.8rem;
  border: none;
  border-radius: 3px;
  cursor: pointer;
  background: #1976d2;
  color: #fff;
  margin: 0.2rem;
}

.button:disabled {
  background: #b0bec5;
  cursor: default;
}

input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%;
  padding: 0.4rem;
  margin: 0.3rem 0 0.8rem 0;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-sizing: border-box;
}

.form-group {
  margin-bottom: 0.8rem;
}

.qc-question {
  margin-bottom: 0.6rem;
}

.qc-question label {
  display: block;
  margin-bottom: 0.2rem;
}

.qc-question select {
  width: auto;
}

.photo-preview img {
  max-width: 120px;
  max-height: 120px;
  margin-right: 8px;
  margin-bottom: 8px;
  border: 1px solid #ddd;
  border-radius: 3px;
}

/* Mobile navigation container inside sidebar. Hidden on desktop */
.mobile-nav {
  margin: 1rem;
  border-top: 1px solid rgba(255,255,255,0.2);
  padding-top: 0.5rem;
  display: none;
}
@media (max-width: 700px) {
  .mobile-nav {
    display: block;
  }
  .mobile-nav .button {
    width: 100%;
    margin: 0.3rem 0;
    text-align: left;
  }
}

/* Spec panel styling: floats right on wide screens to display model documents
   alongside the main QC details. On narrow screens, stacks below the
   details and takes full width. */
.spec-panel {
  float: right;
  width: 35%;
  max-width: 350px;
  min-width: 260px;
  border: 1px solid #ddd;
  padding: 0.5rem;
  margin-left: 1rem;
  background: #ffffff;
}

iframe {
  border: 1px solid #ccc;
}

@media (max-width: 700px) {
  .spec-panel {
    float: none;
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-top: 1rem;
  }
}

/* Responsive design adjustments for tablets and phones */
@media (max-width: 700px) {
  #app {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    order: 1;
  }
  .main {
    order: 2;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .topbar > div:last-child {
    margin-top: 0.5rem;
  }
  /* Ensure inputs take full width on small screens */
  input[type="text"], input[type="password"], input[type="number"], select, textarea {
    width: 100%;
  }
  .photo-preview img {
    max-width: 100%;
    height: auto;
  }
}

@media (max-width: 480px) {
  body {
    font-size: 16px;
  }
  .button {
    font-size: 16px;
  }
}

/* Responsive table handling: ensure tables do not overflow on
   smaller screens. Wrap tables in a scrollable container and
   prevent them from collapsing the layout. */
@media (max-width: 700px) {
  table {
    display: block;
    width: 100%;
    overflow-x: auto;
    white-space: nowrap;
  }
  table th, table td {
    white-space: nowrap;
  }
}