/*
 * Responsive scan layout v105.
 * Loaded after scan-live.css so this section is the final layout authority.
 */

.scan-body,
.scan-body .wrapper {
  width: 100%;
  min-height: 100vh;
  overflow-x: hidden;
}

.scan-body .scan-input {
  font-size: 16px !important;
}

.scan-body .scan-side-card,
.scan-body .scan-panel,
.scan-body .scan-metric,
.scan-body .scan-action-btn,
.scan-body .scan-login-btn {
  box-sizing: border-box;
}

/* Monitor/laptop: use available width instead of leaving a large empty area. */
@media (min-width: 1200px) {
  .scan-body .scan-sidebar {
    width: 250px !important;
    transform: none !important;
  }

  .scan-body .scan-topbar .logo {
    width: 250px !important;
  }

  .scan-body .scan-topbar .navbar {
    margin-left: 250px !important;
  }

  .scan-body .content-wrapper {
    width: 100% !important;
    max-width: none !important;
    margin-left: 0 !important;
    padding: 76px 18px 20px 268px !important;
  }

  .scan-body .scan-shell {
    width: 100% !important;
    max-width: 1920px !important;
    margin: 0 auto !important;
    grid-template-columns: minmax(0, 1fr) clamp(330px, 22vw, 430px) !important;
    gap: 18px !important;
  }

  .scan-body .scan-main-stack,
  .scan-body .scan-right-stack {
    min-width: 0 !important;
  }

  .scan-body .scan-right-stack {
    width: 100% !important;
    max-width: none !important;
  }
}

@media (min-width: 1600px) {
  .scan-body .scan-panel-body {
    padding: 22px !important;
  }

  .scan-body .scan-title {
    font-size: clamp(32px, 2vw, 40px) !important;
  }

  .scan-body .scan-table thead th,
  .scan-body .scan-table tbody td {
    font-size: 14px !important;
  }
}

