:root {
  color: #17202c;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* {
  box-sizing: border-box;
}

/* ---- Accessibility ------------------------------------------------------- */

/* Keyboard focus indicator (visible only for keyboard users, not mouse clicks). */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible,
.v-btn:focus-visible,
.v-field:focus-within {
  outline: 3px solid rgb(var(--v-theme-info, 60 111 153));
  outline-offset: 2px;
}

/* Skip-to-content link: hidden until focused via Tab. */
.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 4000;
  padding: 10px 16px;
  border-radius: 8px;
  background: rgb(var(--v-theme-primary));
  color: rgb(var(--v-theme-on-primary));
  font-weight: 700;
  text-decoration: none;
  transform: translateY(-150%);
  transition: transform 0.15s ease;
}
.skip-link:focus {
  transform: translateY(0);
}

/* Screen-reader-only utility. */
.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* High-contrast boost: stronger borders, bolder text, underlined links. Opt-in per user. */
body.ma-contrast-boost .v-card,
body.ma-contrast-boost .v-field__outline,
body.ma-contrast-boost .v-table,
body.ma-contrast-boost .asset-table th,
body.ma-contrast-boost .asset-table td,
body.ma-contrast-boost .manual-table th,
body.ma-contrast-boost .manual-table td {
  border-color: rgb(var(--v-theme-on-surface)) !important;
}
body.ma-contrast-boost .v-card {
  border: 1px solid rgb(var(--v-theme-on-surface));
}
body.ma-contrast-boost .quiet,
body.ma-contrast-boost .text-caption,
body.ma-contrast-boost .v-list-item-subtitle {
  opacity: 1 !important;
}
body.ma-contrast-boost a:not(.v-btn),
body.ma-contrast-boost .manual-section a {
  text-decoration: underline;
}
body.ma-contrast-boost .v-btn {
  outline: 1px solid rgba(var(--v-theme-on-surface), 0.4);
}

body {
  margin: 0;
  min-width: 320px;
  background: #11161d;
}

.app-shell {
  min-height: 100vh;
}

.rail {
  border-right: 1px solid rgba(var(--v-theme-on-surface), 0.12);
}

.brand-lockup {
  align-items: center;
  display: flex;
  gap: 10px;
  min-height: 56px;
  padding: 0 18px;
}

.brand-mark {
  align-items: center;
  background: #2457a6;
  border-radius: 6px;
  color: #fff;
  display: inline-flex;
  font-weight: 800;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 750;
  letter-spacing: 0;
}

.page-band {
  border-bottom: 1px solid rgba(var(--v-theme-on-surface), 0.12);
  padding: 22px 24px 18px;
}

.top-nav {
  border-bottom: 1px solid rgba(var(--v-theme-on-surface), 0.12);
  padding: 0 18px;
}

.top-nav-title {
  min-width: 0;
}

.profile-trigger {
  min-width: 0;
}

.profile-name {
  display: inline-block;
  font-weight: 700;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  padding: 18px 24px 28px;
}

.span-3 {
  grid-column: span 3;
}

.span-4 {
  grid-column: span 4;
}

.span-5 {
  grid-column: span 5;
}

.span-6 {
  grid-column: span 6;
}

.span-7 {
  grid-column: span 7;
}

.span-8 {
  grid-column: span 8;
}

.span-12 {
  grid-column: span 12;
}

.metric {
  min-height: 116px;
  padding: 18px;
}

