:root {
  --app-bg: #f3f6fa;
  --app-primary: #165dff;
}

body {
  background: var(--app-bg);
  color: #172033;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1 0 auto;
}

.navbar-brand,
.nav-link.active {
  color: var(--app-primary) !important;
}

.nav-link.active {
  font-weight: 700;
}

.card {
  border-radius: 1rem;
}

.form-control,
.input-group-text,
.btn {
  border-radius: .65rem;
}

.input-group > .form-control {
  border-radius: .65rem 0 0 .65rem;
}

.input-group > .input-group-text {
  border-radius: 0 .65rem .65rem 0;
}

.table thead th {
  background: #f8fafc;
  color: #516076;
  font-size: .82rem;
  font-weight: 700;
  white-space: nowrap;
}

.table td,
.table th {
  padding: .9rem .8rem;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
  background:
    radial-gradient(circle at top left, rgba(22, 93, 255, .22), transparent 42%),
    linear-gradient(135deg, #eef4ff, #f8fafc);
}

.login-card {
  width: min(100%, 430px);
  border-radius: 1.4rem;
}

.brand-mark {
  width: 3.5rem;
  height: 3.5rem;
  display: grid;
  place-items: center;
  border-radius: 1rem;
  background: var(--app-primary);
  color: white;
  font-weight: 800;
  letter-spacing: .08em;
}

.chart-wrap {
  min-height: 320px;
  position: relative;
}

.print-only {
  display: none;
}

.app-footer {
  flex-shrink: 0;
  font-size: .9rem;
}

.app-footer a {
  color: var(--app-primary);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

.environment-badge {
  background: #eef4ff;
  border: 1px solid #cbdcff;
  border-radius: 999px;
  color: #1749a5;
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  padding: .25rem .65rem;
}

.manual-nav {
  position: sticky;
  top: 5.5rem;
}

.manual-nav .nav-link {
  color: #516076;
}

.manual-nav .nav-link:hover {
  background: #eef4ff;
  color: var(--app-primary);
}

.manual-section {
  scroll-margin-top: 5.5rem;
}

.manual-steps,
.manual-list {
  line-height: 1.8;
  padding-left: 1.35rem;
}

.manual-help dt {
  font-weight: 700;
  margin-top: 1rem;
}

.manual-help dt:first-child {
  margin-top: 0;
}

.manual-help dd {
  color: #516076;
  margin: .35rem 0 0;
}

.time-picker-trigger {
  background-color: white;
  cursor: pointer;
}

.time-option-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: .5rem;
}

.minute-options {
  grid-template-columns: repeat(4, 1fr);
}

.time-option {
  padding-left: .5rem;
  padding-right: .5rem;
}

.camera-preview {
  aspect-ratio: 4 / 3;
  background: #111827;
  border-radius: 1rem;
  overflow: hidden;
  position: relative;
}

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

.camera-guide {
  position: absolute;
  inset: 22%;
  border: 3px solid rgba(255, 255, 255, .9);
  border-radius: .75rem;
  box-shadow: 0 0 0 999px rgba(0, 0, 0, .2);
}

.camera-fallback-reader {
  background: #111827;
  border-radius: 1rem;
  overflow: hidden;
}

.camera-fallback-reader video {
  max-height: min(60vh, 480px);
  object-fit: cover;
}

@media (max-width: 767.98px) {
  main.container-fluid {
    padding-left: .75rem;
    padding-right: .75rem;
  }

  .card-body.p-4 {
    padding: 1rem !important;
  }

  .mobile-filter-form {
    width: 100%;
  }

  .mobile-card-table thead {
    display: none;
  }

  .mobile-card-table,
  .mobile-card-table tbody,
  .mobile-card-table tr,
  .mobile-card-table td {
    display: block;
    width: 100%;
  }

  .mobile-card-table {
    background: transparent;
    padding: .75rem;
  }

  .mobile-card-table tbody tr {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: .85rem;
    box-shadow: 0 .25rem .75rem rgba(15, 23, 42, .05);
    margin-bottom: .75rem;
    overflow: hidden;
  }

  .mobile-card-table tbody tr.table-warning-subtle {
    background: #fff8db;
  }

  .mobile-card-table td {
    border: 0;
    border-bottom: 1px solid #eef2f7;
    display: grid;
    grid-template-columns: minmax(6.5rem, 38%) 1fr;
    gap: .75rem;
    padding: .65rem .8rem;
    text-align: left !important;
    white-space: normal !important;
    word-break: break-word;
  }

  .mobile-card-table td::before {
    color: #64748b;
    content: attr(data-label);
    font-size: .78rem;
    font-weight: 700;
  }

  .mobile-card-table td:last-child {
    border-bottom: 0;
  }

  .mobile-card-table td[colspan] {
    display: block;
    text-align: center !important;
  }

  .mobile-card-table td[colspan]::before {
    display: none;
  }

  .mobile-actions {
    align-items: center;
  }

  .mobile-action-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
  }

  .time-option-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media print {
  @page {
    margin: 12mm;
    size: A4 landscape;
  }

  body {
    background: white;
    color: black;
    font-size: 10pt;
  }

  nav,
  .print-hide,
  .modal,
  .alert {
    display: none !important;
  }

  main.container-fluid {
    padding: 0 !important;
  }

  .print-only {
    display: block;
  }

  .print-heading {
    border-bottom: 2px solid #222;
    margin-bottom: 1rem;
    padding-bottom: .5rem;
  }

  .print-heading h1 {
    font-size: 18pt;
    margin: 0 0 .25rem;
  }

  .print-heading p {
    margin: 0;
  }

  .card {
    break-inside: avoid;
    border: 1px solid #bbb !important;
    box-shadow: none !important;
  }

  .table-responsive {
    overflow: visible !important;
  }

  .mobile-card-table {
    display: table;
    padding: 0;
  }

  .mobile-card-table thead {
    display: table-header-group;
  }

  .mobile-card-table tbody {
    display: table-row-group;
  }

  .mobile-card-table tr {
    display: table-row;
  }

  .mobile-card-table td,
  .mobile-card-table th {
    display: table-cell;
    width: auto;
  }

  .mobile-card-table td::before {
    display: none;
  }

  .table td,
  .table th {
    padding: .45rem .5rem;
  }

  .chart-wrap {
    min-height: 260px;
  }

  .manual-layout > aside {
    display: none !important;
  }

  .manual-layout > .col-lg-9 {
    width: 100%;
  }

  .manual-section {
    break-inside: auto;
    margin-bottom: 1rem !important;
  }
}
