.scan-panel {
  background-color: #eee;
  border-radius: 12px;
  overflow: clip;
  width: 150px;
}
.scan-panel .image {
  width: 100%;
  height: 200px;
  object-fit: cover;
}

.scan-panel.scan-panel-calibration {
  width: 110px;
  background-color: #e5e7eb;
  opacity: 0.65;
  font-weight: 400;
}
.scan-panel.scan-panel-calibration .image {
  height: 130px;
}

.framed-img-lg {
  border-radius: 8px;
  border: 1px solid #888;
  box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
  overflow: clip;
}

.framed-img-sm {
  border-radius: 4px;
  border: 1px solid #888;
  box-shadow: 0px 1.5px 3px rgba(0, 0, 0, 0.1);
  overflow: clip;
}

table .image-lg {
  border-radius: 4px;
  border: 1px solid #888;
  box-shadow: 0px 1.5px 3px rgba(0, 0, 0, 0.1);
  overflow: clip;
  width: 48px;
  height: 48px;
  object-fit: contain;
}

/* Hover-to-enlarge thumbnail: shows a large floating preview of the same
   image while hovering, without a lightbox/popover library. */
.img-hover-zoom {
  position: relative;
  display: inline-block;
}

.img-hover-zoom .zoom-preview {
  display: none;
  /* Viewport-relative so it can be clamped on-screen near the page edges;
     hover-zoom.js sets top/left on hover. */
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1050;
  width: 320px;
  height: 320px;
  object-fit: contain;
  background: #fff;
  border: 1px solid #888;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  padding: 4px;
  pointer-events: none;
}

.img-hover-zoom:hover .zoom-preview {
  display: block;
}

#drop-container {
  position: relative;
  padding-top: 5em;
  padding-bottom: 5em;
}
#drop-container #drop-zone {
  position: absolute;
  z-index: 1;
  top: 0px;
  left: 0px;
  right: 0px;
  bottom: 0px;
}
#drop-container #select-files-btn {
  position: relative;
  z-index: 2;
}

.drop-zone-hover {
  box-shadow: 0px 0px 10px #0b0 inset;
}

/* ------------------------------------------------------------------ *
 * Sidebar layout (shared by /admin and /op via sidebar_base.html)    *
 * ------------------------------------------------------------------ */
.app-shell {
  min-height: 100vh;
  align-items: stretch;
}
.app-sidebar {
  --bs-offcanvas-width: 264px;
}
/* Inner wrapper paints the dark chrome (offcanvas-body is forced
   transparent by Bootstrap at >=md). */
.app-sidebar .offcanvas-body {
  padding: 0;
}
.app-sidebar-inner {
  background-color: #1f2329;
  color: #cfd3da;
  min-height: 100%;
}
.app-sidebar-brand {
  padding: 14px 16px;
  margin-bottom: 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  color: #fff;
  font-weight: 500;
  font-size: 1.05rem;
}
.app-sidebar-brand img {
  max-height: 30px;
  width: auto;
}
.app-sidebar-search {
  padding: 2px 12px 8px;
}
.app-sidebar-nav {
  padding: 4px 0 12px;
  overflow-y: auto;
}
.app-sidebar-group {
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #7a818c;
  padding: 14px 16px 4px;
}
.app-sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #cfd3da;
  font-size: 0.9rem;
  padding: 7px 16px;
  border-left: 3px solid transparent;
  border-radius: 0;
}
.app-sidebar-nav .nav-link:hover {
  background-color: rgba(255, 255, 255, 0.06);
  color: #fff;
}
.app-sidebar-nav .nav-link.active {
  background-color: rgba(77, 155, 230, 0.18);
  color: #fff;
  border-left-color: #4d9be6;
}
.app-sidebar-nav .nav-link i {
  width: 18px;
  text-align: center;
  font-size: 0.95rem;
  color: #8b919b;
}
.app-sidebar-nav .nav-link:hover i,
.app-sidebar-nav .nav-link.active i {
  color: #4d9be6;
}
.app-sidebar-footer {
  padding: 10px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: #9aa0aa;
  font-size: 0.85rem;
}
.app-main {
  min-width: 0; /* let wide tables scroll instead of forcing flex overflow */
  overflow-x: auto; /* the other half of the above: too-wide content scrolls inside the pane, never pushes the page past the viewport */
}

/* Unbreakable tokens (uids, emails) in narrow key-value panes wrap instead of
 * forcing the column wide. */
.kv-table td {
  overflow-wrap: anywhere;
}
.app-topbar {
  background-color: #1f2329;
  padding: 8px 12px;
}
.app-topbar-brand img {
  max-height: 24px;
  width: auto;
}

@media (min-width: 768px) {
  .app-sidebar {
    flex: 0 0 248px;
    width: 248px;
    position: sticky;
    top: 0;
    height: 100vh;
    align-self: flex-start;
    overflow: hidden;
  }
  .app-sidebar .offcanvas-body {
    height: 100vh;
    overflow: hidden;
  }
  .app-sidebar-inner {
    height: 100vh;
    overflow-y: auto;
  }
}

@media print {
  .app-sidebar,
  .app-topbar,
  .app-nav-toggle {
    display: none !important;
  }
  .app-main {
    width: 100% !important;
  }
}

