html {
  font-size: 16px;
}

:root[data-bs-theme="dark"] {
  --bs-primary: #135e69;
  --bs-primary-rgb: 19, 94, 105;
  --bs-link-color-rgb: 117, 216, 209;
  --bs-link-hover-color-rgb: 159, 237, 231;
  --bs-body-color: #e6eef5;
  --bs-body-bg: #0e1622;
  --bs-secondary-color: #b5c4d1;
  --bs-border-color: #354758;
}

body {
  min-height: 100vh;
  color: var(--bs-body-color);
  background: var(--bs-body-bg);
}

.notification-overlay {
  position: fixed;
  top: 5.25rem;
  right: 1rem;
  z-index: 1090;
  display: flex;
  width: min(28rem, calc(100vw - 2rem));
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.flash-notification {
  margin: 0;
  box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.35);
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}

.flash-notification.is-dismissing {
  opacity: 0;
  transform: translateY(-0.5rem);
}

@media (max-width: 575.98px) {
  .notification-overlay {
    right: 0.75rem;
    left: 0.75rem;
    width: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  .flash-notification {
    transition: none;
  }
}

:focus-visible,
.camera-upload:focus-within {
  outline: 3px solid #80e3da;
  outline-offset: 3px;
}

.btn:focus-visible, .form-control:focus, .form-select:focus, .form-check-input:focus {
  border-color: #80e3da;
  box-shadow: 0 0 0 0.2rem rgba(128, 227, 218, 0.3);
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
  color: var(--bs-secondary-color);
  text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
  text-align: start;
}
.app-navbar {
  background: #141f2d;
  border-bottom: 1px solid #354758;
  box-shadow: 0 2px 18px rgba(0, 0, 0, 0.18);
}

.app-container {
  width: 100%;
  max-width: 1680px;
}

.app-main {
  padding: clamp(1.25rem, 3vw, 2.75rem) 0 4rem;
}

.app-main:has(.page-actions-footer) {
  padding-bottom: 10rem;
}

.navbar-brand, .navbar-brand:hover {
  color: #f0f8fc;
  font-weight: 750;
  letter-spacing: -0.03em;
}

.app-navbar .nav-link {
  padding: 0.65rem 0.85rem;
  border-radius: 0.6rem;
  font-weight: 500;
}

.app-navbar .nav-link:hover, .app-navbar .nav-link:focus-visible {
  color: #fff;
  background: #293c4d;
}

.app-navbar .nav-link-with-icon {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

/* Masked so the icon inherits the link's current text color on the dark navbar. */
.nav-icon {
  display: inline-block;
  flex-shrink: 0;
  width: 1.15em;
  height: 1.15em;
  background-color: currentColor;
  -webkit-mask: var(--nav-icon-url) center / contain no-repeat;
  mask: var(--nav-icon-url) center / contain no-repeat;
}

.nav-icon-login {
  --nav-icon-url: url("../images/login-svgrepo-com.svg");
}

.nav-icon-logout {
  --nav-icon-url: url("../images/logout-svgrepo-com.svg");
}

.nav-icon-read-only {
  --nav-icon-url: url("../images/eye-svgrepo-com.svg");
}

@media (forced-colors: active) {
  .nav-icon {
    background-color: CanvasText;
  }
}

h1, h2, h3 {
  color: #f0f8fc;
  letter-spacing: -0.025em;
}

h1 {
  font-weight: 700;
}

.card, details[data-filter-panel], .table-responsive {
  background: #172333;
  border: 1px solid #354758;
  border-radius: 0.9rem;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
}

.card {
  overflow: hidden;
}

.card-body {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.form-control, .form-select {
  min-height: 2.75rem;
  border-color: #526679;
  border-radius: 0.6rem;
}

textarea.form-control {
  min-height: 7rem;
}

.form-label {
  font-weight: 600;
  color: #d6e7f0;
}

.btn {
  min-height: 2.65rem;
  padding: 0.55rem 1rem;
  border-radius: 0.6rem;
  font-weight: 600;
}

.btn-sm {
  min-height: 2.3rem;
}

.btn-primary {
  background-color: #135e69;
  border-color: #135e69;
}

.btn-primary:hover, .btn-primary:active {
  background-color: #0d4650;
  border-color: #0d4650;
}

.btn-outline-primary {
  color: #80e3da;
  border-color: #57b9b4;
}

.btn-outline-primary:hover {
  color: #fff;
  background-color: #135e69;
  border-color: #57b9b4;
}

.btn-secondary {
  background-color: #33485b;
  border-color: #536a7e;
  color: #f1f7fb;
}

.btn-secondary:hover {
  background-color: #415c72;
  border-color: #71889a;
  color: #fff;
}

.btn-outline-secondary {
  color: #d4e3ef;
  border-color: #849aae;
}

.btn-outline-secondary:hover {
  color: #fff;
  background-color: #3b5165;
  border-color: #9fb2c3;
}

.btn-outline-danger {
  color: #ffabb4;
  border-color: #db7782;
}

.btn-outline-danger:hover {
  color: #fff;
  background-color: #953f4d;
  border-color: #db7782;
}

details[data-filter-panel] {
  padding: 1rem 1.25rem;
}

details[data-filter-panel] summary {
  cursor: pointer;
}

.defect-table {
  --bs-table-bg: #172333;
  --bs-table-color: #e6eef5;
  --bs-table-striped-bg: #1c2a3b;
  margin-bottom: 0;
}

.defect-table thead th {
  background-color: #243a4c;
  color: #ffffff;
  font-weight: 600;
  padding: 0.85rem 0.7rem;
  vertical-align: middle;
}

.defect-table td {
  padding: 0.8rem 0.7rem;
  border-color: #354758;
}

.column-filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.3rem;
  margin: -0.15rem -0.3rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}

.column-filter-toggle:hover,
.column-filter-toggle[aria-expanded="true"] {
  border-color: #80e3da;
  background: #135e69;
}

.column-filter-toggle svg {
  width: 0.95rem;
  height: 0.95rem;
  fill: none;
  stroke: #b5c4d1;
  stroke-width: 2;
  stroke-linejoin: round;
}

.column-filter-toggle.active svg {
  fill: #80e3da;
  stroke: #80e3da;
}

.column-filter-value {
  display: block;
  margin-top: 0.2rem;
  color: #80e3da;
  font-size: 0.8rem;
  font-weight: 500;
}

.column-filter-popover {
  min-width: 14rem;
  max-width: calc(100vw - 1rem);
  padding: 0.75rem;
  border: 1px solid #526679;
  border-radius: 0.5rem;
  background: #172333;
  color: #e6eef5;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
}

/* Placed under its header by defect-form.js; kept separate so browsers without popover support show it inline. */
.column-filter-popover:popover-open {
  position: fixed;
  inset: auto;
  margin: 0;
}

.column-filter-popover .form-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.defect-table .defect-actions {
  min-width: 15rem;
}

.defect-table .reorder-actions {
  min-width: 12rem;
}

.reorder-handle {
  cursor: grab;
  touch-action: none;
}

.reorder-handle:active {
  cursor: grabbing;
}

.defect-table tr.reorder-target td {
  box-shadow: inset 0 0 0 2px #80e3da;
}

.defect-table tbody tr:hover td {
  background: #26384b;
}

.defect-table .description-cell {
  max-width: 28rem;
  overflow-wrap: anywhere;
}

.required-marker {
  color: #ff9aa9;
  font-weight: 700;
}

.item-number-label {
  color: #b5c4d1;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.item-number-value {
  font-size: 1.6rem;
  font-weight: 700;
  margin-left: 0.35rem;
}

.photo-stack {
  display: grid;
  gap: 1rem;
  max-width: 850px;
}

.photo-card[hidden] {
  display: none;
}

.photo-card summary.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.25rem;
  background: #172333;
  border-bottom: 0;
  color: #f0f8fc;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}

.photo-card summary::-webkit-details-marker {
  display: none;
}

.photo-card summary::after {
  content: '+';
  color: #80e3da;
  font-size: 1.5rem;
  line-height: 1;
}

.photo-card[open] summary::after {
  content: '\2212';
}

.photo-card[open] summary {
  border-bottom: 1px solid #354758;
}

.photo-slot-status {
  margin-left: auto;
  color: #b5c4d1;
  font-size: 0.875rem;
  font-weight: 500;
}

.photo-card .card-header:not(summary) {
  background-color: #243a4c;
  font-weight: 600;
}

.photo-annotation-canvas {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #526679;
  border-radius: 0.25rem;
  cursor: crosshair;
  touch-action: none;
}

.photo-annotation-canvas:focus-visible {
  outline: 3px solid #80e3da;
  outline-offset: 3px;
}

.photo-annotation-stage {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}

.photo-annotation-stage .photo-annotation-canvas {
  width: auto;
  max-width: 100%;
  max-height: 75dvh;
}

.photo-annotation-overlay {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  max-width: calc(100% - 1rem);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.35rem;
  padding: 0.3rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.65rem;
  background: rgba(14, 22, 34, 0.88);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.photo-annotation-overlay .photo-icon-button {
  width: 2.75rem;
  height: 2.75rem;
}

.photo-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.photo-confirm-button {
  border-color: #80e3da;
  background: #135e69;
}

.photo-card summary .camera-upload,
.photo-card summary .photo-add-button {
  margin-left: 0.25rem;
}

/* Camera capture is only offered on touch-first (mobile) devices. */
@media (hover: hover) and (pointer: fine) {
  .camera-upload {
    display: none !important;
  }
}

/* Computers with a mouse pick a file instead of using the camera. */
@media not all and (hover: hover) and (pointer: fine) {
  .photo-add-button {
    display: none !important;
  }
}

.photo-annotation.photo-annotation-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 1090;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 !important;
  padding: 0.75rem;
  overflow: auto;
  background: #0e1622;
  color: #e6eef5;
}

.photo-annotation-fullscreen > .form-text {
  margin: 0;
  text-align: center;
}

.photo-annotation-fullscreen .photo-annotation-stage .photo-annotation-canvas {
  max-height: calc(100dvh - 5.5rem);
}

body.photo-annotation-open {
  overflow: hidden;
}

.photo-preview-shell {
  position: relative;
  display: inline-block;
  max-width: 100%;
  vertical-align: top;
}

.photo-preview {
  display: block;
  max-width: 100%;
  max-height: 16rem;
  height: auto;
  border: 1px solid #526679;
  border-radius: 0.4rem;
}

.photo-preview-actions {
  position: absolute;
  right: 0.5rem;
  bottom: 0.5rem;
  display: flex;
  max-width: calc(100% - 1rem);
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.25rem;
  padding: 0.25rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.65rem;
  background: rgba(14, 22, 34, 0.88);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

.photo-icon-button {
  display: inline-flex;
  width: 2.3rem;
  height: 2.3rem;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
  border: 1px solid #849aae;
  border-radius: 0.55rem;
  background: #243a4c;
  color: #f0f8fc;
  cursor: pointer;
  text-decoration: none;
}

.photo-icon-button:hover,
.photo-icon-button:focus-visible {
  border-color: #80e3da;
  background: #135e69;
  color: #fff;
}

.photo-icon-button svg {
  width: 1.35rem;
  height: 1.35rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.photo-remove-button {
  color: #ffabb4;
}

.photo-remove-input:checked + .photo-remove-button {
  border-color: #db7782;
  background: #953f4d;
  color: #fff;
}

.photo-remove-input:focus-visible + .photo-remove-button {
  outline: 3px solid #80e3da;
  outline-offset: 3px;
}

.photo-fullscreen {
  width: 100vw;
  max-width: 100vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  padding: 1rem;
  border: 0;
  background: #0e1622;
  color: #e6eef5;
}

.photo-fullscreen::backdrop {
  background: #0e1622;
}

.photo-fullscreen-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  gap: 1rem;
}

.photo-fullscreen-close {
  align-self: flex-end;
  margin: 0;
}

.photo-fullscreen-image {
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100% - 4rem);
  object-fit: contain;
}

.description-text {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.page-actions-footer {
  position: fixed;
  z-index: 1020;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.65rem;
  margin: 0;
  padding: 0.45rem 1rem calc(0.45rem + env(safe-area-inset-bottom));
  background: rgba(20, 31, 45, 0.98);
  border-top: 1px solid #526679;
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.3);
}

.page-footer-links,
.page-header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.item-footer-links,
.form-actions-footer {
  width: 100%;
  justify-content: space-between;
}

.defect-list-footer .page-footer-links {
  flex: 1 1 auto;
  justify-content: space-between;
}

.icon-only-button {
  display: inline-flex;
  width: 2.65rem;
  min-width: 2.65rem;
  align-items: center;
  justify-content: center;
  padding: 0.55rem;
}

.icon-only-button svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.defect-pagination {
  display: flex;
  flex: 0 1 auto;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin: 0;
}

.defect-pagination .pagination {
  gap: 0.65rem;
}

.defect-pagination .page-item .page-link {
  min-width: 2.65rem;
  min-height: 2.65rem;
  padding: 0.55rem;
  border: 1px solid #526679;
  border-radius: 0.6rem;
  text-align: center;
}

.defect-pagination .page-item.disabled .page-link {
  color: #b5c4d1;
  background: #172333;
  border-color: #354758;
}

form .row {
  --bs-gutter-x: 1rem;
}

@media (max-width: 767.98px) {
  .app-container {
    padding-inline: 1rem;
  }

  .app-navbar .navbar-collapse {
    padding-block: 0.75rem;
  }

  .app-navbar .navbar-nav {
    gap: 0.2rem;
  }
}

@media (max-width: 1199.98px) {
  .page-actions-footer {
    flex-direction: row;
    align-items: center;
    padding-inline: 0.75rem;
  }

  .defect-list-footer {
    flex-wrap: wrap;
  }

  .defect-list-footer .defect-pagination {
    flex-direction: row;
    flex: 0 1 auto;
    justify-content: flex-start;
    gap: 0.5rem;
    text-align: left;
  }

  .defect-list-footer .pagination {
    gap: 0.35rem;
  }

  .defect-list-footer .page-footer-links {
    justify-content: space-between;
  }

  .defect-table, .defect-table tbody, .defect-table tr, .defect-table td {
    display: block;
    width: 100%;
  }

  .defect-table thead {
    display: none;
  }

  .defect-table, .defect-table tbody {
    background: transparent;
  }

  .defect-table tr {
    margin-bottom: 0.75rem;
    overflow: hidden;
    background: #172333;
    border: 1px solid #354758;
    border-radius: 0.85rem;
  }

  .defect-table tr:last-child {
    margin-bottom: 0;
  }

  .defect-table td {
    display: grid;
    grid-template-columns: minmax(7.5rem, 38%) minmax(0, 1fr);
    gap: 0.5rem;
    padding: 0.55rem 0.85rem;
    overflow-wrap: anywhere;
  }

  .defect-table td::before {
    content: attr(data-label);
    color: #b5c4d1;
    font-weight: 600;
  }

  .defect-table .description-cell {
    max-width: none;
  }

  .defect-table td.defect-actions {
    display: block;
    min-width: 0;
  }

  .defect-table td.defect-actions::before {
    display: block;
    margin-bottom: 0.35rem;
  }

  .mobile-list-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
  }

  .mobile-list-actions[hidden] {
    display: none;
  }

  .compact-defect-list .defect-table tbody tr {
    display: grid;
    grid-template-columns: minmax(2.75rem, auto) minmax(0, 1fr) auto;
    grid-template-areas:
      "number room actions"
      "description description actions";
    align-items: center;
    margin-bottom: 0.35rem;
    padding: 0.2rem 0.35rem;
  }

  .compact-defect-list .defect-table tbody td {
    display: none;
    width: auto;
    min-width: 0;
    padding: 0.35rem 0.45rem;
    border: 0;
  }

  .compact-defect-list .defect-table tbody td::before {
    display: none;
  }

  .compact-defect-list .defect-table td[data-label="Tarion Item ID"] {
    grid-area: number;
    display: block;
    font-weight: 700;
    white-space: nowrap;
  }

  .compact-defect-list .defect-table td[data-label="Room/Area"] {
    grid-area: room;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .compact-defect-list .defect-table td.description-cell {
    grid-area: description;
    display: block;
    overflow: hidden;
    padding-top: 0;
    color: #b5c4d1;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .compact-defect-list .defect-table td.defect-actions {
    grid-area: actions;
    display: block;
    min-width: 0;
    align-self: stretch;
  }

  .compact-defect-list .defect-table td.defect-actions::before {
    display: none;
  }

  .compact-defect-list .defect-table td.defect-actions > div {
    height: 100%;
    flex-wrap: nowrap !important;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem !important;
  }

  .compact-defect-list .defect-table .defect-actions .btn {
    padding: 0.35rem;
  }

}

@media (min-width: 768px) and (max-width: 1199.98px) {
  .defect-table tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .defect-table tbody tr > td {
    width: auto;
  }

  .defect-table td.description-cell,
  .defect-table td[data-label="Photos"],
  .defect-table td.defect-actions {
    grid-column: 1 / -1;
  }
}

@media (max-width: 420px) {
  .defect-list-footer .defect-pagination > span {
    display: none;
  }
}

@media (max-width: 390px) {
  .navbar-brand {
    font-size: 1.05rem;
  }

  .defect-table td {
    grid-template-columns: minmax(6.5rem, 38%) minmax(0, 1fr);
  }
}
