:root {
  --accent: #206bc4;
  --accent-2: #4299e1;
  --shell-bg: #f3f6fb;
  --panel-shadow: 0 24px 60px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(32, 107, 196, 0.12), transparent 36%),
    radial-gradient(circle at bottom right, rgba(66, 153, 225, 0.14), transparent 32%),
    var(--shell-bg);
}

.hidden {
  display: none !important;
}

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-shell {
  width: min(420px, 100%);
  padding: 32px;
  border: 0;
  box-shadow: var(--panel-shadow);
}

.boot-shell {
  text-align: center;
}

.login-brand {
  margin-bottom: 24px;
}

.login-form {
  display: grid;
  gap: 16px;
}

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

.app-sidebar {
  background: linear-gradient(180deg, #162033 0%, #0f172a 100%);
  border-right: 0;
}

.app-sidebar .container-fluid {
  height: 100%;
}

.brand-button {
  border: 0;
  background: transparent;
  color: #fff;
  text-align: left;
  display: grid;
  gap: 2px;
  padding: 0;
}

.brand-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.6);
}

.brand-title {
  font-size: 1.35rem;
  font-weight: 700;
}

.navbar-nav {
  gap: 6px;
}

.nav-btn {
  width: 100%;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 12px;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.nav-btn:hover,
.nav-btn:focus {
  background: rgba(255, 255, 255, 0.08);
}

.nav-btn.active {
  background: rgba(32, 107, 196, 0.2);
  color: #fff;
}

.nav-btn-logout {
  color: #fca5a5;
}

.app-header {
  background: transparent;
}

.shell-page.menu-hidden .app-sidebar {
  display: none !important;
}

.shell-page.menu-hidden .page-wrapper {
  margin-left: 0 !important;
}

.shell-page.modal-open .app-sidebar {
  visibility: hidden;
  pointer-events: none;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 104px;
  padding: 10px 16px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-weight: 700;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

.status-pill.compact {
  min-width: auto;
  padding: 8px 14px;
  font-size: 0.875rem;
}

.panel-card {
  border: 0;
  border-radius: 22px;
  box-shadow: var(--panel-shadow);
}

.panel-card-header {
  border-bottom: 1px solid rgba(15, 23, 42, 0.06);
  padding: 20px 24px 16px;
}

.stack-form {
  display: grid;
  gap: 18px;
}

.section-divider {
  height: 1px;
  background: rgba(15, 23, 42, 0.08);
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #637188;
  margin-bottom: 4px;
}

.check-item {
  min-height: 42px;
  align-items: center;
}

.permission-picker .check-item.form-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-left: 14px;
}

.permission-picker .check-item .form-check-input {
  margin-left: 0;
  margin-top: 0;
  flex: 0 0 auto;
}

.permission-picker .check-item .form-check-label {
  flex: 1 1 auto;
  margin: 0;
}

.vehicle-hint,
.lookup-panel {
  border-radius: 16px;
}

.vehicle-hint {
  padding: 12px 14px;
  background: rgba(32, 107, 196, 0.08);
  color: #1d4ed8;
  font-size: 0.92rem;
}

.lookup-panel {
  padding: 16px;
  border: 1px solid rgba(32, 107, 196, 0.16);
  background: #f8fbff;
}

.lookup-panel.inline {
  margin: 0;
}

.lookup-panel-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #637188;
  margin-bottom: 12px;
}

.lookup-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.lookup-item {
  padding: 12px;
  border-radius: 14px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
}

.lookup-label {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #637188;
  margin-bottom: 6px;
}

.lookup-value {
  color: #0f172a;
  word-break: break-word;
}

.lookup-results {
  display: grid;
  gap: 10px;
}

.lookup-result {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #fff;
  color: #0f172a;
}

.lookup-result:hover {
  border-color: rgba(32, 107, 196, 0.28);
  background: #f3f8ff;
}

.lookup-result-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.lookup-result-meta {
  font-size: 0.85rem;
  color: #637188;
}

.readonly-from-catalog {
  background: #eef6ff !important;
  border-color: rgba(32, 107, 196, 0.28) !important;
}

.camera-box {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: #f8fafc;
  border-radius: 18px;
  padding: 18px;
}

.photo-status {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.camera-view,
.detail-photo {
  width: 100%;
  border-radius: 18px;
  background: #0f172a;
}

.camera-view {
  max-height: 320px;
  object-fit: contain;
}

.detail-photo {
  max-height: 360px;
  object-fit: contain;
  margin-bottom: 16px;
}

.detail-empty {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed rgba(32, 107, 196, 0.35);
  background: #f8fbff;
  color: #637188;
  text-align: center;
}

.action-row,
.modal-actions,
.camera-stage-actions,
.list-actions,
.ftp-wrap {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.contact-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.action-row {
  align-items: center;
}

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

.stats-grid-wide {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.stat-box {
  padding: 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, #fff 0%, #f8fbff 100%);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.stat-value {
  font-size: clamp(1.7rem, 3vw, 2.4rem);
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  margin-top: 6px;
  color: #637188;
}

.list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.list li {
  padding: 14px 16px;
  border-radius: 16px;
  background: #f8fafc;
  border: 1px solid rgba(15, 23, 42, 0.06);
  cursor: pointer;
}

.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.list-info {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}

.checklist-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.check-tag {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(15, 23, 42, 0.1);
  background: #fff;
  font-size: 0.8rem;
}

.check-tag.is-alert {
  color: #b42318;
  background: #fef3f2;
  border-color: rgba(180, 35, 24, 0.22);
  font-weight: 700;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
}

.modal-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 0;
  border-radius: 22px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.24);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.modal-body {
  margin-top: 16px;
}

#userEditModal {
  z-index: 120;
  padding: 20px;
  align-items: flex-start;
  overflow-y: auto;
}

#userEditModal .modal-card {
  width: min(1120px, calc(100vw - 40px));
  max-height: none;
  margin: 8px auto 24px;
}