.metric-label {
  color: rgba(var(--v-theme-on-surface), 0.62);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric-value {
  font-size: clamp(1.45rem, 2.4vw, 2.15rem);
  font-weight: 800;
  line-height: 1.1;
  margin-top: 12px;
}

.metric-subtle {
  color: rgba(var(--v-theme-on-surface), 0.62);
  font-size: 0.86rem;
  margin-top: 8px;
}

.toolbar-row {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.section-title {
  font-size: 1rem;
  font-weight: 800;
  margin: 0;
}

.quiet {
  color: rgba(var(--v-theme-on-surface), 0.62);
}

.asset-table {
  border-collapse: collapse;
  width: 100%;
}

.asset-table th,
.asset-table td {
  border-bottom: 1px solid rgba(var(--v-theme-on-surface), 0.12);
  font-size: 0.88rem;
  padding: 10px 12px;
  text-align: left;
  vertical-align: middle;
}

.asset-table th {
  color: rgba(var(--v-theme-on-surface), 0.62);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.asset-table tr:hover td {
  background: rgba(var(--v-theme-on-surface), 0.05);
}

.status-chip {
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 750;
  padding: 4px 9px;
}

.status-in_service {
  background: rgba(var(--v-theme-success), 0.16);
  color: rgb(var(--v-theme-success));
}

.status-disposed {
  background: rgba(var(--v-theme-error), 0.16);
  color: rgb(var(--v-theme-error));
}

.status-cip,
.status-reserved {
  background: rgba(var(--v-theme-warning), 0.18);
  color: rgb(var(--v-theme-warning));
}

.status-checked_out {
  background: rgba(var(--v-theme-info), 0.16);
  color: rgb(var(--v-theme-info));
}

.status-retired {
  background: rgba(var(--v-theme-on-surface), 0.1);
  color: rgba(var(--v-theme-on-surface), 0.7);
}

.panel-pad {
  padding: 16px;
}

/* Reusable DataTable */
.table-scroll {
  overflow: auto;
}

.asset-table.sticky-head thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgb(var(--v-theme-surface));
}

.asset-table.sticky-head tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 2;
  background: rgb(var(--v-theme-surface));
}

.asset-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.asset-table th.sortable:hover {
  color: rgb(var(--v-theme-primary));
}

.asset-table .th-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.asset-table .lead-col {
  width: 44px;
}

.data-table-footer {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-top: 10px;
}

/* PM completion photos */
.pm-photo-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pm-photo-wrap {
  position: relative;
}
.pm-photo-thumb {
  width: 84px;
  height: 84px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(var(--v-theme-on-surface), 0.2);
}
.pm-photo-remove {
  position: absolute;
  top: -8px;
  right: -8px;
}

/* Asset identification photos */
.asset-photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.asset-photo-frame {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(var(--v-theme-on-surface), 0.18);
}
.asset-photo-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.asset-photo-remove {
  position: absolute;
  top: 6px;
  right: 6px;
}

/* PM plan guidance photos */
.pm-guidance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}
.pm-guidance-fig {
  margin: 0;
}
.pm-guidance-fig img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid rgba(var(--v-theme-on-surface), 0.18);
}

/* User-guide print: render only the manual content as a clean document */
@media print {
  body * {
    visibility: hidden !important;
  }
  .user-manual-print,
  .user-manual-print * {
    visibility: visible !important;
  }
  .user-manual-print {
    position: absolute !important;
    inset: 0 !important;
    height: auto !important;
    max-height: none !important;
    box-shadow: none !important;
  }
  .user-manual-nav,
  .d-print-none {
    display: none !important;
  }
  .user-manual-content {
    overflow: visible !important;
    height: auto !important;
    max-height: none !important;
  }
  .manual-section {
    max-width: none !important;
    page-break-inside: avoid;
  }
}

.chart-box {
  position: relative;
  height: 280px;
  overflow: hidden;
}

.chart-box canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
}

.login-screen {
  align-items: center;
  background:
    linear-gradient(110deg, rgba(36, 87, 166, 0.92), rgba(0, 108, 106, 0.86)),
    url('/asset-workbench.png');
  background-position: center;
  background-size: cover;
  display: grid;
  min-height: 100vh;
  padding: 24px;
}

.login-card {
  max-width: 430px;
  width: 100%;
}

.form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.form-grid .full {
  grid-column: 1 / -1;
}

.custom-field-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(120px, 1fr) minmax(110px, 0.9fr) 130px minmax(110px, 0.8fr) 104px 40px;
  margin-bottom: 10px;
}

/* Dark themes get a dark color-scheme so native controls/scrollbars match. */
.v-theme--mixedAssetsDark,
.v-theme--mixedAssetsOcean,
.v-theme--mixedAssetsSlate,
.v-theme--mixedAssetsContrast {
  color-scheme: dark;
}

@media (max-width: 980px) {
  .content-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8 {
    grid-column: span 6;
  }
}

@media (max-width: 680px) {
  .content-grid,
  .page-band {
    padding-left: 14px;
    padding-right: 14px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }

  .span-3,
  .span-4,
  .span-5,
  .span-6,
  .span-7,
  .span-8,
  .span-12 {
    grid-column: 1;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .custom-field-row {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .profile-name {
    display: none;
  }

  .asset-table {
    min-width: 760px;
  }
}

/* Barcode scanning + labels */
.scan-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}

.scan-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.scan-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.6);
  font-size: 0.9rem;
}

.label-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.label-cell {
  border: 1px solid rgba(128, 128, 128, 0.35);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}

.barcode-svg {
  width: 100%;
  height: 46px;
}

.barcode-id {
  font-weight: 700;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  margin-top: 4px;
}

.barcode-caption {
  font-size: 0.7rem;
  opacity: 0.7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