/* Tablet: sidebar becomes a visible scan control panel above the dashboard. */
@media (max-width: 1199px) {
  .scan-body .scan-topbar {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    min-height: 58px !important;
    z-index: 1060 !important;
  }

  .scan-body .scan-topbar .logo {
    width: 230px !important;
    height: 58px !important;
    line-height: 58px !important;
  }

  .scan-body .scan-topbar .navbar {
    margin-left: 230px !important;
    min-height: 58px !important;
  }

  .scan-body .scan-sidebar {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    bottom: auto !important;
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    margin: 58px 0 0 !important;
    padding: 12px !important;
    overflow: visible !important;
    transform: none !important;
    box-shadow: none !important;
    background: rgba(238, 246, 251, .98) !important;
    z-index: 1 !important;
  }

  .scan-body .scan-sidebar .sidebar {
    width: 100% !important;
    display: grid !important;
    grid-template-columns: minmax(180px, .8fr) minmax(210px, .9fr) minmax(270px, 1.2fr) !important;
    gap: 12px !important;
    padding: 0 !important;
  }

  .scan-body .scan-brand,
  .scan-body .scan-side-card {
    min-width: 0 !important;
    height: 100%;
    margin: 0 !important;
  }

  .scan-body .scan-brand {
    align-self: stretch;
  }

  .scan-body .scan-clock-card,
  .scan-body .scan-form-card {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .scan-body .scan-last-card {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    column-gap: 14px;
  }

  .scan-body .scan-last-card h4 {
    grid-column: 1 / -1;
  }

  .scan-body .scan-last-card .scan-photo {
    width: 78px !important;
    height: 78px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 18px !important;
  }

  .scan-body .scan-last-card .scan-name,
  .scan-body .scan-last-card .scan-person-meta {
    margin-top: 0 !important;
  }

  .scan-body .scan-last-card .scan-login-btn {
    margin: 0 !important;
    white-space: nowrap;
  }

  .scan-body .scan-last-card .scan-photo {
    grid-column: 1;
    grid-row: 2 / span 2;
  }

  .scan-body .scan-last-card .scan-name {
    grid-column: 2;
    grid-row: 2;
  }

  .scan-body .scan-last-card .scan-person-meta {
    grid-column: 2;
    grid-row: 3;
  }

  .scan-body .scan-last-card .scan-login-btn {
    grid-column: 3;
    grid-row: 2 / span 2;
    align-self: center;
  }

  .scan-body .scan-last-card .scan-empty {
    grid-column: 1 / 3;
  }

  .scan-body .content-wrapper {
    width: 100% !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: 14px 12px 20px !important;
  }

  .scan-body .scan-shell {
    width: 100% !important;
    max-width: none !important;
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 14px !important;
  }

  .scan-body .scan-main-stack,
  .scan-body .scan-right-stack {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    max-height: none !important;
    overflow: visible !important;
  }

  .scan-body .scan-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

@media (max-width: 900px) and (min-width: 768px) {
  .scan-body .scan-top-info .app {
    display: none !important;
  }

  .scan-body .scan-sidebar .sidebar {
    grid-template-columns: minmax(180px, .8fr) minmax(250px, 1.2fr) !important;
  }

  .scan-body .scan-brand {
    grid-column: 1;
  }

  .scan-body .scan-clock-card {
    grid-column: 2;
  }

  .scan-body .scan-form-card,
  .scan-body .scan-last-card {
    grid-column: 1 / -1;
  }
}

/* Phone: scan controls first, compact cards, no horizontal table scrolling. */
@media (max-width: 767px) {
  .scan-body .scan-topbar .logo {
    display: block !important;
    float: none !important;
    width: 100% !important;
    padding: 0 14px !important;
    text-align: left !important;
  }

  .scan-body .scan-topbar .navbar {
    display: none !important;
  }

  .scan-body .scan-sidebar {
    padding: 10px !important;
  }

  .scan-body .scan-sidebar .sidebar {
    grid-template-columns: 1fr !important;
    gap: 10px !important;
  }

  .scan-body .scan-brand {
    min-height: 72px;
  }

  .scan-body .scan-brand img {
    width: 46px !important;
    height: 46px !important;
  }

  .scan-body .scan-clock-time {
    font-size: clamp(28px, 10vw, 42px) !important;
  }

  .scan-body .scan-form-card {
    position: relative;
    z-index: 2;
  }

  .scan-body .scan-last-card {
    display: block;
  }


  .scan-body .scan-last-card .scan-photo,
  .scan-body .scan-last-card .scan-name,
  .scan-body .scan-last-card .scan-person-meta,
  .scan-body .scan-last-card .scan-login-btn,
  .scan-body .scan-last-card .scan-empty {
    grid-column: auto;
    grid-row: auto;
  }

  .scan-body .scan-last-card .scan-photo {
    display: none;
  }

  .scan-body .scan-last-card .scan-name {
    margin-top: 8px !important;
  }

  .scan-body .scan-last-card .scan-login-btn {
    margin-top: 10px !important;
  }

  .scan-body .content-wrapper {
    padding: 10px 8px 16px !important;
  }

  .scan-body .scan-main-stack {
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }

  .scan-body .scan-panel,
  .scan-body .scan-metric {
    border-radius: 20px !important;
  }

  .scan-body .scan-panel-body {
    padding: 14px !important;
  }

  .scan-body .scan-hero .scan-panel-body {
    padding: 18px 14px !important;
  }

  .scan-body .scan-chip {
    font-size: 11px;
  }

  .scan-body .scan-title {
    font-size: 27px !important;
  }

  .scan-body .scan-subtitle {
    font-size: 13px !important;
    line-height: 1.5 !important;
  }

  .scan-body .scan-hero-actions,
  .scan-body .scan-section-actions,
  .scan-body .scan-category-filter {
    width: 100%;
  }

  .scan-body .scan-action-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }

  .scan-body .scan-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
  }

  .scan-body .scan-metric {
    padding: 13px !important;
    min-height: 118px !important;
  }

  .scan-body .scan-metric .value {
    font-size: 27px !important;
  }

  .scan-body .scan-metric .sub {
    font-size: 11px !important;
  }

  .scan-body .scan-section-title {
    display: block !important;
  }

  .scan-body .scan-section-title h3 {
    font-size: 18px !important;
    line-height: 1.35;
  }

  .scan-body .scan-section-actions {
    display: grid !important;
    gap: 9px !important;
    margin-top: 12px;
  }

  .scan-body .scan-category-filter {
    display: block !important;
  }

  .scan-body .scan-category-filter label {
    margin-bottom: 7px !important;
  }

  .scan-body .scan-filter-select-wrap {
    width: 100% !important;
    min-width: 0 !important;
  }

  .scan-body .scan-filter-select-wrap select {
    height: 46px !important;
    font-size: 14px !important;
  }

  .scan-body .scan-table-wrap {
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
  }

  .scan-body .scan-table,
  .scan-body .scan-table tbody {
    display: block !important;
    width: 100% !important;
    min-width: 0 !important;
  }

  .scan-body .scan-table thead {
    display: none !important;
  }

  .scan-body .scan-table tbody tr {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100% !important;
    margin-bottom: 10px !important;
    overflow: hidden;
    border: 1px solid #dbe4ee;
    border-radius: 17px;
    background: #fff;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .07);
  }

  .scan-body .scan-table tbody td {
    display: grid !important;
    grid-template-columns: minmax(92px, 38%) minmax(0, 1fr) !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    min-height: 44px;
    padding: 9px 12px !important;
    border: 0 !important;
    border-bottom: 1px solid #edf2f7 !important;
    background: #fff !important;
    text-align: left !important;
  }

  .scan-body .scan-table tbody td:last-child {
    border-bottom: 0 !important;
  }

  .scan-body .scan-table tbody td::before {
    content: attr(data-label);
    color: #64748b;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: .35px;
    text-transform: uppercase;
  }

  .scan-body .scan-table tbody td[data-label="No"] {
    display: none !important;
  }

  .scan-body .scan-table tbody td.scan-photo-cell {
    min-height: 74px;
  }

  .scan-body .scan-table tbody td[colspan] {
    display: block !important;
    padding: 0 !important;
  }

  .scan-body .scan-table tbody td[colspan]::before {
    display: none !important;
  }

  .scan-body .scan-status {
    justify-self: start;
    min-width: 0 !important;
    max-width: 100%;
    white-space: normal;
    text-align: center;
  }

  .scan-body .scan-info-grid,
  .scan-body .scan-progress-board {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .scan-body .scan-page-footer {
    display: block !important;
    text-align: center;
    line-height: 1.7;
  }
}

@media (max-width: 420px) {
  .scan-body .scan-metrics,
  .scan-body .scan-info-grid,
  .scan-body .scan-progress-board {
    grid-template-columns: 1fr !important;
  }

  .scan-body .scan-metric {
    min-height: auto !important;
  }

  .scan-body .scan-table tbody td {
    grid-template-columns: 86px minmax(0, 1fr) !important;
  }
}