#userEditModal .modal-header {
  position: sticky;
  top: 0;
  z-index: 2;
  margin: 0;
  padding: 20px 24px 16px;
  background: #fff;
  border-bottom: 1px solid rgba(15, 23, 42, 0.08);
}

#userEditModal .modal-body {
  margin-top: 0;
  padding: 20px 24px 24px;
}

#userEditModal .modal-actions {
  justify-content: flex-end;
}

#userEditModal .permission-picker {
  row-gap: 12px;
}

#userEditModal .check-item {
  min-height: 54px;
  display: flex;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 16px;
  background: #f8fafc;
}

#userEditModal .check-item .form-check-input {
  margin-top: 0;
}

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

.detail-span {
  grid-column: 1 / -1;
}

.detail-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #637188;
  margin-bottom: 4px;
}

.foot {
  text-align: center;
  color: #637188;
  padding: 18px;
}

.camera-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  padding: 18px;
  background: rgba(15, 23, 42, 0.82);
}

.camera-overlay.ticket-mode {
  padding: 12px;
}

.camera-overlay.photo-mode {
  padding: 18px;
}

.camera-stage {
  width: min(1120px, 100%);
  height: min(94vh, 760px);
  margin: 0 auto;
  border: 0;
  border-radius: 24px;
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: 16px;
  background: #07101d;
  color: #fff;
}

.camera-overlay.ticket-mode .camera-stage {
  width: min(560px, 100%);
  height: min(92vh, 860px);
}

.camera-stage-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.camera-stage-body {
  min-height: 0;
}

.camera-overlay.ticket-mode .camera-stage-body {
  display: flex;
  align-items: stretch;
}

.camera-stage-view {
  width: 100%;
  height: 100%;
  min-height: 280px;
  border-radius: 18px;
  object-fit: cover;
  background: #000;
}

.camera-overlay.ticket-mode .camera-stage-view {
  min-height: 420px;
  aspect-ratio: 3 / 4;
}

.camera-stage-status {
  text-align: center;
  color: rgba(255, 255, 255, 0.82);
}

.error {
  color: #d63939;
}

@media (max-width: 991.98px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .app-sidebar .navbar-collapse {
    padding-bottom: 16px;
  }

  .shell-page.menu-hidden .app-sidebar {
    display: none !important;
  }
}

@media (max-width: 720px) {
  .login-screen {
    padding: 16px;
  }

  .login-shell {
    padding: 24px;
  }

  .page-body .container-xl,
  .app-header .container-xl {
    padding-left: 12px;
    padding-right: 12px;
  }

  .panel-card-header,
  .card-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .stats-grid,
  .stats-grid-wide,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .list-row {
    flex-direction: column;
    align-items: stretch;
  }

  .list-actions {
    justify-content: flex-end;
  }

  .action-row,
  .modal-actions,
  .camera-stage-actions,
  .ftp-wrap {
    flex-direction: column;
  }

  .action-row .btn,
  .modal-actions .btn,
  .camera-stage-actions .btn,
  .ftp-wrap .btn {
    width: 100%;
  }

  .modal {
    padding: 12px;
    align-items: flex-start;
  }

  .modal-card {
    max-height: calc(100vh - 24px);
  }

  #userEditModal {
    padding: 12px;
  }

  #userEditModal .modal-card {
    width: min(100%, calc(100vw - 24px));
    margin: 0 auto 12px;
  }

  #userEditModal .modal-header,
  #userEditModal .modal-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .camera-stage {
    height: calc(100vh - 36px);
    padding: 16px;
  }

  .camera-overlay.photo-mode {
    padding: 0;
  }

  .camera-overlay.ticket-mode .camera-stage {
    height: calc(100vh - 24px);
    padding: 14px;
  }

  .camera-stage-head {
    align-items: flex-start;
  }

  .camera-overlay.ticket-mode .camera-stage-view {
    min-height: 360px;
  }
}

@media (max-width: 720px) and (orientation: portrait) {
  .camera-overlay.photo-mode .camera-stage {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100vh;
    height: 100vw;
    max-width: none;
    max-height: none;
    padding: 18px;
    border-radius: 0;
    transform: translate(-50%, -50%) rotate(90deg);
    transform-origin: center;
  }

  .camera-overlay.photo-mode .camera-stage-view {
    min-height: 0;
  }
}