/* ------------------------------------------------------------------ *
 * Dashboard (admin + operator home)                                  *
 * ------------------------------------------------------------------ */
.app-main-inner {
  padding-top: 1.25rem;
  padding-bottom: 2rem;
}
.dash-title {
  font-size: 1.4rem;
  font-weight: 600;
  margin: 0 0 1.25rem;
  color: #1f2329;
}
.dash-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 1.75rem;
}
.dash-metric {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  background-color: #fff;
  border: 1px solid #e6e8ec;
  border-radius: 12px;
  text-decoration: none;
  transition: border-color 0.12s ease, background-color 0.12s ease;
}
.dash-metric:hover {
  border-color: #cfd3da;
  background-color: #fcfcfd;
}
.dash-metric .label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #6b7280;
}
.dash-metric .num {
  font-size: 2rem;
  font-weight: 600;
  line-height: 1;
  color: #1f2329;
}
.dash-metric.alert {
  border-color: #f3c9c9;
  background-color: #fdf6f6;
}
.dash-metric.alert .num {
  color: #d6322f;
}

.dash-groups {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(244px, 1fr));
  gap: 14px;
  align-items: start;
}
.dash-group {
  background-color: #fff;
  border: 1px solid #e6e8ec;
  border-radius: 12px;
  overflow: hidden;
}
.dash-group .head {
  padding: 11px 16px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #6b7280;
  background-color: #fafbfc;
  border-bottom: 1px solid #eef0f3;
}
.dash-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  color: #1f2329;
  text-decoration: none;
  border-top: 1px solid #f2f3f5;
}
.dash-group .dash-link:first-of-type {
  border-top: 0;
}
.dash-link:hover {
  background-color: #f7f8fa;
}
.dash-link .name {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.dash-link .name i {
  width: 18px;
  text-align: center;
  color: #8a909a;
}
.dash-link .count {
  flex-shrink: 0;
  font-size: 0.72rem;
  background-color: #eef0f3;
  color: #4b5563;
  border-radius: 20px;
  padding: 2px 9px;
}
.dash-link .count.danger {
  background-color: #fde8e8;
  color: #b42318;
}

/* ------------------------------------------------------------------ *
 * Light sidebar variant (operator /op surface; admin stays dark)     *
 * ------------------------------------------------------------------ */
.app-shell.sidebar-light .app-sidebar-inner {
  background-color: #f4f5f7;
  color: #3f4651;
  border-right: 1px solid #e3e5ea;
}
.app-shell.sidebar-light .app-sidebar-brand {
  border-bottom-color: #e3e5ea;
  color: #1f2329;
}
.app-shell.sidebar-light .app-sidebar-group {
  color: #8b909a;
}
.app-shell.sidebar-light .app-sidebar-nav .nav-link {
  color: #3f4651;
}
.app-shell.sidebar-light .app-sidebar-nav .nav-link i {
  color: #9aa0aa;
}
.app-shell.sidebar-light .app-sidebar-nav .nav-link:hover {
  background-color: rgba(0, 0, 0, 0.04);
  color: #1f2329;
}
.app-shell.sidebar-light .app-sidebar-nav .nav-link.active {
  background-color: rgba(43, 125, 224, 0.12);
  color: #14467f;
  border-left-color: #2b7de0;
}
.app-shell.sidebar-light .app-sidebar-nav .nav-link:hover i,
.app-shell.sidebar-light .app-sidebar-nav .nav-link.active i {
  color: #2b7de0;
}
.app-shell.sidebar-light .app-sidebar-footer {
  border-top-color: #e3e5ea;
  color: #6b7280;
}
.app-shell.sidebar-light .app-topbar {
  background-color: #f4f5f7;
  border-bottom: 1px solid #e3e5ea;
}
.app-shell.sidebar-light .btn-close {
  filter: none;
}

/* ------------------------------------------------------------------ *
 * Native <details> dropdown menu (no Popper dependency)              *
 * ------------------------------------------------------------------ */
.dropdown-details {
  position: relative;
  display: inline-block;
}
.dropdown-details > summary {
  list-style: none;
  cursor: pointer;
}
.dropdown-details > summary::-webkit-details-marker {
  display: none;
}
.dropdown-details > summary::after {
  content: " \25BE";
}
.dropdown-details-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 190px;
  margin: 0;
  padding: 4px 0;
  list-style: none;
  background-color: #fff;
  border: 1px solid #d3d3d3;
  border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
  z-index: 1050;
}
.dropdown-details-menu > li > a {
  display: block;
  padding: 7px 16px;
  color: #212529;
  text-decoration: none;
  white-space: nowrap;
}
.dropdown-details-menu > li > a:hover {
  background-color: #f1f3f5;
}
/* Form-POST actions rendered as menu items (pass class='menu-item' to form/button.frag). */
.dropdown-details-menu form {
  margin: 0;
}
.dropdown-details-menu .menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 7px 16px;
  border: 0;
  border-radius: 0;
  background: none;
  color: #212529;
  white-space: nowrap;
  font-size: 0.95rem;
}
.dropdown-details-menu .menu-item:hover {
  background-color: #f1f3f5;
}
.dropdown-details-menu .menu-item.text-danger {
  color: #b42318;
}
